From: Owen Leonard Date: Sat, 18 Sep 2010 19:25:36 +0000 (-0600) Subject: removed name field from tc_presidency, updated tc.jpg X-Git-Tag: release_1_0_0~26 X-Git-Url: http://git.pippins.net/embedvideo/.git/%22%22.%24thumbnail.%22/%24link?a=commitdiff_plain;h=618c7a09c5e0b99ca1ef5381aa2349802d11098b;p=eq%2F.git removed name field from tc_presidency, updated tc.jpg --- diff --git a/bin/import_ward_data b/bin/import_ward_data index 6703836..6bbfe56 100755 --- a/bin/import_ward_data +++ b/bin/import_ward_data @@ -249,16 +249,16 @@ sub update_tc_district_table $sth = $dbh->prepare("select * from tc_district"); $sth->execute or die "-E- DB error: $DBI::errstr\n"; while($sqlhashref = $sth->fetchrow_hashref) { - $supervisor_name = $sqlhashref->{name}; - $district = $sqlhashref->{district}; - $sth2 = $dbh->prepare("select * from tc_individual where name='$supervisor_name'"); - $sth2->execute or die "-E- DB error: $DBI::errstr\n"; - $sqlhashref2 = $sth2->fetchrow_hashref; - $supervisor_id = $sqlhashref2->{individual}; - $sth2->finish(); - $sth2 = $dbh->prepare("update tc_district set supervisor='$supervisor_id' where district='$district'"); - $sth2->execute or die "-E- DB error: $DBI::errstr\n"; - $sth2->finish(); + $supervisor_name = $sqlhashref->{name}; + $district = $sqlhashref->{district}; + $sth2 = $dbh->prepare("select * from tc_individual where name='$supervisor_name'"); + $sth2->execute or die "-E- DB error: $DBI::errstr\n"; + $sqlhashref2 = $sth2->fetchrow_hashref; + $supervisor_id = $sqlhashref2->{individual}; + $sth2->finish(); + $sth2 = $dbh->prepare("update tc_district set supervisor='$supervisor_id' where district='$district'"); + $sth2->execute or die "-E- DB error: $DBI::errstr\n"; + $sth2->finish(); } $sth->finish(); } diff --git a/inc/class.tc.inc.php b/inc/class.tc.inc.php index c47ef95..06a11e1 100644 --- a/inc/class.tc.inc.php +++ b/inc/class.tc.inc.php @@ -1366,7 +1366,7 @@ class tc $year = date('Y'); // Get the President - $sql = "SELECT * FROM tc_presidency where president=1 and valid=1"; + $sql = "SELECT * FROM tc_presidency AS tp JOIN tc_individual AS ti where tp.individual=ti.individual AND tp.president=1 AND tp.valid=1"; $this->db->query($sql,__LINE__,__FILE__); if($this->db->next_record()) { $president_name = $this->db->f('name'); @@ -1377,16 +1377,7 @@ class tc $interviewer = $this->db->f('individual'); $district_number = '*'; $district_name = $president_name; - $sql = "SELECT * FROM tc_individual where individual='$president_id'"; - $this->db2->query($sql,__LINE__,__FILE__); - if($this->db2->next_record()) { - $mls_id = $this->db2->f('mls_id'); - } - $sql = "SELECT * FROM tc_individual where mls_id='$mls_id'"; - $this->db2->query($sql,__LINE__,__FILE__); - if($this->db2->next_record()) { - $president_address = $this->db2->f('address'); - } + $president_address = $this->db->f('address'); } else { print "

-E- Unable to locate President in tc_presidency table

"; return; @@ -1784,7 +1775,7 @@ class tc } // Get the Districts - $sql = "SELECT * FROM tc_district where valid=1 ORDER BY district ASC"; + $sql = "SELECT * FROM tc_district AS td JOIN tc_presidency AS tp WHERE td.district=tp.district AND td.valid=1 ORDER BY td.district ASC"; $this->db->query($sql,__LINE__,__FILE__); $i=0; while ($this->db->next_record()) { @@ -1792,11 +1783,7 @@ class tc $districts[$i]['district'] = $this->db->f('district'); $districts[$i]['name'] = $this->db->f('name'); $districts[$i]['supervisor'] = $this->db->f('supervisor'); - $sql = "SELECT * FROM tc_presidency where district=$district and valid=1"; - $this->db2->query($sql,__LINE__,__FILE__); - if($this->db2->next_record()) { - $districts[$i]['presidency'] = $this->db2->f('presidency'); - } + $districts[$i]['presidency'] = $this->db->f('presidency'); $i++; } @@ -2144,7 +2131,7 @@ class tc $appt_table_data = ""; // Find out what the President ID is - $sql = "SELECT * FROM tc_presidency where president=1 and valid=1"; + $sql = "SELECT * FROM tc_presidency AS tp JOIN tc_individual AS ti WHERE tp.individual=ti.individual AND tp.president=1 AND tp.valid=1"; $this->db->query($sql,__LINE__,__FILE__); if($this->db->next_record()) { $presidency_name = $this->db->f('name'); @@ -2357,7 +2344,7 @@ class tc $this->t->set_var('lang_num_months','Years of History'); } - $sql = "SELECT * FROM tc_presidency where president=1 and valid=1"; + $sql = "SELECT * FROM tc_presidency AS tp JOIN tc_individual AS ti WHERE tp.individual=ti.individual AND tp.president=1 AND tp.valid=1"; $this->db->query($sql,__LINE__,__FILE__); if($this->db->next_record()) { $president_name = $this->db->f('name'); @@ -2481,7 +2468,7 @@ class tc $notes = get_var('notes',array('GET','POST')); $interview_type = get_var('interview_type',array('GET','POST')); - $sql = "SELECT * FROM tc_presidency where valid=1 and (president=1 or counselor=1 or secretary=1)"; + $sql = "SELECT * FROM tc_presidency AS tp JOIN tc_individual AS ti WHERE tp.individual=ti.individual AND tp.valid=1 AND (tp.president=1 OR tp.counselor=1 OR tp.secretary=1)"; $this->db2->query($sql,__LINE__,__FILE__); while ($this->db2->next_record()) { $indiv = $this->db2->f('individual'); @@ -2804,7 +2791,7 @@ class tc $notes = get_var('notes',array('GET','POST')); $interview_type = get_var('interview_type',array('GET','POST')); - $sql = "SELECT * FROM tc_presidency where valid=1 and (president=1 or counselor=1 or secretary=1 or district!=0)"; + $sql = "SELECT * FROM tc_presidency AS tp JOIN tc_individual AS ti WHERE tp.individual=ti.individual AND tp.valid=1 AND (tp.president=1 OR tp.counselor=1 OR tp.secretary=1 OR tp.district!=0)"; $this->db2->query($sql,__LINE__,__FILE__); while ($this->db2->next_record()) { $indiv = $this->db2->f('individual'); @@ -3549,7 +3536,7 @@ class tc $header_row.= "Location"; $table_data = ""; - $sql = "SELECT * FROM tc_presidency where valid=1 GROUP BY individual ORDER BY name ASC"; + $sql = "SELECT * FROM tc_presidency AS tp JOIN tc_individual AS ti WHERE tp.individual=ti.individual AND tp.valid=1 GROUP BY tp.individual ORDER BY ti.name ASC"; $this->db->query($sql,__LINE__,__FILE__); $i=0; while ($this->db->next_record()) { @@ -4056,7 +4043,6 @@ class tc $this->db2->query("UPDATE tc_presidency set" . " individual=" . $indiv . " ,district=" . $district . - " ,name='" . $name . "'" . " ,email='" . $email . "'" . " ,president='" . $president . "'" . " ,counselor='" . $counselor . "'" . @@ -4064,10 +4050,10 @@ class tc " WHERE presidency=" . $id,__LINE__,__FILE__); } else { //print "Adding New Entry
"; - $this->db2->query("INSERT INTO tc_presidency (presidency,individual,district,name," . + $this->db2->query("INSERT INTO tc_presidency (presidency,individual,district," . "email,president,counselor,secretary,valid) " . "VALUES (NULL,'" . $indiv . "','" . $district . "','" . - $name . "','" . $email . "','" . $president . "','" . + $email . "','" . $president . "','" . $counselor . "','" . $secretary . "','1'" . ")",__LINE__,__FILE__); } @@ -4093,7 +4079,7 @@ class tc ")",__LINE__,__FILE__); // Requery the tc_presidency table - $sql = "SELECT * FROM tc_presidency where valid=1"; + $sql = "SELECT * FROM tc_presidency AS tp JOIN tc_individual AS ti WHERE tp.individual=ti.individual AND tp.valid=1"; $this->db->query($sql,__LINE__,__FILE__); while ($this->db->next_record()) { // Extract the data for each presidency record @@ -4101,7 +4087,6 @@ class tc $indiv = $this->db->f('individual'); $name = $this->db->f('name'); $district = $this->db->f('district'); - $name = $this->db->f('name'); $valid = 1; // If we have a valid district, add it to the district table @@ -4124,7 +4109,7 @@ class tc // Now save off the data needed for a Presidency Table Update - $sql = "SELECT * FROM tc_presidency where valid=1"; + $sql = "SELECT tp.*, ti.name FROM tc_presidency AS tp JOIN tc_individual AS ti WHERE tp.individual=ti.individual AND tp.valid=1"; $this->db->query($sql,__LINE__,__FILE__); $table_data = ""; $header_row = "IndividualEmailDistrictPresidentCounselorSecretary"; @@ -4294,7 +4279,7 @@ class tc $dtstart = gmdate("Ymd"."\T"."His"."\Z", mktime($hour,$minute,$seconds,$month,$day,$year)); $dtstartstr = date("l, F d, o g:i A", mktime($hour,$minute,$seconds,$month,$day,$year)); - $sql = "SELECT * FROM tc_presidency where presidency='$presidency'"; + $sql = "SELECT * FROM tc_presidency AS tp JOIN tc_individual AS ti WHERE tp.individual=ti.individual AND tp.presidency='$presidency'"; $this->db2->query($sql,__LINE__,__FILE__); if($this->db2->next_record()) { $email = $this->db2->f('email'); diff --git a/sql/schema.dot b/sql/schema.dot index b189159..b5d91fa 100644 --- a/sql/schema.dot +++ b/sql/schema.dot @@ -2,89 +2,124 @@ digraph schema { graph [ rankdir = "LR" ]; - family [ - label = " family|| hofh_id| name| name_id| indiv_id| companionship| visit_pri| visit_notes| valid" + activity [ + label = "activity|| activity| assignment| date| notes" + shape = "record" + ]; + appointment [ + label = "appointment|| appointment|

presidency| family| individual | date| time| location| uid" + shape = "record" + ]; + assignment [ + label = "assignment|| assignment| name| abbreviation" + shape = "record" + ]; + attendance [ + label = "attendance|| individual| date" shape = "record" ]; - indiv [ - label = " indiv|| indiv_id| name| address|

phone| email| family| hh position| priesthood| steward| prospective| ppi_pri| ppi_notes| hti_pri| hti_notes| attending| valid" + calling [ + label = "calling|| name| organization|

position| sustained" shape = "record" ]; companionship [ - label = " companionship|| indiv| district| valid" + label = "companionship|| companionship| individual| district| scheduling_priority| valid" shape = "record" ]; - visit [ - label = " visit|| family| companionship| companion1| companion2| date| notes| visited| visit_type" + district [ + label = "district|| district| name| supervisor| valid" shape = "record" ]; - interview [ - label = " interview|| interviewer| indiv| date| notes| interview_type" + individual [ + label = "individual|| individual| mls_id| name| address|

phone| email| hh position| priesthood| steward| scheduling_priority| attending| valid" shape = "record" ]; - activity [ - label = " activity|| assignment| date| notes" + family [ + label = "family|| family| individual| companionship| scheduling_priority| valid" shape = "record" ]; participation [ - label = "participation|| indiv| activity" + label = "participation|| individual| activity" shape = "record" ]; - attendance [ - label = "attendance|| indiv| date" + interview [ + label = "interview|| interview| interviewer| individual| date| notes| interview_type" shape = "record" ]; - appointment [ - label = " appointment||

presidency| family| indiv | date| time| location| uid" + presidency [ + label = "presidency||

presidency|| individual| district| email| president| counselor| secreatary| valid" shape = "record" ]; - assignment [ - label = " assignment|| name| code" + visit [ + label = "visit|| visit| family| companionship| companion1| companion2| date| notes| visited| visit_type" shape = "record" ]; - calling [ - label = "calling|| indiv_id| name| organization|

position| sequence| sustained" + willingness [ + label = "willingness|| individual| assignment| willing" shape = "record" ]; - district [ - label = " district|| name| supervisor| valid" + scheduling_priority [ + label = "scheduling_priority|| scheduling_priority|

priority| notes" shape = "record" ]; - presidency [ - label = "

presidency|| indiv| district| name| email| president| counselor| secreatary| valid" + email_list [ + label = "email_list|| email_list| name" shape = "record" ]; - willingness [ - label = " indiv|| assignment| willing" + email_list_membership [ + label = "email_list_membership|| individual| email_list" + shape = "record" + ]; + accomplishment [ + label = "accomplishment|| accomplishment| individual| date| task| note" + shape = "record" + ]; + task [ + label = "task|| task| name| description" shape = "record" ]; - family:c -> companionship:c - companionship:i -> indiv:i + activity:s -> assignment:a - appointment:i -> indiv:i + appointment:p -> presidency:p appointment:f -> family:f + appointment:i -> individual:i - interview:il -> indiv:i - interview:i -> indiv:i + attendance:i -> individual:i - presidency:i -> indiv:i - presidency:d -> district:d + companionship:i -> individual:i + companionship:d -> district:d + companionship:sp -> scheduling_priority:sp + + district:s -> individual:i + + individual:sp -> scheduling_priority:sp + + family:i -> individual:i + family:c -> companionship:c + family:sp -> scheduling_priority:sp - willingness:i -> indiv:i - willingness:a -> assignment:a + participation:i -> individual:i + participation:a -> activity:a - activity:s -> assignment:a + interview:il -> individual:i + interview:i -> individual:i + + presidency:i -> individual:i + presidency:d -> district:d visit:c -> companionship:c visit:f -> family:f visit:c1 -> presidency:i visit:c2 -> presidency:i - participation:i -> indiv:i - participation:a -> activity:a - - attendance:i -> indiv:i + willingness:i -> individual:i + willingness:a -> assignment:a - indiv:f -> family:f + email_list_membership:i -> individual:i + email_list_membership:e -> email_list:e + + accomplishment:i -> individual:i + accomplishment:t -> task:t + } diff --git a/sql/tc.jpg b/sql/tc.jpg index 487cdfa..6b3279d 100644 Binary files a/sql/tc.jpg and b/sql/tc.jpg differ diff --git a/sql/tc.sql b/sql/tc.sql index fddc924..6090cdd 100644 --- a/sql/tc.sql +++ b/sql/tc.sql @@ -162,7 +162,6 @@ CREATE TABLE `tc_presidency` ( `presidency` int(16) unsigned NOT NULL auto_increment, `individual` int(16) unsigned NOT NULL default '0', `district` int(16) unsigned default '0', - `name` varchar(60) NOT NULL, `email` varchar(60) NOT NULL, `president` tinyint(1) default '0', `counselor` tinyint(1) default '0',