X-Git-Url: http://git.roojs.org/?p=Pman.Core;a=blobdiff_plain;f=DataObjects%2FCore_company.php;h=2a55369440745695f27dc9bae55cce4ccb78c902;hp=76a063f076fbc513248db237f0e067bb4337c9d3;hb=e23146506d2ade4e9263cb608f9e21f5da13020e;hpb=3e219c8386406f687e78e2f8063be73b94b0818f diff --git a/DataObjects/Core_company.php b/DataObjects/Core_company.php index 76a063f0..2a553694 100644 --- a/DataObjects/Core_company.php +++ b/DataObjects/Core_company.php @@ -82,10 +82,7 @@ class Pman_Core_DataObjects_Core_Company extends DB_DataObject $this->whereAddIn('comptype', explode(',', $q['query']['comptype']), 'string'); } - /*if (!empty($q['query']['deleted_by'])) { - $deleted_by = $this->escape($q['query']['deleted_by']); - $this->whereAdd("deleted_by = '$deleted_by'"); - }*/ + // depricated - should be moved to module specific (texon afair) if (!empty($q['query']['province'])) { @@ -113,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(" @@ -262,11 +265,23 @@ class Pman_Core_DataObjects_Core_Company extends DB_DataObject function beforeUpdate($old, $q,$roo) { - if(!empty($req['_flag_delete']) && $req['_flag_delete'] * 1 == 1){ - $delete_dt = date('Y-m-d H:i:s'); - $this->query("UPDATE {$old->tableName()} SET deleted_by = {$roo->getAuthUser()} , deleted_dt = {$delete_dt} WHERE id = {$req['_update_id']}"); - //$this->addEvent("UPDATE", false, "update core_company record"); - $this->jok("Updated"); + // 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'])){ + $this->deleted_dt = $this->sqlValue("NOW()"); + $this->deleted_by = $roo->getAuthUser()->id; + } + + if(!empty($q['_flag_undelete'])){ + $this->deleted_dt = ""; + $this->deleted_by = 0; } if(!empty($q['_check_name'])){ if($this->checkName()){