DataObjects/Core_notify.php
[Pman.Core] / DataObjects / Core_notify.php
index 790d475..8e5f607 100644 (file)
@@ -41,6 +41,7 @@ class Pman_Core_DataObjects_Core_notify extends DB_DataObject
     public $trigger_person_id;                 // int(11)
     public $trigger_event_id;              // int(11)  
     public $evtype;                         // event type (or method to call)fall
+    public $act_start;
     
     /* the code above is auto generated do not remove the tag below */
     ###END_AUTOCODE
@@ -82,6 +83,19 @@ class Pman_Core_DataObjects_Core_notify extends DB_DataObject
             $roo->jerr("you can not delete a record of a successfull delivery");
         }
     }
+    function  beforeInsert($request,$roo)
+    {
+        if (empty($request['act_when']) && !empty($request['act_start'])) {
+            $this->act_start($request['act_start']);
+        }
+        
+    }
+    function beforeUpdate($old, $request,$roo)
+    {
+        if (empty($request['act_when']) && !empty($request['act_start'])) {
+            $this->act_start($request['act_start']);
+        }
+    }
     
     
     function act_start($set = false)
@@ -152,7 +166,7 @@ class Pman_Core_DataObjects_Core_notify extends DB_DataObject
     
     function applyFilters($q, $au, $roo)
     {
-        if (isset($q['ontable']) && !in_array($q['ontable'], array('Person', 'Events' . 'core_watch'))) {
+        if (isset($q['ontable']) && !in_array($q['ontable'], array('Person', 'Events' 'core_watch'))) {
             // this will only work on tables not joined to ours.
             
             //DB_DAtaObject::DebugLevel(1);
@@ -172,7 +186,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'])}%'");
              
         }
@@ -190,16 +204,30 @@ class Pman_Core_DataObjects_Core_notify extends DB_DataObject
                 case 'PENDING';
                     $this->whereAdd('event_id = 0 OR (event_id  > 0 AND act_when > NOW() )');
                     break;
+                
                 case 'OPENED';
                     $this->whereAdd('is_open > 0');
                     break;
+                
                 case 'ALL':
                 default:
                     break;
             }
         }
         
-        
+        $this->selectAdd("
+            (SELECT
+                    display_name
+            FROM
+                    core_enum
+            WHERE
+                    etype = 'Core.NotifyType'
+                AND
+                    name = core_notify.evtype
+                AND
+                    active = 1
+            ) AS evtype_align
+        ");