Consistent use of return , payment refund handling

This commit is contained in:
Deon George 2013-04-05 23:50:08 +11:00
parent 43dfd88bce
commit 52d9005b64
30 changed files with 255 additions and 210 deletions

View File

@ -105,9 +105,9 @@ class Config extends Kohana_Config {
* security). * security).
*/ */
public static function modules() { public static function modules() {
static $return = array(); static $result = array();
if (! count($return)) { if (! count($result)) {
// We need to know our site here, so that we can subsequently load our enabled modules. // We need to know our site here, so that we can subsequently load our enabled modules.
if (PHP_SAPI === 'cli') { if (PHP_SAPI === 'cli') {
if (! $site = Minion_CLI::options('site')) if (! $site = Minion_CLI::options('site'))
@ -118,10 +118,10 @@ class Config extends Kohana_Config {
} }
foreach (ORM::factory('Module')->list_external() as $mo) foreach (ORM::factory('Module')->list_external() as $mo)
$return[$mo->name] = MODPATH.$mo->name; $result[$mo->name] = MODPATH.$mo->name;
} }
return $return; return $result;
} }
public static function module_config($item) { public static function module_config($item) {

View File

@ -21,14 +21,14 @@ class Controller_Reseller_Account extends Controller_Account {
* @note list_autocomplete() will limit to authorised accounts * @note list_autocomplete() will limit to authorised accounts
*/ */
public function action_ajaxlist() { public function action_ajaxlist() {
$return = array(); $result = array();
if (isset($_REQUEST['term']) AND trim($_REQUEST['term'])) if (isset($_REQUEST['term']) AND trim($_REQUEST['term']))
$return += ORM::factory('Account')->list_autocomplete($_REQUEST['term']); $result += ORM::factory('Account')->list_autocomplete($_REQUEST['term']);
$this->auto_render = FALSE; $this->auto_render = FALSE;
$this->response->headers('Content-Type','application/json'); $this->response->headers('Content-Type','application/json');
$this->response->body(json_encode(array_values($return))); $this->response->body(json_encode(array_values($result)));
} }
/** /**

View File

@ -68,13 +68,13 @@ class Model_Account extends Model_Auth_UserDefault {
* @param int Date (in secs) to only retrieve invoices prior to this date * @param int Date (in secs) to only retrieve invoices prior to this date
*/ */
public function invoices_due($date=NULL) { public function invoices_due($date=NULL) {
$return = array(); $result = array();
foreach ($this->invoices() as $io) foreach ($this->invoices() as $io)
if ((is_null($date) OR $io->date_orig < $date) AND $io->due()) if ((is_null($date) OR $io->date_orig < $date) AND $io->due())
$return[$io->id] = $io; $result[$io->id] = $io;
return $return; return $result;
} }
/** /**
@ -139,7 +139,7 @@ class Model_Account extends Model_Auth_UserDefault {
* Search for accounts matching a term * Search for accounts matching a term
*/ */
public function list_autocomplete($term,$index='id',array $limit=array()) { public function list_autocomplete($term,$index='id',array $limit=array()) {
$return = array(); $result = array();
$ao = Auth::instance()->get_user(); $ao = Auth::instance()->get_user();
$this->clear(); $this->clear();
@ -183,12 +183,12 @@ class Model_Account extends Model_Auth_UserDefault {
$this->and_where('id','IN',$ao->RTM->customers($ao->RTM)); $this->and_where('id','IN',$ao->RTM->customers($ao->RTM));
foreach ($this->find_all() as $o) foreach ($this->find_all() as $o)
$return[$o->$index] = array( $result[$o->$index] = array(
'value'=>$o->$index, 'value'=>$o->$index,
'label'=>sprintf('ACC %s: %s',$o->id,Table::resolve($o,$value)), 'label'=>sprintf('ACC %s: %s',$o->id,Table::resolve($o,$value)),
); );
return $return; return $result;
} }
} }
?> ?>

View File

@ -42,21 +42,21 @@ class Model_Group extends Model_Auth_RoleDefault {
* are also related to this group, in the group heirarchy. * are also related to this group, in the group heirarchy.
*/ */
public function list_childgrps($incParent=FALSE) { public function list_childgrps($incParent=FALSE) {
$return = array(); $result = array();
if (! $this->loaded()) if (! $this->loaded())
return $return; return $result;
foreach (ORM::factory('Group')->where_active()->and_where('parent_id','=',$this)->find_all() as $go) { foreach (ORM::factory('Group')->where_active()->and_where('parent_id','=',$this)->find_all() as $go) {
array_push($return,$go); array_push($result,$go);
$return = array_merge($return,$go->list_childgrps()); $result = array_merge($result,$go->list_childgrps());
} }
if ($incParent) if ($incParent)
array_push($return,$this); array_push($result,$this);
return $return; return $result;
} }
/** /**
@ -64,21 +64,21 @@ class Model_Group extends Model_Auth_RoleDefault {
* are also related to this group, in the group heirarchy. * are also related to this group, in the group heirarchy.
*/ */
public function list_parentgrps($incParent=FALSE) { public function list_parentgrps($incParent=FALSE) {
$return = array(); $result = array();
if (! $this->loaded()) if (! $this->loaded())
return $return; return $result;
foreach (ORM::factory('Group')->where_active()->and_where('id','=',$this->parent_id)->find_all() as $go) { foreach (ORM::factory('Group')->where_active()->and_where('id','=',$this->parent_id)->find_all() as $go) {
array_push($return,$go); array_push($result,$go);
$return = array_merge($return,$go->list_parentgrps()); $result = array_merge($result,$go->list_parentgrps());
} }
if ($incParent) if ($incParent)
array_push($return,$this); array_push($result,$this);
return $return; return $result;
} }
} }
?> ?>

View File

@ -20,15 +20,15 @@ class Model_RTM extends ORM_OSB {
); );
public function customers(Model_RTM $rtmo) { public function customers(Model_RTM $rtmo) {
$return = array(); $result = array();
foreach ($rtmo->agents_direct() as $artmo) foreach ($rtmo->agents_direct() as $artmo)
$return = $return+$rtmo->customers($artmo); $result = $result+$rtmo->customers($artmo);
foreach ($rtmo->customers_direct() as $ao) foreach ($rtmo->customers_direct() as $ao)
array_push($return,$ao); array_push($result,$ao);
return $return; return $result;
} }
public function agents_direct() { public function agents_direct() {

View File

@ -106,7 +106,7 @@ class Period {
// Change our end date to the day before // Change our end date to the day before
$period_end -= 86400; $period_end -= 86400;
$return = array( $result = array(
'start'=>$period_start, 'start'=>$period_start,
'start_time'=>$start, 'start_time'=>$start,
'date'=>$start, 'date'=>$start,
@ -121,9 +121,9 @@ class Period {
if ($df) if ($df)
foreach (array('start','date','end') as $key) foreach (array('start','date','end') as $key)
$return[$key] = Config::date($return[$key]); $result[$key] = Config::date($result[$key]);
return $return; return $result;
} }
} }
?> ?>

View File

@ -123,12 +123,12 @@ class ADSL {
} }
// Return the output sorted // Return the output sorted
$return = array(); $result = array();
foreach (array('base_down_peak','base_down_offpeak','base_up_peak','base_up_offpeak') as $k) foreach (array('base_down_peak','base_down_offpeak','base_up_peak','base_up_offpeak') as $k)
if (isset($a[$k])) if (isset($a[$k]))
$return[$k] = $a[$k]; $result[$k] = $a[$k];
return $return; return $result;
} }
} }
?> ?>

View File

@ -33,13 +33,13 @@ class Model_Adsl_Supplier extends ORM_OSB {
* Return a list of plans that we provide by this supplier * Return a list of plans that we provide by this supplier
*/ */
public function adsl_plans($active=TRUE) { public function adsl_plans($active=TRUE) {
$return = array(); $result = array();
foreach ($this->plans($active)->find_all() as $po) foreach ($this->plans($active)->find_all() as $po)
foreach ($po->adsl_plan->find_all() as $apo) foreach ($po->adsl_plan->find_all() as $apo)
$return[$apo->id] = $apo; $result[$apo->id] = $apo;
return $return; return $result;
} }
/** /**

View File

@ -111,23 +111,23 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
* Calculate the total traffic used in a month * Calculate the total traffic used in a month
*/ */
private function get_traffic_data_month($period=NULL,$cache=NULL) { 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 ($this->get_traffic_data_daily($period,TRUE,$cache) as $tdata)
foreach ($tdata as $k => $v) foreach ($tdata as $k => $v)
if (isset($return[$k])) if (isset($result[$k]))
$return[$k] += $v; $result[$k] += $v;
else else
$return[$k] = $v; $result[$k] = $v;
return $return; return $result;
} }
/** /**
* Return an array of the data used in a month by day * Return an array of the data used in a month by day
*/ */
public function get_traffic_data_daily($period=NULL,$bydate=FALSE,$cache=NULL) { public function get_traffic_data_daily($period=NULL,$bydate=FALSE,$cache=NULL) {
$return = array(); $result = array();
// @temp - caching is broken? // @temp - caching is broken?
$cache=0; $cache=0;
@ -144,20 +144,20 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
$day = date('d',strtotime($to->date)); $day = date('d',strtotime($to->date));
if ($bydate) if ($bydate)
$return[$day] = $to->traffic($this->service->product->plugin()); $result[$day] = $to->traffic($this->service->product->plugin());
else else
foreach ($to->traffic($this->service->product->plugin()) as $k => $v) 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 * Return an array of the data used in a year by month
*/ */
public function get_traffic_data_monthly($period=NULL,$bydate=FALSE) { public function get_traffic_data_monthly($period=NULL,$bydate=FALSE) {
$return = array(); $result = array();
if (is_null($period)) if (is_null($period))
$period = strtotime('yesterday'); $period = strtotime('yesterday');
@ -177,12 +177,12 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
foreach ($t->find_all() as $to) foreach ($t->find_all() as $to)
if ($bydate) if ($bydate)
$return[$to->month] = $to->traffic($this->service->product->plugin()); $result[$to->month] = $to->traffic($this->service->product->plugin());
else else
foreach ($to->traffic($this->service->product->plugin()) as $k => $v) 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) { 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) { public function traffic_lastmonth_exceed($all=FALSE,$date=NULL) {
$return = array(); $result = array();
if (is_null($date)) if (is_null($date))
$date = strtotime('last month')-86400; $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) { foreach ($this->traffic_month($date,FALSE,0) as $k => $v) {
// We shouldnt need to eval for nulls, since the traffic calc does that // We shouldnt need to eval for nulls, since the traffic calc does that
if ($all OR ($v > $this->service->product->plugin()->$k)) { if ($all OR ($v > $this->service->product->plugin()->$k)) {
$return[$k]['allowance'] = $this->service->product->plugin()->$k; $result[$k]['allowance'] = $this->service->product->plugin()->$k;
$return[$k]['used'] = $v; $result[$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; $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;
$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; $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;
$return[$k]['rate'] = $this->service->product->plugin()->{ADSL::map($k)}; $result[$k]['rate'] = $this->service->product->plugin()->{ADSL::map($k)};
$return[$k]['charge'] = ceil(($return[$k]['excess'])/1000)*$return[$k]['rate']; $result[$k]['charge'] = ceil(($result[$k]['excess'])/1000)*$result[$k]['rate'];
} }
} }
return $return; return $result;
} }
public function template_variables($array) { public function template_variables($array) {
@ -228,7 +228,7 @@ class Model_Service_Plugin_Adsl extends Model_Service_Plugin {
'cumulative_base_down_offpeak'=>'Total OffPeak', 'cumulative_base_down_offpeak'=>'Total OffPeak',
); );
$return = array(); $result = array();
if ($this->service->product->prod_plugin_file != 'ADSL') 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)); 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 = ''; $value = '';
} }
$return[$item] = $value; $result[$item] = $value;
} }
return $return; return $result;
} }
/** /**

View File

@ -17,7 +17,7 @@ class Service_Traffic_Adsl_Exetelhspa extends Service_Traffic_Adsl {
private $login_pass_field = 'password'; private $login_pass_field = 'password';
private $date_field = 'date'; private $date_field = 'date';
static $return = array(); static $result = array();
/** /**
* Get the data for Exetel hspa services * Get the data for Exetel hspa services
@ -29,8 +29,8 @@ class Service_Traffic_Adsl_Exetelhspa extends Service_Traffic_Adsl {
$this->fetchresult = TRUE; $this->fetchresult = TRUE;
// If we have already collected the date data, return it. // If we have already collected the date data, return it.
if (! empty(Service_Traffic_Adsl_Exetelhspa::$return[$date])) if (! empty(Service_Traffic_Adsl_Exetelhspa::$result[$date]))
return Service_Traffic_Adsl_Exetelhspa::$return[$date]; return Service_Traffic_Adsl_Exetelhspa::$result[$date];
include_once 'includes/kohana/modules/simplehtmldom/classes/simple_html_dom.php'; 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. // Reformat the data into date order.
foreach ($update as $service => $sdata) foreach ($update as $service => $sdata)
foreach ($sdata as $sdate => $details) 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 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 array();
// Return the date we asked for // Return the date we asked for
return Service_Traffic_Adsl_Exetelhspa::$return[$date]; return Service_Traffic_Adsl_Exetelhspa::$result[$date];
} }
} }
?> ?>

View File

@ -17,7 +17,7 @@ class Service_Traffic_Adsl_Exetelpe extends Service_Traffic_Adsl {
private $login_pass_field = 'password'; private $login_pass_field = 'password';
private $date_field = 'date'; private $date_field = 'date';
static $return = array(); static $result = array();
/** /**
* Get the data for Exetel PE services * Get the data for Exetel PE services
@ -29,8 +29,8 @@ class Service_Traffic_Adsl_Exetelpe extends Service_Traffic_Adsl {
$this->fetchresult = TRUE; $this->fetchresult = TRUE;
// If we have already collected the date data, return it. // If we have already collected the date data, return it.
if (! empty(Service_Traffic_Adsl_Exetelpe::$return[$date])) if (! empty(Service_Traffic_Adsl_Exetelpe::$result[$date]))
return Service_Traffic_Adsl_Exetelpe::$return[$date]; return Service_Traffic_Adsl_Exetelpe::$result[$date];
include_once 'includes/kohana/modules/simplehtmldom/classes/simple_html_dom.php'; 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. // Reformat the data into date order.
foreach ($update as $service => $sdata) foreach ($update as $service => $sdata)
foreach ($sdata as $sdate => $details) 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 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 array();
// Return the date we asked for // Return the date we asked for
return Service_Traffic_Adsl_Exetelpe::$return[$date]; return Service_Traffic_Adsl_Exetelpe::$result[$date];
} }
} }
?> ?>

View File

@ -15,7 +15,7 @@ class Service_Traffic_Adsl_Exetelvisp extends Service_Traffic_Adsl {
private $date_field = 'date'; private $date_field = 'date';
protected function getdata($date) { protected function getdata($date) {
$return = array(); $result = array();
// Assume we have a bad fetch, unless otherwise specified. // Assume we have a bad fetch, unless otherwise specified.
$this->fetchresult = FALSE; $this->fetchresult = FALSE;
@ -58,10 +58,10 @@ class Service_Traffic_Adsl_Exetelvisp extends Service_Traffic_Adsl {
$attrs['up_offpeak'] = $valuesarray[4]/100; $attrs['up_offpeak'] = $valuesarray[4]/100;
$attrs['down_offpeak'] = $valuesarray[5]/100; $attrs['down_offpeak'] = $valuesarray[5]/100;
array_push($return,$attrs); array_push($result,$attrs);
} }
return $return; return $result;
} }
} }
?> ?>

View File

@ -18,7 +18,7 @@ class Service_Traffic_ADSL_PeopleAgent extends Service_Traffic_ADSL {
// Assume we have a bad fetch, unless otherwise specified. // Assume we have a bad fetch, unless otherwise specified.
$this->fetchresult = FALSE; $this->fetchresult = FALSE;
$return = array(); $result = array();
$url_suffix = sprintf('traffic_V34_%s.xml',date('Ymd',strtotime($date))); $url_suffix = sprintf('traffic_V34_%s.xml',date('Ymd',strtotime($date)));
try { 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;
} }
} }
?> ?>

View File

@ -17,7 +17,7 @@ class Service_Traffic_ADSL_iiNetADSL extends Service_Traffic_ADSL {
private $login_pass_field = 'password'; private $login_pass_field = 'password';
private $date_field = 'period'; private $date_field = 'period';
static $return = array(); static $result = array();
// The fields in the XML which are translated into database columns // The fields in the XML which are translated into database columns
private $fields = array( private $fields = array(
@ -37,8 +37,8 @@ class Service_Traffic_ADSL_iiNetADSL extends Service_Traffic_ADSL {
$this->fetchresult = FALSE; $this->fetchresult = FALSE;
// If we have already collected the date data, return it. // If we have already collected the date data, return it.
if (! empty(Service_Traffic_ADSL_iiNetADSL::$return[$date])) if (! empty(Service_Traffic_ADSL_iiNetADSL::$result[$date]))
return Service_Traffic_ADSL_iiNetADSL::$return[$date]; return Service_Traffic_ADSL_iiNetADSL::$result[$date];
// Find our services that need to be collected this way. // Find our services that need to be collected this way.
$update = array(); $update = array();
@ -77,7 +77,7 @@ class Service_Traffic_ADSL_iiNetADSL extends Service_Traffic_ADSL {
file_put_contents($debug_file,$data); 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) { foreach (XML::factory(NULL,'ii_feed',$data)->volume_usage->volume_usage->get('day_hour') as $day_hour) {
$attrs = array(); $attrs = array();
@ -100,9 +100,9 @@ class Service_Traffic_ADSL_iiNetADSL extends Service_Traffic_ADSL {
$attrs[$this->fields[$fields['type']]] += $usage->value()/1000/1000; $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::$result[$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::$result[$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]['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 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 array();
// Return the date we asked for // Return the date we asked for
return Service_Traffic_ADSL_iiNetADSL::$return[$date]; return Service_Traffic_ADSL_iiNetADSL::$result[$date];
} }
} }
?> ?>

View File

@ -97,14 +97,14 @@ class Email_Template {
} }
public function variables() { public function variables() {
$return = array(); $result = array();
foreach ($this->components as $v) foreach ($this->components as $v)
foreach ($this->etto->variables($v) as $x => $y) foreach ($this->etto->variables($v) as $x => $y)
if (! in_array($y,$return)) if (! in_array($y,$result))
array_push($return,$y); array_push($result,$y);
return $return; return $result;
} }
public function send(array $admin=array()) { public function send(array $admin=array()) {

View File

@ -43,9 +43,9 @@ class GoogleChart_ComboChart extends GoogleChart {
} }
public function json() { public function json() {
$return = array(); $result = array();
$return['cols'][] = array( $result['cols'][] = array(
'id'=>'date', 'id'=>'date',
'label'=>'date', 'label'=>'date',
'type'=>'string', 'type'=>'string',
@ -53,7 +53,7 @@ class GoogleChart_ComboChart extends GoogleChart {
// Columns // Columns
foreach (array_keys($this->_axis) as $l) { foreach (array_keys($this->_axis) as $l) {
$return['cols'][] = array( $result['cols'][] = array(
'id'=>$l, 'id'=>$l,
'label'=>$l, 'label'=>$l,
'type'=>'number', 'type'=>'number',
@ -69,7 +69,7 @@ class GoogleChart_ComboChart extends GoogleChart {
foreach ($this->_axis as $l => $axis) foreach ($this->_axis as $l => $axis)
array_push($data,array('v'=>isset($v[$l]) ? $v[$l] : 0)); array_push($data,array('v'=>isset($v[$l]) ? $v[$l] : 0));
$return['rows'][] = array('c'=>$data); $result['rows'][] = array('c'=>$data);
} }
$options = array( $options = array(
@ -81,7 +81,7 @@ class GoogleChart_ComboChart extends GoogleChart {
'series' => $this->series(), 'series' => $this->series(),
); );
return json_encode(array('data'=>$return,'options'=>$options)); return json_encode(array('data'=>$result,'options'=>$options));
} }
public function render() { public function render() {
@ -149,7 +149,7 @@ function drawChart_".$this->_divname."() {
} }
private function series() { private function series() {
$return = array(); $result = array();
$c = $this->seriescolors(); $c = $this->seriescolors();
$j = count($c); $j = count($c);
@ -157,14 +157,14 @@ function drawChart_".$this->_divname."() {
foreach ($this->_axis as $l => $axis) { foreach ($this->_axis as $l => $axis) {
// @todo This shouldnt be hard coded // @todo This shouldnt be hard coded
if ($axis == 'yl') if ($axis == 'yl')
array_push($return,array('type'=>'bar','color'=>$c[$i%$j],'targetAxisIndex'=>0)); array_push($result,array('type'=>'bar','color'=>$c[$i%$j],'targetAxisIndex'=>0));
else else
array_push($return,array('type'=>'line','color'=>$c[$i%$j],'targetAxisIndex'=>1)); array_push($result,array('type'=>'line','color'=>$c[$i%$j],'targetAxisIndex'=>1));
$i++; $i++;
} }
return $return; return $result;
} }
} }
?> ?>

View File

@ -77,51 +77,51 @@ class GoogleChart_Legacy extends GoogleChart {
* Calculate our maximum for each side of the chart * Calculate our maximum for each side of the chart
*/ */
private function maxes() { private function maxes() {
$return = array(); $result = array();
foreach ($this->_axis as $l => $axis) { foreach ($this->_axis as $l => $axis) {
if (! isset($return[$axis])) if (! isset($result[$axis]))
$return[$axis] = 0; $result[$axis] = 0;
$return[$axis] += $this->_max[$l]*1.1; // @todo This scaleup should be configurable $result[$axis] += $this->_max[$l]*1.1; // @todo This scaleup should be configurable
} }
return $return; return $result;
} }
/** CHART FIELDS **/ /** CHART FIELDS **/
private function chd() { private function chd() {
$return = array(); $result = array();
$maxes = $this->maxes(); $maxes = $this->maxes();
// Perform our encoding // Perform our encoding
foreach ($this->_axis as $l => $axis) foreach ($this->_axis as $l => $axis)
array_push($return,$this->encode($this->_data[$l],$maxes[$axis])); array_push($result,$this->encode($this->_data[$l],$maxes[$axis]));
$prefix = (count($maxes) > 1) ? sprintf('%s:',$this->axiscount('yl')) : ':'; $prefix = (count($maxes) > 1) ? sprintf('%s:',$this->axiscount('yl')) : ':';
// If encoding is text, we need to separate the series with a | // If encoding is text, we need to separate the series with a |
return ($this->_encodetype == 't') ? $prefix.implode('|',$return) : $prefix.implode(',',$return); return ($this->_encodetype == 't') ? $prefix.implode('|',$result) : $prefix.implode(',',$result);
} }
private function chm() { private function chm() {
$return = array(); $result = array();
$sc = $this->seriescolors(); $sc = $this->seriescolors();
$i = 0; $i = 0;
foreach ($this->_axis as $l => $axis) { foreach ($this->_axis as $l => $axis) {
if ($axis == 'yr') if ($axis == 'yr')
array_push($return,sprintf('%s,%s,%s,%s,%s,%s','D',$sc[$i],$i,0,2,2));// @todo 'D,0,2,2' May need to be configurable array_push($result,sprintf('%s,%s,%s,%s,%s,%s','D',$sc[$i],$i,0,2,2));// @todo 'D,0,2,2' May need to be configurable
$i++; $i++;
} }
return count($return) ? implode('|',$return) : ''; return count($result) ? implode('|',$result) : '';
} }
private function chxl() { private function chxl() {
$return = array(); $result = array();
// @todo This should be performed better - it may be a wrong assumption that all keys in the series have data. // @todo This should be performed better - it may be a wrong assumption that all keys in the series have data.
foreach ($this->_data as $series => $data) foreach ($this->_data as $series => $data)
@ -130,13 +130,13 @@ class GoogleChart_Legacy extends GoogleChart {
} }
private function chxr() { private function chxr() {
$return = array(); $result = array();
$i = 1; $i = 1;
foreach ($this->maxes() as $key => $value) foreach ($this->maxes() as $key => $value)
array_push($return,sprintf('%s,0,%s,0',$i++,$value)); array_push($result,sprintf('%s,0,%s,0',$i++,$value));
return implode('|',$return); return implode('|',$result);
} }
public function json() {} public function json() {}

View File

@ -119,7 +119,7 @@ class Model_Invoice extends ORM_OSB implements Cartable {
} }
/** /**
* Return a list of invoice items for this payment. * Return a list of invoice items for this invoice.
* @param type [CHARGE|CREDIT|ALL] * @param type [CHARGE|CREDIT|ALL]
* @see invoice_items * @see invoice_items
*/ */
@ -128,6 +128,7 @@ class Model_Invoice extends ORM_OSB implements Cartable {
foreach ($this->invoice_items as $ito) { foreach ($this->invoice_items as $ito) {
$return = FALSE; $return = FALSE;
switch ($type) { switch ($type) {
case 'CHARGE': case 'CHARGE':
if ($ito->quantity > 0) if ($ito->quantity > 0)
@ -143,7 +144,6 @@ class Model_Invoice extends ORM_OSB implements Cartable {
default: default:
$return = TRUE; $return = TRUE;
break; break;
} }
if ($return) if ($return)
@ -530,7 +530,7 @@ class Model_Invoice extends ORM_OSB implements Cartable {
* Search for invoices matching a term * Search for invoices matching a term
*/ */
public function list_autocomplete($term,$index='id') { public function list_autocomplete($term,$index='id') {
$return = array(); $result = array();
if (is_numeric($term)) { if (is_numeric($term)) {
$this->clear(); $this->clear();
@ -541,13 +541,13 @@ class Model_Invoice extends ORM_OSB implements Cartable {
// @todo This should limit the results so that users dont see other users services. // @todo This should limit the results so that users dont see other users services.
foreach ($this->find_all() as $o) foreach ($this->find_all() as $o)
$return[$o->$index] = array( $result[$o->$index] = array(
'value'=>$o->$index, 'value'=>$o->$index,
'label'=>sprintf('INV %s: %s',$o->id,Table::resolve($o,$value)), 'label'=>sprintf('INV %s: %s',$o->id,Table::resolve($o,$value)),
); );
} }
return $return; return $result;
} }
private function _list_due() { private function _list_due() {
@ -589,19 +589,19 @@ class Model_Invoice extends ORM_OSB implements Cartable {
* Return a list of invoices that are over their due date with/without auto billing * Return a list of invoices that are over their due date with/without auto billing
*/ */
public function list_overdue_billing($time=NULL,$billing=FALSE) { public function list_overdue_billing($time=NULL,$billing=FALSE) {
$return = array(); $result = array();
foreach ($this->list_overdue($time) as $io) { foreach ($this->list_overdue($time) as $io) {
$i = FALSE; $i = FALSE;
foreach ($io->service->find_all() as $so) foreach ($io->service->find_all() as $so)
if (($billing AND $so->account_billing_id) OR (! $billing AND ! $so->account_billing_id)) { if (($billing AND $so->account_billing_id) OR (! $billing AND ! $so->account_billing_id)) {
array_push($return,$io); array_push($result,$io);
break; break;
} }
} }
return $return; return $result;
} }
/** /**

View File

@ -20,16 +20,16 @@ class Controller_Admin_Payment extends Controller_TemplateDefault_Admin {
); );
public function action_ajaxlist() { public function action_ajaxlist() {
$return = array(); $result = array();
if (isset($_REQUEST['term']) AND trim($_REQUEST['term'])) { if (isset($_REQUEST['term']) AND trim($_REQUEST['term'])) {
$return += ORM::factory('Account')->list_autocomplete($_REQUEST['term']); $result += ORM::factory('Account')->list_autocomplete($_REQUEST['term']);
$return += ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'account_id'); $result += ORM::factory('Invoice')->list_autocomplete($_REQUEST['term'],'account_id');
} }
$this->auto_render = FALSE; $this->auto_render = FALSE;
$this->response->headers('Content-Type','application/json'); $this->response->headers('Content-Type','application/json');
$this->response->body(json_encode(array_values($return))); $this->response->body(json_encode(array_values($result)));
} }
public function action_autoitemlist() { public function action_autoitemlist() {

View File

@ -46,29 +46,39 @@ class Model_Payment extends ORM_OSB {
} }
/** /**
* Return a list of invoice items for this payment. * Add an item to this payment
*
* @param $inv number, to allocate payment to an invoice
*/ */
public function items() { public function add_item($invnum) {
return $this->payment_items; if ($this->loaded() and ! $this->payment_items)
} throw new Kohana_Exception('Need to load payment_items?');
/**
* Add an item to an invoice
*/
public function add_item($iid) {
// Find our id, if it exists // Find our id, if it exists
foreach ($this->payment_items as $pio) foreach ($this->payment_items as $pio)
if ($pio->invoice_id == $iid) if ($pio->invoice_id == $invnum)
return $pio; return $pio;
// New Item // New Item
$c = count($this->payment_items); $c = count($this->payment_items);
$this->payment_items[$c] = ORM::factory('Payment_Item'); $this->payment_items[$c] = ORM::factory('Payment_Item');
$this->payment_items[$c]->invoice_id = $iid; $this->payment_items[$c]->invoice_id = $invnum;
return $this->payment_items[$c]; return $this->payment_items[$c];
} }
/**
* Calculate the remaining balance available for this payment
*/
public function balance($format=FALSE) {
$result = $this->total();
foreach ($this->items('ALLOC') as $pio)
$result -= $pio->alloc_amt;
return $format ? Currency::display($result) : $result;
}
/** /**
* Find all items that are exportable. * Find all items that are exportable.
* *
@ -80,34 +90,69 @@ class Model_Payment extends ORM_OSB {
->find_all(); ->find_all();
} }
/**
* Calculate the remaining balance available for this payment
*/
public function balance($format=FALSE) {
$t = 0;
foreach ($this->payment_item->find_all() as $pio)
$t += $pio->alloc_amt;
return $format ? Currency::display($this->total_amt-$t) : $this->total_amt-$t;
}
/** /**
* Return a list of invoices that this payment is applied to * Return a list of invoices that this payment is applied to
*/ */
public function invoices() { public function invoices() {
$invoices = array(); $result = array();
foreach ($this->payment_item->find_all() as $pio) foreach ($this->payment_items as $pio)
array_push($invoices,$pio->invoice); array_push($result,$pio->invoice);
return $invoices; return $result;
} }
public function invoicelist() { public function invoicelist() {
return join(',',$this->invoices()); return join(',',$this->invoices());
} }
/**
* Return a list of payment items for this payment.
* @param type [ALLOC|CREDIT|ALL]
* @see payment_items
*/
public function items($type='ALL') {
$result = array();
foreach ($this->payment_items as $pio) {
$return = FALSE;
switch ($type) {
case 'ALLOC':
if ($pio->alloc_amt > 0)
$return = TRUE;
break;
case 'CREDIT':
if ($pio->alloc_amt < 0)
$return = TRUE;
break;
case 'ALL':
default:
$return = TRUE;
break;
}
if ($return)
array_push($result,$pio);
}
return $result;
}
/**
* Show the total amount of a payment.
*/
public function total($format=FALSE) {
$result = $this->total_amt;
foreach ($this->items('CREDIT') as $pio)
$result += $pio->alloc_amt;
return $format ? Currency::display($result) : Currency::round($result);
}
/** LIST FUNCTIONS **/ /** LIST FUNCTIONS **/
public function list_unapplied() { public function list_unapplied() {

View File

@ -11,15 +11,15 @@
*/ */
class Payment_Bulk_Ezypay { class Payment_Bulk_Ezypay {
public function form() { public function form() {
$return = ''; $result = '';
$return .= Form::open(NULL,array('enctype'=>'multipart/form-data')); $result .= Form::open(NULL,array('enctype'=>'multipart/form-data'));
$return .= Form::hidden('payer',$_POST['payer']); $result .= Form::hidden('payer',$_POST['payer']);
$return .= View::factory('payment/admin/addbulk/ezypay'); $result .= View::factory('payment/admin/addbulk/ezypay');
$return .= Form::submit('submit','submit',array('class'=>'form_button')); $result .= Form::submit('submit','submit',array('class'=>'form_button'));
$return .= Form::close(); $result .= Form::close();
return $return; return $result;
} }
public function process() { public function process() {
@ -83,8 +83,8 @@ class Payment_Bulk_Ezypay {
$payments[$array[3]]->checkout_plugin_id = 4; $payments[$array[3]]->checkout_plugin_id = 4;
} }
$return = ''; $result = '';
$return .= View::Factory('payment/admin/addbulk/ezypay/head'); $result .= View::Factory('payment/admin/addbulk/ezypay/head');
$total = $fees = 0; $total = $fees = 0;
foreach ($payments as $po) { foreach ($payments as $po) {
@ -93,15 +93,15 @@ class Payment_Bulk_Ezypay {
$total += $po->total_amt; $total += $po->total_amt;
$fees += $po->fees_amt; $fees += $po->fees_amt;
$return .= View::Factory('payment/admin/addbulk/ezypay/body') $result .= View::Factory('payment/admin/addbulk/ezypay/body')
->set('o',$po); ->set('o',$po);
} }
$return .= View::Factory('payment/admin/addbulk/ezypay/foot') $result .= View::Factory('payment/admin/addbulk/ezypay/foot')
->set('total',$total) ->set('total',$total)
->set('fees',$fees);; ->set('fees',$fees);;
return $return; return $result;
} }
} }
?> ?>

View File

@ -16,7 +16,7 @@
</tr> </tr>
<tr> <tr>
<td>Amount</td> <td>Amount</td>
<td><?php echo Form::input('total_amt',$po->total_amt); ?></td> <td><?php echo Form::input('total_amt',$po->total()); ?></td>
</tr> </tr>
<tr> <tr>
<td>Fees</td> <td>Fees</td>

View File

@ -34,13 +34,13 @@ class Model_Product_Category extends ORM_OSB {
* @todo Consider if we should cache this * @todo Consider if we should cache this
*/ */
public function products() { public function products() {
$return = array(); $result = array();
foreach (ORM::factory('Product')->where_active()->find_all() as $po) foreach (ORM::factory('Product')->where_active()->find_all() as $po)
if (in_array($this->id,$po->categories())) if (in_array($this->id,$po->categories()))
array_push($return,$po); array_push($result,$po);
return $return; return $result;
} }
public function list_bylistgroup($cat) { public function list_bylistgroup($cat) {

View File

@ -33,20 +33,20 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
); );
public function action_ajaxlist() { public function action_ajaxlist() {
$return = array(); $result = array();
$return += ORM::factory('Service')->list_autocomplete( $result += ORM::factory('Service')->list_autocomplete(
isset($_REQUEST['term']) ? $_REQUEST['term'] : '', isset($_REQUEST['term']) ? $_REQUEST['term'] : '',
'id', 'id',
isset($_REQUEST['aid']) ? array(array('account_id','=',$_REQUEST['aid'])) : array()); isset($_REQUEST['aid']) ? array(array('account_id','=',$_REQUEST['aid'])) : array());
$this->auto_render = FALSE; $this->auto_render = FALSE;
$this->response->headers('Content-Type','application/json'); $this->response->headers('Content-Type','application/json');
$this->response->body(json_encode(array_values($return))); $this->response->body(json_encode(array_values($result)));
} }
public function action_ajaxjson_traffic() { public function action_ajaxjson_traffic() {
$return = array(); $result = array();
$svs = ORM::factory('Service')->list_bylistgroup('ADSL'); $svs = ORM::factory('Service')->list_bylistgroup('ADSL');
$data = $this->consoltraffic($svs,time()); $data = $this->consoltraffic($svs,time());
@ -610,7 +610,7 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
return; return;
$start = $end = FALSE; $start = $end = FALSE;
$return = array(); $result = array();
foreach (preg_split("/\n/",$data) as $line) { foreach (preg_split("/\n/",$data) as $line) {
// Items start after "Item ID" // Items start after "Item ID"
if (! $start && preg_match('/^Item ID,/',$line)) { if (! $start && preg_match('/^Item ID,/',$line)) {
@ -638,18 +638,18 @@ class Controller_Admin_Service extends Controller_TemplateDefault_Admin {
// If the description says Monthly Charge, we know its the monthly fee. // If the description says Monthly Charge, we know its the monthly fee.
if (preg_match('/^Monthly Charge/',$description)) if (preg_match('/^Monthly Charge/',$description))
$return[$service]['cost'] = preg_replace('/\$/','',$total); $result[$service]['cost'] = preg_replace('/\$/','',$total);
// If the description says VISP credit, we know this is commission. // If the description says VISP credit, we know this is commission.
elseif (preg_match('/^VISP Credit/',$description)) elseif (preg_match('/^VISP Credit/',$description))
$return[$service]['credit'] = preg_replace('/\$/','',$total); $result[$service]['credit'] = preg_replace('/\$/','',$total);
// If the description says Excess, we know this is excess charges. // If the description says Excess, we know this is excess charges.
elseif (preg_match('/^Excess usage/',$description)) elseif (preg_match('/^Excess usage/',$description))
$return[$service]['excess'] = preg_replace('/\$/','',$total); $result[$service]['excess'] = preg_replace('/\$/','',$total);
else else
$return[$service]['info'] = $line; $result[$service]['info'] = $line;
} }
return $return; return $result;
} }
/** /**

View File

@ -182,7 +182,7 @@ class Model_Service extends ORM_OSB {
* Search for services matching a term * Search for services matching a term
*/ */
public function list_autocomplete($term,$index='id',array $limit=array()) { public function list_autocomplete($term,$index='id',array $limit=array()) {
$return = array(); $result = array();
$this->clear(); $this->clear();
$this->where_active(); $this->where_active();
@ -200,12 +200,12 @@ class Model_Service extends ORM_OSB {
} }
foreach ($this->find_all() as $o) foreach ($this->find_all() as $o)
$return[$o->$index] = array( $result[$o->$index] = array(
'value'=>$o->$index, 'value'=>$o->$index,
'label'=>sprintf('SVC %s: %s',$o->id,Table::resolve($o,$value)), 'label'=>sprintf('SVC %s: %s',$o->id,Table::resolve($o,$value)),
); );
return $return; return $result;
} }
public function list_bylistgroup($cat) { public function list_bylistgroup($cat) {
@ -237,13 +237,13 @@ class Model_Service extends ORM_OSB {
* List invoices for this service * List invoices for this service
*/ */
public function list_invoices($due=FALSE) { public function list_invoices($due=FALSE) {
$return = array(); $result = array();
foreach ($this->invoice->find_all() as $io) foreach ($this->invoice->find_all() as $io)
if (! $due OR $io->due()) if (! $due OR $io->due())
array_push($return,$io); array_push($result,$io);
return $return; return $result;
} }
/** /**

View File

@ -119,16 +119,16 @@ class Model_Service_Plugin_Ssl extends Model_Service_Plugin {
} }
public function cacerts() { public function cacerts() {
$return = array(); $result = array();
$x = $this->ssl_ca_id; $x = $this->ssl_ca_id;
while ($x) { while ($x) {
$sco = ORM::factory('SSL_CA',$x); $sco = ORM::factory('SSL_CA',$x);
array_push($return,$sco->sign_cert); array_push($result,$sco->sign_cert);
$x = $sco->parent_ssl_ca_id; $x = $sco->parent_ssl_ca_id;
} }
return $return; return $result;
} }
public function renew() { public function renew() {

View File

@ -50,7 +50,7 @@ class SSL {
* @param $key Return just that index * @param $key Return just that index
*/ */
private function _aki($key=NULL) { private function _aki($key=NULL) {
$return = array(); $result = array();
$aki = $this->_extensions('authorityKeyIdentifier'); $aki = $this->_extensions('authorityKeyIdentifier');
if (! $aki) if (! $aki)
@ -62,11 +62,11 @@ class SSL {
if (strstr($x,':')) { if (strstr($x,':')) {
list($a,$b) = explode(':',$x,2); list($a,$b) = explode(':',$x,2);
$return[strtolower($a)] = $b; $result[strtolower($a)] = $b;
} }
} }
return is_null($key) ? $return : (isset($return[$key]) ? $return[$key] : ''); return is_null($key) ? $result : (isset($result[$key]) ? $result[$key] : '');
} }
private function _bc() { private function _bc() {
@ -92,26 +92,26 @@ class SSL {
* @param $key Return just that index * @param $key Return just that index
*/ */
private function _extensions($key=NULL) { private function _extensions($key=NULL) {
$return = $this->_details('extensions'); $result = $this->_details('extensions');
return is_null($key) ? $return : (isset($return[$key]) ? $return[$key] : ''); return is_null($key) ? $result : (isset($result[$key]) ? $result[$key] : '');
} }
/** /**
* Render a DN array as a string * Render a DN array as a string
*/ */
private function _dn(array $array) { private function _dn(array $array) {
$return = ''; $result = '';
$i = 0; $i = 0;
foreach ($array as $k=>$v) { foreach ($array as $k=>$v) {
if ($i++) if ($i++)
$return .= ','; $result .= ',';
$return .= sprintf('%s=%s',$k,$v); $result .= sprintf('%s=%s',$k,$v);
} }
return $return; return $result;
} }
public function get_aki_dirname() { public function get_aki_dirname() {

View File

@ -22,7 +22,7 @@ class Controller_Admin_Statement extends Controller_TemplateDefault_Admin {
$ta = array(); $ta = array();
foreach ($ao->payment->find_all() as $o) { foreach ($ao->payment->find_all() as $o) {
if (round($o->total_amt-$o->refund_status,0) == 0) if ( ! $o->total())
continue; continue;
$i = count($ta); $i = count($ta);
@ -49,7 +49,7 @@ class Controller_Admin_Statement extends Controller_TemplateDefault_Admin {
if (isset($v['invoice'])) if (isset($v['invoice']))
$t += $v['invoice']->total(); $t += $v['invoice']->total();
elseif (isset($v['payment'])) elseif (isset($v['payment']))
$t -= $v['payment']->total_amt-$v['payment']->refund_status; $t -= $v['payment']->total();
$ta[$k]['total'] = $t; $ta[$k]['total'] = $t;
$a = $v['time']; $a = $v['time'];

View File

@ -8,7 +8,7 @@
<td><?php echo $o['payment']->display('date_payment'); ?></td> <td><?php echo $o['payment']->display('date_payment'); ?></td>
<td>Payment</td> <td>Payment</td>
<td><?php printf('%s - %s',$o['payment']->id,$o['payment']->checkout->display('name')); ?></td> <td><?php printf('%s - %s',$o['payment']->id,$o['payment']->checkout->display('name')); ?></td>
<td class="right"><?php echo $o['payment']->display('total_amt')-$o['payment']->refund_status; ?></td> <td class="right"><?php echo $o['payment']->total(TRUE); ?></td>
<?php } ?> <?php } ?>
<td class="right"><?php echo Currency::display($o['total']); ?></td> <td class="right"><?php echo Currency::display($o['total']); ?></td>
</tr> </tr>

View File

@ -81,27 +81,27 @@ class Model_Task extends ORM_OSB {
/** LIST FUNCTIONS **/ /** LIST FUNCTIONS **/
public function list_active() { public function list_active() {
$return = array(); $result = array();
foreach ($this->_where_active()->find_all() as $to) { foreach ($this->_where_active()->find_all() as $to) {
$ct = sprintf('%s %s %s %s %s',$to->int_min,$to->int_hour,$to->int_month_day,$to->int_month,$to->int_week_day); $ct = sprintf('%s %s %s %s %s',$to->int_min,$to->int_hour,$to->int_month_day,$to->int_month,$to->int_week_day);
$c = new Cron($ct,$to->command); $c = new Cron($ct,$to->command);
$return[$to->id]['task'] = $to; $result[$to->id]['task'] = $to;
$return[$to->id]['next'] = $c->next($to->date_run); $result[$to->id]['next'] = $c->next($to->date_run);
} }
return $return; return $result;
} }
public function list_next() { public function list_next() {
$return = array(); $result = array();
foreach ($this->list_active() as $v) foreach ($this->list_active() as $v)
if ((! $return OR $v['next']<$return['next']) AND ! $v['task']->running) if ((! $result OR $v['next']<$result['next']) AND ! $v['task']->running)
$return = $v; $result = $v;
return array($return['task']->id=>$return); return array($result['task']->id=>$result);
} }
} }
?> ?>