}
}
-# TC_DISTRICT
-#+------------+------------------+------+-----+---------+-------+
-#| Field | Type | Null | Key | Default | Extra |
-#+------------+------------------+------+-----+---------+-------+
-#| district | int(16) unsigned | | PRI | 0 | |
-#| name | varchar(30) | YES | | NULL | |
-#| supervisor | int(16) unsigned | YES | | NULL | |
-#| valid | tinyint(1) | YES | | NULL | |
-#+------------+------------------+------+-----+---------+-------+
-sub update_tc_district_table
-{
- # Districts should be created by hand. This subroutine only
- # updates the supervisor's ID in each district.
- print "\n-> Updating tc_district table\n";
- $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();
- }
- $sth->finish();
-}
-
# TC_COMPANIONSHIP
#+----------------------+------------------+------+-----+---------+-------+
#| Field | Type | Null | Key | Default | Extra |
# Now update the various eq DB tables
&update_tc_calling_table();
&update_tc_individual_table();
-&update_tc_district_table();
&update_tc_companionship_table();
&update_tc_family_table();
&update_tc_visit_table();
$this->t->set_var('actionurl',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.ht_view'));
$this->t->set_var('title','Hometeaching');
- $sql = "SELECT * FROM tc_district where valid=1 ORDER BY district ASC";
+ $sql = "SELECT * FROM tc_district AS td JOIN tc_individual AS ti WHERE td.supervisor=ti.individual AND td.valid=1 ORDER BY td.district ASC";
$this->db->query($sql,__LINE__,__FILE__);
$i=0;
while ($this->db->next_record()) {
}
// Get the Districts
- $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";
+ $sql = "SELECT * FROM tc_district AS td JOIN (tc_presidency AS tp, tc_individual AS ti) WHERE td.district=tp.district AND td.supervisor=ti.individual AND td.valid=1 ORDER BY td.district ASC";
$this->db->query($sql,__LINE__,__FILE__);
$i=0;
while ($this->db->next_record()) {
$i=0;
for ($j=0; $j < count($unique_companionships); $j++) {
// Select all the companions from each companionship
- $sql = "SELECT * FROM tc_companionship AS tc JOIN (tc_scheduling_priority AS tsp, tc_individual as ti) WHERE tc.scheduling_priority=tsp.scheduling_priority AND tc.individual=ti.individual AND tc.valid=1 AND tc.companionship=". $unique_companionships[$j]['companionship'];
+ $sql = "SELECT * FROM tc_companionship AS tc JOIN (tc_scheduling_priority AS tsp, tc_individual AS ti) WHERE tc.scheduling_priority=tsp.scheduling_priority AND tc.individual=ti.individual AND tc.valid=1 AND tc.companionship=". $unique_companionships[$j]['companionship'];
$this->db->query($sql,__LINE__,__FILE__);
$k=0; $int_completed=0;
$comp = $unique_companionships[$j]['companionship'];
else if($current_month >= 7 && $current_month <= 9) { $current_month=9; }
else if($current_month >= 10 && $current_month <= 12) { $current_month=12; }
- $sql = "SELECT * FROM tc_district where valid=1 ORDER BY district ASC";
+ $sql = "SELECT * FROM tc_district AS td JOIN tc_individual AS ti WHERE td.supervisor=ti.individual AND td.valid=1 ORDER BY td.district ASC";
$this->db->query($sql,__LINE__,__FILE__);
$i=0;
while ($this->db->next_record()) {
$name = "High Priests";
$indiv = 0;
$valid = 0;
- $this->db2->query("INSERT INTO tc_district (district,name,supervisor,valid) " .
- "VALUES ('" . $district . "','" . $name . "','" .
+ $this->db2->query("INSERT INTO tc_district (district,supervisor,valid) " .
+ "VALUES ('" . $district . "','" .
$indiv . "','" . $valid . "'" .
")",__LINE__,__FILE__);
// If we have a valid district, add it to the district table
if($district > 0) {
- $this->db2->query("INSERT INTO tc_district (district,name,supervisor,valid) " .
- "VALUES ('" . $district . "','" . $name . "','" .
+ $this->db2->query("INSERT INTO tc_district (district,supervisor,valid) " .
+ "VALUES ('" . $district . "','" .
$indiv . "','" . $valid . "'" .
")",__LINE__,__FILE__);
}