Fixes for live environment and updates to admin/service/update

This commit is contained in:
Deon George
2011-07-22 11:04:20 +10:00
parent 27cdab1fe4
commit c8c4c5176d
41 changed files with 2457 additions and 82 deletions

View File

@@ -9,7 +9,6 @@
* @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');
@@ -51,14 +50,14 @@ ORDER BY c.id,s.recur_schedule,c.name,a.company,a.last_name,a.first_name
if (($si != $last_account) AND $last_account) {
if ($sc > 1)
$output .= View::factory('service/list/bycheckout_subtotal')
$output .= View::factory('service/admin/list/bycheckout_subtotal')
->set('subtotal',Currency::display($st))
->set('i',$i++%2);
$sc = $st = 0;
}
if (($service['cid'] != $last_checkout) OR (! is_null($last_checkout) AND ! $last_checkout)) {
$output .= View::factory('service/list/bycheckout_header')
$output .= View::factory('service/admin/list/bycheckout_header')
->set('checkout_name',$service['checkout_plugin_name'])
->set('last_checkout',$last_checkout);
}
@@ -69,14 +68,14 @@ ORDER BY c.id,s.recur_schedule,c.name,a.company,a.last_name,a.first_name
$st += round($so->price+$so->tax(),2);
$sc++;
$output .= View::factory('service/list/bycheckout_body')
$output .= View::factory('service/admin/list/bycheckout_body')
->set('service',$so)
->set('i',$i++%2);
}
// Last subtotal
if ($sc > 1)
$output .= View::factory('service/list/bycheckout_subtotal')
$output .= View::factory('service/admin/list/bycheckout_subtotal')
->set('subtotal',$st)
->set('i',$i++%2);
@@ -124,13 +123,13 @@ ORDER BY C.last_name,B.account_id,A.service_number
if ($i)
$output .= '<tr><td colspan="10">&nbsp;</td></tr>';
$output .= View::factory('service/list/adslservices_header')
$output .= View::factory('service/admin/list/adslservices_header')
->set('service',$so);
$last_account = $so->account_id;
}
$output .= View::factory('service/list/adslservices_body')
$output .= View::factory('service/admin/list/adslservices_body')
->set('service',$so)
->set('i',$i++%2);
}
@@ -218,13 +217,13 @@ ORDER BY C.last_name,B.account_id,A.service_number
if ($i)
$output .= '<tr><td colspan="10">&nbsp;</td></tr>';
$output .= View::factory('service/list/adslservices_header')
$output .= View::factory('service/admin/list/adslservices_header')
->set('service',$so);
$last_account = $so->account_id;
}
$output .= View::factory('service/list/adslservices_body')
$output .= View::factory('service/admin/list/adslservices_body')
->set('service',$so)
->set('i',$i++%2);
}
@@ -294,7 +293,7 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
$i = $j = 0;
$total = 0;
$summary = '';
$output = View::factory('service/list/adslbilling_head');
$output = View::factory('service/admin/list/adslbilling_head');
$output .= '<table class="box-left">';
foreach ($aso->services(TRUE) as $so) {
// Reset our uploaded data
@@ -307,7 +306,7 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
// Record the the exception if the cost is not expected
if (round($so->service_adsl->adsl_plan->adsl_supplier_plan->base_cost+$so->service_adsl->adsl_plan->adsl_supplier_plan->tax(),2) != $uploaded['amount']) {
$summary .= View::factory('service/list/adslbilling_summary')
$summary .= View::factory('service/admin/list/adslbilling_summary')
->set('service',$so)
->set('amount',$uploaded['amount'])
->set('i',$j++%2);
@@ -325,7 +324,7 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
}
$total += $uploaded['amount'];
$output .= View::factory('service/list/adslbilling_body')
$output .= View::factory('service/admin/list/adslbilling_body')
->set('service',$so)
->set('checked',$uploaded['checked'])
->set('amount',$uploaded['amount'])
@@ -333,7 +332,7 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
->set('i',$i++%2);
}
$output .= View::factory('service/list/adslbilling_foot')
$output .= View::factory('service/admin/list/adslbilling_foot')
->set('total',$total);
$output .= '</table>';
@@ -341,7 +340,7 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
// Summary Report of remaining CSV items.
if (! empty($csv))
foreach ($csv as $service => $item) {
$summary .= View::factory('service/list/adslbilling_summary_exception')
$summary .= View::factory('service/admin/list/adslbilling_summary_exception')
->set('service',$service)
->set('item',$item)
->set('i',$j++%2);
@@ -433,8 +432,31 @@ GROUP BY DATE_FORMAT(DATE,"%%Y-%%m"),SID
'title'=>sprintf('%s %s:%s',_('Update Service'),$so->id(),$so->name()),
'body'=>View::factory($so->viewpath())
->set('so',$so)
->set('mediapath',Route::get('default/media'))
->set('plugin_form',$so->admin_update()),
));
// @todo Investigate a better way of preparing for jscalendar
Script::add(array(
'type'=>'file',
'data'=>'js/dhtml.calendar.js',
));
Script::add(array(
'type'=>'file',
'data'=>'js/dhtml.calendar-setup.js',
));
Script::add(array(
'type'=>'file',
'data'=>'js/dhtml.calendar-en.js',
));
Script::add(array(
'type'=>'file',
'data'=>'js/dhtml.date_selector.js',
));
Style::add(array(
'type'=>'file',
'data'=>'css/dhtml.calendar.css',
));
}
}
?>

View File

@@ -32,7 +32,7 @@ class Controller_User_Service extends Controller_TemplateDefault {
public function action_list() {
Block::add(array(
'title'=>sprintf('%s: %s - %s',_('Services For'),$this->ao->accnum(),$this->ao->name(TRUE)),
'body'=>View::factory('service/list')
'body'=>View::factory('service/user/list')
->set('services',$this->ao->service->find_all()),
));
}
@@ -47,7 +47,7 @@ class Controller_User_Service extends Controller_TemplateDefault {
Block::add(array(
'title'=>sprintf('%s: %s',$so->id(),$so->product->name()),
'body'=>View::factory('service/view')
'body'=>View::factory('service/user/view')
->set('so',$so),
));
}

View File

@@ -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;

View File

@@ -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));
}
}
?>