X-Git-Url: http://git.pippins.net/embedvideo/.git/static/gitweb.js?a=blobdiff_plain;f=bin%2Fimport_ward_data;h=9b830aada27441ac44ca6c56ff56bbbb3f718d05;hb=96aa338c7566eb9eec4e2200140358166b223790;hp=bd707b4da75f149659a18d4c63a6acc20481d66a;hpb=82963f2191eff35b295440782e4309ea3632cf55;p=eq%2F.git diff --git a/bin/import_ward_data b/bin/import_ward_data index bd707b4..9b830aa 100755 --- a/bin/import_ward_data +++ b/bin/import_ward_data @@ -2,13 +2,12 @@ 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:'); @@ -448,6 +447,16 @@ sub update_eq_family_table $companionship = $hometeaching_data{$index}{'Comp ID'}; $sth = $dbh->prepare("update eq_family set companionship='$companionship' where name_id='$name_id'"); $sth->execute or die "-E- DB error: $DBI::errstr\n"; + + # In addition to changing the hometeaching assignment, update the eq_visit table + # so that all previous visits made by the old hometeaching companionship, get + # updated with the id of the new companionship. This will allow us to go in and + # edit the history as needed for the family being hometaught under their new + # companionship. Otherwise, we will not be able to update this history. + #$family_id = $data[0]->{family}; + #print " update eq_visit set companionship='$companionship' where family='$family_id' and companionship!='0'\n"; + #$sth = $dbh->prepare("update eq_visit set companionship='$companionship' where companionship='$old_companionship'"); + #$sth->execute or die "-E- DB error: $DBI::errstr\n"; } } } @@ -664,7 +673,7 @@ sub check_for_changed_ids ################################################### # 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; @@ -726,6 +735,8 @@ if($opt_s) { $dbh->disconnect(); exit; } &update_eq_parent_table(); &update_eq_child_table(); +print "\n-> Import Successful! DONE...\n"; + ################################################### # Disconnect from the database $dbh->disconnect(); @@ -733,13 +744,3 @@ $dbh->disconnect(); ###################################################################### - - - - - - - - - -