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
45 $this->default_ht_num_months = 1;
46 $this->default_ppi_num_months = 1;
47 $this->default_ppi_num_years = 0;
48 $this->default_att_num_months = 1;
50 $this->db = $GLOBALS['phpgw']->db;
51 $this->db2 = $this->db;
52 $this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
53 $this->t = $GLOBALS['phpgw']->template;
54 $this->account = $GLOBALS['phpgw_info']['user']['account_id'];
55 $this->grants = $GLOBALS['phpgw']->acl->get_grants('eq');
56 $this->grants[$this->account] = PHPGW_ACL_READ + PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE;
58 $this->jscal = CreateObject('phpgwapi.jscalendar'); // before phpgw_header() !!!
59 $this->cal_options = 'daFormat : "%Y-%m-%d",
60 ifFormat : "%Y-%m-%d",
64 $GLOBALS['phpgw_info']['flags']['app_header'] = 'Elders Quorum Tools';
65 $GLOBALS['phpgw']->common->phpgw_header();
67 $this->display_app_header();
70 function save_sessiondata()
75 function display_app_header()
77 $this->t->set_file(array('eq_header' => 'header.tpl'));
79 if (isset($phpgw_info['user']['preferences']['eq']['eq_font']))
81 $font = $phpgw_info['user']['preferences']['eq']['eq_font'];
88 $this->t->set_var('bg_color',$phpgw_info['theme']['th_bg']);
89 $this->t->set_var('font',$font);
90 $link_data['menuaction'] = 'eq.eq.ht_view';
91 $this->t->set_var('link_hometeaching',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
92 $this->t->set_var('lang_hometeaching','HomeTeaching');
93 $link_data['menuaction'] = 'eq.eq.act_list';
94 $this->t->set_var('link_activity',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
95 $this->t->set_var('lang_activity','Activities');
96 $link_data['menuaction'] = 'eq.eq.par_view';
97 $this->t->set_var('link_participation',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
98 $this->t->set_var('lang_participation','Participation');
99 $link_data['menuaction'] = 'eq.eq.ppi_view';
100 $this->t->set_var('link_ppi',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
101 $this->t->set_var('lang_ppi','PPIs');
102 $link_data['menuaction'] = 'eq.eq.vis_view';
103 $this->t->set_var('link_visit',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
104 $this->t->set_var('lang_visit','Visits');
105 $link_data['menuaction'] = 'eq.eq.att_view';
106 $this->t->set_var('link_attendance',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
107 $this->t->set_var('lang_attendance','Attendance');
109 $this->t->pparse('out','eq_header');
114 $this->t->set_file(array('ht_view_t' => 'ht_view.tpl'));
115 $this->t->set_block('ht_view_t','district_list','list');
117 $this->t->set_var('linkurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ht_view'));
118 $num_months = get_var('num_months',array('GET','POST'));
119 if($num_months == '') { $num_months = $this->default_ht_num_months; }
120 $this->t->set_var('num_months',$num_months);
121 $this->t->set_var('lang_filter','Filter');
122 if($num_months == 1) { $this->t->set_var('lang_num_months','Month of History'); }
123 else { $this->t->set_var('lang_num_months','Months of History'); }
125 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ht_view'));
126 $this->t->set_var('title','Hometeaching');
128 $sql = "SELECT * FROM eq_district where valid=1 ORDER BY district ASC";
129 $this->db->query($sql,__LINE__,__FILE__);
131 while ($this->db->next_record())
133 $districts[$i]['district'] = $this->db->f('district');
134 $districts[$i]['name'] = $this->db->f('name');
135 $districts[$i]['supervisor'] = $this->db->f('supervisor');
139 $sql = "SELECT * FROM eq_elder where valid=1 ORDER BY elder ASC";
140 $this->db->query($sql,__LINE__,__FILE__);
142 while ($this->db->next_record())
144 $elder_id[$i] = $this->db->f('elder');
145 $elder_name[$i] = $this->db->f('name');
146 $elder_phone[$elder_id[$i]] = $this->db->f('phone');
149 array_multisort($elder_name, $elder_id);
151 // Make an array mapping elder_ids to elder_names
152 for($i=0; $i < count($elder_id); $i++) {
154 $elders[$id] = $elder_name[$i];
157 $sql = "SELECT * FROM eq_aaronic where valid=1 ORDER BY aaronic ASC";
158 $this->db->query($sql,__LINE__,__FILE__);
159 while ($this->db->next_record())
161 $aaronic_id = $this->db->f('aaronic');
162 $aaronic[$aaronic_id]['name'] = $this->db->f('name');
166 $this->nextmatchs->template_alternate_row_color(&$this->t);
167 for ($i=0; $i < count($districts); $i++) {
168 $this->t->set_var('district_number',$districts[$i]['district']);
169 $this->t->set_var('district_name',$districts[$i]['name']);
170 $supervisor = $districts[$i]['supervisor'];
171 $unique_companionships='';
173 // Select all the unique companionship numbers for this district
174 $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $districts[$i]['district'];
175 $this->db->query($sql,__LINE__,__FILE__);
177 while ($this->db->next_record())
179 $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
183 $comp_width=450; $visit_width=25; $table_width=$comp_width + $num_months*$visit_width;
184 $table_data=""; $num_companionships = 0; $num_families = 0;
185 for($m=$num_months; $m >= 0; $m--) { $visits[$m] = 0; }
186 for ($j=0; $j < count($unique_companionships); $j++) {
187 $companion_table_entry = "";
188 // Select all the companions in each companionship
189 $sql = "SELECT * FROM eq_companionship where valid=1 and ".
190 "companionship=". $unique_companionships[$j]['companionship'];
191 $this->db->query($sql,__LINE__,__FILE__);
193 while ($this->db->next_record())
195 // Get this companions information
196 if($companion_table_entry != "") { $companion_table_entry .= "<td> / </td>"; }
197 $companionship = $this->db->f('companionship');
198 $elder_id = $this->db->f('elder');
199 $aaronic_id = $this->db->f('aaronic');
200 $phone = $elder_phone[$elder_id];
201 if($elder_id) { $name = $elders[$elder_id]; }
202 else if($aaronic_id) { $name = $aaronic[$aaronic_id]['name']; }
203 $companion_table_entry .= "<td title=\"$phone\"><b>$name</b></td>";
205 $table_data.= "<tr bgcolor=#d3dce3><td colspan=20><table><tr>$companion_table_entry</tr></table><hr></td></tr>";
207 // Get the names of the families assigned this home teaching companionship
208 $sql = "SELECT * from eq_family where valid=1 AND companionship=".$unique_companionships[$j]['companionship'];
209 $this->db->query($sql,__LINE__,__FILE__);
211 while ($this->db->next_record())
213 $num_families++; $total_families++;
214 $family_name = $this->db->f('name');
215 $family_id = $this->db->f('family');
216 $this->nextmatchs->template_alternate_row_color(&$this->t);
217 $table_data.="<tr bgcolor=". $this->t->get_var('tr_color') ."><td>$family_name Family</td>";
218 // Find out how many times Visits were performed by this companionship
219 // in the past $num_months for this Family
220 $header_row="<th width=$comp_width><font size=-2>Families</th>";
221 for($m=$num_months; $m >= 0; $m--) {
222 if(`date '+%d'` == 31) { $d = 1; } else { $d = 0; }
223 $month = date('m/Y', strtotime('-'.$m.' month -'.$d.' day'));
224 $month_start = date('Y-m', strtotime('-'.$m.' month -'.$d.' day')); $month_start .= "-01";
225 $month_end = date('Y-m', strtotime('-'.$m.' month -'.$d.' day')); $month_end .= "-31";
226 // Add this to the query to filter on only visits made by this companionship:
227 // " AND companionship=" . $unique_companionships[$j]['companionship'].
228 $sql = "SELECT * FROM eq_visit WHERE date >= '$month_start' AND date <= '$month_end' ".
229 " AND companionship!=0".
230 " AND family=". $family_id;
231 $this->db2->query($sql,__LINE__,__FILE__);
232 $link_data['menuaction'] = 'eq.eq.ht_update';
233 $link_data['date'] = $month_start;
234 $link_data['month_start'] = $month_start;
235 $link_data['month_end'] = $month_end;
236 $link_data['month'] = $month;
237 $link_data['district'] = $districts[$i]['district'];
238 $link_data['district_name'] = $districts[$i]['name'];
239 $link_data['action'] = 'view';
240 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
241 $header_row .= "<th width=$visit_width><font size=-2><a href=$link>$month</a></th>";
242 if(!$total_visits[$m]) { $total_visits[$m] = 0; }
243 if($this->db2->next_record()) {
244 if($this->db2->f('visited') == 'y') {
245 $visits[$m]++; $total_visits[$m]++;
246 $table_data .= '<td align=center><a href="'.$link.'"><img src="checkmark.gif"></a></td>';
248 else if($this->db2->f('visited') == 'n') {
249 $table_data .= '<td align=center><a href="'.$link.'"><img src="x.gif"></a></td>';
252 $visits[$m]++; $total_visits[$m]++;
253 $table_data .= "<td> </td>";
257 $visits[$m]++; $total_visits[$m]++;
258 $table_data .= "<td> </td>";
261 $table_data .= "</tr>";
264 $table_data .= "<tr><td colspan=20></td></tr>";
266 $table_data .= "<tr><td colspan=20><hr></td></tr>";
267 $stat_data = "<tr><td><b><font size=-2>$num_families Families<br>Visit Totals:</font></b></td>";
269 for($m=$num_months; $m >=0; $m--) {
270 $percent = ceil(($visits[$m] / $num_families)*100);
271 $stat_data .= "<td align=center><font size=-2><b>$visits[$m]<br>$percent%</font></b></td>";
273 $stat_data .= "</tr>";
275 $this->t->set_var('table_width',$table_width);
276 $this->t->set_var('header_row',$header_row);
277 $this->t->set_var('table_data',$table_data);
278 $this->t->set_var('stat_data',$stat_data);
279 $this->t->fp('list','district_list',True);
282 $totals = "<tr><td><b><font size=-2>$total_families Total Families<br>Visit Totals:</font></b></td>";
283 for($m=$num_months; $m >=0; $m--) {
284 $percent = ceil(($total_visits[$m] / $total_families)*100);
285 $totals .= "<td align=center><font size=-2><b>$total_visits[$m]<br>$percent%</font></b></td>";
289 $this->t->set_var('totals',$totals);
291 $this->t->pfp('out','ht_view_t');
292 $this->save_sessiondata();
298 $this->t->set_file(array('ht_update_t' => 'ht_update.tpl'));
299 $this->t->set_block('ht_update_t','district_list','list');
300 $this->t->set_block('ht_update_t','save','savehandle');
302 $district = get_var('district',array('GET','POST'));
303 $district_name = get_var('district_name',array('GET','POST'));
304 $date = get_var('date',array('GET','POST'));
305 $month = get_var('month',array('GET','POST'));
306 $month_start = get_var('month_start',array('GET','POST'));
307 $month_end = get_var('month_end',array('GET','POST'));
308 $action = get_var('action',array('GET','POST'));
310 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ht_view'));
311 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ht_update&action=save'));
312 $this->t->set_var('lang_done','Cancel');
313 $this->t->set_var('district_name',$district_name);
314 $this->t->set_var('district_number',$district);
315 $this->t->set_var('title','Hometeaching Update ' . $month);
316 $this->t->set_var('date',$date);
318 if($action == 'save')
320 // Get a list of all the companionships in this district
321 $sql = "SELECT distinct companionship FROM eq_companionship where district=". $district;
322 $this->db->query($sql,__LINE__,__FILE__);
324 while ($this->db->next_record())
326 $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
329 for ($j=0; $j < count($unique_companionships); $j++)
331 // FIXME: We won't be able to go back and edit history on families that have been
332 // reassigned to a different companionship. The following delete command will not delete
333 // the history of visits under an older companionship, only the ones for the existing
334 // companionship. This will lead to duplicate visits being entered for an older
335 // month for the same family, making it impossible to change the past history once
336 // a family is reassigned. However, you will be able to view the history just fine.
338 // Delete all the visits that have taken place for all families for this month
339 $this->db->query("DELETE from eq_visit where companionship=" . $unique_companionships[$j]['companionship'] .
340 " AND " . "date='" . $date . "'",__LINE__,__FILE__);
343 // Now, add the visits that are checked for this month
344 $new_data = get_var('family_visited',array('POST'));
345 foreach ($new_data as $family)
347 foreach ($family as $data)
349 //print "family_visited: $data <br>";
350 $data_array = explode("/",$data);
351 $family_id = $data_array[0];
352 $companionship = $data_array[1];
353 $date = $data_array[2];
354 $visited = $data_array[3];
355 if($visited == "") { $visited = $data_array[4]; }
356 //print "family_id: $family_id companionship: $companionship date: $date visited: $visited<br>";
357 $this->db->query("INSERT INTO eq_visit (family,companionship,date,notes,visited) "
358 . "VALUES (" . $family_id .",". $companionship .",'". $date ."','','". $visited ."')",__LINE__,__FILE__);
365 $sql = "SELECT * FROM eq_elder where valid=1 ORDER BY elder ASC";
366 $this->db->query($sql,__LINE__,__FILE__);
368 while ($this->db->next_record())
370 $elder_id[$i] = $this->db->f('elder');
371 $elder_name[$i] = $this->db->f('name');
372 $elder_phone[$elder_id[$i]] = $this->db->f('phone');
375 array_multisort($elder_name, $elder_id);
377 // Make an array mapping elder_ids to elder_names
378 for($i=0; $i < count($elder_id); $i++) {
380 $elders[$id] = $elder_name[$i];
383 $sql = "SELECT * FROM eq_aaronic where valid=1 ORDER BY aaronic ASC";
384 $this->db->query($sql,__LINE__,__FILE__);
385 while ($this->db->next_record())
387 $aaronic_id = $this->db->f('aaronic');
388 $aaronic[$aaronic_id]['name'] = $this->db->f('name');
391 // Select all the unique companionship numbers for this district
392 $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $district;
393 $this->db->query($sql,__LINE__,__FILE__);
394 $j=0; $unique_companionships='';
395 while ($this->db->next_record())
397 $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
401 $comp_width=300; $visit_width=25; $table_width=$comp_width + $visit_width;
402 $table_data=""; $num_companionships = 0; $num_families = 0; $visits=0;
403 for ($j=0; $j < count($unique_companionships); $j++) {
404 $companion_table_entry = "";
405 // Select all the companions in each companionship
406 $sql = "SELECT * FROM eq_companionship where valid=1 and ".
407 "companionship=". $unique_companionships[$j]['companionship'];
408 $this->db->query($sql,__LINE__,__FILE__);
410 while ($this->db->next_record())
412 // Get this companions information
413 if($companion_table_entry != "") { $companion_table_entry .= "<td> / </td>"; }
414 $companionship = $this->db->f('companionship');
415 $elder_id = $this->db->f('elder');
416 $aaronic_id = $this->db->f('aaronic');
417 $phone = $elder_phone[$elder_id];
418 if($elder_id) { $name = $elders[$elder_id]; }
419 else if($aaronic_id) { $name = $aaronic[$aaronic_id]['name']; }
420 $companion_table_entry .= "<td title=\"$phone\"><b>$name</b></td>";
422 $table_data.= "<tr bgcolor=#d3dce3><td colspan=20><table><tr>$companion_table_entry</tr></table><hr></td></tr>";
424 // Get the names of the families assigned this home teaching companionship
425 $sql = "SELECT * from eq_family where valid=1 AND companionship=".$unique_companionships[$j]['companionship'];
426 $this->db->query($sql,__LINE__,__FILE__);
427 while ($this->db->next_record())
429 $num_families++; $total_families++;
430 $family_name = $this->db->f('name');
431 $family_id = $this->db->f('family');
432 $this->nextmatchs->template_alternate_row_color(&$this->t);
433 $table_data.="<tr bgcolor=". $this->t->get_var('tr_color') ."><td>$family_name Family</td>";
435 $header_row="<th width=$comp_width><font size=-2>Families</th>";
436 $sql = "SELECT * FROM eq_visit WHERE date >= '$month_start' AND date <= '$month_end' ".
437 " AND companionship!=0".
438 " AND family=". $family_id;
439 $this->db2->query($sql,__LINE__,__FILE__);
440 $value = $family_id . "/" . $unique_companionships[$j]['companionship'] . "/" . $date;
441 $header_row .= "<th width=$visit_width><font size=-2><a href=$link>$month</a></th>";
442 if(!$total_visits) { $total_visits = 0; }
443 if($this->db2->next_record()) {
444 if($this->db2->f('visited') == 'y') {
445 $visits++; $total_visits++;
446 $table_data .= '<td width=100 align=center>';
447 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/y" checked>Y';
448 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/n">N';
449 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/"> ';
450 $table_data .= '</td>';
451 } else if($this->db2->f('visited') == 'n') {
452 $table_data .= '<td width=100 align=center>';
453 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/y">Y';
454 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/n" checked>N';
455 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/">';
456 $table_data .= '</td>';
458 $table_data .= '<td width=100 align=center>';
459 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/y">Y';
460 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/n">N';
461 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/" checked> ';
462 $table_data .= '</td>';
467 $table_data .= '<td width=100 align=center>';
468 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/y">Y';
469 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/n">N';
470 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/" checked> ';
471 $table_data .= '</td>';
474 $table_data .= "</tr>";
475 $table_data .= "<tr><td colspan=20></td></tr>";
477 $table_data .= "<tr><td colspan=20><hr></td></tr>";
478 $stat_data = "<tr><td><b><font size=-2>$num_families Families<br>Visit Totals:</font></b></td>";
480 $percent = ceil(($visits / $num_families)*100);
481 $stat_data .= "<td align=center><font size=-2><b>$visits<br>$percent%</font></b></td>";
482 $stat_data .= "</tr>";
484 $this->t->set_var('table_width',$table_width);
485 $this->t->set_var('header_row',$header_row);
486 $this->t->set_var('table_data',$table_data);
487 $this->t->set_var('stat_data',$stat_data);
488 $this->t->fp('list','district_list',True);
490 $this->t->set_var('lang_reset','Clear Form');
491 $this->t->set_var('lang_save','Save Changes');
492 $this->t->set_var('savehandle','');
494 $this->t->pfp('out','ht_update_t');
495 $this->t->pfp('addhandle','save');
497 $this->save_sessiondata();
502 $this->t->set_file(array('act_list_t' => 'act_list.tpl'));
503 $this->t->set_block('act_list_t','act_list','list');
505 $this->t->set_var('lang_name','Activity Name');
506 $this->t->set_var('lang_date','Date');
508 $sql = "SELECT * FROM eq_activity ORDER BY date DESC";
509 $this->db->query($sql,__LINE__,__FILE__);
510 $total_records = $this->db->num_rows();
513 while ($this->db->next_record())
515 $activity_list[$i]['name'] = $this->db->f('name');
516 $activity_list[$i]['date'] = $this->db->f('date');
517 $activity_list[$i]['activity'] = $this->db->f('activity');
521 for ($i=0; $i < count($activity_list); $i++)
523 $this->nextmatchs->template_alternate_row_color(&$this->t);
524 $this->t->set_var('name',$activity_list[$i]['name']);
525 $this->t->set_var('date',$activity_list[$i]['date']);
527 $link_data['menuaction'] = 'eq.eq.act_view';
528 $link_data['activity'] = $activity_list[$i]['activity'];
529 $link_data['action'] = 'view';
530 $this->t->set_var('view',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
531 $this->t->set_var('lang_view','View');
533 $link_data['menuaction'] = 'eq.eq.act_update';
534 $link_data['activity'] = $activity_list[$i]['activity'];
535 $link_data['action'] = 'edit';
536 $this->t->set_var('edit',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
537 $this->t->set_var('lang_edit','Edit');
539 $link_data['menuaction'] = 'eq.eq.act_update';
540 $link_data['activity'] = '0';
541 $link_data['action'] = 'add';
542 $this->t->set_var('add','<form method="POST" action="' . $GLOBALS['phpgw']->link('/eq/index.php',$link_data)
543 . '"><input type="submit" name="Add" value="' . 'Add Activity' .'"></font></form>');
545 $this->t->fp('list','act_list',True);
548 $this->t->pfp('out','act_list_t');
549 $this->save_sessiondata();
554 $this->t->set_file(array('act_view_t' => 'act_view.tpl'));
555 $this->t->set_block('act_view_t','part_list','list');
557 $sql = "SELECT * FROM eq_activity WHERE activity=" . intval(get_var('activity',array('GET','POST')));
558 $this->db->query($sql,__LINE__,__FILE__);
559 $this->db->next_record();
560 $this->t->set_var('name', $this->db->f('name'));
561 $this->t->set_var('date', $this->db->f('date'));
562 $this->t->set_var('notes', $this->db->f('notes'));
564 $this->t->set_var('lang_name','Activity Name');
565 $this->t->set_var('lang_date','Date');
566 $this->t->set_var('lang_notes','Notes');
567 $this->t->set_var('lang_done','Done');
568 $this->t->set_var('lang_action','View');
570 $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
571 $this->t->set_var('tr_color',$tr_color);
573 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.act_list'));
575 $link_data['menuaction'] = 'eq.eq.act_update';
576 $link_data['activity'] = get_var('activity',array('GET','POST'));
577 $link_data['action'] = 'edit';
578 $this->t->set_var('edit',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
579 $this->t->set_var('lang_edit','Edit');
580 $this->t->set_var('cal_date',$this->db->f('date'));
582 // Now find out which elders participated in this activity
583 $sql = "SELECT * FROM eq_participation WHERE activity=" . intval(get_var('activity',array('GET','POST')));
584 $this->db->query($sql,__LINE__,__FILE__);
585 $total_records = $this->db->num_rows();
588 while ($this->db->next_record())
590 $part_list[$i]['elder'] = $this->db->f('elder');
594 for ($i=0; $i < count($part_list); $i++)
596 $sql = "SELECT * FROM eq_elder WHERE elder=" . $part_list[$i]['elder'];
597 $this->db->query($sql,__LINE__,__FILE__);
598 $this->db->next_record();
599 $names[$i] = $this->db->f('name');
602 for ($i=0; $i < count($names); $i++)
604 //$this->nextmatchs->template_alternate_row_color(&$this->t);
605 $this->t->set_var('elder_name',$names[$i]);
606 if(($i+1) % 3 == 0) { $this->t->set_var('table_sep',"</td></tr><tr>"); }
607 else { $this->t->set_var('table_sep',"</td>"); }
608 if(($i) % 3 == 0) { $this->nextmatchs->template_alternate_row_color(&$this->t); }
609 $this->t->fp('list','part_list',True);
612 $this->t->pfp('out','act_view_t');
613 $this->save_sessiondata();
616 function act_update()
618 $this->t->set_file(array('form' => 'act_update.tpl'));
619 $this->t->set_block('form','elder_list','list');
620 $this->t->set_block('form','add','addhandle');
621 $this->t->set_block('form','edit','edithandle');
622 $this->t->set_var('lang_done','Done');
624 $action = get_var('action',array('GET','POST'));
625 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.act_list'));
626 $activity['activity'] = intval(get_var('activity',array('GET','POST')));
628 if($action == 'save')
630 $activity['name'] = $this->db->db_addslashes(get_var('name',array('POST')));
631 $activity['date'] = $this->db->db_addslashes(get_var('date',array('POST')));
632 $activity['notes']= $this->db->db_addslashes(get_var('notes',array('POST')));
633 $this->db->query("UPDATE eq_activity set " .
634 " name='" . $activity['name'] .
635 "', date='" . $activity['date'] . "'" .
636 ", notes='" . $activity['notes'] . "'" .
637 " WHERE activity=" . $activity['activity'],__LINE__,__FILE__);
639 // Delete all the elders who have particiapted in this activity
640 $this->db->query("DELETE from eq_participation where activity=".$activity['activity'],__LINE__,__FILE__);
642 // Re-add the elders who are checked as having participated in this activity
643 $elders = get_var('elder_name',array('POST'));
644 foreach ($elders as $elder)
646 $this->db->query("INSERT INTO eq_participation (elder,activity) "
647 . "VALUES (" . $elder . ",". $activity['activity'] . ")",__LINE__,__FILE__);
654 if($action == 'insert')
656 $activity['name'] = $this->db->db_addslashes(get_var('name',array('POST')));
657 $activity['date'] = $this->db->db_addslashes(get_var('date',array('POST')));
658 $activity['notes']= $this->db->db_addslashes(get_var('notes',array('POST')));
659 $this->db->query("INSERT INTO eq_activity (name,date,notes) "
660 . "VALUES ('" . $activity['name'] . "','"
661 . $activity['date'] . "','" . $activity['notes'] . "')",__LINE__,__FILE__);
668 $activity['activity'] = 0;
669 $this->t->set_var('cal_date',$this->jscal->input('date','','','','','','',$this->cal_options));
670 $this->t->set_var('name','');
671 $this->t->set_var('date','');
672 $this->t->set_var('notes','');
673 $this->t->set_var('lang_done','Cancel');
674 $this->t->set_var('lang_action','Adding New Activity');
675 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.act_update&activity='
676 . $activity['activity'] . '&action=' . 'insert'));
679 if($action == 'edit')
681 $sql = "SELECT * FROM eq_activity WHERE activity=" . $activity['activity'];
682 $this->db->query($sql,__LINE__,__FILE__);
683 $this->db->next_record();
684 $this->t->set_var('cal_date',$this->jscal->input('date',$this->db->f('date'),'','','','','',$this->cal_options));
685 $this->t->set_var('name', $this->db->f('name'));
686 $this->t->set_var('date', $this->db->f('date'));
687 $this->t->set_var('notes', $this->db->f('notes'));
688 $this->t->set_var('lang_done','Cancel');
689 $this->t->set_var('lang_action','Editing Activity');
690 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.act_update&activity='
691 . $activity['activity'] . '&action=' . 'save'));
695 $sql = "SELECT * FROM eq_elder";
696 $this->db->query($sql,__LINE__,__FILE__);
698 while ($this->db->next_record())
700 if($this->db->f('valid') == 1 || $action != 'add') {
701 $elder_name[$i] = $this->db->f('name');
702 $elder_id[$i] = $this->db->f('elder');
703 $elder_valid[$i] = $this->db->f('valid');
707 array_multisort($elder_name, $elder_id, $elder_valid);
710 for ($i=0; $i < count($elder_id); $i++)
712 //$this->nextmatchs->template_alternate_row_color(&$this->t);
713 $sql = "SELECT * FROM eq_participation where activity=". $activity['activity'] . " AND elder=" . $elder_id[$i];
714 $this->db->query($sql,__LINE__,__FILE__);
715 if($this->db->next_record()) { $this->t->set_var('checked','checked'); $checked=1; }
716 else { $this->t->set_var('checked',''); $checked=0; }
717 if($checked || $elder_valid[$i] == 1) {
718 $this->t->set_var('elder_name',$elder_name[$i]);
719 $this->t->set_var('elder',$elder_id[$i]);
720 if(($j+1) % 3 == 0) { $this->t->set_var('table_sep',"</td></tr><tr>"); }
721 else { $this->t->set_var('table_sep',"</td>"); }
722 if(($j) % 3 == 0) { $this->nextmatchs->template_alternate_row_color(&$this->t); }
723 $this->t->fp('list','elder_list',True);
728 $this->t->set_var('lang_reset','Clear Form');
729 $this->t->set_var('lang_add','Add Activity');
730 $this->t->set_var('lang_save','Save Changes');
731 $this->t->set_var('edithandle','');
732 $this->t->set_var('addhandle','');
734 $this->t->pfp('out','form');
735 if($action == 'edit') { $this->t->pfp('addhandle','edit'); }
736 if($action == 'add') { $this->t->pfp('addhandle','add'); }
738 $this->save_sessiondata();
743 $this->t->set_file(array('par_view_t' => 'par_view.tpl'));
744 $this->t->set_block('par_view_t','header_list','list1');
745 $this->t->set_block('par_view_t','elder_list','list2');
747 $sql = "SELECT * FROM eq_elder where valid=1";
748 $this->db->query($sql,__LINE__,__FILE__);
750 while ($this->db->next_record())
752 $elder_name[$i] = $this->db->f('name');
753 $elder_id[$i] = $this->db->f('elder');
756 array_multisort($elder_name, $elder_id);
758 $sql = "SELECT * FROM eq_activity ORDER BY date DESC";
759 $this->db->query($sql,__LINE__,__FILE__);
760 $total_records = $this->db->num_rows();
763 while ($this->db->next_record())
765 $activity_list[$i]['name'] = $this->db->f('name');
766 $activity_list[$i]['date'] = $this->db->f('date');
767 $activity_list[$i]['activity'] = $this->db->f('activity');
768 if($activity_list[$i]['date'] == '0000-00-00') { $activity_list[$i]['date']=""; }
772 $elder_width=250; $part_width=25; $act_width=50;
773 $total_width=$elder_width+$part_width;
774 for ($i=0; $i < count($activity_list); $i++) {
775 $this->t->set_var('activity_name',$activity_list[$i]['name']);
776 $this->t->set_var('activity_date',$activity_list[$i]['date']);
777 $this->t->fp('list1','header_list',True);
778 $total_width += $act_width;
781 for ($i=0; $i < count($elder_id); $i++) {
782 $participated=0; $part_table = '';
783 $this->nextmatchs->template_alternate_row_color(&$this->t);
784 $this->t->set_var('elder_name',$elder_name[$i]);
785 for ($j=0; $j < count($activity_list); $j++) {
786 $sql = "SELECT * FROM eq_participation where activity="
787 . $activity_list[$j]['activity'] . " AND elder=" . $elder_id[$i];
788 $this->db->query($sql,__LINE__,__FILE__);
789 if($this->db->next_record()) {
790 $part_table .= '<td align=center><img src="checkmark.gif"></td>';
793 $part_table .= '<td> </td>';
796 if($participated) { $part_table .= '<td align=center><img src="checkmark.gif">'.$participated.'</td>'; }
797 else { $part_table .= '<td> </td>'; }
798 $this->t->set_var('part_table',$part_table);
799 $this->t->fp('list2','elder_list',True);
801 $this->t->set_var('total_width',$total_width);
802 $this->t->set_var('elder_width',$elder_width);
803 $this->t->set_var('part_width',$part_width);
804 $this->t->set_var('act_width',$act_width);
805 $this->t->pfp('out','par_view_t');
806 $this->save_sessiondata();
811 $this->t->set_file(array('ppi_view_t' => 'ppi_view.tpl'));
812 $this->t->set_block('ppi_view_t','district_list','list');
814 $this->t->set_var('linkurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view'));
815 $num_months = get_var('num_months',array('GET','POST'));
816 if($num_months == '') { $num_months = $this->default_ppi_num_months; }
817 $this->t->set_var('num_months',$num_months);
818 if($num_months == 1) { $this->t->set_var('lang_num_months','Month of History'); }
819 else { $this->t->set_var('lang_num_months','Months of History'); }
820 $this->t->set_var('lang_filter','Filter');
822 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view'));
823 $this->t->set_var('eqpres_ppi_link',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view&eqpresppi=1'));
824 $eqpresppi = get_var('eqpresppi',array('GET','POST'));
826 if($eqpresppi == 1) {
827 $num_months = get_var('num_months',array('GET','POST'));
828 if($num_months == '') { $num_months = $this->default_ppi_num_years; }
829 $this->t->set_var('num_months',$num_months);
830 $this->t->set_var('ppi_link_title','PPIs');
831 $this->t->set_var('title','EQ President Yearly PPIs');
832 if($num_months == 1) { $this->t->set_var('lang_num_months','Year of History'); }
833 else { $this->t->set_var('lang_num_months','Years of History'); }
834 $this->t->set_var('eqpres_ppi_link',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view'));
837 $this->t->set_var('ppi_link_title','EQ President Yearly PPIs');
838 $this->t->set_var('title','PPIs');
841 $sql = "SELECT * FROM eq_district where valid=1 ORDER BY district ASC";
842 $this->db->query($sql,__LINE__,__FILE__);
844 while ($this->db->next_record())
846 $districts[$i]['district'] = $this->db->f('district');
847 $districts[$i]['name'] = $this->db->f('name');
848 $districts[$i]['supervisor'] = $this->db->f('supervisor');
849 if($eqpresppi == 0) { $i++; }
852 $sql = "SELECT * FROM eq_elder where valid=1 ORDER BY elder ASC";
853 $this->db->query($sql,__LINE__,__FILE__);
855 while ($this->db->next_record())
857 $elder_id[$i] = $this->db->f('elder');
858 $elder_name[$i] = $this->db->f('name');
859 $elder_phone[$elder_id[$i]] = $this->db->f('phone');
862 array_multisort($elder_name, $elder_id);
863 for($i=0; $i < count($elder_id); $i++) {
865 $elders[$id] = $elder_name[$i];
868 $sql = "SELECT * FROM eq_aaronic where valid=1 ORDER BY aaronic ASC";
869 $this->db->query($sql,__LINE__,__FILE__);
870 while ($this->db->next_record())
872 $aaronic_id = $this->db->f('aaronic');
873 $aaronic[$aaronic_id]['name'] = $this->db->f('name');
876 $total_companionships = 0;
877 $this->nextmatchs->template_alternate_row_color(&$this->t);
878 for ($i=0; $i < count($districts); $i++) {
879 if($eqpresppi == 1) {
880 $this->t->set_var('district_number','*');
881 $this->t->set_var('district_name','EQ President');
883 $this->t->set_var('district_number',$districts[$i]['district']);
884 $this->t->set_var('district_name',$districts[$i]['name']);
886 $supervisor = $districts[$i]['supervisor'];
887 $unique_companionships='';
889 // Select all the unique companionship numbers for this district
890 if($eqpresppi == 1) {
891 $sql = "SELECT distinct companionship FROM eq_companionship";
894 $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $districts[$i]['district'];
896 $this->db->query($sql,__LINE__,__FILE__);
898 while ($this->db->next_record())
900 $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
904 $comp_width=400; $ppi_width=25; $table_width=$comp_width + $num_months*$ppi_width;
905 $table_data=""; $num_companionships = $j; $num_elders = 0;
906 for($m=$num_months; $m >= 0; $m--) { $ppis[$m] = 0; }
907 for ($j=0; $j < count($unique_companionships); $j++) {
908 // Select all the companions in each companionship
910 $sql = "SELECT * FROM eq_companionship where valid=1 and aaronic=0 and ".
911 "companionship=". $unique_companionships[$j]['companionship'];
914 $sql = "SELECT * FROM eq_companionship where valid=1 and ".
915 "companionship=". $unique_companionships[$j]['companionship'];
917 $this->db->query($sql,__LINE__,__FILE__);
919 while ($this->db->next_record())
921 // Get this companions information
923 $companionship = $this->db->f('companionship');
924 $elder_id = $this->db->f('elder');
925 $aaronic_id = $this->db->f('aaronic');
926 $phone = $elder_phone[$elder_id];
927 if($elder_id) { $name = $elders[$elder_id]; }
928 else if($aaronic_id) { $name = $aaronic[$aaronic_id]['name']; }
929 $link_data['menuaction'] = 'eq.eq.ppi_update';
930 $link_data['companionship'] = $companionship;
931 $link_data['interviewer'] = $supervisor;
932 $link_data['elder'] = $elder_id;
933 $link_data['name'] = $name;
934 $link_data['ppi'] = '';
935 $link_data['eqpresppi'] = $eqpresppi;
936 $link_data['action'] = 'add';
937 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
938 if($aaronic_id == 0) {
939 $table_data.= "<tr bgcolor=". $this->t->get_var('tr_color') ."><td title=\"$phone\"><a href=$link>$name</a></td>";
941 $table_data.= "<tr bgcolor=". $this->t->get_var('tr_color') ."><td>$name</td>";
944 // Find out how many times PPIs were performed in the past $num_months for this Elder
945 $header_row="<th width=$comp_width><font size=-2>Companionship</th>";
946 for($m=$num_months; $m >= 0; $m--) {
947 if($eqpresppi == 1) {
948 $year = date('Y') - $m;
949 $year_start = $year - 1 . "-12-31"; $year_end = $year + 1 . "-01-01";
950 $sql = "SELECT * FROM eq_ppi WHERE date > '$year_start' AND date < '$year_end' ".
951 "AND elder=" . $elder_id . " AND eqpresppi=1";
952 $this->db2->query($sql,__LINE__,__FILE__);
953 $header_row .= "<th width=150><font size=-2>$year</th>";
956 if(`date '+%d'` == 31) { $d = 1; } else { $d = 0; }
957 $month = date('m/Y', strtotime('-'.$m.' month -'.$d.' day'));
958 $month_start = date('Y-m', strtotime('-'.$m.' month -'.$d.' day')); $month_start .= "-01";
959 $month_end = date('Y-m', strtotime('-'.$m.' month -'.$d.' day')); $month_end .= "-31";
960 $sql = "SELECT * FROM eq_ppi WHERE date >= '$month_start' AND date <= '$month_end' ".
961 "AND elder=" . $elder_id . " AND eqpresppi=0";
962 $this->db2->query($sql,__LINE__,__FILE__);
963 $header_row .= "<th width=$ppi_width><font size=-2>$month</th>";
965 if(!$total_ppis[$m]) { $total_ppis[$m] = 0; }
966 if($this->db2->next_record()) {
967 $ppis[$m]++; $total_ppis[$m]++;
968 $link_data['menuaction'] = 'eq.eq.ppi_update';
969 $link_data['companionship'] = $companionship;
970 $link_data['interviewer'] = $this->db2->f('interviewer');
971 $link_data['elder'] = $elder_id;
972 $link_data['name'] = $name;
973 $link_data['ppi'] = $this->db2->f('ppi');
974 $link_data['eqpresppi'] = $eqpresppi;
975 $link_data['action'] = 'view';
976 $date = $this->db2->f('date');
977 $date_array = explode("-",$date);
978 $month = $date_array[1];
979 $day = $date_array[2];
980 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
982 if($aaronic_id == 0) {
983 $table_data .= '<td align=center><a href='.$link.'><img src="checkmark.gif"><br>'.$month.'-'.$day.'</a></td>';
985 $table_data .= '<td align=center><img src="checkmark.gif"></td>';
988 else { $table_data .= "<td> </td>"; }
990 $table_data .= "</tr>";
993 $table_data .= "<tr><td colspan=20><hr></td></tr>";
995 // Now add Elders not assigned to any companionship to the table if we are in eqpresppi mode
996 if($eqpresppi == 1) {
997 $table_data .= "<tr bgcolor=\"#c9c9c9\"><hr><td colspan=20><b>Unassigned Potential Home Teachers</b><hr></td></tr>";
998 foreach($elders as $elder_id => $value) {
999 $sql = "SELECT * FROM eq_companionship where valid=1 and elder=".$elder_id;
1000 $this->db->query($sql,__LINE__,__FILE__);
1001 if(!$this->db->next_record()) {
1002 // We found an Elder not in a companionship, add them to the table
1005 $name = $elders[$elder_id];
1006 $link_data['menuaction'] = 'eq.eq.ppi_update';
1007 $link_data['companionship'] = $companionship;
1008 $link_data['interviewer'] = $supervisor;
1009 $link_data['elder'] = $elder_id;
1010 $link_data['name'] = $name;
1011 $link_data['ppi'] = '';
1012 $link_data['eqpresppi'] = $eqpresppi;
1013 $link_data['action'] = 'add';
1014 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
1015 $table_data.= "<tr bgcolor=". $this->t->get_var('tr_color') ."><td><a href=$link>$name</a></td>";
1016 for($m=$num_months; $m >= 0; $m--) {
1017 $year = date('Y') - $m;
1018 $year_start = $year - 1 . "-12-31"; $year_end = $year + 1 . "-01-01";
1019 $sql = "SELECT * FROM eq_ppi WHERE date > '$year_start' AND date < '$year_end' ".
1020 "AND elder=" . $elder_id . " AND eqpresppi=1";
1021 $this->db2->query($sql,__LINE__,__FILE__);
1022 if(!$total_ppis[$m]) { $total_ppis[$m] = 0; }
1023 if($this->db2->next_record()) {
1024 $ppis[$m]++; $total_ppis[$m]++;
1025 $link_data['menuaction'] = 'eq.eq.ppi_update';
1026 $link_data['companionship'] = $companionship;
1027 $link_data['interviewer'] = $supervisor;
1028 $link_data['elder'] = $elder_id;
1029 $link_data['name'] = $name;
1030 $link_data['ppi'] = $this->db2->f('ppi');
1031 $link_data['eqpresppi'] = $eqpresppi;
1032 $link_data['action'] = 'view';
1033 $date = $this->db2->f('date');
1034 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
1035 $table_data .= '<td align=center><a href='.$link.'><img src="checkmark.gif"><br>'.$date.'</a></td>';
1037 else { $table_data .= "<td> </td>"; }
1039 $table_data .= "</tr>";
1043 $total_companionships += $num_companionships;
1044 if($eqpresppi == 1) {
1045 $stat_data = "<tr><td><b><font size=-2>$num_elders Elders<br>PPI Totals:</font></b></td>";
1047 $stat_data = "<tr><td><b><font size=-2>$num_companionships Companionships<br>PPI Totals:</font></b></td>";
1049 for($m=$num_months; $m >=0; $m--) {
1050 if($eqpresppi == 1) { $percent = ceil(($ppis[$m] / $num_elders)*100); }
1051 else { $percent = ceil(($ppis[$m] / $num_companionships)*100); }
1052 $stat_data .= "<td align=center><font size=-2><b>$ppis[$m]<br>$percent%</font></b></td>";
1054 $stat_data .= "</tr>";
1056 $this->t->set_var('table_width',$table_width);
1057 $this->t->set_var('header_row',$header_row);
1058 $this->t->set_var('table_data',$table_data);
1059 $this->t->set_var('stat_data',$stat_data);
1060 $this->t->fp('list','district_list',True);
1063 $totals = "<tr><td><b><font size=-2>$total_companionships Total Comps<br>PPI Totals:</font></b></td>";
1064 for($m=$num_months; $m >=0; $m--) {
1065 $percent = ceil(($total_ppis[$m] / $total_companionships)*100);
1066 $totals .= "<td align=center><font size=-2><b>$total_ppis[$m]<br>$percent%</font></b></td>";
1070 $this->t->set_var('totals',$totals);
1071 $this->t->pfp('out','ppi_view_t');
1072 $this->save_sessiondata();
1075 function ppi_update()
1077 $this->t->set_file(array('form' => 'ppi_update.tpl'));
1078 $this->t->set_block('form','interviewer_list','int_list');
1079 $this->t->set_block('form','add','addhandle');
1080 $this->t->set_block('form','edit','edithandle');
1082 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view'));
1083 $this->t->set_var('readonly','');
1084 $this->t->set_var('disabled','');
1086 $action = get_var('action',array('GET','POST'));
1087 $companionship = get_var('companionship',array('GET','POST'));
1088 $interviewer = get_var('interviewer',array('GET','POST'));
1089 $name = get_var('name',array('GET','POST'));
1090 $ppi = get_var('ppi',array('GET','POST'));
1091 $elder = get_var('elder',array('GET','POST'));
1092 $date = get_var('date',array('GET','POST'));
1093 $notes = get_var('notes',array('GET','POST'));
1094 $eqpresppi = get_var('eqpresppi',array('GET','POST'));
1096 $sql = "SELECT * FROM eq_district where valid=1 ORDER BY district ASC";
1097 $this->db->query($sql,__LINE__,__FILE__);
1098 while ($this->db->next_record())
1100 $supervisor = $this->db->f('supervisor');
1101 $sql = "SELECT * FROM eq_elder WHERE elder=" . $supervisor;
1102 $this->db2->query($sql,__LINE__,__FILE__);
1103 $this->db2->next_record();
1104 $interviewer_name = $this->db2->f('name');
1106 if($supervisor == $interviewer) {
1107 $this->t->set_var('interviewer',$supervisor . ' selected');
1109 $this->t->set_var('interviewer',$interviewer);
1111 $this->t->set_var('interviewer_name',$interviewer_name);
1112 $this->t->fp('int_list','interviewer_list',True);
1115 if($action == 'save')
1117 $notes = $this->db->db_addslashes(get_var('notes',array('POST')));
1118 $this->db->query("UPDATE eq_ppi set " .
1119 " ppi='" . $ppi . "'" .
1120 ", interviewer='" . $interviewer . "'" .
1121 ", elder='" . $elder . "'" .
1122 ", date='" . $date . "'" .
1123 ", notes='" . $notes . "'" .
1124 ", eqpresppi='" . $eqpresppi . "'" .
1125 " WHERE ppi=" . $ppi,__LINE__,__FILE__);
1130 if($action == 'insert')
1132 $notes = $this->db->db_addslashes(get_var('notes',array('POST')));
1133 $this->db->query("INSERT INTO eq_ppi (interviewer,elder,date,notes,eqpresppi) "
1134 . "VALUES ('" . $interviewer . "','" . $elder . "','"
1135 . $date . "','" . $notes . "','" . $eqpresppi ."')",__LINE__,__FILE__);
1140 if($action == 'add')
1142 $this->t->set_var('cal_date',$this->jscal->input('date','','','','','','',$this->cal_options));
1143 $this->t->set_var('ppi', '');
1144 $this->t->set_var('interviewer', $interviewer);
1145 $this->t->set_var('name',$name);
1146 $this->t->set_var('elder',$elder);
1147 $this->t->set_var('date','');
1148 $this->t->set_var('notes','');
1149 $this->t->set_var('eqpresppi',$eqpresppi);
1150 $this->t->set_var('lang_done','Cancel');
1151 $this->t->set_var('lang_action','Adding New PPI');
1152 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_update&ppi='
1153 . $ppi . '&action=' . 'insert'));
1156 if($action == 'edit' || $action == 'view')
1158 $sql = "SELECT * FROM eq_ppi WHERE ppi=".$ppi;
1159 $this->db->query($sql,__LINE__,__FILE__);
1160 $this->db->next_record();
1161 $this->t->set_var('ppi',$ppi);
1162 $this->t->set_var('name',$name);
1163 $this->t->set_var('interviewer', $this->db->f('interviewer'));
1164 $this->t->set_var('elder',$this->db->f('elder'));
1165 $this->t->set_var('date',$this->db->f('date'));
1166 $this->t->set_var('notes',$this->db->f('notes'));
1167 $this->t->set_var('eqpresppi',$this->db->f('eqpresppi'));
1170 if($action == 'edit')
1172 $this->t->set_var('cal_date',$this->jscal->input('date',$date,'','','','','',$this->cal_options));
1173 $this->t->set_var('lang_done','Cancel');
1174 $this->t->set_var('lang_action','Editing PPI');
1175 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_update&ppi='
1176 . $ppi . '&action=' . 'save'));
1179 if($action == 'view')
1181 $date = $this->db->f('date');
1182 $this->t->set_var('cal_date','<input type=text size="10" maxlength="10" name="date" value="'.$date.'" readonly>');
1183 $this->t->set_var('readonly','READONLY');
1184 $this->t->set_var('disabled','DISABLED');
1185 $this->t->set_var('lang_done','Done');
1186 $this->t->set_var('lang_action','Viewing PPI');
1187 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_update&ppi='
1188 . $ppi . '&action=' . 'edit'));
1191 $this->t->set_var('lang_reset','Clear Form');
1192 $this->t->set_var('lang_add','Add PPI');
1193 $this->t->set_var('lang_save','Save Changes');
1194 $this->t->set_var('edithandle','');
1195 $this->t->set_var('addhandle','');
1197 $this->t->pfp('out','form');
1199 if($action == 'view') { $this->t->set_var('lang_save','Edit PPI'); }
1200 if($action == 'edit' || $action == 'view') { $this->t->pfp('addhandle','edit'); }
1201 if($action == 'add') { $this->t->pfp('addhandle','add'); }
1203 $this->save_sessiondata();
1208 $this->t->set_file(array('vis_view_t' => 'vis_view.tpl'));
1209 $this->t->set_block('vis_view_t','visit_list','list1');
1210 $this->t->set_block('vis_view_t','family_list','list2');
1212 $this->t->set_var('lang_name','Family Name');
1213 $this->t->set_var('lang_date','Date');
1215 $sql = "SELECT * FROM eq_visit WHERE companionship=0 ORDER BY date DESC";
1216 $this->db->query($sql,__LINE__,__FILE__);
1217 $total_records = $this->db->num_rows();
1220 while ($this->db->next_record())
1222 $visit_list[$i]['visit'] = $this->db->f('visit');
1223 $visit_list[$i]['family'] = $this->db->f('family');
1224 $visit_list[$i]['date'] = $this->db->f('date');
1228 for ($i=0; $i < count($visit_list); $i++)
1230 $this->nextmatchs->template_alternate_row_color(&$this->t);
1232 $sql = "SELECT * FROM eq_family WHERE family=".$visit_list[$i]['family'];
1233 $this->db->query($sql,__LINE__,__FILE__);
1234 $this->db->next_record();
1236 $this->t->set_var('family',$visit_list[$i]['family']);
1237 $this->t->set_var('family_name',$this->db->f('name'));
1238 $this->t->set_var('date',$visit_list[$i]['date']);
1240 $link_data['menuaction'] = 'eq.eq.vis_update';
1241 $link_data['visit'] = $visit_list[$i]['visit'];
1242 $link_data['name'] = $this->db->f('name');
1243 $link_data['date'] = $visit_list[$i]['date'];
1244 $link_data['action'] = 'view';
1245 $this->t->set_var('view',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1246 $this->t->set_var('lang_view','View');
1248 $link_data['menuaction'] = 'eq.eq.vis_update';
1249 $link_data['visit'] = $visit_list[$i]['visit'];
1250 $link_data['name'] = $this->db->f('name');
1251 $link_data['date'] = $visit_list[$i]['date'];
1252 $link_data['action'] = 'edit';
1253 $this->t->set_var('edit',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1254 $this->t->set_var('lang_edit','Edit');
1256 $this->t->fp('list1','visit_list',True);
1259 // List the families that are available to record a visit against
1260 $sql = "SELECT * FROM eq_family WHERE valid=1";
1261 $this->db->query($sql,__LINE__,__FILE__);
1262 $total_records = $this->db->num_rows();
1265 while ($this->db->next_record())
1267 $family_names[$i] = $this->db->f('name');
1268 $family_ids[$i] = $this->db->f('family');
1270 } array_multisort($family_names, $family_ids);
1272 for ($i=0; $i < count($family_names); $i++)
1274 $link_data['menuaction'] = 'eq.eq.vis_update';
1275 $link_data['visit'] = '';
1276 $link_data['family'] = $family_ids[$i];
1277 $link_data['action'] = 'add';
1278 $link_data['name'] = $family_names[$i];
1279 $this->t->set_var('add',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1281 $this->t->set_var('name',$family_names[$i]);
1282 if(($i+1) % 3 == 0) { $this->t->set_var('table_sep',"</td></tr><tr>"); }
1283 else { $this->t->set_var('table_sep',"</td>"); }
1284 if(($i) % 3 == 0) { $this->nextmatchs->template_alternate_row_color(&$this->t); }
1286 $this->t->fp('list2','family_list',True);
1289 $this->t->pfp('out','vis_view_t');
1290 $this->save_sessiondata();
1293 function vis_update()
1295 $this->t->set_file(array('form' => 'vis_update.tpl'));
1296 $this->t->set_block('form','add','addhandle');
1297 $this->t->set_block('form','edit','edithandle');
1299 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.vis_view'));
1300 $this->t->set_var('readonly','');
1301 $this->t->set_var('disabled','');
1303 $action = get_var('action',array('GET','POST'));
1304 $visit = get_var('visit',array('GET','POST'));
1305 $family = get_var('family',array('GET','POST'));
1306 $name = get_var('name',array('GET','POST'));
1307 $date = get_var('date',array('GET','POST'));
1308 $notes = get_var('notes',array('GET','POST'));
1311 if($action == 'save')
1313 $notes = $this->db->db_addslashes(get_var('notes',array('POST')));
1314 $this->db->query("UPDATE eq_visit set " .
1315 " date='" . $date . "'" .
1316 ", notes='" . $notes . "'" .
1317 " WHERE visit=" . $visit,__LINE__,__FILE__);
1322 if($action == 'insert')
1324 $notes = $this->db->db_addslashes(get_var('notes',array('POST')));
1325 $this->db->query("INSERT INTO eq_visit (family,companionship,date,notes) "
1326 . "VALUES ('" . $family . "','" . $companionship . "','"
1327 . $date . "','" . $notes . "')",__LINE__,__FILE__);
1332 if($action == 'add')
1334 $this->t->set_var('cal_date',$this->jscal->input('date','','','','','','',$this->cal_options));
1335 $this->t->set_var('family', $family);
1336 $this->t->set_var('visit', '');
1337 $this->t->set_var('name', $name);
1338 $this->t->set_var('date','');
1339 $this->t->set_var('notes','');
1340 $this->t->set_var('lang_done','Cancel');
1341 $this->t->set_var('lang_action','Adding New Visit');
1342 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.vis_update&family='
1343 . $family . '&action=' . 'insert'));
1346 if($action == 'edit' || $action == 'view')
1348 $sql = "SELECT * FROM eq_visit WHERE visit=".$visit;
1349 $this->db->query($sql,__LINE__,__FILE__);
1350 $this->db->next_record();
1351 $this->t->set_var('visit',$visit);
1352 $this->t->set_var('name',$name);
1353 $this->t->set_var('family', $family);
1354 $this->t->set_var('date',$this->db->f('date'));
1355 $this->t->set_var('notes',$this->db->f('notes'));
1358 if($action == 'edit')
1360 $this->t->set_var('cal_date',$this->jscal->input('date',$date,'','','','','',$this->cal_options));
1361 $this->t->set_var('lang_done','Cancel');
1362 $this->t->set_var('lang_action','Editing Visit');
1363 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.vis_update&visit='
1364 . $visit . '&action=' . 'save'));
1367 if($action == 'view')
1369 $date = $this->db->f('date');
1370 $this->t->set_var('cal_date','<input type=text size="10" maxlength="10" name="date" value="'.$date.'" readonly>');
1371 $this->t->set_var('readonly','READONLY');
1372 $this->t->set_var('disabled','DISABLED');
1373 $this->t->set_var('lang_done','Done');
1374 $this->t->set_var('lang_action','Viewing Visit');
1375 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.vis_update&visit='
1376 . $visit . '&action=' . 'edit'));
1379 $this->t->set_var('lang_reset','Clear Form');
1380 $this->t->set_var('lang_add','Add Visit');
1381 $this->t->set_var('lang_save','Save Changes');
1382 $this->t->set_var('edithandle','');
1383 $this->t->set_var('addhandle','');
1385 $this->t->pfp('out','form');
1387 if($action == 'view') { $this->t->set_var('lang_save','Edit Visit'); }
1388 if($action == 'edit' || $action == 'view') { $this->t->pfp('addhandle','edit'); }
1389 if($action == 'add') { $this->t->pfp('addhandle','add'); }
1391 $this->save_sessiondata();
1396 $this->t->set_file(array('att_view_t' => 'att_view.tpl'));
1397 $this->t->set_block('att_view_t','act_list','list');
1399 $this->t->set_block('att_view_t','month_list','list1');
1400 $this->t->set_block('att_view_t','header_list','list2');
1401 $this->t->set_block('att_view_t','elder_list','list3');
1403 $this->t->set_var('linkurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.att_view'));
1404 $num_months = get_var('num_months',array('GET','POST'));
1405 if($num_months == '') { $num_months = $this->default_att_num_months; }
1406 $this->t->set_var('num_months',$num_months);
1407 $this->t->set_var('lang_filter','Filter');
1408 if($num_months == 1) { $this->t->set_var('lang_num_months','Month of History'); }
1409 else { $this->t->set_var('lang_num_months','Months of History'); }
1411 $sql = "SELECT * FROM eq_elder where valid=1";
1412 $this->db->query($sql,__LINE__,__FILE__);
1414 while ($this->db->next_record())
1416 $elder_name[$i] = $this->db->f('name');
1417 $elder_id[$i] = $this->db->f('elder');
1420 array_multisort($elder_name, $elder_id);
1423 // Create a list of sunday dates for a window of 3 months back and current month
1427 $sunday_list[0]['date'] = date("Y-m-d", mktime(0, 0, 0, date("m")-$num_months, 1, date("y")));
1428 $last_date = explode("-",$sunday_list[0]['date']);
1429 $last_time = mktime(0, 0, 0, $last_date[1], $last_date[2], $last_date[0]);
1430 $time_limit = mktime(0, 0, 0, date("m"), date("t"), date("y"));
1431 while($last_time < $time_limit)
1433 $day = date("w",$last_time);
1434 if(date("w",$last_time) == 0) {
1435 $sunday_list[$i]['date'] = date("Y-m-d", $last_time);
1436 $last_date = explode("-",$sunday_list[$i]['date']);
1437 $last_time = mktime(0, 0, 0, $last_date[1], $last_date[2], $last_date[0]);
1438 $sunday_list[$i]['day'] = $last_date[2];
1439 $sunday_list[$i]['month'] = date("M",$last_time);
1440 $sunday_list[$i]['year'] = $last_date[0];
1443 $last_time += 90000;
1444 if($found_sunday) { $i++; $found_sunday=0; }
1447 $total_elders = count($elder_id);
1448 $old_month=$sunday_list[0]['month']; $span=0;
1449 for ($i=0; $i < count($sunday_list); $i++) {
1450 $date = $sunday_list[$i]['date'];
1451 $this->t->set_var('date',$sunday_list[$i]['date']);
1452 $this->t->set_var('day',$sunday_list[$i]['day']);
1453 if(($old_month != $sunday_list[$i]['month']) || $i == count($sunday_list)-1) {
1454 if($i == count($sunday_list)-1) { $span++; }
1455 $cur_month = $sunday_list[$i]['month'];
1456 $old_month = $sunday_list[$i]['month'];
1457 $link_data['menuaction'] = 'eq.eq.att_update';
1458 $link_data['month'] = $sunday_list[$i-1]['month'];
1459 $link_data['year'] = $sunday_list[$i-1]['year'];
1460 $link_data['action'] = 'update_month';
1461 $cur_month = $sunday_list[$i-1]['month'];
1462 $cur_year = $sunday_list[$i-1]['year'];
1463 $header_row .= "<th><font size=-3>$cur_month $cur_year</font></th>";
1464 $this->t->set_var('update_month',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1465 $this->t->set_var('month',$sunday_list[$i-1]['month']);
1466 $this->t->set_var('year',$sunday_list[$i-1]['year']);
1467 $this->t->set_var('span',$span); $span=0;
1468 $this->t->fp('list1','month_list',True);
1471 $this->t->set_var('total_elders',$total_elders);
1472 $this->t->set_var('header_row',$header_row);
1474 $elder_width=200; $att_width=25; $total_width=$elder_width;
1475 for ($i=0; $i < count($sunday_list); $i++) {
1476 $link_data['menuaction'] = 'eq.eq.att_update';
1477 $link_data['month'] = $sunday_list[$i]['month'];
1478 $link_data['year'] = $sunday_list[$i]['year'];
1479 $link_data['day'] = $sunday_list[$i]['day'];
1480 $link_data['date'] = $sunday_list[$i]['date'];
1481 $link_data['action'] = 'update_day';
1482 $this->t->set_var('update_day',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1483 $this->t->set_var('date',$sunday_list[$i]['date']);
1484 $this->t->set_var('day',$sunday_list[$i]['day']);
1485 $this->t->set_var('month',$sunday_list[$i]['month']);
1486 $this->t->set_var('year',$sunday_list[$i]['year']);
1487 $this->t->fp('list2','header_list',True);
1488 $total_width += $att_width;
1491 for ($i=0; $i < count($elder_id); $i++) {
1493 $this->nextmatchs->template_alternate_row_color(&$this->t);
1494 $this->t->set_var('elder_name',$elder_name[$i]);
1495 #print "checking for elder: " . $elder_id[$i] . "<br>";
1496 for ($j=0; $j < count($sunday_list); $j++) {
1497 #print "checking for date: " . $sunday_list[$j]['date'] . "<br>";
1498 #print "SELECT * FROM eq_attendance WHERE date='"
1499 # . $sunday_list[$j]['date'] . "' AND elder=" . $elder_id[$i] . "<br>";
1500 $sql = "SELECT * FROM eq_attendance WHERE date='"
1501 . $sunday_list[$j]['date'] . "' AND elder=" . $elder_id[$i];
1502 $this->db->query($sql,__LINE__,__FILE__);
1503 if($this->db->next_record()) {
1504 $cur_month = $sunday_list[$j]['month'];
1505 if($attended[$i][$cur_month] != 1) {
1506 $attended[$i][$cur_month]=1;
1507 $attendance[$cur_month]++;
1509 $att_table .= '<td align=center><img src="checkmark.gif"></td>';
1511 $att_table .= '<td> </td>';
1514 $this->t->set_var('att_table',$att_table);
1515 $this->t->fp('list3','elder_list',True);
1517 $this->t->set_var('total_width',$total_width);
1518 $this->t->set_var('elder_width',$elder_width);
1519 $this->t->set_var('att_width',$att_width);
1521 # Now calculate attendance for these months
1522 $attendance_str = "";
1523 $nonattendance_str = "";
1524 $aveattendance_str = "";
1525 $avenonattendance_str = "";
1527 $ave_total_attended=0;
1528 foreach($attendance as $att => $value) {
1529 $total_attended = $attendance[$att];
1530 $ave_total_attended += $attendance[$att]; $num_months++;
1531 $percent = ceil(($total_attended / $total_elders)*100);
1532 $attendance_str.="<td align=center><font size=-2><b>$total_attended ($percent%)</b></font></td>";
1533 $total_nonattended = $total_elders - $total_attended;
1534 $percent = ceil(($total_nonattended / $total_elders)*100);
1535 $nonattendance_str.="<td align=center><font size=-2><b>$total_nonattended ($percent%)</b></font></td>";
1537 $total_attended = ceil(($ave_total_attended / $num_months));
1538 $percent = ceil(($total_attended / $total_elders)*100);
1539 $aveattendance_str .= "<td align=center><font size=-2><b>$total_attended ($percent%)</b></font></td>";
1540 $total_attended = $total_elders - ceil(($ave_total_attended / $num_months));
1541 $percent = ceil(($total_attended / $total_elders)*100);
1542 $avenonattendance_str .= "<td align=center><font size=-2><b>$total_attended ($percent%)</b></font></td>";
1545 $this->t->set_var('attendance',$attendance_str);
1546 $this->t->set_var('aveattendance',$aveattendance_str);
1547 $this->t->set_var('nonattendance',$nonattendance_str);
1548 $this->t->set_var('avenonattendance',$avenonattendance_str);
1550 $this->t->pfp('out','att_view_t');
1551 $this->save_sessiondata();
1554 function att_update()
1556 $monthnum['Jan']=1; $monthnum['Feb']=2; $monthnum['Mar']=3; $monthnum['Apr']=4;
1557 $monthnum['May']=5; $monthnum['Jun']=6; $monthnum['Jul']=7; $monthnum['Aug']=8;
1558 $monthnum['Sep']=9; $monthnum['Oct']=10; $monthnum['Nov']=11; $monthnum['Dec']=12;
1560 $this->t->set_file(array('form' => 'att_update.tpl'));
1561 $this->t->set_block('form','edit','edithandle');
1563 $this->t->set_block('form','month_list','list1');
1564 $this->t->set_block('form','header_list','list2');
1565 $this->t->set_block('form','elder_list','list3');
1567 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.att_view'));
1569 $action = get_var('action',array('GET','POST'));
1570 $month = get_var('month',array('GET','POST'));
1571 $year = get_var('year',array('GET','POST'));
1572 $day = get_var('day',array('GET','POST'));
1573 $date = get_var('date',array('GET','POST'));
1575 if($action == 'save_month' || $action == 'save_day')
1577 $new_data = get_var('elders_attended',array('POST'));
1578 $month = $monthnum[$month]; if($month < 10) { $month = "0" . $month; }
1580 if($action == 'save_month') {
1581 $this->db->query("DELETE from eq_attendance where date LIKE '".$year."-".$month."-%'",__LINE__,__FILE__);
1584 if($action == 'save_day') {
1585 $this->db->query("DELETE from eq_attendance where date LIKE '".$year."-".$month."-".$day."'",__LINE__,__FILE__);
1588 foreach ($new_data as $data)
1590 $data_array = explode("-",$data);
1591 $elder = $data_array[0];
1592 $date = "$data_array[1]-$data_array[2]-$data_array[3]";
1593 $this->db->query("INSERT INTO eq_attendance (elder,date) "
1594 . "VALUES (" . $elder . ",'". $date . "')",__LINE__,__FILE__);
1601 $sql = "SELECT * FROM eq_elder where valid=1";
1602 $this->db->query($sql,__LINE__,__FILE__);
1604 while ($this->db->next_record())
1606 $elder_name[$i] = $this->db->f('name');
1607 $elder_id[$i] = $this->db->f('elder');
1610 array_multisort($elder_name, $elder_id);
1612 if($action == 'update_month')
1614 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.att_update&action=save_month'));
1618 $sunday_list[0]['date'] = date("Y-m-d", mktime(0, 0, 0, $monthnum[$month], 1, $year));
1619 $last_date = explode("-",$sunday_list[0]['date']);
1620 $last_time = mktime(0, 0, 0, $last_date[1], $last_date[2], $last_date[0]);
1621 $time_limit = mktime(0, 0, 0, $monthnum[$month], 31, $year);
1622 while($last_time <= $time_limit)
1624 $day = date("w",$last_time);
1625 if(date("w",$last_time) == 0) {
1626 $sunday_list[$i]['date'] = date("Y-m-d", $last_time);
1627 $last_date = explode("-",$sunday_list[$i]['date']);
1628 $last_time = mktime(0, 0, 0, $last_date[1], $last_date[2], $last_date[0]);
1629 $sunday_list[$i]['day'] = $last_date[2];
1630 $sunday_list[$i]['month'] = date("M",$last_time);
1631 $sunday_list[$i]['year'] = $last_date[0];
1634 $last_time += 90000;
1635 if($found_sunday) { $i++; $found_sunday=0; }
1638 $this->t->set_var('span', $i);
1639 $this->t->set_var('month',$sunday_list[$i-1]['month']);
1640 $this->t->set_var('year',$sunday_list[$i-1]['year']);
1641 $this->t->fp('list1','month_list',True);
1642 $elder_width=200; $att_width=25; $total_width=$elder_width;
1643 for ($i=0; $i < count($sunday_list); $i++) {
1644 $link_data['menuaction'] = 'eq.eq.att_update';
1645 $link_data['month'] = $sunday_list[$i]['month'];
1646 $link_data['year'] = $sunday_list[$i]['year'];
1647 $link_data['day'] = $sunday_list[$i]['day'];
1648 $link_data['date'] = $sunday_list[$i]['date'];
1649 $link_data['action'] = 'update_day';
1650 $this->t->set_var('update_day',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1651 $this->t->set_var('date',$sunday_list[$i]['date']);
1652 $this->t->set_var('day',$sunday_list[$i]['day']);
1653 $this->t->set_var('month',$sunday_list[$i]['month']);
1654 $this->t->set_var('year',$sunday_list[$i]['year']);
1655 $this->t->fp('list2','header_list',True);
1656 $total_width += $att_width;
1660 if($action == 'update_day')
1662 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.att_update&action=save_day'));
1663 $sunday_list[0]['date'] = date("Y-m-d", mktime(0, 0, 0, $monthnum[$month], $day, $year));
1664 $this->t->set_var('month',$month);
1665 $this->t->set_var('year',$year);
1666 $this->t->fp('list1','month_list',True);
1667 $this->t->set_var('date',$date);
1668 $this->t->set_var('day',$day);
1669 $this->t->set_var('month',$month);
1670 $this->t->set_var('year',$year);
1671 $this->t->fp('list2','header_list',True);
1674 for ($i=0; $i < count($elder_id); $i++) {
1676 $this->nextmatchs->template_alternate_row_color(&$this->t);
1677 $this->t->set_var('elder_name',$elder_name[$i]);
1678 for ($j=0; $j < count($sunday_list); $j++) {
1679 $sql = "SELECT * FROM eq_attendance WHERE date='"
1680 . $sunday_list[$j]['date'] . "' AND elder=" . $elder_id[$i];
1681 $this->db->query($sql,__LINE__,__FILE__);
1682 $value = $elder_id[$i] . "-" . $sunday_list[$j]['date'];
1683 if($this->db->next_record()) {
1684 $att_table .= '<td align=center><input type="checkbox" name="elders_attended[]" value="'.$value.'" checked></td>';
1686 $att_table .= '<td align=center><input type="checkbox" name="elders_attended[]" value="'.$value.'"></td>';
1689 $this->t->set_var('att_table',$att_table);
1690 $this->t->fp('list3','elder_list',True);
1693 $this->t->set_var('lang_done', 'Cancel');
1694 $this->t->set_var('lang_reset','Clear Form');
1695 $this->t->set_var('lang_save','Save Changes');
1697 $this->t->pfp('out','form');
1698 $this->t->pfp('addhandle','edit');
1700 $this->save_sessiondata();