added tc_scheduling_priority table, removed pri and notes fields from tc_individual...
authorOwen Leonard <owen@balawis.leonard.fam>
Sat, 18 Sep 2010 03:40:05 +0000 (21:40 -0600)
committerOwen Leonard <owen@balawis.leonard.fam>
Sat, 18 Sep 2010 03:40:05 +0000 (21:40 -0600)
bin/import_ward_data
inc/class.tc.inc.php
sql/tc.sql

index 560650a517eb92d278497134d91b111962cd114d..b88cba81ccb6da2fe588d72f48d61086b2bbdbdd 100755 (executable)
@@ -105,22 +105,19 @@ sub print_hash
 ######################################################################
 
 # 3RD_INDIV
-#+-------------+------------------+------+-----+---------+----------------+
-#| Field       | Type             | Null | Key | Default | Extra          |
-#+-------------+------------------+------+-----+---------+----------------+
-#| individual  | int(16) unsigned |      | PRI | NULL    | auto_increment |
-#| mls_id      | int(16) unsigned |      |     | NULL    |                |
-#| name        | varchar(60)      | YES  |     | NULL    |                |
-#| phone       | varchar(12)      | YES  |     | NULL    |                |
-#| email       | varchar(120)     | YES  |     | NULL    |                |
-#| priesthood  | enum             | YES  |     | NULL    |                |
-#| ppi_pri     | int(10) unsigned | YES  |     | 1       |                |
-#| ppi_notes   | varchar(128)     | YES  |     | NULL    |                |
-#| hti_pri     | int(10) unsigned | YES  |     | 1       |                |
-#| hti_notes   | varchar(128)     | YES  |     | NULL    |                |
-#| attending   | tinyint(1)       | YES  |     | 0       |                |
-#| valid       | tinyint(1)       | YES  |     | NULL    |                |
-#+-------------+------------------+------+-----+---------+----------------+
+#+----------------------+------------------+------+-----+---------+----------------+
+#| Field                | Type             | Null | Key | Default | Extra          |
+#+----------------------+------------------+------+-----+---------+----------------+
+#| individual           | int(16) unsigned |      | PRI | NULL    | auto_increment |
+#| mls_id               | int(16) unsigned |      |     | NULL    |                |
+#| name                 | varchar(60)      | YES  |     | NULL    |                |
+#| phone                | varchar(12)      | YES  |     | NULL    |                |
+#| email                | varchar(120)     | YES  |     | NULL    |                |
+#| priesthood           | enum             | YES  |     | NULL    |                |
+#| scheduling_priority  | int(10) unsigned | YES  |     | 30      |                |
+#| attending            | tinyint(1)       | YES  |     | 0       |                |
+#| valid                | tinyint(1)       | YES  |     | NULL    |                |
+#+----------------------+------------------+------+-----+---------+----------------+
 sub update_tc_individual_table
 {
        print "\n-> Updating tc_individual table\n";
@@ -160,7 +157,7 @@ sub update_tc_individual_table
                if($rows == 0) {
                        # No existing records found for this individual, make a new entry
                        print "   Adding new individual: $individual_name\n";
-                       $sth = $dbh->prepare("insert into tc_individual values (NULL,'$id',\"$individual_name\",'$address','$phone','$email','','$hhposition','$priesthood','','$default_interview_pri','','$default_interview_pri','',$attending,1)");
+                       $sth = $dbh->prepare("insert into tc_individual values (NULL,'$id',\"$individual_name\",'$address','$phone','$email','','$hhposition','$priesthood',NULL,$attending,1)");
                        $sth->execute or die "-E- DB error: $DBI::errstr\n";
                } elsif($rows == 1) {
                        # An existing record was found for this individual, update it
@@ -271,14 +268,15 @@ sub update_tc_district_table
 }
 
 # 3RD_COMPANIONSHIP
-#+---------------+------------------+------+-----+---------+-------+
-#| Field         | Type             | Null | Key | Default | Extra |
-#+---------------+------------------+------+-----+---------+-------+
-#| companionship | int(16) unsigned |      |     | 0       |       |
-#| individual    | int(16) unsigned | YES  |     | NULL    |       |
-#| district      | int(16) unsigned | YES  |     | NULL    |       |
-#| valid         | tinyint(1)       | YES  |     | NULL    |       |
-#+---------------+------------------+------+-----+---------+-------+
+#+----------------------+------------------+------+-----+---------+-------+
+#| Field                | Type             | Null | Key | Default | Extra |
+#+----------------------+------------------+------+-----+---------+-------+
+#| companionship        | int(16) unsigned |      |     | 0       |       |
+#| individual           | int(16) unsigned | YES  |     | NULL    |       |
+#| district             | int(16) unsigned | YES  |     | NULL    |       |
+#| scheduling_priority  | int(10) unsigned | YES  |     | 30      |       |
+#| valid                | tinyint(1)       | YES  |     | NULL    |       |
+#+----------------------+------------------+------+-----+---------+-------+
 sub update_tc_companionship_table
 {
        print "\n-> Updating tc_companionship table\n";
@@ -309,7 +307,7 @@ sub update_tc_companionship_table
                                        if($rows == 0) {
                                                # No existing records found for this companionship, make a new entry
                                                print "   Adding Companion to companionship: $individual_name -> $id\n";
-                                               $sth = $dbh->prepare("insert into tc_companionship values ($id,'$individual','$district',1)");
+                                               $sth = $dbh->prepare("insert into tc_companionship values ($id,'$individual','$district',NULL,1)");
                                                $sth->execute or die "-E- DB error: $DBI::errstr\n";
                                        } else {
                                                # An existing companionship was found for this companionship, update it
@@ -332,19 +330,18 @@ sub update_tc_companionship_table
 }
 
 # 3RD_FAMILY
-#+---------------+------------------+------+-----+---------+-------+
-#| Field         | Type             | Null | Key | Default | Extra |
-#+---------------+------------------+------+-----+---------+-------+
-#| family        | int(16) unsigned |      | PRI | 0       |   A   |
-#| hofh_id       | int(16) unsigned | YES  |     | NULL    |       |
-#| name          | varchar(30)      | YES  |     | NULL    |       |
-#| name_id       | varchar(30)      | YES  |     | NULL    |       |
-#| individual    | int(16) unsigned | YES  |     | NULL    |       |
-#| companionship | int(16) unsigned | YES  |     | NULL    |       |
-#| visit_pri     | int(10) unsigned | YES  |     | 1       |       |
-#| visit_notes   | varchar(128)     | YES  |     | NULL    |       |
-#| valid         | tinyint(1)       | YES  |     | NULL    |       |
-#+---------------+------------------+------+-----+---------+-------+
+#+----------------------+------------------+------+-----+---------+-------+
+#| Field                | Type             | Null | Key | Default | Extra |
+#+----------------------+------------------+------+-----+---------+-------+
+#| family               | int(16) unsigned |      | PRI | 0       |   A   |
+#| hofh_id              | int(16) unsigned | YES  |     | NULL    |       |
+#| name                 | varchar(30)      | YES  |     | NULL    |       |
+#| name_id              | varchar(30)      | YES  |     | NULL    |       |
+#| individual           | int(16) unsigned | YES  |     | NULL    |       |
+#| companionship        | int(16) unsigned | YES  |     | NULL    |       |
+#| scheduling_priority  | int(10) unsigned | YES  |     | 30      |       |
+#| valid                | tinyint(1)       | YES  |     | NULL    |       |
+#+----------------------+------------------+------+-----+---------+-------+
 sub update_tc_family_table
 {
        print "\n-> Updating tc_family table\n";
@@ -375,7 +372,7 @@ sub update_tc_family_table
                                if($rows == 0) {
                                        # No existing records found for this family, make a new entry
                                        print "   Adding new Family: $family_name\n";
-                                       $sth = $dbh->prepare("insert into tc_family values (NULL,$id,'$family_name','$name_id','0','0','$default_visit_pri','',1)");
+                                       $sth = $dbh->prepare("insert into tc_family values (NULL,$id,'$family_name','$name_id','0','0',NULL,1)");
                                        $sth->execute or die "-E- DB error: $DBI::errstr\n";
                                } elsif($rows == 1) {
                                        # An existing record was found for this family, update it
@@ -628,6 +625,65 @@ sub update_organization_class_data
        }
 }
 
+sub update_tc_scheduling_priority_table
+{
+       print "\n-> Updating scheduling priority table\n";
+       
+       # individuals
+       # TODO: make steward flexible with a setting in the config file
+       $sth = $dbh->prepare("select * from tc_individual where steward='Elder' and valid=1");
+       $sth->execute or die "-E- DB error: $DBI::errstr\n";
+       while($sqlhashref = $sth->fetchrow_hashref) {
+               $individual = $sqlhashref->{individual};
+               $scheduling_priority = $sqlhashref->{scheduling_priority};
+               if ($scheduling_priority == 'NULL')
+               {
+                       $sth2 = $dbh->prepare("insert into tc_scheduling_priority values (NULL, 30, '')");
+                       $sth2->execute or die "-E- DB error: $DBI::errstr\n";
+                       $scheduling_priority = $dbh->last_insert_id(NULL,NULL,'tc_scheduling_priority',NULL);
+                       $sth2 = $dbh->prepare("update tc_individual set scheduling_priority=$scheduling_priority where individual=$individual");
+                       $sth2->execute or die "-E- DB error: $DBI::errstr\n";
+               }
+       }
+       
+       # families
+       # TODO: make steward flexible with a setting in the config file
+       $sth = $dbh->prepare("select tf.scheduling_priority, tf.family from tc_family AS tf JOIN tc_individual AS ti ON tf.individual=ti.individual and ti.steward='Elder' and tf.valid=1");
+       $sth->execute or die "-E- DB error: $DBI::errstr\n";
+       while($sqlhashref = $sth->fetchrow_hashref) {
+               $family = $sqlhashref->{family};
+               $scheduling_priority = $sqlhashref->{scheduling_priority};
+               #print "$family   $scheduling_priority\n";
+               if ($scheduling_priority == 'NULL')
+               {
+                       $sth2 = $dbh->prepare("insert into tc_scheduling_priority values (NULL, 30, '')");
+                       $sth2->execute or die "-E- DB error: $DBI::errstr\n";
+                       $scheduling_priority = $dbh->last_insert_id(NULL,NULL,'tc_scheduling_priority',NULL);
+                       $sth2 = $dbh->prepare("update tc_family set scheduling_priority=$scheduling_priority where family=$family");
+                       $sth2->execute or die "-E- DB error: $DBI::errstr\n";
+               }
+       }
+       
+       # companionships
+       # TODO: make steward flexible with a setting in the config file
+       $sth = $dbh->prepare("select tc.individual, tc.scheduling_priority from tc_companionship AS tc JOIN tc_individual AS ti ON tc.individual=ti.individual and (ti.steward='Elder' or ti.steward='') and tc.valid=1");
+       $sth->execute or die "-E- DB error: $DBI::errstr\n";
+       while($sqlhashref = $sth->fetchrow_hashref) {
+               $individual = $sqlhashref->{individual};
+               $scheduling_priority = $sqlhashref->{scheduling_priority};
+               #print "$individual   $scheduling_priority\n";
+               if ($scheduling_priority == 'NULL')
+               {
+                       $sth2 = $dbh->prepare("insert into tc_scheduling_priority values (NULL, 30, '')");
+                       $sth2->execute or die "-E- DB error: $DBI::errstr\n";
+                       $scheduling_priority = $dbh->last_insert_id(NULL,NULL,'tc_scheduling_priority',NULL);
+                       $sth2 = $dbh->prepare("update tc_companionship set scheduling_priority=$scheduling_priority where individual=$individual");
+                       $sth2->execute or die "-E- DB error: $DBI::errstr\n";
+               }
+       }
+       
+}
+
 ######################################################################
 # MAIN
 ######################################################################
@@ -699,6 +755,7 @@ if($opt_s) { $dbh->disconnect(); exit; }
 &update_tc_visit_table();
 &update_family_in_tc_individual_table();
 &update_organization_class_data();
+&update_tc_scheduling_priority_table();
 
 print "\n-> Import Successful! DONE...\n";
 
index 976709f698adde9b94b3a6a7bb1e7e9fb3523abf..07c0b0e06e97ea6d00a60d641be19ebe2df4867c 100644 (file)
@@ -1406,17 +1406,27 @@ class tc
                        }
 
                        // Save any changes made to the ppi notes table
-                       $new_data = get_var('ppi_notes',array('POST'));
+                       $new_data = get_var('notes',array('POST'));
                        foreach ($new_data as $entry) {
-                               $ppi_notes = $entry['notes'];
+                               $notes = $entry['notes'];
                                $individual = $entry['individual'];
-                               $ppi_pri = $entry['pri'];
+                               $priority = $entry['pri'];
 
                                // Perform database save actions here
+                               $sql = "SELECT * FROM tc_individual WHERE individual='$individual'";
+                               $this->db->query($sql,__LINE__,__FILE__);
+                               if ($this->db->next_record()) {
+                                       $scheduling_priority = $this->db->f('scheduling_priority');
+                                       $this->db2->query("UPDATE tc_scheduling_priority SET priority='$priority' AND notes=\"$notes\" WHERE scheduling_priority='$scheduling_priority'", __LINE__, __FILE__);
+                               }
+
+/*
                                $this->db->query("UPDATE tc_individual set " .
-                                                " ppi_notes='" . $ppi_notes . "'" .
-                                                ",ppi_pri='" . $ppi_pri . "'" .
+                                                " notes='" . $notes . "'" .
+                                                ",priority='" . $priority . "'" .
                                                 " WHERE individual=" . $individual,__LINE__,__FILE__);
+*/
+
 
                        }
 
@@ -1508,7 +1518,7 @@ class tc
 
                // PPI SCHEDULING TABLE
                // TODO:  changed this so it picks the quorum dynamically
-               $sql = "SELECT * FROM tc_individual where valid=1 and steward='Elder' ORDER BY ppi_pri ASC, name ASC";
+               $sql = "SELECT * FROM tc_individual as ti JOIN tc_scheduling_priority as tsp where ti.scheduling_priority=tsp.scheduling_priority and steward='Elder' and valid=1 ORDER by tsp.priority ASC, ti.name ASC";
                $this->db->query($sql,__LINE__,__FILE__);
 
                $i=0; 
@@ -1517,8 +1527,8 @@ class tc
                        $individual[$i] = $this->db->f('individual');
                        $indiv_name[$i] = $this->db->f('name');
                        $indiv_phone[$individual[$i]] = $this->db->f('phone');
-                       $indiv_ppi_pri[$individual[$i]] = $this->db->f('ppi_pri');
-                       $indiv_ppi_notes[$individual[$i]] = $this->db->f('ppi_notes');
+                       $indiv_priority[$individual[$i]] = $this->db->f('priority');
+                       $indiv_notes[$individual[$i]] = $this->db->f('notes');
                        $i++;
                        $total_indivs++;
                }
@@ -1529,8 +1539,8 @@ class tc
                        $id = $individual[$i];
                        $name = $indiv_name[$i];
                        $phone = $indiv_phone[$id];
-                       $ppi_pri = $indiv_ppi_pri[$id];
-                       $ppi_notes = $indiv_ppi_notes[$id];
+                       $priority = $indiv_priority[$id];
+                       $notes = $indiv_notes[$id];
 
                        // If this individual has had a yearly PPI this year, don't show him on the schedule list
                        $year_start = $year - 1 . "-12-31"; $year_end = $year + 1 . "-01-01";
@@ -1558,12 +1568,12 @@ class tc
                                $this->t->set_var('tr_color',$tr_color);
                                $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>$ppi_pri</td>";
+                               //$table_data.= "<td align=center>$priority</td>";
                                $table_data.= "<td align=center>";
-                               $table_data.= '<select name=ppi_notes['.$i.'][pri]>';
+                               $table_data.= '<select name=notes['.$i.'][pri]>';
                                foreach(range(0,6) as $num) {
                                        if($num == 0) { $num = 1; } else {$num = $num*5; }
-                                       if($ppi_pri == $num) { 
+                                       if($priority == $num) { 
                                                $selected[$num] = 'selected="selected"'; 
                                        } else { 
                                                $selected[$num] = ''; 
@@ -1572,9 +1582,9 @@ class tc
                                }
                                $table_data.= '</select></td>';
                                $table_data.= "<td align=center>$date</td>";
-                               $table_data.= '<td><input type=text size="50" maxlength="128" name="ppi_notes['.$i.'][notes]" value="'.$ppi_notes.'">';
-                               $table_data.= '<input type=hidden name="ppi_notes['.$i.'][individual]" value="'.$id.'">';
-                               $table_data.= '<input type=hidden name="ppi_notes['.$i.'][indiv_name]" value="'.$name.'">';
+                               $table_data.= '<td><input type=text size="50" maxlength="128" name="notes['.$i.'][notes]" value="'.$notes.'">';
+                               $table_data.= '<input type=hidden name="notes['.$i.'][individual]" value="'.$id.'">';
+                               $table_data.= '<input type=hidden name="notes['.$i.'][indiv_name]" value="'.$name.'">';
                                $table_data.= '</td>';
                                $table_data.= '</tr>';
                        } else {
@@ -1588,14 +1598,14 @@ class tc
                                $link = $GLOBALS['phpgw']->link('/tc/index.php',$link_data);    
                                $indivs_with_yearly_ppi++;
                                $date = $this->db2->f('date');
-                               $ppi_notes = $this->db2->f('notes');
-                               if(strlen($ppi_notes) > 40) { $ppi_notes = substr($ppi_notes,0,40) . "..."; }
+                               $notes = $this->db2->f('notes');
+                               if(strlen($notes) > 40) { $notes = substr($notes,0,40) . "..."; }
                                $tr_color2 = $this->nextmatchs->alternate_row_color($tr_color2);
                                $this->t->set_var('tr_color2',$tr_color2);
                                $completed_data.= "<tr bgcolor=". $this->t->get_var('tr_color2') ."><td title=\"$phone\"><a href=$link>$name</a></td>";
                                $completed_data.= "<td align=center>$phone</td>";
                                $completed_data.= "<td align=center><a href=".$link.">$date</a></td>";
-                               $completed_data.= "<td align=left>$ppi_notes</td>";
+                               $completed_data.= "<td align=left>$notes</td>";
                                $completed_data.= '</tr>';
                        }
                } // End for individuals Loop
@@ -1756,10 +1766,17 @@ class tc
                                $hti_pri = $entry['pri'];
                                //print "hti_notes: $hti_notes indiv_name: $indiv_name <Br>";
                                // Perform database save actions here
+                               $this->db->query("SELECT * FROM tc_companionship WHERE individual=$individual and valid=1",__LINE__,__FILE__);
+                               if ($this->db->next_record()) {
+                                       $scheduling_priority = $this->db->f('scheduling_priority');
+                                       $this->db2->query("UPDATE tc_scheduling_priority SET priority='$hti_pri' and notes=\"hti_notes\" where scheduling_priority=$scheduling_priority",__LINE__,__FILE__);
+                               }
+/*
                                $this->db->query("UPDATE tc_individual set " .
                                                 " hti_notes='" . $hti_notes . "'" .
                                                 ",hti_pri='" . $hti_pri . "'" .
                                                 " WHERE individual=" . $individual,__LINE__,__FILE__);
+*/
                        }
 
                        $take_me_to_url = $GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.int_sched');
@@ -1885,7 +1902,7 @@ class tc
                        $i=0;
                        for ($j=0; $j < count($unique_companionships); $j++) {
                                // Select all the companions from each companionship
-                               $sql = "SELECT * FROM tc_companionship where valid=1 and 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'];
@@ -1896,20 +1913,11 @@ class tc
                                        // Get this companions information
                                        $individual = $this->db->f('individual');
 
-                                       $sql = "SELECT * FROM tc_individual where individual='$individual'";
-                                       $this->db2->query($sql,__LINE__,__FILE__);      
-                                       if($this->db2->next_record()) {
-                                               $individual = $this->db2->f('individual');
-                                               $indiv_name = $this->db2->f('name');
-                                               $indiv_phone[$individual] = $this->db2->f('phone');
-                                               $indiv_hti_pri[$individual] = $this->db2->f('hti_pri');
-                                               $indiv_hti_notes[$individual] = $this->db2->f('hti_notes');
-                                       }
-                                       $id = $individual;
-                                       $name = $indiv_name;
-                                       $phone = $indiv_phone[$id];
-                                       $hti_pri = $indiv_hti_pri[$id];
-                                       $hti_notes = $indiv_hti_notes[$id];
+                                       $id = $this->db->f('individual');
+                                       $name = $this->db->f('name');
+                                       $phone = $this->db->f('phone');
+                                       $hti_pri = $this->db->f('priority');
+                                       $hti_notes = $this->db->f('notes');
 
                                        // If the companionship has already had its quarterly interview,
                                        // Skip the other companion in the companionship.
@@ -2118,10 +2126,17 @@ class tc
                                $visit_pri = $entry['pri'];
 
                                // Perform database save actions here
+                               $this->db->query("SELECT * FROM tc_family WHERE family='$family'",__LINE__,__FILE__);
+                               if ($this->db->next_record()) {
+                                       $scheduling_priority = $this->db->f('scheduling_priority');
+                                       $this->db2->query("UPDATE tc_scheduling_priority SET priority='$visit_pri' AND notes=\"$visit_notes\" WHERE scheduling_priority='$scheduling_priority'",__LINE__,__FILE__);
+                               }
+/*
                                $this->db->query("UPDATE tc_family set " .
                                                 " visit_notes='" . $visit_notes . "'" .
                                                 ",visit_pri='" . $visit_pri . "'" .
                                                 " WHERE family=" . $family,__LINE__,__FILE__);
+*/
                        }
 
                        $take_me_to_url = $GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.vis_sched');
@@ -2203,7 +2218,7 @@ class tc
 
 
                // VISIT SCHEDULING TABLE
-               $sql = "SELECT * FROM tc_family where valid=1 and individual != 0  and companionship != 0 ORDER BY visit_pri ASC, name ASC";
+               $sql = "SELECT * FROM tc_family AS tf JOIN tc_scheduling_priority AS tsp WHERE tf.scheduling_priority=tsp.scheduling_priority AND tf.valid=1 AND tf.individual != 0  AND tf.companionship != 0 ORDER BY tsp.priority ASC, tf.name ASC";
                $this->db->query($sql,__LINE__,__FILE__);
 
                $total_families=0; $families_with_yearly_visit=0;
@@ -2390,15 +2405,15 @@ class tc
                $this->t->set_var('district_name',$president_name);
 
                // TODO:  changed this so it picks the quorum dynamically
-               $sql = "SELECT * FROM tc_individual where steward='Elder' and valid=1 ORDER BY individual ASC";
+               $sql = "SELECT * FROM tc_individual AS ti JOIN tc_scheduling_priority as tsp where ti.scheduling_priority=tsp.scheduling_priority and ti.steward='Elder' and ti.valid=1 ORDER BY ti.individual ASC";
                $this->db->query($sql,__LINE__,__FILE__);
                $i=0;
                while ($this->db->next_record()) {
                        $individual[$i] = $this->db->f('individual');
                        $indiv_name[$i] = $this->db->f('name');
                        $indiv_phone[$individual[$i]] = $this->db->f('phone');
-                       $indiv_ppi_pri[$individual[$i]] = $this->db->f('ppi_pri');
-                       $indiv_ppi_notes[$individual[$i]] = $this->db->f('ppi_notes');
+                       $indiv_priority[$individual[$i]] = $this->db->f('priority');
+                       $indiv_notes[$individual[$i]] = $this->db->f('notes');
                        $i++;
                }
                $total_indivs=$i;
index 531b98e02ec3e36afcee0baaf3d3c962766eae70..71902b6063642629e0f9897c0bcef9871aa04383 100644 (file)
@@ -87,6 +87,7 @@ CREATE TABLE `tc_companionship` (
   `companionship` int(16) unsigned NOT NULL default '0',
   `individual` int(16) unsigned NOT NULL default '0',
   `district` int(16) unsigned default NULL,
+  `scheduling_priority` int(16) unsigned default NULL,
   `valid` tinyint(1) default NULL,
   KEY `companionship` (`companionship`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
@@ -116,10 +117,7 @@ CREATE TABLE `tc_individual` (
   `hh_position` enum('Head of Household','Spouse','Other') DEFAULT 'Other',
   `priesthood` enum('High Priest','Elder','Priest','Teacher','Deacon','Unordained') DEFAULT NULL,
   `steward` enum('High Priest','Elder') DEFAULT NULL,
-  `ppi_pri` int(10) unsigned NOT NULL default '1',
-  `ppi_notes` varchar(128) default NULL,
-  `hti_pri` int(10) unsigned default '1',
-  `hti_notes` varchar(128) default NULL,
+  `scheduling_priority` int(16) unsigned default NULL,
   `attending` tinyint(1) default '0',
   `valid` tinyint(1) default NULL,
   PRIMARY KEY  (`individual`)
@@ -135,8 +133,7 @@ CREATE TABLE `tc_family` (
   `name_id` varchar(30) NOT NULL default '',
   `individual` int(16) unsigned default '0',
   `companionship` int(16) unsigned default NULL,
-  `visit_pri` int(10) unsigned default '1',
-  `visit_notes` varchar(128) default NULL,
+  `scheduling_priority` int(16) unsigned default NULL,
   `valid` tinyint(1) default NULL,
   PRIMARY KEY  (`family`)
 ) ENGINE=MyISAM AUTO_INCREMENT=277 DEFAULT CHARSET=latin1;
@@ -206,3 +203,12 @@ CREATE TABLE `tc_willingness` (
   `willing` enum('y','n','') NOT NULL,
   KEY `individual` (`individual`,`assignment`)
 ) ENGINE=MyISAM DEFAULT CHARSET=latin1;
+
+--
+-- Table structure for table `tc_scheduling_priority`
+--
+CREATE TABLE `phpgroupware`.`tc_scheduling_priority` (
+`scheduling_priority` INT( 16 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
+`priority` INT( 10 ) UNSIGNED NOT NULL DEFAULT '30',
+`notes` VARCHAR( 128 ) NOT NULL DEFAULT ''
+) ENGINE = MYISAM ;