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;
29 var $public_functions = array
48 $this->default_ht_num_months = 3;
49 $this->default_ppi_num_months = 3;
50 $this->default_ppi_num_years = 0;
51 $this->default_att_num_months = 3;
53 $this->db = $GLOBALS['phpgw']->db;
54 $this->db2 = $this->db;
55 $this->nextmatchs = CreateObject('phpgwapi.nextmatchs');
56 $this->t = $GLOBALS['phpgw']->template;
57 $this->account = $GLOBALS['phpgw_info']['user']['account_id'];
58 $this->grants = $GLOBALS['phpgw']->acl->get_grants('eq');
59 $this->grants[$this->account] = PHPGW_ACL_READ + PHPGW_ACL_ADD + PHPGW_ACL_EDIT + PHPGW_ACL_DELETE;
61 $this->jscal = CreateObject('phpgwapi.jscalendar'); // before phpgw_header() !!!
62 $this->cal_options = 'daFormat : "%Y-%m-%d",
63 ifFormat : "%Y-%m-%d",
67 $GLOBALS['phpgw_info']['flags']['app_header'] = 'Elders Quorum Tools';
68 $GLOBALS['phpgw']->common->phpgw_header();
70 $this->current_month = `date '+%m'`;
71 $this->current_month = $this->current_month-0; // Make it numeric
72 $this->current_year = `date '+%Y'`;
73 $this->current_year = $this->current_year-0; // Make it numeric
76 $this->display_app_header();
79 function save_sessiondata()
84 function display_app_header()
86 $this->t->set_file(array('eq_header' => 'header.tpl'));
88 if (isset($phpgw_info['user']['preferences']['eq']['eq_font']))
90 $font = $phpgw_info['user']['preferences']['eq']['eq_font'];
97 $this->t->set_var('bg_color',$phpgw_info['theme']['th_bg']);
98 $this->t->set_var('font',$font);
99 $link_data['menuaction'] = 'eq.eq.ht_view';
100 $this->t->set_var('link_hometeaching',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
101 $this->t->set_var('lang_hometeaching','HomeTeaching');
102 $link_data['menuaction'] = 'eq.eq.act_list';
103 $this->t->set_var('link_activity',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
104 $this->t->set_var('lang_activity','Activities');
105 $link_data['menuaction'] = 'eq.eq.par_view';
106 $this->t->set_var('link_participation',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
107 $this->t->set_var('lang_participation','Participation');
108 $link_data['menuaction'] = 'eq.eq.ppi_view';
109 $this->t->set_var('link_ppi',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
110 $this->t->set_var('lang_ppi','PPIs');
111 $link_data['menuaction'] = 'eq.eq.vis_view';
112 $this->t->set_var('link_visit',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
113 $this->t->set_var('lang_visit','Visits');
114 $link_data['menuaction'] = 'eq.eq.att_view';
115 $this->t->set_var('link_attendance',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
116 $this->t->set_var('lang_attendance','Attendance');
117 $link_data['menuaction'] = 'eq.eq.dir_view';
118 $this->t->set_var('link_dir',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
119 $this->t->set_var('lang_dir','Directory');
121 $this->t->pparse('out','eq_header');
126 $this->t->set_file(array('ht_view_t' => 'ht_view.tpl'));
127 $this->t->set_block('ht_view_t','district_list','list');
129 $this->t->set_var('linkurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ht_view'));
130 $num_months = get_var('num_months',array('GET','POST'));
131 if($num_months == '') { $num_months = $this->default_ht_num_months; }
132 $this->t->set_var('num_months',$num_months);
133 $this->t->set_var('lang_filter','Filter');
134 if($num_months == 1) { $this->t->set_var('lang_num_months','Month of History'); }
135 else { $this->t->set_var('lang_num_months','Months of History'); }
137 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ht_view'));
138 $this->t->set_var('title','Hometeaching');
140 $sql = "SELECT * FROM eq_district where valid=1 ORDER BY district ASC";
141 $this->db->query($sql,__LINE__,__FILE__);
143 while ($this->db->next_record())
145 $districts[$i]['district'] = $this->db->f('district');
146 $districts[$i]['name'] = $this->db->f('name');
147 $districts[$i]['supervisor'] = $this->db->f('supervisor');
151 $sql = "SELECT * FROM eq_elder where valid=1 ORDER BY elder ASC";
152 $this->db->query($sql,__LINE__,__FILE__);
154 while ($this->db->next_record())
156 $elder_id[$i] = $this->db->f('elder');
157 $elder_name[$i] = $this->db->f('name');
158 $elder_phone[$elder_id[$i]] = $this->db->f('phone');
161 array_multisort($elder_name, $elder_id);
163 // Make an array mapping elder_ids to elder_names
164 for($i=0; $i < count($elder_id); $i++) {
166 $elders[$id] = $elder_name[$i];
169 $sql = "SELECT * FROM eq_aaronic where valid=1 ORDER BY aaronic ASC";
170 $this->db->query($sql,__LINE__,__FILE__);
171 while ($this->db->next_record())
173 $aaronic_id = $this->db->f('aaronic');
174 $aaronic[$aaronic_id]['name'] = $this->db->f('name');
175 $aaronic[$aaronic_id]['phone'] = $this->db->f('phone');
179 $this->nextmatchs->template_alternate_row_color(&$this->t);
180 for ($i=0; $i < count($districts); $i++) {
181 $this->t->set_var('district_number',$districts[$i]['district']);
182 $this->t->set_var('district_name',$districts[$i]['name']);
183 $supervisor = $districts[$i]['supervisor'];
184 $unique_companionships='';
186 // Select all the unique companionship numbers for this district
187 $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $districts[$i]['district'];
188 $this->db->query($sql,__LINE__,__FILE__);
190 while ($this->db->next_record())
192 $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
196 $comp_width=450; $visit_width=25; $table_width=$comp_width + $num_months*$visit_width;
197 $table_data=""; $num_companionships = 0; $num_families = 0;
198 for($m=$num_months; $m >= 0; $m--) { $visits[$m] = 0; }
199 for ($j=0; $j < count($unique_companionships); $j++) {
200 $companion_table_entry = "";
201 // Select all the companions in each companionship
202 $sql = "SELECT * FROM eq_companionship where valid=1 and ".
203 "companionship=". $unique_companionships[$j]['companionship'];
204 $this->db->query($sql,__LINE__,__FILE__);
206 while ($this->db->next_record())
208 // Get this companions information
209 if($companion_table_entry != "") { $companion_table_entry .= "<td> / </td>"; }
210 $companionship = $this->db->f('companionship');
211 $elder_id = $this->db->f('elder');
212 $aaronic_id = $this->db->f('aaronic');
214 $name = $elders[$elder_id];
215 $phone = $elder_phone[$elder_id];
217 else if($aaronic_id) {
218 $name = $aaronic[$aaronic_id]['name'];
219 $phone = $aaronic[$aaronic_id]['phone'];
221 $companion_table_entry .= "<td title=\"$phone\"><b>$name</b></td>";
223 $table_data.= "<tr bgcolor=#d3dce3><td colspan=20><table><tr>$companion_table_entry</tr></table><hr></td></tr>";
225 // Get the names of the families assigned this home teaching companionship
226 $sql = "SELECT * from eq_family where valid=1 AND companionship=".$unique_companionships[$j]['companionship'];
227 $sql = $sql . " ORDER BY name ASC";
228 $this->db->query($sql,__LINE__,__FILE__);
230 while ($this->db->next_record())
232 $num_families++; $total_families++;
233 $family_name = $this->db->f('name');
234 $family_id = $this->db->f('family');
235 $this->nextmatchs->template_alternate_row_color(&$this->t);
236 $table_data.="<tr bgcolor=". $this->t->get_var('tr_color') ."><td>$family_name Family</td>";
237 // Find out how many times Visits were performed by this companionship
238 // in the past $num_months for this Family
239 $header_row="<th width=$comp_width><font size=-2>Families</th>";
240 for($m=$num_months; $m >= 0; $m--) {
241 $month = $this->current_month - $m;
242 $year = $this->current_year;
243 if($month <= 0) { $remainder = $month; $month = 12 + $remainder; $year=$year-1; }
244 if($month < 10) { $month = "0"."$month"; }
245 $month_start = "$year"."-"."$month"."-"."01";
246 $month_end = "$year"."-"."$month"."-"."31";
247 $month = "$month"."/"."$year";
248 //print "m: $m month: $month year: $year month_start: $month_start month_end: $month_end<br>";
249 // Add this to the query to filter on only visits made by this companionship:
250 // " AND companionship=" . $unique_companionships[$j]['companionship'].
251 $sql = "SELECT * FROM eq_visit WHERE date >= '$month_start' AND date <= '$month_end' ".
252 " AND companionship!=0".
253 " AND family=". $family_id;
254 $this->db2->query($sql,__LINE__,__FILE__);
255 $link_data['menuaction'] = 'eq.eq.ht_update';
256 $link_data['date'] = $month_start;
257 $link_data['month_start'] = $month_start;
258 $link_data['month_end'] = $month_end;
259 $link_data['month'] = $month;
260 $link_data['district'] = $districts[$i]['district'];
261 $link_data['district_name'] = $districts[$i]['name'];
262 $link_data['action'] = 'view';
263 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
264 $header_row .= "<th width=$visit_width><font size=-2><a href=$link>$month</a></th>";
265 if(!$total_visits[$m]) { $total_visits[$m] = 0; }
266 if($this->db2->next_record()) {
267 if($this->db2->f('visited') == 'y') {
268 $visits[$m]++; $total_visits[$m]++;
269 $table_data .= '<td align=center><a href="'.$link.'"><img src="checkmark.gif"></a></td>';
271 else if($this->db2->f('visited') == 'n') {
272 $table_data .= '<td align=center><a href="'.$link.'"><img src="x.gif"></a></td>';
275 $visits[$m]++; $total_visits[$m]++;
276 $table_data .= "<td> </td>";
280 $visits[$m]++; $total_visits[$m]++;
281 $table_data .= "<td> </td>";
284 $table_data .= "</tr>";
287 $table_data .= "<tr><td colspan=20></td></tr>";
289 $table_data .= "<tr><td colspan=20><hr></td></tr>";
290 $stat_data = "<tr><td><b><font size=-2>$num_families Families<br>Visit Totals:</font></b></td>";
292 for($m=$num_months; $m >=0; $m--) {
293 $percent = ceil(($visits[$m] / $num_families)*100);
294 $stat_data .= "<td align=center><font size=-2><b>$visits[$m]<br>$percent%</font></b></td>";
296 $stat_data .= "</tr>";
298 $this->t->set_var('table_width',$table_width);
299 $this->t->set_var('header_row',$header_row);
300 $this->t->set_var('table_data',$table_data);
301 $this->t->set_var('stat_data',$stat_data);
302 $this->t->fp('list','district_list',True);
305 $totals = "<tr><td><b><font size=-2>$total_families Total Families<br>Visit Totals:</font></b></td>";
306 for($m=$num_months; $m >=0; $m--) {
307 $percent = ceil(($total_visits[$m] / $total_families)*100);
308 $totals .= "<td align=center><font size=-2><b>$total_visits[$m]<br>$percent%</font></b></td>";
312 $this->t->set_var('totals',$totals);
314 $this->t->pfp('out','ht_view_t');
315 $this->save_sessiondata();
321 $this->t->set_file(array('ht_update_t' => 'ht_update.tpl'));
322 $this->t->set_block('ht_update_t','district_list','list');
323 $this->t->set_block('ht_update_t','save','savehandle');
325 $district = get_var('district',array('GET','POST'));
326 $district_name = get_var('district_name',array('GET','POST'));
327 $date = get_var('date',array('GET','POST'));
328 $month = get_var('month',array('GET','POST'));
329 $month_start = get_var('month_start',array('GET','POST'));
330 $month_end = get_var('month_end',array('GET','POST'));
331 $action = get_var('action',array('GET','POST'));
333 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ht_view'));
334 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ht_update&action=save'));
335 $this->t->set_var('lang_done','Cancel');
336 $this->t->set_var('district_name',$district_name);
337 $this->t->set_var('district_number',$district);
338 $this->t->set_var('title','Hometeaching Update ' . $month);
339 $this->t->set_var('date',$date);
341 if($action == 'save')
343 // Get a list of all the companionships in this district
344 $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $district;
345 $this->db->query($sql,__LINE__,__FILE__);
347 while ($this->db->next_record())
349 $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
352 for ($j=0; $j < count($unique_companionships); $j++)
354 // FIXME: We won't be able to go back and edit history on families that have been
355 // reassigned to a different companionship. The following delete command will not delete
356 // the history of visits under an older companionship, only the ones for the existing
357 // companionship. This will lead to duplicate visits being entered for an older
358 // month for the same family, making it impossible to change the past history once
359 // a family is reassigned. However, you will be able to view the history just fine.
361 //$comp=$unique_companionships[$j]['companionship'];
362 //print "deleting from eq_visit where companionship=$comp and date=$date and district=$district<br>";
363 // Delete all the visits that have taken place for all families for this month
364 $this->db->query("DELETE from eq_visit where companionship=" . $unique_companionships[$j]['companionship'] .
365 " AND " . "date='" . $date . "'",__LINE__,__FILE__);
368 // Now, add the visits that are checked for this month
369 $new_data = get_var('family_visited',array('POST'));
370 foreach ($new_data as $family)
372 foreach ($family as $data)
374 //print "family_visited: $data <br>";
375 $data_array = explode("/",$data);
376 $family_id = $data_array[0];
377 $companionship = $data_array[1];
378 $date = $data_array[2];
379 $visited = $data_array[3];
380 if($visited == "") { $visited = $data_array[4]; }
381 //print "family_id: $family_id companionship: $companionship date: $date visited: $visited<br>";
382 $this->db->query("INSERT INTO eq_visit (family,companionship,date,notes,visited) "
383 . "VALUES (" . $family_id .",". $companionship .",'". $date ."','','". $visited ."')",__LINE__,__FILE__);
390 $sql = "SELECT * FROM eq_elder where valid=1 ORDER BY elder ASC";
391 $this->db->query($sql,__LINE__,__FILE__);
393 while ($this->db->next_record())
395 $elder_id[$i] = $this->db->f('elder');
396 $elder_name[$i] = $this->db->f('name');
397 $elder_phone[$elder_id[$i]] = $this->db->f('phone');
400 array_multisort($elder_name, $elder_id);
402 // Make an array mapping elder_ids to elder_names
403 for($i=0; $i < count($elder_id); $i++) {
405 $elders[$id] = $elder_name[$i];
408 $sql = "SELECT * FROM eq_aaronic where valid=1 ORDER BY aaronic ASC";
409 $this->db->query($sql,__LINE__,__FILE__);
410 while ($this->db->next_record())
412 $aaronic_id = $this->db->f('aaronic');
413 $aaronic[$aaronic_id]['name'] = $this->db->f('name');
414 $aaronic[$aaronic_id]['phone'] = $this->db->f('phone');
417 // Select all the unique companionship numbers for this district
418 $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $district;
419 $this->db->query($sql,__LINE__,__FILE__);
420 $j=0; $unique_companionships='';
421 while ($this->db->next_record())
423 $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
427 $comp_width=300; $visit_width=25; $table_width=$comp_width + $visit_width;
428 $table_data=""; $num_companionships = 0; $num_families = 0; $visits=0;
429 for ($j=0; $j < count($unique_companionships); $j++) {
430 $companion_table_entry = "";
431 // Select all the companions in each companionship
432 $sql = "SELECT * FROM eq_companionship where valid=1 and ".
433 "companionship=". $unique_companionships[$j]['companionship'];
434 $this->db->query($sql,__LINE__,__FILE__);
436 while ($this->db->next_record())
438 // Get this companions information
439 if($companion_table_entry != "") { $companion_table_entry .= "<td> / </td>"; }
440 $companionship = $this->db->f('companionship');
441 $elder_id = $this->db->f('elder');
442 $aaronic_id = $this->db->f('aaronic');
444 $name = $elders[$elder_id];
445 $phone = $elder_phone[$elder_id];
447 else if($aaronic_id) {
448 $name = $aaronic[$aaronic_id]['name'];
449 $phone = $aaronic[$aaronic_id]['phone'];
451 $companion_table_entry .= "<td title=\"$phone\"><b>$name</b></td>";
453 $table_data.= "<tr bgcolor=#d3dce3><td colspan=20><table><tr>$companion_table_entry</tr></table><hr></td></tr>";
455 // Get the names of the families assigned this home teaching companionship
456 $sql = "SELECT * from eq_family where valid=1 AND companionship=".$unique_companionships[$j]['companionship'];
457 $sql = $sql . " ORDER BY name ASC";
458 $this->db->query($sql,__LINE__,__FILE__);
459 while ($this->db->next_record())
461 $num_families++; $total_families++;
462 $family_name = $this->db->f('name');
463 $family_id = $this->db->f('family');
464 $this->nextmatchs->template_alternate_row_color(&$this->t);
465 $table_data.="<tr bgcolor=". $this->t->get_var('tr_color') ."><td>$family_name Family</td>";
467 $header_row="<th width=$comp_width><font size=-2>Families</th>";
468 $sql = "SELECT * FROM eq_visit WHERE date >= '$month_start' AND date <= '$month_end' ".
469 " AND companionship!=0".
470 " AND family=". $family_id;
471 $this->db2->query($sql,__LINE__,__FILE__);
472 $value = $family_id . "/" . $unique_companionships[$j]['companionship'] . "/" . $date;
473 $header_row .= "<th width=$visit_width><font size=-2><a href=$link>$month</a></th>";
474 if(!$total_visits) { $total_visits = 0; }
475 if($this->db2->next_record()) {
476 if($this->db2->f('visited') == 'y') {
477 $visits++; $total_visits++;
478 $table_data .= '<td width=100 align=center>';
479 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/y" checked>Y';
480 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/n">N';
481 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/"> ';
482 $table_data .= '</td>';
483 } else if($this->db2->f('visited') == 'n') {
484 $table_data .= '<td width=100 align=center>';
485 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/y">Y';
486 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/n" checked>N';
487 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/">';
488 $table_data .= '</td>';
490 $table_data .= '<td width=100 align=center>';
491 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/y">Y';
492 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/n">N';
493 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/" checked> ';
494 $table_data .= '</td>';
499 $table_data .= '<td width=100 align=center>';
500 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/y">Y';
501 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/n">N';
502 $table_data .= '<input type="radio" name="family_visited['.$family_id.'][]" value="'.$value.'/" checked> ';
503 $table_data .= '</td>';
506 $table_data .= "</tr>";
507 $table_data .= "<tr><td colspan=20></td></tr>";
509 $table_data .= "<tr><td colspan=20><hr></td></tr>";
510 $stat_data = "<tr><td><b><font size=-2>$num_families Families<br>Visit Totals:</font></b></td>";
512 $percent = ceil(($visits / $num_families)*100);
513 $stat_data .= "<td align=center><font size=-2><b>$visits<br>$percent%</font></b></td>";
514 $stat_data .= "</tr>";
516 $this->t->set_var('table_width',$table_width);
517 $this->t->set_var('header_row',$header_row);
518 $this->t->set_var('table_data',$table_data);
519 $this->t->set_var('stat_data',$stat_data);
520 $this->t->fp('list','district_list',True);
522 $this->t->set_var('lang_reset','Clear Form');
523 $this->t->set_var('lang_save','Save Changes');
524 $this->t->set_var('savehandle','');
526 $this->t->pfp('out','ht_update_t');
527 $this->t->pfp('addhandle','save');
529 $this->save_sessiondata();
534 $this->t->set_file(array('act_list_t' => 'act_list.tpl'));
535 $this->t->set_block('act_list_t','act_list','list');
537 $this->t->set_var('lang_name','Activity Name');
538 $this->t->set_var('lang_date','Date');
540 $sql = "SELECT * FROM eq_activity ORDER BY date DESC";
541 $this->db->query($sql,__LINE__,__FILE__);
542 $total_records = $this->db->num_rows();
545 while ($this->db->next_record())
547 $activity_list[$i]['name'] = $this->db->f('name');
548 $activity_list[$i]['date'] = $this->db->f('date');
549 $activity_list[$i]['activity'] = $this->db->f('activity');
553 for ($i=0; $i < count($activity_list); $i++)
555 $this->nextmatchs->template_alternate_row_color(&$this->t);
556 $this->t->set_var('name',$activity_list[$i]['name']);
557 $this->t->set_var('date',$activity_list[$i]['date']);
559 $link_data['menuaction'] = 'eq.eq.act_view';
560 $link_data['activity'] = $activity_list[$i]['activity'];
561 $link_data['action'] = 'view';
562 $this->t->set_var('view',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
563 $this->t->set_var('lang_view','View');
565 $link_data['menuaction'] = 'eq.eq.act_update';
566 $link_data['activity'] = $activity_list[$i]['activity'];
567 $link_data['action'] = 'edit';
568 $this->t->set_var('edit',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
569 $this->t->set_var('lang_edit','Edit');
571 $link_data['menuaction'] = 'eq.eq.act_update';
572 $link_data['activity'] = '0';
573 $link_data['action'] = 'add';
574 $this->t->set_var('add','<form method="POST" action="' . $GLOBALS['phpgw']->link('/eq/index.php',$link_data)
575 . '"><input type="submit" name="Add" value="' . 'Add Activity' .'"></font></form>');
577 $this->t->fp('list','act_list',True);
580 $this->t->pfp('out','act_list_t');
581 $this->save_sessiondata();
586 $this->t->set_file(array('act_view_t' => 'act_view.tpl'));
587 $this->t->set_block('act_view_t','part_list','list');
589 $sql = "SELECT * FROM eq_activity WHERE activity=" . intval(get_var('activity',array('GET','POST')));
590 $this->db->query($sql,__LINE__,__FILE__);
591 $this->db->next_record();
592 $this->t->set_var('name', $this->db->f('name'));
593 $this->t->set_var('date', $this->db->f('date'));
594 $this->t->set_var('notes', $this->db->f('notes'));
596 $this->t->set_var('lang_name','Activity Name');
597 $this->t->set_var('lang_date','Date');
598 $this->t->set_var('lang_notes','Notes');
599 $this->t->set_var('lang_done','Done');
600 $this->t->set_var('lang_action','View');
602 $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
603 $this->t->set_var('tr_color',$tr_color);
605 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.act_list'));
607 $link_data['menuaction'] = 'eq.eq.act_update';
608 $link_data['activity'] = get_var('activity',array('GET','POST'));
609 $link_data['action'] = 'edit';
610 $this->t->set_var('edit',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
611 $this->t->set_var('lang_edit','Edit');
612 $this->t->set_var('cal_date',$this->db->f('date'));
614 // Now find out which elders participated in this activity
615 $sql = "SELECT * FROM eq_participation WHERE activity=" . intval(get_var('activity',array('GET','POST')));
616 $this->db->query($sql,__LINE__,__FILE__);
617 $total_records = $this->db->num_rows();
620 while ($this->db->next_record())
622 $part_list[$i]['elder'] = $this->db->f('elder');
626 for ($i=0; $i < count($part_list); $i++)
628 $sql = "SELECT * FROM eq_elder WHERE elder=" . $part_list[$i]['elder'];
629 $this->db->query($sql,__LINE__,__FILE__);
630 $this->db->next_record();
631 $names[$i] = $this->db->f('name');
634 for ($i=0; $i < count($names); $i++)
636 //$this->nextmatchs->template_alternate_row_color(&$this->t);
637 $this->t->set_var('elder_name',$names[$i]);
638 if(($i+1) % 3 == 0) { $this->t->set_var('table_sep',"</td></tr><tr>"); }
639 else { $this->t->set_var('table_sep',"</td>"); }
640 if(($i) % 3 == 0) { $this->nextmatchs->template_alternate_row_color(&$this->t); }
641 $this->t->fp('list','part_list',True);
644 $this->t->pfp('out','act_view_t');
645 $this->save_sessiondata();
648 function act_update()
650 $this->t->set_file(array('form' => 'act_update.tpl'));
651 $this->t->set_block('form','elder_list','list');
652 $this->t->set_block('form','add','addhandle');
653 $this->t->set_block('form','edit','edithandle');
654 $this->t->set_var('lang_done','Done');
656 $action = get_var('action',array('GET','POST'));
657 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.act_list'));
658 $activity['activity'] = intval(get_var('activity',array('GET','POST')));
660 if($action == 'save')
662 $activity['name'] = $this->db->db_addslashes(get_var('name',array('POST')));
663 $activity['date'] = $this->db->db_addslashes(get_var('date',array('POST')));
664 $activity['notes']= $this->db->db_addslashes(get_var('notes',array('POST')));
665 $this->db->query("UPDATE eq_activity set " .
666 " name='" . $activity['name'] .
667 "', date='" . $activity['date'] . "'" .
668 ", notes='" . $activity['notes'] . "'" .
669 " WHERE activity=" . $activity['activity'],__LINE__,__FILE__);
671 // Delete all the elders who have particiapted in this activity
672 $this->db->query("DELETE from eq_participation where activity=".$activity['activity'],__LINE__,__FILE__);
674 // Re-add the elders who are checked as having participated in this activity
675 $elders = get_var('elder_name',array('POST'));
676 foreach ($elders as $elder)
678 $this->db->query("INSERT INTO eq_participation (elder,activity) "
679 . "VALUES (" . $elder . ",". $activity['activity'] . ")",__LINE__,__FILE__);
686 if($action == 'insert')
688 $activity['name'] = $this->db->db_addslashes(get_var('name',array('POST')));
689 $activity['date'] = $this->db->db_addslashes(get_var('date',array('POST')));
690 $activity['notes']= $this->db->db_addslashes(get_var('notes',array('POST')));
691 $this->db->query("INSERT INTO eq_activity (name,date,notes) "
692 . "VALUES ('" . $activity['name'] . "','"
693 . $activity['date'] . "','" . $activity['notes'] . "')",__LINE__,__FILE__);
700 $activity['activity'] = 0;
701 $this->t->set_var('cal_date',$this->jscal->input('date','','','','','','',$this->cal_options));
702 $this->t->set_var('name','');
703 $this->t->set_var('date','');
704 $this->t->set_var('notes','');
705 $this->t->set_var('lang_done','Cancel');
706 $this->t->set_var('lang_action','Adding New Activity');
707 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.act_update&activity='
708 . $activity['activity'] . '&action=' . 'insert'));
711 if($action == 'edit')
713 $sql = "SELECT * FROM eq_activity WHERE activity=" . $activity['activity'];
714 $this->db->query($sql,__LINE__,__FILE__);
715 $this->db->next_record();
716 $this->t->set_var('cal_date',$this->jscal->input('date',$this->db->f('date'),'','','','','',$this->cal_options));
717 $this->t->set_var('name', $this->db->f('name'));
718 $this->t->set_var('date', $this->db->f('date'));
719 $this->t->set_var('notes', $this->db->f('notes'));
720 $this->t->set_var('lang_done','Cancel');
721 $this->t->set_var('lang_action','Editing Activity');
722 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.act_update&activity='
723 . $activity['activity'] . '&action=' . 'save'));
727 $sql = "SELECT * FROM eq_elder";
728 $this->db->query($sql,__LINE__,__FILE__);
730 while ($this->db->next_record())
732 if($this->db->f('valid') == 1 || $action != 'add') {
733 $elder_name[$i] = $this->db->f('name');
734 $elder_id[$i] = $this->db->f('elder');
735 $elder_valid[$i] = $this->db->f('valid');
739 array_multisort($elder_name, $elder_id, $elder_valid);
742 for ($i=0; $i < count($elder_id); $i++)
744 //$this->nextmatchs->template_alternate_row_color(&$this->t);
745 $sql = "SELECT * FROM eq_participation where activity=". $activity['activity'] . " AND elder=" . $elder_id[$i];
746 $this->db->query($sql,__LINE__,__FILE__);
747 if($this->db->next_record()) { $this->t->set_var('checked','checked'); $checked=1; }
748 else { $this->t->set_var('checked',''); $checked=0; }
749 if($checked || $elder_valid[$i] == 1) {
750 $this->t->set_var('elder_name',$elder_name[$i]);
751 $this->t->set_var('elder',$elder_id[$i]);
752 if(($j+1) % 3 == 0) { $this->t->set_var('table_sep',"</td></tr><tr>"); }
753 else { $this->t->set_var('table_sep',"</td>"); }
754 if(($j) % 3 == 0) { $this->nextmatchs->template_alternate_row_color(&$this->t); }
755 $this->t->fp('list','elder_list',True);
760 $this->t->set_var('lang_reset','Clear Form');
761 $this->t->set_var('lang_add','Add Activity');
762 $this->t->set_var('lang_save','Save Changes');
763 $this->t->set_var('edithandle','');
764 $this->t->set_var('addhandle','');
766 $this->t->pfp('out','form');
767 if($action == 'edit') { $this->t->pfp('addhandle','edit'); }
768 if($action == 'add') { $this->t->pfp('addhandle','add'); }
770 $this->save_sessiondata();
775 $this->t->set_file(array('par_view_t' => 'par_view.tpl'));
776 $this->t->set_block('par_view_t','header_list','list1');
777 $this->t->set_block('par_view_t','elder_list','list2');
779 $sql = "SELECT * FROM eq_elder where valid=1";
780 $this->db->query($sql,__LINE__,__FILE__);
782 while ($this->db->next_record())
784 $elder_name[$i] = $this->db->f('name');
785 $elder_id[$i] = $this->db->f('elder');
788 array_multisort($elder_name, $elder_id);
790 $sql = "SELECT * FROM eq_activity ORDER BY date DESC";
791 $this->db->query($sql,__LINE__,__FILE__);
792 $total_records = $this->db->num_rows();
795 while ($this->db->next_record())
797 $activity_list[$i]['name'] = $this->db->f('name');
798 $activity_list[$i]['date'] = $this->db->f('date');
799 $activity_list[$i]['activity'] = $this->db->f('activity');
800 if($activity_list[$i]['date'] == '0000-00-00') { $activity_list[$i]['date']=""; }
804 $elder_width=250; $part_width=25; $act_width=50;
805 $total_width=$elder_width+$part_width;
806 for ($i=0; $i < count($activity_list); $i++) {
807 $this->t->set_var('activity_name',$activity_list[$i]['name']);
808 $this->t->set_var('activity_date',$activity_list[$i]['date']);
809 $this->t->fp('list1','header_list',True);
810 $total_width += $act_width;
813 for ($i=0; $i < count($elder_id); $i++) {
814 $participated=0; $part_table = '';
815 $this->nextmatchs->template_alternate_row_color(&$this->t);
816 $this->t->set_var('elder_name',$elder_name[$i]);
817 for ($j=0; $j < count($activity_list); $j++) {
818 $sql = "SELECT * FROM eq_participation where activity="
819 . $activity_list[$j]['activity'] . " AND elder=" . $elder_id[$i];
820 $this->db->query($sql,__LINE__,__FILE__);
821 if($this->db->next_record()) {
822 $part_table .= '<td align=center><img src="checkmark.gif"></td>';
825 $part_table .= '<td> </td>';
828 if($participated) { $part_table .= '<td align=center><img src="checkmark.gif">'.$participated.'</td>'; }
829 else { $part_table .= '<td> </td>'; }
830 $this->t->set_var('part_table',$part_table);
831 $this->t->fp('list2','elder_list',True);
833 $this->t->set_var('total_width',$total_width);
834 $this->t->set_var('elder_width',$elder_width);
835 $this->t->set_var('part_width',$part_width);
836 $this->t->set_var('act_width',$act_width);
837 $this->t->pfp('out','par_view_t');
838 $this->save_sessiondata();
843 $this->t->set_file(array('ppi_view_t' => 'ppi_view.tpl'));
844 $this->t->set_block('ppi_view_t','district_list','list');
846 $this->t->set_var('linkurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view'));
847 $num_months = get_var('num_months',array('GET','POST'));
848 if($num_months == '') { $num_months = $this->default_ppi_num_months; }
849 $this->t->set_var('num_months',$num_months);
850 if($num_months == 1) { $this->t->set_var('lang_num_months','Month of History'); }
851 else { $this->t->set_var('lang_num_months','Months of History'); }
852 $this->t->set_var('lang_filter','Filter');
854 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view'));
855 $this->t->set_var('eqpres_ppi_link',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view&eqpresppi=1'));
856 $eqpresppi = get_var('eqpresppi',array('GET','POST'));
858 if($eqpresppi == 1) {
859 $num_months = get_var('num_months',array('GET','POST'));
860 if($num_months == '') { $num_months = $this->default_ppi_num_years; }
861 $this->t->set_var('num_months',$num_months);
862 $this->t->set_var('ppi_link_title','PPIs');
863 $this->t->set_var('title','EQ President Yearly PPIs');
864 if($num_months == 1) { $this->t->set_var('lang_num_months','Year of History'); }
865 else { $this->t->set_var('lang_num_months','Years of History'); }
866 $this->t->set_var('eqpres_ppi_link',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view'));
869 $this->t->set_var('ppi_link_title','EQ President Yearly PPIs');
870 $this->t->set_var('title','PPIs');
873 $sql = "SELECT * FROM eq_district where valid=1 ORDER BY district ASC";
874 $this->db->query($sql,__LINE__,__FILE__);
876 while ($this->db->next_record())
878 $districts[$i]['district'] = $this->db->f('district');
879 $districts[$i]['name'] = $this->db->f('name');
880 $districts[$i]['supervisor'] = $this->db->f('supervisor');
881 if($eqpresppi == 0) { $i++; }
884 $sql = "SELECT * FROM eq_elder where valid=1 ORDER BY elder ASC";
885 $this->db->query($sql,__LINE__,__FILE__);
887 while ($this->db->next_record())
889 $elder_id[$i] = $this->db->f('elder');
890 $elder_name[$i] = $this->db->f('name');
891 $elder_phone[$elder_id[$i]] = $this->db->f('phone');
894 array_multisort($elder_name, $elder_id);
895 for($i=0; $i < count($elder_id); $i++) {
897 $elders[$id] = $elder_name[$i];
900 $sql = "SELECT * FROM eq_aaronic where valid=1 ORDER BY aaronic ASC";
901 $this->db->query($sql,__LINE__,__FILE__);
902 while ($this->db->next_record())
904 $aaronic_id = $this->db->f('aaronic');
905 $aaronic[$aaronic_id]['name'] = $this->db->f('name');
906 $aaronic[$aaronic_id]['phone'] = $this->db->f('phone');
909 $total_companionships = 0;
910 $this->nextmatchs->template_alternate_row_color(&$this->t);
911 for ($i=0; $i < count($districts); $i++) {
912 if($eqpresppi == 1) {
913 $this->t->set_var('district_number','*');
914 $this->t->set_var('district_name','EQ President');
916 $this->t->set_var('district_number',$districts[$i]['district']);
917 $this->t->set_var('district_name',$districts[$i]['name']);
919 $supervisor = $districts[$i]['supervisor'];
920 $unique_companionships='';
922 // Select all the unique companionship numbers for this district
923 if($eqpresppi == 1) {
924 $sql = "SELECT distinct companionship FROM eq_companionship where valid=1";
927 $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $districts[$i]['district'];
929 $this->db->query($sql,__LINE__,__FILE__);
931 while ($this->db->next_record())
933 $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
937 $comp_width=400; $ppi_width=25; $table_width=$comp_width + $num_months*$ppi_width;
938 $table_data=""; $num_companionships = $j; $num_elders = 0;
939 for($m=$num_months; $m >= 0; $m--) { $ppis[$m] = 0; }
940 for ($j=0; $j < count($unique_companionships); $j++) {
941 // Select all the companions in each companionship
943 $sql = "SELECT * FROM eq_companionship where valid=1 and aaronic=0 and ".
944 "companionship=". $unique_companionships[$j]['companionship'];
947 $sql = "SELECT * FROM eq_companionship where valid=1 and ".
948 "companionship=". $unique_companionships[$j]['companionship'];
950 $this->db->query($sql,__LINE__,__FILE__);
952 $comp = $unique_companionships[$j]['companionship'];
953 for($m=$num_months; $m >= 0; $m--) { $ppi_recorded[$comp][$m] = 0; }
954 while ($this->db->next_record())
956 // Get this companions information
958 $companionship = $this->db->f('companionship');
959 $elder_id = $this->db->f('elder');
960 $aaronic_id = $this->db->f('aaronic');
962 $name = $elders[$elder_id];
963 $phone = $elder_phone[$elder_id];
965 else if($aaronic_id) {
966 $name = $aaronic[$aaronic_id]['name'];
967 $phone = $aaronic[$aaronic_id]['phone'];
969 $link_data['menuaction'] = 'eq.eq.ppi_update';
970 $link_data['companionship'] = $companionship;
971 $link_data['interviewer'] = $supervisor;
972 $link_data['elder'] = $elder_id;
973 $link_data['aaronic'] = $aaronic_id;
974 $link_data['name'] = $name;
975 $link_data['ppi'] = '';
976 $link_data['eqpresppi'] = $eqpresppi;
977 $link_data['action'] = 'add';
978 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
979 $table_data.= "<tr bgcolor=". $this->t->get_var('tr_color') ."><td title=\"$phone\"><a href=$link>$name</a></td>";
981 // Find out how many times PPIs were performed in the past $num_months for this Elder
982 $header_row="<th width=$comp_width><font size=-2>Companionship</th>";
983 for($m=$num_months; $m >= 0; $m--) {
984 if($eqpresppi == 1) {
985 $year = date('Y') - $m;
986 $year_start = $year - 1 . "-12-31"; $year_end = $year + 1 . "-01-01";
987 $sql = "SELECT * FROM eq_ppi WHERE date > '$year_start' AND date < '$year_end' ".
988 "AND elder=" . $elder_id . " AND aaronic=" . $aaronic_id . " AND eqpresppi=1";
989 $this->db2->query($sql,__LINE__,__FILE__);
990 $header_row .= "<th width=150><font size=-2>$year</th>";
993 $month = $this->current_month - $m;
994 $year = $this->current_year;
995 if($month <= 0) { $remainder = $month; $month = 12 + $remainder; $year=$year-1; }
996 if($month < 10) { $month = "0"."$month"; }
997 $month_start = "$year"."-"."$month"."-"."01";
998 $month_end = "$year"."-"."$month"."-"."31";
999 $month = "$month"."/"."$year";
1000 $sql = "SELECT * FROM eq_ppi WHERE date >= '$month_start' AND date <= '$month_end' ".
1001 "AND elder=" . $elder_id . " AND aaronic=" . $aaronic_id . " AND eqpresppi=0";
1002 $this->db2->query($sql,__LINE__,__FILE__);
1003 $header_row .= "<th width=$ppi_width><font size=-2>$month</th>";
1005 if(!$total_ppis[$m]) { $total_ppis[$m] = 0; }
1006 if($this->db2->next_record()) {
1007 if(!$ppi_recorded[$companionship][$m]) {
1008 $ppis[$m]++; $total_ppis[$m]++; $ppi_recorded[$companionship][$m]=1;
1010 $link_data['menuaction'] = 'eq.eq.ppi_update';
1011 $link_data['companionship'] = $companionship;
1012 $link_data['interviewer'] = $this->db2->f('interviewer');
1013 $link_data['elder'] = $elder_id;
1014 $link_data['aaronic'] = $aaronic_id;
1015 $link_data['name'] = $name;
1016 $link_data['ppi'] = $this->db2->f('ppi');
1017 $link_data['eqpresppi'] = $eqpresppi;
1018 $link_data['action'] = 'view';
1019 $date = $this->db2->f('date');
1020 $date_array = explode("-",$date);
1021 $month = $date_array[1];
1022 $day = $date_array[2];
1023 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
1024 $table_data .= '<td align=center><a href='.$link.'><img src="checkmark.gif"><br>'.$month.'-'.$day.'</a></td>';
1026 else { $table_data .= "<td> </td>"; }
1028 $table_data .= "</tr>";
1031 $table_data .= "<tr><td colspan=20><hr></td></tr>";
1033 // Now add Elders not assigned to any companionship to the table if we are in eqpresppi mode
1034 if($eqpresppi == 1) {
1035 $table_data .= "<tr bgcolor=\"#c9c9c9\"><hr><td colspan=20><b>Unassigned Potential Home Teachers</b><hr></td></tr>";
1036 foreach($elders as $elder_id => $value) {
1037 $sql = "SELECT * FROM eq_companionship where valid=1 and elder=".$elder_id;
1038 $this->db->query($sql,__LINE__,__FILE__);
1039 if(!$this->db->next_record()) {
1040 // We found an Elder not in a companionship, add them to the table
1043 $name = $elders[$elder_id];
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'] = '';
1050 $link_data['eqpresppi'] = $eqpresppi;
1051 $link_data['action'] = 'add';
1052 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
1053 $table_data.= "<tr bgcolor=". $this->t->get_var('tr_color') ."><td><a href=$link>$name</a></td>";
1054 for($m=$num_months; $m >= 0; $m--) {
1055 $year = date('Y') - $m;
1056 $year_start = $year - 1 . "-12-31"; $year_end = $year + 1 . "-01-01";
1057 $sql = "SELECT * FROM eq_ppi WHERE date > '$year_start' AND date < '$year_end' ".
1058 "AND elder=" . $elder_id . " AND eqpresppi=1";
1059 $this->db2->query($sql,__LINE__,__FILE__);
1060 if(!$total_ppis[$m]) { $total_ppis[$m] = 0; }
1061 if($this->db2->next_record()) {
1062 $ppis[$m]++; $total_ppis[$m]++;
1063 $link_data['menuaction'] = 'eq.eq.ppi_update';
1064 $link_data['companionship'] = $companionship;
1065 $link_data['interviewer'] = $supervisor;
1066 $link_data['elder'] = $elder_id;
1067 $link_data['name'] = $name;
1068 $link_data['ppi'] = $this->db2->f('ppi');
1069 $link_data['eqpresppi'] = $eqpresppi;
1070 $link_data['action'] = 'view';
1071 $date = $this->db2->f('date');
1072 $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
1073 $table_data .= '<td align=center><a href='.$link.'><img src="checkmark.gif"><br>'.$date.'</a></td>';
1075 else { $table_data .= "<td> </td>"; }
1077 $table_data .= "</tr>";
1081 $total_companionships += $num_companionships;
1082 if($eqpresppi == 1) {
1083 $stat_data = "<tr><td><b><font size=-2>$num_elders Elders<br>PPI Totals:</font></b></td>";
1085 $stat_data = "<tr><td><b><font size=-2>$num_companionships Companionships<br>PPI Totals:</font></b></td>";
1087 for($m=$num_months; $m >=0; $m--) {
1088 if($eqpresppi == 1) { $percent = ceil(($ppis[$m] / $num_elders)*100); }
1089 else { $percent = ceil(($ppis[$m] / $num_companionships)*100); }
1090 $stat_data .= "<td align=center><font size=-2><b>$ppis[$m]<br>$percent%</font></b></td>";
1092 $stat_data .= "</tr>";
1094 $this->t->set_var('table_width',$table_width);
1095 $this->t->set_var('header_row',$header_row);
1096 $this->t->set_var('table_data',$table_data);
1097 $this->t->set_var('stat_data',$stat_data);
1098 $this->t->fp('list','district_list',True);
1101 $totals = "<tr><td><b><font size=-2>$total_companionships Total Comps<br>PPI Totals:</font></b></td>";
1102 for($m=$num_months; $m >=0; $m--) {
1103 $percent = ceil(($total_ppis[$m] / $total_companionships)*100);
1104 $totals .= "<td align=center><font size=-2><b>$total_ppis[$m]<br>$percent%</font></b></td>";
1108 $this->t->set_var('totals',$totals);
1109 $this->t->pfp('out','ppi_view_t');
1110 $this->save_sessiondata();
1113 function ppi_update()
1115 $this->t->set_file(array('form' => 'ppi_update.tpl'));
1116 $this->t->set_block('form','interviewer_list','int_list');
1117 $this->t->set_block('form','add','addhandle');
1118 $this->t->set_block('form','edit','edithandle');
1120 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_view'));
1121 $this->t->set_var('readonly','');
1122 $this->t->set_var('disabled','');
1124 $action = get_var('action',array('GET','POST'));
1125 $companionship = get_var('companionship',array('GET','POST'));
1126 $interviewer = get_var('interviewer',array('GET','POST'));
1127 $name = get_var('name',array('GET','POST'));
1128 $ppi = get_var('ppi',array('GET','POST'));
1129 $elder = get_var('elder',array('GET','POST'));
1130 $aaronic = get_var('aaronic',array('GET','POST'));
1131 $date = get_var('date',array('GET','POST'));
1132 $notes = get_var('notes',array('GET','POST'));
1133 $eqpresppi = get_var('eqpresppi',array('GET','POST'));
1135 $sql = "SELECT * FROM eq_district where valid=1 ORDER BY district ASC";
1136 $this->db->query($sql,__LINE__,__FILE__);
1137 while ($this->db->next_record())
1139 $supervisor = $this->db->f('supervisor');
1140 $sql = "SELECT * FROM eq_elder WHERE elder=" . $supervisor;
1141 $this->db2->query($sql,__LINE__,__FILE__);
1142 $this->db2->next_record();
1143 $interviewer_name = $this->db2->f('name');
1145 if($supervisor == $interviewer) {
1146 $this->t->set_var('interviewer',$supervisor . ' selected');
1148 $this->t->set_var('interviewer',$interviewer);
1150 $this->t->set_var('interviewer_name',$interviewer_name);
1151 $this->t->fp('int_list','interviewer_list',True);
1154 if($action == 'save')
1156 $notes = $this->db->db_addslashes(get_var('notes',array('POST')));
1157 $this->db->query("UPDATE eq_ppi set " .
1158 " ppi='" . $ppi . "'" .
1159 ", interviewer='" . $interviewer . "'" .
1160 ", elder='" . $elder . "'" .
1161 ", aaronic='" . $aaronic . "'" .
1162 ", date='" . $date . "'" .
1163 ", notes='" . $notes . "'" .
1164 ", eqpresppi='" . $eqpresppi . "'" .
1165 " WHERE ppi=" . $ppi,__LINE__,__FILE__);
1170 if($action == 'insert')
1172 $notes = $this->db->db_addslashes(get_var('notes',array('POST')));
1173 $this->db->query("INSERT INTO eq_ppi (interviewer,elder,aaronic,date,notes,eqpresppi) "
1174 . "VALUES ('" . $interviewer . "','" . $elder . "','" . $aaronic . "','"
1175 . $date . "','" . $notes . "','" . $eqpresppi ."')",__LINE__,__FILE__);
1180 if($action == 'add')
1182 $this->t->set_var('cal_date',$this->jscal->input('date','','','','','','',$this->cal_options));
1183 $this->t->set_var('ppi', '');
1184 $this->t->set_var('interviewer', $interviewer);
1185 $this->t->set_var('name',$name);
1186 $this->t->set_var('elder',$elder);
1187 $this->t->set_var('aaronic',$aaronic);
1188 $this->t->set_var('date','');
1189 $this->t->set_var('notes','');
1190 $this->t->set_var('eqpresppi',$eqpresppi);
1191 $this->t->set_var('lang_done','Cancel');
1192 $this->t->set_var('lang_action','Adding New PPI');
1193 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_update&ppi='
1194 . $ppi . '&action=' . 'insert'));
1197 if($action == 'edit' || $action == 'view')
1199 $sql = "SELECT * FROM eq_ppi WHERE ppi=".$ppi;
1200 $this->db->query($sql,__LINE__,__FILE__);
1201 $this->db->next_record();
1202 $this->t->set_var('ppi',$ppi);
1203 $this->t->set_var('name',$name);
1204 $this->t->set_var('interviewer', $this->db->f('interviewer'));
1205 $this->t->set_var('elder',$this->db->f('elder'));
1206 $this->t->set_var('aaronic',$this->db->f('aaronic'));
1207 $this->t->set_var('date',$this->db->f('date'));
1208 $this->t->set_var('notes',$this->db->f('notes'));
1209 $this->t->set_var('eqpresppi',$this->db->f('eqpresppi'));
1212 if($action == 'edit')
1214 $this->t->set_var('cal_date',$this->jscal->input('date',$date,'','','','','',$this->cal_options));
1215 $this->t->set_var('lang_done','Cancel');
1216 $this->t->set_var('lang_action','Editing PPI');
1217 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_update&ppi='
1218 . $ppi . '&action=' . 'save'));
1221 if($action == 'view')
1223 $date = $this->db->f('date');
1224 $this->t->set_var('cal_date','<input type=text size="10" maxlength="10" name="date" value="'.$date.'" readonly>');
1225 $this->t->set_var('readonly','READONLY');
1226 $this->t->set_var('disabled','DISABLED');
1227 $this->t->set_var('lang_done','Done');
1228 $this->t->set_var('lang_action','Viewing PPI');
1229 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_update&ppi='
1230 . $ppi . '&action=' . 'edit'));
1233 $this->t->set_var('lang_reset','Clear Form');
1234 $this->t->set_var('lang_add','Add PPI');
1235 $this->t->set_var('lang_save','Save Changes');
1236 $this->t->set_var('edithandle','');
1237 $this->t->set_var('addhandle','');
1239 $this->t->pfp('out','form');
1241 if($action == 'view') { $this->t->set_var('lang_save','Edit PPI'); }
1242 if($action == 'edit' || $action == 'view') { $this->t->pfp('addhandle','edit'); }
1243 if($action == 'add') { $this->t->pfp('addhandle','add'); }
1245 $this->save_sessiondata();
1250 $this->t->set_file(array('vis_view_t' => 'vis_view.tpl'));
1251 $this->t->set_block('vis_view_t','visit_list','list1');
1252 $this->t->set_block('vis_view_t','family_list','list2');
1254 $this->t->set_var('lang_name','Family Name');
1255 $this->t->set_var('lang_date','Date');
1257 $sql = "SELECT * FROM eq_visit WHERE companionship=0 ORDER BY date DESC";
1258 $this->db->query($sql,__LINE__,__FILE__);
1259 $total_records = $this->db->num_rows();
1262 while ($this->db->next_record())
1264 $visit_list[$i]['visit'] = $this->db->f('visit');
1265 $visit_list[$i]['family'] = $this->db->f('family');
1266 $visit_list[$i]['date'] = $this->db->f('date');
1270 for ($i=0; $i < count($visit_list); $i++)
1272 $this->nextmatchs->template_alternate_row_color(&$this->t);
1274 $sql = "SELECT * FROM eq_family WHERE family=".$visit_list[$i]['family'];
1275 $this->db->query($sql,__LINE__,__FILE__);
1276 $this->db->next_record();
1278 $this->t->set_var('family',$visit_list[$i]['family']);
1279 $this->t->set_var('family_name',$this->db->f('name'));
1280 $this->t->set_var('date',$visit_list[$i]['date']);
1282 $link_data['menuaction'] = 'eq.eq.vis_update';
1283 $link_data['visit'] = $visit_list[$i]['visit'];
1284 $link_data['name'] = $this->db->f('name');
1285 $link_data['date'] = $visit_list[$i]['date'];
1286 $link_data['action'] = 'view';
1287 $this->t->set_var('view',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1288 $this->t->set_var('lang_view','View');
1290 $link_data['menuaction'] = 'eq.eq.vis_update';
1291 $link_data['visit'] = $visit_list[$i]['visit'];
1292 $link_data['name'] = $this->db->f('name');
1293 $link_data['date'] = $visit_list[$i]['date'];
1294 $link_data['action'] = 'edit';
1295 $this->t->set_var('edit',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1296 $this->t->set_var('lang_edit','Edit');
1298 $this->t->fp('list1','visit_list',True);
1301 // List the families that are available to record a visit against
1302 $sql = "SELECT * FROM eq_family WHERE valid=1";
1303 $this->db->query($sql,__LINE__,__FILE__);
1304 $total_records = $this->db->num_rows();
1307 while ($this->db->next_record())
1309 $family_names[$i] = $this->db->f('name');
1310 $family_ids[$i] = $this->db->f('family');
1312 } array_multisort($family_names, $family_ids);
1314 for ($i=0; $i < count($family_names); $i++)
1316 $link_data['menuaction'] = 'eq.eq.vis_update';
1317 $link_data['visit'] = '';
1318 $link_data['family'] = $family_ids[$i];
1319 $link_data['action'] = 'add';
1320 $link_data['name'] = $family_names[$i];
1321 $this->t->set_var('add',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1323 $this->t->set_var('name',$family_names[$i]);
1324 if(($i+1) % 3 == 0) { $this->t->set_var('table_sep',"</td></tr><tr>"); }
1325 else { $this->t->set_var('table_sep',"</td>"); }
1326 if(($i) % 3 == 0) { $this->nextmatchs->template_alternate_row_color(&$this->t); }
1328 $this->t->fp('list2','family_list',True);
1331 $this->t->pfp('out','vis_view_t');
1332 $this->save_sessiondata();
1335 function vis_update()
1337 $this->t->set_file(array('form' => 'vis_update.tpl'));
1338 $this->t->set_block('form','add','addhandle');
1339 $this->t->set_block('form','edit','edithandle');
1341 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.vis_view'));
1342 $this->t->set_var('readonly','');
1343 $this->t->set_var('disabled','');
1345 $action = get_var('action',array('GET','POST'));
1346 $visit = get_var('visit',array('GET','POST'));
1347 $family = get_var('family',array('GET','POST'));
1348 $name = get_var('name',array('GET','POST'));
1349 $date = get_var('date',array('GET','POST'));
1350 $notes = get_var('notes',array('GET','POST'));
1353 if($action == 'save')
1355 $notes = $this->db->db_addslashes(get_var('notes',array('POST')));
1356 $this->db->query("UPDATE eq_visit set " .
1357 " date='" . $date . "'" .
1358 ", notes='" . $notes . "'" .
1359 " WHERE visit=" . $visit,__LINE__,__FILE__);
1364 if($action == 'insert')
1366 $notes = $this->db->db_addslashes(get_var('notes',array('POST')));
1367 $this->db->query("INSERT INTO eq_visit (family,companionship,date,notes) "
1368 . "VALUES ('" . $family . "','" . $companionship . "','"
1369 . $date . "','" . $notes . "')",__LINE__,__FILE__);
1374 if($action == 'add')
1376 $this->t->set_var('cal_date',$this->jscal->input('date','','','','','','',$this->cal_options));
1377 $this->t->set_var('family', $family);
1378 $this->t->set_var('visit', '');
1379 $this->t->set_var('name', $name);
1380 $this->t->set_var('date','');
1381 $this->t->set_var('notes','');
1382 $this->t->set_var('lang_done','Cancel');
1383 $this->t->set_var('lang_action','Adding New Visit');
1384 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.vis_update&family='
1385 . $family . '&action=' . 'insert'));
1388 if($action == 'edit' || $action == 'view')
1390 $sql = "SELECT * FROM eq_visit WHERE visit=".$visit;
1391 $this->db->query($sql,__LINE__,__FILE__);
1392 $this->db->next_record();
1393 $this->t->set_var('visit',$visit);
1394 $this->t->set_var('name',$name);
1395 $this->t->set_var('family', $family);
1396 $this->t->set_var('date',$this->db->f('date'));
1397 $this->t->set_var('notes',$this->db->f('notes'));
1400 if($action == 'edit')
1402 $this->t->set_var('cal_date',$this->jscal->input('date',$date,'','','','','',$this->cal_options));
1403 $this->t->set_var('lang_done','Cancel');
1404 $this->t->set_var('lang_action','Editing Visit');
1405 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.vis_update&visit='
1406 . $visit . '&action=' . 'save'));
1409 if($action == 'view')
1411 $date = $this->db->f('date');
1412 $this->t->set_var('cal_date','<input type=text size="10" maxlength="10" name="date" value="'.$date.'" readonly>');
1413 $this->t->set_var('readonly','READONLY');
1414 $this->t->set_var('disabled','DISABLED');
1415 $this->t->set_var('lang_done','Done');
1416 $this->t->set_var('lang_action','Viewing Visit');
1417 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.vis_update&visit='
1418 . $visit . '&action=' . 'edit'));
1421 $this->t->set_var('lang_reset','Clear Form');
1422 $this->t->set_var('lang_add','Add Visit');
1423 $this->t->set_var('lang_save','Save Changes');
1424 $this->t->set_var('edithandle','');
1425 $this->t->set_var('addhandle','');
1427 $this->t->pfp('out','form');
1429 if($action == 'view') { $this->t->set_var('lang_save','Edit Visit'); }
1430 if($action == 'edit' || $action == 'view') { $this->t->pfp('addhandle','edit'); }
1431 if($action == 'add') { $this->t->pfp('addhandle','add'); }
1433 $this->save_sessiondata();
1438 $this->t->set_file(array('att_view_t' => 'att_view.tpl'));
1439 $this->t->set_block('att_view_t','act_list','list');
1441 $this->t->set_block('att_view_t','month_list','list1');
1442 $this->t->set_block('att_view_t','header_list','list2');
1443 $this->t->set_block('att_view_t','elder_list','list3');
1445 $this->t->set_var('linkurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.att_view'));
1446 $num_months = get_var('num_months',array('GET','POST'));
1447 if($num_months == '') { $num_months = $this->default_att_num_months; }
1448 $this->t->set_var('num_months',$num_months);
1449 $this->t->set_var('lang_filter','Filter');
1450 if($num_months == 1) { $this->t->set_var('lang_num_months','Month of History'); }
1451 else { $this->t->set_var('lang_num_months','Months of History'); }
1453 $sql = "SELECT * FROM eq_elder where valid=1";
1454 $this->db->query($sql,__LINE__,__FILE__);
1456 while ($this->db->next_record())
1458 $elder_name[$i] = $this->db->f('name');
1459 $elder_id[$i] = $this->db->f('elder');
1462 array_multisort($elder_name, $elder_id);
1465 // Create a list of sunday dates for a window of 3 months back and current month
1469 $sunday_list[0]['date'] = date("Y-m-d", mktime(0, 0, 0, date("m")-$num_months, 1, date("y")));
1470 $last_date = explode("-",$sunday_list[0]['date']);
1471 $last_time = mktime(0, 0, 0, $last_date[1], $last_date[2], $last_date[0]);
1472 $time_limit = mktime(0, 0, 0, date("m"), date("t"), date("y"));
1473 while($last_time < $time_limit)
1475 $day = date("w",$last_time);
1476 if(date("w",$last_time) == 0) {
1477 $sunday_list[$i]['date'] = date("Y-m-d", $last_time);
1478 $last_date = explode("-",$sunday_list[$i]['date']);
1479 $last_time = mktime(0, 0, 0, $last_date[1], $last_date[2], $last_date[0]);
1480 $sunday_list[$i]['day'] = $last_date[2];
1481 $sunday_list[$i]['month'] = date("M",$last_time);
1482 $sunday_list[$i]['year'] = $last_date[0];
1485 $last_time += 90000;
1486 if($found_sunday) { $i++; $found_sunday=0; }
1489 $total_elders = count($elder_id);
1490 $old_month=$sunday_list[0]['month']; $span=0;
1491 for ($i=0; $i < count($sunday_list); $i++) {
1492 $date = $sunday_list[$i]['date'];
1493 $this->t->set_var('date',$sunday_list[$i]['date']);
1494 $this->t->set_var('day',$sunday_list[$i]['day']);
1495 if(($old_month != $sunday_list[$i]['month']) || $i == count($sunday_list)-1) {
1496 if($i == count($sunday_list)-1) { $span++; }
1497 $cur_month = $sunday_list[$i]['month'];
1498 $old_month = $sunday_list[$i]['month'];
1499 $link_data['menuaction'] = 'eq.eq.att_update';
1500 $link_data['month'] = $sunday_list[$i-1]['month'];
1501 $link_data['year'] = $sunday_list[$i-1]['year'];
1502 $link_data['action'] = 'update_month';
1503 $cur_month = $sunday_list[$i-1]['month'];
1504 $cur_year = $sunday_list[$i-1]['year'];
1505 $header_row .= "<th><font size=-3>$cur_month $cur_year</font></th>";
1506 $this->t->set_var('update_month',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1507 $this->t->set_var('month',$sunday_list[$i-1]['month']);
1508 $this->t->set_var('year',$sunday_list[$i-1]['year']);
1509 $this->t->set_var('span',$span); $span=0;
1510 $this->t->fp('list1','month_list',True);
1513 $this->t->set_var('total_elders',$total_elders);
1514 $this->t->set_var('header_row',$header_row);
1516 $elder_width=200; $att_width=25; $total_width=$elder_width;
1517 for ($i=0; $i < count($sunday_list); $i++) {
1518 $link_data['menuaction'] = 'eq.eq.att_update';
1519 $link_data['month'] = $sunday_list[$i]['month'];
1520 $link_data['year'] = $sunday_list[$i]['year'];
1521 $link_data['day'] = $sunday_list[$i]['day'];
1522 $link_data['date'] = $sunday_list[$i]['date'];
1523 $link_data['action'] = 'update_day';
1524 $this->t->set_var('update_day',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1525 $this->t->set_var('date',$sunday_list[$i]['date']);
1526 $this->t->set_var('day',$sunday_list[$i]['day']);
1527 $this->t->set_var('month',$sunday_list[$i]['month']);
1528 $this->t->set_var('year',$sunday_list[$i]['year']);
1529 $this->t->fp('list2','header_list',True);
1530 $total_width += $att_width;
1533 for ($i=0; $i < count($elder_id); $i++) {
1535 $this->nextmatchs->template_alternate_row_color(&$this->t);
1536 $this->t->set_var('elder_name',$elder_name[$i]);
1537 #print "checking for elder: " . $elder_id[$i] . "<br>";
1538 for ($j=0; $j < count($sunday_list); $j++) {
1539 #print "checking for date: " . $sunday_list[$j]['date'] . "<br>";
1540 #print "SELECT * FROM eq_attendance WHERE date='"
1541 # . $sunday_list[$j]['date'] . "' AND elder=" . $elder_id[$i] . "<br>";
1542 $sql = "SELECT * FROM eq_attendance WHERE date='"
1543 . $sunday_list[$j]['date'] . "' AND elder=" . $elder_id[$i];
1544 $this->db->query($sql,__LINE__,__FILE__);
1545 if($this->db->next_record()) {
1546 $cur_month = $sunday_list[$j]['month'];
1547 if($attended[$i][$cur_month] != 1) {
1548 $attended[$i][$cur_month]=1;
1549 $attendance[$cur_month]++;
1551 $att_table .= '<td align=center><img src="checkmark.gif"></td>';
1553 $att_table .= '<td> </td>';
1556 $this->t->set_var('att_table',$att_table);
1557 $this->t->fp('list3','elder_list',True);
1559 $this->t->set_var('total_width',$total_width);
1560 $this->t->set_var('elder_width',$elder_width);
1561 $this->t->set_var('att_width',$att_width);
1563 # Now calculate attendance for these months
1564 $attendance_str = "";
1565 $nonattendance_str = "";
1566 $aveattendance_str = "";
1567 $avenonattendance_str = "";
1569 $ave_total_attended=0;
1570 foreach($attendance as $att => $value) {
1571 $total_attended = $attendance[$att];
1572 $ave_total_attended += $attendance[$att]; $num_months++;
1573 $percent = ceil(($total_attended / $total_elders)*100);
1574 $attendance_str.="<td align=center><font size=-2><b>$total_attended ($percent%)</b></font></td>";
1575 $total_nonattended = $total_elders - $total_attended;
1576 $percent = ceil(($total_nonattended / $total_elders)*100);
1577 $nonattendance_str.="<td align=center><font size=-2><b>$total_nonattended ($percent%)</b></font></td>";
1579 $total_attended = ceil(($ave_total_attended / $num_months));
1580 $percent = ceil(($total_attended / $total_elders)*100);
1581 $aveattendance_str .= "<td align=center><font size=-2><b>$total_attended ($percent%)</b></font></td>";
1582 $total_attended = $total_elders - ceil(($ave_total_attended / $num_months));
1583 $percent = ceil(($total_attended / $total_elders)*100);
1584 $avenonattendance_str .= "<td align=center><font size=-2><b>$total_attended ($percent%)</b></font></td>";
1587 $this->t->set_var('attendance',$attendance_str);
1588 $this->t->set_var('aveattendance',$aveattendance_str);
1589 $this->t->set_var('nonattendance',$nonattendance_str);
1590 $this->t->set_var('avenonattendance',$avenonattendance_str);
1592 $this->t->pfp('out','att_view_t');
1593 $this->save_sessiondata();
1596 function att_update()
1598 $monthnum['Jan']=1; $monthnum['Feb']=2; $monthnum['Mar']=3; $monthnum['Apr']=4;
1599 $monthnum['May']=5; $monthnum['Jun']=6; $monthnum['Jul']=7; $monthnum['Aug']=8;
1600 $monthnum['Sep']=9; $monthnum['Oct']=10; $monthnum['Nov']=11; $monthnum['Dec']=12;
1602 $this->t->set_file(array('form' => 'att_update.tpl'));
1603 $this->t->set_block('form','edit','edithandle');
1605 $this->t->set_block('form','month_list','list1');
1606 $this->t->set_block('form','header_list','list2');
1607 $this->t->set_block('form','elder_list','list3');
1609 $this->t->set_var('done_action',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.att_view'));
1611 $action = get_var('action',array('GET','POST'));
1612 $month = get_var('month',array('GET','POST'));
1613 $year = get_var('year',array('GET','POST'));
1614 $day = get_var('day',array('GET','POST'));
1615 $date = get_var('date',array('GET','POST'));
1617 if($action == 'save_month' || $action == 'save_day')
1619 $new_data = get_var('elders_attended',array('POST'));
1620 $month = $monthnum[$month]; if($month < 10) { $month = "0" . $month; }
1622 if($action == 'save_month') {
1623 $this->db->query("DELETE from eq_attendance where date LIKE '".$year."-".$month."-%'",__LINE__,__FILE__);
1626 if($action == 'save_day') {
1627 $this->db->query("DELETE from eq_attendance where date LIKE '".$year."-".$month."-".$day."'",__LINE__,__FILE__);
1630 foreach ($new_data as $data)
1632 $data_array = explode("-",$data);
1633 $elder = $data_array[0];
1634 $date = "$data_array[1]-$data_array[2]-$data_array[3]";
1635 $this->db->query("INSERT INTO eq_attendance (elder,date) "
1636 . "VALUES (" . $elder . ",'". $date . "')",__LINE__,__FILE__);
1643 $sql = "SELECT * FROM eq_elder where valid=1";
1644 $this->db->query($sql,__LINE__,__FILE__);
1646 while ($this->db->next_record())
1648 $elder_name[$i] = $this->db->f('name');
1649 $elder_id[$i] = $this->db->f('elder');
1652 array_multisort($elder_name, $elder_id);
1654 if($action == 'update_month')
1656 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.att_update&action=save_month'));
1660 $sunday_list[0]['date'] = date("Y-m-d", mktime(0, 0, 0, $monthnum[$month], 1, $year));
1661 $last_date = explode("-",$sunday_list[0]['date']);
1662 $last_time = mktime(0, 0, 0, $last_date[1], $last_date[2], $last_date[0]);
1663 $time_limit = mktime(0, 0, 0, $monthnum[$month], 31, $year);
1664 while($last_time <= $time_limit)
1666 $day = date("w",$last_time);
1667 if(date("w",$last_time) == 0) {
1668 $sunday_list[$i]['date'] = date("Y-m-d", $last_time);
1669 $last_date = explode("-",$sunday_list[$i]['date']);
1670 $last_time = mktime(0, 0, 0, $last_date[1], $last_date[2], $last_date[0]);
1671 $sunday_list[$i]['day'] = $last_date[2];
1672 $sunday_list[$i]['month'] = date("M",$last_time);
1673 $sunday_list[$i]['year'] = $last_date[0];
1676 $last_time += 90000;
1677 if($found_sunday) { $i++; $found_sunday=0; }
1680 $this->t->set_var('span', $i);
1681 $this->t->set_var('month',$sunday_list[$i-1]['month']);
1682 $this->t->set_var('year',$sunday_list[$i-1]['year']);
1683 $this->t->fp('list1','month_list',True);
1684 $elder_width=200; $att_width=25; $total_width=$elder_width;
1685 for ($i=0; $i < count($sunday_list); $i++) {
1686 $link_data['menuaction'] = 'eq.eq.att_update';
1687 $link_data['month'] = $sunday_list[$i]['month'];
1688 $link_data['year'] = $sunday_list[$i]['year'];
1689 $link_data['day'] = $sunday_list[$i]['day'];
1690 $link_data['date'] = $sunday_list[$i]['date'];
1691 $link_data['action'] = 'update_day';
1692 $this->t->set_var('update_day',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
1693 $this->t->set_var('date',$sunday_list[$i]['date']);
1694 $this->t->set_var('day',$sunday_list[$i]['day']);
1695 $this->t->set_var('month',$sunday_list[$i]['month']);
1696 $this->t->set_var('year',$sunday_list[$i]['year']);
1697 $this->t->fp('list2','header_list',True);
1698 $total_width += $att_width;
1702 if($action == 'update_day')
1704 $this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.att_update&action=save_day'));
1705 $sunday_list[0]['date'] = date("Y-m-d", mktime(0, 0, 0, $monthnum[$month], $day, $year));
1706 $this->t->set_var('month',$month);
1707 $this->t->set_var('year',$year);
1708 $this->t->fp('list1','month_list',True);
1709 $this->t->set_var('date',$date);
1710 $this->t->set_var('day',$day);
1711 $this->t->set_var('month',$month);
1712 $this->t->set_var('year',$year);
1713 $this->t->fp('list2','header_list',True);
1716 for ($i=0; $i < count($elder_id); $i++) {
1718 $this->nextmatchs->template_alternate_row_color(&$this->t);
1719 $this->t->set_var('elder_name',$elder_name[$i]);
1720 for ($j=0; $j < count($sunday_list); $j++) {
1721 $sql = "SELECT * FROM eq_attendance WHERE date='"
1722 . $sunday_list[$j]['date'] . "' AND elder=" . $elder_id[$i];
1723 $this->db->query($sql,__LINE__,__FILE__);
1724 $value = $elder_id[$i] . "-" . $sunday_list[$j]['date'];
1725 if($this->db->next_record()) {
1726 $att_table .= '<td align=center><input type="checkbox" name="elders_attended[]" value="'.$value.'" checked></td>';
1728 $att_table .= '<td align=center><input type="checkbox" name="elders_attended[]" value="'.$value.'"></td>';
1731 $this->t->set_var('att_table',$att_table);
1732 $this->t->fp('list3','elder_list',True);
1735 $this->t->set_var('lang_done', 'Cancel');
1736 $this->t->set_var('lang_reset','Clear Form');
1737 $this->t->set_var('lang_save','Save Changes');
1739 $this->t->pfp('out','form');
1740 $this->t->pfp('addhandle','edit');
1742 $this->save_sessiondata();
1747 $this->t->set_file(array('dir_view_t' => 'dir_view.tpl'));
1748 $this->t->set_block('dir_view_t','dir_list','list');
1750 $sql = "SELECT * FROM eq_parent where valid=1 ORDER BY name ASC";
1751 $this->db->query($sql,__LINE__,__FILE__);
1753 while ($this->db->next_record())
1755 $parent[$i]['id'] = $this->db->f('parent');
1756 $parent[$i]['name'] = $this->db->f('name');
1757 $parent[$i]['phone'] = $this->db->f('phone');
1758 $parent[$i]['address'] = $this->db->f('address');
1762 for ($i=0; $i < count($parent); $i++)
1764 $name = $parent[$i]['name'];
1765 $phone = $parent[$i]['phone'];
1766 $address = $parent[$i]['address'];
1767 $this->t->set_var('name', $name);
1768 $this->t->set_var('address', $address);
1769 $this->t->set_var('phone', $phone);
1770 $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
1771 $this->t->set_var('tr_color',$tr_color);
1772 $this->t->fp('list','dir_list',True);
1773 //print "$phone $name $address<br>";
1775 $this->t->pfp('out','dir_view_t');
1776 $this->save_sessiondata();