X-Git-Url: http://git.pippins.net/embedvideo/.git/static/git-logo.png?a=blobdiff_plain;f=inc%2Fclass.tc.inc.php;h=b1995ed9202c5c266d0251ed472a416c08b6114f;hb=1d7d0afcd39dbd2c4c4ebe13ac110cb984270761;hp=6a6a6e73ee4d9a4ad315fce442bda915f087fc7e;hpb=9cbfdccb986373952fc820285cbc027b41c44b5e;p=eq%2F.git diff --git a/inc/class.tc.inc.php b/inc/class.tc.inc.php index 6a6a6e7..b1995ed 100644 --- a/inc/class.tc.inc.php +++ b/inc/class.tc.inc.php @@ -228,7 +228,7 @@ class tc $this->t->set_var('ht_sandbox_link',$GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.ht_sandbox')); $this->t->set_var('ht_sandbox_link_title','Hometeaching Sandbox'); - $sql = "SELECT * FROM tc_district AS td JOIN tc_individual AS ti WHERE td.leader=ti.individual AND td.valid=1 ORDER BY td.district ASC"; + $sql = "SELECT * FROM tc_district AS td JOIN (tc_individual AS ti, tc_leader AS tl) WHERE td.leader=tl.leader AND tl.individual=ti.individual AND td.valid=1 ORDER BY td.district ASC"; $this->db->query($sql,__LINE__,__FILE__); $i=0; while ($this->db->next_record()) { @@ -874,7 +874,7 @@ class tc $email_contents .= "\r\n"; // email changes to leader - $sql = "SELECT DISTINCT tp.email AS email1, ti.email AS email2 FROM tc_leader AS tl JOIN tc_individual AS ti WHERE tl.individual=ti.individual AND (tl.president=1 OR tl.counselor=1 OR tl.secretary=1) AND tl.valid=1"; + $sql = "SELECT DISTINCT tp.email AS email1, ti.email AS email2 FROM tc_leader AS tl JOIN tc_individual AS ti WHERE tl.individual=ti.individual AND (tl.type='P' OR tl.type='C' OR tl.type='S') AND tl.valid=1"; $this->db->query($sql,__LINE__,__FILE__); while ($this->db->next_record()) { $email = ""; @@ -889,7 +889,7 @@ class tc $to .= ", $email"; } } - $sql = "SELECT DISTINCT tp.email AS email1, ti.email AS email2 FROM tc_leader AS tl JOIN tc_individual AS ti WHERE tl.individual=ti.individual AND tl.president=1 AND tl.valid=1"; + $sql = "SELECT DISTINCT tp.email AS email1, ti.email AS email2 FROM tc_leader AS tl JOIN tc_individual AS ti WHERE tl.individual=ti.individual AND tl.type='P' AND tl.valid=1"; $this->db->query($sql,__LINE__,__FILE__); if ($this->db->next_record()) { if ($this->db->f('email1') != "") { @@ -1965,9 +1965,9 @@ class tc // Get the President $sql = "SELECT * FROM tc_leader AS tl JOIN tc_individual AS ti where tl.individual=ti.individual AND tl.valid=1 AND "; - if($this->yearly_ppi_interviewer == 1) { $sql .= " (tl.president=1)"; } - if($this->yearly_ppi_interviewer == 2) { $sql .= " (tl.president=1 OR tl.counselor=1)"; } - if($this->yearly_ppi_interviewer == 3) { $sql .= " (tl.president=1 OR tl.counselor=1 OR tl.secretary=1)"; } + if($this->yearly_ppi_interviewer == 1) { $sql .= " (tl.type='P')"; } + if($this->yearly_ppi_interviewer == 2) { $sql .= " (tl.type='P' OR tl.type='C')"; } + if($this->yearly_ppi_interviewer == 3) { $sql .= " (tl.type='P' OR tl.type='C' OR tl.type='S')"; } $this->db->query($sql,__LINE__,__FILE__); while ($this->db->next_record()) { $leader_name = $this->db->f('name'); @@ -2287,7 +2287,7 @@ class tc } // Get the Districts - $sql = "SELECT * FROM tc_district AS td JOIN (tc_leader AS tl, tc_individual AS ti) WHERE td.district=tl.district AND td.leader=ti.individual AND td.valid=1 ORDER BY td.district ASC"; + $sql = "SELECT * FROM tc_district AS td JOIN (tc_leader AS tl, tc_individual AS ti) WHERE td.leader=tl.leader AND tl.individual=ti.individual AND td.valid=1 ORDER BY td.district ASC"; $this->db->query($sql,__LINE__,__FILE__); $i=0; while ($this->db->next_record()) { @@ -2295,7 +2295,6 @@ class tc $districts[$i]['district'] = $this->db->f('district'); $districts[$i]['name'] = $this->db->f('name'); $districts[$i]['leader'] = $this->db->f('leader'); - $districts[$i]['leader'] = $this->db->f('leader'); $i++; } @@ -2625,7 +2624,7 @@ class tc $appt_table_data = ""; // Find out what the President ID is - $sql = "SELECT * FROM tc_leader AS tl JOIN tc_individual AS ti WHERE tl.individual=ti.individual AND tl.president=1 AND tl.valid=1"; + $sql = "SELECT * FROM tc_leader AS tl JOIN tc_individual AS ti WHERE tl.individual=ti.individual AND tl.type='P' AND tl.valid=1"; $this->db->query($sql,__LINE__,__FILE__); if($this->db->next_record()) { $leader_name = $this->db->f('name'); @@ -2832,7 +2831,7 @@ class tc $this->t->set_var('lang_num_months','Years of History'); } - $sql = "SELECT * FROM tc_leader AS tl JOIN tc_individual AS ti WHERE tl.individual=ti.individual AND tl.president=1 AND tl.valid=1"; + $sql = "SELECT * FROM tc_leader AS tl JOIN tc_individual AS ti WHERE tl.individual=ti.individual AND tl.type='P' AND tl.valid=1"; $this->db->query($sql,__LINE__,__FILE__); if($this->db->next_record()) { $president_name = $this->db->f('name'); @@ -2955,17 +2954,17 @@ class tc $type = get_var('type',array('GET','POST')); $sql = "SELECT * FROM tc_leader AS tl JOIN tc_individual AS ti WHERE tl.individual=ti.individual AND tl.valid=1 AND "; - if($this->yearly_ppi_interviewer == 1) { $sql .= " (tl.president=1)"; } - if($this->yearly_ppi_interviewer == 2) { $sql .= " (tl.president=1 OR tl.counselor=1)"; } - if($this->yearly_ppi_interviewer == 3) { $sql .= " (tl.president=1 OR tl.counselor=1 OR tl.secretary=1)"; } + if($this->yearly_ppi_interviewer == 1) { $sql .= " (tl.type='P')"; } + if($this->yearly_ppi_interviewer == 2) { $sql .= " (tl.type='P' OR tl.type='C')"; } + if($this->yearly_ppi_interviewer == 3) { $sql .= " (tl.type='P' OR tl.type='C' OR tl.type='S')"; } $this->db2->query($sql,__LINE__,__FILE__); while ($this->db2->next_record()) { - $indiv = $this->db2->f('individual'); + $leader = $this->db2->f('leader'); $interviewer_name = $this->db2->f('name'); - if($indiv == $interviewer) { - $this->t->set_var('interviewer',$indiv . ' selected'); + if($leader == $interviewer) { + $this->t->set_var('interviewer',$leader . ' selected'); } else { - $this->t->set_var('interviewer',$indiv); + $this->t->set_var('interviewer',$leader); } #print "indiv: $indiv interviewer: $interviewer
"; $this->t->set_var('interviewer_name',$interviewer_name); @@ -3091,7 +3090,7 @@ class tc 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 AS td JOIN tc_individual AS ti WHERE td.leader=ti.individual AND td.valid=1 ORDER BY td.district ASC"; + $sql = "SELECT * FROM tc_district AS td JOIN (tc_individual AS ti, tc_leader AS tl) WHERE td.leader=tl.leader AND tl.individual=ti.individual AND td.valid=1 ORDER BY td.district ASC"; $this->db->query($sql,__LINE__,__FILE__); $i=0; while ($this->db->next_record()) { @@ -3283,15 +3282,15 @@ class tc $notes = get_var('notes',array('GET','POST')); $type = get_var('type',array('GET','POST')); - $sql = "SELECT * FROM tc_leader AS tl JOIN tc_individual AS ti WHERE tl.individual=ti.individual AND tl.valid=1 AND (tl.president=1 OR tl.counselor=1 OR tl.secretary=1 OR tl.district!=0)"; + $sql = "SELECT * FROM tc_leader AS tl JOIN (tc_individual AS ti, tc_district AS td) WHERE tl.individual=ti.individual AND tl.leader=td.leader AND tl.valid=1 AND (tl.type='P' OR tl.type='C' OR tl.type='D' OR td.district!=0)"; $this->db2->query($sql,__LINE__,__FILE__); while ($this->db2->next_record()) { - $indiv = $this->db2->f('individual'); + $leader = $this->db2->f('leader'); $interviewer_name = $this->db2->f('name'); - if($indiv == $interviewer) { - $this->t->set_var('interviewer',$indiv . ' selected'); + if($leader == $interviewer) { + $this->t->set_var('interviewer',$leader . ' selected'); } else { - $this->t->set_var('interviewer',$indiv); + $this->t->set_var('interviewer',$leader); } $this->t->set_var('interviewer_name',$interviewer_name); $this->t->fp('int_list','interviewer_list',True); @@ -4512,6 +4511,21 @@ class tc } } else if($action == "leader") { $new_data = get_var('eqpres',array('POST')); + + // Delete all the previous district entries from the table + $this->db->query("DELETE from tc_district where valid=1",__LINE__,__FILE__); + $this->db->query("DELETE from tc_district where valid=0",__LINE__,__FILE__); + + // Always add a "District 0" assigned to the High Priests Group + $district = 0; + $name = "High Priests"; + $indiv = 0; + $valid = 0; + $this->db2->query("INSERT INTO tc_district (district,leader,valid) " . + "VALUES ('" . $district . "','" . + $indiv . "','" . $valid . "'" . + ")",__LINE__,__FILE__); + foreach ($new_data as $entry) { $id = $entry['id']; $email = $entry['email']; @@ -4527,66 +4541,40 @@ class tc //print "counselor=$counselor secretary=$secretary
"; if(($indiv > 0) || ($name != "")) { + $leader_type = 'D'; + if ($secretary == 1) {$leader_type = 'S';} + if ($counselor == 1) {$leader_type = 'C';} + if ($president == 1) {$leader_type = 'P';} if($id < $this->max_leader_members) { //print "Updating Existing Entry
"; $this->db2->query("UPDATE tc_leader set" . " individual=" . $indiv . - " ,district=" . $district . " ,email='" . $email . "'" . - " ,president='" . $president . "'" . - " ,counselor='" . $counselor . "'" . - " ,secretary='" . $secretary . "'" . + " ,type='" . $leader_type . "'" . " WHERE leader=" . $id,__LINE__,__FILE__); } else { //print "Adding New Entry
"; - $this->db2->query("INSERT INTO tc_leader (leader,individual,district," . - "email,president,counselor,secretary,valid) " . - "VALUES (NULL,'" . $indiv . "','" . $district . "','" . - $email . "','" . $president . "','" . - $counselor . "','" . $secretary . "','1'" . + $this->db2->query("INSERT INTO tc_leader (leader,individual," . + "email,type,valid) " . + "VALUES (NULL,'" . $indiv . "','" . + $email . "','" . $leader_type . "','1'" . ")",__LINE__,__FILE__); + $id = mysql_insert_id(); + } + + // If we have a valid district, add it to the district table + if($district > 0) { + $valid = 1; + $this->db2->query("INSERT INTO tc_district (district,leader,valid) " . + "VALUES ('" . $district . "','" . + $id . "','" . $valid . "'" . + ")",__LINE__,__FILE__); } } else { //print "Ignoring Blank Entry
"; } } - // Now update the tc_district table appropriately - - // Delete all the previous district entries from the table - $this->db->query("DELETE from tc_district where valid=1",__LINE__,__FILE__); - $this->db->query("DELETE from tc_district where valid=0",__LINE__,__FILE__); - - // Always add a "District 0" assigned to the High Priests Group - $district = 0; - $name = "High Priests"; - $indiv = 0; - $valid = 0; - $this->db2->query("INSERT INTO tc_district (district,leader,valid) " . - "VALUES ('" . $district . "','" . - $indiv . "','" . $valid . "'" . - ")",__LINE__,__FILE__); - - // Requery the tc_leader table - $sql = "SELECT * FROM tc_leader AS tl JOIN tc_individual AS ti WHERE tl.individual=ti.individual AND tl.valid=1"; - $this->db->query($sql,__LINE__,__FILE__); - while ($this->db->next_record()) { - // Extract the data for each leader record - $id = $this->db->f('leader'); - $indiv = $this->db->f('individual'); - $name = $this->db->f('name'); - $district = $this->db->f('district'); - $valid = 1; - - // If we have a valid district, add it to the district table - if($district > 0) { - $this->db2->query("INSERT INTO tc_district (district,leader,valid) " . - "VALUES ('" . $district . "','" . - $indiv . "','" . $valid . "'" . - ")",__LINE__,__FILE__); - } - } - $this->t->set_var('adminhandle',''); $this->t->pfp('adminhandle','admin'); } @@ -4606,12 +4594,20 @@ class tc // Extract the data for each leader record $id = $this->db->f('leader'); $indiv = $this->db->f('individual'); - $district = $this->db->f('district'); $name = $this->db->f('name'); $email = $this->db->f('email'); - $president = $this->db->f('president'); - $counselor = $this->db->f('counselor'); - $secretary = $this->db->f('secretary'); + $leader_type = $this->db->f('type'); + if ($leader_type == 'P') {$president = 1;} else {$president = 0;} + if ($leader_type == 'C') {$counselor = 1;} else {$counselor = 0;} + if ($leader_type == 'S') {$secretary = 1;} else {$secretary = 0;} + + $sql = "SELECT * FROM tc_district AS td JOIN tc_leader AS tl WHERE td.leader=tl.leader AND td.leader=$id AND td.district!=0 AND td.valid=1"; + $this->db2->query($sql,__LINE__,__FILE__); + if ($this->db2->next_record()) { + $district = $this->db2->f('district'); + } else { + $district = 0; + } // Create the forms needed in the table $table_data .= "";