Overhaul ADSL traffic reporting/graphing

This commit is contained in:
Deon George
2013-11-14 22:50:35 +11:00
parent 158a4f9e47
commit e01d37244c
33 changed files with 891 additions and 471 deletions

View File

@@ -12,6 +12,8 @@
class Controller_Admin_Adsl extends Controller_Adsl {
protected $secure_actions = array(
'index'=>TRUE,
'edit'=>TRUE,
'list'=>TRUE,
'traffic'=>TRUE,
);
@@ -29,6 +31,94 @@ class Controller_Admin_Adsl extends Controller_Adsl {
->body($output);
}
public function action_list() {
Block::factory()
->title('ADSL Plans')
->title_icon('icon-th-list')
->body(Table::factory()
->data(ORM::factory('Product_Plugin_Adsl')->find_all())
->jssort('adsl')
->columns(array(
'id'=>'ID',
'adsl_supplier_plan->name()'=>'Plan',
'adsl_supplier_plan->display("status")'=>'Avail',
'base_down_peak'=>'PD',
'base_down_offpeak'=>'OPD',
'base_up_peak'=>'PU',
'base_up_offpeak'=>'OPU',
'extra_charged'=>'$',
'extra_down_peak'=>'EPD',
'extra_down_offpeak'=>'EOPD',
'extra_up_peak'=>'EPU',
'extra_up_offpeak'=>'EOPU',
'contract_term'=>'Cont',
))
->prepend(array(
'id'=>array('url'=>URL::link('admin','adsl/edit/')),
))
);
}
public function action_edit() {
$apo = ORM::factory('Product_Plugin_Adsl',$this->request->param('id'));
$test_result = array();
if (! $apo->loaded())
HTTP::redirect(URL::link('admin','adsl/list'));
if ($_POST) {
// Entry updated
if ($apo->values($_POST)->check() AND $apo->changed()) {
try {
if ($apo->save())
SystemMessage::factory()
->title('Record updated')
->type('success')
->body(_('Your Charge record has been recorded/updated.'));
} catch (ORM_Validation_Exception $e) {
$errors = $e->errors('models');
SystemMessage::factory()
->title('Record NOT updated')
->type('error')
->body(join('<br/>',array_values($errors)));
$sco->reload();
}
}
if (isset($_POST['test'])) {
$charge = isset($_POST['test']['charge']) ? $_POST['test']['charge'] : FALSE;
$test_result = $apo->allowance($_POST['test'],FALSE,$charge,1000);
}
}
Block::factory()
->type('form-horizontal')
->title('Update ADSL Plan')
->title_icon('icon-wrench')
->body(View::factory('adsl/admin/edit')
->set('test_result',$test_result)
->set('o',$apo));
Block::factory()
->title('Products Using this Plan')
->title_icon('icon-th-list')
->body(Table::factory()
->jssort('traffic')
->data($apo->products()->find_all())
->columns(array(
'id'=>'ID',
'title()'=>'Name',
'status'=>'Active',
))
->prepend(array(
'id'=>array('url'=>URL::link('admin','product/edit/')),
))
);
}
/**
* Reconcile billing for an ADSL supplier
*/