X-Git-Url: http://git.pippins.net/embedvideo/.git/?a=blobdiff_plain;f=bin%2Fimport_ward_data;h=6fbb96b3ba1e7400a251c92c2b6f546ca583a60d;hb=355decc5cec577acbcbafe58d335b2d1523c9e71;hp=b5847c7fe047bc554f0bbb6529095b50a19e5db9;hpb=7de71664eadedf8c057de6e534ecbbc9869c25a5;p=eq%2F.git diff --git a/bin/import_ward_data b/bin/import_ward_data index b5847c7..6fbb96b 100755 --- a/bin/import_ward_data +++ b/bin/import_ward_data @@ -138,13 +138,22 @@ sub update_tc_individual_table $phone = $membership_data{$index}{'Household Phone'}; $priesthood = $membership_data{$index}{'Priesthood'}; $hhposition = $membership_data{$index}{'HH Position'}; - $organization = $organization_by_id{$id}; + $steward = ""; # This will be set later + # Default to the "Elders" quorum if the Organization data per member isn't available + # Only add "Elders" to the quorum since we don't have any other data availalbe to us to make a call + # TODO: make steward flexible with a setting in the config file + if((! -e "$datadir/Organization\ class\ per\ member.csv") && ($priesthood =~ /Elder/i)) { + $steward = "Elder"; + $organization = "Elders"; + } + # Preferred method is to pull organization data from the csv file + else { $organization = $organization_by_id{$id}; } $attending = 0; if(($organization =~ /Elders/) || ($organization =~ /Young Men/) || ($organization =~ /Sunday School/) || ($organization =~ /Primary/) - ) { $attending = 1; } + ) { $attending = 1; } 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}{'indiv E-mail'}; @@ -157,7 +166,7 @@ sub update_tc_individual_table if($rows == 0) { # No existing records found for this individual, make a new entry print " Adding new individual: $individual_name\n"; - $sth = $dbh->prepare("insert into tc_individual values (NULL,'$id',\"$individual_name\",'$address','$phone','$email','$hhposition','$priesthood','',NULL,$attending,1)"); + $sth = $dbh->prepare("insert into tc_individual values (NULL,'$id',\"$individual_name\",'$address','$phone','$email','$hhposition','$priesthood','$steward',NULL,$attending,1)"); $sth->execute or die "-E- DB error: $DBI::errstr\n"; } elsif($rows == 1) { # An existing record was found for this individual, update it @@ -221,6 +230,7 @@ sub update_tc_calling_table() $name =~ s/\'/\\'/g; #' $organization = $organization_data{$index}{'Organization'}; $organization_by_name{$name} = $organization; + $indiv_id = $organization_data{$index}{'Indiv ID'}; $organization_by_id{$indiv_id} = $organization; $position = $organization_data{$index}{'Position'}; $sustained = $organization_data{$index}{'Sustained'}; @@ -663,13 +673,14 @@ if(defined $opt_o) { ################################################### # Process command line options +our $datadir; if(defined $opt_n) { $datadir = $opt_n; } else { $datadir = shift(@ARGV); } print "\n-> Processing all ward data files in $datadir\n"; ################################################### # Parse Ward Data Files -&csv_to_hash("$datadir/Organization\ class\ per\ member.csv", \%organization_class_data); +&optional_csv_to_hash("$datadir/Organization\ class\ per\ member.csv", \%organization_class_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);