fixed updating tc_scheduling_priority so we don't get jumbled information
authorOwen Leonard <owen@balawis.leonard.fam>
Sat, 18 Sep 2010 17:41:52 +0000 (11:41 -0600)
committerOwen Leonard <owen@balawis.leonard.fam>
Sat, 18 Sep 2010 17:41:52 +0000 (11:41 -0600)
inc/class.tc.inc.php
sql/tc.sql

index 8de0e856b0d29cded864d91961f4f7b7a5ec61ea..c47ef9552c14ac35c527bc07dbc28b4cad865a95 100644 (file)
@@ -109,6 +109,18 @@ class tc
                echo parse_navbar();
                $this->display_app_header();    
        }
+       
+       function logToFile($func, $msg)
+       {
+               // open file
+               $fd = fopen($this->upload_target_path . "/tc_trace.log", "a");
+               // append date/time to message
+               $str = "[" . date("Y/m/d h:i:s", mktime()) . "] [" . $func . "] " . $msg;
+               // write string
+               fwrite($fd, $str . "\n");
+               // close file
+               fclose($fd);
+       }
   
        function save_sessiondata()
        {
@@ -1418,17 +1430,9 @@ class tc
                                $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->logToFile("ppi_sched", "UPDATE tc_scheduling_priority SET priority='$priority', notes=\"$notes\" WHERE scheduling_priority='$scheduling_priority'");
+                                       $this->db2->query("UPDATE tc_scheduling_priority SET priority='$priority', notes=\"$notes\" WHERE scheduling_priority='$scheduling_priority'", __LINE__, __FILE__);
                                }
-
-/*
-                               $this->db->query("UPDATE tc_individual set " .
-                                                " notes='" . $notes . "'" .
-                                                ",priority='" . $priority . "'" .
-                                                " WHERE individual=" . $individual,__LINE__,__FILE__);
-*/
-
-
                        }
 
                        $take_me_to_url = $GLOBALS['phpgw']->link('/tc/index.php','menuaction=tc.tc.ppi_sched');
@@ -1519,7 +1523,7 @@ class tc
 
                // PPI SCHEDULING TABLE
                // TODO:  changed this so it picks the quorum dynamically
-               $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";
+               $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; 
@@ -1770,14 +1774,9 @@ class tc
                                $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->logToFile("int_sched", "UPDATE tc_scheduling_priority SET priority='$hti_pri', notes=\"$hti_notes\" WHERE scheduling_priority='$scheduling_priority'");
+                                       $this->db2->query("UPDATE tc_scheduling_priority SET priority='$hti_pri', 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');
@@ -2126,14 +2125,9 @@ class tc
                                $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->logToFile("vis_sched", "UPDATE tc_scheduling_priority SET priority='$visit_pri', notes=\"$visit_notes\" WHERE scheduling_priority='$scheduling_priority'");
+                                       $this->db2->query("UPDATE tc_scheduling_priority SET priority='$visit_pri', 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');
index 2fedef164a486579352634ad614571b9cc0fbf92..fddc9242b8b483e967613a537a9ad6c9f1af7789 100644 (file)
@@ -202,43 +202,43 @@ CREATE TABLE `tc_willingness` (
 -- Table structure for table `tc_scheduling_priority`
 --
 CREATE TABLE `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 ''
+  `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 ;
 
 --
 -- Table structure for table `tc_email_list`
 --
 CREATE TABLE `tc_email_list` (
-`email_list` INT( 16 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
-`name` VARCHAR( 128 ) NULL DEFAULT NULL
+  `email_list` INT( 16 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
+  `name` VARCHAR( 128 ) NULL DEFAULT NULL
 ) ENGINE = MYISAM ;
 
 --
 -- Table structure for table `tc_email_list_membership`
 --
 CREATE TABLE `tc_email_list_membership` (
-`individual` INT( 16 ) UNSIGNED NULL DEFAULT NULL ,
-`email_list` INT( 16 ) UNSIGNED NULL DEFAULT NULL
+  `individual` INT( 16 ) UNSIGNED NULL DEFAULT NULL ,
+  `email_list` INT( 16 ) UNSIGNED NULL DEFAULT NULL
 ) ENGINE = MYISAM ;
 
 --
 -- Table structure for table `tc_accomplishment`
 --
 CREATE TABLE `tc_accomplishment` (
-`accomplishment` INT( 16 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
-`individual` INT( 16 ) UNSIGNED NULL DEFAULT NULL ,
-`date` DATE NULL DEFAULT NULL ,
-`task` INT( 16 ) UNSIGNED NULL DEFAULT NULL ,
-`note` VARCHAR( 128 ) NOT NULL
+  `accomplishment` INT( 16 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY ,
+  `individual` INT( 16 ) UNSIGNED NULL DEFAULT NULL ,
+  `date` DATE NULL DEFAULT NULL ,
+  `task` INT( 16 ) UNSIGNED NULL DEFAULT NULL ,
+  `note` VARCHAR( 128 ) NOT NULL
 ) ENGINE = MYISAM ;
 
 --
 -- Table structure for table `tc_task`
 --
 CREATE TABLE `tc_task` (
-`task` INT( 16 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
-`name` VARCHAR( 128 ) NOT NULL ,
-`description` VARCHAR( 128 ) NOT NULL
+  `task` INT( 16 ) NOT NULL AUTO_INCREMENT PRIMARY KEY ,
+  `name` VARCHAR( 128 ) NOT NULL ,
+  `description` VARCHAR( 128 ) NOT NULL
 ) ENGINE = MYISAM ;