Merge branch 'owenleonard/database_changes' of git@github.com:apippin/3rd into owenle...
[eq/.git] / inc / class.tc.inc.php
index 409b87e6bf0cd05a0709f1f70a132d26aa42b206..45d012e649d8724e0d6dde2dc320dbb3cc91fc50 100644 (file)
@@ -255,7 +255,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 ".
+                               $sql = "SELECT * FROM tc_companion where valid=1 and ".
                                "companionship=". $unique_companionships[$j]['companionship'];
                                $this->db->query($sql,__LINE__,__FILE__);
 
@@ -825,7 +825,7 @@ class tc
                $this->t->set_var('assignment_data',$assignment_data);
 
                // Create individual selection boxes
-               $sql = "SELECT * FROM tc_individual";
+               $sql = "SELECT * FROM tc_individual WHERE steward='$this->default_stewardship'";
                $this->db->query($sql,__LINE__,__FILE__);
                $i=0;
                while ($this->db->next_record()) {
@@ -996,8 +996,7 @@ class tc
                $this->t->set_block('par_view_t','header_list','list1');
                $this->t->set_block('par_view_t','individual_list','list2');
 
-               // TODO:  changed this so it picks the quorum dynamically
-               $sql = "SELECT * FROM tc_individual where steward='Elder' and valid=1";
+               $sql = "SELECT * FROM tc_individual where steward='$this->default_stewardship' and valid=1";
                $this->db->query($sql,__LINE__,__FILE__);
                $i=0;
                while ($this->db->next_record()) {
@@ -1107,8 +1106,7 @@ class tc
                }
                $this->t->set_var('filter_input',$filter_input);
 
-               // TODO:  changed this so it picks the quorum dynamically
-               $sql = "SELECT * FROM tc_individual where steward='Elder' and valid=1";
+               $sql = "SELECT * FROM tc_individual where steward='$this->default_stewardship' and valid=1";
                $this->db->query($sql,__LINE__,__FILE__);
                $i=0;
                while ($this->db->next_record()) {
@@ -1431,8 +1429,7 @@ class tc
                }
 
                // create the individual id -> individual name mapping
-               // TODO:  changed this so it picks the quorum dynamically
-               $sql = "SELECT * FROM tc_individual where valid=1 and steward='Elder' ORDER BY name ASC";
+               $sql = "SELECT * FROM tc_individual where valid=1 and steward='$this->default_stewardship' ORDER BY name ASC";
                $this->db->query($sql,__LINE__,__FILE__);
                $i=0;
                $individual = NULL;
@@ -1513,8 +1510,7 @@ class tc
                $this->t->set_var('appt_table_width',$appt_table_width);
 
                // PPI SCHEDULING TABLE
-               // TODO:  changed this so it picks the quorum dynamically
-               $sql = "SELECT * FROM tc_individual AS ti JOIN tc_scheduling_priority AS tsp WHERE ti.scheduling_priority=tsp.scheduling_priority AND steward='Elder' AND valid=1 ORDER BY tsp.priority ASC, ti.name ASC";
+               $sql = "SELECT * FROM tc_individual AS ti JOIN tc_scheduling_priority AS tsp WHERE ti.scheduling_priority=tsp.scheduling_priority AND steward='$this->default_stewardship' AND valid=1 ORDER BY tsp.priority ASC, ti.name ASC";
                $this->db->query($sql,__LINE__,__FILE__);
 
                $i=0; 
@@ -1683,8 +1679,7 @@ class tc
                //print "year: $year month: $month quarter_start: $quarter_start quarter_end: $quarter_end<br>";
 
                // create the individual id -> individual name mapping
-               // TODO:  changed this so it picks the quorum dynamically
-               $sql = "SELECT * FROM tc_individual where steward='Elder' and valid=1 ORDER BY name ASC";
+               $sql = "SELECT * FROM tc_individual where steward='$this->default_stewardship' and valid=1 ORDER BY name ASC";
                $this->db->query($sql,__LINE__,__FILE__);
                $i=0;
                $individual_data = NULL;
@@ -1762,7 +1757,7 @@ class tc
                                $hti_pri = $entry['pri'];
                                //print "hti_notes: $hti_notes indiv_name: $indiv_name <Br>";
                                // Perform database save actions here
-                               $this->db->query("SELECT * FROM tc_companionship WHERE individual=$individual and valid=1",__LINE__,__FILE__);
+                               $this->db->query("SELECT * FROM tc_companion WHERE individual=$individual and valid=1",__LINE__,__FILE__);
                                if ($this->db->next_record()) {
                                        $scheduling_priority = $this->db->f('scheduling_priority');
                                        //$this->logToFile("int_sched", "UPDATE tc_scheduling_priority SET priority='$hti_pri', notes=\"$hti_notes\" WHERE scheduling_priority='$scheduling_priority'");
@@ -1889,7 +1884,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 AS tc JOIN (tc_scheduling_priority AS tsp, tc_individual AS ti) WHERE tc.scheduling_priority=tsp.scheduling_priority AND tc.individual=ti.individual AND tc.valid=1 AND tc.companionship=". $unique_companionships[$j]['companionship'];
+                               $sql = "SELECT * FROM tc_companion AS tc JOIN (tc_scheduling_priority AS tsp, tc_individual AS ti) WHERE tc.scheduling_priority=tsp.scheduling_priority AND tc.individual=ti.individual AND tc.valid=1 AND tc.companionship=". $unique_companionships[$j]['companionship'];
                                $this->db->query($sql,__LINE__,__FILE__);
                                $k=0; $int_completed=0;
                                $comp = $unique_companionships[$j]['companionship'];
@@ -1938,6 +1933,7 @@ class tc
                                                $link_data['name'] = $name;
                                                $link_data['interview'] = '';
                                                $link_data['action'] = 'add';
+                                               $link_data['interview_type'] = 'hti';
                                                $link_data['interviewer'] = $districts[$d]['supervisor'];
                                                $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>";
@@ -1967,6 +1963,7 @@ class tc
                                                $link_data['individual'] = $this->db2->f('individual');
                                                $link_data['name'] = $name;
                                                $link_data['interview'] = $this->db2->f('interview');
+                                               $link_data['interview_type'] = 'hti';
                                                $link_data['action'] = 'view';
                                                $link = $GLOBALS['phpgw']->link('/tc/index.php',$link_data);    
                                                $comps_with_quarterly_int++;
@@ -2056,7 +2053,7 @@ class tc
                $year = date('Y');
 
                // create the family id -> family name mapping
-               $sql = "SELECT * FROM tc_family AS tf JOIN tc_individual AS ti WHERE tf.individual=ti.individual AND tf.valid=1 AND tf.individual != 0 AND tf.companionship != 0 ORDER BY ti.name ASC";
+               $sql = "SELECT * FROM tc_family AS tf JOIN tc_individual AS ti WHERE tf.individual=ti.individual AND tf.valid=1 AND tf.individual != 0 AND tf.companionship != 0 AND ti.steward='$this->default_stewardship' ORDER BY ti.name ASC";
                $this->db->query($sql,__LINE__,__FILE__);
                $i=0;
                $family_id = NULL;
@@ -2107,12 +2104,10 @@ class tc
                                $visit_notes = $entry['notes'];
                                $family = $entry['family_id'];
                                $visit_pri = $entry['pri'];
-
                                // Perform database save actions here
                                $this->db->query("SELECT * FROM tc_family WHERE family='$family'",__LINE__,__FILE__);
                                if ($this->db->next_record()) {
                                        $scheduling_priority = $this->db->f('scheduling_priority');
-                                       //$this->logToFile("vis_sched", "UPDATE tc_scheduling_priority SET priority='$visit_pri', notes=\"$visit_notes\" WHERE scheduling_priority='$scheduling_priority'");
                                        $this->db2->query("UPDATE tc_scheduling_priority SET priority='$visit_pri', notes=\"$visit_notes\" WHERE scheduling_priority='$scheduling_priority'", __LINE__, __FILE__);
                                }
                        }
@@ -2196,7 +2191,7 @@ class tc
 
 
                // VISIT SCHEDULING TABLE
-               $sql = "SELECT * FROM tc_family AS tf JOIN (tc_scheduling_priority AS tsp, tc_individual as ti) WHERE tf.scheduling_priority=tsp.scheduling_priority AND tf.individual=ti.individual AND tf.valid=1 AND tf.individual != 0  AND tf.companionship != 0 ORDER BY tsp.priority ASC, ti.name ASC";
+               $sql = "SELECT * FROM tc_family AS tf JOIN (tc_scheduling_priority AS tsp, tc_individual as ti) WHERE tf.scheduling_priority=tsp.scheduling_priority AND tf.individual=ti.individual AND tf.valid=1 AND tf.individual != 0  AND tf.companionship != 0 AND ti.steward='$this->default_stewardship' ORDER BY tsp.priority ASC, ti.name ASC";
                $this->db->query($sql,__LINE__,__FILE__);
 
                $total_families=0; $families_with_yearly_visit=0;
@@ -2232,7 +2227,7 @@ class tc
                                $table_data.= "<tr bgcolor=". $this->t->get_var('tr_color') ."><td title=\"$phone\"><a href=$link>$name Family</a></td>";
                                $table_data.= "<td align=center>$phone</td>";
                                $table_data.= "<td align=center>";
-                               $table_data.= '<select name=vis_notes['.$i.'][pri]>';
+                               $table_data.= '<select name=vis_notes['.$id.'][pri]>';
                                foreach(range(0,6) as $num) {
                                        if($num == 0) { $num = 1; } else {$num = $num*5; }
                                        if($vis_pri == $num) { 
@@ -2244,9 +2239,9 @@ class tc
                                }
                                $table_data.= '</select></td>';
                                $table_data.= "<td align=center>$date</td>";
-                               $table_data.= '<td><input type=text size="50" maxlength="128" name="vis_notes['.$i.'][notes]" value="'.$vis_notes.'">';
-                               $table_data.= '<input type=hidden name="vis_notes['.$i.'][family_id]" value="'.$id.'">';
-                               $table_data.= '<input type=hidden name="vis_notes['.$i.'][family_name]" value="'.$name.'">';
+                               $table_data.= '<td><input type=text size="50" maxlength="128" name="vis_notes['.$id.'][notes]" value="'.$vis_notes.'">';
+                               $table_data.= '<input type=hidden name="vis_notes['.$id.'][family_id]" value="'.$id.'">';
+                               $table_data.= '<input type=hidden name="vis_notes['.$id.'][family_name]" value="'.$name.'">';
                                $table_data.= '</td>';
                                $table_data.= '</tr>';
                                $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
@@ -2349,7 +2344,6 @@ class tc
                if($this->db->next_record()) {
                        $president_name = $this->db->f('name');
                        $interviewer = $this->db->f('individual');
-                       $interview_type = 'ppi';
                } else {
                        print "<hr><font color=red><h3>-E- Unable to locate President in tc_presidency table</h3></font></hr>";
                        return;
@@ -2357,8 +2351,7 @@ class tc
                $this->t->set_var('district_number','*');
                $this->t->set_var('district_name',$president_name);
 
-               // TODO:  changed this so it picks the quorum dynamically
-               $sql = "SELECT * FROM tc_individual AS ti JOIN tc_scheduling_priority as tsp where ti.scheduling_priority=tsp.scheduling_priority and ti.steward='Elder' and ti.valid=1 ORDER BY ti.individual ASC";
+               $sql = "SELECT * FROM tc_individual AS ti JOIN tc_scheduling_priority as tsp where ti.scheduling_priority=tsp.scheduling_priority and ti.steward='$this->default_stewardship' and ti.valid=1 ORDER BY ti.individual ASC";
                $this->db->query($sql,__LINE__,__FILE__);
                $i=0;
                while ($this->db->next_record()) {
@@ -2390,10 +2383,10 @@ class tc
 
                        $link_data['menuaction'] = 'tc.tc.ppi_update';
                        $link_data['interviewer'] = $interviewer;
-                       $link_data['indiv'] = $id;
+                       $link_data['individual'] = $id;
                        $link_data['name'] = $name;
                        $link_data['interview'] = '';
-                       $link_data['interview_type'] = $interview_type;
+                       $link_data['interview_type'] = 'ppi'; 
                        $link_data['action'] = 'add';
                        $link = $GLOBALS['phpgw']->link('/tc/index.php',$link_data);
                        $this->nextmatchs->template_alternate_row_color(&$this->t);
@@ -2416,7 +2409,7 @@ class tc
                                        $link_data['indiv'] = $id;
                                        $link_data['name'] = $name;
                                        $link_data['interview'] = $this->db2->f('interview');
-                                       $link_data['interview_type'] = $interview_type;
+                                       $link_data['interview_type'] = 'ppi';
                                        $link_data['action'] = 'view';
                                        $date = $this->db2->f('date');
                                        $date_array = explode("-",$date);
@@ -2463,7 +2456,7 @@ class tc
                $interviewer = get_var('interviewer',array('GET','POST'));      
                $name = get_var('name',array('GET','POST'));
                $interview = get_var('interview',array('GET','POST'));
-               $indiv = get_var('indiv',array('GET','POST'));
+               $individual = get_var('individual',array('GET','POST'));
                $date = get_var('date',array('GET','POST'));
                $notes = get_var('notes',array('GET','POST'));
                $interview_type = get_var('interview_type',array('GET','POST'));
@@ -2479,7 +2472,7 @@ class tc
                                $this->t->set_var('interviewer',$interviewer);
                        }
                        $this->t->set_var('interviewer_name',$interviewer_name);
-                       $this->t->set_var('interview_type_checked','');
+                       $this->t->set_var('eqpresppi_checked','checked');
                        $this->t->fp('int_list','interviewer_list',True);
                }
 
@@ -2488,7 +2481,7 @@ class tc
                        $this->db->query("UPDATE tc_interview set " .
                                         "   interview='" . $interview . "'" .
                                         ", interviewer='" . $interviewer . "'" .
-                                        ", individual='" . $indiv . "'" .
+                                        ", individual='" . $individual . "'" .
                                         ", date='" . $date . "'" .
                                         ", notes='" . $notes . "'" .
                                         ", interview_type='" . $interview_type . "'" .
@@ -2500,7 +2493,7 @@ class tc
                if($action == 'insert') {
                        $notes = get_var('notes',array('POST'));
                        $this->db->query("INSERT INTO tc_interview (interviewer,individual,date,notes,interview_type) " .
-                                        "VALUES ('" . $interviewer . "','" . $indiv . "','" .
+                                        "VALUES ('" . $interviewer . "','" . $individual . "','" .
                                         $date . "','" . $notes . "','" . $interview_type  ."')",__LINE__,__FILE__);
                        $this->ppi_view();
                        return false;
@@ -2511,11 +2504,11 @@ class tc
                        $this->t->set_var('interview', '');
                        $this->t->set_var('interviewer', $interviewer);
                        $this->t->set_var('name',$name);
-                       $this->t->set_var('indiv',$indiv);
+                       $this->t->set_var('individual',$individual);
                        $this->t->set_var('date','');
                        $this->t->set_var('notes','');
                        $this->t->set_var('interview_type',$interview_type);
-                       $this->t->set_var('interview_type_checked','checked');
+                       $this->t->set_var('eqpresppi_checked','checked');
                        $this->t->set_var('lang_done','Cancel');
                        $this->t->set_var('lang_action','Adding New PPI');
                        $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.ppi_update&interview=' .
@@ -2529,11 +2522,11 @@ class tc
                        $this->t->set_var('interview',$interview);
                        $this->t->set_var('name',$name);
                        $this->t->set_var('interviewer', $this->db->f('interviewer'));
-                       $this->t->set_var('indiv',$this->db->f('indiv'));
+                       $this->t->set_var('individual',$this->db->f('individual'));
                        $this->t->set_var('date',$this->db->f('date'));
                        $this->t->set_var('notes',$this->db->f('notes'));
                        $this->t->set_var('interview_type',$this->db->f('interview_type'));
-                       if($this->db->f('interview_type') == 1) { $this->t->set_var('interview_type_checked','checked'); }
+                       if($this->db->f('interview_type') == 'ppi') { $this->t->set_var('eqpresppi_checked','checked'); }
                }
 
                if($action == 'edit') {
@@ -2647,7 +2640,7 @@ class tc
                        for($m=$num_months; $m >= 0; $m--) { $ints[$m] = 0; }
                        for ($j=0; $j < count($unique_companionships); $j++) {
                                // Select all the companions in each companionship
-                               $sql = "SELECT * FROM tc_companionship where valid=1 and ".
+                               $sql = "SELECT * FROM tc_companion where valid=1 and ".
                                       "companionship=". $unique_companionships[$j]['companionship'];
                                $this->db->query($sql,__LINE__,__FILE__);
                                $k=0;
@@ -2663,9 +2656,10 @@ class tc
                                        $link_data['menuaction'] = 'tc.tc.int_update';
                                        $link_data['companionship'] = $companionship;
                                        $link_data['interviewer'] = $supervisor;
-                                       $link_data['indiv'] = $individual;
+                                       $link_data['individual'] = $individual;
                                        $link_data['name'] = $name;
                                        $link_data['interview'] = '';
+                                       $link_data['interview_type'] = 'hti';
                                        $link_data['action'] = 'add';
                                        $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>";
@@ -2699,10 +2693,11 @@ class tc
                                                        $link_data['menuaction'] = 'tc.tc.int_update';
                                                        $link_data['companionship'] = $companionship;
                                                        $link_data['interviewer'] = $this->db2->f('interviewer');
-                                                       $link_data['indiv'] = $individual;
+                                                       $link_data['individual'] = $individual;
                                                        $link_data['name'] = $name;
                                                        $link_data['interview'] = $this->db2->f('interview');
                                                        $link_data['action'] = 'view';
+                                                       $link_data['interview_type'] = 'hti';
                                                        $date = $this->db2->f('date');
                                                        $date_array = explode("-",$date);
                                                        $month = $date_array[1];
@@ -2779,14 +2774,14 @@ class tc
                $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.int_view'));
                $this->t->set_var('readonly','');
                $this->t->set_var('disabled','');
-               $this->t->set_var('interview_type_checked','');
+               $this->t->set_var('eqpresppi','');
 
                $action = get_var('action',array('GET','POST'));
                $companionship = get_var('companionship',array('GET','POST'));
                $interviewer = get_var('interviewer',array('GET','POST'));      
                $name = get_var('name',array('GET','POST'));
                $interview = get_var('interview',array('GET','POST'));
-               $indiv = get_var('indiv',array('GET','POST'));
+               $individual = get_var('individual',array('GET','POST'));
                $date = get_var('date',array('GET','POST'));
                $notes = get_var('notes',array('GET','POST'));
                $interview_type = get_var('interview_type',array('GET','POST'));
@@ -2810,7 +2805,7 @@ class tc
                        $this->db->query("UPDATE tc_interview set " .
                                         "   interview='" . $interview . "'" .
                                         ", interviewer='" . $interviewer . "'" .
-                                        ", individual='" . $indiv . "'" .
+                                        ", individual='" . $individual . "'" .
                                         ", date='" . $date . "'" .
                                         ", notes='" . $notes . "'" .
                                         ", interview_type='" . $interview_type . "'" .
@@ -2822,7 +2817,7 @@ class tc
                if($action == 'insert') {
                        $notes = get_var('notes',array('POST'));
                        $this->db->query("INSERT INTO tc_interview (interviewer,individual,date,notes,interview_type) " .
-                                        "VALUES ('" . $interviewer . "','" . $indiv . "','" .
+                                        "VALUES ('" . $interviewer . "','" . $individual . "','" .
                                         $date . "','" . $notes ."','" . $interview_type . "')",__LINE__,__FILE__);
                        $this->int_view();
                        return false;
@@ -2833,9 +2828,10 @@ class tc
                        $this->t->set_var('interview', '');
                        $this->t->set_var('interviewer', $interviewer);
                        $this->t->set_var('name',$name);
-                       $this->t->set_var('indiv',$indiv);
+                       $this->t->set_var('individual',$individual);
                        $this->t->set_var('date','');
                        $this->t->set_var('notes','');
+                       $this->t->set_var('interview_type',$interview_type);
                        $this->t->set_var('lang_done','Cancel');
                        $this->t->set_var('lang_action','Adding New Interview');
                        $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.int_update&interview=' .
@@ -2849,10 +2845,11 @@ class tc
                        $this->t->set_var('interview',$interview);
                        $this->t->set_var('name',$name);
                        $this->t->set_var('interviewer', $this->db->f('interviewer'));
-                       $this->t->set_var('indiv',$this->db->f('individual'));
+                       $this->t->set_var('individual',$this->db->f('individual'));
                        $this->t->set_var('date',$this->db->f('date'));
                        $this->t->set_var('notes',$this->db->f('notes'));
-                       if($this->db->f('interview_type') == 1) { $this->t->set_var('interview_type_checked','checked'); }
+                       $this->t->set_var('interview_type',$this->db->f('interview_type'));
+                       if($this->db->f('interview_type') == 'ppi') { $this->t->set_var('eqpresppi_checked','checked'); }
                }
 
                if($action == 'edit') {
@@ -2933,7 +2930,7 @@ class tc
                for ($i=0; $i < count($visit_list); $i++) {
                        $this->nextmatchs->template_alternate_row_color(&$this->t);
 
-                       $sql = "SELECT * FROM tc_family AS tf JOIN tc_individual AS ti WHERE tf.individual=ti.individual AND tf.family=".$visit_list[$i]['family'];
+                       $sql = "SELECT * FROM tc_family AS tf JOIN tc_individual AS ti WHERE tf.individual=ti.individual AND tf.family=".$visit_list[$i]['family']." AND ti.steward='$this->default_stewardship'";
                        $this->db->query($sql,__LINE__,__FILE__);
                        $this->db->next_record();
 
@@ -2961,7 +2958,7 @@ class tc
                }
 
                // List the families that are available to record a visit against
-               $sql = "SELECT * FROM tc_family AS tf JOIN tc_individual AS ti WHERE tf.individual=ti.individual AND tf.companionship != 0 and tf.valid=1";
+               $sql = "SELECT * FROM tc_family AS tf JOIN tc_individual AS ti WHERE tf.individual=ti.individual AND tf.companionship != 0 AND tf.valid=1 AND ti.steward='$this->default_stewardship'";
                $this->db->query($sql,__LINE__,__FILE__);
                $total_records = $this->db->num_rows();
 
@@ -3121,8 +3118,7 @@ class tc
                else if($current_month >= 7 && $current_month <= 9) { $current_month=9; }
                else if($current_month >= 10 && $current_month <= 12) { $current_month=12; }
 
-               // TODO:  changed this so it picks the quorum dynamically
-               $sql = "SELECT * FROM tc_individual where steward='Elder' and valid=1";
+               $sql = "SELECT * FROM tc_individual where steward='$this->default_stewardship' and valid=1";
                $this->db->query($sql,__LINE__,__FILE__);
                $i=0;
                while ($this->db->next_record()) {
@@ -3311,8 +3307,7 @@ class tc
                        return false;
                }
 
-               // TODO:  changed this so it picks the quorum dynamically
-               $sql = "SELECT * FROM tc_individual where steward='Elder' and valid=1";
+               $sql = "SELECT * FROM tc_individual where steward='$this->default_stewardship' and valid=1";
                $this->db->query($sql,__LINE__,__FILE__);
                $i=0;
                while ($this->db->next_record()) {
@@ -3452,7 +3447,7 @@ class tc
                $this->t->set_block('org_view_t','org_list','list2');
 
                # Display a list ordered alphabetically
-               $sql = "SELECT * FROM tc_calling ORDER BY name ASC";
+               $sql = "SELECT * FROM tc_calling AS tc JOIN tc_individual AS ti WHERE tc.individual=ti.individual ORDER BY name ASC";
                $this->db->query($sql,__LINE__,__FILE__);
                $i=0;
                while ($this->db->next_record()) {
@@ -3477,7 +3472,7 @@ class tc
                }
 
                # Display a list ordered by organization
-               $sql = "SELECT * FROM tc_calling ORDER BY organization ASC";
+               $sql = "SELECT * FROM tc_calling AS tc JOIN tc_individual AS ti where tc.individual=ti.individual ORDER BY organization ASC";
                $this->db->query($sql,__LINE__,__FILE__);
                $i=0;
                while ($this->db->next_record()) {
@@ -3527,7 +3522,7 @@ class tc
                $this->t->set_var('schedule_ppi_link',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.ppi_sched'));
                $this->t->set_var('schedule_ppi_link_title','Schedule Yearly PPIs');
 
-               $date_width=150; $time_width=220; $indiv_width=170; $family_width=180; $location_width=100;
+               $date_width=160; $time_width=220; $indiv_width=170; $family_width=180; $location_width=100;
                $table_width=$date_width + $time_width + $indiv_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>";      
@@ -3548,7 +3543,7 @@ class tc
                        $i++;
                }
 
-               $sql = "SELECT * FROM tc_family AS tf JOIN tc_individual AS ti WHERE tf.individual=ti.individual AND tf.valid=1 AND tf.individual != 0 ORDER BY ti.name ASC";
+               $sql = "SELECT * FROM tc_family AS tf JOIN tc_individual AS ti WHERE tf.individual=ti.individual AND ti.steward='$this->default_stewardship' AND tf.valid=1 AND tf.individual != 0 ORDER BY ti.name ASC";
                $this->db->query($sql,__LINE__,__FILE__);
                $i=0;
                while ($this->db->next_record()) {
@@ -3674,8 +3669,7 @@ class tc
                        //Header('Location: ' . $take_me_to_url);
                }
 
-               // TODO:  changed this so it picks the quorum dynamically
-               $sql = "SELECT * FROM tc_individual where steward='Elder' and valid=1 ORDER BY individual ASC";
+               $sql = "SELECT * FROM tc_individual where steward='$this->default_stewardship' and valid=1 ORDER BY individual ASC";
                $this->db->query($sql,__LINE__,__FILE__);
                $i=0;
                while ($this->db->next_record()) {
@@ -3896,8 +3890,7 @@ class tc
 
                $this->t->pfp('out','admin_t');
 
-               // TODO:  changed this so it picks the quorum dynamically
-               $sql = "SELECT * FROM tc_individual where steward='Elder' and valid=1 ORDER BY individual ASC";
+               $sql = "SELECT * FROM tc_individual where steward='$this->default_stewardship' and valid=1 ORDER BY individual ASC";
                $this->db->query($sql,__LINE__,__FILE__);
                $i=0;
                while ($this->db->next_record()) {