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

@ -27,6 +27,9 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
'service_connect_date'=>array( 'service_connect_date'=>array(
array('Config::date',array(':value')), array('Config::date',array(':value')),
), ),
'service_contract_date'=>array(
array('Config::date',array(':value')),
),
); );
// Required abstract functions // Required abstract functions
@ -76,11 +79,11 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
} }
public function contract_date_start() { public function contract_date_start() {
return Config::date($this->service_connect_date); return Config::date($this->service_contract_date);
} }
public function contract_date_end() { public function contract_date_end() {
return Config::date(strtotime(sprintf('+%s months',$this->contract_term),$this->service_connect_date)); return Config::date(strtotime(sprintf('+%s months',$this->contract_term),$this->service_contract_date));
} }
public function hasOffpeak() { public function hasOffpeak() {

View File

@ -21,6 +21,16 @@
<script type="text/javascript">defaults['service_connect_date'] = '%s';</script> <script type="text/javascript">defaults['service_connect_date'] = '%s';</script>
</td> </td>
</tr> </tr>
<tr>
<td>Service Contract Date</td>
<td class="data">
<?php echo Form::input('plugin[service_contract]',$so->service_contract_date,array('id'=>'service_contract_date')); ?>
<?php echo HTML::anchor('#',
HTML::image($mediapath->uri(array('file'=>'img/calendar.png')),array('alt'=>_('Calendar'),'style'=>'cursor: pointer;')),
array('title'=>'Click to popup a dialog to select a date graphically','onclick'=>"dateSelector('service_contract_date')")); ?>
<script type="text/javascript">defaults['service_contract_date'] = '%s';</script>
</td>
</tr>
<tr> <tr>
<td>Service Username</td> <td>Service Username</td>
<td class="data"><?php echo Form::input('plugin[service_username]',$so->service_username); ?></td> <td class="data"><?php echo Form::input('plugin[service_username]',$so->service_username); ?></td>

View File

@ -49,7 +49,7 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin {
$prods, $prods,
25, 25,
array( array(
'id'=>array('label'=>'ID','url'=>'product/view/'), 'id'=>array('label'=>'ID','url'=>'admin/product/view/'),
'name()'=>array('label'=>'Details'), 'name()'=>array('label'=>'Details'),
'status'=>array('label'=>'Active'), 'status'=>array('label'=>'Active'),
'prod_plugin_file'=>array('label'=>'Plugin Name'), 'prod_plugin_file'=>array('label'=>'Plugin Name'),
@ -62,7 +62,7 @@ class Controller_Admin_Product extends Controller_TemplateDefault_Admin {
array( array(
'page'=>TRUE, 'page'=>TRUE,
'type'=>'select', 'type'=>'select',
'form'=>'product/view', 'form'=>'admin/product/view',
)), )),
)); ));
} }

View File

@ -51,7 +51,8 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
$svs = ORM::factory('Service')->list_bylistgroup('ADSL'); $svs = ORM::factory('Service')->list_bylistgroup('ADSL');
$data = $this->consoltraffic($svs,time()); $data = $this->consoltraffic($svs,time());
$google = GoogleChart::factory('ComboChart'); $google = GoogleChart::factory('ComboChart')
->stacked(TRUE);
foreach ($data['data'] as $key => $values) foreach ($data['data'] as $key => $values)
$google->sdata(array('yl'=>$key),array($key=>$values)); $google->sdata(array('yl'=>$key),array($key=>$values));
@ -492,7 +493,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
->rule('csv','Upload::size',array(':value','10M')); ->rule('csv','Upload::size',array(':value','10M'));
if ($files->check()) if ($files->check())
foreach ($files as $file) foreach ($files->data() as $file)
$csv = $this->process($file); $csv = $this->process($file);
} }

View File

@ -22,6 +22,7 @@ class Model_Service extends ORM_OSB {
protected $_has_many = array( protected $_has_many = array(
'invoice_item'=>array('far_key'=>'id'), 'invoice_item'=>array('far_key'=>'id'),
'invoice'=>array('through'=>'invoice_item'), 'invoice'=>array('through'=>'invoice_item'),
'service_change'=>array('far_key'=>'id'),
); );
protected $_belongs_to = array( protected $_belongs_to = array(
'product'=>array(), 'product'=>array(),
@ -75,6 +76,10 @@ class Model_Service extends ORM_OSB {
return is_null($plugin=$this->plugin()) ? $this->product->name() : $plugin->name(); 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 * 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);
}
}
?>

View File

@ -1,3 +1,7 @@
<?php if ($so->pending_change()) {?>
Pending change to: <?php echo $so->service_change->list_details(); ?>
<?php } ?>
<br/>
<!-- @todo NEEDS TO BE TRANSLATED --> <!-- @todo NEEDS TO BE TRANSLATED -->
<table class="list-box-left"> <table class="list-box-left">
<tr class="list-head"> <tr class="list-head">

View File

@ -18,7 +18,7 @@
</tr> </tr>
<tr> <tr>
<td>Cost</td> <td>Cost</td>
<td class="data"><?php echo $so->price(TRUE,TRUE); ?></td> <td class="data"><?php echo $so->price(TRUE,TRUE); if ($so->pending_change()) echo ' *'; ?></td>
</tr> </tr>
<?php if (is_null($so->price) OR ($so->price<=$so->product->price($so->price_group,$so->recur_schedule,'price_base'))) { ?> <?php if (is_null($so->price) OR ($so->price<=$so->product->price($so->price_group,$so->recur_schedule,'price_base'))) { ?>
<tr> <tr>