Added email field to eq_aaronic
authorOwen Leonard <owen@balawis.leonard.fam>
Fri, 10 Sep 2010 04:44:44 +0000 (22:44 -0600)
committerOwen Leonard <owen@balawis.leonard.fam>
Fri, 10 Sep 2010 05:29:07 +0000 (23:29 -0600)
Added priesthood field to eq_elder
Added prospective elders to eq_elder during import of data and set the priesthood field  (this way they are included in attendance, ppi's, etc)

bin/import_ward_data
bin/upgrade_3_0_to_4_0 [new file with mode: 0644]
doc/install.txt
sql/eq.sql
sql/schema.dot

index 37fb24869615dcbad74fd17a69be1b442c64559b..2b22197357de0f08a0a920f3c2cc488acebb8b26 100755 (executable)
@@ -109,6 +109,7 @@ sub print_hash
 #| aaronic | int(16) unsigned |      | PRI | 0       |   A   |
 #| name    | varchar(60)      | YES  |     | NULL    |       |
 #| phone   | varchar(12)      | YES  |     | NULL    |       |
+#| email   | varchar(120)     | YES  |     | NULL    |       |
 #| valid   | tinyint(1)       | YES  |     | NULL    |       |
 #+-------+--------------------+------+-----+---------+-------+
 sub update_eq_aaronic_table
@@ -131,6 +132,8 @@ sub update_eq_aaronic_table
                $phone = $membership_data{$index}{'Household Phone'};
                if($phone =~ /(\d\d\d-\d\d\d\d)/) { $phone = "$areacode-$1"; }
                if($phone =~ /^\(\d\d\d\) (\d\d\d-\d\d\d\d)/) { $phone = "$1-$2"; }
+               $email = $membership_data{$index}{'Individual E-mail'};
+               if ($email eq "") { $email = $membership_data{$index}{'Household E-mail'}; }
                $sth = $dbh->prepare("select * from eq_aaronic where name='$aaronic_name'");
                $sth->execute or die "-E- DB error: $DBI::errstr\n";
                my @data = ();
@@ -139,13 +142,15 @@ sub update_eq_aaronic_table
                if($rows == 0) {
                    # No existing records found for this aaronic, make a new entry
                    print "   Adding new Aaronic: $aaronic_name\n";
-                   $sth = $dbh->prepare("insert into eq_aaronic values (NULL,'$aaronic_name','$phone',1)");
+                   $sth = $dbh->prepare("insert into eq_aaronic values (NULL,'$aaronic_name','$phone','$email',1)");
                    $sth->execute or die "-E- DB error: $DBI::errstr\n";
                } elsif($rows == 1) {
                    # An existing record was found for this aaronic, update it, mark it valid!
                    print "   Updating existing aaronic: $aaronic_name\n";
                    $sth = $dbh->prepare("update eq_aaronic set phone='$phone' where name='$aaronic_name'");
                    $sth->execute or die "-E- DB error: $DBI::errstr\n";
+                   $sth = $dbh->prepare("update eq_aaronic set email='$email' where name='$aaronic_name'");
+                   $sth->execute or die "-E- DB error: $DBI::errstr\n";
                    $sth = $dbh->prepare("update eq_aaronic set valid=1 where name='$aaronic_name'");
                    $sth->execute or die "-E- DB error: $DBI::errstr\n";
                } else {
@@ -167,6 +172,7 @@ sub update_eq_aaronic_table
 #| name        | varchar(60)      | YES  |     | NULL    |                |
 #| phone       | varchar(12)      | YES  |     | NULL    |                |
 #| email       | varchar(120)     | YES  |     | NULL    |                |
+#| priesthood  | enum             | YES  |     | NULL    |                |
 #| ppi_pri     | int(10) unsigned | YES  |     | 1       |                |
 #| ppi_notes   | varchar(128)     | YES  |     | NULL    |                |
 #| int_pri     | int(10) unsigned | YES  |     | 1       |                |
@@ -186,10 +192,31 @@ sub update_eq_elder_table
     {
        $hashref = $membership_data{$index};
        foreach $key (keys %$hashref) {
-           if($key =~ /Priesthood/i && $membership_data{$index}{$key} =~ /Elder/i) {
+           if($key =~ /Priesthood/i && 
+              ($membership_data{$index}{$key} =~ /Deacon/i ||
+               $membership_data{$index}{$key} =~ /Teacher/i ||
+               $membership_data{$index}{$key} =~ /Priest/i ||
+               $membership_data{$index}{$key} =~ /Elder/i ||
+               $membership_data{$index}{$key} =~ /Unordained/i)) {
+               
+               # check if this is a prospective elder under the stewardship of the EQ
+               if($membership_data{$index}{$key} !~ /Elder/i) {
+                       $found = 0;
+                       foreach $i (keys %prospective_elder_data) {
+                               #print "$membership_data{$index}{'Full Name'}\n";
+                               #print "$prospective_elder_data{$i}{'Full Name'}\n";
+                               if($membership_data{$index}{'Full Name'} eq $prospective_elder_data{$i}{'Full Name'}) {
+                                       $found = 1;
+                                       last;
+                               }
+                       }
+                       if($found == 0) { next;}
+               }
+               
                $id = $membership_data{$index}{'Indiv ID'};
                $elder_name = $membership_data{$index}{'Preferred Name'};
                $phone = $membership_data{$index}{'Household Phone'};
+               $priesthood = $membership_data{$index}{'Priesthood'};
                $organization = $organization_by_id{$id};
                $attending = 0;
                if(($organization =~ /Elders/) ||
@@ -209,7 +236,7 @@ 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,'$id','$elder_name','$phone','$email','1','','1','',$attending,1)");
+                   $sth = $dbh->prepare("insert into eq_elder values (NULL,'$id','$elder_name','$phone','$email','$priesthood','1','','1','',$attending,1)");
                    $sth->execute or die "-E- DB error: $DBI::errstr\n";
                } elsif($rows == 1) {
                    # An existing record was found for this elder, update it
@@ -226,6 +253,8 @@ sub update_eq_elder_table
                    $sth->execute or die "-E- DB error: $DBI::errstr\n";
                    $sth = $dbh->prepare("update eq_elder set indiv_id='$id' where name='$elder_name'");
                    $sth->execute or die "-E- DB error: $DBI::errstr\n";
+                   $sth = $dbh->prepare("update eq_elder set priesthood='$priesthood' where name='$elder_name'");
+                   $sth->execute or die "-E- DB error: $DBI::errstr\n";
                    $sth = $dbh->prepare("update eq_elder set email='$email' where name='$elder_name'");
                    $sth->execute or die "-E- DB error: $DBI::errstr\n";
                } else {
@@ -845,7 +874,7 @@ print "\n-> Processing all ward data files in $datadir\n";
 
 ###################################################
 # Parse Ward Data Files
-#&optional_csv_to_hash("$datadir/EQ\ Prospective\ Elders.csv", \%prospective_elder_data);
+&optional_csv_to_hash("$datadir/EQ\ Prospective\ Elders.csv", \%prospective_elder_data);
 &csv_to_hash("$datadir/Membership.csv",\%membership_data);
 &csv_to_hash("$datadir/HomeTeaching.csv",\%hometeaching_data);
 &csv_to_hash("$datadir/Organization.csv",\%organization_data);
diff --git a/bin/upgrade_3_0_to_4_0 b/bin/upgrade_3_0_to_4_0
new file mode 100644 (file)
index 0000000..a7ac6f9
--- /dev/null
@@ -0,0 +1,33 @@
+#!/usr/bin/perl
+
+use DBI;
+use Getopt::Std;
+
+$mydir = `cd \$(dirname $0) 2>/dev/null; pwd`; chomp($mydir);
+unshift @INC,("$mydir/../setup");
+if( -f "$mydir/../setup/db_config.local") { require "db_config.local"; }
+else { require "db_config"; }
+
+###################################################
+# Connect to the database
+$dbh=DBI->connect("dbi:mysql:dbname=$dbname:host=$dbhost:port=$dbport",$dbuser,$dbpass,{
+    AutoCommit=>0,
+    PrintError=>0}) or print "Connect Failure:".$DBI::errstr."\n" and exit 2;
+###################################################
+
+# Add a new 'email' field to the eq_aaronic table
+$sth = $dbh->prepare("ALTER TABLE `eq_aaronic` ADD `email` VARCHAR( 120 ) NULL AFTER `phone`");
+$sth->execute or die "-E- DB error: $DBI::errstr\n";
+
+# Add a new 'priesthood' field to the eq_elder table
+$sth = $dbh->prepare("ALTER TABLE `eq_elder` ADD `priesthood` enum('High Priest','Elder','Priest','Teacher','Deacon','Unordained') NULL AFTER `email`");
+$sth->execute or die "-E- DB error: $DBI::errstr\n";
+
+print "-> Done!\n";
+
+###################################################
+# Disconnect from the database
+$dbh->disconnect();
+###################################################
+
+
index 11f272801c159f03a40062a14f5f042af456dd3a..284da64769fb3f82c4b75359c8535312ebed196b 100644 (file)
@@ -24,6 +24,7 @@ Dependencies
    mysql
    apache (or equivalent webserver)
    MLS data dumps (required fields shown below)
+   Python 2.6 or .Net 3.5 (for trimming MLS data dumps)
 
 Installing
 
@@ -48,6 +49,12 @@ Installing
       Install the right perl modules until the scripts run without any errors.
    7) A graphical representation of the mysql schema used by this application can 
       be found here: eq/sql/eq.jpg
+   8) Run mls/mlstrimmer.py or MLSFileTrimmer.exe to trim down the csv files and combine them
+      into a zip file.  If you run mls/mlstrimmer.py, you'll need to point it to 
+      mls/windowsGUI/MLSFileTrimmer/MLSRequiredFields.xml.  If you choose to not use 
+      EQ\ Prospective\ Elders.mls or Home\ Teacher\ per\ Companionship.mls, you'll need to 
+      remove them from MLSRequiredFields.xml (probably best to just comment them out in case you
+      decide to use them later)
    8) Click on the Admin tool in the EQ app to import your initial set of ward data
       obtained from MLS into the EQ application.
    9) Click on the Admin tool and update the EQ Presidency Table appropriately.
@@ -59,7 +66,7 @@ Requirements
 
    The following csv files must be obtained from MLS (or a stripped down version
    of each csv with the fields indicated must be manually created). These files
-   should be placed in 1 .zip file and uplodaed to the application via the Admin
+   should be placed in 1 .zip file and uploaded to the application via the Admin
    section of the EQ Tools application.
 
    Membership.csv:
@@ -94,9 +101,9 @@ Requirements
      Sustained
    
    EQ Prospective Elders.csv  
-      (optional file that lists the prospective elders for which  the EQ has stewardship.
-      Use this file if you want them listed in the PPI list
-      import mls/EQ\ Prospective\ Elders.mls as a new report into MLS to create the csv file.)
+      Optional file that lists the prospective elders for which  the EQ has stewardship.
+      Use this file if you want them listed in the PPI/attendence/etc lists
+      import mls/EQ\ Prospective\ Elders.mls as a new report into MLS to create the csv file.
 
    Home Teacher per Companionship.csv  (optional file that lists home teaching stats - use all fields)
      import mls/Home\ Teacher\ per\ Companionship.mls as a new report into MLS to create the csv file.
index 468bd1e40413f86192638335c4c951d7d1c95376..81065417c5b810683057a5747c28e9aad0db9570 100644 (file)
@@ -18,6 +18,7 @@ CREATE TABLE `eq_aaronic` (
   `aaronic` int(16) unsigned NOT NULL auto_increment,
   `name` varchar(60) default NULL,
   `phone` varchar(12) default NULL,
+  `email` varchar(120) default NULL,
   `valid` tinyint(1) default NULL,
   PRIMARY KEY  (`aaronic`)
 ) ENGINE=MyISAM AUTO_INCREMENT=92 DEFAULT CHARSET=latin1;
@@ -137,6 +138,7 @@ CREATE TABLE `eq_elder` (
   `name` varchar(60) default NULL,
   `phone` varchar(12) default NULL,
   `email` varchar(120) default NULL,
+  `priesthood` enum('High Priest','Elder','Priest','Teacher','Deacon','Unordained') DEFAULT NULL,
   `ppi_pri` int(10) unsigned NOT NULL default '1',
   `ppi_notes` varchar(128) default NULL,
   `int_pri` int(10) unsigned default '1',
index 99fb6c422a2ae8389ba03f37933e82d126b03223..641e87501de54fa1247c628cd14f01b0d6e5abad 100644 (file)
@@ -7,7 +7,7 @@ digraph schema {
     shape = "record"
   ];
   elder   [
-    label = "<e> elder||<n> name|<p> phone|<pp> ppi_pri|<t> ppi_notes|<ip> int_pri|<in> int_notes|<a> attending|<v> valid"
+    label = "<e> elder||<n> name|<p> phone|<em> email|<po> priesthood|<pp> ppi_pri|<t> ppi_notes|<ip> int_pri|<in> int_notes|<a> attending|<v> valid"
     shape = "record"
   ];
   companionship   [
@@ -43,7 +43,7 @@ digraph schema {
     shape = "record"
   ]; 
   aaronic       [
-    label = "<a> aaronic||<n> name|<p> phone|<v> valid"
+    label = "<a> aaronic||<n> name|<p> phone|<em> email|<v> valid"
     shape = "record"
   ];
   appointment   [