X-Git-Url: http://git.pippins.net/embedvideo/.git/%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%01%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%0F%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD%EF%BF%BD?a=blobdiff_plain;f=inc%2Fclass.tc.inc.php;h=6c80090beb3fa8560297662d70df92300cfc8e95;hb=fb4fe3b1180e8c1178007e1d2e593f8970bd4c13;hp=d1dae8e0ce3a01d11c8f2cc635123f64c7851b31;hpb=a7b3dad05fd92523cda0ebb5ba7c85e194b4e82f;p=eq%2F.git
diff --git a/inc/class.tc.inc.php b/inc/class.tc.inc.php
index d1dae8e..6c80090 100644
--- a/inc/class.tc.inc.php
+++ b/inc/class.tc.inc.php
@@ -68,6 +68,7 @@ class tc
'assign_view' => True,
'assign_update' => True,
'get_time_selection_form' => True,
+ 'ht_sandbox' => True,
);
function tc()
@@ -216,6 +217,9 @@ class tc
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.ht_view'));
$this->t->set_var('title','Hometeaching');
+ $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";
$this->db->query($sql,__LINE__,__FILE__);
$i=0;
@@ -394,6 +398,198 @@ class tc
}
+ function ht_sandbox()
+ {
+ $this->t->set_file(array('ht_sandbox_t' => 'ht_sandbox.tpl'));
+ $this->t->set_block('ht_sandbox_t','comp_list','c_list');
+ $this->t->set_block('ht_sandbox_t','district_list','d_list');
+ $this->t->set_block('ht_sandbox_t','unassigned_ht_list','uht_list');
+ $this->t->set_block('ht_sandbox_t','assigned_ht_list','aht_list');
+ $this->t->set_block('ht_sandbox_t','unassigned_family_list','uf_list');
+ $this->t->set_block('ht_sandbox_t','assigned_family_list','af_list');
+ $this->t->set_block('ht_sandbox_t','district_table_list','dt_list');
+ $this->t->set_block('ht_sandbox_t','companionship_table_list','ct_list');
+
+ $this->t->set_var('linkurl',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.ht_sandbox'));
+
+ $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.ht_sandbox'));
+ $this->t->set_var('title','Hometeaching Sandbox');
+
+ // get list of companionships
+ $sql = "SELECT DISTINCT companionship FROM tc_companionship where valid=1 ORDER BY companionship ASC";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $unique_companionships = '';
+ $unique_companionships[0]['companionship'] = 0;
+ $this->t->set_var('companionship_list','New ');
+ $this->t->fp('list','comp_list',True);
+ $j=1;
+ while ($this->db->next_record()) {
+ $companionship = $this->db->f('companionship');
+ $unique_companionships[$j]['companionship'] = $companionship;
+ $combined_companionship = "";
+ $sql = "SELECT * FROM tc_companion AS tc JOIN tc_individual AS ti WHERE tc.individual=ti.individual AND companionship=$companionship AND tc.valid=1 ORDER BY ti.name ASC";
+ $this->db2->query($sql,__LINE__,__FILE__);
+ while ($this->db2->next_record()) {
+ if ($combined_companionship == "") {
+ $combined_companionship .= $this->db2->f('name');
+ } else {
+ $combined_companionship .= " / " . $this->db2->f('name');
+ }
+ }
+ $this->t->set_var('companionship_list',''.$combined_companionship.' ');
+ $this->t->fp('c_list','comp_list',True);
+ $j++;
+ }
+
+ # get list of districts
+ $sql = "SELECT DISTINCT district FROM tc_district WHERE valid=1 ORDER BY district ASC";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $districts = '';
+ $num_districts=0;
+ while ($this->db->next_record()) {
+ $districts[$num_districts] = $this->db->f('district');
+ $this->t->set_var('district',''.$districts[$num_districts].' ');
+ $this->t->fp('d_list','district_list',True);
+ $num_districts++;
+ }
+
+ # get list of individuals who are and are not home teachers
+ $sql = "SELECT * FROM tc_individual WHERE steward='$this->default_stewardship' AND valid=1 ORDER BY name ASC";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $unassigned_ht = '';
+ $assigned_ht = '';
+ $num_ht_assigned=0; $num_ht_unassigned=0;
+ while ($this->db->next_record()) {
+ $individual = $this->db->f('individual');
+ $name = $this->db->f('name');
+ $sql = "SELECT DISTINCT * FROM tc_companion WHERE individual=$individual AND valid=1";
+ $this->db2->query($sql,__LINE__,__FILE__);
+ if ($this->db2->next_record()) {
+ $assigned_ht[$num_ht_assigned]['individual'] = $individual;
+ $assigned_ht[$num_ht_assigned]['name'] = $name;
+ $this->t->set_var('assigned_ht',''.$name.' ');
+ $this->t->fp('aht_list','assigned_ht_list',True);
+ $num_ht_assigned++;
+ } else {
+ $unassigned_ht[$num_ht_unassigned]['individual'] = $individual;
+ $unassigned_ht[$num_ht_unassigned]['name'] = $name;
+ $this->t->set_var('unassigned_ht',''.$name.' ');
+ $this->t->fp('uht_list','unassigned_ht_list',True);
+ $num_ht_unassigned++;
+ }
+ }
+
+ # get list of families who are and are not assigned home teachers
+ $sql = "SELECT * FROM tc_family AS tf JOIN tc_individual AS ti WHERE tf.individual=ti.individual AND tf.valid=1 ORDER BY ti.name ASC";
+ $this->db->query($sql,__LINE__,__FILE__);
+ $unassigned_families = '';
+ $assigned_families = '';
+ $num_families_assigned=0; $num_families_unassigned=0;
+ while ($this->db->next_record()) {
+ $individual = $this->db->f('individual');
+ $family = $this->db->f('family');
+ $name = $this->db->f('name');
+ if ($this->db->f('companionship') != 0) {
+ $assigned_families[$num_families_assigned]['family'] = $family;
+ $assigned_families[$num_families_assigned]['name'] = $name;
+ $this->t->set_var('assigned_family',''.$name.' Family ');
+ $this->t->fp('af_list','assigned_family_list',True);
+ $num_families_assigned++;
+ } else {
+ $unassigned_families[$num_families_unassigned]['family'] = $family;
+ $unassigned_families[$num_families_unassigned]['name'] = $name;
+ $this->t->set_var('unassigned_family',''.$name.' Family ');
+ $this->t->fp('uf_list','unassigned_family_list',True);
+ $num_families_unassigned++;
+ }
+ }
+
+ # populate ht districts table
+ $sandbox_table_data = "
";
+
+ # set up column headers
+ $sandbox_table_data .= "";
+ for ($d = 0; $d < $num_districts; $d++) {
+ $sandbox_table_data .= "District " . $districts[$d] . " ";
+ }
+
+ # get each companionship in each district
+ $sandbox_table_data .= " ";
+ for ($d = 0; $d < $num_districts; $d++) {
+ $sandbox_table_data .= "";
+ $sandbox_table_data .= "";
+ $sql = "SELECT DISTINCT companionship FROM tc_companionship WHERE district=$districts[$d] AND valid=1 ORDER BY companionship ASC";
+ $this->db->query($sql,__LINE__,__FILE__);
+ while ($this->db->next_record()) {
+ $sandbox_table_data .= "";
+ $companionship = $this->db->f('companionship');
+ # get names of companions in this companionship
+ $sql = "SELECT * FROM tc_companion AS tc JOIN tc_individual AS ti WHERE tc.individual=ti.individual AND companionship=$companionship AND tc.valid=1 ORDER BY ti.name ASC";
+ $this->db2->query($sql,__LINE__,__FILE__);
+ $companion_names = "";
+ while ($this->db2->next_record()) {
+ if ($companion_names == "") {
+ $companion_names .= $this->db2->f('name');
+ } else {
+ $companion_names .= " / " . $this->db2->f('name');
+ }
+ }
+ $sandbox_table_data .= "$companion_names ";
+ $sandbox_table_data .= "";
+
+ # get families they visit
+ $sql = "SELECT * FROM tc_companionship AS tcp JOIN (tc_family AS tf, tc_individual AS ti) WHERE tcp.companionship=$companionship AND tcp.companionship=tf.companionship AND tf.individual=ti.individual AND tcp.valid=1";
+ $this->db2->query($sql,__LINE__,__FILE__);
+ while ($this->db2->next_record()) {
+ $family_name = $this->db2->f('name') . " Family";
+ $family_id = $this->db2->f('family');
+ $sandbox_table_data .= "";
+ $sandbox_table_data .= "$family_name ";
+
+ # get 12 months visit data for given family
+ for($m=12; $m >= 0; $m--) {
+ $month = $this->current_month - $m;
+ $year = $this->current_year;
+ if($month <= 0) { $remainder = $month; $month = 12 + $remainder; $year=$year-1; }
+ if($month < 10) { $month = "0"."$month"; }
+ $month_start = "$year"."-"."$month"."-"."01";
+ $month_end = "$year"."-"."$month"."-"."31";
+ $month = "$month"."/"."$year";
+
+ $sql = "SELECT * FROM tc_visit WHERE date >= '$month_start' AND date <= '$month_end' AND companionship!=0 AND family=". $family_id;
+ $query_id = $this->db3->query($sql,__LINE__,__FILE__);
+
+ if($this->db3->next_record()) {
+ if($this->db3->f('visited') == 'y') {
+ $sandbox_table_data .= ' ';
+ } else if($this->db3->f('visited') == 'n') {
+ $sandbox_table_data .= ' ';
+ } else {
+ $sandbox_table_data .= " ";
+ }
+ } else {
+ $sandbox_table_data .= " ";
+ }
+ }
+ $sandbox_table_data .= " ";
+ }
+ $sandbox_table_data .= "
";
+ $sandbox_table_data .= "
";
+ }
+
+ $sandbox_table_data .= "
";
+ $sandbox_table_data .= " ";
+ }
+ $sandbox_table_data .= " ";
+
+ $sandbox_table_data .= "
";
+ $this->t->set_var('district_table',$sandbox_table_data);
+
+ $this->t->pfp('out','ht_sandbox_t');
+ $this->save_sessiondata();
+ }
+
+
function ht_update()
{
$this->t->set_file(array('ht_update_t' => 'ht_update.tpl'));
@@ -1471,9 +1667,9 @@ class tc
// Display a scheduling table for this presidency member
$district_number = '*';
$district_name = $presidency_name;
- $table_title = "District ".$district_number.": ".$district_name.": All indivs with " . $this->ppi_frequency_label . " PPI Not Completed";
+ $not_completed_table_title = "District ".$district_number.": ".$district_name.": All indivs with " . $this->ppi_frequency_label . " PPI Not Completed";
$appt_table_title = "District ".$district_number.": ".$district_name.": ".$this->ppi_frequency_label." PPI Appointment Slots";
- $this->t->set_var('table_title',$table_title);
+ $this->t->set_var('not_completed_table_title',$not_completed_table_title);
$this->t->set_var('appt_table_title',$appt_table_title);
// query the database for all the appointments
@@ -1621,6 +1817,7 @@ class tc
}
} // End for individuals Loop
+ $completed_table_title = "District ".$district_number.": ".$district_name.": All indivs with " . $this->ppi_frequency_label . " PPI Completed";
$name_width=175; $phone_width=100; $date_width=100; $notes_width=300;
$completed_table_width=$name_width + $phone_width + $date_width + $notes_width;
$completed_header_row = "Individual ";
@@ -1628,6 +1825,7 @@ class tc
$completed_header_row.= "Date ";
$completed_header_row.= "PPI Notes ";
+ $this->t->set_var('completed_table_title',$completed_table_title);
$this->t->set_var('table_width',$table_width);
$this->t->set_var('header_row',$header_row);
$this->t->set_var('table_data',$table_data);