From a09d03a95920d3698aa9c1dc7556b44451cfd24a Mon Sep 17 00:00:00 2001 From: Alan Jack Pippin Date: Wed, 25 Jan 2006 23:42:48 -0700 Subject: [PATCH] Added new phone field to eq_elder table. Added support for showing phone as table cell title in ht_view. --- import_ward_data | 12 +++++++++++- inc/class.eq.inc.php | 8 +++++--- 2 files changed, 16 insertions(+), 4 deletions(-) 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']; -- 2.34.1