From: Alan Jack Pippin Date: Mon, 23 Jan 2006 05:39:49 +0000 (-0700) Subject: Fixed bug related to hometeaching history being lost. X-Git-Tag: release_0_1_0~67 X-Git-Url: http://git.pippins.net/embedvideo/.git/?a=commitdiff_plain;h=4d253dd156e29b53b2b2d0307d71eaef3379df8d;hp=2d62fe2d30e68f295572b6ae87597b882537511b;p=eq%2F.git Fixed bug related to hometeaching history being lost. This happened when a family was reassigned. The ht_view app would only query the history of visits for the new companionship, not the older ones. --- diff --git a/inc/class.eq.inc.php b/inc/class.eq.inc.php index d2396c4..8c2984e 100644 --- a/inc/class.eq.inc.php +++ b/inc/class.eq.inc.php @@ -221,8 +221,10 @@ class eq $month = date('m/Y', strtotime('-'.$m.' month -'.$d.' day')); $month_start = date('Y-m', strtotime('-'.$m.' month -'.$d.' day')); $month_start .= "-01"; $month_end = date('Y-m', strtotime('-'.$m.' month -'.$d.' day')); $month_end .= "-31"; + // Add this to the query to filter on only visits made by this companionship: + // " AND companionship=" . $unique_companionships[$j]['companionship']. $sql = "SELECT * FROM eq_visit WHERE date >= '$month_start' AND date <= '$month_end' ". - " AND companionship=" . $unique_companionships[$j]['companionship']. + " AND companionship!=0". " AND family=". $family_id; $this->db2->query($sql,__LINE__,__FILE__); $link_data['menuaction'] = 'eq.eq.ht_update'; @@ -324,6 +326,13 @@ class eq } for ($j=0; $j < count($unique_companionships); $j++) { + // FIXME: We won't be able to go back and edit history on families that have been + // reassigned to a different companionship. The following delete command will not delete + // the history of visits under an older companionship, only the ones for the existing + // companionship. This will lead to duplicate visits being entered for an older + // month for the same family, making it impossible to change the past history once + // a family is reassigned. However, you will be able to view the history just fine. + // Delete all the visits that have taken place for all families for this month $this->db->query("DELETE from eq_visit where companionship=" . $unique_companionships[$j]['companionship'] . " AND " . "date='" . $date . "'",__LINE__,__FILE__); @@ -421,7 +430,7 @@ class eq $header_row="Families"; $sql = "SELECT * FROM eq_visit WHERE date >= '$month_start' AND date <= '$month_end' ". - " AND companionship=" . $unique_companionships[$j]['companionship'] . + " AND companionship!=0". " AND family=". $family_id; $this->db2->query($sql,__LINE__,__FILE__); $value = $family_id . "/" . $unique_companionships[$j]['companionship'] . "/" . $date;