2010-11-29 22:41:08 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
2011-09-28 06:46:22 +00:00
|
|
|
* This class is for access company information.
|
2010-11-29 22:41:08 +00:00
|
|
|
*
|
|
|
|
* @package OSB
|
|
|
|
* @category Helpers
|
|
|
|
* @author Deon George
|
2013-03-19 22:35:19 +00:00
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
2011-09-28 06:46:22 +00:00
|
|
|
* @license http://dev.osbill.net/license.html
|
2010-11-29 22:41:08 +00:00
|
|
|
*/
|
|
|
|
class Company {
|
2013-02-12 11:14:59 +00:00
|
|
|
// Our Company Setup object
|
|
|
|
private $so;
|
|
|
|
|
|
|
|
public function __construct(Model_Setup $so) {
|
|
|
|
$this->so = $so;
|
|
|
|
|
|
|
|
if (! $this->so->loaded())
|
|
|
|
throw new Kohana_Exception(_('Site [:site] not defined in DB?'),array(':site'=>URL::base('http')));
|
|
|
|
|
|
|
|
Kohana::$environment = (int)$this->so->status;
|
|
|
|
}
|
|
|
|
|
2010-11-29 22:41:08 +00:00
|
|
|
public static function instance() {
|
2013-04-18 08:17:33 +00:00
|
|
|
return new Company(ORM::factory('Setup',array('url'=>URL::base('http'))));
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
|
2013-02-12 11:14:59 +00:00
|
|
|
public function admin() {
|
|
|
|
return $this->so->account->name();
|
2011-10-14 05:44:12 +00:00
|
|
|
}
|
|
|
|
|
2013-02-12 11:14:59 +00:00
|
|
|
public function address($ln='<br/>') {
|
|
|
|
return implode($ln,array($this->street($ln),sprintf('%s, %s %s',$this->city(),$this->state(),$this->pcode())));
|
2011-05-02 12:28:17 +00:00
|
|
|
}
|
|
|
|
|
2013-02-12 11:14:59 +00:00
|
|
|
public function city() {
|
|
|
|
return $this->so->site_details('city');
|
2011-05-02 12:28:17 +00:00
|
|
|
}
|
|
|
|
|
2013-02-12 11:14:59 +00:00
|
|
|
public function contacts() {
|
|
|
|
return 'Tel: '.$this->phone();
|
2011-05-02 12:28:17 +00:00
|
|
|
}
|
|
|
|
|
2013-02-12 11:14:59 +00:00
|
|
|
public function country() {
|
|
|
|
return $this->so->country;
|
2011-05-02 12:28:17 +00:00
|
|
|
}
|
|
|
|
|
2013-02-12 11:14:59 +00:00
|
|
|
public function date_format() {
|
|
|
|
return $this->so->date_format;
|
2011-05-02 12:28:17 +00:00
|
|
|
}
|
|
|
|
|
2013-02-12 11:14:59 +00:00
|
|
|
public function decimals() {
|
|
|
|
return $this->so->decimal_place;
|
2011-05-02 12:28:17 +00:00
|
|
|
}
|
|
|
|
|
2013-02-12 11:14:59 +00:00
|
|
|
public function email() {
|
|
|
|
return $this->so->site_details('email');
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
2012-01-09 01:35:24 +00:00
|
|
|
|
2013-02-12 11:14:59 +00:00
|
|
|
public function fax() {
|
|
|
|
return $this->so->site_details('fax');
|
2012-01-09 01:35:24 +00:00
|
|
|
}
|
2010-11-29 22:41:08 +00:00
|
|
|
|
2013-02-12 11:14:59 +00:00
|
|
|
public function language() {
|
2013-04-26 01:42:09 +00:00
|
|
|
return $this->so->language;
|
2011-05-02 12:28:17 +00:00
|
|
|
}
|
|
|
|
|
2013-02-12 11:14:59 +00:00
|
|
|
public function logo() {
|
|
|
|
return Config::logo();
|
2011-05-02 12:28:17 +00:00
|
|
|
}
|
|
|
|
|
2013-02-12 11:14:59 +00:00
|
|
|
public function logo_file() {
|
|
|
|
list ($path,$suffix) = explode('.',Config::$logo);
|
|
|
|
|
|
|
|
return ($x=Kohana::find_file(sprintf('media/site/%s',$this->site()),$path,$suffix)) ? $x : Kohana::find_file('media',$path,$suffix);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function name() {
|
|
|
|
return $this->so->site_details('name');
|
2011-05-02 12:28:17 +00:00
|
|
|
}
|
|
|
|
|
2013-02-12 11:14:59 +00:00
|
|
|
public function module_config($item) {
|
|
|
|
return $this->so->module_config($item);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function pcode() {
|
|
|
|
return $this->so->site_details('pcode');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function phone() {
|
|
|
|
return $this->so->site_details('phone');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function site($format=FALSE) {
|
|
|
|
return $format ? sprintf('%02s',$this->so->id) : $this->so->id;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function so() {
|
|
|
|
return $this->so;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function state() {
|
|
|
|
return $this->so->site_details('state');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function street($ln='<br/>') {
|
|
|
|
return $this->so->site_details('address2') ? implode($ln,array($this->so->site_details('address1'),$this->so->site_details('address2'))) : $this->so->site_details('address1');
|
|
|
|
}
|
|
|
|
|
|
|
|
public function sitemode() {
|
|
|
|
return $this->so->status;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function taxid() {
|
2012-01-02 01:35:47 +00:00
|
|
|
// Tax ID details are stored in invoice config
|
2013-02-12 11:14:59 +00:00
|
|
|
$mc = $this->so->module_config('invoice');
|
2012-01-02 01:35:47 +00:00
|
|
|
|
|
|
|
if (empty($mc['TAX_ID_NAME']))
|
|
|
|
return empty($mc['TAX_ID']) ? '' : $mc['TAX_ID'];
|
|
|
|
else
|
|
|
|
return sprintf('%s: %s',$mc['TAX_ID_NAME'],empty($mc['TAX_ID']) ? '' : $mc['TAX_ID']);
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
|
2013-02-12 11:14:59 +00:00
|
|
|
public function time_format() {
|
|
|
|
return $this->so->time_format;
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
|
2013-02-12 11:14:59 +00:00
|
|
|
public static function bsb() {
|
|
|
|
// @todo Details should be obtained from DB
|
|
|
|
return Kohana::$config->load('config')->bsb;
|
|
|
|
}
|
2010-11-29 22:41:08 +00:00
|
|
|
|
2013-02-12 11:14:59 +00:00
|
|
|
public static function account() {
|
|
|
|
// @todo Details should be obtained from DB
|
|
|
|
return Kohana::$config->load('config')->accnum;
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|