$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'])) {
) as comptype_display_name
");
- if(!empty($q['query']['name'])){
- $s = $this->escape($q['query']['name']);
+ if(!empty($q['query']['name']) || !empty($q['search']['name'])){
+
+ $s = (!empty($q['query']['name'])) ? $this->escape($q['query']['name']) : $this->escape($q['search']['name']);
+
$this->whereAdd("
{$tn}.name LIKE '%$s%'
");
}
- if(!empty($q['search']['name_starts'])){
- $s = $this->escape($q['search']['name_starts']);
+
+ if(!empty($q['query']['name_starts']) || !empty($q['search']['name_starts'])){
+
+ $s = (!empty($q['query']['name_starts'])) ? $this->escape($q['query']['name_starts']) : $this->escape($q['search']['name_starts']);
+
$this->whereAdd("
{$tn}.name LIKE '$s%'
");
function beforeInsert($q, $roo)
{
+ // 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['_check_name'])){
if($this->checkName()){
$roo->jok('OK');
function beforeUpdate($old, $q,$roo)
{
- var_dump($roo); 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_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()){