Added default values for interview_pri and visit_pri and changed the default value...
[eq/.git] / bin / import_ward_data
index 97823c43a4fbe7cac26982707491f360b6c7a2ef..fe2cf3ed31ec2d42234d6b4cd165211b39010607 100755 (executable)
@@ -160,7 +160,7 @@ sub update_tc_indiv_table
        if($rows == 0) {
            # No existing records found for this indiv, make a new entry
            print "   Adding new indiv: $indiv_name\n";
-           $sth = $dbh->prepare("insert into tc_indiv values (NULL,'$id',\"$indiv_name\",'$year-$month-$day','$address','$phone','$email','','$hhposition','$priesthood','1','','1','',$attending,1)");
+           $sth = $dbh->prepare("insert into tc_indiv values (NULL,'$id',\"$indiv_name\",'$year-$month-$day','$address','$phone','$email','','$hhposition','$priesthood','','$default_interview_pri','','$default_interview_pri','',$attending,1)");
            $sth->execute or die "-E- DB error: $DBI::errstr\n";
        } elsif($rows == 1) {
            # An existing record was found for this indiv, update it
@@ -381,7 +381,7 @@ sub update_tc_family_table
                if($rows == 0) {
                    # No existing records found for this family, make a new entry
                    print "   Adding new Family: $family_name\n";
-                   $sth = $dbh->prepare("insert into tc_family values (NULL,$id,'$family_name','$name_id','0','0','1','',1)");
+                   $sth = $dbh->prepare("insert into tc_family values (NULL,$id,'$family_name','$name_id','0','0','$default_visit_pri','',1)");
                    $sth->execute or die "-E- DB error: $DBI::errstr\n";
                } elsif($rows == 1) {
                    # An existing record was found for this family, update it
@@ -609,6 +609,29 @@ sub update_family_in_tc_indiv_table
     }
 }
 
+sub update_organization_class_data
+{
+       print "\n-> Updating organization class info in tc_indiv table\n";
+       
+       foreach $index (keys %organization_class_data)
+       {
+               # get name and organization info for each individual
+               $name = $organization_class_data{$index}{'Preferred Name'};
+               $org_class = $organization_class_data{$index}{'Organization Class'};
+               
+               if ($org_class =~ m/Elder/i) {
+                       #print "   $name:  Elder\n";
+                       $sth = $dbh->prepare("update tc_indiv set steward='Elder' where name=\"$name\"");
+                       $sth->execute or die "-E- DB error: $DBI::errstr\n";
+               }
+               if ($org_class =~ m/High Priest/i) {
+                       #print "   $name:  High Priest\n";
+                       $sth = $dbh->prepare("update tc_indiv set steward='High Priest' where name=\"$name\"");
+                       $sth->execute or die "-E- DB error: $DBI::errstr\n";
+               }
+       }
+}
+
 ######################################################################
 # MAIN
 ######################################################################
@@ -650,7 +673,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);
+&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);
@@ -679,6 +702,7 @@ if($opt_s) { $dbh->disconnect(); exit; }
 &update_tc_family_table();
 &update_tc_visit_table();
 &update_family_in_tc_indiv_table();
+&update_organization_class_data();
 
 print "\n-> Import Successful! DONE...\n";