Fixed bug related to hometeaching history being lost.
authorAlan Jack Pippin <ajp@pippin.(none)>
Mon, 23 Jan 2006 05:39:49 +0000 (22:39 -0700)
committerAlan J. Pippin <ajp@pippins.net>
Mon, 23 Jan 2006 05:39:49 +0000 (22:39 -0700)
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.

inc/class.eq.inc.php

index d2396c4faed2339bd2b8ea73de9052d8cb2f2b11..8c2984e511210cbe2e203254bdb40552d074112f 100644 (file)
@@ -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="<th width=$comp_width><font size=-2>Families</th>";
            $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;