2 /**************************************************************************\
4 * http://www.phpgroupware.org *
5 * ----------------------------------------------- *
6 * This program is free software; you can redistribute it and/or modify it *
7 * under the terms of the GNU General Public License as published by the *
8 * Free Software Foundation; either version 2 of the License, or (at your *
9 * option) any later version. *
10 \**************************************************************************/
11 /* $Id: class.eq.inc.php,v 1.1.1.1 2001/05/20 07:40:32 seek3r Exp $ */
22 var $default_ht_num_months;
23 var $default_ppi_num_months;
24 var $default_ppi_num_years;
25 var $default_att_num_months;
27 var $public_functions = array
46 $this->default_ht_num_months = 1;
47 $this->default_ppi_num_months = 1;
48 $this->default_ppi_num_years = 0;
49 $this->default_att_num_months = 1;
51 $this->db = $GLOBALS['phpgw']->db;
52 $this->db2 = $this->db;
53 $this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
54 $this->t = $GLOBALS['phpgw']->template;
55 $this->account = $GLOBALS['phpgw_info']['user']['account_id'];
56 $this->grants = $GLOBALS['phpgw']->acl->get_grants('eq');
57 $this->grants[$this->account] = PHPGW_ACL_READ + PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE;
59 $this->jscal = CreateObject('phpgwapi.jscalendar'); // before phpgw_header() !!!
60 $this->cal_options = 'daFormat : "%Y-%m-%d",
61 ifFormat : "%Y-%m-%d",
65 $GLOBALS['phpgw_info']['flags']['app_header'] = 'Elders Quorum Tools';
66 $GLOBALS['phpgw']->common->phpgw_header();
68 $this->display_app_header();
71 function save_sessiondata()
76 function display_app_header()
78 $this->t->set_file(array('eq_header' => 'header.tpl'));
80 if (isset($phpgw_info['user']['preferences']['eq']['eq_font']))
82 $font = $phpgw_info['user']['preferences']['eq']['eq_font'];
89 $this->t->set_var('bg_color',$phpgw_info['theme']['th_bg']);
90 $this->t->set_var('font',$font);
91 $link_data['menuaction'] = 'eq.eq.ht_view';
92 $this->t->set_var('link_hometeaching',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
93 $this->t->set_var('lang_hometeaching','HomeTeaching');
94 $link_data['menuaction'] = 'eq.eq.act_list';
95 $this->t->set_var('link_activity',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
96 $this->t->set_var('lang_activity','Activities');
97 $link_data['menuaction'] = 'eq.eq.par_view';
98 $this->t->set_var('link_participation',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
99 $this->t->set_var('lang_participation','Participation');
100 $link_data['menuaction'] = 'eq.eq.ppi_view';
101 $this->t->set_var('link_ppi',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
102 $this->t->set_var('lang_ppi','PPIs');
103 $link_data['menuaction'] = 'eq.eq.vis_view';
104 $this->t->set_var('link_visit',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
105 $this->t->set_var('lang_visit','Visits');
106 $link_data['menuaction'] = 'eq.eq.att_view';
107 $this->t->set_var('link_attendance',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
108 $this->t->set_var('lang_attendance','Attendance');
109 $link_data['menuaction'] = 'eq.eq.dir_view';
110 $this->t->set_var('link_dir',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
111 $this->t->set_var('lang_dir','Directory');
113 $this->t->pparse('out','eq_header');
118 $this->t->set_file(array('ht_view_t' => 'ht_view.tpl'));
119 $this->t->set_block('ht_view_t','district_list','list');
121 $this->t->set_var('linkurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ht_view'));
122 $num_months = get_var('num_months',array('GET','POST'));
123 if($num_months == '') { $num_months = $this->default_ht_num_months; }
124 $this->t->set_var('num_months',$num_months);
125 $this->t->set_var('lang_filter','Filter');
126 if($num_months == 1) { $this->t->set_var('lang_num_months','Month of History'); }
127 else { $this->t->set_var('lang_num_months','Months of History'); }
129 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ht_view'));
130 $this->t->set_var('title','Hometeaching');
132 $sql = "SELECT * FROM eq_district where valid=1 ORDER BY district ASC";
133 $this->db->query($sql,__LINE__,__FILE__);
135 while ($this->db->next_record())
137 $districts[$i]['district'] = $this->db->f('district');
138 $districts[$i]['name'] = $this->db->f('name');
139 $districts[$i]['supervisor'] = $this->db->f('supervisor');
143 $sql = "SELECT * FROM eq_elder where valid=1 ORDER BY elder ASC";
144 $this->db->query($sql,__LINE__,__FILE__);
146 while ($this->db->next_record())
148 $elder_id[$i] = $this->db->f('elder');
149 $elder_name[$i] = $this->db->f('name');
150 $elder_phone[$elder_id[$i]] = $this->db->f('phone');
153 array_multisort($elder_name, $elder_id);
155 // Make an array mapping elder_ids to elder_names
156 for($i=0; $i < count($elder_id); $i++) {
158 $elders[$id] = $elder_name[$i];
161 $sql = "SELECT * FROM eq_aaronic where valid=1 ORDER BY aaronic ASC";
162 $this->db->query($sql,__LINE__,__FILE__);
163 while ($this->db->next_record())
165 $aaronic_id = $this->db->f('aaronic');
166 $aaronic[$aaronic_id]['name'] = $this->db->f('name');
167 $aaronic[$aaronic_id]['phone'] = $this->db->f('phone');
171 $this->nextmatchs->template_alternate_row_color(&$this->t);
172 for ($i=0; $i < count($districts); $i++) {
173 $this->t->set_var('district_number',$districts[$i]['district']);
174 $this->t->set_var('district_name',$districts[$i]['name']);
175 $supervisor = $districts[$i]['supervisor'];
176 $unique_companionships='';
178 // Select all the unique companionship numbers for this district
179 $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $districts[$i]['district'];
180 $this->db->query($sql,__LINE__,__FILE__);
182 while ($this->db->next_record())
184 $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
188 $comp_width=450; $visit_width=25; $table_width=$comp_width + $num_months*$visit_width;
189 $table_data=""; $num_companionships = 0; $num_families = 0;
190 for($m=$num_months; $m >= 0; $m--) { $visits[$m] = 0; }
191 for ($j=0; $j < count($unique_companionships); $j++) {
192 $companion_table_entry = "";
193 // Select all the companions in each companionship
194 $sql = "SELECT * FROM eq_companionship where valid=1 and ".
195 "companionship=". $unique_companionships[$j]['companionship'];
196 $this->db->query($sql,__LINE__,__FILE__);
198 while ($this->db->next_record())
200 // Get this companions information
201 if($companion_table_entry != "") { $companion_table_entry .= "<td> / </td>"; }
202 $companionship = $this->db->f('companionship');
203 $elder_id = $this->db->f('elder');
204 $aaronic_id = $this->db->f('aaronic');
206 $name = $elders[$elder_id];
207 $phone = $elder_phone[$elder_id];
209 else if($aaronic_id) {
210 $name = $aaronic[$aaronic_id]['name'];
211 $phone = $aaronic[$aaronic_id]['phone'];
213 $companion_table_entry .= "<td title=\"$phone\"><b>$name</b></td>";
215 $table_data.= "<tr bgcolor=#d3dce3><td colspan=20><table><tr>$companion_table_entry</tr></table><hr></td></tr>";
217 // Get the names of the families assigned this home teaching companionship
218 $sql = "SELECT * from eq_family where valid=1 AND companionship=".$unique_companionships[$j]['companionship'];
219 $this->db->query($sql,__LINE__,__FILE__);
221 while ($this->db->next_record())
223 $num_families++; $total_families++;
224 $family_name = $this->db->f('name');
225 $family_id = $this->db->f('family');
226 $this->nextmatchs->template_alternate_row_color(&$this->t);
227 $table_data.="<tr bgcolor=". $this->t->get_var('tr_color') ."><td>$family_name Family</td>";
228 // Find out how many times Visits were performed by this companionship
229 // in the past $num_months for this Family
230 $header_row="<th width=$comp_width><font size=-2>Families</th>";
231 for($m=$num_months; $m >= 0; $m--) {
232 if(`date '+%d'` == 31) { $d = 1; } else { $d = 0; }
233 $month = date('m/Y', strtotime('-'.$m.' month -'.$d.' day'));
234 $month_start = date('Y-m', strtotime('-'.$m.' month -'.$d.' day')); $month_start .= "-01";
235 $month_end = date('Y-m', strtotime('-'.$m.' month -'.$d.' day')); $month_end .= "-31";
236 // Add this to the query to filter on only visits made by this companionship:
237 // " AND companionship=" . $unique_companionships[$j]['companionship'].
238 $sql = "SELECT * FROM eq_visit WHERE date >= '$month_start' AND date <= '$month_end' ".
239 " AND companionship!=0".
240 " AND family=". $family_id;
241 $this->db2->query($sql,__LINE__,__FILE__);
242 $link_data['menuaction'] = 'eq.eq.ht_update';
243 $link_data['date'] = $month_start;
244 $link_data['month_start'] = $month_start;
245 $link_data['month_end'] = $month_end;
246 $link_data['month'] = $month;
247 $link_data['district'] = $districts[$i]['district'];
248 $link_data['district_name'] = $districts[$i]['name'];
249 $link_data['action'] = 'view';
250 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
251 $header_row .= "<th width=$visit_width><font size=-2><a href=$link>$month</a></th>";
252 if(!$total_visits[$m]) { $total_visits[$m] = 0; }
253 if($this->db2->next_record()) {
254 if($this->db2->f('visited') == 'y') {
255 $visits[$m]++; $total_visits[$m]++;
256 $table_data .= '<td align=center><a href="'.$link.'"><img src="checkmark.gif"></a></td>';
258 else if($this->db2->f('visited') == 'n') {
259 $table_data .= '<td align=center><a href="'.$link.'"><img src="x.gif"></a></td>';
262 $visits[$m]++; $total_visits[$m]++;
263 $table_data .= "<td> </td>";
267 $visits[$m]++; $total_visits[$m]++;
268 $table_data .= "<td> </td>";
271 $table_data .= "</tr>";
274 $table_data .= "<tr><td colspan=20></td></tr>";
276 $table_data .= "<tr><td colspan=20><hr></td></tr>";
277 $stat_data = "<tr><td><b><font size=-2>$num_families Families<br>Visit Totals:</font></b></td>";
279 for($m=$num_months; $m >=0; $m--) {
280 $percent = ceil(($visits[$m] / $num_families)*100);
281 $stat_data .= "<td align=center><font size=-2><b>$visits[$m]<br>$percent%</font></b></td>";
283 $stat_data .= "</tr>";
285 $this->t->set_var('table_width',$table_width);
286 $this->t->set_var('header_row',$header_row);
287 $this->t->set_var('table_data',$table_data);
288 $this->t->set_var('stat_data',$stat_data);
289 $this->t->fp('list','district_list',True);
292 $totals = "<tr><td><b><font size=-2>$total_families Total Families<br>Visit Totals:</font></b></td>";
293 for($m=$num_months; $m >=0; $m--) {
294 $percent = ceil(($total_visits[$m] / $total_families)*100);
295 $totals .= "<td align=center><font size=-2><b>$total_visits[$m]<br>$percent%</font></b></td>";
299 $this->t->set_var('totals',$totals);
301 $this->t->pfp('out','ht_view_t');
302 $this->save_sessiondata();
308 $this->t->set_file(array('ht_update_t' => 'ht_update.tpl'));
309 $this->t->set_block('ht_update_t','district_list','list');
310 $this->t->set_block('ht_update_t','save','savehandle');
312 $district = get_var('district',array('GET','POST'));
313 $district_name = get_var('district_name',array('GET','POST'));
314 $date = get_var('date',array('GET','POST'));
315 $month = get_var('month',array('GET','POST'));
316 $month_start = get_var('month_start',array('GET','POST'));
317 $month_end = get_var('month_end',array('GET','POST'));
318 $action = get_var('action',array('GET','POST'));
320 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ht_view'));
321 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ht_update&action=save'));
322 $this->t->set_var('lang_done','Cancel');
323 $this->t->set_var('district_name',$district_name);
324 $this->t->set_var('district_number',$district);
325 $this->t->set_var('title','Hometeaching Update ' . $month);
326 $this->t->set_var('date',$date);
328 if($action == 'save')
330 // Get a list of all the companionships in this district
331 $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $district;
332 $this->db->query($sql,__LINE__,__FILE__);
334 while ($this->db->next_record())
336 $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
339 for ($j=0; $j < count($unique_companionships); $j++)
341 // FIXME: We won't be able to go back and edit history on families that have been
342 // reassigned to a different companionship. The following delete command will not delete
343 // the history of visits under an older companionship, only the ones for the existing
344 // companionship. This will lead to duplicate visits being entered for an older
345 // month for the same family, making it impossible to change the past history once
346 // a family is reassigned. However, you will be able to view the history just fine.
348 //$comp=$unique_companionships[$j]['companionship'];
349 //print "deleting from eq_visit where companionship=$comp and date=$date and district=$district<br>";
350 // Delete all the visits that have taken place for all families for this month
351 $this->db->query("DELETE from eq_visit where companionship=" . $unique_companionships[$j]['companionship'] .
352 " AND " . "date='" . $date . "'",__LINE__,__FILE__);
355 // Now, add the visits that are checked for this month
356 $new_data = get_var('family_visited',array('POST'));
357 foreach ($new_data as $family)
359 foreach ($family as $data)
361 //print "family_visited: $data <br>";
362 $data_array = explode("/",$data);
363 $family_id = $data_array[0];
364 $companionship = $data_array[1];
365 $date = $data_array[2];
366 $visited = $data_array[3];
367 if($visited == "") { $visited = $data_array[4]; }
368 //print "family_id: $family_id companionship: $companionship date: $date visited: $visited<br>";
369 $this->db->query("INSERT INTO eq_visit (family,companionship,date,notes,visited) "
370 . "VALUES (" . $family_id .",". $companionship .",'". $date ."','','". $visited ."')",__LINE__,__FILE__);
377 $sql = "SELECT * FROM eq_elder where valid=1 ORDER BY elder ASC";
378 $this->db->query($sql,__LINE__,__FILE__);
380 while ($this->db->next_record())
382 $elder_id[$i] = $this->db->f('elder');
383 $elder_name[$i] = $this->db->f('name');
384 $elder_phone[$elder_id[$i]] = $this->db->f('phone');
387 array_multisort($elder_name, $elder_id);
389 // Make an array mapping elder_ids to elder_names
390 for($i=0; $i < count($elder_id); $i++) {
392 $elders[$id] = $elder_name[$i];
395 $sql = "SELECT * FROM eq_aaronic where valid=1 ORDER BY aaronic ASC";
396 $this->db->query($sql,__LINE__,__FILE__);
397 while ($this->db->next_record())
399 $aaronic_id = $this->db->f('aaronic');
400 $aaronic[$aaronic_id]['name'] = $this->db->f('name');
401 $aaronic[$aaronic_id]['phone'] = $this->db->f('phone');
404 // Select all the unique companionship numbers for this district
405 $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $district;
406 $this->db->query($sql,__LINE__,__FILE__);
407 $j=0; $unique_companionships='';
408 while ($this->db->next_record())
410 $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
414 $comp_width=300; $visit_width=25; $table_width=$comp_width + $visit_width;
415 $table_data=""; $num_companionships = 0; $num_families = 0; $visits=0;
416 for ($j=0; $j < count($unique_companionships); $j++) {
417 $companion_table_entry = "";
418 // Select all the companions in each companionship
419 $sql = "SELECT * FROM eq_companionship where valid=1 and ".
420 "companionship=". $unique_companionships[$j]['companionship'];
421 $this->db->query($sql,__LINE__,__FILE__);
423 while ($this->db->next_record())
425 // Get this companions information
426 if($companion_table_entry != "") { $companion_table_entry .= "<td> / </td>"; }
427 $companionship = $this->db->f('companionship');
428 $elder_id = $this->db->f('elder');
429 $aaronic_id = $this->db->f('aaronic');
431 $name = $elders[$elder_id];
432 $phone = $elder_phone[$elder_id];
434 else if($aaronic_id) {
435 $name = $aaronic[$aaronic_id]['name'];
436 $phone = $aaronic[$aaronic_id]['phone'];
438 $companion_table_entry .= "<td title=\"$phone\"><b>$name</b></td>";
440 $table_data.= "<tr bgcolor=#d3dce3><td colspan=20><table><tr>$companion_table_entry</tr></table><hr></td></tr>";
442 // Get the names of the families assigned this home teaching companionship
443 $sql = "SELECT * from eq_family where valid=1 AND companionship=".$unique_companionships[$j]['companionship'];
444 $this->db->query($sql,__LINE__,__FILE__);
445 while ($this->db->next_record())
447 $num_families++; $total_families++;
448 $family_name = $this->db->f('name');
449 $family_id = $this->db->f('family');
450 $this->nextmatchs->template_alternate_row_color(&$this->t);
451 $table_data.="<tr bgcolor=". $this->t->get_var('tr_color') ."><td>$family_name Family</td>";
453 $header_row="<th width=$comp_width><font size=-2>Families</th>";
454 $sql = "SELECT * FROM eq_visit WHERE date >= '$month_start' AND date <= '$month_end' ".
455 " AND companionship!=0".
456 " AND family=". $family_id;
457 $this->db2->query($sql,__LINE__,__FILE__);
458 $value = $family_id . "/" . $unique_companionships[$j]['companionship'] . "/" . $date;
459 $header_row .= "<th width=$visit_width><font size=-2><a href=$link>$month</a></th>";
460 if(!$total_visits) { $total_visits = 0; }
461 if($this->db2->next_record()) {
462 if($this->db2->f('visited') == 'y') {
463 $visits++; $total_visits++;
464 $table_data .= '<td width=100 align=center>';
465 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/y" checked>Y';
466 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/n">N';
467 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/"> ';
468 $table_data .= '</td>';
469 } else if($this->db2->f('visited') == 'n') {
470 $table_data .= '<td width=100 align=center>';
471 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/y">Y';
472 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/n" checked>N';
473 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/">';
474 $table_data .= '</td>';
476 $table_data .= '<td width=100 align=center>';
477 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/y">Y';
478 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/n">N';
479 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/" checked> ';
480 $table_data .= '</td>';
485 $table_data .= '<td width=100 align=center>';
486 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/y">Y';
487 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/n">N';
488 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/" checked> ';
489 $table_data .= '</td>';
492 $table_data .= "</tr>";
493 $table_data .= "<tr><td colspan=20></td></tr>";
495 $table_data .= "<tr><td colspan=20><hr></td></tr>";
496 $stat_data = "<tr><td><b><font size=-2>$num_families Families<br>Visit Totals:</font></b></td>";
498 $percent = ceil(($visits / $num_families)*100);
499 $stat_data .= "<td align=center><font size=-2><b>$visits<br>$percent%</font></b></td>";
500 $stat_data .= "</tr>";
502 $this->t->set_var('table_width',$table_width);
503 $this->t->set_var('header_row',$header_row);
504 $this->t->set_var('table_data',$table_data);
505 $this->t->set_var('stat_data',$stat_data);
506 $this->t->fp('list','district_list',True);
508 $this->t->set_var('lang_reset','Clear Form');
509 $this->t->set_var('lang_save','Save Changes');
510 $this->t->set_var('savehandle','');
512 $this->t->pfp('out','ht_update_t');
513 $this->t->pfp('addhandle','save');
515 $this->save_sessiondata();
520 $this->t->set_file(array('act_list_t' => 'act_list.tpl'));
521 $this->t->set_block('act_list_t','act_list','list');
523 $this->t->set_var('lang_name','Activity Name');
524 $this->t->set_var('lang_date','Date');
526 $sql = "SELECT * FROM eq_activity ORDER BY date DESC";
527 $this->db->query($sql,__LINE__,__FILE__);
528 $total_records = $this->db->num_rows();
531 while ($this->db->next_record())
533 $activity_list[$i]['name'] = $this->db->f('name');
534 $activity_list[$i]['date'] = $this->db->f('date');
535 $activity_list[$i]['activity'] = $this->db->f('activity');
539 for ($i=0; $i < count($activity_list); $i++)
541 $this->nextmatchs->template_alternate_row_color(&$this->t);
542 $this->t->set_var('name',$activity_list[$i]['name']);
543 $this->t->set_var('date',$activity_list[$i]['date']);
545 $link_data['menuaction'] = 'eq.eq.act_view';
546 $link_data['activity'] = $activity_list[$i]['activity'];
547 $link_data['action'] = 'view';
548 $this->t->set_var('view',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
549 $this->t->set_var('lang_view','View');
551 $link_data['menuaction'] = 'eq.eq.act_update';
552 $link_data['activity'] = $activity_list[$i]['activity'];
553 $link_data['action'] = 'edit';
554 $this->t->set_var('edit',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
555 $this->t->set_var('lang_edit','Edit');
557 $link_data['menuaction'] = 'eq.eq.act_update';
558 $link_data['activity'] = '0';
559 $link_data['action'] = 'add';
560 $this->t->set_var('add','<form method="POST" action="' . $GLOBALS['phpgw']->link('/eq/index.php',$link_data)
561 . '"><input type="submit" name="Add" value="' . 'Add Activity' .'"></font></form>');
563 $this->t->fp('list','act_list',True);
566 $this->t->pfp('out','act_list_t');
567 $this->save_sessiondata();
572 $this->t->set_file(array('act_view_t' => 'act_view.tpl'));
573 $this->t->set_block('act_view_t','part_list','list');
575 $sql = "SELECT * FROM eq_activity WHERE activity=" . intval(get_var('activity',array('GET','POST')));
576 $this->db->query($sql,__LINE__,__FILE__);
577 $this->db->next_record();
578 $this->t->set_var('name', $this->db->f('name'));
579 $this->t->set_var('date', $this->db->f('date'));
580 $this->t->set_var('notes', $this->db->f('notes'));
582 $this->t->set_var('lang_name','Activity Name');
583 $this->t->set_var('lang_date','Date');
584 $this->t->set_var('lang_notes','Notes');
585 $this->t->set_var('lang_done','Done');
586 $this->t->set_var('lang_action','View');
588 $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
589 $this->t->set_var('tr_color',$tr_color);
591 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.act_list'));
593 $link_data['menuaction'] = 'eq.eq.act_update';
594 $link_data['activity'] = get_var('activity',array('GET','POST'));
595 $link_data['action'] = 'edit';
596 $this->t->set_var('edit',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
597 $this->t->set_var('lang_edit','Edit');
598 $this->t->set_var('cal_date',$this->db->f('date'));
600 // Now find out which elders participated in this activity
601 $sql = "SELECT * FROM eq_participation WHERE activity=" . intval(get_var('activity',array('GET','POST')));
602 $this->db->query($sql,__LINE__,__FILE__);
603 $total_records = $this->db->num_rows();
606 while ($this->db->next_record())
608 $part_list[$i]['elder'] = $this->db->f('elder');
612 for ($i=0; $i < count($part_list); $i++)
614 $sql = "SELECT * FROM eq_elder WHERE elder=" . $part_list[$i]['elder'];
615 $this->db->query($sql,__LINE__,__FILE__);
616 $this->db->next_record();
617 $names[$i] = $this->db->f('name');
620 for ($i=0; $i < count($names); $i++)
622 //$this->nextmatchs->template_alternate_row_color(&$this->t);
623 $this->t->set_var('elder_name',$names[$i]);
624 if(($i+1) % 3 == 0) { $this->t->set_var('table_sep',"</td></tr><tr>"); }
625 else { $this->t->set_var('table_sep',"</td>"); }
626 if(($i) % 3 == 0) { $this->nextmatchs->template_alternate_row_color(&$this->t); }
627 $this->t->fp('list','part_list',True);
630 $this->t->pfp('out','act_view_t');
631 $this->save_sessiondata();
634 function act_update()
636 $this->t->set_file(array('form' => 'act_update.tpl'));
637 $this->t->set_block('form','elder_list','list');
638 $this->t->set_block('form','add','addhandle');
639 $this->t->set_block('form','edit','edithandle');
640 $this->t->set_var('lang_done','Done');
642 $action = get_var('action',array('GET','POST'));
643 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.act_list'));
644 $activity['activity'] = intval(get_var('activity',array('GET','POST')));
646 if($action == 'save')
648 $activity['name'] = $this->db->db_addslashes(get_var('name',array('POST')));
649 $activity['date'] = $this->db->db_addslashes(get_var('date',array('POST')));
650 $activity['notes']= $this->db->db_addslashes(get_var('notes',array('POST')));
651 $this->db->query("UPDATE eq_activity set " .
652 " name='" . $activity['name'] .
653 "', date='" . $activity['date'] . "'" .
654 ", notes='" . $activity['notes'] . "'" .
655 " WHERE activity=" . $activity['activity'],__LINE__,__FILE__);
657 // Delete all the elders who have particiapted in this activity
658 $this->db->query("DELETE from eq_participation where activity=".$activity['activity'],__LINE__,__FILE__);
660 // Re-add the elders who are checked as having participated in this activity
661 $elders = get_var('elder_name',array('POST'));
662 foreach ($elders as $elder)
664 $this->db->query("INSERT INTO eq_participation (elder,activity) "
665 . "VALUES (" . $elder . ",". $activity['activity'] . ")",__LINE__,__FILE__);
672 if($action == 'insert')
674 $activity['name'] = $this->db->db_addslashes(get_var('name',array('POST')));
675 $activity['date'] = $this->db->db_addslashes(get_var('date',array('POST')));
676 $activity['notes']= $this->db->db_addslashes(get_var('notes',array('POST')));
677 $this->db->query("INSERT INTO eq_activity (name,date,notes) "
678 . "VALUES ('" . $activity['name'] . "','"
679 . $activity['date'] . "','" . $activity['notes'] . "')",__LINE__,__FILE__);
686 $activity['activity'] = 0;
687 $this->t->set_var('cal_date',$this->jscal->input('date','','','','','','',$this->cal_options));
688 $this->t->set_var('name','');
689 $this->t->set_var('date','');
690 $this->t->set_var('notes','');
691 $this->t->set_var('lang_done','Cancel');
692 $this->t->set_var('lang_action','Adding New Activity');
693 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.act_update&activity='
694 . $activity['activity'] . '&action=' . 'insert'));
697 if($action == 'edit')
699 $sql = "SELECT * FROM eq_activity WHERE activity=" . $activity['activity'];
700 $this->db->query($sql,__LINE__,__FILE__);
701 $this->db->next_record();
702 $this->t->set_var('cal_date',$this->jscal->input('date',$this->db->f('date'),'','','','','',$this->cal_options));
703 $this->t->set_var('name', $this->db->f('name'));
704 $this->t->set_var('date', $this->db->f('date'));
705 $this->t->set_var('notes', $this->db->f('notes'));
706 $this->t->set_var('lang_done','Cancel');
707 $this->t->set_var('lang_action','Editing Activity');
708 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.act_update&activity='
709 . $activity['activity'] . '&action=' . 'save'));
713 $sql = "SELECT * FROM eq_elder";
714 $this->db->query($sql,__LINE__,__FILE__);
716 while ($this->db->next_record())
718 if($this->db->f('valid') == 1 || $action != 'add') {
719 $elder_name[$i] = $this->db->f('name');
720 $elder_id[$i] = $this->db->f('elder');
721 $elder_valid[$i] = $this->db->f('valid');
725 array_multisort($elder_name, $elder_id, $elder_valid);
728 for ($i=0; $i < count($elder_id); $i++)
730 //$this->nextmatchs->template_alternate_row_color(&$this->t);
731 $sql = "SELECT * FROM eq_participation where activity=". $activity['activity'] . " AND elder=" . $elder_id[$i];
732 $this->db->query($sql,__LINE__,__FILE__);
733 if($this->db->next_record()) { $this->t->set_var('checked','checked'); $checked=1; }
734 else { $this->t->set_var('checked',''); $checked=0; }
735 if($checked || $elder_valid[$i] == 1) {
736 $this->t->set_var('elder_name',$elder_name[$i]);
737 $this->t->set_var('elder',$elder_id[$i]);
738 if(($j+1) % 3 == 0) { $this->t->set_var('table_sep',"</td></tr><tr>"); }
739 else { $this->t->set_var('table_sep',"</td>"); }
740 if(($j) % 3 == 0) { $this->nextmatchs->template_alternate_row_color(&$this->t); }
741 $this->t->fp('list','elder_list',True);
746 $this->t->set_var('lang_reset','Clear Form');
747 $this->t->set_var('lang_add','Add Activity');
748 $this->t->set_var('lang_save','Save Changes');
749 $this->t->set_var('edithandle','');
750 $this->t->set_var('addhandle','');
752 $this->t->pfp('out','form');
753 if($action == 'edit') { $this->t->pfp('addhandle','edit'); }
754 if($action == 'add') { $this->t->pfp('addhandle','add'); }
756 $this->save_sessiondata();
761 $this->t->set_file(array('par_view_t' => 'par_view.tpl'));
762 $this->t->set_block('par_view_t','header_list','list1');
763 $this->t->set_block('par_view_t','elder_list','list2');
765 $sql = "SELECT * FROM eq_elder where valid=1";
766 $this->db->query($sql,__LINE__,__FILE__);
768 while ($this->db->next_record())
770 $elder_name[$i] = $this->db->f('name');
771 $elder_id[$i] = $this->db->f('elder');
774 array_multisort($elder_name, $elder_id);
776 $sql = "SELECT * FROM eq_activity ORDER BY date DESC";
777 $this->db->query($sql,__LINE__,__FILE__);
778 $total_records = $this->db->num_rows();
781 while ($this->db->next_record())
783 $activity_list[$i]['name'] = $this->db->f('name');
784 $activity_list[$i]['date'] = $this->db->f('date');
785 $activity_list[$i]['activity'] = $this->db->f('activity');
786 if($activity_list[$i]['date'] == '0000-00-00') { $activity_list[$i]['date']=""; }
790 $elder_width=250; $part_width=25; $act_width=50;
791 $total_width=$elder_width+$part_width;
792 for ($i=0; $i < count($activity_list); $i++) {
793 $this->t->set_var('activity_name',$activity_list[$i]['name']);
794 $this->t->set_var('activity_date',$activity_list[$i]['date']);
795 $this->t->fp('list1','header_list',True);
796 $total_width += $act_width;
799 for ($i=0; $i < count($elder_id); $i++) {
800 $participated=0; $part_table = '';
801 $this->nextmatchs->template_alternate_row_color(&$this->t);
802 $this->t->set_var('elder_name',$elder_name[$i]);
803 for ($j=0; $j < count($activity_list); $j++) {
804 $sql = "SELECT * FROM eq_participation where activity="
805 . $activity_list[$j]['activity'] . " AND elder=" . $elder_id[$i];
806 $this->db->query($sql,__LINE__,__FILE__);
807 if($this->db->next_record()) {
808 $part_table .= '<td align=center><img src="checkmark.gif"></td>';
811 $part_table .= '<td> </td>';
814 if($participated) { $part_table .= '<td align=center><img src="checkmark.gif">'.$participated.'</td>'; }
815 else { $part_table .= '<td> </td>'; }
816 $this->t->set_var('part_table',$part_table);
817 $this->t->fp('list2','elder_list',True);
819 $this->t->set_var('total_width',$total_width);
820 $this->t->set_var('elder_width',$elder_width);
821 $this->t->set_var('part_width',$part_width);
822 $this->t->set_var('act_width',$act_width);
823 $this->t->pfp('out','par_view_t');
824 $this->save_sessiondata();
829 $this->t->set_file(array('ppi_view_t' => 'ppi_view.tpl'));
830 $this->t->set_block('ppi_view_t','district_list','list');
832 $this->t->set_var('linkurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view'));
833 $num_months = get_var('num_months',array('GET','POST'));
834 if($num_months == '') { $num_months = $this->default_ppi_num_months; }
835 $this->t->set_var('num_months',$num_months);
836 if($num_months == 1) { $this->t->set_var('lang_num_months','Month of History'); }
837 else { $this->t->set_var('lang_num_months','Months of History'); }
838 $this->t->set_var('lang_filter','Filter');
840 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view'));
841 $this->t->set_var('eqpres_ppi_link',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view&eqpresppi=1'));
842 $eqpresppi = get_var('eqpresppi',array('GET','POST'));
844 if($eqpresppi == 1) {
845 $num_months = get_var('num_months',array('GET','POST'));
846 if($num_months == '') { $num_months = $this->default_ppi_num_years; }
847 $this->t->set_var('num_months',$num_months);
848 $this->t->set_var('ppi_link_title','PPIs');
849 $this->t->set_var('title','EQ President Yearly PPIs');
850 if($num_months == 1) { $this->t->set_var('lang_num_months','Year of History'); }
851 else { $this->t->set_var('lang_num_months','Years of History'); }
852 $this->t->set_var('eqpres_ppi_link',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view'));
855 $this->t->set_var('ppi_link_title','EQ President Yearly PPIs');
856 $this->t->set_var('title','PPIs');
859 $sql = "SELECT * FROM eq_district where valid=1 ORDER BY district ASC";
860 $this->db->query($sql,__LINE__,__FILE__);
862 while ($this->db->next_record())
864 $districts[$i]['district'] = $this->db->f('district');
865 $districts[$i]['name'] = $this->db->f('name');
866 $districts[$i]['supervisor'] = $this->db->f('supervisor');
867 if($eqpresppi == 0) { $i++; }
870 $sql = "SELECT * FROM eq_elder where valid=1 ORDER BY elder ASC";
871 $this->db->query($sql,__LINE__,__FILE__);
873 while ($this->db->next_record())
875 $elder_id[$i] = $this->db->f('elder');
876 $elder_name[$i] = $this->db->f('name');
877 $elder_phone[$elder_id[$i]] = $this->db->f('phone');
880 array_multisort($elder_name, $elder_id);
881 for($i=0; $i < count($elder_id); $i++) {
883 $elders[$id] = $elder_name[$i];
886 $sql = "SELECT * FROM eq_aaronic where valid=1 ORDER BY aaronic ASC";
887 $this->db->query($sql,__LINE__,__FILE__);
888 while ($this->db->next_record())
890 $aaronic_id = $this->db->f('aaronic');
891 $aaronic[$aaronic_id]['name'] = $this->db->f('name');
892 $aaronic[$aaronic_id]['phone'] = $this->db->f('phone');
895 $total_companionships = 0;
896 $this->nextmatchs->template_alternate_row_color(&$this->t);
897 for ($i=0; $i < count($districts); $i++) {
898 if($eqpresppi == 1) {
899 $this->t->set_var('district_number','*');
900 $this->t->set_var('district_name','EQ President');
902 $this->t->set_var('district_number',$districts[$i]['district']);
903 $this->t->set_var('district_name',$districts[$i]['name']);
905 $supervisor = $districts[$i]['supervisor'];
906 $unique_companionships='';
908 // Select all the unique companionship numbers for this district
909 if($eqpresppi == 1) {
910 $sql = "SELECT distinct companionship FROM eq_companionship where valid=1";
913 $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $districts[$i]['district'];
915 $this->db->query($sql,__LINE__,__FILE__);
917 while ($this->db->next_record())
919 $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
923 $comp_width=400; $ppi_width=25; $table_width=$comp_width + $num_months*$ppi_width;
924 $table_data=""; $num_companionships = $j; $num_elders = 0;
925 for($m=$num_months; $m >= 0; $m--) { $ppis[$m] = 0; }
926 for ($j=0; $j < count($unique_companionships); $j++) {
927 // Select all the companions in each companionship
929 $sql = "SELECT * FROM eq_companionship where valid=1 and aaronic=0 and ".
930 "companionship=". $unique_companionships[$j]['companionship'];
933 $sql = "SELECT * FROM eq_companionship where valid=1 and ".
934 "companionship=". $unique_companionships[$j]['companionship'];
936 $this->db->query($sql,__LINE__,__FILE__);
938 $comp = $unique_companionships[$j]['companionship'];
939 for($m=$num_months; $m >= 0; $m--) { $ppi_recorded[$comp][$m] = 0; }
940 while ($this->db->next_record())
942 // Get this companions information
944 $companionship = $this->db->f('companionship');
945 $elder_id = $this->db->f('elder');
946 $aaronic_id = $this->db->f('aaronic');
948 $name = $elders[$elder_id];
949 $phone = $elder_phone[$elder_id];
951 else if($aaronic_id) {
952 $name = $aaronic[$aaronic_id]['name'];
953 $phone = $aaronic[$aaronic_id]['phone'];
955 $link_data['menuaction'] = 'eq.eq.ppi_update';
956 $link_data['companionship'] = $companionship;
957 $link_data['interviewer'] = $supervisor;
958 $link_data['elder'] = $elder_id;
959 $link_data['aaronic'] = $aaronic_id;
960 $link_data['name'] = $name;
961 $link_data['ppi'] = '';
962 $link_data['eqpresppi'] = $eqpresppi;
963 $link_data['action'] = 'add';
964 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
965 $table_data.= "<tr bgcolor=". $this->t->get_var('tr_color') ."><td title=\"$phone\"><a href=$link>$name</a></td>";
967 // Find out how many times PPIs were performed in the past $num_months for this Elder
968 $header_row="<th width=$comp_width><font size=-2>Companionship</th>";
969 for($m=$num_months; $m >= 0; $m--) {
970 if($eqpresppi == 1) {
971 $year = date('Y') - $m;
972 $year_start = $year - 1 . "-12-31"; $year_end = $year + 1 . "-01-01";
973 $sql = "SELECT * FROM eq_ppi WHERE date > '$year_start' AND date < '$year_end' ".
974 "AND elder=" . $elder_id . " AND aaronic=" . $aaronic_id . " AND eqpresppi=1";
975 $this->db2->query($sql,__LINE__,__FILE__);
976 $header_row .= "<th width=150><font size=-2>$year</th>";
979 if(`date '+%d'` == 31) { $d = 1; } else { $d = 0; }
980 $month = date('m/Y', strtotime('-'.$m.' month -'.$d.' day'));
981 $month_start = date('Y-m', strtotime('-'.$m.' month -'.$d.' day')); $month_start .= "-01";
982 $month_end = date('Y-m', strtotime('-'.$m.' month -'.$d.' day')); $month_end .= "-31";
983 $sql = "SELECT * FROM eq_ppi WHERE date >= '$month_start' AND date <= '$month_end' ".
984 "AND elder=" . $elder_id . " AND aaronic=" . $aaronic_id . " AND eqpresppi=0";
985 $this->db2->query($sql,__LINE__,__FILE__);
986 $header_row .= "<th width=$ppi_width><font size=-2>$month</th>";
988 if(!$total_ppis[$m]) { $total_ppis[$m] = 0; }
989 if($this->db2->next_record()) {
990 if(!$ppi_recorded[$companionship][$m]) {
991 $ppis[$m]++; $total_ppis[$m]++; $ppi_recorded[$companionship][$m]=1;
993 $link_data['menuaction'] = 'eq.eq.ppi_update';
994 $link_data['companionship'] = $companionship;
995 $link_data['interviewer'] = $this->db2->f('interviewer');
996 $link_data['elder'] = $elder_id;
997 $link_data['aaronic'] = $aaronic_id;
998 $link_data['name'] = $name;
999 $link_data['ppi'] = $this->db2->f('ppi');
1000 $link_data['eqpresppi'] = $eqpresppi;
1001 $link_data['action'] = 'view';
1002 $date = $this->db2->f('date');
1003 $date_array = explode("-",$date);
1004 $month = $date_array[1];
1005 $day = $date_array[2];
1006 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
1007 $table_data .= '<td align=center><a href='.$link.'><img src="checkmark.gif"><br>'.$month.'-'.$day.'</a></td>';
1009 else { $table_data .= "<td> </td>"; }
1011 $table_data .= "</tr>";
1014 $table_data .= "<tr><td colspan=20><hr></td></tr>";
1016 // Now add Elders not assigned to any companionship to the table if we are in eqpresppi mode
1017 if($eqpresppi == 1) {
1018 $table_data .= "<tr bgcolor=\"#c9c9c9\"><hr><td colspan=20><b>Unassigned Potential Home Teachers</b><hr></td></tr>";
1019 foreach($elders as $elder_id => $value) {
1020 $sql = "SELECT * FROM eq_companionship where valid=1 and elder=".$elder_id;
1021 $this->db->query($sql,__LINE__,__FILE__);
1022 if(!$this->db->next_record()) {
1023 // We found an Elder not in a companionship, add them to the table
1026 $name = $elders[$elder_id];
1027 $link_data['menuaction'] = 'eq.eq.ppi_update';
1028 $link_data['companionship'] = $companionship;
1029 $link_data['interviewer'] = $supervisor;
1030 $link_data['elder'] = $elder_id;
1031 $link_data['name'] = $name;
1032 $link_data['ppi'] = '';
1033 $link_data['eqpresppi'] = $eqpresppi;
1034 $link_data['action'] = 'add';
1035 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
1036 $table_data.= "<tr bgcolor=". $this->t->get_var('tr_color') ."><td><a href=$link>$name</a></td>";
1037 for($m=$num_months; $m >= 0; $m--) {
1038 $year = date('Y') - $m;
1039 $year_start = $year - 1 . "-12-31"; $year_end = $year + 1 . "-01-01";
1040 $sql = "SELECT * FROM eq_ppi WHERE date > '$year_start' AND date < '$year_end' ".
1041 "AND elder=" . $elder_id . " AND eqpresppi=1";
1042 $this->db2->query($sql,__LINE__,__FILE__);
1043 if(!$total_ppis[$m]) { $total_ppis[$m] = 0; }
1044 if($this->db2->next_record()) {
1045 $ppis[$m]++; $total_ppis[$m]++;
1046 $link_data['menuaction'] = 'eq.eq.ppi_update';
1047 $link_data['companionship'] = $companionship;
1048 $link_data['interviewer'] = $supervisor;
1049 $link_data['elder'] = $elder_id;
1050 $link_data['name'] = $name;
1051 $link_data['ppi'] = $this->db2->f('ppi');
1052 $link_data['eqpresppi'] = $eqpresppi;
1053 $link_data['action'] = 'view';
1054 $date = $this->db2->f('date');
1055 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
1056 $table_data .= '<td align=center><a href='.$link.'><img src="checkmark.gif"><br>'.$date.'</a></td>';
1058 else { $table_data .= "<td> </td>"; }
1060 $table_data .= "</tr>";
1064 $total_companionships += $num_companionships;
1065 if($eqpresppi == 1) {
1066 $stat_data = "<tr><td><b><font size=-2>$num_elders Elders<br>PPI Totals:</font></b></td>";
1068 $stat_data = "<tr><td><b><font size=-2>$num_companionships Companionships<br>PPI Totals:</font></b></td>";
1070 for($m=$num_months; $m >=0; $m--) {
1071 if($eqpresppi == 1) { $percent = ceil(($ppis[$m] / $num_elders)*100); }
1072 else { $percent = ceil(($ppis[$m] / $num_companionships)*100); }
1073 $stat_data .= "<td align=center><font size=-2><b>$ppis[$m]<br>$percent%</font></b></td>";
1075 $stat_data .= "</tr>";
1077 $this->t->set_var('table_width',$table_width);
1078 $this->t->set_var('header_row',$header_row);
1079 $this->t->set_var('table_data',$table_data);
1080 $this->t->set_var('stat_data',$stat_data);
1081 $this->t->fp('list','district_list',True);
1084 $totals = "<tr><td><b><font size=-2>$total_companionships Total Comps<br>PPI Totals:</font></b></td>";
1085 for($m=$num_months; $m >=0; $m--) {
1086 $percent = ceil(($total_ppis[$m] / $total_companionships)*100);
1087 $totals .= "<td align=center><font size=-2><b>$total_ppis[$m]<br>$percent%</font></b></td>";
1091 $this->t->set_var('totals',$totals);
1092 $this->t->pfp('out','ppi_view_t');
1093 $this->save_sessiondata();
1096 function ppi_update()
1098 $this->t->set_file(array('form' => 'ppi_update.tpl'));
1099 $this->t->set_block('form','interviewer_list','int_list');
1100 $this->t->set_block('form','add','addhandle');
1101 $this->t->set_block('form','edit','edithandle');
1103 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view'));
1104 $this->t->set_var('readonly','');
1105 $this->t->set_var('disabled','');
1107 $action = get_var('action',array('GET','POST'));
1108 $companionship = get_var('companionship',array('GET','POST'));
1109 $interviewer = get_var('interviewer',array('GET','POST'));
1110 $name = get_var('name',array('GET','POST'));
1111 $ppi = get_var('ppi',array('GET','POST'));
1112 $elder = get_var('elder',array('GET','POST'));
1113 $aaronic = get_var('aaronic',array('GET','POST'));
1114 $date = get_var('date',array('GET','POST'));
1115 $notes = get_var('notes',array('GET','POST'));
1116 $eqpresppi = get_var('eqpresppi',array('GET','POST'));
1118 $sql = "SELECT * FROM eq_district where valid=1 ORDER BY district ASC";
1119 $this->db->query($sql,__LINE__,__FILE__);
1120 while ($this->db->next_record())
1122 $supervisor = $this->db->f('supervisor');
1123 $sql = "SELECT * FROM eq_elder WHERE elder=" . $supervisor;
1124 $this->db2->query($sql,__LINE__,__FILE__);
1125 $this->db2->next_record();
1126 $interviewer_name = $this->db2->f('name');
1128 if($supervisor == $interviewer) {
1129 $this->t->set_var('interviewer',$supervisor . ' selected');
1131 $this->t->set_var('interviewer',$interviewer);
1133 $this->t->set_var('interviewer_name',$interviewer_name);
1134 $this->t->fp('int_list','interviewer_list',True);
1137 if($action == 'save')
1139 $notes = $this->db->db_addslashes(get_var('notes',array('POST')));
1140 $this->db->query("UPDATE eq_ppi set " .
1141 " ppi='" . $ppi . "'" .
1142 ", interviewer='" . $interviewer . "'" .
1143 ", elder='" . $elder . "'" .
1144 ", aaronic='" . $aaronic . "'" .
1145 ", date='" . $date . "'" .
1146 ", notes='" . $notes . "'" .
1147 ", eqpresppi='" . $eqpresppi . "'" .
1148 " WHERE ppi=" . $ppi,__LINE__,__FILE__);
1153 if($action == 'insert')
1155 $notes = $this->db->db_addslashes(get_var('notes',array('POST')));
1156 $this->db->query("INSERT INTO eq_ppi (interviewer,elder,aaronic,date,notes,eqpresppi) "
1157 . "VALUES ('" . $interviewer . "','" . $elder . "','" . $aaronic . "','"
1158 . $date . "','" . $notes . "','" . $eqpresppi ."')",__LINE__,__FILE__);
1163 if($action == 'add')
1165 $this->t->set_var('cal_date',$this->jscal->input('date','','','','','','',$this->cal_options));
1166 $this->t->set_var('ppi', '');
1167 $this->t->set_var('interviewer', $interviewer);
1168 $this->t->set_var('name',$name);
1169 $this->t->set_var('elder',$elder);
1170 $this->t->set_var('aaronic',$aaronic);
1171 $this->t->set_var('date','');
1172 $this->t->set_var('notes','');
1173 $this->t->set_var('eqpresppi',$eqpresppi);
1174 $this->t->set_var('lang_done','Cancel');
1175 $this->t->set_var('lang_action','Adding New PPI');
1176 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_update&ppi='
1177 . $ppi . '&action=' . 'insert'));
1180 if($action == 'edit' || $action == 'view')
1182 $sql = "SELECT * FROM eq_ppi WHERE ppi=".$ppi;
1183 $this->db->query($sql,__LINE__,__FILE__);
1184 $this->db->next_record();
1185 $this->t->set_var('ppi',$ppi);
1186 $this->t->set_var('name',$name);
1187 $this->t->set_var('interviewer', $this->db->f('interviewer'));
1188 $this->t->set_var('elder',$this->db->f('elder'));
1189 $this->t->set_var('aaronic',$this->db->f('aaronic'));
1190 $this->t->set_var('date',$this->db->f('date'));
1191 $this->t->set_var('notes',$this->db->f('notes'));
1192 $this->t->set_var('eqpresppi',$this->db->f('eqpresppi'));
1195 if($action == 'edit')
1197 $this->t->set_var('cal_date',$this->jscal->input('date',$date,'','','','','',$this->cal_options));
1198 $this->t->set_var('lang_done','Cancel');
1199 $this->t->set_var('lang_action','Editing PPI');
1200 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_update&ppi='
1201 . $ppi . '&action=' . 'save'));
1204 if($action == 'view')
1206 $date = $this->db->f('date');
1207 $this->t->set_var('cal_date','<input type=text size="10" maxlength="10" name="date" value="'.$date.'" readonly>');
1208 $this->t->set_var('readonly','READONLY');
1209 $this->t->set_var('disabled','DISABLED');
1210 $this->t->set_var('lang_done','Done');
1211 $this->t->set_var('lang_action','Viewing PPI');
1212 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_update&ppi='
1213 . $ppi . '&action=' . 'edit'));
1216 $this->t->set_var('lang_reset','Clear Form');
1217 $this->t->set_var('lang_add','Add PPI');
1218 $this->t->set_var('lang_save','Save Changes');
1219 $this->t->set_var('edithandle','');
1220 $this->t->set_var('addhandle','');
1222 $this->t->pfp('out','form');
1224 if($action == 'view') { $this->t->set_var('lang_save','Edit PPI'); }
1225 if($action == 'edit' || $action == 'view') { $this->t->pfp('addhandle','edit'); }
1226 if($action == 'add') { $this->t->pfp('addhandle','add'); }
1228 $this->save_sessiondata();
1233 $this->t->set_file(array('vis_view_t' => 'vis_view.tpl'));
1234 $this->t->set_block('vis_view_t','visit_list','list1');
1235 $this->t->set_block('vis_view_t','family_list','list2');
1237 $this->t->set_var('lang_name','Family Name');
1238 $this->t->set_var('lang_date','Date');
1240 $sql = "SELECT * FROM eq_visit WHERE companionship=0 ORDER BY date DESC";
1241 $this->db->query($sql,__LINE__,__FILE__);
1242 $total_records = $this->db->num_rows();
1245 while ($this->db->next_record())
1247 $visit_list[$i]['visit'] = $this->db->f('visit');
1248 $visit_list[$i]['family'] = $this->db->f('family');
1249 $visit_list[$i]['date'] = $this->db->f('date');
1253 for ($i=0; $i < count($visit_list); $i++)
1255 $this->nextmatchs->template_alternate_row_color(&$this->t);
1257 $sql = "SELECT * FROM eq_family WHERE family=".$visit_list[$i]['family'];
1258 $this->db->query($sql,__LINE__,__FILE__);
1259 $this->db->next_record();
1261 $this->t->set_var('family',$visit_list[$i]['family']);
1262 $this->t->set_var('family_name',$this->db->f('name'));
1263 $this->t->set_var('date',$visit_list[$i]['date']);
1265 $link_data['menuaction'] = 'eq.eq.vis_update';
1266 $link_data['visit'] = $visit_list[$i]['visit'];
1267 $link_data['name'] = $this->db->f('name');
1268 $link_data['date'] = $visit_list[$i]['date'];
1269 $link_data['action'] = 'view';
1270 $this->t->set_var('view',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1271 $this->t->set_var('lang_view','View');
1273 $link_data['menuaction'] = 'eq.eq.vis_update';
1274 $link_data['visit'] = $visit_list[$i]['visit'];
1275 $link_data['name'] = $this->db->f('name');
1276 $link_data['date'] = $visit_list[$i]['date'];
1277 $link_data['action'] = 'edit';
1278 $this->t->set_var('edit',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1279 $this->t->set_var('lang_edit','Edit');
1281 $this->t->fp('list1','visit_list',True);
1284 // List the families that are available to record a visit against
1285 $sql = "SELECT * FROM eq_family WHERE valid=1";
1286 $this->db->query($sql,__LINE__,__FILE__);
1287 $total_records = $this->db->num_rows();
1290 while ($this->db->next_record())
1292 $family_names[$i] = $this->db->f('name');
1293 $family_ids[$i] = $this->db->f('family');
1295 } array_multisort($family_names, $family_ids);
1297 for ($i=0; $i < count($family_names); $i++)
1299 $link_data['menuaction'] = 'eq.eq.vis_update';
1300 $link_data['visit'] = '';
1301 $link_data['family'] = $family_ids[$i];
1302 $link_data['action'] = 'add';
1303 $link_data['name'] = $family_names[$i];
1304 $this->t->set_var('add',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1306 $this->t->set_var('name',$family_names[$i]);
1307 if(($i+1) % 3 == 0) { $this->t->set_var('table_sep',"</td></tr><tr>"); }
1308 else { $this->t->set_var('table_sep',"</td>"); }
1309 if(($i) % 3 == 0) { $this->nextmatchs->template_alternate_row_color(&$this->t); }
1311 $this->t->fp('list2','family_list',True);
1314 $this->t->pfp('out','vis_view_t');
1315 $this->save_sessiondata();
1318 function vis_update()
1320 $this->t->set_file(array('form' => 'vis_update.tpl'));
1321 $this->t->set_block('form','add','addhandle');
1322 $this->t->set_block('form','edit','edithandle');
1324 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.vis_view'));
1325 $this->t->set_var('readonly','');
1326 $this->t->set_var('disabled','');
1328 $action = get_var('action',array('GET','POST'));
1329 $visit = get_var('visit',array('GET','POST'));
1330 $family = get_var('family',array('GET','POST'));
1331 $name = get_var('name',array('GET','POST'));
1332 $date = get_var('date',array('GET','POST'));
1333 $notes = get_var('notes',array('GET','POST'));
1336 if($action == 'save')
1338 $notes = $this->db->db_addslashes(get_var('notes',array('POST')));
1339 $this->db->query("UPDATE eq_visit set " .
1340 " date='" . $date . "'" .
1341 ", notes='" . $notes . "'" .
1342 " WHERE visit=" . $visit,__LINE__,__FILE__);
1347 if($action == 'insert')
1349 $notes = $this->db->db_addslashes(get_var('notes',array('POST')));
1350 $this->db->query("INSERT INTO eq_visit (family,companionship,date,notes) "
1351 . "VALUES ('" . $family . "','" . $companionship . "','"
1352 . $date . "','" . $notes . "')",__LINE__,__FILE__);
1357 if($action == 'add')
1359 $this->t->set_var('cal_date',$this->jscal->input('date','','','','','','',$this->cal_options));
1360 $this->t->set_var('family', $family);
1361 $this->t->set_var('visit', '');
1362 $this->t->set_var('name', $name);
1363 $this->t->set_var('date','');
1364 $this->t->set_var('notes','');
1365 $this->t->set_var('lang_done','Cancel');
1366 $this->t->set_var('lang_action','Adding New Visit');
1367 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.vis_update&family='
1368 . $family . '&action=' . 'insert'));
1371 if($action == 'edit' || $action == 'view')
1373 $sql = "SELECT * FROM eq_visit WHERE visit=".$visit;
1374 $this->db->query($sql,__LINE__,__FILE__);
1375 $this->db->next_record();
1376 $this->t->set_var('visit',$visit);
1377 $this->t->set_var('name',$name);
1378 $this->t->set_var('family', $family);
1379 $this->t->set_var('date',$this->db->f('date'));
1380 $this->t->set_var('notes',$this->db->f('notes'));
1383 if($action == 'edit')
1385 $this->t->set_var('cal_date',$this->jscal->input('date',$date,'','','','','',$this->cal_options));
1386 $this->t->set_var('lang_done','Cancel');
1387 $this->t->set_var('lang_action','Editing Visit');
1388 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.vis_update&visit='
1389 . $visit . '&action=' . 'save'));
1392 if($action == 'view')
1394 $date = $this->db->f('date');
1395 $this->t->set_var('cal_date','<input type=text size="10" maxlength="10" name="date" value="'.$date.'" readonly>');
1396 $this->t->set_var('readonly','READONLY');
1397 $this->t->set_var('disabled','DISABLED');
1398 $this->t->set_var('lang_done','Done');
1399 $this->t->set_var('lang_action','Viewing Visit');
1400 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.vis_update&visit='
1401 . $visit . '&action=' . 'edit'));
1404 $this->t->set_var('lang_reset','Clear Form');
1405 $this->t->set_var('lang_add','Add Visit');
1406 $this->t->set_var('lang_save','Save Changes');
1407 $this->t->set_var('edithandle','');
1408 $this->t->set_var('addhandle','');
1410 $this->t->pfp('out','form');
1412 if($action == 'view') { $this->t->set_var('lang_save','Edit Visit'); }
1413 if($action == 'edit' || $action == 'view') { $this->t->pfp('addhandle','edit'); }
1414 if($action == 'add') { $this->t->pfp('addhandle','add'); }
1416 $this->save_sessiondata();
1421 $this->t->set_file(array('att_view_t' => 'att_view.tpl'));
1422 $this->t->set_block('att_view_t','act_list','list');
1424 $this->t->set_block('att_view_t','month_list','list1');
1425 $this->t->set_block('att_view_t','header_list','list2');
1426 $this->t->set_block('att_view_t','elder_list','list3');
1428 $this->t->set_var('linkurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.att_view'));
1429 $num_months = get_var('num_months',array('GET','POST'));
1430 if($num_months == '') { $num_months = $this->default_att_num_months; }
1431 $this->t->set_var('num_months',$num_months);
1432 $this->t->set_var('lang_filter','Filter');
1433 if($num_months == 1) { $this->t->set_var('lang_num_months','Month of History'); }
1434 else { $this->t->set_var('lang_num_months','Months of History'); }
1436 $sql = "SELECT * FROM eq_elder where valid=1";
1437 $this->db->query($sql,__LINE__,__FILE__);
1439 while ($this->db->next_record())
1441 $elder_name[$i] = $this->db->f('name');
1442 $elder_id[$i] = $this->db->f('elder');
1445 array_multisort($elder_name, $elder_id);
1448 // Create a list of sunday dates for a window of 3 months back and current month
1452 $sunday_list[0]['date'] = date("Y-m-d", mktime(0, 0, 0, date("m")-$num_months, 1, date("y")));
1453 $last_date = explode("-",$sunday_list[0]['date']);
1454 $last_time = mktime(0, 0, 0, $last_date[1], $last_date[2], $last_date[0]);
1455 $time_limit = mktime(0, 0, 0, date("m"), date("t"), date("y"));
1456 while($last_time < $time_limit)
1458 $day = date("w",$last_time);
1459 if(date("w",$last_time) == 0) {
1460 $sunday_list[$i]['date'] = date("Y-m-d", $last_time);
1461 $last_date = explode("-",$sunday_list[$i]['date']);
1462 $last_time = mktime(0, 0, 0, $last_date[1], $last_date[2], $last_date[0]);
1463 $sunday_list[$i]['day'] = $last_date[2];
1464 $sunday_list[$i]['month'] = date("M",$last_time);
1465 $sunday_list[$i]['year'] = $last_date[0];
1468 $last_time += 90000;
1469 if($found_sunday) { $i++; $found_sunday=0; }
1472 $total_elders = count($elder_id);
1473 $old_month=$sunday_list[0]['month']; $span=0;
1474 for ($i=0; $i < count($sunday_list); $i++) {
1475 $date = $sunday_list[$i]['date'];
1476 $this->t->set_var('date',$sunday_list[$i]['date']);
1477 $this->t->set_var('day',$sunday_list[$i]['day']);
1478 if(($old_month != $sunday_list[$i]['month']) || $i == count($sunday_list)-1) {
1479 if($i == count($sunday_list)-1) { $span++; }
1480 $cur_month = $sunday_list[$i]['month'];
1481 $old_month = $sunday_list[$i]['month'];
1482 $link_data['menuaction'] = 'eq.eq.att_update';
1483 $link_data['month'] = $sunday_list[$i-1]['month'];
1484 $link_data['year'] = $sunday_list[$i-1]['year'];
1485 $link_data['action'] = 'update_month';
1486 $cur_month = $sunday_list[$i-1]['month'];
1487 $cur_year = $sunday_list[$i-1]['year'];
1488 $header_row .= "<th><font size=-3>$cur_month $cur_year</font></th>";
1489 $this->t->set_var('update_month',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1490 $this->t->set_var('month',$sunday_list[$i-1]['month']);
1491 $this->t->set_var('year',$sunday_list[$i-1]['year']);
1492 $this->t->set_var('span',$span); $span=0;
1493 $this->t->fp('list1','month_list',True);
1496 $this->t->set_var('total_elders',$total_elders);
1497 $this->t->set_var('header_row',$header_row);
1499 $elder_width=200; $att_width=25; $total_width=$elder_width;
1500 for ($i=0; $i < count($sunday_list); $i++) {
1501 $link_data['menuaction'] = 'eq.eq.att_update';
1502 $link_data['month'] = $sunday_list[$i]['month'];
1503 $link_data['year'] = $sunday_list[$i]['year'];
1504 $link_data['day'] = $sunday_list[$i]['day'];
1505 $link_data['date'] = $sunday_list[$i]['date'];
1506 $link_data['action'] = 'update_day';
1507 $this->t->set_var('update_day',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1508 $this->t->set_var('date',$sunday_list[$i]['date']);
1509 $this->t->set_var('day',$sunday_list[$i]['day']);
1510 $this->t->set_var('month',$sunday_list[$i]['month']);
1511 $this->t->set_var('year',$sunday_list[$i]['year']);
1512 $this->t->fp('list2','header_list',True);
1513 $total_width += $att_width;
1516 for ($i=0; $i < count($elder_id); $i++) {
1518 $this->nextmatchs->template_alternate_row_color(&$this->t);
1519 $this->t->set_var('elder_name',$elder_name[$i]);
1520 #print "checking for elder: " . $elder_id[$i] . "<br>";
1521 for ($j=0; $j < count($sunday_list); $j++) {
1522 #print "checking for date: " . $sunday_list[$j]['date'] . "<br>";
1523 #print "SELECT * FROM eq_attendance WHERE date='"
1524 # . $sunday_list[$j]['date'] . "' AND elder=" . $elder_id[$i] . "<br>";
1525 $sql = "SELECT * FROM eq_attendance WHERE date='"
1526 . $sunday_list[$j]['date'] . "' AND elder=" . $elder_id[$i];
1527 $this->db->query($sql,__LINE__,__FILE__);
1528 if($this->db->next_record()) {
1529 $cur_month = $sunday_list[$j]['month'];
1530 if($attended[$i][$cur_month] != 1) {
1531 $attended[$i][$cur_month]=1;
1532 $attendance[$cur_month]++;
1534 $att_table .= '<td align=center><img src="checkmark.gif"></td>';
1536 $att_table .= '<td> </td>';
1539 $this->t->set_var('att_table',$att_table);
1540 $this->t->fp('list3','elder_list',True);
1542 $this->t->set_var('total_width',$total_width);
1543 $this->t->set_var('elder_width',$elder_width);
1544 $this->t->set_var('att_width',$att_width);
1546 # Now calculate attendance for these months
1547 $attendance_str = "";
1548 $nonattendance_str = "";
1549 $aveattendance_str = "";
1550 $avenonattendance_str = "";
1552 $ave_total_attended=0;
1553 foreach($attendance as $att => $value) {
1554 $total_attended = $attendance[$att];
1555 $ave_total_attended += $attendance[$att]; $num_months++;
1556 $percent = ceil(($total_attended / $total_elders)*100);
1557 $attendance_str.="<td align=center><font size=-2><b>$total_attended ($percent%)</b></font></td>";
1558 $total_nonattended = $total_elders - $total_attended;
1559 $percent = ceil(($total_nonattended / $total_elders)*100);
1560 $nonattendance_str.="<td align=center><font size=-2><b>$total_nonattended ($percent%)</b></font></td>";
1562 $total_attended = ceil(($ave_total_attended / $num_months));
1563 $percent = ceil(($total_attended / $total_elders)*100);
1564 $aveattendance_str .= "<td align=center><font size=-2><b>$total_attended ($percent%)</b></font></td>";
1565 $total_attended = $total_elders - ceil(($ave_total_attended / $num_months));
1566 $percent = ceil(($total_attended / $total_elders)*100);
1567 $avenonattendance_str .= "<td align=center><font size=-2><b>$total_attended ($percent%)</b></font></td>";
1570 $this->t->set_var('attendance',$attendance_str);
1571 $this->t->set_var('aveattendance',$aveattendance_str);
1572 $this->t->set_var('nonattendance',$nonattendance_str);
1573 $this->t->set_var('avenonattendance',$avenonattendance_str);
1575 $this->t->pfp('out','att_view_t');
1576 $this->save_sessiondata();
1579 function att_update()
1581 $monthnum['Jan']=1; $monthnum['Feb']=2; $monthnum['Mar']=3; $monthnum['Apr']=4;
1582 $monthnum['May']=5; $monthnum['Jun']=6; $monthnum['Jul']=7; $monthnum['Aug']=8;
1583 $monthnum['Sep']=9; $monthnum['Oct']=10; $monthnum['Nov']=11; $monthnum['Dec']=12;
1585 $this->t->set_file(array('form' => 'att_update.tpl'));
1586 $this->t->set_block('form','edit','edithandle');
1588 $this->t->set_block('form','month_list','list1');
1589 $this->t->set_block('form','header_list','list2');
1590 $this->t->set_block('form','elder_list','list3');
1592 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.att_view'));
1594 $action = get_var('action',array('GET','POST'));
1595 $month = get_var('month',array('GET','POST'));
1596 $year = get_var('year',array('GET','POST'));
1597 $day = get_var('day',array('GET','POST'));
1598 $date = get_var('date',array('GET','POST'));
1600 if($action == 'save_month' || $action == 'save_day')
1602 $new_data = get_var('elders_attended',array('POST'));
1603 $month = $monthnum[$month]; if($month < 10) { $month = "0" . $month; }
1605 if($action == 'save_month') {
1606 $this->db->query("DELETE from eq_attendance where date LIKE '".$year."-".$month."-%'",__LINE__,__FILE__);
1609 if($action == 'save_day') {
1610 $this->db->query("DELETE from eq_attendance where date LIKE '".$year."-".$month."-".$day."'",__LINE__,__FILE__);
1613 foreach ($new_data as $data)
1615 $data_array = explode("-",$data);
1616 $elder = $data_array[0];
1617 $date = "$data_array[1]-$data_array[2]-$data_array[3]";
1618 $this->db->query("INSERT INTO eq_attendance (elder,date) "
1619 . "VALUES (" . $elder . ",'". $date . "')",__LINE__,__FILE__);
1626 $sql = "SELECT * FROM eq_elder where valid=1";
1627 $this->db->query($sql,__LINE__,__FILE__);
1629 while ($this->db->next_record())
1631 $elder_name[$i] = $this->db->f('name');
1632 $elder_id[$i] = $this->db->f('elder');
1635 array_multisort($elder_name, $elder_id);
1637 if($action == 'update_month')
1639 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.att_update&action=save_month'));
1643 $sunday_list[0]['date'] = date("Y-m-d", mktime(0, 0, 0, $monthnum[$month], 1, $year));
1644 $last_date = explode("-",$sunday_list[0]['date']);
1645 $last_time = mktime(0, 0, 0, $last_date[1], $last_date[2], $last_date[0]);
1646 $time_limit = mktime(0, 0, 0, $monthnum[$month], 31, $year);
1647 while($last_time <= $time_limit)
1649 $day = date("w",$last_time);
1650 if(date("w",$last_time) == 0) {
1651 $sunday_list[$i]['date'] = date("Y-m-d", $last_time);
1652 $last_date = explode("-",$sunday_list[$i]['date']);
1653 $last_time = mktime(0, 0, 0, $last_date[1], $last_date[2], $last_date[0]);
1654 $sunday_list[$i]['day'] = $last_date[2];
1655 $sunday_list[$i]['month'] = date("M",$last_time);
1656 $sunday_list[$i]['year'] = $last_date[0];
1659 $last_time += 90000;
1660 if($found_sunday) { $i++; $found_sunday=0; }
1663 $this->t->set_var('span', $i);
1664 $this->t->set_var('month',$sunday_list[$i-1]['month']);
1665 $this->t->set_var('year',$sunday_list[$i-1]['year']);
1666 $this->t->fp('list1','month_list',True);
1667 $elder_width=200; $att_width=25; $total_width=$elder_width;
1668 for ($i=0; $i < count($sunday_list); $i++) {
1669 $link_data['menuaction'] = 'eq.eq.att_update';
1670 $link_data['month'] = $sunday_list[$i]['month'];
1671 $link_data['year'] = $sunday_list[$i]['year'];
1672 $link_data['day'] = $sunday_list[$i]['day'];
1673 $link_data['date'] = $sunday_list[$i]['date'];
1674 $link_data['action'] = 'update_day';
1675 $this->t->set_var('update_day',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1676 $this->t->set_var('date',$sunday_list[$i]['date']);
1677 $this->t->set_var('day',$sunday_list[$i]['day']);
1678 $this->t->set_var('month',$sunday_list[$i]['month']);
1679 $this->t->set_var('year',$sunday_list[$i]['year']);
1680 $this->t->fp('list2','header_list',True);
1681 $total_width += $att_width;
1685 if($action == 'update_day')
1687 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.att_update&action=save_day'));
1688 $sunday_list[0]['date'] = date("Y-m-d", mktime(0, 0, 0, $monthnum[$month], $day, $year));
1689 $this->t->set_var('month',$month);
1690 $this->t->set_var('year',$year);
1691 $this->t->fp('list1','month_list',True);
1692 $this->t->set_var('date',$date);
1693 $this->t->set_var('day',$day);
1694 $this->t->set_var('month',$month);
1695 $this->t->set_var('year',$year);
1696 $this->t->fp('list2','header_list',True);
1699 for ($i=0; $i < count($elder_id); $i++) {
1701 $this->nextmatchs->template_alternate_row_color(&$this->t);
1702 $this->t->set_var('elder_name',$elder_name[$i]);
1703 for ($j=0; $j < count($sunday_list); $j++) {
1704 $sql = "SELECT * FROM eq_attendance WHERE date='"
1705 . $sunday_list[$j]['date'] . "' AND elder=" . $elder_id[$i];
1706 $this->db->query($sql,__LINE__,__FILE__);
1707 $value = $elder_id[$i] . "-" . $sunday_list[$j]['date'];
1708 if($this->db->next_record()) {
1709 $att_table .= '<td align=center><input type="checkbox" name="elders_attended[]" value="'.$value.'" checked></td>';
1711 $att_table .= '<td align=center><input type="checkbox" name="elders_attended[]" value="'.$value.'"></td>';
1714 $this->t->set_var('att_table',$att_table);
1715 $this->t->fp('list3','elder_list',True);
1718 $this->t->set_var('lang_done', 'Cancel');
1719 $this->t->set_var('lang_reset','Clear Form');
1720 $this->t->set_var('lang_save','Save Changes');
1722 $this->t->pfp('out','form');
1723 $this->t->pfp('addhandle','edit');
1725 $this->save_sessiondata();
1730 $this->t->set_file(array('dir_view_t' => 'dir_view.tpl'));
1731 $this->t->set_block('dir_view_t','dir_list','list');
1733 $sql = "SELECT * FROM eq_parent where valid=1 ORDER BY name ASC";
1734 $this->db->query($sql,__LINE__,__FILE__);
1736 while ($this->db->next_record())
1738 $parent[$i]['id'] = $this->db->f('parent');
1739 $parent[$i]['name'] = $this->db->f('name');
1740 $parent[$i]['phone'] = $this->db->f('phone');
1741 $parent[$i]['address'] = $this->db->f('address');
1745 for ($i=0; $i < count($parent); $i++)
1747 $name = $parent[$i]['name'];
1748 $phone = $parent[$i]['phone'];
1749 $address = $parent[$i]['address'];
1750 $this->t->set_var('name', $name);
1751 $this->t->set_var('address', $address);
1752 $this->t->set_var('phone', $phone);
1753 $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
1754 $this->t->set_var('tr_color',$tr_color);
1755 $this->t->fp('list','dir_list',True);
1756 //print "$phone $name $address<br>";
1758 $this->t->pfp('out','dir_view_t');
1759 $this->save_sessiondata();