Fixed bug related to not being able to edit hometeaching history for
authorAlan J. Pippin <ajp@server.pippins.net>
Wed, 13 Feb 2008 15:06:55 +0000 (08:06 -0700)
committerAlan J. Pippin <ajp@pippins.net>
Wed, 13 Feb 2008 15:06:55 +0000 (08:06 -0700)
a family once they had been reassigned to a new companionship.

bin/import_ward_data
inc/class.eq.inc.php

index 9b830aada27441ac44ca6c56ff56bbbb3f718d05..0e04f0598274506cec12fcc5de9760b36005d2a0 100755 (executable)
@@ -447,16 +447,6 @@ sub update_eq_family_table
                            $companionship = $hometeaching_data{$index}{'Comp ID'};
                            $sth = $dbh->prepare("update eq_family set companionship='$companionship' where name_id='$name_id'");
                            $sth->execute or die "-E- DB error: $DBI::errstr\n";
-                           
-                           # In addition to changing the hometeaching assignment, update the eq_visit table
-                           # so that all previous visits made by the old hometeaching companionship, get
-                           # updated with the id of the new companionship. This will allow us to go in and
-                           # edit the history as needed for the family being hometaught under their new
-                           # companionship. Otherwise, we will not be able to update this history.
-                           #$family_id = $data[0]->{family};
-                           #print "   update eq_visit set companionship='$companionship' where family='$family_id' and companionship!='0'\n";
-                           #$sth = $dbh->prepare("update eq_visit set companionship='$companionship' where companionship='$old_companionship'");
-                           #$sth->execute or die "-E- DB error: $DBI::errstr\n";
                        }
                    }
                }
index 2af40b12a295756e52b9fadcb3a591cf6c302974..4574d4b9290db9ecc5b22dad4605117b303ab943 100644 (file)
@@ -294,12 +294,24 @@ class eq
                $month_start = "$year"."-"."$month"."-"."01";
                $month_end = "$year"."-"."$month"."-"."31";
                $month = "$month"."/"."$year";
+               
                //print "m: $m month: $month year: $year month_start: $month_start month_end: $month_end<br>";
                // Add this to the query to filter on only visits made by this companionship:
                // " AND companionship=" . $unique_companionships[$j]['companionship'].
+
+               // First check to see if the currently assigned companionship has visited them
                $sql = "SELECT * FROM eq_visit WHERE date >= '$month_start' AND date <= '$month_end' ".
-                      " AND companionship!=0".
-                      " AND family=". $family_id;
+                  " AND companionship=".$unique_companionships[$j]['companionship'].
+                  " AND family=". $family_id;
+               $query_id = $this->db2->query($sql,__LINE__,__FILE__);
+               if($this->db2->num_rows($query_id) == 0) {
+                 // We did not find any visits made by the currently assigned companionship,
+                 // look for visits made by any other companionship other than 0. (0 == EQ Presidency Visit)
+                 $sql = "SELECT * FROM eq_visit WHERE date >= '$month_start' AND date <= '$month_end' ".
+                    " AND companionship!=0".
+                    " AND family=". $family_id;
+                 $query_id = $this->db2->query($sql,__LINE__,__FILE__);
+               }
                $this->db2->query($sql,__LINE__,__FILE__);
                $link_data['menuaction'] = 'eq.eq.ht_update';
                $link_data['date'] = $month_start;
@@ -507,10 +519,21 @@ class eq
            $table_data.="<tr bgcolor=". $this->t->get_var('tr_color') ."><td>$family_name Family</td>";
            
            $header_row="<th width=$comp_width><font size=-2>Families</th>";
+
+           // First check to see if the currently assigned companionship has visited them
            $sql = "SELECT * FROM eq_visit WHERE date >= '$month_start' AND date <= '$month_end' ".
+                  " AND companionship=".$unique_companionships[$j]['companionship'].
+                  " AND family=". $family_id;
+           $query_id = $this->db2->query($sql,__LINE__,__FILE__);
+           if($this->db2->num_rows($query_id) == 0) {
+             // We did not find any visits made by the currently assigned companionship,
+             // look for visits made by any other companionship other than 0. (0 == EQ Presidency Visit)
+             $sql = "SELECT * FROM eq_visit WHERE date >= '$month_start' AND date <= '$month_end' ".
                   " AND companionship!=0".
                   " AND family=". $family_id;
-           $this->db2->query($sql,__LINE__,__FILE__);
+             $query_id = $this->db2->query($sql,__LINE__,__FILE__);
+           }
+           
            $value = $family_id . "/" . $unique_companionships[$j]['companionship'] . "/" . $date;
            $header_row .= "<th width=$visit_width><font size=-2><a href=$link>$month</a></th>";
            if(!$total_visits) { $total_visits = 0; }