######################################################################
-# 3RD_AARONIC
-#+-------+--------------------+------+-----+---------+-------+
-#| Field | Type | Null | Key | Default | Extra |
-#+-------+--------------------+------+-----+---------+-------+
-#| aaronic | int(16) unsigned | | PRI | 0 | A |
-#| name | varchar(60) | YES | | NULL | |
-#| phone | varchar(12) | YES | | NULL | |
-#| email | varchar(120) | YES | | NULL | |
-#| valid | tinyint(1) | YES | | NULL | |
-#+-------+--------------------+------+-----+---------+-------+
-sub update_tc_aaronic_table
-{
- print "\n-> Updating tc_aaronic table\n";
-
- # Set all records to be invalid. Only mark them as valid if they appear on the new list.
- $sth = $dbh->prepare("update tc_aaronic set valid=0");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
-
- foreach $index (keys %membership_data)
- {
- $hashref = $membership_data{$index};
- foreach $key (keys %$hashref) {
- if($key =~ /Priesthood/i &&
- ($membership_data{$index}{$key} =~ /^Deacon\s*$/i ||
- $membership_data{$index}{$key} =~ /^Teacher\s*$/i ||
- $membership_data{$index}{$key} =~ /^Priest\s*$/i)) {
- $aaronic_name = $membership_data{$index}{'Preferred Name'};
- $phone = $membership_data{$index}{'Household Phone'};
- 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}{'Individual E-mail'};
- if ($email eq "") { $email = $membership_data{$index}{'Household E-mail'}; }
- $sth = $dbh->prepare("select * from tc_aaronic where name='$aaronic_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- my @data = ();
- while($sqlhashref = $sth->fetchrow_hashref) { push(@data, $sqlhashref); }
- my $rows = scalar @data;
- if($rows == 0) {
- # No existing records found for this aaronic, make a new entry
- print " Adding new Aaronic: $aaronic_name\n";
- $sth = $dbh->prepare("insert into tc_aaronic values (NULL,'$aaronic_name','$phone','$email',1)");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- } elsif($rows == 1) {
- # An existing record was found for this aaronic, update it, mark it valid!
- print " Updating existing aaronic: $aaronic_name\n";
- $sth = $dbh->prepare("update tc_aaronic set phone='$phone' where name='$aaronic_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_aaronic set email='$email' where name='$aaronic_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_aaronic set valid=1 where name='$aaronic_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 aaronic name: $aaronic_name\n";
- }
- }
- }
- }
- $sth->finish();
-}
-
# 3RD_INDIV
#+-------------+------------------+------+-----+---------+----------------+
#| Field | Type | Null | Key | Default | Extra |
foreach $index (keys %membership_data)
{
$hashref = $membership_data{$index};
- foreach $key (keys %$hashref) {
- if($key =~ /Priesthood/i &&
- ($membership_data{$index}{$key} =~ /Deacon/i ||
- $membership_data{$index}{$key} =~ /Teacher/i ||
- $membership_data{$index}{$key} =~ /Priest/i ||
- $membership_data{$index}{$key} =~ /Elder/i ||
- $membership_data{$index}{$key} =~ /Unordained/i)) {
-
- # check if this is a prospective elder under the stewardship of the EQ
- if($membership_data{$index}{$key} !~ /Elder/i) {
- $found = 0;
- foreach $i (keys %prospective_elder_data) {
- #print "$membership_data{$index}{'Full Name'}\n";
- #print "$prospective_elder_data{$i}{'Full Name'}\n";
- if($membership_data{$index}{'Full Name'} eq $prospective_elder_data{$i}{'Full Name'}) {
- $found = 1;
- last;
- }
- }
- if($found == 0) { next;}
- }
-
- $id = $membership_data{$index}{'Indiv ID'};
- $indiv_name = $membership_data{$index}{'Preferred Name'};
- $phone = $membership_data{$index}{'Household Phone'};
- $priesthood = $membership_data{$index}{'Priesthood'};
- $organization = $organization_by_id{$id};
- $attending = 0;
- if(($organization =~ /Elders/) ||
- ($organization =~ /Young Men/) ||
- ($organization =~ /Sunday School/) ||
- ($organization =~ /Primary/)
- ) { $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'};
- if ($email eq "") { $email = $membership_data{$index}{'Household E-mail'}; }
- $sth = $dbh->prepare("select * from tc_indiv where name='$indiv_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- my @data = ();
- while($sqlhashref = $sth->fetchrow_hashref) { push(@data, $sqlhashref); }
- my $rows = scalar @data;
- 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','$phone','$email','$priesthood','n','1','','1','',$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
- print " Updating existing indiv: $indiv_name\n";
- $sth = $dbh->prepare("update tc_indiv set valid=1 where name='$indiv_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- if($phone ne "") {
- $sth = $dbh->prepare("update tc_indiv set phone='$phone' where name='$indiv_name'");
- } else {
- $sth = $dbh->prepare("update tc_indiv set phone=NULL where name='$indiv_name'");
- }
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_indiv set attending='$attending' where name='$indiv_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_indiv set indiv_id='$id' where name='$indiv_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_indiv set priesthood='$priesthood' where name='$indiv_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_indiv set email='$email' where name='$indiv_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 indiv: $indiv_name\n";
- }
+ $id = $membership_data{$index}{'Indiv ID'};
+ $indiv_name = $membership_data{$index}{'Preferred Name'};
+ $birthday = $membership_data{$index}{'Birth'};
+ $birthday =~ /(\d+) (\S+) (\d+)/; $day=$1; $month=$monthname2num{$2}; $year=$3;
+ $address = $membership_data{$index}{'Street 1'};
+ if($membership_data{$index}{'Street 2'} ne "") {
+ $address .= " " . $membership_data{$index}{'Street 2'};
+ }
+ $phone = $membership_data{$index}{'Household Phone'};
+ $priesthood = $membership_data{$index}{'Priesthood'};
+ $hhposition = $membership_data{$index}{'HH Position'};
+ $organization = $organization_by_id{$id};
+ $attending = 0;
+ if(($organization =~ /Elders/) ||
+ ($organization =~ /Young Men/) ||
+ ($organization =~ /Sunday School/) ||
+ ($organization =~ /Primary/)
+ ) { $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'};
+ if ($email eq "") { $email = $membership_data{$index}{'Household E-mail'}; }
+ $sth = $dbh->prepare("select * from tc_indiv where name=\"$indiv_name\"");
+ $sth->execute or die "-E- DB error: $DBI::errstr\n";
+ my @data = ();
+ while($sqlhashref = $sth->fetchrow_hashref) { push(@data, $sqlhashref); }
+ my $rows = scalar @data;
+ 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->execute or die "-E- DB error: $DBI::errstr\n";
+ } elsif($rows == 1) {
+ # An existing record was found for this indiv, update it
+ print " Updating existing indiv: $indiv_name\n";
+ $sth = $dbh->prepare("update tc_indiv set valid=1 where name=\"$indiv_name\"");
+ $sth->execute or die "-E- DB error: $DBI::errstr\n";
+ if($phone ne "") {
+ $sth = $dbh->prepare("update tc_indiv set phone='$phone' where name=\"$indiv_name\"");
+ } else {
+ $sth = $dbh->prepare("update tc_indiv set phone=NULL where name=\"$indiv_name\"");
+ }
+ $sth->execute or die "-E- DB error: $DBI::errstr\n";
+ if($birthday ne "") {
+ $sth = $dbh->prepare("update tc_indiv set birthday='$year-$month-$day' where name=\"$indiv_name\"");
+ } else {
+ $sth = $dbh->prepare("update tc_indiv set birthday=NULL where name=\"$indiv_name\"");
+ }
+ $sth->execute or die "-E- DB error: $DBI::errstr\n";
+ if($address ne "") {
+ $sth = $dbh->prepare("update tc_indiv set address='$address' where name=\"$indiv_name\"");
+ } else {
+ $sth = $dbh->prepare("update tc_indiv set address=NULL where name=\"$indiv_name\"");
}
+ $sth->execute or die "-E- DB error: $DBI::errstr\n";
+ $sth = $dbh->prepare("update tc_indiv set attending='$attending' where name=\"$indiv_name\"");
+ $sth->execute or die "-E- DB error: $DBI::errstr\n";
+ $sth = $dbh->prepare("update tc_indiv set indiv_id='$id' where name=\"$indiv_name\"");
+ $sth->execute or die "-E- DB error: $DBI::errstr\n";
+ $sth = $dbh->prepare("update tc_indiv set priesthood='$priesthood' where name=\"$indiv_name\"");
+ $sth->execute or die "-E- DB error: $DBI::errstr\n";
+ $sth = $dbh->prepare("update tc_indiv set email='$email' where name=\"$indiv_name\"");
+ $sth->execute or die "-E- DB error: $DBI::errstr\n";
+ $sth = $dbh->prepare("update tc_indiv set hh_position='$hhposition' where name=\"$indiv_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 indiv: $indiv_name\n";
}
}
$sth->finish();
#+---------------+------------------+------+-----+---------+-------+
#| companionship | int(16) unsigned | | | 0 | |
#| indiv | int(16) unsigned | YES | | NULL | |
-#| aaronic | int(16) unsigned | YES | | NULL | |
#| district | int(16) unsigned | YES | | NULL | |
#| valid | tinyint(1) | YES | | NULL | |
#+---------------+------------------+------+-----+---------+-------+
# First, mark all existing companionships as invalid in case they have been dissolved
$sth = $dbh->prepare("update tc_companionship set valid=0");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
- # Second, mark all the aaronic invalid. We'll only mark the ones as valid that are assigned to hometeach
- $sth = $dbh->prepare("update tc_aaronic set valid=0");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
foreach $index (keys %hometeaching_data)
{
$sth2->execute or die "-E- DB error: $DBI::errstr\n";
$sqlhashref2 = $sth2->fetchrow_hashref;
$indiv = $sqlhashref2->{indiv};
- $aaronic = "NULL";
- if($indiv eq "") {
- $sth2 = $dbh->prepare("select * from tc_aaronic where name='$indiv_name'");
- $sth2->execute or die "-E- DB error: $DBI::errstr\n";
- $sqlhashref2 = $sth2->fetchrow_hashref;
- $aaronic = $sqlhashref2->{aaronic};
- $indiv = "NULL";
- if($aaronic eq "") { print "-W- Unable to find $indiv_name in tc_indiv or tc_aaronic tables\n"; next; }
- }
$id = $hometeaching_data{$index}{'Comp ID'};
$district = $hometeaching_data{$index}{'HT District'};
- $sth = $dbh->prepare("select * from tc_companionship where indiv='$indiv' and aaronic='$aaronic' and companionship='$id'");
+ $sth = $dbh->prepare("select * from tc_companionship where indiv='$indiv' and companionship='$id'");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
my @data = ();
while($sqlhashref = $sth->fetchrow_hashref) { push(@data, $sqlhashref); }
if($rows == 0) {
# No existing records found for this companionship, make a new entry
print " Adding Companion to companionship: $indiv_name -> $id\n";
- $sth = $dbh->prepare("insert into tc_companionship values ($id,'$indiv','$aaronic','$district',1)");
+ $sth = $dbh->prepare("insert into tc_companionship values ($id,'$indiv','$district',1)");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
} else {
# An existing companionship was found for this companionship, update it
$sth2 = $dbh->prepare("select * from tc_companionship where district='$district' and companionship='$id'");
$sth2->execute or die "-E- DB error: $DBI::errstr\n";
- if($indiv ne "NULL") {
- print " Updating Companionship with indiv: $indiv_name ($indiv) -> $id\n";
- $sth = $dbh->prepare("update tc_companionship set district='$district' where indiv='$indiv' and companionship='$id'");
- $sth->execute or die "-E- DB error 'district': $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_companionship set indiv='$indiv' where indiv='$indiv' and companionship='$id'");
- $sth->execute or die "-E- DB error 'indiv': $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_companionship set valid=1 where indiv='$indiv' and companionship='$id'");
- $sth->execute or die "-E- DB error 'valid': $DBI::errstr\n";
- } else {
- print " Updating Companionship with Aaronic: $indiv_name ($aaronic) -> $id\n";
- $sth = $dbh->prepare("update tc_companionship set district='$district' where aaronic='$aaronic' and companionship='$id'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_companionship set aaronic='$aaronic' where aaronic='$aaronic' and companionship='$id'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_companionship set valid=1 where aaronic='$aaronic' and companionship='$id'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_aaronic set valid=1 where aaronic='$aaronic'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- }
+ print " Updating Companionship with indiv: $indiv_name ($indiv) -> $id\n";
+ $sth = $dbh->prepare("update tc_companionship set district='$district' where indiv='$indiv' and companionship='$id'");
+ $sth->execute or die "-E- DB error 'district': $DBI::errstr\n";
+ $sth = $dbh->prepare("update tc_companionship set indiv='$indiv' where indiv='$indiv' and companionship='$id'");
+ $sth->execute or die "-E- DB error 'indiv': $DBI::errstr\n";
+ $sth = $dbh->prepare("update tc_companionship set valid=1 where indiv='$indiv' and companionship='$id'");
+ $sth->execute or die "-E- DB error 'valid': $DBI::errstr\n";
}
$sth->finish();
$sth2->finish();
}
}
-# 3RD_PARENT
-#+----------+------------------+------+-----+---------+-------+
-#| Field | Type | Null | Key | Default | Extra |
-#+----------+------------------+------+-----+---------+-------+
-#| parent | int(16) unsigned | | PRI | 0 | A |
-#| family | int(16) unsigned | YES | | NULL | |
-#| name | varchar(30) | YES | | NULL | |
-#| birthday | date | YES | | NULL | |
-#| phone | varchar(12) | YES | | NULL | |
-#| address | varchar(255) | YES | | NULL | |
-#| indiv_id | int(16) unsigned | YES | UNI | NULL | |
-#| valid | tinyint(1) | YES | | NULL | |
-#+----------+------------------+------+-----+---------+-------+
-sub update_tc_parent_table
-{
- print "\n-> Updating tc_parent table\n";
-
- # Set all records to be invalid. Only mark them as valid if they appear on the new list.
- $sth = $dbh->prepare("update tc_parent set valid=0");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
-
- foreach $index (keys %membership_data)
- {
- $hashref = $membership_data{$index};
- foreach $key (keys %$hashref) {
- if($key =~ /HH Position/i &&
- $membership_data{$index}{$key} =~ /Head of Household/i ||
- $membership_data{$index}{$key} =~ /Spouse/i
- ) {
- # Get some information from the hash about this parent
- $parent_name = $membership_data{$index}{'Preferred Name'};
- $parent_name =~ s/\'/\\'/g; #'
- $birthday = $membership_data{$index}{'Birth'};
- $birthday =~ /(\d+) (\S+) (\d+)/; $day=$1; $month=$monthname2num{$2}; $year=$3;
- $hofh_id = $membership_data{$index}{'HofH ID'};
- $id = $membership_data{$index}{'Indiv ID'};
- $phone = $membership_data{$index}{'Household Phone'};
- 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 "") {
- $address .= " " . $membership_data{$index}{'Street 2'};
- }
-
- # Find the family id for this parent's HofH_ID.
- $sth = $dbh->prepare("select * from tc_family where hofh_id='$hofh_id' and valid=1");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- my @family_data = ();
- while($sqlhashref = $sth->fetchrow_hashref) { push(@family_data, $sqlhashref); }
- my $family_rows = scalar @family_data;
- if($family_rows > 0) { $family_id = $family_data[0]->{'family'}; }
- else { $family_id = 0; }
-
- # Find out how many parents match this parent's name
- $sth = $dbh->prepare("select * from tc_parent where name='$parent_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- my @data = ();
- while($sqlhashref = $sth->fetchrow_hashref) { push(@data, $sqlhashref); }
- my $rows = scalar @data;
-
- if($rows == 0 && $family_rows > 0) {
- # No existing records found for this parent, make a new entry
- print " Adding new Parent: $parent_name\n";
- $sth = $dbh->prepare("insert into tc_parent values (NULL,$family_id,'$parent_name','$year-$month-$day','$phone','$address','$id',1)");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- } elsif($rows == 1 && $family_rows > 0) {
- # An existing record was found for this parent, update it
- print " Updating existing parent: $parent_name\n";
- $sth = $dbh->prepare("update tc_parent set family='$family_id' where name='$parent_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_parent set birthday='$year-$month-$day' where name='$parent_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_parent set phone='$phone' where name='$parent_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_parent set address='$address' where name='$parent_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_parent set valid=1 where name='$parent_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_parent set indiv_id='$id' where name='$parent_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- } elsif($rows > 1) {
- # More than one record was found. Error! This shouldn't happen.
- print " -E- More than one record found with same parent name: $parent_name with hofh_id: $hofh_id\n";
- } else {
- print " -E- Unable to find a family to attach this parent to: $parent_name with hofh_id: $hofh_id\n";
- }
- $sth->finish();
- }
- }
- }
-}
-
-# 3RD_CHILD
-#+----------+------------------+------+-----+---------+-------+
-#| Field | Type | Null | Key | Default | Extra |
-#+----------+------------------+------+-----+---------+-------+
-#| child | int(16) unsigned | | PRI | 0 | A |
-#| family | int(16) unsigned | YES | | NULL | |
-#| name | varchar(30) | YES | | NULL | |
-#| birthday | date | YES | | NULL | |
-#| indiv_id | int(16) unsigned | YES | UNI | NULL | |
-#| valid | tinyint(1) | YES | | NULL | |
-#+----------+------------------+------+-----+---------+-------+
-sub update_tc_child_table
-{
- print "\n-> Updating tc_child table\n";
-
- # Set all records to be invalid. Only mark them as valid if they appear on the new list.
- $sth = $dbh->prepare("update tc_child set valid=0");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
-
- foreach $index (keys %membership_data)
- {
- $hashref = $membership_data{$index};
- foreach $key (keys %$hashref) {
- if($key =~ /HH Position/i && $membership_data{$index}{$key} =~ /Other/i ) {
- $child_name = $membership_data{$index}{'Full Name'};
- $child_name =~ s/\'/\\'/g; #'
- $birthday = $membership_data{$index}{'Birth'};
- $birthday =~ /(\d+) (\S+) (\d+)/; $day=$1; $month=$monthname2num{$2}; $year=$3;
- $id = $membership_data{$index}{'Indiv ID'};
- $hofh_id = $membership_data{$index}{'HofH ID'};
-
- # Find the family id for this child's HofH_ID.
- $sth = $dbh->prepare("select * from tc_family where hofh_id='$hofh_id' and valid=1");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- my @family_data = ();
- while($sqlhashref = $sth->fetchrow_hashref) { push(@family_data, $sqlhashref); }
- my $family_rows = scalar @family_data;
- if($family_rows > 0) { $family_id = $family_data[0]->{'family'}; }
- else { $family_id = 0; }
-
- # Find out how many children have the same name for the same family
- $sth = $dbh->prepare("select * from tc_child where name='$child_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- my @data = ();
- while($sqlhashref = $sth->fetchrow_hashref) { push(@data, $sqlhashref); }
- my $rows = scalar @data;
-
- if($rows == 0 && $family_rows > 0) {
- # No existing records found for this child, make a new entry
- print " Adding new Child: $child_name\n";
- $sth = $dbh->prepare("insert into tc_child values (NULL,$family_id,'$child_name','$year-$month-$day','$id',1)");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- } elsif($rows == 1 && $family_rows > 0) {
- # An existing record was found for this child, update it
- print " Updating existing child: $child_name\n";
- $sth = $dbh->prepare("update tc_child set family='$family_id' where name='$child_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_child set birthday='$year-$month-$day' where name='$child_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_child set valid=1 where name='$child_name'");
- $sth->execute or die "-E- DB error: $DBI::errstr\n";
- $sth = $dbh->prepare("update tc_child set indiv_id='$id' where name='$child_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) with same child name: $child_name\n";
- }
- $sth->finish();
- }
- }
- }
-}
-
# 3RD_VISIT
#+----------------+------------------+------+-----+---------+-------+
#| Field | Type | Null | Key | Default | Extra |
return $found_problem;
}
+sub update_family_in_tc_indiv_table
+{
+ print "\n-> Updating family info in tc_indiv table\n";
+
+ foreach $index (keys %membership_data)
+ {
+ $hashref = $membership_data{$index};
+
+ # get some information from hash about this individual
+ $name = $membership_data{$index}{'Preferred Name'};
+ $hofh_id = $membership_data{$index}{'HofH ID'};
+
+ # Find the family id for this individual's HofH_id
+ $sth = $dbh->prepare("select * from tc_family where hofh_id=$hofh_id and valid=1");
+ $sth->execute or die "-E- DB error: $DBI::errstr\n";
+ my @family_data = ();
+ while($sqlhashref = $sth->fetchrow_hashref) { push(@family_data, $sqlhashref); }
+ my $family_rows = scalar @family_data;
+ if($family_rows > 0) {
+ $family_id = $family_data[0]->{'family'};
+
+ print " Updating family data for: $name\n";
+
+ # write the family id to the individual's data in tc_indiv
+ $sth = $dbh->prepare("update tc_indiv set family='$family_id' where name=\"$name\"");
+ $sth->execute or die "-E- DB error: $DBI::errstr\n";
+ } else { $family_id = 0; }
+ }
+}
+
######################################################################
# MAIN
######################################################################
# Now update the various eq DB tables
&update_tc_calling_table();
&update_tc_indiv_table();
-&update_tc_aaronic_table();
&update_tc_district_table();
&update_tc_companionship_table();
&update_tc_family_table();
-&update_tc_parent_table();
-&update_tc_child_table();
&update_tc_visit_table();
+&update_family_in_tc_indiv_table();
print "\n-> Import Successful! DONE...\n";
PrintError=>0}) or print "Connect Failure:".$DBI::errstr."\n" and exit 2;
###################################################
-# Rename eq_aaronic table to tc_aaronic
-$sth = $dbh->prepare("RENAME TABLE `eq_aaronic` TO `tc_aaronic`");
+# Remove eq_aaronic table
+$sth = $dbh->prepare("DROP TABLE `eq_aaronic` IF EXISTS");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
# Rename eq_activity table to tc_activity
$sth = $dbh->prepare("RENAME TABLE `eq_calling` TO `tc_calling`");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
-# Rename eq_child table to tc_child
-$sth = $dbh->prepare("RENAME TABLE `eq_child` TO `tc_child`");
+# Remove eq_child table
+$sth = $dbh->prepare("DROP TABLE `eq_child` IF EXISTS");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
# Rename eq_companionship table to tc_companionship
$sth = $dbh->prepare("RENAME TABLE `eq_companionship` TO `tc_companionship`");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
+# Remove aaronic field from tc_companionship
+$sth = $dbh->prepare("ALTER TABLE 'tc_companionship' DROP 'aaronic'");
+$sth->execute or die "-E- DB error: $DBI::errstr\n";
+
# Change elder field in tc_companionship table to indiv
$sth = $dbh->prepare("ALTER TABLE `tc_companionship` CHANGE `elder` `indiv` INT(16)");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
$sth = $dbh->prepare("RENAME TABLE `eq_elder` TO `tc_indiv`");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
-# Add a new 'propective' field to the tc_indiv table
-$sth = $dbh->prepare("ALTER TABLE `tc_indiv` ADD `prospective` enum('y','n') NULL AFTER `priesthood`");
-$sth->execute or die "-E- DB error: $DBI::errstr\n";
-
# Change elder field in tc_indiv table to indiv
$sth = $dbh->prepare("ALTER TABLE `tc_indiv` CHANGE `elder` `indiv` INT(16)");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
+# Add a new 'birthday' column to the tc_indiv table
+$sth = $dbh->prepare("ALTER TABLE `tc_indiv` ADD `birthday` DATE NULL DEFAULT NULL AFTER `name` ");
+$sth->execute or die "-E- DB error: $DBI::errstr\n";
+
+# Add a new 'address' column to the tc_indiv table
+$sth = $dbh->prepare("ALTER TABLE `tc_indiv` ADD `address` VARCHAR( 255 ) NULL DEFAULT NULL AFTER `birthday`");
+$sth->execute or die "-E- DB error: $DBI::errstr\n";
+
+# Add a new 'family' column to the tc_indiv table
+$sth = $dbh->prepare("ALTER TABLE `tc_indiv` ADD `family` INT(16) UNSIGNED NULL DEFAULT NULL AFTER `email`");
+$sth->execute or die "-E- DB error: $DBI::errstr\n";
+
+# Add a new 'family' column to the tc_indiv table
+$sth = $dbh->prepare("ALTER TABLE `tc_indiv` ADD `hh_position` ENUM( 'Head of Household', 'Spouse', 'Other' ) NOT NULL DEFAULT 'Other' AFTER `family`");
+$sth->execute or die "-E- DB error: $DBI::errstr\n";
+
# Rename eq_family table to tc_family
$sth = $dbh->prepare("RENAME TABLE `eq_family` TO `tc_family`");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
$sth = $dbh->prepare("ALTER TABLE `tc_family` CHANGE `elder_id` `indiv_id` INT(16)");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
-# Rename eq_parent table to tc_parent
-$sth = $dbh->prepare("RENAME TABLE `eq_parent` TO `tc_parent`");
+# Remove eq_parent table
+$sth = $dbh->prepare("DROP TABLE `eq_parent` IF EXISTS");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
# Rename eq_participation table to tc_participation
$sth = $dbh->prepare("ALTER TABLE `tc_interview` CHANGE `elder` `indiv` INT(16)");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
+# Remove aaronic field from tc_interview
+$sth = $dbh->prepare("ALTER TABLE 'tc_interview' DROP 'aaronic'");
+$sth->execute or die "-E- DB error: $DBI::errstr\n";
+
# Change ppi field in tc_interview table to interview
$sth = $dbh->prepare("ALTER TABLE `tc_interview` CHANGE `ppi` `interview` INT(16)");
$sth->execute or die "-E- DB error: $DBI::errstr\n";
$indivs[$id] = $indiv_name[$i];
}
- $sql = "SELECT * FROM tc_aaronic where valid=1 ORDER BY aaronic ASC";
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- $aaronic_id = $this->db->f('aaronic');
- $aaronic[$aaronic_id]['name'] = $this->db->f('name');
- $aaronic[$aaronic_id]['phone'] = $this->db->f('phone');
- }
-
$this->nextmatchs->template_alternate_row_color(&$this->t);
for($m=$num_months; $m >= 0; $m--) { $total_families[$m]=0; }
for ($i=0; $i < count($districts); $i++) {
if($companion_table_entry != "") { $companion_table_entry .= "<td> / </td>"; }
$companionship = $this->db->f('companionship');
$indiv_id = $this->db->f('indiv');
- $aaronic_id = $this->db->f('aaronic');
- if($indiv_id) {
- $name = $indivs[$indiv_id];
- $phone = $indiv_phone[$indiv_id];
- }
- else if($aaronic_id) {
- $name = $aaronic[$aaronic_id]['name'];
- $phone = $aaronic[$aaronic_id]['phone'];
- }
+ $name = $indivs[$indiv_id];
+ $phone = $indiv_phone[$indiv_id];
$companion_table_entry .= "<td title=\"$phone\"><b>$name</b></td>";
}
$table_data.= "<tr bgcolor=#d3dce3><td colspan=20><table><tr>$companion_table_entry</tr></table><hr></td></tr>";
$indivs[$id] = $indiv_name[$i];
}
- $sql = "SELECT * FROM tc_aaronic where valid=1 ORDER BY aaronic ASC";
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- $aaronic_id = $this->db->f('aaronic');
- $aaronic[$aaronic_id]['name'] = $this->db->f('name');
- $aaronic[$aaronic_id]['phone'] = $this->db->f('phone');
- }
-
// Select all the unique companionship numbers for this district
$sql = "SELECT distinct companionship FROM tc_companionship where valid=1 and district=". $district;
$this->db->query($sql,__LINE__,__FILE__);
if($companion_table_entry != "") { $companion_table_entry .= "<td> / </td>"; }
$companionship = $this->db->f('companionship');
$indiv_id = $this->db->f('indiv');
- $aaronic_id = $this->db->f('aaronic');
- if($indiv_id) {
- $name = $indivs[$indiv_id];
- $phone = $indiv_phone[$indiv_id];
- }
- else if($aaronic_id) {
- $name = $aaronic[$aaronic_id]['name'];
- $phone = $aaronic[$aaronic_id]['phone'];
- }
+ $name = $indivs[$indiv_id];
+ $phone = $indiv_phone[$indiv_id];
$companion_table_entry .= "<td title=\"$phone\"><b>$name</b></td>";
}
$table_data.= "<tr bgcolor=#d3dce3><td colspan=20><table><tr>$companion_table_entry</tr></table><hr></td></tr>";
if($this->db2->next_record()) {
$indiv_id = $this->db2->f('indiv_id');
}
- $sql = "SELECT * FROM tc_parent where indiv_id='$indiv_id'";
+ $sql = "SELECT * FROM tc_indiv where indiv_id='$indiv_id'";
$this->db2->query($sql,__LINE__,__FILE__);
if($this->db2->next_record()) {
$president_address = $this->db2->f('address');
if($this->db2->next_record()) {
$indiv_id = $this->db2->f('indiv_id');
}
- $sql = "SELECT * FROM tc_parent where indiv_id='$indiv_id'";
+ $sql = "SELECT * FROM tc_indiv where indiv_id='$indiv_id'";
$this->db2->query($sql,__LINE__,__FILE__);
if($this->db2->next_record()) {
$supervisor_address = $this->db2->f('address');
$indiv_id = $entry['indiv_id'];
$indiv_name = $entry['indiv_name'];
$int_pri = $entry['pri'];
- $aaronic = $entry['aaronic'];
- //print "int_notes: $int_notes indiv_name: $indiv_name aaronic: $aaronic <Br>";
- if($aaronic == 0) {
- // Perform database save actions here
- $this->db->query("UPDATE tc_indiv set " .
- " int_notes='" . $int_notes . "'" .
- ",int_pri='" . $int_pri . "'" .
- " WHERE indiv=" . $indiv_id,__LINE__,__FILE__);
- }
+ //print "int_notes: $int_notes indiv_name: $indiv_name <Br>";
+ // Perform database save actions here
+ $this->db->query("UPDATE tc_indiv set " .
+ " int_notes='" . $int_notes . "'" .
+ ",int_pri='" . $int_pri . "'" .
+ " WHERE indiv=" . $indiv_id,__LINE__,__FILE__);
}
if($this->db2->next_record()) {
$indiv_id = $this->db2->f('indiv_id');
}
- $sql = "SELECT * FROM tc_parent where indiv_id='$indiv_id'";
+ $sql = "SELECT * FROM tc_indiv where indiv_id='$indiv_id'";
$this->db2->query($sql,__LINE__,__FILE__);
if($this->db2->next_record()) {
$supervisor_address = $this->db2->f('address');
{
// Get this companions information
$indiv_id = $this->db->f('indiv');
- $aaronic_id = $this->db->f('aaronic');
$sql = "SELECT * FROM tc_indiv where indiv=$indiv_id";
$this->db2->query($sql,__LINE__,__FILE__);
- if($this->db2->next_record())
- {
- $indiv_id = $this->db2->f('indiv');
- $indiv_name = $this->db2->f('name');
- $indiv_phone[$indiv_id] = $this->db2->f('phone');
- $indiv_int_pri[$indiv_id] = $this->db2->f('int_pri');
- $indiv_int_notes[$indiv_id] = $this->db2->f('int_notes');
- $indiv_aaronic = 0;
- }
- else {
- $sql = "SELECT * FROM tc_aaronic where aaronic=$aaronic_id";
- $this->db2->query($sql,__LINE__,__FILE__);
- if($this->db2->next_record())
- {
- $indiv_id = $this->db2->f('aaronic');
- $indiv_name = $this->db2->f('name');
- $indiv_phone[$indiv_id] = $this->db2->f('phone');
- $indiv_aaronic = 1;
- }
- }
+ $indiv_id = $this->db2->f('indiv');
+ $indiv_name = $this->db2->f('name');
+ $indiv_phone[$indiv_id] = $this->db2->f('phone');
+ $indiv_int_pri[$indiv_id] = $this->db2->f('int_pri');
+ $indiv_int_notes[$indiv_id] = $this->db2->f('int_notes');
$id = $indiv_id;
$name = $indiv_name;
$phone = $indiv_phone[$id];
$int_pri = $indiv_int_pri[$id];
$int_notes = $indiv_int_notes[$id];
- $aaronic = $indiv_aaronic;
// If the companionship has already had its quarterly interview,
// Skip the other companion in the companionship.
if($this->db3->next_record()) { $date = $this->db3->f('date'); } else { $date = ""; }
$link_data['menuaction'] = 'tc.tc.int_update';
$link_data['indiv'] = $id;
- $link_data['aaronic'] = 0;
$link_data['name'] = $name;
$link_data['interview'] = '';
$link_data['action'] = 'add';
$table_data.= "<tr bgcolor=". $this->t->get_var('tr_color') ."><td title=\"$phone\"><a href=$link>$name</a></td>";
$table_data.= "<td align=center>$phone</td>";
$table_data.= "<td align=center>";
- if($aaronic == 0) {
- $table_data.= '<select name=int_notes['.$i.'][pri]>';
- foreach(range(0,6) as $num) {
- if($num == 0) { $num = 1; } else {$num = $num*5; }
- if($int_pri == $num) { $selected[$num] = 'selected="selected"'; } else { $selected[$num] = ''; }
- $table_data.= '<option value='.$num.' '.$selected[$num].'>'.$num.'</option>';
- }
- $table_data.= '</select></td>';
+ $table_data.= '<select name=int_notes['.$i.'][pri]>';
+ foreach(range(0,6) as $num) {
+ if($num == 0) { $num = 1; } else {$num = $num*5; }
+ if($int_pri == $num) { $selected[$num] = 'selected="selected"'; } else { $selected[$num] = ''; }
+ $table_data.= '<option value='.$num.' '.$selected[$num].'>'.$num.'</option>';
}
+ $table_data.= '</select></td>';
$table_data.= "<td align=center>$date</td>";
- if($aaronic == 0) {
- $table_data.= '<td><input type=text size="50" maxlength="128" name="int_notes['.$i.'][notes]" value="'.$int_notes.'">';
- }
+ $table_data.= '<td><input type=text size="50" maxlength="128" name="int_notes['.$i.'][notes]" value="'.$int_notes.'">';
$table_data.= '<input type=hidden name="int_notes['.$i.'][indiv_id]" value="'.$id.'">';
$table_data.= '<input type=hidden name="int_notes['.$i.'][indiv_name]" value="'.$name.'">';
- $table_data.= '<input type=hidden name="int_notes['.$i.'][aaronic]" value="'.$aaronic.'">';
$table_data.= '</td>';
$table_data.= '</tr>'."\n";
$i++;
$link_data['menuaction'] = 'tc.tc.int_update';
$link_data['interviewer'] = $this->db2->f('interviewer');
$link_data['indiv'] = $this->db2->f('indiv');
- $link_data['aaronic'] = $this->db2->f('aaronic');
$link_data['name'] = $name;
$link_data['interview'] = $this->db2->f('interview');
$link_data['action'] = 'view';
$family_id[$i] = $this->db->f('family');
$family_name[$i] = $this->db->f('name');
$familyid2name[$family_id[$i]] = $family_name[$i];
- $sql = "SELECT * FROM tc_parent where family='$family_id[$i]'";
+ $sql = "SELECT * FROM tc_indiv where family='$family_id[$i]'";
$this->db2->query($sql,__LINE__,__FILE__);
if($this->db2->next_record()) {
$familyid2address[$family_id[$i]] = $this->db2->f('address');
$total_families++;
}
- $sql = "SELECT * FROM tc_parent where valid=1";
+ $sql = "SELECT * FROM tc_indiv where valid=1";
$this->db->query($sql,__LINE__,__FILE__);
while ($this->db->next_record())
{
$name = get_var('name',array('GET','POST'));
$interview = get_var('interview',array('GET','POST'));
$indiv = get_var('indiv',array('GET','POST'));
- $aaronic = get_var('aaronic',array('GET','POST'));
$date = get_var('date',array('GET','POST'));
$notes = get_var('notes',array('GET','POST'));
$interview_type = get_var('interview_type',array('GET','POST'));
" interview='" . $interview . "'" .
", interviewer='" . $interviewer . "'" .
", indiv='" . $indiv . "'" .
- ", aaronic='" . $aaronic . "'" .
", date='" . $date . "'" .
", notes='" . $notes . "'" .
", interview_type='" . $interview_type . "'" .
if($action == 'insert')
{
$notes = get_var('notes',array('POST'));
- $this->db->query("INSERT INTO tc_interview (interviewer,indiv,aaronic,date,notes,interview_type) "
- . "VALUES ('" . $interviewer . "','" . $indiv . "','" . $aaronic . "','"
+ $this->db->query("INSERT INTO tc_interview (interviewer,indiv,date,notes,interview_type) "
+ . "VALUES ('" . $interviewer . "','" . $indiv . "','"
. $date . "','" . $notes . "','" . $interview_type ."')",__LINE__,__FILE__);
$this->ppi_view();
return false;
$indivs[$id] = $indiv_name[$i];
}
- $sql = "SELECT * FROM tc_aaronic where valid=1 ORDER BY aaronic ASC";
- $this->db->query($sql,__LINE__,__FILE__);
- while ($this->db->next_record())
- {
- $aaronic_id = $this->db->f('aaronic');
- $aaronic[$aaronic_id]['name'] = $this->db->f('name');
- $aaronic[$aaronic_id]['phone'] = $this->db->f('phone');
- }
-
$total_companionships = 0;
$this->nextmatchs->template_alternate_row_color(&$this->t);
for ($i=0; $i < count($districts); $i++) {
$num_indivs++;
$companionship = $this->db->f('companionship');
$indiv_id = $this->db->f('indiv');
- $aaronic_id = $this->db->f('aaronic');
- if($indiv_id) {
- $name = $indivs[$indiv_id];
- $phone = $indiv_phone[$indiv_id];
- }
- else if($aaronic_id) {
- $name = $aaronic[$aaronic_id]['name'];
- $phone = $aaronic[$aaronic_id]['phone'];
- }
+ $name = $indivs[$indiv_id];
+ $phone = $indiv_phone[$indiv_id];
$link_data['menuaction'] = 'tc.tc.int_update';
$link_data['companionship'] = $companionship;
$link_data['interviewer'] = $supervisor;
$link_data['indiv'] = $indiv_id;
- $link_data['aaronic'] = $aaronic_id;
$link_data['name'] = $name;
$link_data['interview'] = '';
$link_data['action'] = 'add';
$month_end = "$year"."-"."$month"."-"."31";
$month = "$month"."/"."$year";
$sql = "SELECT * FROM tc_interview WHERE date >= '$month_start' AND date <= '$month_end' ".
- "AND indiv=" . $indiv_id . " AND aaronic=" . $aaronic_id;
+ "AND indiv=" . $indiv_id;
$this->db2->query($sql,__LINE__,__FILE__);
$header_row .= "<th width=$int_width><font size=-2>$month</th>";
$link_data['companionship'] = $companionship;
$link_data['interviewer'] = $this->db2->f('interviewer');
$link_data['indiv'] = $indiv_id;
- $link_data['aaronic'] = $aaronic_id;
$link_data['name'] = $name;
$link_data['interview'] = $this->db2->f('interview');
$link_data['action'] = 'view';
$name = get_var('name',array('GET','POST'));
$interview = get_var('interview',array('GET','POST'));
$indiv = get_var('indiv',array('GET','POST'));
- $aaronic = get_var('aaronic',array('GET','POST'));
$date = get_var('date',array('GET','POST'));
$notes = get_var('notes',array('GET','POST'));
$interview_type = get_var('interview_type',array('GET','POST'));
" interview='" . $interview . "'" .
", interviewer='" . $interviewer . "'" .
", indiv='" . $indiv . "'" .
- ", aaronic='" . $aaronic . "'" .
", date='" . $date . "'" .
", notes='" . $notes . "'" .
", interview_type='" . $interview_type . "'" .
if($action == 'insert')
{
$notes = get_var('notes',array('POST'));
- $this->db->query("INSERT INTO tc_interview (interviewer,indiv,aaronic,date,notes,interview_type) "
- . "VALUES ('" . $interviewer . "','" . $indiv . "','" . $aaronic . "','"
+ $this->db->query("INSERT INTO tc_interview (interviewer,indiv,date,notes,interview_type) "
+ . "VALUES ('" . $interviewer . "','" . $indiv . "','"
. $date . "','" . $notes ."','" . $interview_type . "')",__LINE__,__FILE__);
$this->int_view();
return false;
$this->t->set_var('interviewer', $interviewer);
$this->t->set_var('name',$name);
$this->t->set_var('indiv',$indiv);
- $this->t->set_var('aaronic',$aaronic);
$this->t->set_var('date','');
$this->t->set_var('notes','');
$this->t->set_var('lang_done','Cancel');
$this->t->set_var('name',$name);
$this->t->set_var('interviewer', $this->db->f('interviewer'));
$this->t->set_var('indiv',$this->db->f('indiv'));
- $this->t->set_var('aaronic',$this->db->f('aaronic'));
$this->t->set_var('date',$this->db->f('date'));
$this->t->set_var('notes',$this->db->f('notes'));
if($this->db->f('interview_type') == 1) { $this->t->set_var('interview_type_checked','checked'); }
$this->t->set_file(array('dir_view_t' => 'dir_view.tpl'));
$this->t->set_block('dir_view_t','dir_list','list');
- $sql = "SELECT * FROM tc_parent where valid=1 ORDER BY name ASC";
+ $sql = "SELECT * FROM tc_indiv where valid=1 and hh_position='Head of Household' ORDER BY name ASC";
$this->db->query($sql,__LINE__,__FILE__);
$i=0;
while ($this->db->next_record())
{
- $parent[$i]['id'] = $this->db->f('parent');
+ $parent[$i]['id'] = $this->db->f('indiv');
$parent[$i]['name'] = $this->db->f('name');
$parent[$i]['phone'] = $this->db->f('phone');
$parent[$i]['address'] = $this->db->f('address');
$family_id[$i] = $this->db->f('family');
$family_name[$i] = $this->db->f('name');
$familyid2name[$family_id[$i]] = $family_name[$i];
- $sql = "SELECT * FROM tc_parent where family='$family_id[$i]'";
+ $sql = "SELECT * FROM tc_indiv where family='$family_id[$i]' and hh_position='Head of Household'";
$this->db2->query($sql,__LINE__,__FILE__);
if($this->db2->next_record()) {
$familyid2address[$family_id[$i]] = $this->db2->f('address');
if($this->db2->next_record()) {
$indiv_id = $this->db2->f('indiv_id');
}
- $sql = "SELECT * FROM tc_parent where indiv_id='$indiv_id'";
+ $sql = "SELECT * FROM tc_indiv where indiv_id='$indiv_id'";
$this->db2->query($sql,__LINE__,__FILE__);
if($this->db2->next_record()) {
$supervisor_address = $this->db2->f('address');
if($this->db2->next_record()) {
$indiv_id = $this->db2->f('indiv_id');
}
- $sql = "SELECT * FROM tc_parent where indiv_id='$indiv_id'";
+ $sql = "SELECT * FROM tc_indiv where indiv_id='$indiv_id'";
$this->db2->query($sql,__LINE__,__FILE__);
if($this->db2->next_record()) {
$supervisor_address = $this->db2->f('address');
shape = "record"
];
indiv [
- label = "<i> indiv||<id> indiv_id|<n> name|<p> phone|<em> email|<po> priesthood|<pr> prospective|<pp> ppi_pri|<t> ppi_notes|<ip> int_pri|<in> int_notes|<a> attending|<v> valid"
+ label = "<i> indiv||<id> indiv_id|<n> name|<b> birthday|<a> address|<p> phone|<em> email|<f> family|<hh> hh position|<po> priesthood|<pr> prospective|<pp> ppi_pri|<t> ppi_notes|<ip> int_pri|<in> int_notes|<a> attending|<v> valid"
shape = "record"
];
companionship [
- label = "<c> companionship||<i> indiv|<a> aaronic|<d> district|<v> valid"
+ label = "<c> companionship||<i> indiv|<d> district|<v> valid"
shape = "record"
];
visit [
shape = "record"
];
interview [
- label = "<in> interview||<i> interviewer|<il> indiv|<a> aaronic|<t> date|<n> notes|<it> interview_type"
+ label = "<in> interview||<i> interviewer|<il> indiv|<t> date|<n> notes|<it> interview_type"
shape = "record"
];
activity [
label = "attendance||<i> indiv|<d> date"
shape = "record"
];
- child [
- label = "<c> child||<f> family|<n> name|<b> birthday|<i> indiv_id|<v> valid"
- shape = "record"
- ];
- parent [
- label = "<p> parent||<f> family|<n> name|<b> birthday|<p> phone|<a> address|<i>indiv_id|<v> valid"
- shape = "record"
- ];
- aaronic [
- label = "<a> aaronic||<n> name|<p> phone|<em> email|<v> valid"
- shape = "record"
- ];
appointment [
label = "<a> appointment||<p> presidency|<f> family|<i> indiv |<d> date|<t> time|<l> location|<u> uid"
shape = "record"
family:c -> companionship:c
companionship:i -> indiv:i
- companionship:a -> aaronic:a
appointment:i -> indiv:i
appointment:f -> family:f
interview:il -> indiv:i
interview:i -> indiv:i
- interview:a -> aaronic:a
presidency:i -> indiv:i
presidency:d -> district:d
attendance:i -> indiv:i
- child:f -> family:f
- parent:f -> family:f
+ indiv:f -> family:f
}
USE `phpgroupware`;
---
--- Table structure for table `tc_aaronic`
---
-CREATE TABLE `tc_aaronic` (
- `aaronic` int(16) unsigned NOT NULL auto_increment,
- `name` varchar(60) default NULL,
- `phone` varchar(12) default NULL,
- `email` varchar(120) default NULL,
- `valid` tinyint(1) default NULL,
- PRIMARY KEY (`aaronic`)
-) ENGINE=MyISAM AUTO_INCREMENT=92 DEFAULT CHARSET=latin1;
-
-
--
-- Table structure for table `tc_activity`
--
KEY `indiv_id` (`indiv_id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
---
--- Table structure for table `tc_child`
---
-CREATE TABLE `tc_child` (
- `child` int(16) unsigned NOT NULL auto_increment,
- `family` int(16) unsigned default NULL,
- `name` varchar(30) default NULL,
- `birthday` date default NULL,
- `indiv_id` int(16) unsigned default NULL,
- `valid` tinyint(1) default NULL,
- PRIMARY KEY (`child`)
-) ENGINE=MyISAM AUTO_INCREMENT=260 DEFAULT CHARSET=latin1;
-
--
-- Table structure for table `tc_companionship`
--
CREATE TABLE `tc_companionship` (
`companionship` int(16) unsigned NOT NULL default '0',
`indiv` int(16) unsigned NOT NULL default '0',
- `aaronic` int(16) unsigned NOT NULL default '0',
`district` int(16) unsigned default NULL,
`valid` tinyint(1) default NULL,
KEY `companionship` (`companionship`)
`indiv` int(16) unsigned NOT NULL auto_increment,
`indiv_id` int(16) unsigned NOT NULL,
`name` varchar(60) default NULL,
+ `birthday` date default NULL,
+ `address` varchar(255) default NULL,
`phone` varchar(12) default NULL,
`email` varchar(120) default NULL,
+ `family` int(16) unsigned default NULL,
+ `hh_position` enum('Head of Household','Spouse','Other') DEFAULT 'Other',
`priesthood` enum('High Priest','Elder','Priest','Teacher','Deacon','Unordained') DEFAULT NULL,
- `prospective` enum('y','n') DEFAULT 'n',
`ppi_pri` int(10) unsigned NOT NULL default '1',
`ppi_notes` varchar(128) default NULL,
`int_pri` int(10) unsigned default '1',
PRIMARY KEY (`family`)
) ENGINE=MyISAM AUTO_INCREMENT=277 DEFAULT CHARSET=latin1;
---
--- Table structure for table `tc_parent`
---
-CREATE TABLE `tc_parent` (
- `parent` int(16) unsigned NOT NULL auto_increment,
- `family` int(16) unsigned default NULL,
- `name` varchar(30) default NULL,
- `birthday` date default NULL,
- `phone` varchar(12) default NULL,
- `address` varchar(255) default NULL,
- `indiv_id` int(16) unsigned default NULL,
- `valid` tinyint(1) default NULL,
- PRIMARY KEY (`parent`)
-) ENGINE=MyISAM AUTO_INCREMENT=396 DEFAULT CHARSET=latin1;
-
--
-- Table structure for table `tc_participation`
--
`interview` int(16) unsigned NOT NULL auto_increment,
`interviewer` int(16) unsigned default NULL,
`indiv` int(16) unsigned default NULL,
- `aaronic` int(16) unsigned NOT NULL default '0',
`date` date default NULL,
`notes` text,
`interview_type` enum('hti','ppi') NOT NULL DEFAULT 'hti',
<form action="{actionurl}" method="POST">
<input type=hidden name=interviewer value={interviewer}>
<input type=hidden name=indiv value={indiv}>
- <input type=hidden name=aaronic value={aaronic}>
<input type=hidden name=companionship value={companionship}>
<table border="0" width="60%" cellspacing="2" cellpadding="2">
<tr>
<form action="{actionurl}" method="POST">
<input type=hidden name=interviewer value={interviewer}>
<input type=hidden name=indiv value={indiv}>
- <input type=hidden name=aaronic value={aaronic}>
<input type=hidden name=companionship value={companionship}>
<table border="0" width="60%" cellspacing="2" cellpadding="2">
<tr>