change tc_interview.interviewer to point to tc_leader.leader instead of tc_individual...
authorOwen Leonard <owen@balawis.leonard.fam>
Mon, 1 Nov 2010 00:51:17 +0000 (18:51 -0600)
committerOwen Leonard <owen@balawis.leonard.fam>
Mon, 1 Nov 2010 00:51:17 +0000 (18:51 -0600)
bin/upgrade_1_1_0_to_1_1_1
inc/class.tc.inc.php
sql/schema.dot
sql/tc.jpg

index 21b6bede198aafc54d07bf9e2e6c337f395991da..0337a6e2564c6b283b38d0d389aa9115cf7e1a56 100755 (executable)
@@ -86,6 +86,9 @@ $sth->execute or die "-E- DB error: $DBI::errstr\n";
 $sth = $dbh->prepare("ALTER TABLE `tc_visit` DROP `companion1`, DROP `companion2`");
 $sth->execute or die "-E- DB error: $DBI::errstr\n";
 
+# change tc_interview so interviewer points to tc_leader.leader
+$sth = $dbh->prepare("UPDATE tc_interview AS ti JOIN tc_leader AS tl SET ti.interviewer=tl.leader WHERE ti.interviewer=tl.individual");
+$sth->execute or die "-E- DB error: $DBI::errstr\n";
 
 
 print "-> Done!\n";
index 3a412eb9b031213cd0726c09adcdf0342496c0ba..b1995ed9202c5c266d0251ed472a416c08b6114f 100644 (file)
@@ -2959,12 +2959,12 @@ class tc
                if($this->yearly_ppi_interviewer == 3) { $sql .= " (tl.type='P' OR tl.type='C' OR tl.type='S')"; }
                $this->db2->query($sql,__LINE__,__FILE__);
                while ($this->db2->next_record()) {
-                       $indiv = $this->db2->f('individual');
+                       $leader = $this->db2->f('leader');
                        $interviewer_name = $this->db2->f('name');
-                       if($indiv == $interviewer) {
-                               $this->t->set_var('interviewer',$indiv . ' selected');
+                       if($leader == $interviewer) {
+                               $this->t->set_var('interviewer',$leader . ' selected');
                        } else {
-                               $this->t->set_var('interviewer',$indiv);
+                               $this->t->set_var('interviewer',$leader);
                        }
                        #print "indiv: $indiv interviewer: $interviewer<br>";
                        $this->t->set_var('interviewer_name',$interviewer_name);
@@ -3285,12 +3285,12 @@ class tc
                $sql = "SELECT * FROM tc_leader AS tl JOIN (tc_individual AS ti, tc_district AS td) WHERE tl.individual=ti.individual AND tl.leader=td.leader AND tl.valid=1 AND (tl.type='P' OR tl.type='C' OR tl.type='D' OR td.district!=0)";
                $this->db2->query($sql,__LINE__,__FILE__);
                while ($this->db2->next_record()) {
-                       $indiv = $this->db2->f('individual');
+                       $leader = $this->db2->f('leader');
                        $interviewer_name = $this->db2->f('name');
-                       if($indiv == $interviewer) {
-                               $this->t->set_var('interviewer',$indiv . ' selected');
+                       if($leader == $interviewer) {
+                               $this->t->set_var('interviewer',$leader . ' selected');
                        } else {
-                               $this->t->set_var('interviewer',$indiv);
+                               $this->t->set_var('interviewer',$leader);
                        }
                        $this->t->set_var('interviewer_name',$interviewer_name);
                        $this->t->fp('int_list','interviewer_list',True);
index 136e25338e737ae545856c7d0a32272a9f6ee412..b6f961c3737f82eca05d817fb69b6916c08e9e43 100644 (file)
@@ -127,7 +127,7 @@ digraph schema {
   participation:a -> activity:a
 
   interview:il    -> individual:i
-  interview:i     -> individual:i
+  interview:i     -> leader:l
 
   leader:i    -> individual:i
 
index 7885fed7128fea360249864b0d1b93c4433a8221..f6eef0bd807fa440b70e16b89b9ef12091362ddb 100644 (file)
Binary files a/sql/tc.jpg and b/sql/tc.jpg differ