added YM to ht interview individual list if they are a home teacher
[eq/.git] / inc / class.tc.inc.php
index 543aed895317a4f44ff95ab615e15dceb31fa644..93d8aedbbedff77584ba1b739f22b5fdca9167cf 100644 (file)
@@ -1004,7 +1004,8 @@ class tc
       $this->t->set_block('par_view_t','header_list','list1');
       $this->t->set_block('par_view_t','indiv_list','list2');
 
-      $sql = "SELECT * FROM tc_indiv where valid=1";
+      // TODO:  changed this so it picks the quorum dynamically
+      $sql = "SELECT * FROM tc_indiv where steward='Elder' and valid=1";
       $this->db->query($sql,__LINE__,__FILE__);
       $i=0;
       while ($this->db->next_record())
@@ -1114,7 +1115,8 @@ class tc
       }
       $this->t->set_var('filter_input',$filter_input);
       
-      $sql = "SELECT * FROM tc_indiv where valid=1";
+      // TODO:  changed this so it picks the quorum dynamically
+      $sql = "SELECT * FROM tc_indiv where steward='Elder' and valid=1";
       $this->db->query($sql,__LINE__,__FILE__);
       $i=0;
       while ($this->db->next_record())
@@ -1457,7 +1459,8 @@ class tc
        }
       
       // create the individual id -> individual name mapping
-      $sql = "SELECT * FROM tc_indiv where valid=1 ORDER BY name ASC";
+      // TODO:  changed this so it picks the quorum dynamically
+      $sql = "SELECT * FROM tc_indiv where valid=1 and steward='Elder' ORDER BY name ASC";
       $this->db->query($sql,__LINE__,__FILE__);
       $i=0;
       $indiv_id = NULL;
@@ -1536,7 +1539,8 @@ class tc
       $this->t->set_var('appt_table_width',$appt_table_width);
 
       // PPI SCHEDULING TABLE
-      $sql = "SELECT * FROM tc_indiv where valid=1 ORDER BY ppi_pri ASC";
+      // TODO:  changed this so it picks the quorum dynamically
+      $sql = "SELECT * FROM tc_indiv where valid=1 and steward='Elder' ORDER BY ppi_pri ASC";
       $this->db->query($sql,__LINE__,__FILE__);
       
       $i=0; 
@@ -1698,7 +1702,8 @@ class tc
       //print "year: $year month: $month quarter_start: $quarter_start quarter_end: $quarter_end<br>";
 
       // create the individual id -> individual name mapping
-      $sql = "SELECT * FROM tc_indiv where valid=1 ORDER BY name ASC";
+      // TODO:  changed this so it picks the quorum dynamically
+      $sql = "SELECT * FROM tc_indiv where steward='Elder' and valid=1 ORDER BY name ASC";
       $this->db->query($sql,__LINE__,__FILE__);
       $i=0;
       $indiv_id_data = NULL;
@@ -1710,6 +1715,21 @@ class tc
          $individ2name[$indiv_id_data[$i]] = $indiv_name_data[$i];
          $i++;
        }
+      // add any YM that are home teachers
+      $sql = "SELECT * FROM tc_companionship where valid=1";
+      $this->db->query($sql,__LINE__,__FILE__);
+      while ($this->db->next_record())
+      {
+         $tmp_indiv_id = $this->db->f('indiv');
+          $sql = "Select * FROM tc_indiv where indiv='$tmp_indiv_id' and steward='' and valid=1";
+          $this->db2->query($sql,__LINE__,__FILE__);
+          while ($this->db2->next_record()) {
+             $indiv_name_data[$i] = $this->db2->f('name');
+             $indiv_id_data[$i] = $this->db2->f('indiv');
+             $individ2name[$indiv_id_data[$i]] = $indiv_name_data[$i];
+             $i++;
+         }
+      }
       array_multisort($indiv_name_data, $indiv_id_data);
 
       if($action == 'save')
@@ -1895,8 +1915,7 @@ class tc
       $i=0;
       for ($j=0; $j < count($unique_companionships); $j++) {
        // Select all the companions from each companionship
-       $sql = "SELECT * FROM tc_companionship where valid=1 and ".
-          "companionship=". $unique_companionships[$j]['companionship'];
+       $sql = "SELECT * FROM tc_companionship where valid=1 and companionship=". $unique_companionships[$j]['companionship'];
        $this->db->query($sql,__LINE__,__FILE__);
        $k=0; $int_completed=0;
        $comp = $unique_companionships[$j]['companionship'];
@@ -1908,14 +1927,16 @@ class tc
              // Get this companions information
              $indiv_id = $this->db->f('indiv');
             
-             $sql = "SELECT * FROM tc_indiv where indiv=$indiv_id";
+             $sql = "SELECT * FROM tc_indiv where indiv='$indiv_id'";
              $this->db2->query($sql,__LINE__,__FILE__);        
-             $indiv_id = $this->db2->f('indiv');
-             $indiv_name = $this->db2->f('name');
-             $indiv_phone[$indiv_id] = $this->db2->f('phone');
-             $indiv_int_pri[$indiv_id] = $this->db2->f('int_pri');
-             $indiv_int_notes[$indiv_id] = $this->db2->f('int_notes');
-
+             if($this->db2->next_record())
+             {
+                     $indiv_id = $this->db2->f('indiv');
+                     $indiv_name = $this->db2->f('name');
+                     $indiv_phone[$indiv_id] = $this->db2->f('phone');
+                     $indiv_int_pri[$indiv_id] = $this->db2->f('int_pri');
+                     $indiv_int_notes[$indiv_id] = $this->db2->f('int_notes');
+             }
              $id = $indiv_id;
              $name = $indiv_name;
              $phone = $indiv_phone[$id];
@@ -1938,12 +1959,11 @@ class tc
              }
              
              // If this companionship has had a hometeaching interview this quarter, don't show them on the schedule list
-             $sql = "SELECT * FROM tc_interview WHERE date >= '$quarter_start' AND date < '$quarter_end' ".
-                "AND indiv=" . $id;
+             $sql = "SELECT * FROM tc_interview WHERE date >= '$quarter_start' AND date < '$quarter_end' AND indiv='$id'";
              $this->db2->query($sql,__LINE__,__FILE__);
              
              if(!$this->db2->next_record()) {
-               $sql = "SELECT * FROM tc_interview WHERE indiv=" . $id . " ORDER BY date DESC";
+               $sql = "SELECT * FROM tc_interview WHERE indiv='$id' ORDER BY date DESC";
                $this->db3->query($sql,__LINE__,__FILE__);
                if($this->db3->next_record()) { $date = $this->db3->f('date'); } else { $date = ""; }
                $link_data['menuaction'] = 'tc.tc.int_update';
@@ -2384,7 +2404,8 @@ class tc
       $this->t->set_var('district_number','*');
       $this->t->set_var('district_name',$president_name);
 
-      $sql = "SELECT * FROM tc_indiv where valid=1 ORDER BY indiv ASC";
+      // TODO:  changed this so it picks the quorum dynamically
+      $sql = "SELECT * FROM tc_indiv where steward='Elder' and valid=1 ORDER BY indiv ASC";
       $this->db->query($sql,__LINE__,__FILE__);
       $i=0;
       while ($this->db->next_record())
@@ -3149,7 +3170,8 @@ 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_indiv where valid=1";
+      // TODO:  changed this so it picks the quorum dynamically
+      $sql = "SELECT * FROM tc_indiv where steward='Elder' and valid=1";
       $this->db->query($sql,__LINE__,__FILE__);
       $i=0;
       while ($this->db->next_record())
@@ -3341,7 +3363,8 @@ class tc
         return false;    
        }
 
-      $sql = "SELECT * FROM tc_indiv where valid=1";
+      // TODO:  changed this so it picks the quorum dynamically
+      $sql = "SELECT * FROM tc_indiv where steward='Elder' and valid=1";
       $this->db->query($sql,__LINE__,__FILE__);
       $i=0;
       while ($this->db->next_record())
@@ -3725,7 +3748,8 @@ class tc
          //Header('Location: ' . $take_me_to_url);
        }
       
-      $sql = "SELECT * FROM tc_indiv where valid=1 ORDER BY indiv ASC";
+      // TODO:  changed this so it picks the quorum dynamically
+      $sql = "SELECT * FROM tc_indiv where steward='Elder' and valid=1 ORDER BY indiv ASC";
       $this->db->query($sql,__LINE__,__FILE__);
       $i=0;
       while ($this->db->next_record())
@@ -3943,7 +3967,8 @@ class tc
 
       $this->t->pfp('out','admin_t');
 
-      $sql = "SELECT * FROM tc_indiv where valid=1 ORDER BY indiv ASC";
+      // TODO:  changed this so it picks the quorum dynamically
+      $sql = "SELECT * FROM tc_indiv where steward='Elder' and valid=1 ORDER BY indiv ASC";
       $this->db->query($sql,__LINE__,__FILE__);
       $i=0;
       while ($this->db->next_record())