5 ###################################################
7 $dbname = "phpgroupware";
8 $dbhost = "192.168.0.2";
10 $dbuser = "phpgroupware";
11 $dbpass = "phpgroupware";
12 %hometeaching_data = ();
13 %membership_data = ();
16 $monthname2num{'Jan'} = '01';
17 $monthname2num{'Feb'} = '02';
18 $monthname2num{'Mar'} = '03';
19 $monthname2num{'Apr'} = '04';
20 $monthname2num{'May'} = '05';
21 $monthname2num{'Jun'} = '06';
22 $monthname2num{'Jul'} = '07';
23 $monthname2num{'Aug'} = '08';
24 $monthname2num{'Sep'} = '09';
25 $monthname2num{'Oct'} = '10';
26 $monthname2num{'Nov'} = '11';
27 $monthname2num{'Dec'} = '12';
29 ######################################################################
31 ######################################################################
34 my ($filename, $hashref) = @_;
36 open(FILE,$filename) || die "-E- Could not open $filename for reading\n";
38 my $found_header = 0; my $index = 0;
42 @data = split /\",/, $line;
43 if(!$found_header) { @header = @data; $found_header = 1; }
45 foreach $i (0..$#data-1) {
47 $header[$i] =~ s/\"//g;
48 $hashref->{$index}{$header[$i]} = $data[$i];
49 #print "$index: $i: $header[$i]: $data[$i]\n";
58 ######################################################################
63 foreach $key (sort {$a <=> $b} keys %$hashref) {
64 print "Index: $key\n";
65 foreach $field (keys %{$hashref->{$key}}) {
66 print "$field: $hashref->{$key}{$field}\n";
72 ######################################################################
75 #+-------+--------------------+------+-----+---------+-------+
76 #| Field | Type | Null | Key | Default | Extra |
77 #+-------+--------------------+------+-----+---------+-------+
78 #| aaronic | int(16) unsigned | | PRI | 0 | A |
79 #| name | varchar(60) | YES | | NULL | |
80 #| valid | tinyint(1) | YES | | NULL | |
81 #+-------+--------------------+------+-----+---------+-------+
82 sub update_eq_aaronic_table
84 print "-> Updating eq_aaronic table\n";
85 foreach $index (keys %membership_data)
87 $hashref = $membership_data{$index};
88 foreach $key (keys %$hashref) {
89 if($key =~ /Priesthood/i &&
90 ($membership_data{$index}{$key} =~ /^Teacher\s*$/i ||
91 $membership_data{$index}{$key} =~ /^Priest\s*$/i)) {
92 $aaronic_name = $membership_data{$index}{'Preferred Name'};
93 $sth = $dbh->prepare("select * from eq_aaronic where name='$aaronic_name'");
94 $sth->execute or die "-E- DB error: $DBI::errstr\n";
96 while($sqlhashref = $sth->fetchrow_hashref) { push(@data, $sqlhashref); }
97 my $rows = scalar @data;
99 # No existing records found for this aaronic, make a new entry
100 print " Adding new Aaronic: $aaronic_name\n";
101 $sth = $dbh->prepare("insert into eq_aaronic values (NULL,'$aaronic_name',1)");
102 $sth->execute or die "-E- DB error: $DBI::errstr\n";
103 } elsif($rows == 1) {
104 # An existing record was found for this aaronic, update it if it is valid
105 if($data[0]->{valid} == 1) {
106 print " Updating existing aaronic: $aaronic_name\n";
109 # More than one record was found. Error! This shouldn't happen.
110 print " -E- More than one record found ($rows) for aaronic name: $aaronic_name\n";
119 #+------------+------------------+------+-----+---------+-------+
120 #| Field | Type | Null | Key | Default | Extra |
121 #+------------+------------------+------+-----+---------+-------+
122 #| elder | int(16) unsigned | | PRI | 0 | A |
123 #| name | varchar(60) | YES | | NULL | |
124 #| valid | tinyint(1) | YES | | NULL | |
125 #+------------+------------------+------+-----+---------+-------+
126 sub update_eq_elder_table
128 print "-> Updating eq_elder table\n";
130 # Set all records to be invalid. Only mark them as valid if they appear on the new list.
131 $sth = $dbh->prepare("update eq_elder set valid=0");
132 $sth->execute or die "-E- DB error: $DBI::errstr\n";
134 foreach $index (keys %membership_data)
136 $hashref = $membership_data{$index};
137 foreach $key (keys %$hashref) {
138 if($key =~ /Priesthood/i && $membership_data{$index}{$key} =~ /Elder/i) {
139 $elder_name = $membership_data{$index}{'Preferred Name'};
140 $sth = $dbh->prepare("select * from eq_elder where name='$elder_name'");
141 $sth->execute or die "-E- DB error: $DBI::errstr\n";
143 while($sqlhashref = $sth->fetchrow_hashref) { push(@data, $sqlhashref); }
144 my $rows = scalar @data;
146 # No existing records found for this elder, make a new entry
147 print " Adding new Elder: $elder_name\n";
148 $sth = $dbh->prepare("insert into eq_elder values (NULL,'$elder_name',1)");
149 $sth->execute or die "-E- DB error: $DBI::errstr\n";
150 } elsif($rows == 1) {
151 # An existing record was found for this elder, update it
152 print " Updating existing Elder: $elder_name\n";
153 $sth = $dbh->prepare("update eq_elder set valid=1 where name='$elder_name'");
154 $sth->execute or die "-E- DB error: $DBI::errstr\n";
156 # More than one record was found. Error! This shouldn't happen.
157 print " -E- More than one record found ($rows) for Elder: $elder_name\n";
166 #+------------+------------------+------+-----+---------+-------+
167 #| Field | Type | Null | Key | Default | Extra |
168 #+------------+------------------+------+-----+---------+-------+
169 #| district | int(16) unsigned | | PRI | 0 | |
170 #| name | varchar(30) | YES | | NULL | |
171 #| supervisor | int(16) unsigned | YES | | NULL | |
172 #| valid | tinyint(1) | YES | | NULL | |
173 #+------------+------------------+------+-----+---------+-------+
174 sub update_eq_district_table
176 # Districts should be created by hand. This subroutine only
177 # updates the supervisor's ID in each district.
178 print "-> Updating eq_district table\n";
179 $sth = $dbh->prepare("select * from eq_district");
180 $sth->execute or die "-E- DB error: $DBI::errstr\n";
181 while($sqlhashref = $sth->fetchrow_hashref) {
182 $supervisor_name = $sqlhashref->{name};
183 $district = $sqlhashref->{district};
184 $sth2 = $dbh->prepare("select * from eq_elder where name='$supervisor_name'");
185 $sth2->execute or die "-E- DB error: $DBI::errstr\n";
186 $sqlhashref2 = $sth2->fetchrow_hashref;
187 $supervisor_id = $sqlhashref2->{elder};
189 $sth2 = $dbh->prepare("update eq_district set supervisor='$supervisor_id' where district='$district'");
190 $sth2->execute or die "-E- DB error: $DBI::errstr\n";
197 #+---------------+------------------+------+-----+---------+-------+
198 #| Field | Type | Null | Key | Default | Extra |
199 #+---------------+------------------+------+-----+---------+-------+
200 #| companionship | int(16) unsigned | | | 0 | |
201 #| elder | int(16) unsigned | YES | | NULL | |
202 #| aaronic | int(16) unsigned | YES | | NULL | |
203 #| district | int(16) unsigned | YES | | NULL | |
204 #| valid | tinyint(1) | YES | | NULL | |
205 #+---------------+------------------+------+-----+---------+-------+
206 sub update_eq_companionship_table
208 print "-> Updating eq_companionship table\n";
210 # First, mark all existing companionships as invalid in case they have been dissolved
211 $sth = $dbh->prepare("update eq_companionship set valid=0");
212 $sth->execute or die "-E- DB error: $DBI::errstr\n";
213 # Second, mark all the aaronic invalid. We'll only mark the ones as valid that are assigned to hometeach
214 $sth = $dbh->prepare("update eq_aaronic set valid=0");
215 $sth->execute or die "-E- DB error: $DBI::errstr\n";
217 foreach $index (keys %hometeaching_data)
219 $hashref = $hometeaching_data{$index};
220 foreach $key (keys %$hashref) {
221 if($key =~ /Quorum/i && $hometeaching_data{$index}{$key} =~ /Elders/i) {
222 foreach $field ("Home Teacher 1","Home Teacher 2") {
223 $elder_name = $hometeaching_data{$index}{$field};
224 if($elder_name eq "") { next; }
225 $sth2 = $dbh->prepare("select * from eq_elder where name='$elder_name'");
226 $sth2->execute or die "-E- DB error: $DBI::errstr\n";
227 $sqlhashref2 = $sth2->fetchrow_hashref;
228 $elder = $sqlhashref2->{elder};
231 $sth2 = $dbh->prepare("select * from eq_aaronic where name='$elder_name'");
232 $sth2->execute or die "-E- DB error: $DBI::errstr\n";
233 $sqlhashref2 = $sth2->fetchrow_hashref;
234 $aaronic = $sqlhashref2->{aaronic};
236 if($aaronic eq "") { print "-W- Unable to find $elder_name in eq_elder or eq_aaronic tables\n"; }
238 $id = $hometeaching_data{$index}{'Comp ID'};
239 $district = $hometeaching_data{$index}{'HT District'};
240 $sth = $dbh->prepare("select * from eq_companionship where elder='$elder' and aaronic='$aaronic' and companionship='$id'");
241 $sth->execute or die "-E- DB error: $DBI::errstr\n";
243 while($sqlhashref = $sth->fetchrow_hashref) { push(@data, $sqlhashref); }
244 my $rows = scalar @data;
246 # No existing records found for this companionship, make a new entry
247 print " Adding Elder to companionship: $elder_name -> $id\n";
248 $sth = $dbh->prepare("insert into eq_companionship values ($id,'$elder','$aaronic','$district',1)");
249 $sth->execute or die "-E- DB error: $DBI::errstr\n";
251 # An existing companionship was found for this companionship, update it
252 $sth2 = $dbh->prepare("select * from eq_companionship where district='$district' and companionship='$id'");
253 $sth2->execute or die "-E- DB error: $DBI::errstr\n";
254 if($elder ne "NULL") {
255 print " Updating Companionship with Elder: $elder_name ($elder) -> $id\n";
256 $sth = $dbh->prepare("update eq_companionship set district='$district' where elder='$elder' and companionship='$id'");
257 $sth->execute or die "-E- DB error 'district': $DBI::errstr\n";
258 $sth = $dbh->prepare("update eq_companionship set elder='$elder' where elder='$elder' and companionship='$id'");
259 $sth->execute or die "-E- DB error 'elder': $DBI::errstr\n";
260 $sth = $dbh->prepare("update eq_companionship set valid=1 where elder='$elder' and companionship='$id'");
261 $sth->execute or die "-E- DB error 'valid': $DBI::errstr\n";
263 print " Updating Companionship with Aaronic: $elder_name ($aaronic) -> $id\n";
264 $sth = $dbh->prepare("update eq_companionship set district='$district' where aaronic='$aaronic' and companionship='$id'");
265 $sth->execute or die "-E- DB error: $DBI::errstr\n";
266 $sth = $dbh->prepare("update eq_companionship set aaronic='$aaronic' where aaronic='$aaronic' and companionship='$id'");
267 $sth->execute or die "-E- DB error: $DBI::errstr\n";
268 $sth = $dbh->prepare("update eq_companionship set valid=1 where aaronic='$aaronic' and companionship='$id'");
269 $sth->execute or die "-E- DB error: $DBI::errstr\n";
270 $sth = $dbh->prepare("update eq_aaronic set valid=1 where aaronic='$aaronic'");
271 $sth->execute or die "-E- DB error: $DBI::errstr\n";
283 #+---------------+------------------+------+-----+---------+-------+
284 #| Field | Type | Null | Key | Default | Extra |
285 #+---------------+------------------+------+-----+---------+-------+
286 #| family | int(16) unsigned | | PRI | 0 | A |
287 #| hofh_id | int(16) unsigned | YES | | NULL | |
288 #| name | varchar(30) | YES | | NULL | |
289 #| companionship | int(16) unsigned | YES | | NULL | |
290 #| valid | tinyint(1) | YES | | NULL | |
291 #+---------------+------------------+------+-----+---------+-------+
292 sub update_eq_family_table
294 print "-> Updating eq_family table\n";
296 # Set all records to be invalid. Only mark them as valid if they appear on the new list.
297 $sth = $dbh->prepare("update eq_family set valid=0");
298 $sth->execute or die "-E- DB error: $DBI::errstr\n";
300 foreach $index (keys %membership_data)
302 $hashref = $membership_data{$index};
303 foreach $key (keys %$hashref) {
304 if($key =~ /HH Position/i && $membership_data{$index}{$key} =~ /Head of Household/i) {
305 $family_name = $membership_data{$index}{'Preferred Name'};
306 $family_name =~ s/\'/\\'/g; #'
307 $id = $membership_data{$index}{'HofH ID'};
309 # Find out how many families match this family's name
310 $sth = $dbh->prepare("select * from eq_family where name='$family_name'");
311 $sth->execute or die "-E- DB error: $DBI::errstr\n";
313 while($sqlhashref = $sth->fetchrow_hashref) { push(@data, $sqlhashref); }
314 my $rows = scalar @data;
317 # No existing records found for this family, make a new entry
318 print " Adding new Family: $family_name\n";
319 $sth = $dbh->prepare("insert into eq_family values (NULL,$id,'$family_name','0',1)");
320 $sth->execute or die "-E- DB error: $DBI::errstr\n";
321 } elsif($rows == 1) {
322 # An existing record was found for this family, update it
323 print " Updating existing family: $family_name\n";
324 $sth = $dbh->prepare("update eq_family set hofh_id=$id where name='$family_name'");
325 $sth->execute or die "-E- DB error: $DBI::errstr\n";
326 $sth = $dbh->prepare("update eq_family set valid=1 where name='$family_name'");
327 $sth->execute or die "-E- DB error: $DBI::errstr\n";
329 # More than one record was found. Error! This shouldn't happen.
330 print " -E- More than one record found ($rows) for family name: $family_name\n";
332 # Now update the hometeaching field for this family
333 foreach $index (keys %hometeaching_data)
335 $hashref = $hometeaching_data{$index};
336 foreach $key (keys %$hashref) {
337 if($hometeaching_data{$index}{'Household'} =~ /(\S+)\s+(\S+),\s+(\S+)\s+(.*)/) {
338 print "I: Adjusting hometeaching match from: $hometeaching_data{$index}{'Household'} to $1, $3 $4\n";
339 $hometeaching_data{$index}{'Household'} = "$1, $3 $4";
341 if($key =~ /Quorum/i &&
342 $hometeaching_data{$index}{$key} =~ /Elders/i &&
343 $hometeaching_data{$index}{'Household'} =~ /$family_name/ &&
344 $data[0]->{companionship} != $hometeaching_data{$index}{'Comp ID'}
347 print " Updating hometeaching assignment for $family_name family\n";
348 $companionship = $hometeaching_data{$index}{'Comp ID'};
349 $sth = $dbh->prepare("update eq_family set companionship='$companionship' where name='$family_name'");
350 $sth->execute or die "-E- DB error: $DBI::errstr\n";
361 #+----------+------------------+------+-----+---------+-------+
362 #| Field | Type | Null | Key | Default | Extra |
363 #+----------+------------------+------+-----+---------+-------+
364 #| parent | int(16) unsigned | | PRI | 0 | A |
365 #| family | int(16) unsigned | YES | | NULL | |
366 #| name | varchar(30) | YES | | NULL | |
367 #| birthday | date | YES | | NULL | |
368 #| valid | tinyint(1) | YES | | NULL | |
369 #+----------+------------------+------+-----+---------+-------+
370 sub update_eq_parent_table
372 print "-> Updating eq_parent table\n";
374 # Set all records to be invalid. Only mark them as valid if they appear on the new list.
375 $sth = $dbh->prepare("update eq_parent set valid=0");
376 $sth->execute or die "-E- DB error: $DBI::errstr\n";
378 foreach $index (keys %membership_data)
380 $hashref = $membership_data{$index};
381 foreach $key (keys %$hashref) {
382 if($key =~ /HH Position/i &&
383 $membership_data{$index}{$key} =~ /Head of Household/i ||
384 $membership_data{$index}{$key} =~ /Spouse/i
386 # Get some information from the hash about this parent
387 $parent_name = $membership_data{$index}{'Preferred Name'};
388 $parent_name =~ s/\'/\\'/g; #'
389 $birthday = $membership_data{$index}{'Birth'};
390 $birthday =~ /(\d+) (\S+) (\d+)/; $day=$1; $month=$monthname2num{$2}; $year=$3;
391 $hofh_id = $membership_data{$index}{'HofH ID'};
393 # Find the family id for this parent's HofH_ID.
394 $sth = $dbh->prepare("select * from eq_family where hofh_id='$hofh_id'");
395 $sth->execute or die "-E- DB error: $DBI::errstr\n";
396 $sqlhashref = $sth->fetchrow_hashref();
397 $family_id = $sqlhashref->{'family'};
399 # Find out how many parents match this parent's name
400 $sth = $dbh->prepare("select * from eq_parent where name='$parent_name'");
401 $sth->execute or die "-E- DB error: $DBI::errstr\n";
403 while($sqlhashref = $sth->fetchrow_hashref) { push(@data, $sqlhashref); }
404 my $rows = scalar @data;
407 # No existing records found for this parent, make a new entry
408 print " Adding new Parent: $parent_name\n";
409 $sth = $dbh->prepare("insert into eq_parent values (NULL,$family_id,'$parent_name','$year-$month-$day',1)");
410 $sth->execute or die "-E- DB error: $DBI::errstr\n";
411 } elsif($rows == 1) {
412 # An existing record was found for this parent, update it
413 print " Updating existing parent: $parent_name\n";
414 $sth = $dbh->prepare("update eq_parent set family='$family_id' where name='$parent_name'");
415 $sth->execute or die "-E- DB error: $DBI::errstr\n";
416 $sth = $dbh->prepare("update eq_parent set birthday='$year-$month-$day' where name='$parent_name'");
417 $sth->execute or die "-E- DB error: $DBI::errstr\n";
418 $sth = $dbh->prepare("update eq_parent set valid=1 where name='$parent_name'");
419 $sth->execute or die "-E- DB error: $DBI::errstr\n";
421 # More than one record was found. Error! This shouldn't happen.
422 print " -E- More than one record found with same parent name: $parent_name\n";
431 #+----------+------------------+------+-----+---------+-------+
432 #| Field | Type | Null | Key | Default | Extra |
433 #+----------+------------------+------+-----+---------+-------+
434 #| child | int(16) unsigned | | PRI | 0 | A |
435 #| family | int(16) unsigned | YES | | NULL | |
436 #| name | varchar(30) | YES | | NULL | |
437 #| birthday | date | YES | | NULL | |
438 #| valid | tinyint(1) | YES | | NULL | |
439 #+----------+------------------+------+-----+---------+-------+
440 sub update_eq_child_table
442 print "-> Updating eq_child table\n";
444 # Set all records to be invalid. Only mark them as valid if they appear on the new list.
445 $sth = $dbh->prepare("update eq_child set valid=0");
446 $sth->execute or die "-E- DB error: $DBI::errstr\n";
448 foreach $index (keys %membership_data)
450 $hashref = $membership_data{$index};
451 foreach $key (keys %$hashref) {
452 if($key =~ /HH Position/i && $membership_data{$index}{$key} =~ /Other/i ) {
453 $child_name = $membership_data{$index}{'Full Name'};
454 $child_name =~ s/\'/\\'/g; #'
455 $birthday = $membership_data{$index}{'Birth'};
456 $birthday =~ /(\d+) (\S+) (\d+)/; $day=$1; $month=$monthname2num{$2}; $year=$3;
457 $id = $membership_data{$index}{'Indiv ID'};
458 $hofh_id = $membership_data{$index}{'HofH ID'};
460 # Find the family id for this child's HofH_ID.
461 $sth = $dbh->prepare("select * from eq_family where hofh_id='$hofh_id'");
462 $sth->execute or die "-E- DB error: $DBI::errstr\n";
463 $sqlhashref = $sth->fetchrow_hashref();
464 $family_id = $sqlhashref->{'family'};
466 # Find out how many children have the same name for the same family
467 $sth = $dbh->prepare("select * from eq_child where name='$child_name'");
468 $sth->execute or die "-E- DB error: $DBI::errstr\n";
470 while($sqlhashref = $sth->fetchrow_hashref) { push(@data, $sqlhashref); }
471 my $rows = scalar @data;
474 # No existing records found for this child, make a new entry
475 print " Adding new Child: $child_name\n";
476 $sth = $dbh->prepare("insert into eq_child values (NULL,$family_id,'$child_name','$year-$month-$day',1)");
477 $sth->execute or die "-E- DB error: $DBI::errstr\n";
478 } elsif($rows == 1) {
479 # An existing record was found for this child, update it
480 print " Updating existing child: $child_name\n";
481 $sth = $dbh->prepare("update eq_child set family='$family_id' where name='$child_name'");
482 $sth->execute or die "-E- DB error: $DBI::errstr\n";
483 $sth = $dbh->prepare("update eq_child set birthday='$year-$month-$day' where name='$child_name'");
484 $sth->execute or die "-E- DB error: $DBI::errstr\n";
485 $sth = $dbh->prepare("update eq_child set valid=1 where name='$child_name'");
486 $sth->execute or die "-E- DB error: $DBI::errstr\n";
488 # More than one record was found. Error! This shouldn't happen.
489 print " -E- More than one record found ($rows) with same child name: $child_name\n";
497 ######################################################################
498 sub check_for_changed_ids
500 # If the Indiv ID & HofH ID has changed between data sets, we could have problems
501 my ($oldhashref, $newhashref) = @_;
502 my $found_problem = 0;
504 foreach $oldindex (keys %$oldhashref)
506 $indiv_id = $oldhashref->{$oldindex}{'Indiv ID'};
507 $hofh_id = $oldhashref->{$oldindex}{'HofH ID'};
508 $full_name = $oldhashref->{$oldindex}{'Full Name'};
509 $hh_position = $oldhashref->{$oldindex}{'HH Position'};
510 if($hh_position =~ /Other/i) { next; }
512 foreach $newindex (keys %$newhashref)
514 if($newhashref->{$newindex}{'Full Name'} eq $full_name &&
515 $indiv_id != $newhashref->{$newindex}{'Indiv ID'})
517 print "-W- Indiv ID for $full_name changed from $indiv_id to $newhashref->{$newindex}{'Indiv ID'}\n";
521 if($newhashref->{$newindex}{'Full Name'} eq $full_name &&
522 $hofh_id != $newhashref->{$newindex}{'HofH ID'})
524 print "-W- HofH ID for $full_name changed from $hofh_id to $newhashref->{$newindex}{'HofH ID'}\n";
530 return $found_problem;
533 ######################################################################
535 ######################################################################
537 ###################################################
538 # Open a connection to the database
539 $dbh=DBI->connect("dbi:mysql:dbname=$dbname;host=$dbhost port=$dbport",$dbuser,$dbpass,{
541 PrintError=>0}) or print "Connect Failure:".$DBI::errstr."\n" and exit 2;
543 ###################################################
544 # Check old directory against new directory to ensure
545 # that the Indiv ID & HofH ID have not changed between updates
547 print "-> Comparing old data files to new ones: $opt_o => $opt_n\n";
548 my %old_membership_data = ();
549 my %new_membership_data = ();
550 &csv_to_hash("$opt_o/Membership.csv",\%old_membership_data);
551 &csv_to_hash("$opt_n/Membership.csv",\%new_membership_data);
553 $changed_ids=&check_for_changed_ids(\%old_membership_data, \%new_membership_data);
557 print "-E- Some Indiv IDs and HofH IDs have changed for Head of Households between \n";
558 print " $opt_o and $opt_n data sets.\n";
559 print " This script is not currently setup to handle this properly.\n";
561 print " Exiting without updating...\n\n";
566 ###################################################
567 # Process command line options
568 if(defined $opt_n) { $datadir = $opt_n; }
569 else { $datadir = shift(@ARGV); }
570 print "-> Processing all ward data files in $datadir\n";
572 ###################################################
573 # Parse Ward Data Files
574 &csv_to_hash("$datadir/Membership.csv",\%membership_data);
575 &csv_to_hash("$datadir/HomeTeaching.csv",\%hometeaching_data);
578 print "-> Membership Data Dump\n\n";
579 &print_hash(\%membership_data);
580 print "-> HomeTeaching Data Dump\n\n";
581 &print_hash(\%hometeaching_data);
584 if($opt_s) { $dbh->disconnect(); exit; }
586 # Now update the various eq DB tables
587 &update_eq_elder_table();
588 &update_eq_aaronic_table();
589 &update_eq_district_table();
590 &update_eq_companionship_table();
591 &update_eq_family_table();
592 &update_eq_parent_table();
593 &update_eq_child_table();
595 ###################################################
596 # Disconnect from the database
599 ######################################################################