";
$table_data=""; $completed_data=""; $totals_data="";
$year = date('Y');
+ $month = date('m');
+ $nextyear = $year + 1;
+ if($month >= 1 && $month <= 3) { $quarter_start=$year."-01-01"; $quarter_end=$year."-04-01"; }
+ if($month >= 4 && $month <= 6) { $quarter_start=$year."-04-01"; $quarter_end=$year."-07-01"; }
+ if($month >= 7 && $month <= 9) { $quarter_start=$year."-07-01"; $quarter_end=$year."-10-01"; }
+ if($month >= 10 && $month <= 12) { $quarter_start=$year."-10-01"; $quarter_end=$nextyear."-01-01"; }
+ //print "year: $year month: $month quarter_start: $quarter_start quarter_end: $quarter_end ";
if($action == 'save')
{
@@ -907,31 +1690,41 @@ class eq
$appointment = $entry['appointment'];
//print "elder: $elder appointment: $appointment ";
-
- // Perform database save actions here
- $this->db->query("UPDATE eq_appointment set " .
- " elder='" . $elder . "'" .
- " WHERE appointment=" . $appointment,__LINE__,__FILE__);
-
+ //Only perform a database update if we have made a change to this appointment
+ $sql = "SELECT * FROM eq_appointment where appointment='$appointment' and elder='$elder'";
+ $this->db->query($sql,__LINE__,__FILE__);
+ if(!$this->db->next_record()) {
+ // Perform database save actions here
+ $this->db->query("UPDATE eq_appointment set " .
+ " elder='" . $elder . "'" .
+ " WHERE appointment=" . $appointment,__LINE__,__FILE__);
+
+ // Email the appointment
+ $this->email_appt($appointment);
+ }
}
- // Save any changes made to the ppi notes table
- $new_data = get_var('ppi_notes',array('POST'));
+ // Save any changes made to the int notes table
+ $new_data = get_var('int_notes',array('POST'));
foreach ($new_data as $entry)
{
- $ppi_notes = $entry['notes'];
+ $int_notes = $entry['notes'];
$elder_id = $entry['elder_id'];
- $ppi_pri = $entry['pri'];
-
- // Perform database save actions here
- $this->db->query("UPDATE eq_elder set " .
- " ppi_notes='" . $ppi_notes . "'" .
- ",ppi_pri='" . $ppi_pri . "'" .
- " WHERE elder=" . $elder_id,__LINE__,__FILE__);
+ $elder_name = $entry['elder_name'];
+ $int_pri = $entry['pri'];
+ $aaronic = $entry['aaronic'];
+ //print "int_notes: $int_notes elder_name: $elder_name aaronic: $aaronic ";
+ if($aaronic == 0) {
+ // Perform database save actions here
+ $this->db->query("UPDATE eq_elder set " .
+ " int_notes='" . $int_notes . "'" .
+ ",int_pri='" . $int_pri . "'" .
+ " WHERE elder=" . $elder_id,__LINE__,__FILE__);
+ }
}
- $take_me_to_url = $GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.ppi_sched');
+ $take_me_to_url = $GLOBALS['phpgw']->link('/eq/index.php','menuaction=eq.eq.int_sched');
Header('Location: ' . $take_me_to_url);
}
@@ -941,28 +1734,31 @@ class eq
$i=0;
while ($this->db->next_record())
{
+ $district = $this->db->f('district');
$districts[$i]['district'] = $this->db->f('district');
$districts[$i]['name'] = $this->db->f('name');
$districts[$i]['supervisor'] = $this->db->f('supervisor');
+ $sql = "SELECT * FROM eq_presidency where district=$district and valid=1";
+ $this->db2->query($sql,__LINE__,__FILE__);
+ if($this->db2->next_record()) {
+ $districts[$i]['presidency'] = $this->db2->f('presidency');
+ }
$i++;
}
- $districts[$i]['district'] = $i + 1;
- $districts[$i]['name'] = "Unassigned";
- $districts[$i]['supervisor'] = "Unassigned";
// create the elder id -> elder name mapping
$sql = "SELECT * FROM eq_elder where valid=1 ORDER BY name ASC";
$this->db->query($sql,__LINE__,__FILE__);
$i=0;
- $elder_id = NULL;
- $elder_name = NULL;
+ $elder_id_data = NULL;
+ $elder_name_data = NULL;
while ($this->db->next_record())
{
- $elder_name[$i] = $this->db->f('name');
- $elder_id[$i] = $this->db->f('elder');
+ $elder_name_data[$i] = $this->db->f('name');
+ $elder_id_data[$i] = $this->db->f('elder');
$i++;
}
- array_multisort($elder_name, $elder_id);
+ array_multisort($elder_name_data, $elder_id_data);
// APPOINTMENT TABLE
$district = 1;
@@ -973,7 +1769,7 @@ class eq
$appt_header_row.= "
Elder
";
$appt_table_data = "";
- $total_elders=0; $elders_with_yearly_ppi=0;
+ $total_comps=0; $comps_with_quarterly_int=0;
// Display a scheduling table for each district
for ($d=0; $d < count($districts); $d++) {
@@ -981,13 +1777,13 @@ class eq
$this->t->set_var('district_number',$districts[$d]['district']);
$this->t->set_var('district_name',$districts[$d]['name']);
$supervisor = $districts[$d]['supervisor'];
- $table_title = "District ".$districts[$d]['district'].": ".$districts[$d]['name'].": All Elders with Yearly PPI Not Completed";
- $appt_table_title = "District ".$districts[$d]['district'].": ".$districts[$d]['name'].": Yearly PPI Appointment Slots";
+ $table_title = "District ".$districts[$d]['district'].": ".$districts[$d]['name'].": All Elders with Interviews Not Completed";
+ $appt_table_title = "District ".$districts[$d]['district'].": ".$districts[$d]['name'].": Interview Appointment Slots";
$this->t->set_var('table_title',$table_title);
$this->t->set_var('appt_table_title',$appt_table_title);
// query the database for all the appointments
- $sql = "SELECT * FROM eq_appointment where district=".$districts[$d]['district']." and date>=CURDATE() ORDER BY date ASC, time ASC";
+ $sql = "SELECT * FROM eq_appointment where presidency=".$districts[$d]['presidency']." and date>=CURDATE() ORDER BY date ASC, time ASC";
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
@@ -1010,10 +1806,10 @@ class eq
$appt_table_data.= '
';
@@ -1028,105 +1824,148 @@ class eq
$this->t->set_var('appt_header_row',$appt_header_row);
$this->t->set_var('appt_table_width',$appt_table_width);
- // PPI SCHEDULING TABLE
- $sql = "SELECT * FROM eq_elder where valid=1 ORDER BY ppi_pri ASC";
- $this->db->query($sql,__LINE__,__FILE__);
+ // INTERVIEW SCHEDULING TABLE
- $i=0;
- $elder_id = NULL;
+ // Select all the unique companionship numbers for this district
+ $sql = "SELECT distinct companionship FROM eq_companionship where valid=1 and district=". $districts[$d]['district'];
+ $this->db->query($sql,__LINE__,__FILE__);
+ $j=0;
while ($this->db->next_record())
{
- $sql2 = "SELECT * FROM eq_companionship where valid=1 and elder=".$this->db->f('elder');
- $this->db2->query($sql2,__LINE__,__FILE__);
-
- if(((!$this->db2->next_record()) && ($d == count($districts) - 1)) ||
- ($this->db2->f('district') == $districts[$d]['district'])) {
- $elder_id[$i] = $this->db->f('elder');
- $elder_name[$i] = $this->db->f('name');
- $elder_phone[$elder_id[$i]] = $this->db->f('phone');
- $elder_ppi_pri[$elder_id[$i]] = $this->db->f('ppi_pri');
- $elder_ppi_notes[$elder_id[$i]] = $this->db->f('ppi_notes');
- $i++;
- $total_elders++;
- }
+ $unique_companionships[$j]['companionship'] = $this->db->f('companionship');
+ $j++;
}
- $max = count($elder_id);
-
- for($i=0; $i < $max; $i++) {
- $id = $elder_id[$i];
- $name = $elder_name[$i];
- $phone = $elder_phone[$id];
- $ppi_pri = $elder_ppi_pri[$id];
- $ppi_notes = $elder_ppi_notes[$id];
+ $i=0;
+ for ($j=0; $j < count($unique_companionships); $j++) {
+ // Select all the companions from each companionship
+ $sql = "SELECT * FROM eq_companionship where valid=1 and ".
+ "companionship=". $unique_companionships[$j]['companionship'];
+ $this->db->query($sql,__LINE__,__FILE__);
+ $k=0; $int_completed=0;
+ $comp = $unique_companionships[$j]['companionship'];
+ $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
+ $this->t->set_var('tr_color',$tr_color);
+ $total_comps++;
+ while ($this->db->next_record())
+ {
+ // Get this companions information
+ $elder_id = $this->db->f('elder');
+ $aaronic_id = $this->db->f('aaronic');
+
+ $sql = "SELECT * FROM eq_elder where elder=$elder_id";
+ $this->db2->query($sql,__LINE__,__FILE__);
+ if($this->db2->next_record())
+ {
+ $elder_id = $this->db2->f('elder');
+ $elder_name = $this->db2->f('name');
+ $elder_phone[$elder_id] = $this->db2->f('phone');
+ $elder_int_pri[$elder_id] = $this->db2->f('int_pri');
+ $elder_int_notes[$elder_id] = $this->db2->f('int_notes');
+ $elder_aaronic = 0;
+ }
+ else {
+ $sql = "SELECT * FROM eq_aaronic where aaronic=$aaronic_id";
+ $this->db2->query($sql,__LINE__,__FILE__);
+ if($this->db2->next_record())
+ {
+ $elder_id = $this->db2->f('aaronic');
+ $elder_name = $this->db2->f('name');
+ $elder_phone[$elder_id] = $this->db2->f('phone');
+ $elder_aaronic = 1;
+ }
+ }
- // If this elder has had a yearly PPI this year, don't show him on the schedule list
- $year_start = $year - 1 . "-12-31"; $year_end = $year + 1 . "-01-01";
- $sql = "SELECT * FROM eq_ppi WHERE date > '$year_start' AND date < '$year_end' ".
- "AND elder=" . $id;
- $this->db2->query($sql,__LINE__,__FILE__);
-
- if(!$this->db2->next_record()) {
- $sql = "SELECT * FROM eq_ppi WHERE elder=" . $id . " ORDER BY date DESC";
- $this->db->query($sql,__LINE__,__FILE__);
- if($this->db->next_record()) { $date = $this->db->f('date'); } else { $date = ""; }
- $link_data['menuaction'] = 'eq.eq.ppi_update';
- $link_data['elder'] = $id;
- $link_data['aaronic'] = 0;
- $link_data['name'] = $name;
- $link_data['ppi'] = '';
- $link_data['eqpresppi'] = 1;
- $link_data['action'] = 'add';
- $link = $GLOBALS['phpgw']->link('/eq/index.php',$link_data);
- $table_data.= "
";
$this->t->set_var('table_width',$table_width);
$this->t->set_var('header_row',$header_row);
@@ -1138,17 +1977,15 @@ class eq
} // End for each district loop
- // Now display a table of those elders not assigned to any companionships
-
$elders_width=300; $totals_width=100;
$totals_table_width=$elders_width + $totals_width;
$totals_header_row = "
";
@@ -1160,7 +1997,7 @@ class eq
$this->t->set_var('totals_header_row',$totals_header_row);
$this->t->set_var('totals_table_width',$totals_table_width);
- $this->t->pfp('out','ppi_sched_t');
+ $this->t->pfp('out','int_sched_t');
$this->save_sessiondata();
}
@@ -1204,11 +2041,19 @@ class eq
$family = $entry['family'];
$appointment = $entry['appointment'];
- // Perform database save actions here
- $this->db->query("UPDATE eq_appointment set " .
- " family='" . $family . "'" .
- " WHERE appointment=" . $appointment,__LINE__,__FILE__);
-
+ //Only perform a database update if we have made a change to this appointment
+ $sql = "SELECT * FROM eq_appointment where appointment='$appointment' and family='$family'";
+ $this->db->query($sql,__LINE__,__FILE__);
+ if(!$this->db->next_record()) {
+
+ // Perform database save actions here
+ $this->db->query("UPDATE eq_appointment set " .
+ " family='" . $family . "'" .
+ " WHERE appointment=" . $appointment,__LINE__,__FILE__);
+
+ // Email the appointment
+ $this->email_appt($appointment);
+ }
}
// Save any changes made to the visit notes table
@@ -1232,7 +2077,6 @@ class eq
}
// APPOINTMENT TABLE
- $district = 4;
$date_width=150; $time_width=100; $family_width=250;
$appt_table_width=$date_width + $time_width + $family_width;
$appt_header_row = "
Date
";
@@ -1240,6 +2084,17 @@ class eq
$appt_header_row.= "
Family
";
$appt_table_data = "";
+ // Find out what the EQ Presidency ID is
+ $sql = "SELECT * FROM eq_presidency where eqpres=1 and valid=1";
+ $this->db->query($sql,__LINE__,__FILE__);
+ if($this->db->next_record()) {
+ $presidency_name = $this->db->f('name');
+ $presidency_id = $this->db->f('presidency');
+ } else {
+ print "
-E- Unable to locate EQ Presidency in eq_presidency table
";
+ return;
+ }
+
// create the family id -> family name mapping
$sql = "SELECT * FROM eq_family where valid=1 and elder_id != 0 ORDER BY name ASC";
$this->db->query($sql,__LINE__,__FILE__);
@@ -1254,7 +2109,7 @@ class eq
array_multisort($family_name, $family_id);
// query the database for all the appointments
- $sql = "SELECT * FROM eq_appointment where district=$district and date>=CURDATE() ORDER BY date ASC, time ASC";
+ $sql = "SELECT * FROM eq_appointment where presidency=$presidency_id and date>=CURDATE() ORDER BY date ASC, time ASC";
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
@@ -1382,7 +2237,7 @@ class eq
$families_with_yearly_visit++;
$date = $this->db2->f('date');
$vis_notes = $this->db2->f('notes');
- if(strlen($vis_notes) > 40) { $vis_notes = substr($vis_notes,0,40) . "..."; }
+ if(strlen($vis_notes) > 40) { $vis_notes = stripslashes(substr($vis_notes,0,40) . "..."); }
$completed_data.= "