Added new Ward Calling display application.
authorAlan Jack Pippin <ajp@pippin.(none)>
Fri, 2 Jun 2006 06:03:50 +0000 (00:03 -0600)
committerAlan J. Pippin <ajp@pippins.net>
Fri, 2 Jun 2006 06:03:50 +0000 (00:03 -0600)
import_ward_data
inc/class.eq.inc.php
templates/default/dir_view.tpl
templates/default/header.tpl
templates/default/org_view.tpl [new file with mode: 0644]

index ef1c7eab0e862ed52fd2ce3dbcda3668b36ce3b6..c45feafde8a73c6410877a57165a3674dc112522 100755 (executable)
@@ -183,6 +183,46 @@ sub update_eq_elder_table
     $sth->finish();
 }
 
+# EQ_CALLING
+#+--------------+------------------+------+-----+---------+-------+
+#| Field        | Type             | Null | Key | Default | Extra |
+#+--------------+------------------+------+-----+---------+-------+
+#| indiv_id     | int(16) unsigned | YES  |     | NULL    |       |
+#| name         | varchar(30)      | YES  |     | NULL    |       |
+#| organization | varchar(30)      | YES  |     | NULL    |       |
+#| position     | varchar(30)      | YES  |     | NULL    |       |
+#| sequence     | int(16) unsigned | YES  |     | NULL    |       |
+#| sustained    | date             | YES  |     | NULL    |       |
+#+--------------+------------------+------+-----+---------+-------+
+sub update_eq_calling_table()
+{
+    print "-> Updating eq_calling table\n";
+
+    #print "-> Organization Data Dump\n\n";
+    #&print_hash(\%organization_data);
+    
+    # Delete all records from the calling table. We have no history to
+    # save here. Just re-populate with the latest calling information.
+    $sth = $dbh->prepare("delete from eq_calling ");
+    $sth->execute or die "-E- DB error: $DBI::errstr\n";
+    
+    foreach $index (keys %organization_data)
+    {
+       $indiv_id = $organization_data{$index}{'Indiv ID'};
+       $name = $organization_data{$index}{'Indiv Name'};
+       $name =~ s/\'/\\'/g; #'
+       $organization = $organization_data{$index}{'Organization'};
+       $position = $organization_data{$index}{'Position'};
+       $sequence = $organization_data{$index}{'Org Seq'};
+       $sustained = $organization_data{$index}{'Sustained'};
+       $sustained =~ /(\S+) (\d+)/; $month=$1; $year=$2;
+       if($name eq "") { next; }
+       print "   Adding new Calling: $name -> $position\n";
+       $sth = $dbh->prepare("insert into eq_calling values ('$indiv_id','$name','$organization','$position','$sequence','$month $year')");
+       $sth->execute or die "-E- DB error: $DBI::errstr\n";
+    }
+}
+
 # EQ_DISTRICT
 #+------------+------------------+------+-----+---------+-------+
 #| Field      | Type             | Null | Key | Default | Extra |
@@ -390,6 +430,9 @@ sub update_eq_family_table
 #| family   | int(16) unsigned | YES  |     | NULL    |       |
 #| name     | varchar(30)      | YES  |     | NULL    |       |
 #| birthday | date             | YES  |     | NULL    |       |
+#| phone    | varchar(12)      | YES  |     | NULL    |       |
+#| address  | varchar(255)     | YES  |     | NULL    |       |
+#| indiv_id | int(16) unsigned | YES  | UNI | NULL    |       |
 #| valid    | tinyint(1)       | YES  |     | NULL    |       |
 #+----------+------------------+------+-----+---------+-------+
 sub update_eq_parent_table
@@ -414,6 +457,7 @@ sub update_eq_parent_table
                $birthday = $membership_data{$index}{'Birth'};
                $birthday =~ /(\d+) (\S+) (\d+)/; $day=$1; $month=$monthname2num{$2}; $year=$3;
                $hofh_id = $membership_data{$index}{'HofH ID'};
+               $id = $membership_data{$index}{'Indiv ID'};
                $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"; }
@@ -438,7 +482,7 @@ sub update_eq_parent_table
                if($rows == 0) {
                    # No existing records found for this parent, make a new entry
                    print "   Adding new Parent: $parent_name\n";
-                   $sth = $dbh->prepare("insert into eq_parent values (NULL,$family_id,'$parent_name','$year-$month-$day','$phone','$address',1)");
+                   $sth = $dbh->prepare("insert into eq_parent values (NULL,$family_id,'$parent_name','$year-$month-$day','$phone','$address','$id',1)");
                    $sth->execute or die "-E- DB error: $DBI::errstr\n";
                } elsif($rows == 1) {
                    # An existing record was found for this parent, update it
@@ -453,6 +497,8 @@ sub update_eq_parent_table
                    $sth->execute or die "-E- DB error: $DBI::errstr\n";
                    $sth = $dbh->prepare("update eq_parent set valid=1 where name='$parent_name'");
                    $sth->execute or die "-E- DB error: $DBI::errstr\n";
+                   $sth = $dbh->prepare("update eq_parent set indiv_id='$id' where name='$parent_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 with same parent name: $parent_name\n";
@@ -471,6 +517,7 @@ sub update_eq_parent_table
 #| family   | int(16) unsigned | YES  |     | NULL    |       |
 #| name     | varchar(30)      | YES  |     | NULL    |       |
 #| birthday | date             | YES  |     | NULL    |       |
+#| indiv_id | int(16) unsigned | YES  | UNI | NULL    |       |
 #| valid    | tinyint(1)       | YES  |     | NULL    |       |
 #+----------+------------------+------+-----+---------+-------+
 sub update_eq_child_table
@@ -509,7 +556,7 @@ sub update_eq_child_table
                if($rows == 0) {
                    # No existing records found for this child, make a new entry
                    print "   Adding new Child: $child_name\n";
-                   $sth = $dbh->prepare("insert into eq_child values (NULL,$family_id,'$child_name','$year-$month-$day',1)");
+                   $sth = $dbh->prepare("insert into eq_child values (NULL,$family_id,'$child_name','$year-$month-$day','$id',1)");
                    $sth->execute or die "-E- DB error: $DBI::errstr\n";
                } elsif($rows == 1) {
                    # An existing record was found for this child, update it
@@ -520,6 +567,8 @@ sub update_eq_child_table
                    $sth->execute or die "-E- DB error: $DBI::errstr\n";
                    $sth = $dbh->prepare("update eq_child set valid=1 where name='$child_name'");
                    $sth->execute or die "-E- DB error: $DBI::errstr\n";
+                   $sth = $dbh->prepare("update eq_child set indiv_id='$id' where name='$child_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) with same child name: $child_name\n";
@@ -609,12 +658,15 @@ print "-> Processing all ward data files in $datadir\n";
 # Parse Ward Data Files
 &csv_to_hash("$datadir/Membership.csv",\%membership_data);
 &csv_to_hash("$datadir/HomeTeaching.csv",\%hometeaching_data);
+&csv_to_hash("$datadir/Organization.csv",\%organization_data);
 
 if($opt_v) {
     print "-> Membership Data Dump\n\n";
     &print_hash(\%membership_data);
     print "-> HomeTeaching Data Dump\n\n";
     &print_hash(\%hometeaching_data);
+    print "-> Organization Data Dump\n\n";
+    &print_hash(\%organization_data);
 }
 
 if($opt_s) { $dbh->disconnect(); exit; }
@@ -627,6 +679,7 @@ if($opt_s) { $dbh->disconnect(); exit; }
 &update_eq_family_table();
 &update_eq_parent_table();
 &update_eq_child_table();
+&update_eq_calling_table();
 
 ###################################################
 # Disconnect from the database
index aab3ffd61d40b3792059fcc712c4cdb8d8e1d6e7..b1dbb23a16972777e4cf215dba8e16f1032f7eb0 100644 (file)
@@ -40,7 +40,8 @@ class eq
      'vis_update' => True,
      'att_view'   => True,
      'att_update' => True,
-     'dir_view'   => True
+     'dir_view'   => True,
+     'org_view'   => True
      );
  
   function eq()
@@ -117,6 +118,9 @@ class eq
       $link_data['menuaction'] = 'eq.eq.dir_view';     
       $this->t->set_var('link_dir',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
       $this->t->set_var('lang_dir','Directory');
+      $link_data['menuaction'] = 'eq.eq.org_view';     
+      $this->t->set_var('link_org',$GLOBALS['phpgw']->link('/eq/index.php',$link_data));
+      $this->t->set_var('lang_org','Callings');
                
       $this->t->pparse('out','eq_header');
     }
@@ -1782,6 +1786,72 @@ class eq
       $this->save_sessiondata();   
     }
   
+  function org_view()
+    {
+      $this->t->set_file(array('org_view_t' => 'org_view.tpl'));
+      $this->t->set_block('org_view_t','calling_list','list1');
+      $this->t->set_block('org_view_t','org_list','list2');
+
+      # Display a list ordered alphabetically
+      $sql = "SELECT * FROM eq_calling ORDER BY name ASC";
+      $this->db->query($sql,__LINE__,__FILE__);
+      $i=0;
+      while ($this->db->next_record())
+       {
+         $calling[$i]['id'] = $this->db->f('indiv_id');
+         $calling[$i]['name'] = $this->db->f('name');
+         $calling[$i]['position'] = $this->db->f('position');
+         $calling[$i]['sustained'] = $this->db->f('sustained');
+         $calling[$i]['organization'] = $this->db->f('organization');
+         $i++;
+       }   
+      for ($i=0; $i < count($calling); $i++) 
+      {
+        $name = $calling[$i]['name'];
+       $position = $calling[$i]['position'];
+       $sustained = $calling[$i]['sustained'];
+       $organization = $calling[$i]['organization'];
+       $this->t->set_var('name', $name);
+       $this->t->set_var('position', $position);
+       $this->t->set_var('sustained', $sustained);
+       $this->t->set_var('organization', $organization);
+        $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
+        $this->t->set_var('tr_color',$tr_color);
+       $this->t->fp('list1','calling_list',True);
+      }
+
+      # Display a list ordered by organization
+      $sql = "SELECT * FROM eq_calling ORDER BY sequence ASC";
+      $this->db->query($sql,__LINE__,__FILE__);
+      $i=0;
+      while ($this->db->next_record())
+       {
+         $calling[$i]['id'] = $this->db->f('indiv_id');
+         $calling[$i]['name'] = $this->db->f('name');
+         $calling[$i]['position'] = $this->db->f('position');
+         $calling[$i]['sustained'] = $this->db->f('sustained');
+         $calling[$i]['organization'] = $this->db->f('organization');
+         $i++;
+       }   
+      for ($i=0; $i < count($calling); $i++) 
+      {
+        $name = $calling[$i]['name'];
+       $position = $calling[$i]['position'];
+       $sustained = $calling[$i]['sustained'];
+       $organization = $calling[$i]['organization'];
+       $this->t->set_var('name', $name);
+       $this->t->set_var('position', $position);
+       $this->t->set_var('sustained', $sustained);
+       $this->t->set_var('organization', $organization);
+        $tr_color = $this->nextmatchs->alternate_row_color($tr_color);
+        $this->t->set_var('tr_color',$tr_color);
+       $this->t->fp('list2','org_list',True);
+      }
+      
+      $this->t->pfp('out','org_view_t');
+      $this->save_sessiondata();   
+    }
+  
 }
 
 ?>
index b1adc19cd7700585cd6f21e15fbec72c38d7c11f..e49518d37c5fb45210a55ef59b7642dfa310a470 100644 (file)
@@ -1,7 +1,7 @@
 <center>
        <table border="0" width="80%" cellspacing="2" cellpadding="2">
        <tr>
-         <td align="center" bgcolor="#c9c9c9"><font face="{font}"><b>Online Ward Directory</b></font></td>
+         <td align="center" bgcolor="#c9c9c9"><font face="{font}"><b>Ward Directory</b></font></td>
        </tr>
        </table>
        <br>
index 4a624a1f345cd320f27bc37a9b484087ac6aba37..8da35981ad284e9d6c1d3bfdbc72c7f52b5b3c55 100644 (file)
@@ -24,6 +24,9 @@
                                        &nbsp;
                                         &nbsp;
                                         <a href="{link_dir}">{lang_dir}</a>
+                                       &nbsp;
+                                        &nbsp;
+                                        <a href="{link_org}">{lang_org}</a>
                                        </b></font></td>
 
                        </tr>
diff --git a/templates/default/org_view.tpl b/templates/default/org_view.tpl
new file mode 100644 (file)
index 0000000..d1bb206
--- /dev/null
@@ -0,0 +1,42 @@
+<center>
+       <table border="0" width="80%" cellspacing="2" cellpadding="2">
+       <tr>
+         <td align="center" bgcolor="#c9c9c9"><font face="{font}"><b>Ward Callings</b></font></td>
+       </tr>
+       </table>
+       <br><h2>By Name</h2>
+
+       <table border="0" width=80% cellspacing="2" cellpadding="2">
+       <tr>
+         <td colspan="1" align="center" bgcolor="#c9c9c9"><font face="{font}"><b>Name</b></font></td>
+         <td colspan="1" align="center" bgcolor="#c9c9c9"><font face="{font}"><b>Calling</b></font></td>
+         <td colspan="1" align="center" bgcolor="#c9c9c9"><font face="{font}"><b>Date Sustained</b></font></td>
+       </tr>
+<!-- BEGIN calling_list -->
+       <tr bgcolor="{tr_color}">
+          <td align="left" width=25%><font face="{font}">{name}</font></td>
+          <td align="left" width=25%><font face="{font}">{position}</font></td>
+          <td align="left" width=25%><font face="{font}">{sustained}</font></td>
+        </tr>
+<!-- END calling_list -->
+       </table>
+
+       <br><h2>By Organization</h2>
+       <table border="0" width=80% cellspacing="2" cellpadding="2">
+       <tr>
+         <td colspan="1" align="center" bgcolor="#c9c9c9"><font face="{font}"><b>Organization</b></font></td>
+         <td colspan="1" align="center" bgcolor="#c9c9c9"><font face="{font}"><b>Name</b></font></td>
+         <td colspan="1" align="center" bgcolor="#c9c9c9"><font face="{font}"><b>Calling</b></font></td>
+         <td colspan="1" align="center" bgcolor="#c9c9c9"><font face="{font}"><b>Date Sustained</b></font></td>
+       </tr>
+<!-- BEGIN org_list -->
+       <tr bgcolor="{tr_color}">
+          <td align="left" width=25%><font face="{font}">{organization}</font></td>
+          <td align="left" width=25%><font face="{font}">{name}</font></td>
+          <td align="left" width=25%><font face="{font}">{position}</font></td>
+          <td align="left" width=25%><font face="{font}">{sustained}</font></td>
+        </tr>
+<!-- END org_list -->
+
+       </table>
+</center>