public $dispatch_port; // string(255) not_null
public $province; // string(255) not_null
public $country; // string(4) not_null
-
+ public $is_system; // int(2)
/* the code above is auto generated do not remove the tag below */
###END_AUTOCODE
) as comptype_display_name
");
+ if(!empty($q['query']['name'])){
+ $s = $this->escape($q['query']['name']);
+ $this->whereAdd("
+ {$tn}.name LIKE '%$s%'
+ ");
+ }
}
}
- function beforeDelete()
+ function beforeUpdate($old, $q,$roo)
+ {
+ if(!empty($this->is_system) &&
+ ($old->code != $this->code || $old->name != $this->name)
+ ){
+ $roo->jerr('This company is not allow to editing Ref. or Company Name...');
+ }
+ }
+
+ function beforeDelete($req, $roo)
{
// should check for members....
-
+ if(!empty($this->is_system) &&
+ ($old->code != $this->code || $old->name != $this->name)
+ ){
+ $roo->jerr('This company is not allow to delete');
+ }
$img = DB_DataObject::factory('Images');
$img->ontable = 'Companies';
$img->onid = $this->id;
$e = DB_DataObject::Factory('core_enum')->lookupObject('COMPTYPE', $this->comptype);
$ret['comptype_display'] = $ret['comptype'];
- if ($e->find(true) && !empty($e->name_display)) {
+ if ($e && !empty($e->name_display)) {
$ret['comptype_display'] = $e->name_display;
}
if(!$com->find(true)){
$com->created_dt = Date('Y-m-d H:i:s');
$com->updated_dt = Date('Y-m-d H:i:s');
+ $com->is_system = 1;// new column.. block the user changing the code and name..
$com->insert();
}
}
$companies->insert();
$companies->onInsert(array(), $roo);
}
- function lookupOwner()
+ function lookupOwner()
{
- $enum = DB_DataObject::Factory('core_enum')->lookup('COMPTYPE', $ctype );
+ $enum = DB_DataObject::Factory('core_enum')->lookup('COMPTYPE', 'OWNER' );
$companies = DB_DataObject::factory('companies');
$companies->comptype_id = $enum;
if ($companies->find(true)) {