60 lines
1.5 KiB
PHP
60 lines
1.5 KiB
PHP
<?php defined('SYSPATH') or die('No direct access allowed.');
|
|
|
|
/**
|
|
* This class provides User Invoice functions
|
|
*
|
|
* @package OSB
|
|
* @subpackage Invoice
|
|
* @category Controllers/User
|
|
* @author Deon George
|
|
* @copyright (c) 2010 Deon George
|
|
* @license http://dev.leenooks.net/license.html
|
|
*/
|
|
class Controller_User_Invoice extends Controller_TemplateDefault_User {
|
|
protected $secure_actions = array(
|
|
'download'=>TRUE,
|
|
'list'=>TRUE,
|
|
'view'=>TRUE,
|
|
);
|
|
|
|
/**
|
|
* Show a product
|
|
*/
|
|
public function action_list() {
|
|
Block::add(array(
|
|
'title'=>sprintf('%s: %s - %s',_('Invoices For'),$this->ao->accnum(),$this->ao->name(TRUE)),
|
|
'body'=>View::factory('invoice/user/list')
|
|
->set('invoices',$this->ao->invoice->find_all()),
|
|
));
|
|
}
|
|
|
|
/**
|
|
* View an Invoice
|
|
*/
|
|
public function action_view($id) {
|
|
$io = ORM::factory('invoice',$id);
|
|
|
|
if (! $io->loaded() OR ! Auth::instance()->authorised($io->account_id)) {
|
|
$this->template->content = 'Unauthorised or doesnt exist?';
|
|
return FALSE;
|
|
}
|
|
|
|
// @todo media path probably should be a config item
|
|
$this->template->content = View::factory('invoice/user/html')
|
|
->set('mediapath',Route::get('default/media'))
|
|
->set('invoice',$io);
|
|
}
|
|
|
|
/**
|
|
* Download an invoice
|
|
*/
|
|
public function action_download($id) {
|
|
$io = ORM::factory('invoice',$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;
|
|
}
|
|
}
|
|
?>
|