Added new phone field to eq_elder table.
authorAlan Jack Pippin <ajp@pippin.(none)>
Thu, 26 Jan 2006 06:42:48 +0000 (23:42 -0700)
committerAlan J. Pippin <ajp@pippins.net>
Thu, 26 Jan 2006 06:42:48 +0000 (23:42 -0700)
Added support for showing phone as table cell title in ht_view.

import_ward_data
inc/class.eq.inc.php

index edf701ae14ae6d7395603f68d41794ee5193c3d1..6a1e121ed9acd45c1f1d77dcb4cc1c24eb12ad1d 100755 (executable)
@@ -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";
index 069b3ae9b963a7cab80d86ccc6f94dfa30612da3..6b2b8aa346d1c04c10038bf8555ec33d399f8d88 100644 (file)
@@ -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 .= "&nbsp;/&nbsp;"; }
+             if($companion_table_entry != "") { $companion_table_entry .= "<td>&nbsp;/&nbsp;</td>"; }
              $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 .= "<td title=\"$phone\"><b>$name</b></td>";
            }
-         $table_data.= "<tr bgcolor=#d3dce3><td colspan=20><b>$companion_table_entry<hr></td></tr>";
+         $table_data.= "<tr bgcolor=#d3dce3><td colspan=20><table><tr>$companion_table_entry</tr></table><hr></td></tr>";
          
          // 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'];