Consistent use of return , payment refund handling
This commit is contained in:
@@ -123,12 +123,12 @@ class ADSL {
|
||||
}
|
||||
|
||||
// Return the output sorted
|
||||
$return = array();
|
||||
$result = array();
|
||||
foreach (array('base_down_peak','base_down_offpeak','base_up_peak','base_up_offpeak') as $k)
|
||||
if (isset($a[$k]))
|
||||
$return[$k] = $a[$k];
|
||||
$result[$k] = $a[$k];
|
||||
|
||||
return $return;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -33,13 +33,13 @@ class Model_Adsl_Supplier extends ORM_OSB {
|
||||
* Return a list of plans that we provide by this supplier
|
||||
*/
|
||||
public function adsl_plans($active=TRUE) {
|
||||
$return = array();
|
||||
$result = array();
|
||||
|
||||
foreach ($this->plans($active)->find_all() as $po)
|
||||
foreach ($po->adsl_plan->find_all() as $apo)
|
||||
$return[$apo->id] = $apo;
|
||||
$result[$apo->id] = $apo;
|
||||
|
||||
return $return;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -111,23 +111,23 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
|
||||
* Calculate the total traffic used in a month
|
||||
*/
|
||||
private function get_traffic_data_month($period=NULL,$cache=NULL) {
|
||||
$return = array();
|
||||
$result = array();
|
||||
|
||||
foreach ($this->get_traffic_data_daily($period,TRUE,$cache) as $tdata)
|
||||
foreach ($tdata as $k => $v)
|
||||
if (isset($return[$k]))
|
||||
$return[$k] += $v;
|
||||
if (isset($result[$k]))
|
||||
$result[$k] += $v;
|
||||
else
|
||||
$return[$k] = $v;
|
||||
$result[$k] = $v;
|
||||
|
||||
return $return;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of the data used in a month by day
|
||||
*/
|
||||
public function get_traffic_data_daily($period=NULL,$bydate=FALSE,$cache=NULL) {
|
||||
$return = array();
|
||||
$result = array();
|
||||
|
||||
// @temp - caching is broken?
|
||||
$cache=0;
|
||||
@@ -144,20 +144,20 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
|
||||
$day = date('d',strtotime($to->date));
|
||||
|
||||
if ($bydate)
|
||||
$return[$day] = $to->traffic($this->service->product->plugin());
|
||||
$result[$day] = $to->traffic($this->service->product->plugin());
|
||||
else
|
||||
foreach ($to->traffic($this->service->product->plugin()) as $k => $v)
|
||||
$return[$k][$day] = $v;
|
||||
$result[$k][$day] = $v;
|
||||
}
|
||||
|
||||
return $return;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an array of the data used in a year by month
|
||||
*/
|
||||
public function get_traffic_data_monthly($period=NULL,$bydate=FALSE) {
|
||||
$return = array();
|
||||
$result = array();
|
||||
|
||||
if (is_null($period))
|
||||
$period = strtotime('yesterday');
|
||||
@@ -177,12 +177,12 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
|
||||
|
||||
foreach ($t->find_all() as $to)
|
||||
if ($bydate)
|
||||
$return[$to->month] = $to->traffic($this->service->product->plugin());
|
||||
$result[$to->month] = $to->traffic($this->service->product->plugin());
|
||||
else
|
||||
foreach ($to->traffic($this->service->product->plugin()) as $k => $v)
|
||||
$return[$k][$to->month] = $v;
|
||||
$result[$k][$to->month] = $v;
|
||||
|
||||
return $return;
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function traffic_month($month,$string=TRUE,$cache=NULL) {
|
||||
@@ -200,7 +200,7 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
|
||||
}
|
||||
|
||||
public function traffic_lastmonth_exceed($all=FALSE,$date=NULL) {
|
||||
$return = array();
|
||||
$result = array();
|
||||
|
||||
if (is_null($date))
|
||||
$date = strtotime('last month')-86400;
|
||||
@@ -208,16 +208,16 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
|
||||
foreach ($this->traffic_month($date,FALSE,0) as $k => $v) {
|
||||
// We shouldnt need to eval for nulls, since the traffic calc does that
|
||||
if ($all OR ($v > $this->service->product->plugin()->$k)) {
|
||||
$return[$k]['allowance'] = $this->service->product->plugin()->$k;
|
||||
$return[$k]['used'] = $v;
|
||||
$return[$k]['shaped'] = (! empty($this->service->product->plugin()->extra_shaped) AND $this->service->product->plugin()->extra_shaped AND $v > $this->service->product->plugin()->$k) ? TRUE : FALSE;
|
||||
$return[$k]['excess'] = (! empty($this->service->product->plugin()->extra_charged) AND $this->service->product->plugin()->extra_charged AND $v > $this->service->product->plugin()->$k) ? $v-$this->service->product->plugin()->$k : 0;
|
||||
$return[$k]['rate'] = $this->service->product->plugin()->{ADSL::map($k)};
|
||||
$return[$k]['charge'] = ceil(($return[$k]['excess'])/1000)*$return[$k]['rate'];
|
||||
$result[$k]['allowance'] = $this->service->product->plugin()->$k;
|
||||
$result[$k]['used'] = $v;
|
||||
$result[$k]['shaped'] = (! empty($this->service->product->plugin()->extra_shaped) AND $this->service->product->plugin()->extra_shaped AND $v > $this->service->product->plugin()->$k) ? TRUE : FALSE;
|
||||
$result[$k]['excess'] = (! empty($this->service->product->plugin()->extra_charged) AND $this->service->product->plugin()->extra_charged AND $v > $this->service->product->plugin()->$k) ? $v-$this->service->product->plugin()->$k : 0;
|
||||
$result[$k]['rate'] = $this->service->product->plugin()->{ADSL::map($k)};
|
||||
$result[$k]['charge'] = ceil(($result[$k]['excess'])/1000)*$result[$k]['rate'];
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function template_variables($array) {
|
||||
@@ -228,7 +228,7 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
|
||||
'cumulative_base_down_offpeak'=>'Total OffPeak',
|
||||
);
|
||||
|
||||
$return = array();
|
||||
$result = array();
|
||||
if ($this->service->product->prod_plugin_file != 'ADSL')
|
||||
throw new Kohana_Exception('Huh? How did this get called, for a non ADSL product (:ppf)',array(':ppf'=>$this->service_id));
|
||||
|
||||
@@ -280,10 +280,10 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
|
||||
$value = '';
|
||||
}
|
||||
|
||||
$return[$item] = $value;
|
||||
$result[$item] = $value;
|
||||
}
|
||||
|
||||
return $return;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -17,7 +17,7 @@ class Service_Traffic_Adsl_Exetelhspa extends Service_Traffic_Adsl {
|
||||
private $login_pass_field = 'password';
|
||||
private $date_field = 'date';
|
||||
|
||||
static $return = array();
|
||||
static $result = array();
|
||||
|
||||
/**
|
||||
* Get the data for Exetel hspa services
|
||||
@@ -29,8 +29,8 @@ class Service_Traffic_Adsl_Exetelhspa extends Service_Traffic_Adsl {
|
||||
$this->fetchresult = TRUE;
|
||||
|
||||
// If we have already collected the date data, return it.
|
||||
if (! empty(Service_Traffic_Adsl_Exetelhspa::$return[$date]))
|
||||
return Service_Traffic_Adsl_Exetelhspa::$return[$date];
|
||||
if (! empty(Service_Traffic_Adsl_Exetelhspa::$result[$date]))
|
||||
return Service_Traffic_Adsl_Exetelhspa::$result[$date];
|
||||
|
||||
include_once 'includes/kohana/modules/simplehtmldom/classes/simple_html_dom.php';
|
||||
|
||||
@@ -173,14 +173,14 @@ class Service_Traffic_Adsl_Exetelhspa extends Service_Traffic_Adsl {
|
||||
// Reformat the data into date order.
|
||||
foreach ($update as $service => $sdata)
|
||||
foreach ($sdata as $sdate => $details)
|
||||
Service_Traffic_Adsl_Exetelhspa::$return[$sdate][$service] = $details;
|
||||
Service_Traffic_Adsl_Exetelhspa::$result[$sdate][$service] = $details;
|
||||
|
||||
// If the date we want is empty, return an array
|
||||
if (empty(Service_Traffic_Adsl_Exetelhspa::$return[$date]))
|
||||
if (empty(Service_Traffic_Adsl_Exetelhspa::$result[$date]))
|
||||
return array();
|
||||
|
||||
// Return the date we asked for
|
||||
return Service_Traffic_Adsl_Exetelhspa::$return[$date];
|
||||
return Service_Traffic_Adsl_Exetelhspa::$result[$date];
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -17,7 +17,7 @@ class Service_Traffic_Adsl_Exetelpe extends Service_Traffic_Adsl {
|
||||
private $login_pass_field = 'password';
|
||||
private $date_field = 'date';
|
||||
|
||||
static $return = array();
|
||||
static $result = array();
|
||||
|
||||
/**
|
||||
* Get the data for Exetel PE services
|
||||
@@ -29,8 +29,8 @@ class Service_Traffic_Adsl_Exetelpe extends Service_Traffic_Adsl {
|
||||
$this->fetchresult = TRUE;
|
||||
|
||||
// If we have already collected the date data, return it.
|
||||
if (! empty(Service_Traffic_Adsl_Exetelpe::$return[$date]))
|
||||
return Service_Traffic_Adsl_Exetelpe::$return[$date];
|
||||
if (! empty(Service_Traffic_Adsl_Exetelpe::$result[$date]))
|
||||
return Service_Traffic_Adsl_Exetelpe::$result[$date];
|
||||
|
||||
include_once 'includes/kohana/modules/simplehtmldom/classes/simple_html_dom.php';
|
||||
|
||||
@@ -166,14 +166,14 @@ class Service_Traffic_Adsl_Exetelpe extends Service_Traffic_Adsl {
|
||||
// Reformat the data into date order.
|
||||
foreach ($update as $service => $sdata)
|
||||
foreach ($sdata as $sdate => $details)
|
||||
Service_Traffic_Adsl_Exetelpe::$return[$sdate][$service] = $details;
|
||||
Service_Traffic_Adsl_Exetelpe::$result[$sdate][$service] = $details;
|
||||
|
||||
// If the date we want is empty, return an array
|
||||
if (empty(Service_Traffic_Adsl_Exetelpe::$return[$date]))
|
||||
if (empty(Service_Traffic_Adsl_Exetelpe::$result[$date]))
|
||||
return array();
|
||||
|
||||
// Return the date we asked for
|
||||
return Service_Traffic_Adsl_Exetelpe::$return[$date];
|
||||
return Service_Traffic_Adsl_Exetelpe::$result[$date];
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -15,7 +15,7 @@ class Service_Traffic_Adsl_Exetelvisp extends Service_Traffic_Adsl {
|
||||
private $date_field = 'date';
|
||||
|
||||
protected function getdata($date) {
|
||||
$return = array();
|
||||
$result = array();
|
||||
|
||||
// Assume we have a bad fetch, unless otherwise specified.
|
||||
$this->fetchresult = FALSE;
|
||||
@@ -58,10 +58,10 @@ class Service_Traffic_Adsl_Exetelvisp extends Service_Traffic_Adsl {
|
||||
$attrs['up_offpeak'] = $valuesarray[4]/100;
|
||||
$attrs['down_offpeak'] = $valuesarray[5]/100;
|
||||
|
||||
array_push($return,$attrs);
|
||||
array_push($result,$attrs);
|
||||
}
|
||||
|
||||
return $return;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -18,7 +18,7 @@ class Service_Traffic_ADSL_PeopleAgent extends Service_Traffic_ADSL {
|
||||
// Assume we have a bad fetch, unless otherwise specified.
|
||||
$this->fetchresult = FALSE;
|
||||
|
||||
$return = array();
|
||||
$result = array();
|
||||
$url_suffix = sprintf('traffic_V34_%s.xml',date('Ymd',strtotime($date)));
|
||||
|
||||
try {
|
||||
@@ -52,10 +52,10 @@ class Service_Traffic_ADSL_PeopleAgent extends Service_Traffic_ADSL {
|
||||
}
|
||||
}
|
||||
|
||||
array_push($return,$attrs);
|
||||
array_push($result,$attrs);
|
||||
}
|
||||
|
||||
return $return;
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@@ -17,7 +17,7 @@ class Service_Traffic_ADSL_iiNetADSL extends Service_Traffic_ADSL {
|
||||
private $login_pass_field = 'password';
|
||||
private $date_field = 'period';
|
||||
|
||||
static $return = array();
|
||||
static $result = array();
|
||||
|
||||
// The fields in the XML which are translated into database columns
|
||||
private $fields = array(
|
||||
@@ -37,8 +37,8 @@ class Service_Traffic_ADSL_iiNetADSL extends Service_Traffic_ADSL {
|
||||
$this->fetchresult = FALSE;
|
||||
|
||||
// If we have already collected the date data, return it.
|
||||
if (! empty(Service_Traffic_ADSL_iiNetADSL::$return[$date]))
|
||||
return Service_Traffic_ADSL_iiNetADSL::$return[$date];
|
||||
if (! empty(Service_Traffic_ADSL_iiNetADSL::$result[$date]))
|
||||
return Service_Traffic_ADSL_iiNetADSL::$result[$date];
|
||||
|
||||
// Find our services that need to be collected this way.
|
||||
$update = array();
|
||||
@@ -77,7 +77,7 @@ class Service_Traffic_ADSL_iiNetADSL extends Service_Traffic_ADSL {
|
||||
file_put_contents($debug_file,$data);
|
||||
}
|
||||
|
||||
$return = array();
|
||||
$result = array();
|
||||
foreach (XML::factory(NULL,'ii_feed',$data)->volume_usage->volume_usage->get('day_hour') as $day_hour) {
|
||||
$attrs = array();
|
||||
|
||||
@@ -100,9 +100,9 @@ class Service_Traffic_ADSL_iiNetADSL extends Service_Traffic_ADSL {
|
||||
$attrs[$this->fields[$fields['type']]] += $usage->value()/1000/1000;
|
||||
}
|
||||
|
||||
Service_Traffic_ADSL_iiNetADSL::$return[$period['period']][$so->service_adsl->service_username] = $attrs;
|
||||
Service_Traffic_ADSL_iiNetADSL::$return[$period['period']][$so->service_adsl->service_username]['date'] = $period['period'];
|
||||
Service_Traffic_ADSL_iiNetADSL::$return[$period['period']][$so->service_adsl->service_username]['service'] = $so->service_adsl->service_username;
|
||||
Service_Traffic_ADSL_iiNetADSL::$result[$period['period']][$so->service_adsl->service_username] = $attrs;
|
||||
Service_Traffic_ADSL_iiNetADSL::$result[$period['period']][$so->service_adsl->service_username]['date'] = $period['period'];
|
||||
Service_Traffic_ADSL_iiNetADSL::$result[$period['period']][$so->service_adsl->service_username]['service'] = $so->service_adsl->service_username;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -113,11 +113,11 @@ class Service_Traffic_ADSL_iiNetADSL extends Service_Traffic_ADSL {
|
||||
}
|
||||
|
||||
// If the date we want is empty, return an array
|
||||
if (empty(Service_Traffic_ADSL_iiNetADSL::$return[$date]))
|
||||
if (empty(Service_Traffic_ADSL_iiNetADSL::$result[$date]))
|
||||
return array();
|
||||
|
||||
// Return the date we asked for
|
||||
return Service_Traffic_ADSL_iiNetADSL::$return[$date];
|
||||
return Service_Traffic_ADSL_iiNetADSL::$result[$date];
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Reference in New Issue
Block a user