Update valid flag in database and display in web frontend
authorJoachim Breitner <mail@joachim-breitner.de>
Fri, 26 Jun 2009 09:03:22 +0000 (11:03 +0200)
committerJoachim Breitner <mail@joachim-breitner.de>
Fri, 26 Jun 2009 09:03:22 +0000 (11:03 +0200)
web/js/communication.js
web/php/Controller.php
web/php/Database.php
web/php/Plant.php
web/php/page/myplants.pg

index a968b5d..fffafa5 100644 (file)
@@ -663,6 +663,9 @@ Lseed.Plant = Ext.data.Record.create([{
 }, {
        name: 'Code'
        ,type: 'string'
+}, {
+       name: 'IsValid'
+       ,type: 'boolean'
 }, {
        name: 'IsActive'
        ,type: 'boolean'
index d8ff405..f0577ec 100644 (file)
 
                                case "CheckSyntax":
                                        # Create a temporary plant              
-                                       $plant = new Plant(0,0,$plantname,$code,0);
+                                       $plant = new Plant(0,0,$plantname,$code,0,0);
                                        $res = $plant->Validate();
                                        break;
 
index 49466e2..ed29af0 100644 (file)
                public function InsertNewPlant($userid, $name, $code) {
                        $result = false;
 
-                       $plant = new Plant(0,$userid,$plantname,$code,this);
+                       $plant = new Plant(0,$userid,$plantname,$code,0,this);
                        $valid = $plant->IsValid();
                        
                        $stmt = $this->m_Connection->prepare("INSERT INTO plant (UserID, Name, Code, Valid) VALUES (?, ?, ?, ?)");
                public function GetPlantByID($userid, $plantid) {
                        $result = null;
 
-                       $stmt = $this->m_Connection->prepare("SELECT ID, UserID, Name, Code FROM plant WHERE UserID=? AND ID=?");
+                       $stmt = $this->m_Connection->prepare("SELECT ID, UserID, Name, Code, Valid FROM plant WHERE UserID=? AND ID=?");
                        
                        if ($stmt) {
                                $stmt->bind_param("ds", $userid, $plantid);
                                $stmt->execute();
-                               $stmt->bind_result( $id, $theuserid, $thename, $code);
+                               $stmt->bind_result( $id, $theuserid, $thename, $code, $isvalid);
                                
                                if ($stmt->fetch()) {
-                                       $result = new Plant($id, $theuserid, $thename, $code, $this);
+                                       $result = new Plant($id, $theuserid, $thename, $code, $isvalid, $this);
                                } else {
                                        //echo "nope no plant like that found.";
                                }
index ed5d8db..3594e4a 100644 (file)
@@ -9,12 +9,13 @@
                public $IsActive;
                public $m_Database;
 
-               public function __construct($id, $userid, $name, $code, $database) {
+               public function __construct($id, $userid, $name, $code, $valid, $database) {
                        $this->ID = $id;
                        $this->UserID = $userid;
                        $this->Name = $name;
                        $this->Code = $code;
                        $this->IsActive = false;
+                       $this->Valid = $valid;
                        $this->m_Database = $database;
                        if (!isset($GLOBALS['ValidatorFile'])) {
                                $GLOBALS['ValidatorFile'] = '/home/lseed/.cabal/bin/validate';
@@ -28,7 +29,7 @@
                        
                        $active = 'false';
                        if ($this->IsActive) { $active = 'true'; } else { $active = 'false'; }
-                       return "{ ID: " . $this->ID . ", Name: '" . $this->Name . "', Code: '" . $this->Code . "', IsActive: " . $active . " }";
+                       return "{ ID: " . $this->ID . ", Name: '" . $this->Name . "', Code: '" . $this->Code . "', IsValid: " . $this->Valid . ", IsActive: " . $active . " }";
                }
 
                public function ToJsonArray() {
index 52006de..aad0120 100644 (file)
                                        xtype: 'textfield'
                                        ,allowBlank: true
                                }
+                       },{
+                               id: 'IsValid'
+                               ,header: 'Valid'
+                               ,width: 50
+                               ,sortable: true
+                               ,dataIndex: 'IsValid'
                        },{
                                id: 'IsActive'
                                ,header: 'IsActive'
-                               ,width: 200
+                               ,width: 50
                                ,sortable: true
                                ,dataIndex: 'IsActive'
                        }