Moved all service tasks to minion
This commit is contained in:
parent
1b83a5a0b1
commit
4206b683da
@ -141,12 +141,12 @@ abstract class Service_Traffic_Adsl {
|
||||
}
|
||||
|
||||
public function alert_traffic() {
|
||||
$et = Email_Template::instance('adsl_traffic_notice');
|
||||
|
||||
foreach ($this->aso->services() as $so) {
|
||||
if (! $so->plugin()->report_traffic())
|
||||
continue;
|
||||
|
||||
$et = Email_Template::instance('adsl_traffic_notice');
|
||||
|
||||
// Get our variable data
|
||||
$et->to = array('account'=>array($so->account_id));
|
||||
$et->variables = $so->plugin()->template_variables($et->variables());
|
||||
|
22
modules/adsl/classes/Task/Adsl/Trafficalert.php
Normal file
22
modules/adsl/classes/Task/Adsl/Trafficalert.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?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
|
||||
*/
|
||||
class Task_Adsl_Trafficalert extends Task_Adsl_Trafficget {
|
||||
protected function _execute(array $params) {
|
||||
foreach ($this->_traffic_suppliers(TRUE) as $aso) {
|
||||
if ($params['verbose'])
|
||||
echo $aso->name."\n";
|
||||
|
||||
Service_Traffic_Adsl::instance($aso->name)->alert_traffic();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
22
modules/adsl/classes/Task/Adsl/Trafficcharge.php
Normal file
22
modules/adsl/classes/Task/Adsl/Trafficcharge.php
Normal file
@ -0,0 +1,22 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* Charge 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
|
||||
*/
|
||||
class Task_Adsl_Trafficcharge extends Task_Adsl_Trafficget {
|
||||
protected function _execute(array $params) {
|
||||
foreach ($this->_traffic_suppliers(TRUE) as $aso) {
|
||||
if ($params['verbose'])
|
||||
echo $aso->name."\n";
|
||||
|
||||
Service_Traffic_Adsl::instance($aso->name)->charge_excess_traffic();
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@ -10,7 +10,7 @@
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Task_Adsl_Trafficget extends Minion_Task {
|
||||
private function _traffic_suppliers($active=FALSE) {
|
||||
protected function _traffic_suppliers($active=FALSE) {
|
||||
$suppliers = ORM::factory('ADSL_Supplier');
|
||||
|
||||
return $active ? $suppliers->list_active() : $suppliers->find_all();
|
||||
|
@ -26,7 +26,7 @@ class Task_Invoice_Complete extends Minion_Task {
|
||||
$c++;
|
||||
}
|
||||
|
||||
printf('%s invoices updated',$c);
|
||||
return sprintf('%s invoices updated',$c);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
55
modules/invoice/classes/Task/Invoice/Reminddue.php
Normal file
55
modules/invoice/classes/Task/Invoice/Reminddue.php
Normal file
@ -0,0 +1,55 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* Send out an invoice remind for upcoming due invoices.
|
||||
*
|
||||
* @package Invoice
|
||||
* @category Tasks
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Task_Invoice_Reminddue extends Minion_Task {
|
||||
protected function _execute(array $params) {
|
||||
$action = array();
|
||||
$key = 'remind_due';
|
||||
$days = ORM::factory('Invoice')->config(strtoupper($key));
|
||||
|
||||
foreach (ORM::factory('Invoice')->list_due(time()+86400*$days) as $io) {
|
||||
// @todo Use another option to supress reminders
|
||||
// If we have already sent a reminder, we'll skip to the next one.
|
||||
if (($io->remind($key) AND (is_null($x=$this->request->param('id')) OR $x != 'again')) OR ($io->account->invoice_delivery != 1))
|
||||
continue;
|
||||
|
||||
// Generate a token to view the invoice online
|
||||
$token = ORM::factory('Module_Method_Token')
|
||||
->method(array('invoice','user_view'))
|
||||
->account($io->account)
|
||||
->expire(time()+86400*21)
|
||||
->uses(3)
|
||||
->generate();
|
||||
|
||||
// Send our email
|
||||
$et = Email_Template::instance('task_invoice_'.$key);
|
||||
|
||||
$et->to = array('account'=>array($io->account_id));
|
||||
$et->variables = array(
|
||||
'DUE'=>$io->due(TRUE),
|
||||
'DUE_DATE'=>$io->display('due_date'),
|
||||
'FIRST_NAME'=>$io->account->first_name,
|
||||
'INV_NUM'=>$io->refnum(),
|
||||
'INV_URL'=>URL::site(URL::link('user',sprintf('invoice/view/%s?token=%s',$io->id,$token)),'http'),
|
||||
'SITE_NAME'=>Company::instance()->name(),
|
||||
);
|
||||
|
||||
// @todo Record email log id if possible.
|
||||
if ($et->send()) {
|
||||
$io->set_remind($key,time());
|
||||
array_push($action,(string)$io);
|
||||
}
|
||||
}
|
||||
|
||||
return _('Due Reminders Sent: ').join('|',$action);
|
||||
}
|
||||
}
|
||||
?>
|
@ -1,35 +0,0 @@
|
||||
<?php defined('SYSPATH') or die('No direct access allowed.');
|
||||
|
||||
/**
|
||||
* This class provides OSB service task capabilities.
|
||||
*
|
||||
* @package Service
|
||||
* @category Controllers/Task
|
||||
* @author Deon George
|
||||
* @copyright (c) 2009-2013 Open Source Billing
|
||||
* @license http://dev.osbill.net/license.html
|
||||
*/
|
||||
class Controller_Task_Service extends Controller_Task {
|
||||
private function _traffic_suppliers($active=FALSE) {
|
||||
$suppliers = ORM::factory('ADSL_Supplier');
|
||||
|
||||
return $active ? $suppliers->list_active() : $suppliers->find_all();
|
||||
}
|
||||
|
||||
/**
|
||||
* Charges for excess traffic usage
|
||||
*/
|
||||
public function action_chargetraffic() {
|
||||
foreach ($this->_traffic_suppliers(TRUE) as $aso)
|
||||
$traffic = Service_Traffic_Adsl::instance($aso->name)->charge_excess_traffic();
|
||||
}
|
||||
|
||||
/**
|
||||
* Send alerts to users when they exceed their traffic allowance
|
||||
*/
|
||||
public function action_alerttraffic() {
|
||||
foreach ($this->_traffic_suppliers(TRUE) as $aso)
|
||||
$traffic = Service_Traffic_Adsl::instance($aso->name)->alert_traffic();
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user