Improved service display
This commit is contained in:
@@ -40,66 +40,15 @@ class Controller_User_Service extends Controller_TemplateDefault {
|
||||
public function action_view($id) {
|
||||
$so = ORM::factory('service',$id);
|
||||
|
||||
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account_id)) {
|
||||
$this->template->content = 'Unauthorised or doesnt exist?';
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$graph = $graph_data = $product_info = $product_detail = '';
|
||||
|
||||
// @todo Work this out dynamically
|
||||
if ($so->product->prod_plugin AND in_array($so->product->prod_plugin_file,array('ADSL'))) {
|
||||
|
||||
$google = GoogleChart::factory('vertical_bar');
|
||||
|
||||
// If we came in via a post to show a particular month, then show that, otherwise show the yearly result
|
||||
if ($_POST AND isset($_POST['month'])) {
|
||||
$google->title = sprintf('DSL traffic usage for %s',$_POST['month']);
|
||||
$traffic_data = $so->service_adsl->get_traffic_data_daily(strtotime($_POST['month'].'-01'));
|
||||
|
||||
foreach ($traffic_data as $k => $details)
|
||||
$google->series(array(
|
||||
'title'=>array((isset($friendly[$k]) ? $friendly[$k] : $k)),
|
||||
'axis'=>'x',
|
||||
'data'=>array((isset($friendly[$k]) ? $friendly[$k] : $k)=>$traffic_data[$k])));
|
||||
|
||||
foreach ($traffic_data as $k => $details)
|
||||
$google->series(array(
|
||||
'title'=>array((isset($friendly['cumulative'.$k]) ? $friendly['cumulative'.$k] : 'cumulative'.$k)),
|
||||
'axis'=>'r',
|
||||
'data'=>array((isset($friendly['cumulative'.$k]) ? $friendly['cumulative'.$k] : 'cumulative'.$k)=>$so->service_adsl->cumulative($traffic_data[$k]))));
|
||||
|
||||
$graph_data = View::factory('service/view_detail_adsl_traffic')
|
||||
->set('traffic',$so->service_adsl->traffic_month(strtotime($_POST['month'].'-01'),FALSE));
|
||||
|
||||
} else {
|
||||
// @todo Change the date to the last record date
|
||||
$google->title = sprintf('Monthly DSL traffic usage as at %s',Config::date(strtotime('yesterday')));
|
||||
$traffic_data = $so->service_adsl->get_traffic_data_monthly();
|
||||
|
||||
foreach ($traffic_data as $k => $details)
|
||||
$google->series(array(
|
||||
'title'=>array((isset($friendly[$k]) ? $friendly[$k] : $k)),
|
||||
'axis'=>'x',
|
||||
'data'=>array((isset($friendly[$k]) ? $friendly[$k] : $k)=>$traffic_data[$k])));
|
||||
}
|
||||
|
||||
$graph = (string)$google;
|
||||
|
||||
$product_info = ADSL::instance()->product_view($so->service_adsl->adsl_plan_id,$so->price,$so->product->price_setup);
|
||||
$product_detail = View::factory('service/view_detail_adsl')
|
||||
->set('graph',$graph)
|
||||
->set('graph_data',$graph_data)
|
||||
->set('service',$so);
|
||||
if (! $so->loaded() OR ! Auth::instance()->authorised($so->account_id)) {
|
||||
$this->template->content = 'Unauthorised or doesnt exist?';
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// @todo need to get the monthly price
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%06s: %s',$so->id,$so->product->product_translate->find()->name),
|
||||
'title'=>sprintf('%s: %s',$so->id(),$so->product->name()),
|
||||
'body'=>View::factory('service/view')
|
||||
->set('service',$so)
|
||||
->set('product_info',$product_info)
|
||||
->set('product_detail',$product_detail),
|
||||
->set('so',$so),
|
||||
));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user