Rework service, change module_method configuration
This commit is contained in:
92
modules/adsl/classes/Controller/Reseller/Service/Adsl.php
Normal file
92
modules/adsl/classes/Controller/Reseller/Service/Adsl.php
Normal file
@@ -0,0 +1,92 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides Reseller ADSL Service functions
|
||||
*
|
||||
* @package ADSL
|
||||
* @category Controllers/Reseller
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Reseller_Service_Adsl extends Controller_Service {
|
||||
protected $secure_actions = array(
|
||||
'list'=>TRUE,
|
||||
);
|
||||
|
||||
private function consoltraffic($svs,$date) {
|
||||
$data = array();
|
||||
|
||||
foreach ($svs as $so) {
|
||||
$c = array();
|
||||
foreach ($so->plugin()->get_traffic_data_monthly($date) as $metric => $ma) {
|
||||
foreach ($ma as $month => $traffic) {
|
||||
// Only count the service once, not for each metric.
|
||||
if (! isset($c[$month])) {
|
||||
if (isset($data['svs'][$month]))
|
||||
$data['svs'][$month] += 1;
|
||||
else
|
||||
$data['svs'][$month] = 1;
|
||||
|
||||
$c[$month] = 1;
|
||||
}
|
||||
|
||||
if (isset($data['data'][$metric][$month]))
|
||||
$data['data'][$metric][$month] += (int)$traffic;
|
||||
else
|
||||
$data['data'][$metric][$month] = (int)$traffic;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ksort($data['svs']);
|
||||
foreach ($data['data'] as $metric => $details)
|
||||
ksort($data['data'][$metric]);
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function action_list() {
|
||||
$svs = $this->filter(ORM::factory('Service')->list_byplugin('ADSL'),$this->ao->RTM->customers($this->ao->RTM),'account_id','name()');
|
||||
|
||||
$data = $this->consoltraffic($svs,time());
|
||||
|
||||
$google = GoogleChart::factory('Legacy')
|
||||
->type('vertical_bar')
|
||||
->title(sprintf('ADSL traffic as at %s',date('Y-m-d',strtotime('yesterday'))));
|
||||
|
||||
foreach ($data['data'] as $key => $values)
|
||||
$google->sdata(array('yl'=>$key),array($key=>$values));
|
||||
|
||||
$google->sdata(array('yr'=>'services'),array('services'=>$data['svs']));
|
||||
|
||||
Block::add(array('body'=>(string)$google));
|
||||
|
||||
Block::factory()
|
||||
->title('ADSL Services')
|
||||
->title_icon('icon-th-list')
|
||||
->body(Table::factory()
|
||||
->jssort('adsl')
|
||||
->data($svs)
|
||||
->columns(array(
|
||||
'id'=>'ID',
|
||||
'name()'=>'Service',
|
||||
'plugin()->ipaddress()'=>'IP Address',
|
||||
'product->plugin()->speed'=>'Speed',
|
||||
'product->plugin()->allowance()'=>'Allowance',
|
||||
'plugin()->traffic_thismonth()'=>'This Month',
|
||||
'plugin()->traffic_lastmonth()'=>'Last Month',
|
||||
'recur_schedule'=>'Billing',
|
||||
'price(TRUE,TRUE)'=>'Price',
|
||||
'account->accnum()'=>'Cust ID',
|
||||
'account->name()'=>'Customer',
|
||||
'date_next_invoice'=>'Next Invoice',
|
||||
'due(TRUE)'=>'Due Invoices',
|
||||
))
|
||||
->prepend(array(
|
||||
'id'=>array('url'=>URL::link('user','service/view/')),
|
||||
))
|
||||
);
|
||||
}
|
||||
}
|
||||
?>
|
@@ -59,7 +59,7 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
|
||||
|
||||
public function service_view() {
|
||||
return View::factory('service/user/plugin/adsl/view')
|
||||
->set('so',$this);
|
||||
->set('o',$this);
|
||||
}
|
||||
|
||||
public function username_value() {
|
||||
@@ -81,8 +81,10 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
|
||||
return Config::date($this->service_contract_date);
|
||||
}
|
||||
|
||||
public function contract_date_end() {
|
||||
return Config::date(strtotime(sprintf('+%s months',$this->contract_term),$this->service_contract_date));
|
||||
public function contract_date_end($format=FALSE) {
|
||||
$x = strtotime(sprintf('+%s months',$this->contract_term),$this->service_contract_date);
|
||||
|
||||
return $format ? Config::date($x) : $x;
|
||||
}
|
||||
|
||||
public function hasOffpeak() {
|
||||
|
@@ -1,28 +1,18 @@
|
||||
<!-- //@todo To translate -->
|
||||
<table class="box-full">
|
||||
<tr>
|
||||
<td style="width: 40%;">Speed</td>
|
||||
<td class="data" style="width: 60%;" colspan="2"><?php echo $po->display('speed'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td>Peak</td>
|
||||
<?php if ($po->base_down_offpeak OR $po->extra_down_offpeak) { ?>
|
||||
<td>Off Peak</td>
|
||||
<?php } ?>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Included Download Traffic</td>
|
||||
<!-- // @todo Since price is stored in the DB in GB, so should the traffic. -->
|
||||
<td class="data"><?php echo $po->base_down_peak/1000; ?> GB</td>
|
||||
<td class="data"><?php echo $po->base_down_offpeak ? ($po->base_down_offpeak/1000).'GB' : HTML::nbsp(''); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Extra Download Traffic</td>
|
||||
<td class="data"><?php echo $po->display('extra_down_peak'); ?>/GB</td>
|
||||
<td class="data"><?php echo $po->extra_down_offpeak ? $po->display('extra_down_offpeak').'/GB' : HTML::nbsp(''); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<fieldset class="span6">
|
||||
<legend>ADSL Features</legend>
|
||||
|
||||
<div class="dl-horizontal">
|
||||
|
||||
<dt>Speed</dt>
|
||||
<dd><?php echo $po->display('speed'); ?></dd>
|
||||
|
||||
<dt>Peak Downloads Included</dt>
|
||||
<dd><?php echo $po->base_down_peak/1000; ?> GB, excess <?php echo $po->display('extra_down_peak'); ?>/GB.
|
||||
|
||||
<?php if ($po->base_down_offpeak OR $po->extra_down_offpeak) : ?>
|
||||
<dt>OffPeak Downloads Included</dt>
|
||||
<dd><?php echo $po->base_down_offpeak/1000; ?> GB, excess <?php echo $po->display('extra_down_offpeak'); ?>/GB.
|
||||
<?php endif ?>
|
||||
|
||||
</div> <!-- /dl-horizontal -->
|
||||
</fieldset>
|
||||
|
@@ -1,79 +1,60 @@
|
||||
<!-- //@todo To translate -->
|
||||
<table class="box-full">
|
||||
<tr>
|
||||
<td class="head" colspan="3">Service Details</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3"> </td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<table>
|
||||
<tr>
|
||||
<td style="width: 40%;">Service Number</td>
|
||||
<td style="width: 60%;" class="data"><?php echo $so->display('service_number'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Service Address</td>
|
||||
<td class="data"><?php echo $so->display('service_address'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Contract Term</td>
|
||||
<td class="data"><?php echo $so->display('contract_term'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Connect Date</td>
|
||||
<td class="data"><?php echo $so->display('service_connect_date'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Contract End Date</td>
|
||||
<td class="data"><?php echo $so->contract_date_end(); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Service Username</td>
|
||||
<td class="data"><?php echo $so->display('service_username'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Service Password</td>
|
||||
<td class="data"><?php # @todo Enable the ability to hide this value echo $so->display('service_password'); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Service IP</td>
|
||||
<td class="data"><?php echo $so->ipaddress(); ?></td>
|
||||
</tr>
|
||||
<?php if ($so->hasOffPeak() AND $so->offpeak_start AND $so->offpeak_end) { ?>
|
||||
<tr>
|
||||
<td>Offpeak Period</td>
|
||||
<td class="data"><?php printf('%s-%s',$so->offpeak_start,$so->offpeak_end); ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</td>
|
||||
<td style="vertical-align: top;" colspan="2">
|
||||
<table>
|
||||
<tr>
|
||||
<td style="width: 40%;">Traffic Used This Month</td>
|
||||
<td style="width: 60%;" class="data"><?php echo $so->traffic_month(NULL); ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Traffic Used Last Month</td>
|
||||
<td class="data"><?php echo $so->traffic_lastmonth(); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<table>
|
||||
<tr>
|
||||
<td>View Daily Traffic for Month</td>
|
||||
<td><?php echo Form::open(); echo Form::select('month',array_merge(array(''),$so->get_traffic_months()),(isset($_POST['month']) ? $_POST['month'] : '')); echo Form::submit('submit',_('Show'),array('class'=>'form_button')); echo Form::close(); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2"><?php echo $so->graph_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?></td>
|
||||
<td><?php echo $so->table_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<fieldset class="span5">
|
||||
<legend>Service Details</legend>
|
||||
|
||||
<div class="dl-horizontal">
|
||||
|
||||
<dt>Service Number</dt>
|
||||
<dd><?php echo $o->display('service_number'); ?></dd>
|
||||
|
||||
<dt>Service Address</dt>
|
||||
<dd><?php echo $o->display('service_address'); ?></dd>
|
||||
|
||||
<dt>Connect Date</dt>
|
||||
<dd><?php echo $o->display('service_connect_date'); ?></dd>
|
||||
|
||||
<dt>Contract Term</dt>
|
||||
<dd><?php echo $o->display('contract_term'); ?></dd>
|
||||
|
||||
<dt>Contract End Date</dt>
|
||||
<dd><?php echo $o->contract_date_end(TRUE); ?></dd>
|
||||
|
||||
<dt>Service Username</dt>
|
||||
<dd><?php echo $o->display('service_username'); ?></dd>
|
||||
|
||||
<dt>Service Password</dt>
|
||||
<dd><?php echo $o->display('service_password'); ?></dd>
|
||||
|
||||
<dt>Service IP</dt>
|
||||
<dd><?php echo $o->ipaddress(); ?></dd>
|
||||
|
||||
<?php if ($o->hasOffPeak() AND $o->offpeak_start AND $o->offpeak_end) : ?>
|
||||
<dt>Offpeak Period</dt>
|
||||
<dd><?php printf('%s-%s',$o->offpeak_start,$o->offpeak_end); ?></dd>
|
||||
<?php endif ?>
|
||||
|
||||
</div> <!-- dl-horizontal -->
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="span6">
|
||||
<legend>Traffic Usage</legend>
|
||||
|
||||
<div class="dl-horizontal">
|
||||
<dt>This Month</dt>
|
||||
<dd> <?php echo $o->traffic_month(NULL); ?></dd>
|
||||
|
||||
<dt>Last Month</dt>
|
||||
<dd> <?php echo $o->traffic_lastmonth(); ?></dd>
|
||||
</div> <!-- dl-horizontal -->
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="span6">
|
||||
<table>
|
||||
<tr>
|
||||
<td>View Daily Traffic for Month</td>
|
||||
<td><?php echo Form::open(); echo Form::select('month',array_merge(array(''),$o->get_traffic_months()),(isset($_POST['month']) ? $_POST['month'] : '')); echo Form::submit('submit',_('Show'),array('class'=>'form_button')); echo Form::close(); ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php echo $o->graph_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?><br>
|
||||
<?php echo $o->table_traffic(isset($_POST['month']) ? $_POST['month'] : ''); ?>
|
||||
</fieldset>
|
||||
|
Reference in New Issue
Block a user