- var_dump($roo->getAuthUser()->name); exit;
- if(!empty($q['_flag_delete']) && $q['_flag_delete'] * 1 == 1){
- //$delete_dt = date('Y-m-d H:i:s');
- $this->deleted_dt = date('Y-m-d H:i:s');
- $this->deleted_by = $roo->getAuthUser();
- $this->id = $q['_ids'];
- var_dump($this); die;
- $this->update();
- //$roo->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");
+ // we still use comptype in some old systems...
+
+ if(!empty($q['comptype']) && empty($q['comptype_id'])) {
+ $en = DB_DataObject::Factory('core_enum');
+ $en->setFrom(array(
+ 'etype' => 'COMPTYPE',
+ 'name' => $q['comptype'],
+ 'active' => 1
+ ));
+ if($en->find(true)) {
+ $this->comptype_id = $en->id;
+ }
+ }
+
+ 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;