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/invoice/classes/controller/task/invoice.php

49 lines
1.3 KiB
PHP
Raw Normal View History

2011-08-16 02:27:19 +00:00
<?php defined('SYSPATH') or die('No direct access allowed.');
/**
* This class provides OSB invoice task capabilities.
*
* @package OSB
* @subpackage Invoice
* @category Controllers/Task
* @author Deon George
* @copyright (c) 2010 Open Source Billing
* @license http://dev.osbill.net/license.html
*/
class Controller_Task_Invoice extends Controller_Task {
public function action_list($mode) {
$io = ORM::factory('invoice');
$tm = 'list_'.$mode;
if (! method_exists($io,$tm))
throw new Kohana_Exception('Unknown Task List command :command',array(':command'=>$mode));
$total = $numinv = 0;
$duelist = View::factory('invoice/task/'.$tm.'_header');
foreach ($io->$tm() as $t) {
$duelist .= View::factory('invoice/task/'.$tm.'_body')
->set('io',$t);
$numinv++;
$total += $t->due();
}
$duelist .= View::factory('invoice/task/'.$tm.'_footer');
// Send our email
2011-08-26 02:01:45 +00:00
$et = Email_Template::instance('task_invoice_overdue');
2011-08-16 02:27:19 +00:00
// @todo Update this to be dynamic
$et->to = array('account'=>array(1,68));
$et->variables = array(
'TABLE'=>$duelist,
'NUM_INV'=>$numinv,
'TOTAL'=>$total,
);
$et->send();
$output = sprintf('List (%s) sent to: %s',$mode,implode(',',array_keys($et->to)));
$this->response->body($output);
}
}
?>