DataObjects/Core_company.php
[Pman.Core] / DataObjects / Core_project.php
index 62d2ba3..818a3ee 100644 (file)
@@ -2,14 +2,14 @@
 /**
  * Table Definition for Projects
  */
-require_once 'DB/DataObject.php';
+class_exists('DB_DataObject') ? '' : require_once 'DB/DataObject.php';
 
-class Pman_Core_DataObjects_Projects extends DB_DataObject 
+class Pman_Core_DataObjects_Core_project extends DB_DataObject 
 {
     ###START_AUTOCODE
     /* the code below is auto generated do not remove the above tag */
 
-    public $__table = 'Projects';            // table name
+    public $__table = 'core_project';            // table name
     public $id;                              // int(11)  not_null primary_key auto_increment
     public $name;                            // string(254)  not_null
     public $remarks;                         // blob(65535)  not_null blob
@@ -69,7 +69,7 @@ class Pman_Core_DataObjects_Projects extends DB_DataObject
 
     function toEventString() {
         $c = $this->client();
-        return ($c->id ? $c->toEventString() : '??'). ':' . $this->name;
+        return ($c && $c->id ? $c->toEventString() : '??'). ':' . $this->name;
     }
     
     /**
@@ -272,6 +272,29 @@ class Pman_Core_DataObjects_Projects extends DB_DataObject
             
     }
     
+    
+    
+    function client()
+    {
+        if (!$this->client_id) {
+            return false;
+        }
+        $c = DB_DataObject::factory('core_company');
+        $c->get($this->client_id);
+        return $c;
+    }
+    
+    
+    
+    function team()
+    {
+        $c = DB_DataObject::factory('core_group');
+        $c->get($this->team_id);
+        return $c;
+    }
+    
+    
+    
     // DEPRICATED - use userProjects
     
     function getUserProjects($au, $data='id') // COMPANY BASED!!!!
@@ -282,13 +305,6 @@ class Pman_Core_DataObjects_Projects extends DB_DataObject
     }
     
     
-    function client()
-    {
-        $c = DB_DataObject::factory('Companies');
-        $c->get($this->client_id);
-        return $c;
-    }
-    
     /**
      * check who is trying to access this. false == access denied..
      */