From: Owen Leonard <owen@balawis.leonard.fam>
Date: Sat, 30 Oct 2010 04:48:21 +0000 (-0600)
Subject: change supervisor field in tc_district and tc_district_sandbox to leader
X-Git-Url: http://git.pippins.net/%27%20.%20%24this-%3Ephpgw_js_url%20.%20%27/jscalendar/images/checkmark.gif?a=commitdiff_plain;h=6164e3a3c2d19b4e1d718ccafd7dddf6da27d270;p=eq%2F.git

change supervisor field in tc_district and tc_district_sandbox to leader
---

diff --git a/bin/import_ward_data b/bin/import_ward_data
index 3f08fc0..ae20ab7 100755
--- a/bin/import_ward_data
+++ b/bin/import_ward_data
@@ -310,7 +310,7 @@ sub update_tc_companionship_table
 		for my $companion (keys %{$companionships->{$companionship}->{'companions'}}) {
 			#print "companion = $companion\n";
 			# see if $companion is in tc_companion
-			$sth = $dbh->prepare("SELECT * FROM tc_companion AS tc JOIN (tc_individual AS ti, tc_companionship AS tp) WHERE tc.individual=ti.individual AND tc.companionship=tp.companionship AND tp.mls_id=$companionship AND ti.name='$companion' COLLATE latin1_general_cs AND tc.valid=1");
+			$sth = $dbh->prepare("SELECT * FROM tc_companion AS tc JOIN (tc_individual AS ti, tc_companionship AS tp) WHERE tc.individual=ti.individual AND tc.companionship=tp.companionship AND tp.mls_id=$companionship AND ti.name='$companion' COLLATE latin1_general_cs AND tp.type='H' AND tc.valid=1");
 			$sth->execute or die "-E- DB error: $DBI::errstr\n";
 			my @data = ();
 			while($sqlhashref = $sth->fetchrow_hashref) { push(@data, $sqlhashref); }
@@ -357,7 +357,7 @@ sub update_tc_companionship_table
 			# loop through families from HomeTeaching.csv
 			for my $family (keys %{$companionships->{$companionship}->{'families'}}) {
 				#print "SELECT * FROM tc_family AS tf JOIN (tc_companionship AS tc, tc_individual AS ti) WHERE tf.companionship=tc.companionship AND tf.individual=ti.individual AND ti.name=\"$family\" COLLATE latin1_general_cs AND tf.valid=1\n";
-				$sth = $dbh->prepare("SELECT * FROM tc_family AS tf JOIN (tc_companionship AS tc, tc_individual AS ti) WHERE tf.companionship=tc.companionship AND tf.individual=ti.individual AND ti.name=\"$family\" COLLATE latin1_general_cs AND tf.valid=1");
+				$sth = $dbh->prepare("SELECT * FROM tc_family AS tf JOIN (tc_companionship AS tc, tc_individual AS ti) WHERE tf.companionship=tc.companionship AND tf.individual=ti.individual AND ti.name=\"$family\" COLLATE latin1_general_cs AND tc.type='H' AND tf.valid=1");
 				$sth->execute or die "-E- DB error: $DBI::errstr\n";
 				# if family isn't in tc_family table, we have a change
 				# if family in tc_family has a different companionship assigned to it, we have a change
@@ -379,12 +379,12 @@ sub update_tc_companionship_table
 		if ($changed == 1) {
 			# invalidate existing companionship in database
 			print "   invalidating companionship:$tc_companionship_id\n";
-			$sth = $dbh->prepare("UPDATE tc_companionship SET valid=0 WHERE companionship='$tc_companionship_id'");
+			$sth = $dbh->prepare("UPDATE tc_companionship SET valid=0 WHERE companionship='$tc_companionship_id' AND type='H'");
 			$sth->execute or die "-E- DB error: $DBI::errstr\n";
 			
 			# create new companionship in database
 			print "   creating a new companionship\n";
-			$sth = $dbh->prepare("INSERT INTO tc_companionship values (NULL,$companionship,$district,1)");
+			$sth = $dbh->prepare("INSERT INTO tc_companionship values (NULL,$companionship,$district,'H',1)");
 			$sth->execute or die "-E- DB error: $DBI::errstr\n";
 			$comp_id = $dbh->last_insert_id(NULL,NULL,'tc_companionship',NULL);
 			
@@ -393,7 +393,7 @@ sub update_tc_companionship_table
 				print "   companion=$companion\n";
 				# if companion exists, preserve scheduling_priority
 				#print "SELECT tc.* FROM tc_companion AS tc JOIN (tc_individual AS ti, tc_companionship AS tp) WHERE tc.individual=ti.individual AND tc.companionship=tp.companionship AND tp.mls_id=$companionship AND ti.name=\"$companion\" AND tc.valid=1\n";
-				$sth = $dbh->prepare("SELECT tc.* FROM tc_companion AS tc JOIN (tc_individual AS ti, tc_companionship AS tp) WHERE tc.individual=ti.individual AND tc.companionship=tp.companionship AND tp.mls_id=$companionship AND ti.name=\"$companion\" AND tc.valid=1");
+				$sth = $dbh->prepare("SELECT tc.* FROM tc_companion AS tc JOIN (tc_individual AS ti, tc_companionship AS tp) WHERE tc.individual=ti.individual AND tc.companionship=tp.companionship AND tp.mls_id=$companionship AND ti.name=\"$companion\" AND tp.type='H' AND tc.valid=1");
 				$sth->execute or die "-E- DB error: $DBI::errstr\n";
 				if ($sqlhashref = $sth->fetchrow_hashref) {
 					my $individual = $sqlhashref->{'individual'};
diff --git a/bin/upgrade_1_1_0_to_1_1_1 b/bin/upgrade_1_1_0_to_1_1_1
index 9bb7ff6..9424728 100755
--- a/bin/upgrade_1_1_0_to_1_1_1
+++ b/bin/upgrade_1_1_0_to_1_1_1
@@ -36,6 +36,18 @@ $sth->execute or die "-E- DB error: $DBI::errstr\n";
 $sth = $dbh->prepare("ALTER TABLE `tc_visit` DROP `visit_type` ");
 $sth->execute or die "-E- DB error: $DBI::errstr\n";
 
+# add type field to tc_companionship
+$sth = $dbh->prepare("ALTER TABLE `tc_companionship` ADD `type` ENUM( 'H', 'P' ) NOT NULL DEFAULT 'H' AFTER `district`");
+$sth->execute or die "-E- DB error: $DBI::errstr\n";
+
+# rename supervisor field in tc_district to leader
+$sth = $dbh->prepare("ALTER TABLE `tc_district` CHANGE `supervisor` `leader` INT( 16 ) UNSIGNED NULL DEFAULT NULL");
+$sth->execute or die "-E- DB error: $DBI::errstr\n";
+
+# rename supervisor field in tc_district_sandbox to leader
+$sth = $dbh->prepare("ALTER TABLE `tc_district_sandbox` CHANGE `supervisor` `leader` INT( 16 ) UNSIGNED NULL DEFAULT NULL");
+$sth->execute or die "-E- DB error: $DBI::errstr\n";
+
 print "-> Done!\n";
 
 ###################################################
diff --git a/inc/class.tc.inc.php b/inc/class.tc.inc.php
index 05b2a52..57a3f3a 100644
--- a/inc/class.tc.inc.php
+++ b/inc/class.tc.inc.php
@@ -228,13 +228,13 @@ class tc
 		$this->t->set_var('ht_sandbox_link',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.ht_sandbox'));
 		$this->t->set_var('ht_sandbox_link_title','Hometeaching Sandbox'); 
 
-		$sql = "SELECT * FROM tc_district AS td JOIN tc_individual AS ti WHERE td.supervisor=ti.individual AND td.valid=1 ORDER BY td.district ASC";
+		$sql = "SELECT * FROM tc_district AS td JOIN tc_individual AS ti WHERE td.leader=ti.individual AND td.valid=1 ORDER BY td.district ASC";
 		$this->db->query($sql,__LINE__,__FILE__);
 		$i=0;
 		while ($this->db->next_record()) {
 			$districts[$i]['district'] = $this->db->f('district');
 			$districts[$i]['name'] = $this->db->f('name');
-			$districts[$i]['supervisor'] = $this->db->f('supervisor');
+			$districts[$i]['leader'] = $this->db->f('leader');
 			$i++;
 		}
 
@@ -260,10 +260,10 @@ class tc
 		for ($i=0; $i < count($districts); $i++) {
 			$this->t->set_var('district_number',$districts[$i]['district']);
 			$this->t->set_var('district_name',$districts[$i]['name']);	
-			$supervisor = $districts[$i]['supervisor'];
+			$leader = $districts[$i]['leader'];
 
 			// Select all the unique companionship numbers for this district
-			$sql = "SELECT distinct companionship FROM tc_companionship where valid=1 and district=". $districts[$i]['district'];
+			$sql = "SELECT DISTINCT companionship FROM tc_companionship WHERE type='H' AND valid=1 AND district=". $districts[$i]['district'];
 			$this->db->query($sql,__LINE__,__FILE__);
 			$j=0; $unique_companionships = '';
 			while ($this->db->next_record()) {
@@ -539,13 +539,13 @@ class tc
 			$this->db->query($sql,__LINE__,__FILE__);
 			while ($this->db->next_record()) {
 				$district = $this->db->f('district');
-				$supervisor = $this->db->f('supervisor');
-				$sql = "INSERT INTO tc_district_sandbox (district,supervisor) VALUES (\"$district\",\"$supervisor\")";
+				$leader = $this->db->f('leader');
+				$sql = "INSERT INTO tc_district_sandbox (district,leader) VALUES (\"$district\",\"$leader\")";
 				$this->db2->query($sql,__LINE__,__FILE__);
 			}
 			
 			# populate family, companion, and companionship tables
-			$sql = "SELECT * FROM tc_companionship WHERE valid=1";
+			$sql = "SELECT * FROM tc_companionship WHERE type='H' AND valid=1";
 			$this->db->query($sql,__LINE__,__FILE__);
 			while ($this->db->next_record()) {
 				$companionship = $this->db->f('companionship');
@@ -758,7 +758,7 @@ class tc
 		$email_contents = "Please review the following changes to home teaching.\r\n\r\n";
 		// list all companionships deleted
 		$email_contents .= "Removed Companionships\r\n\r\n";
-		$sql = "SELECT * FROM tc_companionship WHERE companionship NOT IN (SELECT tc_companionship FROM tc_companionship_sandbox) AND valid=1";
+		$sql = "SELECT * FROM tc_companionship WHERE companionship NOT IN (SELECT tc_companionship FROM tc_companionship_sandbox) AND type='H' AND valid=1";
 		$this->db->query($sql,__LINE__,__FILE__);
 		while ($this->db->next_record()) {
 			$companionship = $this->db->f('companionship');
@@ -804,7 +804,7 @@ class tc
 		
 		// list all companionships with changes
 		$email_contents .= "Modified Companionships\r\n\r\n";
-		$sql = "SELECT tcps.* FROM tc_companionship AS tc JOIN tc_companionship_sandbox AS tcps WHERE tc.companionship=tcps.tc_companionship AND tc.valid=1";
+		$sql = "SELECT tcps.* FROM tc_companionship AS tc JOIN tc_companionship_sandbox AS tcps WHERE tc.companionship=tcps.tc_companionship AND tc.type='H' AND tc.valid=1";
 		$this->db->query($sql,__LINE__,__FILE__);
 		while ($this->db->next_record()) {
 			$companionship = $this->db->f('companionship');
@@ -933,7 +933,7 @@ class tc
 
 		if($action == 'save') {
 			// Get a list of all the companionships in this district
-			$sql = "SELECT distinct companionship FROM tc_companionship where valid=1 and district=". $district;
+			$sql = "SELECT DISTINCT companionship FROM tc_companionship WHERE type='H' AND valid=1 AND district=". $district;
 			$this->db->query($sql,__LINE__,__FILE__);
 			$j=0; $unique_companionships = '';
 			while ($this->db->next_record()) {
@@ -986,7 +986,7 @@ class tc
 		}      
 
 		// Select all the unique companionship numbers for this district
-		$sql = "SELECT distinct companionship FROM tc_companionship where valid=1 and district=". $district;
+		$sql = "SELECT DISTINCT companionship FROM tc_companionship WHERE type='H' AND valid=1 AND district=". $district;
 		$this->db->query($sql,__LINE__,__FILE__);
 		$j=0; $unique_companionships = '';
 		while ($this->db->next_record()) {
@@ -999,8 +999,7 @@ class tc
 		for ($j=0; $j < count($unique_companionships); $j++) {
 			$companion_table_entry = "";
 			// Select all the companions in each companionship
-			$sql = "SELECT * FROM tc_companionship where valid=1 and ".
-			"companionship=". $unique_companionships[$j]['companionship'];
+			$sql = "SELECT * FROM tc_companionship WHERE type='H' AND valid=1 AND companionship=". $unique_companionships[$j]['companionship'];
 			$this->db->query($sql,__LINE__,__FILE__);
 
 			while ($this->db->next_record()) {
@@ -2214,7 +2213,7 @@ class tc
 			$i++;
 		}
 		// add any YM that are home teachers
-		$sql = "SELECT * FROM tc_companionship where valid=1";
+		$sql = "SELECT * FROM tc_companionship WHERE type='H' AND valid=1";
 		$this->db->query($sql,__LINE__,__FILE__);
 		while ($this->db->next_record()) {
 			$tmp_individual = $this->db->f('individual');
@@ -2238,15 +2237,15 @@ class tc
 					$appointment = $entry['appointment'];
 					$location = $entry['location'];
 					if($location == "") {
-						$supervisor = $entry['supervisor'];
-						$supervisor_array = explode(",", $individ2name[$supervisor]);
-						$supervisor_last_name = $supervisor_array[0];
-						$sql = "SELECT * FROM tc_individual where individual='$supervisor'";
+						$leader = $entry['leader'];
+						$leader_array = explode(",", $individ2name[$leader]);
+						$leader_last_name = $leader_array[0];
+						$sql = "SELECT * FROM tc_individual where individual='$leader'";
 						$this->db2->query($sql,__LINE__,__FILE__);
 						if($this->db2->next_record()) {
-							$supervisor_address = $this->db2->f('address');
+							$leader_address = $this->db2->f('address');
 						}
-						$location = "$supervisor_last_name"." home ($supervisor_address)";
+						$location = "$leader_last_name"." home ($leader_address)";
 					}
 					if($indiv == 0) { $location = ""; }
 
@@ -2288,14 +2287,14 @@ class tc
 		}
 
 		// Get the Districts
-		$sql = "SELECT * FROM tc_district AS td JOIN (tc_presidency AS tp, tc_individual AS ti) WHERE td.district=tp.district AND td.supervisor=ti.individual AND td.valid=1 ORDER BY td.district ASC";
+		$sql = "SELECT * FROM tc_district AS td JOIN (tc_presidency AS tp, tc_individual AS ti) WHERE td.district=tp.district AND td.leader=ti.individual AND td.valid=1 ORDER BY td.district ASC";
 		$this->db->query($sql,__LINE__,__FILE__);
 		$i=0;
 		while ($this->db->next_record()) {
 			$district = $this->db->f('district');
 			$districts[$i]['district'] = $this->db->f('district');
 			$districts[$i]['name'] = $this->db->f('name');
-			$districts[$i]['supervisor'] = $this->db->f('supervisor');
+			$districts[$i]['leader'] = $this->db->f('leader');
 			$districts[$i]['presidency'] = $this->db->f('presidency');
 			$i++;
 		}
@@ -2315,15 +2314,15 @@ class tc
 			$table_data=""; $appt_table_data="";
 			$this->t->set_var('district_number',$districts[$d]['district']);
 			$this->t->set_var('district_name',$districts[$d]['name']);	
-			$supervisor = $districts[$d]['supervisor'];
-			$supervisor_array = explode(",", $supervisor);
-			$supervisor_last_name = $supervisor_array[0];
-			$sql = "SELECT * FROM tc_individual where individual='$supervisor'";
+			$leader = $districts[$d]['leader'];
+			$leader_array = explode(",", $leader);
+			$leader_last_name = $leader_array[0];
+			$sql = "SELECT * FROM tc_individual where individual='$leader'";
 			$this->db2->query($sql,__LINE__,__FILE__);
 			if($this->db2->next_record()) {
-				$supervisor_address = $this->db2->f('address');
+				$leader_address = $this->db2->f('address');
 			}
-			$location = "$supervisor_last_name"." home ($supervisor_address)";
+			$location = "$leader_last_name"." home ($leader_address)";
 			$table_title = "District ".$districts[$d]['district'].": ".$districts[$d]['name'].": All Individuals with Interviews Not Completed";
 			$appt_table_title = "District ".$districts[$d]['district'].": ".$districts[$d]['name'].": Interview Appointment Slots";
 			$this->t->set_var('table_title',$table_title);
@@ -2337,7 +2336,7 @@ class tc
 				$appointment = $this->db->f('appointment');
 				$indiv = $this->db->f('individual');
 				$location = $this->db->f('location');
-				if(($location == "") && ($indiv > 0)) { $location = "$supervisor_last_name"." home ($supervisor_address)"; }
+				if(($location == "") && ($indiv > 0)) { $location = "$leader_last_name"." home ($leader_address)"; }
 
 				$date = $this->db->f('date');
 				$date_array = explode("-",$date);
@@ -2370,7 +2369,7 @@ class tc
 				$appt_table_data.= 'name="appt_notes['.$appointment.'][location]" value="'.$location.'">';
 
 				$appt_table_data.= '<input type=hidden name="appt_notes['.$appointment.'][appointment]" value="'.$appointment.'">';
-				$appt_table_data.= '<input type=hidden name="appt_notes['.$appointment.'][supervisor]" value="'.$supervisor.'">';
+				$appt_table_data.= '<input type=hidden name="appt_notes['.$appointment.'][leader]" value="'.$leader.'">';
 
 				$tr_color = $this->nextmatchs->alternate_row_color($tr_color);
 				$this->t->set_var('tr_color',$tr_color);
@@ -2382,7 +2381,7 @@ class tc
 			// INTERVIEW SCHEDULING TABLE
 
 			// Select all the unique companionship numbers for this district
-			$sql = "SELECT distinct companionship FROM tc_companionship where valid=1 and district=". $districts[$d]['district'];
+			$sql = "SELECT DISTINCT companionship FROM tc_companionship WHERE type='H' AND valid=1 AND district=". $districts[$d]['district'];
 			$this->db->query($sql,__LINE__,__FILE__);
 			$j=0; $unique_companionships = '';
 			while ($this->db->next_record())
@@ -2444,7 +2443,7 @@ class tc
 						$link_data['interview'] = '';
 						$link_data['action'] = 'add';
 						$link_data['type'] = 'H';
-						$link_data['interviewer'] = $districts[$d]['supervisor'];
+						$link_data['interviewer'] = $districts[$d]['leader'];
 						$link = $GLOBALS['phpgw']->link('/tc/index.php',$link_data);
 						$table_data.= "<tr bgcolor=". $this->t->get_var('tr_color') ."><td title=\"$phone\"><a href=$link>$name</a></td>";
 						$table_data.= "<td align=center>$phone</td>";
@@ -3092,13 +3091,13 @@ class tc
 		else if($current_month >= 7 && $current_month <= 9) { $current_month=9; }
 		else if($current_month >= 10 && $current_month <= 12) { $current_month=12; }
 
-		$sql = "SELECT * FROM tc_district AS td JOIN tc_individual AS ti WHERE td.supervisor=ti.individual AND td.valid=1 ORDER BY td.district ASC";
+		$sql = "SELECT * FROM tc_district AS td JOIN tc_individual AS ti WHERE td.leader=ti.individual AND td.valid=1 ORDER BY td.district ASC";
 		$this->db->query($sql,__LINE__,__FILE__);
 		$i=0;
 		while ($this->db->next_record()) {
 			$districts[$i]['district'] = $this->db->f('district');
 			$districts[$i]['name'] = $this->db->f('name');
-			$districts[$i]['supervisor'] = $this->db->f('supervisor');
+			$districts[$i]['leader'] = $this->db->f('leader');
 			$i++;
 		}
 
@@ -3122,10 +3121,10 @@ class tc
 		for ($i=0; $i < count($districts); $i++) {
 			$this->t->set_var('district_number',$districts[$i]['district']);
 			$this->t->set_var('district_name',$districts[$i]['name']);	
-			$supervisor = $districts[$i]['supervisor'];
+			$leader = $districts[$i]['leader'];
 
 			// Select all the unique companionship numbers for this district
-			$sql = "SELECT distinct companionship FROM tc_companionship where valid=1 and district=". $districts[$i]['district'];
+			$sql = "SELECT DISTINCT companionship FROM tc_companionship WHERE type='H' AND valid=1 AND district=". $districts[$i]['district'];
 			$this->db->query($sql,__LINE__,__FILE__);
 			$j=0; $unique_companionships = '';
 			while ($this->db->next_record()) {
@@ -3153,7 +3152,7 @@ class tc
 					$phone = $indiv_phone[$individual];
 					$link_data['menuaction'] = 'tc.tc.int_update';
 					$link_data['companionship'] = $companionship;
-					$link_data['interviewer'] = $supervisor;
+					$link_data['interviewer'] = $leader;
 					$link_data['individual'] = $individual;
 					$link_data['name'] = $name;
 					$link_data['interview'] = '';
@@ -4058,15 +4057,15 @@ class tc
 							$family_address = $familyid2address[$family];
 							$location = "$family_last_name"." home ($family_address)";
 						} else if($indiv > 0) {
-							$supervisor_name_array = explode(",",$presidency2name[$presidency]);
-							$supervisor_last_name = $supervisor_name_array[0];
+							$leader_name_array = explode(",",$presidency2name[$presidency]);
+							$leader_last_name = $leader_name_array[0];
 							#print "presidency2indiv: $presidency $presidency2indiv[$presidency]<br>";
 							$sql = "SELECT * FROM tc_individual where individual='$presidency2indiv[$presidency]'";
 							$this->db2->query($sql,__LINE__,__FILE__);
 							if($this->db2->next_record()) {
-								$supervisor_address = $this->db2->f('address');
+								$leader_address = $this->db2->f('address');
 							}
-							$location = "$supervisor_last_name"." home ($supervisor_address)";
+							$location = "$leader_last_name"." home ($leader_address)";
 						}
 					}
 
@@ -4207,14 +4206,14 @@ class tc
 						$family_address = $familyid2address[$family];
 						$location = "$family_last_name"." home ($family_address)";
 					} else if($indiv > 0) {
-						$supervisor_name_array = explode(",",$presidency2name[$presidency]);
-						$supervisor_last_name = $supervisor_name_array[0];
+						$leader_name_array = explode(",",$presidency2name[$presidency]);
+						$leader_last_name = $leader_name_array[0];
 						$sql = "SELECT * FROM tc_individual where individual='$presidency2indiv[$presidency]'";
 						$this->db2->query($sql,__LINE__,__FILE__);
 						if($this->db2->next_record()) {
-							$supervisor_address = $this->db2->f('address');
+							$leader_address = $this->db2->f('address');
 						}
-						$location = "$supervisor_last_name"." home ($supervisor_address)";
+						$location = "$leader_last_name"." home ($leader_address)";
 					}
 				}
 
@@ -4563,7 +4562,7 @@ class tc
 			$name = "High Priests";
 			$indiv = 0;
 			$valid = 0;
-			$this->db2->query("INSERT INTO tc_district (district,supervisor,valid) " .
+			$this->db2->query("INSERT INTO tc_district (district,leader,valid) " .
 			                  "VALUES ('" . $district . "','" . 
 			                  $indiv . "','" . $valid . "'" .
 			                  ")",__LINE__,__FILE__);
@@ -4581,7 +4580,7 @@ class tc
 
 				// If we have a valid district, add it to the district table
 				if($district > 0) {
-					$this->db2->query("INSERT INTO tc_district (district,supervisor,valid) " .
+					$this->db2->query("INSERT INTO tc_district (district,leader,valid) " .
 					                  "VALUES ('" . $district . "','" . 
 					                  $indiv . "','" . $valid . "'" .
 					                  ")",__LINE__,__FILE__);
diff --git a/sql/schema.dot b/sql/schema.dot
index 9f5e512..cbd156a 100644
--- a/sql/schema.dot
+++ b/sql/schema.dot
@@ -27,11 +27,11 @@ digraph schema {
     shape = "record"
   ];
   companionship   [
-    label = "companionship||<c> companionship|<d> district|<v> valid"
+    label = "companionship||<c> companionship|<d> district|<t> type|<v> valid"
     shape = "record"
   ];
   district      [
-    label = "district||<d> district|<s> supervisor|<v> valid"
+    label = "district||<d> district|<l> leader|<v> valid"
     shape = "record"
   ];
   individual   [
@@ -83,7 +83,7 @@ digraph schema {
     shape = "record"
   ];
   district_sandbox   [
-    label = "district_sandbox||<d> district|<s> supervisor"
+    label = "district_sandbox||<d> district|<l> leader"
     shape = "record"
   ];
   companion_sandbox   [
@@ -115,7 +115,7 @@ digraph schema {
 
   companionship:d -> district:d
   
-  district:s      -> individual:i
+  district:l      -> individual:i
   
   individual:sp   -> scheduling_priority:sp
   
@@ -146,7 +146,7 @@ digraph schema {
   accomplishment:i   -> individual:i
   accomplishment:t   -> task:t
  
-  district_sandbox:s      -> individual:i
+  district_sandbox:l      -> individual:i
   companion_sandbox:i     -> individual:i
   companion_sandbox:cp    -> companionship_sandbox:cp
   companionship_sandbox:tcp -> companionship:c
diff --git a/sql/tc.jpg b/sql/tc.jpg
index e365f5a..2137785 100644
Binary files a/sql/tc.jpg and b/sql/tc.jpg differ
diff --git a/sql/tc.sql b/sql/tc.sql
index f5520db..cc84931 100644
--- a/sql/tc.sql
+++ b/sql/tc.sql
@@ -86,6 +86,7 @@ CREATE TABLE /*!42501 IF NOT EXISTS*/ `tc_companionship` (
   `companionship` INT( 16 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
   `mls_id` INT( 16 ) UNSIGNED NULL DEFAULT NULL ,
   `district` INT( 16 ) UNSIGNED NULL DEFAULT NULL ,
+  `type` ENUM( 'H', 'P' ) NOT NULL DEFAULT 'H' ,
   `valid` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '1'
 ) ENGINE = MYISAM ;
 
@@ -94,7 +95,7 @@ CREATE TABLE /*!42501 IF NOT EXISTS*/ `tc_companionship` (
 --
 CREATE TABLE /*!42501 IF NOT EXISTS*/ `tc_district` (
   `district` int(16) unsigned NOT NULL default '0',
-  `supervisor` int(16) unsigned default NULL,
+  `leader` int(16) unsigned default NULL,
   `valid` tinyint(1) default NULL,
   PRIMARY KEY  (`district`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@@ -246,7 +247,7 @@ CREATE TABLE /*!42501 IF NOT EXISTS*/ `tc_task` (
 --
 CREATE TABLE /*!42501 IF NOT EXISTS*/ `tc_district_sandbox` (
   `district` INT( 16 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
-  `supervisor` INT( 16 ) UNSIGNED NULL DEFAULT NULL
+  `leader` INT( 16 ) UNSIGNED NULL DEFAULT NULL
 ) ENGINE = MYISAM ;
 
 --