X-Git-Url: http://git.pippins.net/embedvideo/.git/%27%20%20%20%20.%20%24GLOBALS%5B%27phpgw%27%5D-%3Elink%28%27inc/jquery/jquery.tablesorter.css%27%29.%27?a=blobdiff_plain;f=inc%2Fclass.tc.inc.php;h=45d012e649d8724e0d6dde2dc320dbb3cc91fc50;hb=7bb723fd27b007ab4f83131542012aee588625aa;hp=49d9a49e615b8f2e5aea3f42dc423b54efe7f188;hpb=428f6a4f9c29acce79cd2a94081185bd3fd262d9;p=eq%2F.git
diff --git a/inc/class.tc.inc.php b/inc/class.tc.inc.php
index 49d9a49..45d012e 100644
--- a/inc/class.tc.inc.php
+++ b/inc/class.tc.inc.php
@@ -15,6 +15,7 @@ class tc
{
var $db;
var $db2;
+ var $db3;
var $t;
var $nextmatchs;
var $grants;
@@ -108,6 +109,18 @@ class tc
echo parse_navbar();
$this->display_app_header();
}
+
+ function logToFile($func, $msg)
+ {
+ // open file
+ $fd = fopen($this->upload_target_path . "/tc_trace.log", "a");
+ // append date/time to message
+ $str = "[" . date("Y/m/d h:i:s", mktime()) . "] [" . $func . "] " . $msg;
+ // write string
+ fwrite($fd, $str . "\n");
+ // close file
+ fclose($fd);
+ }
function save_sessiondata()
{
@@ -190,7 +203,7 @@ class tc
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.ht_view'));
$this->t->set_var('title','Hometeaching');
- $sql = "SELECT * FROM tc_district where valid=1 ORDER BY district ASC";
+ $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;
while ($this->db->next_record()) {
@@ -242,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__);
@@ -258,7 +271,7 @@ class tc
$table_data.= "
$companion_table_entry
";
// Get the names of the families assigned this home teaching companionship
- $sql = "SELECT * from tc_family where valid=1 AND companionship=".$unique_companionships[$j]['companionship'];
+ $sql = "SELECT * FROM tc_family AS tf JOIN tc_individual AS ti WHERE tf.individual=ti.individual AND tf.valid=1 AND tf.companionship=".$unique_companionships[$j]['companionship'];
$sql = $sql . " ORDER BY name ASC";
$this->db->query($sql,__LINE__,__FILE__);
$k=0;
@@ -474,8 +487,8 @@ class tc
$table_data.= "
$companion_table_entry
";
// Get the names of the families assigned this home teaching companionship
- $sql = "SELECT * from tc_family where valid=1 AND companionship=".$unique_companionships[$j]['companionship'];
- $sql = $sql . " ORDER BY 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.companionship=".$unique_companionships[$j]['companionship'];
+ $sql = $sql . " ORDER BY ti.name ASC";
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record()) {
$family_name = $this->db->f('name');
@@ -584,7 +597,7 @@ class tc
$this->db2->query($sql,__LINE__,__FILE__);
if($this->db2->next_record()) {
$activity_list[$i]['name'] = $this->db2->f('name');
- $activity_list[$i]['code'] = $this->db2->f('code');
+ $activity_list[$i]['abbreviation'] = $this->db2->f('abbreviation');
}
$i++;
}
@@ -638,7 +651,7 @@ class tc
$this->db2->query($sql,__LINE__,__FILE__);
if($this->db2->next_record()) {
$this->t->set_var('name', $this->db2->f('name'));
- $this->t->set_var('code', $this->db2->f('code'));
+ $this->t->set_var('abbreviation', $this->db2->f('abbreviation'));
}
$this->t->set_var('lang_name','Assignment');
$this->t->set_var('lang_date','Date');
@@ -679,7 +692,7 @@ class tc
for ($i=0; $i < count($names); $i++) {
//$this->nextmatchs->template_alternate_row_color(&$this->t);
- $this->t->set_var('indiv_name',$names[$i]);
+ $this->t->set_var('individual_name',$names[$i]);
if(($i+1) % 3 == 0) {
$this->t->set_var('table_sep',"
");
} else {
@@ -721,7 +734,7 @@ class tc
// Re-add the individuals who are checked as having participated in this activity
$indivs = get_var('individual_name',array('POST'));
if(is_array($indivs)) { // Only do the foreach loop if we have a valid array of indivs to work with
- foreach ($indivs as $indiv) {
+ foreach ($indivs as $individual) {
$this->db->query("INSERT INTO tc_participation (individual,activity) " .
"VALUES (" . $individual . ",". $activity['activity'] . ")",__LINE__,__FILE__);
}
@@ -748,7 +761,7 @@ class tc
}
$indivs = get_var('individual_name',array('POST'));
- foreach ($indivs as $indiv)
+ foreach ($indivs as $individual)
{
$this->db->query("INSERT INTO tc_participation (individual,activity) " .
"VALUES (" . $individual . ",". $activity['activity'] . ")",__LINE__,__FILE__);
@@ -792,7 +805,7 @@ class tc
while ($this->db->next_record()) {
$assignments[$i]['assignment'] = $this->db->f('assignment');
$assignments[$i]['name'] = $this->db->f('name');
- $assignments[$i]['code'] = $this->db->f('code');
+ $assignments[$i]['abbreviation'] = $this->db->f('abbreviation');
$i++;
}
@@ -812,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()) {
@@ -870,7 +883,7 @@ class tc
$this->t->set_block('assign_view_t','assign_view','list');
$this->t->set_var('lang_name','Assignment Name');
- $this->t->set_var('lang_code','Code');
+ $this->t->set_var('lang_code','Abbreviation');
$sql = "SELECT * FROM tc_assignment ORDER BY name ASC";
$this->db->query($sql,__LINE__,__FILE__);
@@ -880,14 +893,14 @@ class tc
while ($this->db->next_record()) {
$assignment_list[$i]['assignment'] = $this->db->f('assignment');
$assignment_list[$i]['name'] = $this->db->f('name');
- $assignment_list[$i]['code'] = $this->db->f('code');
+ $assignment_list[$i]['abbreviation'] = $this->db->f('abbreviation');
$i++;
}
for ($i=0; $i < count($assignment_list); $i++) {
$this->nextmatchs->template_alternate_row_color(&$this->t);
$this->t->set_var('name',$assignment_list[$i]['name']);
- $this->t->set_var('code',$assignment_list[$i]['code']);
+ $this->t->set_var('abbreviation',$assignment_list[$i]['abbreviation']);
$link_data['menuaction'] = 'tc.tc.assign_update';
$link_data['assignment'] = $assignment_list[$i]['assignment'];
@@ -921,10 +934,10 @@ class tc
if($action == 'save') {
$assignment['name'] = get_var('name',array('POST'));
- $assignment['code'] = get_var('code',array('POST'));
+ $assignment['abbreviation'] = get_var('abbreviation',array('POST'));
$this->db->query("UPDATE tc_assignment set " .
" name='" . $assignment['name'] . "'" .
- ", code='" . $assignment['code'] . "'" .
+ ", abbreviation='" . $assignment['abbreviation'] . "'" .
" WHERE assignment=" . $assignment['assignment'],__LINE__,__FILE__);
$this->assign_view();
@@ -933,10 +946,10 @@ class tc
if($action == 'insert') {
$assignment['name'] = get_var('name',array('POST'));
- $assignment['code'] = get_var('code',array('POST'));
- $this->db->query("INSERT INTO tc_assignment (name,code) " .
+ $assignment['abbreviation'] = get_var('abbreviation',array('POST'));
+ $this->db->query("INSERT INTO tc_assignment (name,abbreviation) " .
"VALUES ('" . $assignment['name'] . "','" .
- $assignment['code'] . "')",__LINE__,__FILE__);
+ $assignment['abbreviation'] . "')",__LINE__,__FILE__);
$this->assign_view();
return false;
}
@@ -944,7 +957,7 @@ class tc
if($action == 'add') {
$assignment['assignment'] = 0;
$this->t->set_var('name','');
- $this->t->set_var('code','');
+ $this->t->set_var('abbreviation','');
$this->t->set_var('lang_done','Cancel');
$this->t->set_var('lang_action','Adding New Assignment');
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.assign_update&assignment=' .
@@ -957,7 +970,7 @@ class tc
$this->db->query($sql,__LINE__,__FILE__);
$this->db->next_record();
$this->t->set_var('name', $this->db->f('name'));
- $this->t->set_var('code', $this->db->f('code'));
+ $this->t->set_var('abbreviation', $this->db->f('abbreviation'));
$this->t->set_var('lang_done','Cancel');
$this->t->set_var('lang_action','Editing Assignment');
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.assign_update&assignment=' .
@@ -983,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()) {
@@ -1012,7 +1024,7 @@ class tc
while($this->db->next_record()) {
$assignment_list[$i]['assignment'] = $this->db->f('assignment');
$assignment_list[$i]['name'] = $this->db->f('name');
- $assignment_list[$i]['code'] = $this->db->f('code');
+ $assignment_list[$i]['abbreviation'] = $this->db->f('abbreviation');
$i++;
}
@@ -1020,7 +1032,7 @@ class tc
$total_width=$individual_width+$part_width;
for ($i=0; $i < count($assignment_list); $i++) {
$this->t->set_var('assignment_name',$assignment_list[$i]['name']);
- $this->t->set_var('assignment_code',$assignment_list[$i]['code']);
+ $this->t->set_var('assignment_abbreviation',$assignment_list[$i]['abbreviation']);
$this->t->fp('list1','header_list',True);
$total_width += $assignment_width;
}
@@ -1094,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()) {
@@ -1112,7 +1123,7 @@ class tc
while($this->db->next_record()) {
$assignment_list[$i]['assignment'] = $this->db->f('assignment');
$assignment_list[$i]['name'] = $this->db->f('name');
- $assignment_list[$i]['code'] = $this->db->f('code');
+ $assignment_list[$i]['abbreviation'] = $this->db->f('abbreviation');
$i++;
}
@@ -1133,7 +1144,7 @@ class tc
for ($i=0; $i < count($assignment_list); $i++) {
$this->t->set_var('assignment_name',$assignment_list[$i]['name']);
- $this->t->set_var('assignment_code',$assignment_list[$i]['code']);
+ $this->t->set_var('assignment_abbreviation',$assignment_list[$i]['abbreviation']);
$this->t->fp('list1','header_list',True);
$total_width += $assignment_width;
$total_willing[$i] = 0;
@@ -1261,7 +1272,7 @@ class tc
while ($this->db->next_record()) {
$assignment = $this->db->f('assignment');
$assignment_name = $this->db->f('name');
- $assignment_code = $this->db->f('code');
+ $assignment_abbreviation = $this->db->f('abbreviation');
$this->nextmatchs->template_alternate_row_color(&$this->t);
$table_data.="
$assignment_name
";
@@ -1353,7 +1364,7 @@ class tc
$year = date('Y');
// Get the President
- $sql = "SELECT * FROM tc_presidency where president=1 and valid=1";
+ $sql = "SELECT * FROM tc_presidency AS tp JOIN tc_individual AS ti where tp.individual=ti.individual AND tp.president=1 AND tp.valid=1";
$this->db->query($sql,__LINE__,__FILE__);
if($this->db->next_record()) {
$president_name = $this->db->f('name');
@@ -1364,16 +1375,7 @@ class tc
$interviewer = $this->db->f('individual');
$district_number = '*';
$district_name = $president_name;
- $sql = "SELECT * FROM tc_individual where individual='$president_id'";
- $this->db2->query($sql,__LINE__,__FILE__);
- if($this->db2->next_record()) {
- $mls_indiv_id = $this->db2->f('mls_indiv_id');
- }
- $sql = "SELECT * FROM tc_individual where mls_indiv_id='$mls_indiv_id'";
- $this->db2->query($sql,__LINE__,__FILE__);
- if($this->db2->next_record()) {
- $president_address = $this->db2->f('address');
- }
+ $president_address = $this->db->f('address');
} else {
print "
-E- Unable to locate President in tc_presidency table
";
return;
@@ -1406,18 +1408,20 @@ class tc
}
// Save any changes made to the ppi notes table
- $new_data = get_var('ppi_notes',array('POST'));
+ $new_data = get_var('notes',array('POST'));
foreach ($new_data as $entry) {
- $ppi_notes = $entry['notes'];
+ $notes = $entry['notes'];
$individual = $entry['individual'];
- $ppi_pri = $entry['pri'];
+ $priority = $entry['pri'];
// Perform database save actions here
- $this->db->query("UPDATE tc_individual set " .
- " ppi_notes='" . $ppi_notes . "'" .
- ",ppi_pri='" . $ppi_pri . "'" .
- " WHERE individual=" . $individual,__LINE__,__FILE__);
-
+ $sql = "SELECT * FROM tc_individual WHERE individual='$individual'";
+ $this->db->query($sql,__LINE__,__FILE__);
+ if ($this->db->next_record()) {
+ $scheduling_priority = $this->db->f('scheduling_priority');
+ //$this->logToFile("ppi_sched", "UPDATE tc_scheduling_priority SET priority='$priority', notes=\"$notes\" WHERE scheduling_priority='$scheduling_priority'");
+ $this->db2->query("UPDATE tc_scheduling_priority SET priority='$priority', notes=\"$notes\" WHERE scheduling_priority='$scheduling_priority'", __LINE__, __FILE__);
+ }
}
$take_me_to_url = $GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.ppi_sched');
@@ -1425,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;
@@ -1507,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 where valid=1 and steward='Elder' ORDER BY ppi_pri ASC, 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;
@@ -1517,8 +1519,8 @@ class tc
$individual[$i] = $this->db->f('individual');
$indiv_name[$i] = $this->db->f('name');
$indiv_phone[$individual[$i]] = $this->db->f('phone');
- $indiv_ppi_pri[$individual[$i]] = $this->db->f('ppi_pri');
- $indiv_ppi_notes[$individual[$i]] = $this->db->f('ppi_notes');
+ $indiv_priority[$individual[$i]] = $this->db->f('priority');
+ $indiv_notes[$individual[$i]] = $this->db->f('notes');
$i++;
$total_indivs++;
}
@@ -1529,8 +1531,8 @@ class tc
$id = $individual[$i];
$name = $indiv_name[$i];
$phone = $indiv_phone[$id];
- $ppi_pri = $indiv_ppi_pri[$id];
- $ppi_notes = $indiv_ppi_notes[$id];
+ $priority = $indiv_priority[$id];
+ $notes = $indiv_notes[$id];
// If this individual has had a yearly PPI this year, don't show him on the schedule list
$year_start = $year - 1 . "-12-31"; $year_end = $year + 1 . "-01-01";
@@ -1558,12 +1560,12 @@ class tc
$this->t->set_var('tr_color',$tr_color);
$table_data.= "