Local fixes to invoice display and retrieve traffic data
This commit is contained in:
@@ -195,10 +195,13 @@ class Model_Service_ADSL extends Model_Service {
|
||||
return $this->traffic_month(strtotime('yesterday'),$string);
|
||||
}
|
||||
|
||||
public function traffic_lastmonth_exceed($all=FALSE) {
|
||||
public function traffic_lastmonth_exceed($all=FALSE,$date=NULL) {
|
||||
$return = array();
|
||||
|
||||
foreach ($this->traffic_month(strtotime('last month'),FALSE) as $k => $v) {
|
||||
if (is_null($date))
|
||||
$date = strtotime('last month');
|
||||
|
||||
foreach ($this->traffic_month($date,FALSE) as $k => $v) {
|
||||
// We shouldnt need to eval for nulls, since the traffic calc does that
|
||||
if ($all OR ($v > $this->adsl_plan->$k)) {
|
||||
$return[$k]['allowance'] = $this->adsl_plan->$k;
|
||||
@@ -351,7 +354,7 @@ class Model_Service_ADSL extends Model_Service {
|
||||
case 'invoice':
|
||||
return array(
|
||||
_('Service Address')=>$this->display('service_address'),
|
||||
_('Contact Until')=>$this->contract_date_end(),
|
||||
_('Contract Until')=>$this->contract_date_end(),
|
||||
);
|
||||
break;
|
||||
default:
|
||||
|
@@ -107,9 +107,11 @@ 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->so->services() as $so) {
|
||||
if ($charge = $so->service_adsl->traffic_lastmonth_exceed(FALSE)) {
|
||||
if ($charge = $so->service_adsl->traffic_lastmonth_exceed(FALSE,$date)) {
|
||||
foreach ($charge as $metric => $details) {
|
||||
$co = ORM::factory('charge');
|
||||
|
||||
@@ -128,14 +130,12 @@ class Service_Traffic_ADSL {
|
||||
sprintf('Allowance==%s',$details['allowance']),
|
||||
sprintf('Metric==%s',$metric),
|
||||
sprintf('Used==%s',$details['used']),
|
||||
sprintf('Month==%s',date('Y-m',strtotime('last month'))),
|
||||
sprintf('Month==%s',date('Y-m',$date)),
|
||||
));
|
||||
|
||||
$co->check();
|
||||
$co->save();
|
||||
}
|
||||
|
||||
print_r(array('s'=>$so->id,'a'=>$so->service_adsl->service_number,'al'=>$so->service_adsl->adsl_plan->allowance(FALSE),'charge'=>$charge));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,5 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
include_once 'includes/kohana/modules/simplehtmldom/classes/simple_html_dom.php';
|
||||
|
||||
/**
|
||||
* This class is able to collect traffic information for Exetel HSPA
|
||||
*
|
||||
@@ -64,6 +62,8 @@ class Service_Traffic_ADSL_ExetelHSPA extends Service_Traffic_ADSL {
|
||||
continue;
|
||||
}
|
||||
|
||||
include_once 'includes/kohana/modules/simplehtmldom/classes/simple_html_dom.php';
|
||||
|
||||
for ($servicedate=date('Y-m-d',strtotime($this->so->stats_lastupdate.'+1 day'));
|
||||
$servicedate <= $this->today;
|
||||
$servicedate=date('Y-m-d',strtotime('+1 month',strtotime(date('Y-m',strtotime($servicedate)).'-01')))) {
|
||||
|
Reference in New Issue
Block a user