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/application/classes/Task/Account/Complete.php
2013-05-15 13:58:50 +10:00

33 lines
778 B
PHP

<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* Mark all accounts that have no outstanding invoices and active services as disabled.
*
* @package Account
* @category Tasks
* @author Deon George
* @copyright (c) 2009-2013 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Task_Account_Complete extends Minion_Task {
protected function _execute(array $params) {
$c = 0;
$o = ORM::factory('Account')
->where_active();
foreach ($o->find_all() as $ao) {
if (count($ao->invoice->where_unprocessed()->find_all()) == 0 AND count($ao->service->where_active()->find_all()) == 0)
$ao->status = 0;
$ao->save();
if ($ao->saved())
$c++;
}
printf("%s services made inactive\n",$c);
}
}
?>