This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/application/classes/Company.php

143 lines
3.3 KiB
PHP
Raw Normal View History

2013-10-10 02:44:53 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class is for access company information.
*
* @package OSB
* @category Helpers
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Company {
public static $instance = array();
2013-10-10 02:44:53 +00:00
// Our Company Setup object
private $so;
2013-05-28 11:35:54 +00:00
protected function __construct(Model_Setup $so) {
2013-10-10 02:44:53 +00:00
$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;
}
public static function instance() {
$x = URL::base('http');
if (! isset(Company::$instance[$x]))
Company::$instance[$x] = new Company(ORM::factory('Setup',array('url'=>$x)));
return Company::$instance[$x];
2013-10-10 02:44:53 +00:00
}
public function admin() {
return $this->so->account->name();
}
public function address($ln='<br/>') {
return implode($ln,array($this->street($ln),sprintf('%s, %s %s',$this->city(),$this->state(),$this->pcode())));
}
public function city() {
return $this->so->site_details('city');
}
public function contacts() {
return 'Tel: '.$this->phone();
}
public function country() {
return $this->so->country;
}
public function date_format() {
return $this->so->date_format;
}
public function decimals() {
return $this->so->decimal_place;
}
public function email() {
return $this->so->site_details('email');
}
public function fax() {
return $this->so->site_details('fax');
}
public function faq() {
return $this->so->site_details('faqurl');
}
2013-10-10 02:44:53 +00:00
public function language() {
return $this->so->language;
2013-10-10 02:44:53 +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);
}
2016-08-03 04:00:51 +00:00
public function name($variable=NULL) {
2013-10-10 02:44:53 +00:00
return $this->so->site_details('name');
}
public function module_config($item,array $value=NULL) {
return $this->so->module_config($item,$value);
2013-10-10 02:44:53 +00:00
}
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 taxid() {
// Tax ID details are stored in invoice config
$mc = $this->so->module_config('invoice');
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']);
}
public function time_format() {
return $this->so->time_format;
}
public static function bsb() {
// @todo Details should be obtained from DB
return Kohana::$config->load('config')->bsb;
}
public static function account() {
// @todo Details should be obtained from DB
return Kohana::$config->load('config')->accnum;
}
}
?>