From: Alan Jack Pippin Date: Thu, 26 Jan 2006 06:42:48 +0000 (-0700) Subject: Added new phone field to eq_elder table. X-Git-Tag: release_0_1_0~65 X-Git-Url: http://git.pippins.net/embedvideo/static/images/%7Bediturl%7D?a=commitdiff_plain;h=a09d03a95920d3698aa9c1dc7556b44451cfd24a;p=eq%2F.git Added new phone field to eq_elder table. Added support for showing phone as table cell title in ht_view. --- diff --git a/import_ward_data b/import_ward_data index edf701a..6a1e121 100755 --- a/import_ward_data +++ b/import_ward_data @@ -121,6 +121,7 @@ sub update_eq_aaronic_table #+------------+------------------+------+-----+---------+-------+ #| elder | int(16) unsigned | | PRI | 0 | A | #| name | varchar(60) | YES | | NULL | | +#| phone | varchar(12) | YES | | NULL | | #| valid | tinyint(1) | YES | | NULL | | #+------------+------------------+------+-----+---------+-------+ sub update_eq_elder_table @@ -137,6 +138,9 @@ sub update_eq_elder_table foreach $key (keys %$hashref) { if($key =~ /Priesthood/i && $membership_data{$index}{$key} =~ /Elder/i) { $elder_name = $membership_data{$index}{'Preferred Name'}; + $phone = $membership_data{$index}{'Phone 1'}; + if($phone =~ /(\d\d\d-\d\d\d\d)/) { $phone = "970-$1"; } + if($phone =~ /^\(\d\d\d\) (\d\d\d-\d\d\d\d)/) { $phone = "$1-$2"; } $sth = $dbh->prepare("select * from eq_elder where name='$elder_name'"); $sth->execute or die "-E- DB error: $DBI::errstr\n"; my @data = (); @@ -145,13 +149,19 @@ sub update_eq_elder_table if($rows == 0) { # No existing records found for this elder, make a new entry print " Adding new Elder: $elder_name\n"; - $sth = $dbh->prepare("insert into eq_elder values (NULL,'$elder_name',1)"); + $sth = $dbh->prepare("insert into eq_elder values (NULL,'$elder_name','$phone',1)"); $sth->execute or die "-E- DB error: $DBI::errstr\n"; } elsif($rows == 1) { # An existing record was found for this elder, update it print " Updating existing Elder: $elder_name\n"; $sth = $dbh->prepare("update eq_elder set valid=1 where name='$elder_name'"); $sth->execute or die "-E- DB error: $DBI::errstr\n"; + if($phone ne "") { + $sth = $dbh->prepare("update eq_elder set phone='$phone' where name='$elder_name'"); + } else { + $sth = $dbh->prepare("update eq_elder set phone=NULL where name='$elder_name'"); + } + $sth->execute or die "-E- DB error: $DBI::errstr\n"; } else { # More than one record was found. Error! This shouldn't happen. print " -E- More than one record found ($rows) for Elder: $elder_name\n"; diff --git a/inc/class.eq.inc.php b/inc/class.eq.inc.php index 069b3ae..6b2b8aa 100644 --- a/inc/class.eq.inc.php +++ b/inc/class.eq.inc.php @@ -143,6 +143,7 @@ class eq { $elder_id[$i] = $this->db->f('elder'); $elder_name[$i] = $this->db->f('name'); + $elder_phone[$elder_id[$i]] = $this->db->f('phone'); $i++; } array_multisort($elder_name, $elder_id); @@ -192,15 +193,16 @@ class eq while ($this->db->next_record()) { // Get this companions information - if($companion_table_entry != "") { $companion_table_entry .= " / "; } + if($companion_table_entry != "") { $companion_table_entry .= " / "; } $companionship = $this->db->f('companionship'); $elder_id = $this->db->f('elder'); $aaronic_id = $this->db->f('aaronic'); + $phone = $elder_phone[$elder_id]; if($elder_id) { $name = $elders[$elder_id]; } else if($aaronic_id) { $name = $aaronic[$aaronic_id]['name']; } - $companion_table_entry .= "$name"; + $companion_table_entry .= "$name"; } - $table_data.= "$companion_table_entry
"; + $table_data.= "$companion_table_entry

"; // Get the names of the families assigned this home teaching companionship $sql = "SELECT * from eq_family where valid=1 AND companionship=".$unique_companionships[$j]['companionship'];