Fixed bug in querying eqpres PPI history in scheduling tool.
[eq/.git] / inc / class.eq.inc.php
index 2ffb985a68c0870437e2752f0c88dd3727e06302..7f0d5a6e887671fb744d508cd3468d9b6aaf1508 100644 (file)
@@ -1423,6 +1423,16 @@ class eq
        $interviewer = $this->db->f('elder');
        $district_number = '*';
        $district_name = $president_name;
+       $sql = "SELECT * FROM eq_elder where elder='$president_id'";
+       $this->db2->query($sql,__LINE__,__FILE__);
+       if($this->db2->next_record()) {
+         $indiv_id = $this->db2->f('indiv_id');
+       }
+       $sql = "SELECT * FROM eq_parent where indiv_id='$indiv_id'";
+       $this->db2->query($sql,__LINE__,__FILE__);
+       if($this->db2->next_record()) {
+         $president_address = $this->db2->f('address');
+       }
       } else {
        print "<hr><font color=red><h3>-E- Unable to locate EQ President in eq_presidency table</h3></font></hr>";
        return;
@@ -1438,7 +1448,7 @@ class eq
                $elder = $entry['elder'];
                $appointment = $entry['appointment'];
                $location = $entry['location'];
-               if($location == "") { $location = "$president_last_name"." home"; }
+               if($location == "") { $location = "$president_last_name"." home ($president_address)"; }
                if($elder == 0) { $location = ""; }
                
                //Only perform a database update if we have made a change to this appointment
@@ -1518,7 +1528,7 @@ class eq
          $appointment = $this->db->f('appointment');
          $elder = $this->db->f('elder');
          $location = $this->db->f('location');
-         if(($location == "") && ($elder > 0)) { $location = "$president_last_name"." home"; }
+         if(($location == "") && ($elder > 0)) { $location = "$president_last_name"." home ($president_address)"; }
          
          $date = $this->db->f('date');
          $date_array = explode("-",$date);
@@ -1589,7 +1599,7 @@ class eq
          $this->db2->query($sql,__LINE__,__FILE__);
          
          if(!$this->db2->next_record()) {
-           $sql = "SELECT * FROM eq_ppi WHERE elder=" . $id . " ORDER BY date DESC";
+           $sql = "SELECT * FROM eq_ppi WHERE elder=" . $id . " AND eqpresppi=1 ORDER BY date DESC";
            $this->db->query($sql,__LINE__,__FILE__);
            if($this->db->next_record()) { $date = $this->db->f('date'); } else { $date = ""; }
            $link_data['menuaction'] = 'eq.eq.ppi_update';
@@ -1747,7 +1757,17 @@ class eq
                  $supervisor = $entry['supervisor'];
                  $supervisor_array = explode(",", $elderid2name[$supervisor]);
                  $supervisor_last_name = $supervisor_array[0];
-                 $location = "$supervisor_last_name"." home";
+                 $sql = "SELECT * FROM eq_elder where elder='$supervisor'";
+                 $this->db2->query($sql,__LINE__,__FILE__);
+                 if($this->db2->next_record()) {
+                   $indiv_id = $this->db2->f('indiv_id');
+                 }
+                 $sql = "SELECT * FROM eq_parent where indiv_id='$indiv_id'";
+                 $this->db2->query($sql,__LINE__,__FILE__);
+                 if($this->db2->next_record()) {
+                   $supervisor_address = $this->db2->f('address');
+                 }
+                 $location = "$supervisor_last_name"." home ($supervisor_address)";
                }
                if($elder == 0) { $location = ""; }
                
@@ -1830,6 +1850,17 @@ class eq
       $supervisor = $districts[$d]['supervisor'];
       $supervisor_array = explode(",", $supervisor);
       $supervisor_last_name = $supervisor_array[0];
+      $sql = "SELECT * FROM eq_elder where elder='$supervisor'";
+      $this->db2->query($sql,__LINE__,__FILE__);
+      if($this->db2->next_record()) {
+       $indiv_id = $this->db2->f('indiv_id');
+      }
+      $sql = "SELECT * FROM eq_parent where indiv_id='$indiv_id'";
+      $this->db2->query($sql,__LINE__,__FILE__);
+      if($this->db2->next_record()) {
+       $supervisor_address = $this->db2->f('address');
+      }
+      $location = "$supervisor_last_name"." home ($supervisor_address)";
       $table_title = "District ".$districts[$d]['district'].": ".$districts[$d]['name'].": All Elders 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);
@@ -1844,7 +1875,7 @@ class eq
          $appointment = $this->db->f('appointment');
          $elder = $this->db->f('elder');
          $location = $this->db->f('location');
-         if(($location == "") && ($elder > 0)) { $location = "$supervisor_last_name"." home"; }
+         if(($location == "") && ($elder > 0)) { $location = "$supervisor_last_name"." home ($supervisor_address)"; }
          
          $date = $this->db->f('date');
          $date_array = explode("-",$date);
@@ -3618,7 +3649,7 @@ class eq
       $this->t->set_var('schedule_ppi_link',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_sched'));
       $this->t->set_var('schedule_ppi_link_title','Schedule Yearly PPIs');
       
-      $date_width=150; $time_width=225; $elder_width=200; $family_width=200; $location_width=100;
+      $date_width=150; $time_width=220; $elder_width=170; $family_width=180; $location_width=100;
       $table_width=$date_width + $time_width + $elder_width + $family_width + $location_width;
       $header_row = "<th width=$date_width><font size=-2>Date</th>";
       $header_row.= "<th width=$time_width><font size=-2>Time</th>";      
@@ -3636,6 +3667,7 @@ class eq
          $presidency_data[$i]['name'] = $this->db->f('name');
          $presidency_data[$i]['elder'] = $this->db->f('elder');
          $presidency2name[$presidency_data[$i]['id']] = $presidency_data[$i]['name'];
+         $presidency2elder[$presidency_data[$i]['id']] = $presidency_data[$i]['elder'];
          $i++;
        }
       
@@ -3688,7 +3720,17 @@ class eq
                   else if($elder > 0) {
                     $supervisor_name_array = explode(",",$presidency2name[$presidency]);
                     $supervisor_last_name = $supervisor_name_array[0];
-                    $location = "$supervisor_last_name"." home";
+                    $sql = "SELECT * FROM eq_elder where elder='$presidency2elder[$presidency]'";
+                    $this->db2->query($sql,__LINE__,__FILE__);
+                    if($this->db2->next_record()) {
+                      $indiv_id = $this->db2->f('indiv_id');
+                    }
+                    $sql = "SELECT * FROM eq_parent where indiv_id='$indiv_id'";
+                    $this->db2->query($sql,__LINE__,__FILE__);
+                    if($this->db2->next_record()) {
+                      $supervisor_address = $this->db2->f('address');
+                    }
+                    $location = "$supervisor_last_name"." home ($supervisor_address)";
                   }
                 }
                 
@@ -3805,7 +3847,17 @@ class eq
              else if($elder > 0) {
                $supervisor_name_array = explode(",",$presidency2name[$presidency]);
                $supervisor_last_name = $supervisor_name_array[0];
-               $location = "$supervisor_last_name"." home";
+               $sql = "SELECT * FROM eq_elder where elder='$presidency2elder[$presidency]'";
+               $this->db2->query($sql,__LINE__,__FILE__);
+               if($this->db2->next_record()) {
+                 $indiv_id = $this->db2->f('indiv_id');
+               }
+               $sql = "SELECT * FROM eq_parent where indiv_id='$indiv_id'";
+               $this->db2->query($sql,__LINE__,__FILE__);
+               if($this->db2->next_record()) {
+                 $supervisor_address = $this->db2->f('address');
+               }
+               $location = "$supervisor_last_name"." home ($supervisor_address)";
              }
            }
            
@@ -3835,7 +3887,7 @@ class eq
            $table_data.= "</td>";
            
            // Elder drop down list (for PPIs)
-           $table_data.= '<td align=center><select name=sched['.$presidency.']['.$appointment.'][elder]>';
+           $table_data.= '<td align=center><select name=sched['.$presidency.']['.$appointment.'][elder] STYLE="font-size : 8pt">';
            $table_data.= '<option value=0></option>';  
            for ($j=0; $j < count($elder_id); $j++) {
              $id = $elder_id[$j];
@@ -3846,7 +3898,7 @@ class eq
            $table_data.='</select></td>';
 
            // Family drop down list (for Visits)
-           $table_data.= '<td align=center><select name=sched['.$presidency.']['.$appointment.'][family]>';
+           $table_data.= '<td align=center><select name=sched['.$presidency.']['.$appointment.'][family] STYLE="font-size : 8pt">';
            $table_data.= '<option value=0></option>';              
            for ($j=0; $j < count($elder_id); $j++) {
              $id = $family_id[$j];
@@ -3858,7 +3910,7 @@ class eq
 
            // Location text box
            $table_data.= '<td align=center><input type=text size="25" maxlength="120" ';
-           $table_data.= 'name="sched['.$presidency.']['.$appointment.'][location]" value="'.$location.'">';
+           $table_data.= 'name="sched['.$presidency.']['.$appointment.'][location]" value="'.$location.'" STYLE="font-size : 8pt">';
            
            $table_data.= '<input type=hidden name="sched['.$presidency.']['.$appointment.'][appointment]" value="'.$appointment.'">';
            $table_data.= '<input type=hidden name="sched['.$presidency.']['.$appointment.'][presidency]" value="'.$presidency.'">';
@@ -3884,7 +3936,7 @@ class eq
          $table_data.= "</td>";
          
          // Elder drop down list
-         $table_data.= '<td align=center><select name=sched['.$presidency.']['.$appointment.'][elder]>';
+         $table_data.= '<td align=center><select name=sched['.$presidency.']['.$appointment.'][elder] STYLE="font-size : 8pt">';
          $table_data.= '<option value=0></option>';  
          for ($j=0; $j < count($elder_id); $j++) {
            $id = $elder_id[$j];
@@ -3894,7 +3946,7 @@ class eq
          $table_data.='</select></td>';
          
          // Family drop down list
-         $table_data.= '<td align=center><select name=sched['.$presidency.']['.$appointment.'][family]>';
+         $table_data.= '<td align=center><select name=sched['.$presidency.']['.$appointment.'][family] STYLE="font-size : 8pt">';
          $table_data.= '<option value=0></option>';        
          for ($j=0; $j < count($elder_id); $j++) {
            $id = $family_id[$j];
@@ -3905,7 +3957,7 @@ class eq
 
          // Location text box
          $table_data.= '<td align=center><input type=text size="25" maxlength="120" ';
-         $table_data.= 'name="sched['.$presidency.']['.$appointment.'][location]" value="">';
+         $table_data.= 'name="sched['.$presidency.']['.$appointment.'][location]" value="" STYLE="font-size : 8pt">';
          
          $table_data.= '<input type=hidden name="sched['.$presidency.']['.$appointment.'][appointment]" value="'.$appointment.'">';
          $table_data.= '<input type=hidden name="sched['.$presidency.']['.$appointment.'][presidency]" value="'.$presidency.'">';