Optimised Company() Setup() Config() and changed method_directory into URL

This commit is contained in:
Deon George
2013-02-12 22:14:59 +11:00
parent 97d894d472
commit 288d974cfa
63 changed files with 422 additions and 346 deletions

View File

@@ -46,7 +46,7 @@ class Model_Account extends Model_Auth_UserDefault {
}
public function accnum() {
return sprintf('%s-%04s',Config::siteid(TRUE),$this->id);
return sprintf('%s-%04s',Company::instance()->site(TRUE),$this->id);
}
public function sortkey($withcompany=FALSE) {
@@ -115,10 +115,6 @@ class Model_Account extends Model_Auth_UserDefault {
foreach ($this->invoices_due($date) as $io)
$result += $io->due();
// @todo This shouldnt really be required
if ($result < 0)
throw new Kohana_Exception($result);
return $format ? Currency::display($result) : $result;
}

View File

@@ -25,7 +25,7 @@ class Model_Record_Id extends ORM_OSB {
$max = DB::select(array('MAX(id)','id'))
->from($mo->name)
->where('site_id','=',Config::siteid());
->where('site_id','=',Company::instance()->site());
$this->id = $max->execute()->get('id');
}

View File

@@ -18,6 +18,7 @@ class Model_Setup extends ORM_OSB {
protected $_updated_column = FALSE;
protected $_has_one = array(
'account'=>array('foreign_key'=>'id','far_key'=>'admin_id'),
'country'=>array('foreign_key'=>'id','far_key'=>'country_id'),
'language'=>array('foreign_key'=>'id','far_key'=>'language_id'),
);