OSB enhancements to date
This commit is contained in:
55
modules/invoice/classes/controller/user/invoice.php
Normal file
55
modules/invoice/classes/controller/user/invoice.php
Normal file
@@ -0,0 +1,55 @@
|
||||
<?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 {
|
||||
public $secure_actions = array(
|
||||
'list'=>TRUE,
|
||||
'view'=>FALSE,
|
||||
);
|
||||
|
||||
/**
|
||||
* Show a product
|
||||
*/
|
||||
public function action_list() {
|
||||
$id = Auth::instance()->get_user()->id;
|
||||
$ao = ORM::factory('account',$id);
|
||||
|
||||
if (! $ao->loaded())
|
||||
throw new Kohana_Exception('Account doesnt exist :account ?',array(':account'=>$id));
|
||||
|
||||
Block::add(array(
|
||||
'title'=>sprintf('%s: %s - %s',_('Invoices For'),$ao->accnum(),$ao->name(TRUE)),
|
||||
'body'=>View::factory('invoice/list')
|
||||
->set('invoices',$ao->invoice->find_all()),
|
||||
));
|
||||
|
||||
$this->template->content = Block::factory();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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/html')
|
||||
->set('mediapath',Route::get('default/media'))
|
||||
->set('invoice',$io);
|
||||
}
|
||||
}
|
||||
?>
|
Reference in New Issue
Block a user