DataObjects/Core_notify.php
[Pman.Core] / DataObjects / Core_notify.php
index 32c7a61..dfde126 100644 (file)
@@ -42,7 +42,9 @@ class Pman_Core_DataObjects_Core_notify extends DB_DataObject
     public $trigger_event_id;              // int(11)  
     public $evtype;                         // event type (or method to call)fall
     public $act_start;
-    
+    public $person_table;
+
+
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
     
@@ -52,8 +54,12 @@ class Pman_Core_DataObjects_Core_notify extends DB_DataObject
             $this->person_id = is_object($set) ? $set->id : $set;
             return;
         }
-        $c = DB_DataObject::Factory('Person');
-        $c->get($this->person_id);
+        
+        $person_table = empty($this->person_table) ? 'Person' : $this->person_table;
+        $col = $person_table == "Person" ? 'person_id' : $person_table . '_id';
+            
+        $c = DB_DataObject::Factory($person_table);
+        $c->get($this->{$col});
         return $c;
         
     }
@@ -186,7 +192,7 @@ class Pman_Core_DataObjects_Core_notify extends DB_DataObject
             "; 
             $this->selectAs($d, 'core_notify_%s');
         } 
-        if (isset($q['query']['person_id_name']) ) {
+        if (!empty($q['query']['person_id_name']) ) {
             $this->whereAdd( "join_person_id_id.name LIKE '{$this->escape($q['query']['person_id_name'])}%'");
              
         }
@@ -215,22 +221,33 @@ class Pman_Core_DataObjects_Core_notify extends DB_DataObject
             }
         }
         
-        $this->selectAdd("
-            (SELECT
-                    display_name
-            FROM
-                    core_enum
-            WHERE
-                    etype = 'Core.NotifyType'
-                AND
-                    name = core_notify.evtype
-                AND
-                    active = 1
-            ) AS evtype_align
-        ");
-        
+        if(!empty($q['_evtype_align'])){
+            $this->selectAdd("
+                (SELECT
+                        display_name
+                FROM
+                        core_enum
+                WHERE
+                        etype = 'Core.NotifyType'
+                    AND
+                        name = core_notify.evtype
+                    AND
+                        active = 1
+                ) AS evtype_align
+            ");
+        }
         
+        if(!empty($q['from'])){
+            $this->whereAdd("
+                act_when >= '{$q['from']}'
+            ");
+        }
         
+        if(!empty($q['to'])){
+            $this->whereAdd("
+                act_when <= '{$q['to']}'
+            ");
+        }
         
     }