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