From 7bff2c70e50a4f6e46e156497396c9dadf65d5c9 Mon Sep 17 00:00:00 2001 From: Alan Knowles Date: Fri, 7 Oct 2016 14:24:18 +0800 Subject: [PATCH] MOVED DataObjects/Office.php to DataObjects/Core_office.php --- DataObjects/Core_office.php | 80 +++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 DataObjects/Core_office.php diff --git a/DataObjects/Core_office.php b/DataObjects/Core_office.php new file mode 100644 index 00000000..75d47c2d --- /dev/null +++ b/DataObjects/Core_office.php @@ -0,0 +1,80 @@ +tableName(); + $this->selectAdd(" i18n_translate('c' , {$tn}.country, 'en') as office_id_country_name"); + } + + + function toEventString() { + return $this->name; + } + /** + * check who is trying to access this. false == access denied.. + */ + function checkPerm($lvl, $au) + { + return $au->hasPerm("Core.Offices", $lvl); + } + + function company() + { + $c = DB_DataObject::Factory('Companies'); + $c->get($this->company_id); + return $c; + + } + + function beforeDelete($dependants_array, $roo) + { + if (count($dependants_array) != 1) { + //$roo->jerr("more than one dependant type...."); + return true; // standard error message. + } + + $p = DB_DAtaObject::Factory('Person'); + + if (!is_a($dependants_array[0], get_class($p))) { + $roo->jerr("dep is not a person.."); + return true; + } + + $p->office_id = $this->id; + if ($p->count() > 1) { + return true; // default err.. + } + $p->find(true); + $pp = clone($p); + $p->office_id = 0; + $p->update($pp); + return true; + } + + +} \ No newline at end of file -- 2.39.2