public $__table = 'core_company'; // table name
public $code; // string(32) not_null
public $name; // string(128)
- public $remarks; // blob(65535) blob
+ public $remarks; // blob(65535) blobeforeDeleteb
public $owner_id; // int(11) not_null
public $address; // blob(65535) blob
public $tel; // string(32)
) as comptype_display_name
");
- if(!empty($q['query']['name'])){
- $s = $this->escape($q['query']['name']);
- $this->whereAdd("
- {$tn}.name LIKE '%$s%'
- ");
- }
- if(!empty($q['search']['name'])){
- $s = $this->escape($q['search']['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%'
");
{
// we still use comptype in some old systems...
- if(!empty($q['_merge_id'])){
- $this->merge($q['_merge_id'], $roo);
+ 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'])) {
{
// 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;
$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..
){
$img->onid = $this->id;
$img->find();
while ($img->fetch()) {
- $img->beforeDelete();
+ $img->beforeDelete(array(), $roo);
$img->delete();
}
return true;