Fixes for live environment and updates to admin/service/update
This commit is contained in:
@@ -76,7 +76,7 @@ class Model_Service extends ORMOSB {
|
||||
/**
|
||||
* Return the object of the product plugin
|
||||
*/
|
||||
public function plugin() {
|
||||
private function plugin() {
|
||||
if (! $this->product->prod_plugin_file)
|
||||
return NULL;
|
||||
|
||||
|
@@ -183,7 +183,8 @@ class Model_Service_ADSL extends Model_Service {
|
||||
}
|
||||
|
||||
public function traffic_lastmonth($string=TRUE) {
|
||||
return $this->traffic_month(strtotime('last month'),$string);
|
||||
// We need it to be last month as of yesterday
|
||||
return $this->traffic_month(strtotime('last month')-86400,$string);
|
||||
}
|
||||
|
||||
public function traffic_thismonth($string=TRUE) {
|
||||
@@ -225,8 +226,8 @@ class Model_Service_ADSL extends Model_Service {
|
||||
|
||||
$traffic_type = $this->get_traffic_data_daily($period,TRUE);
|
||||
$day = count($traffic_type) ? max(array_keys($traffic_type)) : 1;
|
||||
$date = mktime(0,0,0,date('m',$period),$day,date('Y',$period));
|
||||
$daysleft = date('d',strtotime('last day ',$date))-$day;
|
||||
$date = mktime(0,0,0,date('n',$period),$day,date('Y',$period));
|
||||
$daysleft = date('d',strtotime('last day of',$date))-$day;
|
||||
|
||||
$google = GoogleChart::factory('vertical_bar');
|
||||
$google->title = sprintf('DSL traffic usage as at %s',Config::date($date));
|
||||
@@ -248,7 +249,7 @@ class Model_Service_ADSL extends Model_Service {
|
||||
switch ($item) {
|
||||
case 'MONTH_GRAPH': $value = (string)$google; break;
|
||||
case 'MONTH_TABLE': $value = $google->html_table(FALSE,array(
|
||||
'table'=>'style="border: 1px solid #bebcb7; padding: 5px 5px; background: none repeat scroll 0% 0% #f8f7f5;"',
|
||||
'table'=>'style="border: 1px solid #bebcb7; padding: 5px 5px; background: none repeat scroll 0% 0% #f8f7f5; font-size: 70%;"',
|
||||
)); break;
|
||||
|
||||
case 'OFFPEAK_ALLOWANCE': $value = isset($allowance['base_down_offpeak']) ? $allowance['base_down_offpeak'].' MB' : '-'; break;
|
||||
@@ -331,7 +332,7 @@ class Model_Service_ADSL extends Model_Service {
|
||||
}
|
||||
|
||||
protected function _service_view() {
|
||||
return View::factory('service/adsl/view')
|
||||
return View::factory($this->viewpath(strtolower($this->service->prod_plugin_name)))
|
||||
->set('so',$this);
|
||||
}
|
||||
|
||||
@@ -356,13 +357,14 @@ class Model_Service_ADSL extends Model_Service {
|
||||
|
||||
protected function _admin_update() {
|
||||
return View::factory($this->viewpath(strtolower($this->service->prod_plugin_name)))
|
||||
->set('mediapath',Route::get('default/media'))
|
||||
->set('so',$this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render a google chart of traffic
|
||||
*/
|
||||
public function graph_traffic($month=null) {
|
||||
public function graph_traffic($month=NULL) {
|
||||
$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
|
||||
@@ -382,9 +384,6 @@ class Model_Service_ADSL extends Model_Service {
|
||||
'axis'=>'r',
|
||||
'data'=>array((isset($friendly['cumulative'.$k]) ? $friendly['cumulative'.$k] : 'cumulative'.$k)=>$this->cumulative($traffic_data[$k]))));
|
||||
|
||||
$graph_data = View::factory('service/view_detail_adsl_traffic')
|
||||
->set('traffic',$this->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')));
|
||||
@@ -399,5 +398,10 @@ class Model_Service_ADSL extends Model_Service {
|
||||
|
||||
return (string)$google;
|
||||
}
|
||||
|
||||
public function table_traffic($month=NULL) {
|
||||
return View::factory('service/user/adsl/table_traffic')
|
||||
->set('traffic',$this->traffic_month((! is_null($month) AND trim($month)) ? strtotime($month.'-01') : NULL,FALSE));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user