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 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 // Delete all the visits that have taken place for all families for this month
349 $this->db->query("DELETE from eq_visit where companionship=" . $unique_companionships[$j]['companionship'] .
350 " AND " . "date='" . $date . "'",__LINE__,__FILE__);
353 // Now, add the visits that are checked for this month
354 $new_data = get_var('family_visited',array('POST'));
355 foreach ($new_data as $family)
357 foreach ($family as $data)
359 //print "family_visited: $data <br>";
360 $data_array = explode("/",$data);
361 $family_id = $data_array[0];
362 $companionship = $data_array[1];
363 $date = $data_array[2];
364 $visited = $data_array[3];
365 if($visited == "") { $visited = $data_array[4]; }
366 //print "family_id: $family_id companionship: $companionship date: $date visited: $visited<br>";
367 $this->db->query("INSERT INTO eq_visit (family,companionship,date,notes,visited) "
368 . "VALUES (" . $family_id .",". $companionship .",'". $date ."','','". $visited ."')",__LINE__,__FILE__);
375 $sql = "SELECT * FROM eq_elder where valid=1 ORDER BY elder ASC";
376 $this->db->query($sql,__LINE__,__FILE__);
378 while ($this->db->next_record())
380 $elder_id[$i] = $this->db->f('elder');
381 $elder_name[$i] = $this->db->f('name');
382 $elder_phone[$elder_id[$i]] = $this->db->f('phone');
385 array_multisort($elder_name, $elder_id);
387 // Make an array mapping elder_ids to elder_names
388 for($i=0; $i < count($elder_id); $i++) {
390 $elders[$id] = $elder_name[$i];
393 $sql = "SELECT * FROM eq_aaronic where valid=1 ORDER BY aaronic ASC";
394 $this->db->query($sql,__LINE__,__FILE__);
395 while ($this->db->next_record())
397 $aaronic_id = $this->db->f('aaronic');
398 $aaronic[$aaronic_id]['name'] = $this->db->f('name');
399 $aaronic[$aaronic_id]['phone'] = $this->db->f('phone');
402 // Select all the unique companionship numbers for this district
403 $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $district;
404 $this->db->query($sql,__LINE__,__FILE__);
405 $j=0; $unique_companionships='';
406 while ($this->db->next_record())
408 $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
412 $comp_width=300; $visit_width=25; $table_width=$comp_width + $visit_width;
413 $table_data=""; $num_companionships = 0; $num_families = 0; $visits=0;
414 for ($j=0; $j < count($unique_companionships); $j++) {
415 $companion_table_entry = "";
416 // Select all the companions in each companionship
417 $sql = "SELECT * FROM eq_companionship where valid=1 and ".
418 "companionship=". $unique_companionships[$j]['companionship'];
419 $this->db->query($sql,__LINE__,__FILE__);
421 while ($this->db->next_record())
423 // Get this companions information
424 if($companion_table_entry != "") { $companion_table_entry .= "<td> / </td>"; }
425 $companionship = $this->db->f('companionship');
426 $elder_id = $this->db->f('elder');
427 $aaronic_id = $this->db->f('aaronic');
429 $name = $elders[$elder_id];
430 $phone = $elder_phone[$elder_id];
432 else if($aaronic_id) {
433 $name = $aaronic[$aaronic_id]['name'];
434 $phone = $aaronic[$aaronic_id]['phone'];
436 $companion_table_entry .= "<td title=\"$phone\"><b>$name</b></td>";
438 $table_data.= "<tr bgcolor=#d3dce3><td colspan=20><table><tr>$companion_table_entry</tr></table><hr></td></tr>";
440 // Get the names of the families assigned this home teaching companionship
441 $sql = "SELECT * from eq_family where valid=1 AND companionship=".$unique_companionships[$j]['companionship'];
442 $this->db->query($sql,__LINE__,__FILE__);
443 while ($this->db->next_record())
445 $num_families++; $total_families++;
446 $family_name = $this->db->f('name');
447 $family_id = $this->db->f('family');
448 $this->nextmatchs->template_alternate_row_color(&$this->t);
449 $table_data.="<tr bgcolor=". $this->t->get_var('tr_color') ."><td>$family_name Family</td>";
451 $header_row="<th width=$comp_width><font size=-2>Families</th>";
452 $sql = "SELECT * FROM eq_visit WHERE date >= '$month_start' AND date <= '$month_end' ".
453 " AND companionship!=0".
454 " AND family=". $family_id;
455 $this->db2->query($sql,__LINE__,__FILE__);
456 $value = $family_id . "/" . $unique_companionships[$j]['companionship'] . "/" . $date;
457 $header_row .= "<th width=$visit_width><font size=-2><a href=$link>$month</a></th>";
458 if(!$total_visits) { $total_visits = 0; }
459 if($this->db2->next_record()) {
460 if($this->db2->f('visited') == 'y') {
461 $visits++; $total_visits++;
462 $table_data .= '<td width=100 align=center>';
463 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/y" checked>Y';
464 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/n">N';
465 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/"> ';
466 $table_data .= '</td>';
467 } else if($this->db2->f('visited') == 'n') {
468 $table_data .= '<td width=100 align=center>';
469 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/y">Y';
470 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/n" checked>N';
471 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/">';
472 $table_data .= '</td>';
474 $table_data .= '<td width=100 align=center>';
475 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/y">Y';
476 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/n">N';
477 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/" checked> ';
478 $table_data .= '</td>';
483 $table_data .= '<td width=100 align=center>';
484 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/y">Y';
485 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/n">N';
486 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/" checked> ';
487 $table_data .= '</td>';
490 $table_data .= "</tr>";
491 $table_data .= "<tr><td colspan=20></td></tr>";
493 $table_data .= "<tr><td colspan=20><hr></td></tr>";
494 $stat_data = "<tr><td><b><font size=-2>$num_families Families<br>Visit Totals:</font></b></td>";
496 $percent = ceil(($visits / $num_families)*100);
497 $stat_data .= "<td align=center><font size=-2><b>$visits<br>$percent%</font></b></td>";
498 $stat_data .= "</tr>";
500 $this->t->set_var('table_width',$table_width);
501 $this->t->set_var('header_row',$header_row);
502 $this->t->set_var('table_data',$table_data);
503 $this->t->set_var('stat_data',$stat_data);
504 $this->t->fp('list','district_list',True);
506 $this->t->set_var('lang_reset','Clear Form');
507 $this->t->set_var('lang_save','Save Changes');
508 $this->t->set_var('savehandle','');
510 $this->t->pfp('out','ht_update_t');
511 $this->t->pfp('addhandle','save');
513 $this->save_sessiondata();
518 $this->t->set_file(array('act_list_t' => 'act_list.tpl'));
519 $this->t->set_block('act_list_t','act_list','list');
521 $this->t->set_var('lang_name','Activity Name');
522 $this->t->set_var('lang_date','Date');
524 $sql = "SELECT * FROM eq_activity ORDER BY date DESC";
525 $this->db->query($sql,__LINE__,__FILE__);
526 $total_records = $this->db->num_rows();
529 while ($this->db->next_record())
531 $activity_list[$i]['name'] = $this->db->f('name');
532 $activity_list[$i]['date'] = $this->db->f('date');
533 $activity_list[$i]['activity'] = $this->db->f('activity');
537 for ($i=0; $i < count($activity_list); $i++)
539 $this->nextmatchs->template_alternate_row_color(&$this->t);
540 $this->t->set_var('name',$activity_list[$i]['name']);
541 $this->t->set_var('date',$activity_list[$i]['date']);
543 $link_data['menuaction'] = 'eq.eq.act_view';
544 $link_data['activity'] = $activity_list[$i]['activity'];
545 $link_data['action'] = 'view';
546 $this->t->set_var('view',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
547 $this->t->set_var('lang_view','View');
549 $link_data['menuaction'] = 'eq.eq.act_update';
550 $link_data['activity'] = $activity_list[$i]['activity'];
551 $link_data['action'] = 'edit';
552 $this->t->set_var('edit',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
553 $this->t->set_var('lang_edit','Edit');
555 $link_data['menuaction'] = 'eq.eq.act_update';
556 $link_data['activity'] = '0';
557 $link_data['action'] = 'add';
558 $this->t->set_var('add','<form method="POST" action="' . $GLOBALS['phpgw']->link('/eq/index.php',$link_data)
559 . '"><input type="submit" name="Add" value="' . 'Add Activity' .'"></font></form>');
561 $this->t->fp('list','act_list',True);
564 $this->t->pfp('out','act_list_t');
565 $this->save_sessiondata();
570 $this->t->set_file(array('act_view_t' => 'act_view.tpl'));
571 $this->t->set_block('act_view_t','part_list','list');
573 $sql = "SELECT * FROM eq_activity WHERE activity=" . intval(get_var('activity',array('GET','POST')));
574 $this->db->query($sql,__LINE__,__FILE__);
575 $this->db->next_record();
576 $this->t->set_var('name', $this->db->f('name'));
577 $this->t->set_var('date', $this->db->f('date'));
578 $this->t->set_var('notes', $this->db->f('notes'));
580 $this->t->set_var('lang_name','Activity Name');
581 $this->t->set_var('lang_date','Date');
582 $this->t->set_var('lang_notes','Notes');
583 $this->t->set_var('lang_done','Done');
584 $this->t->set_var('lang_action','View');
586 $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
587 $this->t->set_var('tr_color',$tr_color);
589 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.act_list'));
591 $link_data['menuaction'] = 'eq.eq.act_update';
592 $link_data['activity'] = get_var('activity',array('GET','POST'));
593 $link_data['action'] = 'edit';
594 $this->t->set_var('edit',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
595 $this->t->set_var('lang_edit','Edit');
596 $this->t->set_var('cal_date',$this->db->f('date'));
598 // Now find out which elders participated in this activity
599 $sql = "SELECT * FROM eq_participation WHERE activity=" . intval(get_var('activity',array('GET','POST')));
600 $this->db->query($sql,__LINE__,__FILE__);
601 $total_records = $this->db->num_rows();
604 while ($this->db->next_record())
606 $part_list[$i]['elder'] = $this->db->f('elder');
610 for ($i=0; $i < count($part_list); $i++)
612 $sql = "SELECT * FROM eq_elder WHERE elder=" . $part_list[$i]['elder'];
613 $this->db->query($sql,__LINE__,__FILE__);
614 $this->db->next_record();
615 $names[$i] = $this->db->f('name');
618 for ($i=0; $i < count($names); $i++)
620 //$this->nextmatchs->template_alternate_row_color(&$this->t);
621 $this->t->set_var('elder_name',$names[$i]);
622 if(($i+1) % 3 == 0) { $this->t->set_var('table_sep',"</td></tr><tr>"); }
623 else { $this->t->set_var('table_sep',"</td>"); }
624 if(($i) % 3 == 0) { $this->nextmatchs->template_alternate_row_color(&$this->t); }
625 $this->t->fp('list','part_list',True);
628 $this->t->pfp('out','act_view_t');
629 $this->save_sessiondata();
632 function act_update()
634 $this->t->set_file(array('form' => 'act_update.tpl'));
635 $this->t->set_block('form','elder_list','list');
636 $this->t->set_block('form','add','addhandle');
637 $this->t->set_block('form','edit','edithandle');
638 $this->t->set_var('lang_done','Done');
640 $action = get_var('action',array('GET','POST'));
641 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.act_list'));
642 $activity['activity'] = intval(get_var('activity',array('GET','POST')));
644 if($action == 'save')
646 $activity['name'] = $this->db->db_addslashes(get_var('name',array('POST')));
647 $activity['date'] = $this->db->db_addslashes(get_var('date',array('POST')));
648 $activity['notes']= $this->db->db_addslashes(get_var('notes',array('POST')));
649 $this->db->query("UPDATE eq_activity set " .
650 " name='" . $activity['name'] .
651 "', date='" . $activity['date'] . "'" .
652 ", notes='" . $activity['notes'] . "'" .
653 " WHERE activity=" . $activity['activity'],__LINE__,__FILE__);
655 // Delete all the elders who have particiapted in this activity
656 $this->db->query("DELETE from eq_participation where activity=".$activity['activity'],__LINE__,__FILE__);
658 // Re-add the elders who are checked as having participated in this activity
659 $elders = get_var('elder_name',array('POST'));
660 foreach ($elders as $elder)
662 $this->db->query("INSERT INTO eq_participation (elder,activity) "
663 . "VALUES (" . $elder . ",". $activity['activity'] . ")",__LINE__,__FILE__);
670 if($action == 'insert')
672 $activity['name'] = $this->db->db_addslashes(get_var('name',array('POST')));
673 $activity['date'] = $this->db->db_addslashes(get_var('date',array('POST')));
674 $activity['notes']= $this->db->db_addslashes(get_var('notes',array('POST')));
675 $this->db->query("INSERT INTO eq_activity (name,date,notes) "
676 . "VALUES ('" . $activity['name'] . "','"
677 . $activity['date'] . "','" . $activity['notes'] . "')",__LINE__,__FILE__);
684 $activity['activity'] = 0;
685 $this->t->set_var('cal_date',$this->jscal->input('date','','','','','','',$this->cal_options));
686 $this->t->set_var('name','');
687 $this->t->set_var('date','');
688 $this->t->set_var('notes','');
689 $this->t->set_var('lang_done','Cancel');
690 $this->t->set_var('lang_action','Adding New Activity');
691 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.act_update&activity='
692 . $activity['activity'] . '&action=' . 'insert'));
695 if($action == 'edit')
697 $sql = "SELECT * FROM eq_activity WHERE activity=" . $activity['activity'];
698 $this->db->query($sql,__LINE__,__FILE__);
699 $this->db->next_record();
700 $this->t->set_var('cal_date',$this->jscal->input('date',$this->db->f('date'),'','','','','',$this->cal_options));
701 $this->t->set_var('name', $this->db->f('name'));
702 $this->t->set_var('date', $this->db->f('date'));
703 $this->t->set_var('notes', $this->db->f('notes'));
704 $this->t->set_var('lang_done','Cancel');
705 $this->t->set_var('lang_action','Editing Activity');
706 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.act_update&activity='
707 . $activity['activity'] . '&action=' . 'save'));
711 $sql = "SELECT * FROM eq_elder";
712 $this->db->query($sql,__LINE__,__FILE__);
714 while ($this->db->next_record())
716 if($this->db->f('valid') == 1 || $action != 'add') {
717 $elder_name[$i] = $this->db->f('name');
718 $elder_id[$i] = $this->db->f('elder');
719 $elder_valid[$i] = $this->db->f('valid');
723 array_multisort($elder_name, $elder_id, $elder_valid);
726 for ($i=0; $i < count($elder_id); $i++)
728 //$this->nextmatchs->template_alternate_row_color(&$this->t);
729 $sql = "SELECT * FROM eq_participation where activity=". $activity['activity'] . " AND elder=" . $elder_id[$i];
730 $this->db->query($sql,__LINE__,__FILE__);
731 if($this->db->next_record()) { $this->t->set_var('checked','checked'); $checked=1; }
732 else { $this->t->set_var('checked',''); $checked=0; }
733 if($checked || $elder_valid[$i] == 1) {
734 $this->t->set_var('elder_name',$elder_name[$i]);
735 $this->t->set_var('elder',$elder_id[$i]);
736 if(($j+1) % 3 == 0) { $this->t->set_var('table_sep',"</td></tr><tr>"); }
737 else { $this->t->set_var('table_sep',"</td>"); }
738 if(($j) % 3 == 0) { $this->nextmatchs->template_alternate_row_color(&$this->t); }
739 $this->t->fp('list','elder_list',True);
744 $this->t->set_var('lang_reset','Clear Form');
745 $this->t->set_var('lang_add','Add Activity');
746 $this->t->set_var('lang_save','Save Changes');
747 $this->t->set_var('edithandle','');
748 $this->t->set_var('addhandle','');
750 $this->t->pfp('out','form');
751 if($action == 'edit') { $this->t->pfp('addhandle','edit'); }
752 if($action == 'add') { $this->t->pfp('addhandle','add'); }
754 $this->save_sessiondata();
759 $this->t->set_file(array('par_view_t' => 'par_view.tpl'));
760 $this->t->set_block('par_view_t','header_list','list1');
761 $this->t->set_block('par_view_t','elder_list','list2');
763 $sql = "SELECT * FROM eq_elder where valid=1";
764 $this->db->query($sql,__LINE__,__FILE__);
766 while ($this->db->next_record())
768 $elder_name[$i] = $this->db->f('name');
769 $elder_id[$i] = $this->db->f('elder');
772 array_multisort($elder_name, $elder_id);
774 $sql = "SELECT * FROM eq_activity ORDER BY date DESC";
775 $this->db->query($sql,__LINE__,__FILE__);
776 $total_records = $this->db->num_rows();
779 while ($this->db->next_record())
781 $activity_list[$i]['name'] = $this->db->f('name');
782 $activity_list[$i]['date'] = $this->db->f('date');
783 $activity_list[$i]['activity'] = $this->db->f('activity');
784 if($activity_list[$i]['date'] == '0000-00-00') { $activity_list[$i]['date']=""; }
788 $elder_width=250; $part_width=25; $act_width=50;
789 $total_width=$elder_width+$part_width;
790 for ($i=0; $i < count($activity_list); $i++) {
791 $this->t->set_var('activity_name',$activity_list[$i]['name']);
792 $this->t->set_var('activity_date',$activity_list[$i]['date']);
793 $this->t->fp('list1','header_list',True);
794 $total_width += $act_width;
797 for ($i=0; $i < count($elder_id); $i++) {
798 $participated=0; $part_table = '';
799 $this->nextmatchs->template_alternate_row_color(&$this->t);
800 $this->t->set_var('elder_name',$elder_name[$i]);
801 for ($j=0; $j < count($activity_list); $j++) {
802 $sql = "SELECT * FROM eq_participation where activity="
803 . $activity_list[$j]['activity'] . " AND elder=" . $elder_id[$i];
804 $this->db->query($sql,__LINE__,__FILE__);
805 if($this->db->next_record()) {
806 $part_table .= '<td align=center><img src="checkmark.gif"></td>';
809 $part_table .= '<td> </td>';
812 if($participated) { $part_table .= '<td align=center><img src="checkmark.gif">'.$participated.'</td>'; }
813 else { $part_table .= '<td> </td>'; }
814 $this->t->set_var('part_table',$part_table);
815 $this->t->fp('list2','elder_list',True);
817 $this->t->set_var('total_width',$total_width);
818 $this->t->set_var('elder_width',$elder_width);
819 $this->t->set_var('part_width',$part_width);
820 $this->t->set_var('act_width',$act_width);
821 $this->t->pfp('out','par_view_t');
822 $this->save_sessiondata();
827 $this->t->set_file(array('ppi_view_t' => 'ppi_view.tpl'));
828 $this->t->set_block('ppi_view_t','district_list','list');
830 $this->t->set_var('linkurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view'));
831 $num_months = get_var('num_months',array('GET','POST'));
832 if($num_months == '') { $num_months = $this->default_ppi_num_months; }
833 $this->t->set_var('num_months',$num_months);
834 if($num_months == 1) { $this->t->set_var('lang_num_months','Month of History'); }
835 else { $this->t->set_var('lang_num_months','Months of History'); }
836 $this->t->set_var('lang_filter','Filter');
838 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view'));
839 $this->t->set_var('eqpres_ppi_link',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view&eqpresppi=1'));
840 $eqpresppi = get_var('eqpresppi',array('GET','POST'));
842 if($eqpresppi == 1) {
843 $num_months = get_var('num_months',array('GET','POST'));
844 if($num_months == '') { $num_months = $this->default_ppi_num_years; }
845 $this->t->set_var('num_months',$num_months);
846 $this->t->set_var('ppi_link_title','PPIs');
847 $this->t->set_var('title','EQ President Yearly PPIs');
848 if($num_months == 1) { $this->t->set_var('lang_num_months','Year of History'); }
849 else { $this->t->set_var('lang_num_months','Years of History'); }
850 $this->t->set_var('eqpres_ppi_link',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view'));
853 $this->t->set_var('ppi_link_title','EQ President Yearly PPIs');
854 $this->t->set_var('title','PPIs');
857 $sql = "SELECT * FROM eq_district where valid=1 ORDER BY district ASC";
858 $this->db->query($sql,__LINE__,__FILE__);
860 while ($this->db->next_record())
862 $districts[$i]['district'] = $this->db->f('district');
863 $districts[$i]['name'] = $this->db->f('name');
864 $districts[$i]['supervisor'] = $this->db->f('supervisor');
865 if($eqpresppi == 0) { $i++; }
868 $sql = "SELECT * FROM eq_elder where valid=1 ORDER BY elder ASC";
869 $this->db->query($sql,__LINE__,__FILE__);
871 while ($this->db->next_record())
873 $elder_id[$i] = $this->db->f('elder');
874 $elder_name[$i] = $this->db->f('name');
875 $elder_phone[$elder_id[$i]] = $this->db->f('phone');
878 array_multisort($elder_name, $elder_id);
879 for($i=0; $i < count($elder_id); $i++) {
881 $elders[$id] = $elder_name[$i];
884 $sql = "SELECT * FROM eq_aaronic where valid=1 ORDER BY aaronic ASC";
885 $this->db->query($sql,__LINE__,__FILE__);
886 while ($this->db->next_record())
888 $aaronic_id = $this->db->f('aaronic');
889 $aaronic[$aaronic_id]['name'] = $this->db->f('name');
890 $aaronic[$aaronic_id]['phone'] = $this->db->f('phone');
893 $total_companionships = 0;
894 $this->nextmatchs->template_alternate_row_color(&$this->t);
895 for ($i=0; $i < count($districts); $i++) {
896 if($eqpresppi == 1) {
897 $this->t->set_var('district_number','*');
898 $this->t->set_var('district_name','EQ President');
900 $this->t->set_var('district_number',$districts[$i]['district']);
901 $this->t->set_var('district_name',$districts[$i]['name']);
903 $supervisor = $districts[$i]['supervisor'];
904 $unique_companionships='';
906 // Select all the unique companionship numbers for this district
907 if($eqpresppi == 1) {
908 $sql = "SELECT distinct companionship FROM eq_companionship";
911 $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $districts[$i]['district'];
913 $this->db->query($sql,__LINE__,__FILE__);
915 while ($this->db->next_record())
917 $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
921 $comp_width=400; $ppi_width=25; $table_width=$comp_width + $num_months*$ppi_width;
922 $table_data=""; $num_companionships = $j; $num_elders = 0;
923 for($m=$num_months; $m >= 0; $m--) { $ppis[$m] = 0; }
924 for ($j=0; $j < count($unique_companionships); $j++) {
925 // Select all the companions in each companionship
927 $sql = "SELECT * FROM eq_companionship where valid=1 and aaronic=0 and ".
928 "companionship=". $unique_companionships[$j]['companionship'];
931 $sql = "SELECT * FROM eq_companionship where valid=1 and ".
932 "companionship=". $unique_companionships[$j]['companionship'];
934 $this->db->query($sql,__LINE__,__FILE__);
936 $comp = $unique_companionships[$j]['companionship'];
937 for($m=$num_months; $m >= 0; $m--) { $ppi_recorded[$comp][$m] = 0; }
938 while ($this->db->next_record())
940 // Get this companions information
942 $companionship = $this->db->f('companionship');
943 $elder_id = $this->db->f('elder');
944 $aaronic_id = $this->db->f('aaronic');
946 $name = $elders[$elder_id];
947 $phone = $elder_phone[$elder_id];
949 else if($aaronic_id) {
950 $name = $aaronic[$aaronic_id]['name'];
951 $phone = $aaronic[$aaronic_id]['phone'];
953 $link_data['menuaction'] = 'eq.eq.ppi_update';
954 $link_data['companionship'] = $companionship;
955 $link_data['interviewer'] = $supervisor;
956 $link_data['elder'] = $elder_id;
957 $link_data['aaronic'] = $aaronic_id;
958 $link_data['name'] = $name;
959 $link_data['ppi'] = '';
960 $link_data['eqpresppi'] = $eqpresppi;
961 $link_data['action'] = 'add';
962 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
963 $table_data.= "<tr bgcolor=". $this->t->get_var('tr_color') ."><td title=\"$phone\"><a href=$link>$name</a></td>";
965 // Find out how many times PPIs were performed in the past $num_months for this Elder
966 $header_row="<th width=$comp_width><font size=-2>Companionship</th>";
967 for($m=$num_months; $m >= 0; $m--) {
968 if($eqpresppi == 1) {
969 $year = date('Y') - $m;
970 $year_start = $year - 1 . "-12-31"; $year_end = $year + 1 . "-01-01";
971 $sql = "SELECT * FROM eq_ppi WHERE date > '$year_start' AND date < '$year_end' ".
972 "AND elder=" . $elder_id . " AND aaronic=" . $aaronic_id . " AND eqpresppi=1";
973 $this->db2->query($sql,__LINE__,__FILE__);
974 $header_row .= "<th width=150><font size=-2>$year</th>";
977 if(`date '+%d'` == 31) { $d = 1; } else { $d = 0; }
978 $month = date('m/Y', strtotime('-'.$m.' month -'.$d.' day'));
979 $month_start = date('Y-m', strtotime('-'.$m.' month -'.$d.' day')); $month_start .= "-01";
980 $month_end = date('Y-m', strtotime('-'.$m.' month -'.$d.' day')); $month_end .= "-31";
981 $sql = "SELECT * FROM eq_ppi WHERE date >= '$month_start' AND date <= '$month_end' ".
982 "AND elder=" . $elder_id . " AND aaronic=" . $aaronic_id . " AND eqpresppi=0";
983 $this->db2->query($sql,__LINE__,__FILE__);
984 $header_row .= "<th width=$ppi_width><font size=-2>$month</th>";
986 if(!$total_ppis[$m]) { $total_ppis[$m] = 0; }
987 if($this->db2->next_record()) {
988 if(!$ppi_recorded[$companionship][$m]) {
989 $ppis[$m]++; $total_ppis[$m]++; $ppi_recorded[$companionship][$m]=1;
991 $link_data['menuaction'] = 'eq.eq.ppi_update';
992 $link_data['companionship'] = $companionship;
993 $link_data['interviewer'] = $this->db2->f('interviewer');
994 $link_data['elder'] = $elder_id;
995 $link_data['aaronic'] = $aaronic_id;
996 $link_data['name'] = $name;
997 $link_data['ppi'] = $this->db2->f('ppi');
998 $link_data['eqpresppi'] = $eqpresppi;
999 $link_data['action'] = 'view';
1000 $date = $this->db2->f('date');
1001 $date_array = explode("-",$date);
1002 $month = $date_array[1];
1003 $day = $date_array[2];
1004 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
1005 $table_data .= '<td align=center><a href='.$link.'><img src="checkmark.gif"><br>'.$month.'-'.$day.'</a></td>';
1007 else { $table_data .= "<td> </td>"; }
1009 $table_data .= "</tr>";
1012 $table_data .= "<tr><td colspan=20><hr></td></tr>";
1014 // Now add Elders not assigned to any companionship to the table if we are in eqpresppi mode
1015 if($eqpresppi == 1) {
1016 $table_data .= "<tr bgcolor=\"#c9c9c9\"><hr><td colspan=20><b>Unassigned Potential Home Teachers</b><hr></td></tr>";
1017 foreach($elders as $elder_id => $value) {
1018 $sql = "SELECT * FROM eq_companionship where valid=1 and elder=".$elder_id;
1019 $this->db->query($sql,__LINE__,__FILE__);
1020 if(!$this->db->next_record()) {
1021 // We found an Elder not in a companionship, add them to the table
1024 $name = $elders[$elder_id];
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'] = '';
1031 $link_data['eqpresppi'] = $eqpresppi;
1032 $link_data['action'] = 'add';
1033 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
1034 $table_data.= "<tr bgcolor=". $this->t->get_var('tr_color') ."><td><a href=$link>$name</a></td>";
1035 for($m=$num_months; $m >= 0; $m--) {
1036 $year = date('Y') - $m;
1037 $year_start = $year - 1 . "-12-31"; $year_end = $year + 1 . "-01-01";
1038 $sql = "SELECT * FROM eq_ppi WHERE date > '$year_start' AND date < '$year_end' ".
1039 "AND elder=" . $elder_id . " AND eqpresppi=1";
1040 $this->db2->query($sql,__LINE__,__FILE__);
1041 if(!$total_ppis[$m]) { $total_ppis[$m] = 0; }
1042 if($this->db2->next_record()) {
1043 $ppis[$m]++; $total_ppis[$m]++;
1044 $link_data['menuaction'] = 'eq.eq.ppi_update';
1045 $link_data['companionship'] = $companionship;
1046 $link_data['interviewer'] = $supervisor;
1047 $link_data['elder'] = $elder_id;
1048 $link_data['name'] = $name;
1049 $link_data['ppi'] = $this->db2->f('ppi');
1050 $link_data['eqpresppi'] = $eqpresppi;
1051 $link_data['action'] = 'view';
1052 $date = $this->db2->f('date');
1053 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
1054 $table_data .= '<td align=center><a href='.$link.'><img src="checkmark.gif"><br>'.$date.'</a></td>';
1056 else { $table_data .= "<td> </td>"; }
1058 $table_data .= "</tr>";
1062 $total_companionships += $num_companionships;
1063 if($eqpresppi == 1) {
1064 $stat_data = "<tr><td><b><font size=-2>$num_elders Elders<br>PPI Totals:</font></b></td>";
1066 $stat_data = "<tr><td><b><font size=-2>$num_companionships Companionships<br>PPI Totals:</font></b></td>";
1068 for($m=$num_months; $m >=0; $m--) {
1069 if($eqpresppi == 1) { $percent = ceil(($ppis[$m] / $num_elders)*100); }
1070 else { $percent = ceil(($ppis[$m] / $num_companionships)*100); }
1071 $stat_data .= "<td align=center><font size=-2><b>$ppis[$m]<br>$percent%</font></b></td>";
1073 $stat_data .= "</tr>";
1075 $this->t->set_var('table_width',$table_width);
1076 $this->t->set_var('header_row',$header_row);
1077 $this->t->set_var('table_data',$table_data);
1078 $this->t->set_var('stat_data',$stat_data);
1079 $this->t->fp('list','district_list',True);
1082 $totals = "<tr><td><b><font size=-2>$total_companionships Total Comps<br>PPI Totals:</font></b></td>";
1083 for($m=$num_months; $m >=0; $m--) {
1084 $percent = ceil(($total_ppis[$m] / $total_companionships)*100);
1085 $totals .= "<td align=center><font size=-2><b>$total_ppis[$m]<br>$percent%</font></b></td>";
1089 $this->t->set_var('totals',$totals);
1090 $this->t->pfp('out','ppi_view_t');
1091 $this->save_sessiondata();
1094 function ppi_update()
1096 $this->t->set_file(array('form' => 'ppi_update.tpl'));
1097 $this->t->set_block('form','interviewer_list','int_list');
1098 $this->t->set_block('form','add','addhandle');
1099 $this->t->set_block('form','edit','edithandle');
1101 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view'));
1102 $this->t->set_var('readonly','');
1103 $this->t->set_var('disabled','');
1105 $action = get_var('action',array('GET','POST'));
1106 $companionship = get_var('companionship',array('GET','POST'));
1107 $interviewer = get_var('interviewer',array('GET','POST'));
1108 $name = get_var('name',array('GET','POST'));
1109 $ppi = get_var('ppi',array('GET','POST'));
1110 $elder = get_var('elder',array('GET','POST'));
1111 $aaronic = get_var('aaronic',array('GET','POST'));
1112 $date = get_var('date',array('GET','POST'));
1113 $notes = get_var('notes',array('GET','POST'));
1114 $eqpresppi = get_var('eqpresppi',array('GET','POST'));
1116 $sql = "SELECT * FROM eq_district where valid=1 ORDER BY district ASC";
1117 $this->db->query($sql,__LINE__,__FILE__);
1118 while ($this->db->next_record())
1120 $supervisor = $this->db->f('supervisor');
1121 $sql = "SELECT * FROM eq_elder WHERE elder=" . $supervisor;
1122 $this->db2->query($sql,__LINE__,__FILE__);
1123 $this->db2->next_record();
1124 $interviewer_name = $this->db2->f('name');
1126 if($supervisor == $interviewer) {
1127 $this->t->set_var('interviewer',$supervisor . ' selected');
1129 $this->t->set_var('interviewer',$interviewer);
1131 $this->t->set_var('interviewer_name',$interviewer_name);
1132 $this->t->fp('int_list','interviewer_list',True);
1135 if($action == 'save')
1137 $notes = $this->db->db_addslashes(get_var('notes',array('POST')));
1138 $this->db->query("UPDATE eq_ppi set " .
1139 " ppi='" . $ppi . "'" .
1140 ", interviewer='" . $interviewer . "'" .
1141 ", elder='" . $elder . "'" .
1142 ", aaronic='" . $aaronic . "'" .
1143 ", date='" . $date . "'" .
1144 ", notes='" . $notes . "'" .
1145 ", eqpresppi='" . $eqpresppi . "'" .
1146 " WHERE ppi=" . $ppi,__LINE__,__FILE__);
1151 if($action == 'insert')
1153 $notes = $this->db->db_addslashes(get_var('notes',array('POST')));
1154 $this->db->query("INSERT INTO eq_ppi (interviewer,elder,aaronic,date,notes,eqpresppi) "
1155 . "VALUES ('" . $interviewer . "','" . $elder . "','" . $aaronic . "','"
1156 . $date . "','" . $notes . "','" . $eqpresppi ."')",__LINE__,__FILE__);
1161 if($action == 'add')
1163 $this->t->set_var('cal_date',$this->jscal->input('date','','','','','','',$this->cal_options));
1164 $this->t->set_var('ppi', '');
1165 $this->t->set_var('interviewer', $interviewer);
1166 $this->t->set_var('name',$name);
1167 $this->t->set_var('elder',$elder);
1168 $this->t->set_var('aaronic',$aaronic);
1169 $this->t->set_var('date','');
1170 $this->t->set_var('notes','');
1171 $this->t->set_var('eqpresppi',$eqpresppi);
1172 $this->t->set_var('lang_done','Cancel');
1173 $this->t->set_var('lang_action','Adding New PPI');
1174 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_update&ppi='
1175 . $ppi . '&action=' . 'insert'));
1178 if($action == 'edit' || $action == 'view')
1180 $sql = "SELECT * FROM eq_ppi WHERE ppi=".$ppi;
1181 $this->db->query($sql,__LINE__,__FILE__);
1182 $this->db->next_record();
1183 $this->t->set_var('ppi',$ppi);
1184 $this->t->set_var('name',$name);
1185 $this->t->set_var('interviewer', $this->db->f('interviewer'));
1186 $this->t->set_var('elder',$this->db->f('elder'));
1187 $this->t->set_var('aaronic',$this->db->f('aaronic'));
1188 $this->t->set_var('date',$this->db->f('date'));
1189 $this->t->set_var('notes',$this->db->f('notes'));
1190 $this->t->set_var('eqpresppi',$this->db->f('eqpresppi'));
1193 if($action == 'edit')
1195 $this->t->set_var('cal_date',$this->jscal->input('date',$date,'','','','','',$this->cal_options));
1196 $this->t->set_var('lang_done','Cancel');
1197 $this->t->set_var('lang_action','Editing PPI');
1198 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_update&ppi='
1199 . $ppi . '&action=' . 'save'));
1202 if($action == 'view')
1204 $date = $this->db->f('date');
1205 $this->t->set_var('cal_date','<input type=text size="10" maxlength="10" name="date" value="'.$date.'" readonly>');
1206 $this->t->set_var('readonly','READONLY');
1207 $this->t->set_var('disabled','DISABLED');
1208 $this->t->set_var('lang_done','Done');
1209 $this->t->set_var('lang_action','Viewing PPI');
1210 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_update&ppi='
1211 . $ppi . '&action=' . 'edit'));
1214 $this->t->set_var('lang_reset','Clear Form');
1215 $this->t->set_var('lang_add','Add PPI');
1216 $this->t->set_var('lang_save','Save Changes');
1217 $this->t->set_var('edithandle','');
1218 $this->t->set_var('addhandle','');
1220 $this->t->pfp('out','form');
1222 if($action == 'view') { $this->t->set_var('lang_save','Edit PPI'); }
1223 if($action == 'edit' || $action == 'view') { $this->t->pfp('addhandle','edit'); }
1224 if($action == 'add') { $this->t->pfp('addhandle','add'); }
1226 $this->save_sessiondata();
1231 $this->t->set_file(array('vis_view_t' => 'vis_view.tpl'));
1232 $this->t->set_block('vis_view_t','visit_list','list1');
1233 $this->t->set_block('vis_view_t','family_list','list2');
1235 $this->t->set_var('lang_name','Family Name');
1236 $this->t->set_var('lang_date','Date');
1238 $sql = "SELECT * FROM eq_visit WHERE companionship=0 ORDER BY date DESC";
1239 $this->db->query($sql,__LINE__,__FILE__);
1240 $total_records = $this->db->num_rows();
1243 while ($this->db->next_record())
1245 $visit_list[$i]['visit'] = $this->db->f('visit');
1246 $visit_list[$i]['family'] = $this->db->f('family');
1247 $visit_list[$i]['date'] = $this->db->f('date');
1251 for ($i=0; $i < count($visit_list); $i++)
1253 $this->nextmatchs->template_alternate_row_color(&$this->t);
1255 $sql = "SELECT * FROM eq_family WHERE family=".$visit_list[$i]['family'];
1256 $this->db->query($sql,__LINE__,__FILE__);
1257 $this->db->next_record();
1259 $this->t->set_var('family',$visit_list[$i]['family']);
1260 $this->t->set_var('family_name',$this->db->f('name'));
1261 $this->t->set_var('date',$visit_list[$i]['date']);
1263 $link_data['menuaction'] = 'eq.eq.vis_update';
1264 $link_data['visit'] = $visit_list[$i]['visit'];
1265 $link_data['name'] = $this->db->f('name');
1266 $link_data['date'] = $visit_list[$i]['date'];
1267 $link_data['action'] = 'view';
1268 $this->t->set_var('view',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1269 $this->t->set_var('lang_view','View');
1271 $link_data['menuaction'] = 'eq.eq.vis_update';
1272 $link_data['visit'] = $visit_list[$i]['visit'];
1273 $link_data['name'] = $this->db->f('name');
1274 $link_data['date'] = $visit_list[$i]['date'];
1275 $link_data['action'] = 'edit';
1276 $this->t->set_var('edit',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1277 $this->t->set_var('lang_edit','Edit');
1279 $this->t->fp('list1','visit_list',True);
1282 // List the families that are available to record a visit against
1283 $sql = "SELECT * FROM eq_family WHERE valid=1";
1284 $this->db->query($sql,__LINE__,__FILE__);
1285 $total_records = $this->db->num_rows();
1288 while ($this->db->next_record())
1290 $family_names[$i] = $this->db->f('name');
1291 $family_ids[$i] = $this->db->f('family');
1293 } array_multisort($family_names, $family_ids);
1295 for ($i=0; $i < count($family_names); $i++)
1297 $link_data['menuaction'] = 'eq.eq.vis_update';
1298 $link_data['visit'] = '';
1299 $link_data['family'] = $family_ids[$i];
1300 $link_data['action'] = 'add';
1301 $link_data['name'] = $family_names[$i];
1302 $this->t->set_var('add',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1304 $this->t->set_var('name',$family_names[$i]);
1305 if(($i+1) % 3 == 0) { $this->t->set_var('table_sep',"</td></tr><tr>"); }
1306 else { $this->t->set_var('table_sep',"</td>"); }
1307 if(($i) % 3 == 0) { $this->nextmatchs->template_alternate_row_color(&$this->t); }
1309 $this->t->fp('list2','family_list',True);
1312 $this->t->pfp('out','vis_view_t');
1313 $this->save_sessiondata();
1316 function vis_update()
1318 $this->t->set_file(array('form' => 'vis_update.tpl'));
1319 $this->t->set_block('form','add','addhandle');
1320 $this->t->set_block('form','edit','edithandle');
1322 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.vis_view'));
1323 $this->t->set_var('readonly','');
1324 $this->t->set_var('disabled','');
1326 $action = get_var('action',array('GET','POST'));
1327 $visit = get_var('visit',array('GET','POST'));
1328 $family = get_var('family',array('GET','POST'));
1329 $name = get_var('name',array('GET','POST'));
1330 $date = get_var('date',array('GET','POST'));
1331 $notes = get_var('notes',array('GET','POST'));
1334 if($action == 'save')
1336 $notes = $this->db->db_addslashes(get_var('notes',array('POST')));
1337 $this->db->query("UPDATE eq_visit set " .
1338 " date='" . $date . "'" .
1339 ", notes='" . $notes . "'" .
1340 " WHERE visit=" . $visit,__LINE__,__FILE__);
1345 if($action == 'insert')
1347 $notes = $this->db->db_addslashes(get_var('notes',array('POST')));
1348 $this->db->query("INSERT INTO eq_visit (family,companionship,date,notes) "
1349 . "VALUES ('" . $family . "','" . $companionship . "','"
1350 . $date . "','" . $notes . "')",__LINE__,__FILE__);
1355 if($action == 'add')
1357 $this->t->set_var('cal_date',$this->jscal->input('date','','','','','','',$this->cal_options));
1358 $this->t->set_var('family', $family);
1359 $this->t->set_var('visit', '');
1360 $this->t->set_var('name', $name);
1361 $this->t->set_var('date','');
1362 $this->t->set_var('notes','');
1363 $this->t->set_var('lang_done','Cancel');
1364 $this->t->set_var('lang_action','Adding New Visit');
1365 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.vis_update&family='
1366 . $family . '&action=' . 'insert'));
1369 if($action == 'edit' || $action == 'view')
1371 $sql = "SELECT * FROM eq_visit WHERE visit=".$visit;
1372 $this->db->query($sql,__LINE__,__FILE__);
1373 $this->db->next_record();
1374 $this->t->set_var('visit',$visit);
1375 $this->t->set_var('name',$name);
1376 $this->t->set_var('family', $family);
1377 $this->t->set_var('date',$this->db->f('date'));
1378 $this->t->set_var('notes',$this->db->f('notes'));
1381 if($action == 'edit')
1383 $this->t->set_var('cal_date',$this->jscal->input('date',$date,'','','','','',$this->cal_options));
1384 $this->t->set_var('lang_done','Cancel');
1385 $this->t->set_var('lang_action','Editing Visit');
1386 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.vis_update&visit='
1387 . $visit . '&action=' . 'save'));
1390 if($action == 'view')
1392 $date = $this->db->f('date');
1393 $this->t->set_var('cal_date','<input type=text size="10" maxlength="10" name="date" value="'.$date.'" readonly>');
1394 $this->t->set_var('readonly','READONLY');
1395 $this->t->set_var('disabled','DISABLED');
1396 $this->t->set_var('lang_done','Done');
1397 $this->t->set_var('lang_action','Viewing Visit');
1398 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.vis_update&visit='
1399 . $visit . '&action=' . 'edit'));
1402 $this->t->set_var('lang_reset','Clear Form');
1403 $this->t->set_var('lang_add','Add Visit');
1404 $this->t->set_var('lang_save','Save Changes');
1405 $this->t->set_var('edithandle','');
1406 $this->t->set_var('addhandle','');
1408 $this->t->pfp('out','form');
1410 if($action == 'view') { $this->t->set_var('lang_save','Edit Visit'); }
1411 if($action == 'edit' || $action == 'view') { $this->t->pfp('addhandle','edit'); }
1412 if($action == 'add') { $this->t->pfp('addhandle','add'); }
1414 $this->save_sessiondata();
1419 $this->t->set_file(array('att_view_t' => 'att_view.tpl'));
1420 $this->t->set_block('att_view_t','act_list','list');
1422 $this->t->set_block('att_view_t','month_list','list1');
1423 $this->t->set_block('att_view_t','header_list','list2');
1424 $this->t->set_block('att_view_t','elder_list','list3');
1426 $this->t->set_var('linkurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.att_view'));
1427 $num_months = get_var('num_months',array('GET','POST'));
1428 if($num_months == '') { $num_months = $this->default_att_num_months; }
1429 $this->t->set_var('num_months',$num_months);
1430 $this->t->set_var('lang_filter','Filter');
1431 if($num_months == 1) { $this->t->set_var('lang_num_months','Month of History'); }
1432 else { $this->t->set_var('lang_num_months','Months of History'); }
1434 $sql = "SELECT * FROM eq_elder where valid=1";
1435 $this->db->query($sql,__LINE__,__FILE__);
1437 while ($this->db->next_record())
1439 $elder_name[$i] = $this->db->f('name');
1440 $elder_id[$i] = $this->db->f('elder');
1443 array_multisort($elder_name, $elder_id);
1446 // Create a list of sunday dates for a window of 3 months back and current month
1450 $sunday_list[0]['date'] = date("Y-m-d", mktime(0, 0, 0, date("m")-$num_months, 1, date("y")));
1451 $last_date = explode("-",$sunday_list[0]['date']);
1452 $last_time = mktime(0, 0, 0, $last_date[1], $last_date[2], $last_date[0]);
1453 $time_limit = mktime(0, 0, 0, date("m"), date("t"), date("y"));
1454 while($last_time < $time_limit)
1456 $day = date("w",$last_time);
1457 if(date("w",$last_time) == 0) {
1458 $sunday_list[$i]['date'] = date("Y-m-d", $last_time);
1459 $last_date = explode("-",$sunday_list[$i]['date']);
1460 $last_time = mktime(0, 0, 0, $last_date[1], $last_date[2], $last_date[0]);
1461 $sunday_list[$i]['day'] = $last_date[2];
1462 $sunday_list[$i]['month'] = date("M",$last_time);
1463 $sunday_list[$i]['year'] = $last_date[0];
1466 $last_time += 90000;
1467 if($found_sunday) { $i++; $found_sunday=0; }
1470 $total_elders = count($elder_id);
1471 $old_month=$sunday_list[0]['month']; $span=0;
1472 for ($i=0; $i < count($sunday_list); $i++) {
1473 $date = $sunday_list[$i]['date'];
1474 $this->t->set_var('date',$sunday_list[$i]['date']);
1475 $this->t->set_var('day',$sunday_list[$i]['day']);
1476 if(($old_month != $sunday_list[$i]['month']) || $i == count($sunday_list)-1) {
1477 if($i == count($sunday_list)-1) { $span++; }
1478 $cur_month = $sunday_list[$i]['month'];
1479 $old_month = $sunday_list[$i]['month'];
1480 $link_data['menuaction'] = 'eq.eq.att_update';
1481 $link_data['month'] = $sunday_list[$i-1]['month'];
1482 $link_data['year'] = $sunday_list[$i-1]['year'];
1483 $link_data['action'] = 'update_month';
1484 $cur_month = $sunday_list[$i-1]['month'];
1485 $cur_year = $sunday_list[$i-1]['year'];
1486 $header_row .= "<th><font size=-3>$cur_month $cur_year</font></th>";
1487 $this->t->set_var('update_month',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1488 $this->t->set_var('month',$sunday_list[$i-1]['month']);
1489 $this->t->set_var('year',$sunday_list[$i-1]['year']);
1490 $this->t->set_var('span',$span); $span=0;
1491 $this->t->fp('list1','month_list',True);
1494 $this->t->set_var('total_elders',$total_elders);
1495 $this->t->set_var('header_row',$header_row);
1497 $elder_width=200; $att_width=25; $total_width=$elder_width;
1498 for ($i=0; $i < count($sunday_list); $i++) {
1499 $link_data['menuaction'] = 'eq.eq.att_update';
1500 $link_data['month'] = $sunday_list[$i]['month'];
1501 $link_data['year'] = $sunday_list[$i]['year'];
1502 $link_data['day'] = $sunday_list[$i]['day'];
1503 $link_data['date'] = $sunday_list[$i]['date'];
1504 $link_data['action'] = 'update_day';
1505 $this->t->set_var('update_day',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1506 $this->t->set_var('date',$sunday_list[$i]['date']);
1507 $this->t->set_var('day',$sunday_list[$i]['day']);
1508 $this->t->set_var('month',$sunday_list[$i]['month']);
1509 $this->t->set_var('year',$sunday_list[$i]['year']);
1510 $this->t->fp('list2','header_list',True);
1511 $total_width += $att_width;
1514 for ($i=0; $i < count($elder_id); $i++) {
1516 $this->nextmatchs->template_alternate_row_color(&$this->t);
1517 $this->t->set_var('elder_name',$elder_name[$i]);
1518 #print "checking for elder: " . $elder_id[$i] . "<br>";
1519 for ($j=0; $j < count($sunday_list); $j++) {
1520 #print "checking for date: " . $sunday_list[$j]['date'] . "<br>";
1521 #print "SELECT * FROM eq_attendance WHERE date='"
1522 # . $sunday_list[$j]['date'] . "' AND elder=" . $elder_id[$i] . "<br>";
1523 $sql = "SELECT * FROM eq_attendance WHERE date='"
1524 . $sunday_list[$j]['date'] . "' AND elder=" . $elder_id[$i];
1525 $this->db->query($sql,__LINE__,__FILE__);
1526 if($this->db->next_record()) {
1527 $cur_month = $sunday_list[$j]['month'];
1528 if($attended[$i][$cur_month] != 1) {
1529 $attended[$i][$cur_month]=1;
1530 $attendance[$cur_month]++;
1532 $att_table .= '<td align=center><img src="checkmark.gif"></td>';
1534 $att_table .= '<td> </td>';
1537 $this->t->set_var('att_table',$att_table);
1538 $this->t->fp('list3','elder_list',True);
1540 $this->t->set_var('total_width',$total_width);
1541 $this->t->set_var('elder_width',$elder_width);
1542 $this->t->set_var('att_width',$att_width);
1544 # Now calculate attendance for these months
1545 $attendance_str = "";
1546 $nonattendance_str = "";
1547 $aveattendance_str = "";
1548 $avenonattendance_str = "";
1550 $ave_total_attended=0;
1551 foreach($attendance as $att => $value) {
1552 $total_attended = $attendance[$att];
1553 $ave_total_attended += $attendance[$att]; $num_months++;
1554 $percent = ceil(($total_attended / $total_elders)*100);
1555 $attendance_str.="<td align=center><font size=-2><b>$total_attended ($percent%)</b></font></td>";
1556 $total_nonattended = $total_elders - $total_attended;
1557 $percent = ceil(($total_nonattended / $total_elders)*100);
1558 $nonattendance_str.="<td align=center><font size=-2><b>$total_nonattended ($percent%)</b></font></td>";
1560 $total_attended = ceil(($ave_total_attended / $num_months));
1561 $percent = ceil(($total_attended / $total_elders)*100);
1562 $aveattendance_str .= "<td align=center><font size=-2><b>$total_attended ($percent%)</b></font></td>";
1563 $total_attended = $total_elders - ceil(($ave_total_attended / $num_months));
1564 $percent = ceil(($total_attended / $total_elders)*100);
1565 $avenonattendance_str .= "<td align=center><font size=-2><b>$total_attended ($percent%)</b></font></td>";
1568 $this->t->set_var('attendance',$attendance_str);
1569 $this->t->set_var('aveattendance',$aveattendance_str);
1570 $this->t->set_var('nonattendance',$nonattendance_str);
1571 $this->t->set_var('avenonattendance',$avenonattendance_str);
1573 $this->t->pfp('out','att_view_t');
1574 $this->save_sessiondata();
1577 function att_update()
1579 $monthnum['Jan']=1; $monthnum['Feb']=2; $monthnum['Mar']=3; $monthnum['Apr']=4;
1580 $monthnum['May']=5; $monthnum['Jun']=6; $monthnum['Jul']=7; $monthnum['Aug']=8;
1581 $monthnum['Sep']=9; $monthnum['Oct']=10; $monthnum['Nov']=11; $monthnum['Dec']=12;
1583 $this->t->set_file(array('form' => 'att_update.tpl'));
1584 $this->t->set_block('form','edit','edithandle');
1586 $this->t->set_block('form','month_list','list1');
1587 $this->t->set_block('form','header_list','list2');
1588 $this->t->set_block('form','elder_list','list3');
1590 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.att_view'));
1592 $action = get_var('action',array('GET','POST'));
1593 $month = get_var('month',array('GET','POST'));
1594 $year = get_var('year',array('GET','POST'));
1595 $day = get_var('day',array('GET','POST'));
1596 $date = get_var('date',array('GET','POST'));
1598 if($action == 'save_month' || $action == 'save_day')
1600 $new_data = get_var('elders_attended',array('POST'));
1601 $month = $monthnum[$month]; if($month < 10) { $month = "0" . $month; }
1603 if($action == 'save_month') {
1604 $this->db->query("DELETE from eq_attendance where date LIKE '".$year."-".$month."-%'",__LINE__,__FILE__);
1607 if($action == 'save_day') {
1608 $this->db->query("DELETE from eq_attendance where date LIKE '".$year."-".$month."-".$day."'",__LINE__,__FILE__);
1611 foreach ($new_data as $data)
1613 $data_array = explode("-",$data);
1614 $elder = $data_array[0];
1615 $date = "$data_array[1]-$data_array[2]-$data_array[3]";
1616 $this->db->query("INSERT INTO eq_attendance (elder,date) "
1617 . "VALUES (" . $elder . ",'". $date . "')",__LINE__,__FILE__);
1624 $sql = "SELECT * FROM eq_elder where valid=1";
1625 $this->db->query($sql,__LINE__,__FILE__);
1627 while ($this->db->next_record())
1629 $elder_name[$i] = $this->db->f('name');
1630 $elder_id[$i] = $this->db->f('elder');
1633 array_multisort($elder_name, $elder_id);
1635 if($action == 'update_month')
1637 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.att_update&action=save_month'));
1641 $sunday_list[0]['date'] = date("Y-m-d", mktime(0, 0, 0, $monthnum[$month], 1, $year));
1642 $last_date = explode("-",$sunday_list[0]['date']);
1643 $last_time = mktime(0, 0, 0, $last_date[1], $last_date[2], $last_date[0]);
1644 $time_limit = mktime(0, 0, 0, $monthnum[$month], 31, $year);
1645 while($last_time <= $time_limit)
1647 $day = date("w",$last_time);
1648 if(date("w",$last_time) == 0) {
1649 $sunday_list[$i]['date'] = date("Y-m-d", $last_time);
1650 $last_date = explode("-",$sunday_list[$i]['date']);
1651 $last_time = mktime(0, 0, 0, $last_date[1], $last_date[2], $last_date[0]);
1652 $sunday_list[$i]['day'] = $last_date[2];
1653 $sunday_list[$i]['month'] = date("M",$last_time);
1654 $sunday_list[$i]['year'] = $last_date[0];
1657 $last_time += 90000;
1658 if($found_sunday) { $i++; $found_sunday=0; }
1661 $this->t->set_var('span', $i);
1662 $this->t->set_var('month',$sunday_list[$i-1]['month']);
1663 $this->t->set_var('year',$sunday_list[$i-1]['year']);
1664 $this->t->fp('list1','month_list',True);
1665 $elder_width=200; $att_width=25; $total_width=$elder_width;
1666 for ($i=0; $i < count($sunday_list); $i++) {
1667 $link_data['menuaction'] = 'eq.eq.att_update';
1668 $link_data['month'] = $sunday_list[$i]['month'];
1669 $link_data['year'] = $sunday_list[$i]['year'];
1670 $link_data['day'] = $sunday_list[$i]['day'];
1671 $link_data['date'] = $sunday_list[$i]['date'];
1672 $link_data['action'] = 'update_day';
1673 $this->t->set_var('update_day',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1674 $this->t->set_var('date',$sunday_list[$i]['date']);
1675 $this->t->set_var('day',$sunday_list[$i]['day']);
1676 $this->t->set_var('month',$sunday_list[$i]['month']);
1677 $this->t->set_var('year',$sunday_list[$i]['year']);
1678 $this->t->fp('list2','header_list',True);
1679 $total_width += $att_width;
1683 if($action == 'update_day')
1685 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.att_update&action=save_day'));
1686 $sunday_list[0]['date'] = date("Y-m-d", mktime(0, 0, 0, $monthnum[$month], $day, $year));
1687 $this->t->set_var('month',$month);
1688 $this->t->set_var('year',$year);
1689 $this->t->fp('list1','month_list',True);
1690 $this->t->set_var('date',$date);
1691 $this->t->set_var('day',$day);
1692 $this->t->set_var('month',$month);
1693 $this->t->set_var('year',$year);
1694 $this->t->fp('list2','header_list',True);
1697 for ($i=0; $i < count($elder_id); $i++) {
1699 $this->nextmatchs->template_alternate_row_color(&$this->t);
1700 $this->t->set_var('elder_name',$elder_name[$i]);
1701 for ($j=0; $j < count($sunday_list); $j++) {
1702 $sql = "SELECT * FROM eq_attendance WHERE date='"
1703 . $sunday_list[$j]['date'] . "' AND elder=" . $elder_id[$i];
1704 $this->db->query($sql,__LINE__,__FILE__);
1705 $value = $elder_id[$i] . "-" . $sunday_list[$j]['date'];
1706 if($this->db->next_record()) {
1707 $att_table .= '<td align=center><input type="checkbox" name="elders_attended[]" value="'.$value.'" checked></td>';
1709 $att_table .= '<td align=center><input type="checkbox" name="elders_attended[]" value="'.$value.'"></td>';
1712 $this->t->set_var('att_table',$att_table);
1713 $this->t->fp('list3','elder_list',True);
1716 $this->t->set_var('lang_done', 'Cancel');
1717 $this->t->set_var('lang_reset','Clear Form');
1718 $this->t->set_var('lang_save','Save Changes');
1720 $this->t->pfp('out','form');
1721 $this->t->pfp('addhandle','edit');
1723 $this->save_sessiondata();
1728 $this->t->set_file(array('form' => 'dir_view.tpl'));
1730 $this->t->pfp('out','form');
1731 $this->save_sessiondata();