This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
khosb/modules/adsl/classes/Task/Adsl/Trafficalert.php

46 lines
1.2 KiB
PHP
Raw Normal View History

2013-07-06 14:00:10 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* Alert ADSL Traffic to Customers
*
* @package ADSL
* @category Tasks
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
2013-11-15 05:25:45 +00:00
class Task_Adsl_Trafficalert extends Minion_Task {
protected $_options = array(
'verbose'=>FALSE,
);
2013-07-06 14:00:10 +00:00
protected function _execute(array $params) {
$date = strtotime('first day of last month');
2013-11-15 05:25:45 +00:00
$c = array();
// @todo Pick up services that are no longer active, but were inactive < 30 days ago.
foreach (ORM::factory('Service')->list_byplugin('ADSL') as $so) {
if (Minion_CLI::options('verbose'))
2013-11-15 05:25:45 +00:00
echo $so->service_name()."\n";
if (! $data=$so->plugin()->traffic_report())
continue;
$et = Email_Template::instance('adsl_traffic_notice');
2013-07-06 14:00:10 +00:00
2013-11-15 05:25:45 +00:00
// Get our variable data
$et->to = array('account'=>array($so->account_id));
$et->variables = $so->plugin()->template_variables($et->variables(),$data);
$et->module = $so->mid();
$et->module_data = $so->id;
2013-11-15 05:25:45 +00:00
$et->send();
array_push($c,$so->id);
2013-07-06 14:00:10 +00:00
}
2013-11-15 05:25:45 +00:00
return sprintf('%s alerts sent (%s)',count($c),join('|',$c));
2013-07-06 14:00:10 +00:00
}
}
?>