Revamping invoice PDF rendering and standardisation work

This commit is contained in:
Deon George
2016-08-10 16:07:00 +10:00
parent a560c5f4fa
commit 24bb4a701b
27 changed files with 229 additions and 475 deletions

View File

@@ -10,5 +10,6 @@
* @license http://dev.osbill.net/license.html
*/
class Controller_Service extends Controller_TemplateDefault {
protected $icon = 'fa fa-barcode'; //fa-plug for plugins
}
?>

View File

@@ -59,7 +59,7 @@ class Controller_User_Service extends Controller_Service {
->set('o',$so);
Block::factory()
->title(sprintf('%s: %s',$so->id(),$so->name()))
->title(sprintf('%s: %s',$so->refnum(TRUE),$so->name()))
->title_icon('fa fa-server')
->body($output);
}

View File

@@ -116,6 +116,15 @@ class Model_Service extends ORM_OSB {
return $this->_plugin;
}
/**
* Get the attributes of the service
*
* @return an array of attributes
*/
public function attributes($variable=NULL) {
return ($this->_plugin()) ? $this->_plugin()->attributes() : array();
}
/**
* Get the additional charges associated with this service
*/
@@ -178,13 +187,6 @@ class Model_Service extends ORM_OSB {
return time()+$days*86400 > $this->expire();
}
/**
* Display the service number
*/
public function id() {
return sprintf('%05s',$this->id);
}
/**
* List invoices for this service
*/
@@ -291,10 +293,6 @@ class Model_Service extends ORM_OSB {
return $this->price(TRUE)*$multiple;
}
public function service_change() {
return $this->service_change->where_active()->where_open()->and_where('complete','!=',1)->or_where('complete','IS',null)->where_close()->find();
}
/**
* Return the service charge
*/
@@ -313,19 +311,8 @@ class Model_Service extends ORM_OSB {
return $format ? Currency::display($p) : $p;
}
/**
* Render some details for specific calls, eg: invoice
*/
public function details($type) {
$plugin = $this->plugin();
switch ($type) {
case 'invoice_detail_items':
return is_null($plugin) ? array() : $plugin->_details($type);
default:
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type));
}
public function service_change() {
return $this->service_change->where_active()->where_open()->and_where('complete','!=',1)->or_where('complete','IS',null)->where_close()->find();
}
public function service_view() {
@@ -368,7 +355,6 @@ class Model_Service extends ORM_OSB {
public function list_byplugin($plugin) {
return $this
->join('product')
->on($this->table_name().'.site_id','=','product.site_id') // @todo This should be automatic
->on($this->table_name().'.product_id','=','product.id')
->where('prod_plugin_file','=',$plugin)
->and_where('service.status','=',TRUE)
@@ -417,12 +403,5 @@ class Model_Service extends ORM_OSB {
->where('date_next_invoice','<',time()+(ORM::factory('Invoice')->config('GEN_DAYS')+$days)*86400)
->find_all();
}
/**
* List services that need to be provisioned
*/
public function list_provision() {
return $this->_where_active()->where('queue','=','PROVISION');
}
}
?>

View File

@@ -17,22 +17,26 @@ abstract class Model_Service_Plugin extends ORM_OSB {
'service'=>array(),
);
/** REQUIRED ABSTRACT METHODS **/
/**
* Service attributes
*/
abstract public function attributes($variable=NULL);
/**
* When does our service expire
*/
abstract public function expire();
/**
* Our service name as defined in the DB
*/
abstract public function name();
/**
* The table attributes that provide username/password values
*/
abstract public function password();
abstract public function username();
/** LOCAL METHODS **/
/**
* Provide the button that launches the management of this service, generally from a 3rd party
*/
@@ -93,30 +97,5 @@ $(document).ready(function() {
return View::factory(sprintf('service/user/plugin/%s/view',$this->plugin()))
->set('o',$this);
}
/**
* Show our service name as defined in the DB with product suffix.
*/
public function service_name() {
return sprintf('%s - %s',$this->service->product->title(),$this->name());
}
/**
* Get specific service details for use in other modules
* For Example: Invoice
*
* @todo Make the rendered items configurable
* @todo Change this method name, now that it is public
*/
public function _details($type) {
switch ($type) {
// Nothing to add for invoices
case 'invoice_detail_items':
return array();
default:
throw new Kohana_Exception('Unkown detail request :type',array(':type'=>$type));
}
}
}
?>