2010-11-29 22:41:08 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class provides OSB service task capabilities.
|
|
|
|
*
|
|
|
|
* @package OSB
|
|
|
|
* @subpackage Service
|
|
|
|
* @category Controllers/Task
|
|
|
|
* @author Deon George
|
|
|
|
* @copyright (c) 2010 Open Source Billing
|
|
|
|
* @license http://dev.osbill.net/license.html
|
|
|
|
*/
|
2011-08-16 02:27:19 +00:00
|
|
|
class Controller_Task_Service extends Controller_Task {
|
2011-08-04 02:53:33 +00:00
|
|
|
private function _traffic_suppliers($active=FALSE) {
|
|
|
|
$suppliers = ORM::factory('adsl_supplier');
|
|
|
|
|
2011-08-16 02:27:19 +00:00
|
|
|
return $active ? $suppliers->list_active() : $suppliers->find_all();
|
2011-08-04 02:53:33 +00:00
|
|
|
}
|
|
|
|
|
2010-11-29 22:41:08 +00:00
|
|
|
/**
|
|
|
|
* List all services by their default checkout method
|
|
|
|
*/
|
|
|
|
public function action_gettraffic() {
|
2012-02-22 08:15:46 +00:00
|
|
|
foreach ($this->_traffic_suppliers(TRUE) as $aso) {
|
|
|
|
if (CLI::options('verbose'))
|
|
|
|
echo $aso->name."\n";
|
|
|
|
|
2012-01-01 09:41:42 +00:00
|
|
|
$traffic = Service_Traffic_ADSL::instance($aso->name)->update_traffic();
|
2012-02-22 08:15:46 +00:00
|
|
|
}
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Charges for excess traffic usage
|
|
|
|
*/
|
|
|
|
public function action_chargetraffic() {
|
2012-01-01 09:41:42 +00:00
|
|
|
foreach ($this->_traffic_suppliers(TRUE) as $aso)
|
|
|
|
$traffic = Service_Traffic_ADSL::instance($aso->name)->charge_excess_traffic();
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Send alerts to users when they exceed their traffic allowance
|
|
|
|
*/
|
|
|
|
public function action_alerttraffic() {
|
2012-01-01 09:41:42 +00:00
|
|
|
foreach ($this->_traffic_suppliers(TRUE) as $aso)
|
|
|
|
$traffic = Service_Traffic_ADSL::instance($aso->name)->alert_traffic();
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|