DataObjects/Core_company.php
[Pman.Core] / DataObjects / Core_company.php
index 5e136c2..3e7a3e5 100644 (file)
@@ -110,6 +110,12 @@ class Pman_Core_DataObjects_Core_Company extends DB_DataObject
                 {$tn}.name LIKE '%$s%'
             ");
         }
+        if(!empty($q['search']['name'])){ 
+            $s = $this->escape($q['search']['name']);
+            $this->whereAdd("
+                {$tn}.name LIKE '%$s%'
+            ");
+        }
         if(!empty($q['search']['name_starts'])){
             $s = $this->escape($q['search']['name_starts']);
             $this->whereAdd("
@@ -248,6 +254,18 @@ class Pman_Core_DataObjects_Core_Company extends DB_DataObject
     
     function beforeInsert($q, $roo)
     {
+        // we still use comptype in some old systems...
+        
+        if(!empty($q['_merge_id'])){
+            $this->merge($q['_merge_id'], $roo);
+        }
+        
+        if (!empty($q['comptype_id'])) {
+            $en = DB_DataObject::Factory('core_enum');
+            $en->get($q['comptype_id']);
+            $this->comptype = $en->name;
+        }
+        
         if(!empty($q['_check_name'])){
             if($this->checkName()){
                 $roo->jok('OK');
@@ -259,14 +277,21 @@ class Pman_Core_DataObjects_Core_Company extends DB_DataObject
     
     function beforeUpdate($old, $q,$roo)
     {
-        var_dump($q); exit;
+        // we still use comptype in some old systems...
+        
+        if (!empty($q['comptype_id'])) {
+            $en = DB_DataObject::Factory('core_enum');
+            $en->get($q['comptype_id']);
+            $this->comptype = $en->name;
+        }
+        
+        
         if(!empty($q['_flag_delete'])){
-            if($q['_flag_delete'] * 1 == 1){
-                
-                $this->deleted_dt = $this->sqlValue("NOW()");
-                $this->deleted_by = $roo->getAuthUser()->id;
-            }
-            
+            $this->deleted_dt = $this->sqlValue("NOW()");
+            $this->deleted_by = $roo->getAuthUser()->id;
+        }
+        
+        if(!empty($q['_flag_undelete'])){
             $this->deleted_dt = "";
             $this->deleted_by = 0;
         }
@@ -278,10 +303,6 @@ class Pman_Core_DataObjects_Core_Company extends DB_DataObject
             $roo->jerr('EXIST');
         }
         
-        if(!empty($q['_merge_id'])){
-            $this->merge($q['_merge_id'], $roo);
-        }
-        
         if(!empty($this->is_system) && 
             ($old->code != $this->code  ) // used to be not allowed to change name..
         ){