#| 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
$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 = ();
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 {
#| 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 | |
{
$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/) ||
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
$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 {
###################################################
# 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);
--- /dev/null
+#!/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();
+###################################################
+
+
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
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.
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:
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.
`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;
`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',