From 3922955bdc5c67d0ad7485288016754aa981b280 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 9 Sep 2010 22:44:44 -0600 Subject: [PATCH] Added email field to eq_aaronic 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 | 37 +++++++++++++++++++++++++++++++++---- bin/upgrade_3_0_to_4_0 | 33 +++++++++++++++++++++++++++++++++ doc/install.txt | 15 +++++++++++---- sql/eq.sql | 2 ++ sql/schema.dot | 4 ++-- 5 files changed, 81 insertions(+), 10 deletions(-) create mode 100644 bin/upgrade_3_0_to_4_0 diff --git a/bin/import_ward_data b/bin/import_ward_data index 37fb248..2b22197 100755 --- a/bin/import_ward_data +++ b/bin/import_ward_data @@ -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 index 0000000..a7ac6f9 --- /dev/null +++ b/bin/upgrade_3_0_to_4_0 @@ -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(); +################################################### + + diff --git a/doc/install.txt b/doc/install.txt index 11f2728..284da64 100644 --- a/doc/install.txt +++ b/doc/install.txt @@ -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. diff --git a/sql/eq.sql b/sql/eq.sql index 468bd1e..8106541 100644 --- a/sql/eq.sql +++ b/sql/eq.sql @@ -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', diff --git a/sql/schema.dot b/sql/schema.dot index 99fb6c4..641e875 100644 --- a/sql/schema.dot +++ b/sql/schema.dot @@ -7,7 +7,7 @@ digraph schema { shape = "record" ]; elder [ - label = " elder|| name|

phone| ppi_pri| ppi_notes| int_pri| int_notes| attending| valid" + label = " elder|| name|

phone| email| priesthood| ppi_pri| ppi_notes| int_pri| int_notes| attending| valid" shape = "record" ]; companionship [ @@ -43,7 +43,7 @@ digraph schema { shape = "record" ]; aaronic [ - label = " aaronic|| name|

phone| valid" + label = " aaronic|| name|

phone| email| valid" shape = "record" ]; appointment [ -- 2.34.1