Overhaul ADSL traffic reporting/graphing

This commit is contained in:
Deon George
2013-11-14 22:50:35 +11:00
parent 158a4f9e47
commit e01d37244c
33 changed files with 891 additions and 471 deletions

View File

@@ -106,42 +106,6 @@ abstract class Service_Traffic_Adsl {
}
}
public function charge_excess_traffic() {
$date = strtotime('last month');
// @todo need a way to find out services that have traffic charges dynamically.
foreach ($this->aso->services() as $so) {
if ($charge = $so->plugin()->traffic_lastmonth_exceed(FALSE,$date)) {
foreach ($charge as $metric => $details) {
$co = ORM::factory('Charge');
$co->status = 0;
$co->sweep_type = 6;
$co->account_id = $so->account_id;
$co->service_id = $so->id;
// @todo This needs to be calculated.
$co->type = 5;
$co->amount = $details['rate'];
// @todo This needs to be calculated.
$co->taxable = TRUE;
$co->quantity = ceil($details['excess']/1000);
$co->description = _('Excess Traffic');
// @todo This need to be improved = strtotime function should be the one used in the function call
$co->attributes = implode("\n",array(
sprintf('ADSL Service==%s',$so->plugin()->service_number),
sprintf('Allowance==%s',$details['allowance']),
sprintf('Metric==%s',$metric),
sprintf('Used==%s',$details['used']),
sprintf('Month==%s',date('Y-m',$date)),
));
$co->check();
$co->save();
}
}
}
}
public function alert_traffic() {
foreach ($this->aso->services() as $so) {
if (! $so->plugin()->report_traffic())