From: Alan J. Pippin Date: Wed, 13 Feb 2008 15:06:55 +0000 (-0700) Subject: Fixed bug related to not being able to edit hometeaching history for X-Git-Tag: release_0_2_0~1^2~1 X-Git-Url: http://git.pippins.net/embedvideo/.git/%22%22.%24thumbnail.%22/.%24link.?a=commitdiff_plain;h=c57e6e155b11fb24d9e2a9e29763db98b7d4bf21;p=eq%2F.git Fixed bug related to not being able to edit hometeaching history for a family once they had been reassigned to a new companionship. --- diff --git a/bin/import_ward_data b/bin/import_ward_data index 9b830aa..0e04f05 100755 --- a/bin/import_ward_data +++ b/bin/import_ward_data @@ -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"; } } } diff --git a/inc/class.eq.inc.php b/inc/class.eq.inc.php index 2af40b1..4574d4b 100644 --- a/inc/class.eq.inc.php +++ b/inc/class.eq.inc.php @@ -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
"; // 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.="$family_name Family"; $header_row="Families"; + + // 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 .= "$month"; if(!$total_visits) { $total_visits = 0; }