projects
/
eq
/
.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Changed hard coded areacode number into a configurable variable
[eq/.git]
/
bin
/
import_ward_data
diff --git
a/bin/import_ward_data
b/bin/import_ward_data
index bd707b4da75f149659a18d4c63a6acc20481d66a..ef7eac4a6cb403645fe1692e92cfb50bb80af0bd 100755
(executable)
--- a/
bin/import_ward_data
+++ b/
bin/import_ward_data
@@
-2,13
+2,12
@@
use DBI;
use Getopt::Std;
use DBI;
use Getopt::Std;
-###################################################
-# GLOBALS
-$dbname = "phpgroupware";
-$dbhost = "192.168.0.2";
-$dbport = 3306;
-$dbuser = "phpgroupware";
-$dbpass = "phpgroupware";
+
+$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"; }
+
%hometeaching_data = ();
%membership_data = ();
getopts('vsn:o:');
%hometeaching_data = ();
%membership_data = ();
getopts('vsn:o:');
@@
-98,7
+97,7
@@
sub update_eq_aaronic_table
$membership_data{$index}{$key} =~ /^Priest\s*$/i)) {
$aaronic_name = $membership_data{$index}{'Preferred Name'};
$phone = $membership_data{$index}{'Phone 1'};
$membership_data{$index}{$key} =~ /^Priest\s*$/i)) {
$aaronic_name = $membership_data{$index}{'Preferred Name'};
$phone = $membership_data{$index}{'Phone 1'};
- if($phone =~ /(\d\d\d-\d\d\d\d)/) { $phone = "
970
-$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"; }
$sth = $dbh->prepare("select * from eq_aaronic where name='$aaronic_name'");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
if($phone =~ /^\(\d\d\d\) (\d\d\d-\d\d\d\d)/) { $phone = "$1-$2"; }
$sth = $dbh->prepare("select * from eq_aaronic where name='$aaronic_name'");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
@@
-132,8
+131,10
@@
sub update_eq_aaronic_table
#| Field | Type | Null | Key | Default | Extra |
#+-------------+------------------+------+-----+---------+----------------+
#| elder | int(16) unsigned | | PRI | NULL | auto_increment |
#| Field | Type | Null | Key | Default | Extra |
#+-------------+------------------+------+-----+---------+----------------+
#| elder | int(16) unsigned | | PRI | NULL | auto_increment |
+#| indiv_id | int(16) unsigned | | | NULL | |
#| name | varchar(60) | YES | | NULL | |
#| phone | varchar(12) | YES | | NULL | |
#| name | varchar(60) | YES | | NULL | |
#| phone | varchar(12) | YES | | NULL | |
+#| email | varchar(120) | YES | | NULL | |
#| ppi_pri | int(10) unsigned | YES | | 1 | |
#| ppi_notes | varchar(128) | YES | | NULL | |
#| int_pri | int(10) unsigned | YES | | 1 | |
#| ppi_pri | int(10) unsigned | YES | | 1 | |
#| ppi_notes | varchar(128) | YES | | NULL | |
#| int_pri | int(10) unsigned | YES | | 1 | |
@@
-164,7
+165,7
@@
sub update_eq_elder_table
($organization =~ /Sunday School/) ||
($organization =~ /Primary/)
) { $attending = 1; }
($organization =~ /Sunday School/) ||
($organization =~ /Primary/)
) { $attending = 1; }
- if($phone =~ /(\d\d\d-\d\d\d\d)/) { $phone = "
970
-$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"; }
$sth = $dbh->prepare("select * from eq_elder where name='$elder_name'");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
if($phone =~ /^\(\d\d\d\) (\d\d\d-\d\d\d\d)/) { $phone = "$1-$2"; }
$sth = $dbh->prepare("select * from eq_elder where name='$elder_name'");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
@@
-174,7
+175,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";
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,'$
elder_name','$phone
','1','','1','',$attending,1)");
+ $sth = $dbh->prepare("insert into eq_elder values (NULL,'$
id','$elder_name','$phone','
','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";
} elsif($rows == 1) {
# An existing record was found for this elder, update it
@@
-189,6
+190,8
@@
sub update_eq_elder_table
$sth->execute or die "-E- DB error: $DBI::errstr\n";
$sth = $dbh->prepare("update eq_elder set attending='$attending' where name='$elder_name'");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
$sth->execute or die "-E- DB error: $DBI::errstr\n";
$sth = $dbh->prepare("update eq_elder set attending='$attending' where name='$elder_name'");
$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";
} else {
# More than one record was found. Error! This shouldn't happen.
print " -E- More than one record found ($rows) for Elder: $elder_name\n";
} else {
# More than one record was found. Error! This shouldn't happen.
print " -E- More than one record found ($rows) for Elder: $elder_name\n";
@@
-494,7
+497,7
@@
sub update_eq_parent_table
$hofh_id = $membership_data{$index}{'HofH ID'};
$id = $membership_data{$index}{'Indiv ID'};
$phone = $membership_data{$index}{'Phone 1'};
$hofh_id = $membership_data{$index}{'HofH ID'};
$id = $membership_data{$index}{'Indiv ID'};
$phone = $membership_data{$index}{'Phone 1'};
- if($phone =~ /(\d\d\d-\d\d\d\d)/) { $phone = "
970
-$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"; }
$address = $membership_data{$index}{'Street 1'};
if($membership_data{$index}{'Street 2'} ne "") {
if($phone =~ /^\(\d\d\d\) (\d\d\d-\d\d\d\d)/) { $phone = "$1-$2"; }
$address = $membership_data{$index}{'Street 1'};
if($membership_data{$index}{'Street 2'} ne "") {
@@
-664,7
+667,7
@@
sub check_for_changed_ids
###################################################
# Open a connection to the database
###################################################
# Open a connection to the database
-$dbh=DBI->connect("dbi:mysql:dbname=$dbname
;host=$dbhost
port=$dbport",$dbuser,$dbpass,{
+$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;
AutoCommit=>0,
PrintError=>0}) or print "Connect Failure:".$DBI::errstr."\n" and exit 2;
@@
-726,6
+729,8
@@
if($opt_s) { $dbh->disconnect(); exit; }
&update_eq_parent_table();
&update_eq_child_table();
&update_eq_parent_table();
&update_eq_child_table();
+print "\n-> Import Successful! DONE...\n";
+
###################################################
# Disconnect from the database
$dbh->disconnect();
###################################################
# Disconnect from the database
$dbh->disconnect();
@@
-733,13
+738,3
@@
$dbh->disconnect();
######################################################################
######################################################################
-
-
-
-
-
-
-
-
-
-