2010-11-29 22:41:08 +00:00
|
|
|
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This class provides User Invoice functions
|
|
|
|
*
|
2013-03-19 22:35:19 +00:00
|
|
|
* @package Invoice
|
2010-11-29 22:41:08 +00:00
|
|
|
* @category Controllers/User
|
|
|
|
* @author Deon George
|
2013-03-19 22:35:19 +00:00
|
|
|
* @copyright (c) 2009-2013 Open Source Billing
|
|
|
|
* @license http://dev.osbill.net/license.html
|
2010-11-29 22:41:08 +00:00
|
|
|
*/
|
2013-04-04 22:42:29 +00:00
|
|
|
class Controller_User_Invoice extends Controller_Invoice {
|
2013-06-11 04:30:13 +00:00
|
|
|
protected $secure_actions = array(
|
|
|
|
'download'=>TRUE,
|
|
|
|
'list'=>TRUE,
|
|
|
|
'view'=>TRUE,
|
|
|
|
);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Download an invoice
|
|
|
|
*/
|
|
|
|
public function action_download() {
|
|
|
|
$io = ORM::factory('Invoice',$this->request->param('id'));
|
|
|
|
|
|
|
|
$this->response->body(Invoice::instance($io)->pdf()->Output(sprintf('%s.pdf',$io->refnum()),'D'));
|
|
|
|
$this->response->headers(array('Content-Type' => 'application/pdf'));
|
|
|
|
$this->auto_render = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show a list of invoices
|
|
|
|
*/
|
|
|
|
public function action_list() {
|
|
|
|
Block::factory()
|
|
|
|
->title(sprintf('Invoices for Account: %s',$this->ao->accnum()))
|
|
|
|
->title_icon('icon-th-list')
|
|
|
|
->body(Table::factory()
|
|
|
|
->jssort('invoices')
|
|
|
|
->data($this->ao->invoice->find_all())
|
|
|
|
->columns(array(
|
|
|
|
'id'=>'ID',
|
|
|
|
'date_orig'=>'Date Issued',
|
|
|
|
'due_date'=>'Date Due',
|
|
|
|
'total(TRUE)'=>'Total',
|
|
|
|
'total_credits(TRUE)'=>'Credits',
|
|
|
|
'payments_total(TRUE)'=>'Payments',
|
|
|
|
'due(TRUE)'=>'Still Due',
|
|
|
|
))
|
|
|
|
->prepend(array(
|
|
|
|
'id'=>array('url'=>URL::link('user','invoice/view/')),
|
|
|
|
))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* View an Invoice
|
|
|
|
*/
|
|
|
|
public function action_view() {
|
|
|
|
list($id,$output) = Table::page(__METHOD__);
|
|
|
|
|
|
|
|
$io = ORM::factory('Invoice',$id);
|
|
|
|
|
|
|
|
if (! $io->loaded() OR ! Auth::instance()->authorised($io->account))
|
|
|
|
throw HTTP_Exception::factory(403,'Service either doesnt exist, or you are not authorised to see it');
|
|
|
|
|
|
|
|
$output .= View::factory('invoice/user/view')
|
|
|
|
->set('o',$io);
|
|
|
|
|
|
|
|
if ($io->due() AND ! $io->cart_exists())
|
|
|
|
$output .= View::factory('/invoice/user/view/pay')
|
|
|
|
->set('mid',$io->mid())
|
|
|
|
->set('o',$io);
|
|
|
|
|
|
|
|
if (! $io->status) {
|
|
|
|
Style::factory()
|
|
|
|
->type('file')
|
|
|
|
->data('media/css/pages/invoice.css');
|
|
|
|
|
|
|
|
$output .= '<div id="watermark">Invoice CANCELLED.</div>';
|
|
|
|
}
|
|
|
|
|
|
|
|
Block::factory()
|
|
|
|
->title(sprintf('%s: %s - %s',_('Invoice'),$io->refnum(),$io->account->name()))
|
|
|
|
->title_icon('icon-list-alt')
|
|
|
|
->body($output);
|
|
|
|
}
|
2010-11-29 22:41:08 +00:00
|
|
|
}
|
|
|
|
?>
|