Some invoice cleanup, and Task updating conversion

This commit is contained in:
Deon George
2013-06-16 23:36:47 +10:00
parent 6875dc3693
commit 609a72425b
10 changed files with 126 additions and 101 deletions

View File

@@ -12,48 +12,6 @@
class Controller_Task_Invoice extends Controller_Task {
public $auto_render = FALSE;
/**
* Email a list of invoice balances
*
* This function is typically used to list the overdue invoices to the admins
* @param string mode The callback method to use as the data list eg: overdue
*/
public function action_list() {
$mode = $this->request->param('id');
$i = ORM::factory('Invoice');
$tm = 'list_'.$mode;
if (! method_exists($i,$tm))
throw new Kohana_Exception('Unknown Task List command :command',array(':command'=>$mode));
$total = $numinv = 0;
$duelist = View::factory('invoice/task/'.$tm.'_head');
foreach ($i->$tm() as $t) {
$duelist .= View::factory('invoice/task/'.$tm.'_body')
->set('io',$t);
$numinv++;
$total += $t->due();
}
$duelist .= View::factory('invoice/task/'.$tm.'_foot');
// Send our email
$et = Email_Template::instance('task_invoice_list_overdue');
// @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);
}
/**
* Email a customers a reminder of their upcoming invoices that are due.
*/