Misc fixes and new function service_change

This commit is contained in:
Deon George
2013-01-23 22:17:22 +11:00
parent 47fa9993be
commit 1b7aa6b1a7
8 changed files with 79 additions and 7 deletions

View File

@@ -22,6 +22,7 @@ class Model_Service extends ORM_OSB {
protected $_has_many = array(
'invoice_item'=>array('far_key'=>'id'),
'invoice'=>array('through'=>'invoice_item'),
'service_change'=>array('far_key'=>'id'),
);
protected $_belongs_to = array(
'product'=>array(),
@@ -75,6 +76,10 @@ class Model_Service extends ORM_OSB {
return is_null($plugin=$this->plugin()) ? $this->product->name() : $plugin->name();
}
public function pending_change() {
return count($this->service_change->where_active()->where_open()->and_where('complete','!=',1)->or_where('complete','IS',null)->where_close()->find_all()->as_array());
}
/**
* Display how much is due on this service
*/

View File

@@ -0,0 +1,49 @@
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class supports Service Product Changes.
*
* @package OSB
* @subpackage Product/Service
* @category Models
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Model_Service_Change extends ORM_OSB {
protected $_table_name = 'service_change';
// Relationships
protected $_belongs_to = array(
'product'=>array(),
'service'=>array(),
);
/**
* Filters used to format the display of values into friendlier values
*/
protected $_display_filters = array(
'date_ordered'=>array(
array('Config::date',array(':value')),
),
'date_effective'=>array(
array('Config::date',array(':value')),
),
);
public function list_details() {
if ($this->_db_pending) {
$output = array();
foreach ($this->find_all() as $sco) {
array_push($output,sprintf('%s %s',$sco->product->name(),$sco->display('date_effective')));
}
} else {
throw new Kohana_Exception('Shouldnt be here!');
}
return join('|',$output);
}
}
?>