Improved service display
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
* @author Deon George
|
||||
* @copyright (c) 2010 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
* @todo Replace View::factory files to use $this->viewpath()
|
||||
*/
|
||||
class Controller_Admin_Service extends Controller_TemplateDefault {
|
||||
protected $control = array('Services'=>'services');
|
||||
@@ -17,6 +18,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault {
|
||||
'listbycheckout'=>TRUE,
|
||||
'listadslservices'=>TRUE,
|
||||
'listhspaservices'=>TRUE,
|
||||
'update'=>TRUE,
|
||||
);
|
||||
|
||||
/**
|
||||
@@ -355,7 +357,7 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
|
||||
Block::add(array(
|
||||
'title'=>_('ADSL Services'),
|
||||
'body'=>$output,
|
||||
));
|
||||
));
|
||||
|
||||
if ($summary)
|
||||
Block::add(array(
|
||||
@@ -411,5 +413,28 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
||||
public function action_update($id) {
|
||||
$so = ORM::factory('service',$id);
|
||||
|
||||
if (! $so->loaded())
|
||||
Request::current()->redirect('welcome/index');
|
||||
|
||||
if ($_POST) {
|
||||
if (isset($_POST['plugin']) AND $_POST['plugin'])
|
||||
if (! $so->plugin()->values($_POST['plugin'])->update()->saved())
|
||||
throw new Kohana_Exception('Failed to save updates to plugin data for record :record',array(':record'=>$so->id()));
|
||||
|
||||
if (! $so->values($_POST)->update()->saved())
|
||||
throw new Kohana_Exception('Failed to save updates to plugin data for record :record',array(':record'=>$so->id()));
|
||||
}
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s %s:%s',_('Update Service'),$so->id(),$so->name()),
|
||||
'body'=>View::factory($so->viewpath())
|
||||
->set('so',$so)
|
||||
->set('plugin_form',$so->admin_update()),
|
||||
));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -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