TRUE, 'list'=>TRUE, 'view'=>TRUE, ); /** * Show a list of invoices */ public function action_list() { Block::add(array( 'title'=>sprintf('%s: %s - %s',_('Invoices For'),$this->ao->accnum(),$this->ao->name(TRUE)), 'body'=>Table::display( $this->ao->invoice->find_all(), 25, array( 'id'=>array('label'=>'ID','url'=>URL::link('user','invoice/view/')), 'date_orig'=>array('label'=>'Date Issued'), 'due_date'=>array('label'=>'Date Due'), 'total(TRUE)'=>array('label'=>'Total','class'=>'right'), 'total_credits(TRUE)'=>array('label'=>'Credits','class'=>'right'), 'payments_total(TRUE)'=>array('label'=>'Payments','class'=>'right'), 'due(TRUE)'=>array('label'=>'Still Due','class'=>'right'), ), array( 'page'=>TRUE, 'type'=>'select', 'form'=>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)) { $this->template->content = 'Unauthorised or doesnt exist?'; return FALSE; } $output .= View::factory($this->viewpath()) ->set('mediapath',Route::get('default/media')) ->set('io',$io); if ($io->due() AND ! $io->cart_exists()) { $output .= View::factory($this->viewpath().'/pay') ->set('mid',$io->mid()) ->set('o',$io); } if (! $io->status) { // Add a gribber popup // @todo Make a gribber popup a class on its own. Style::add(array( 'type'=>'file', 'data'=>'css/jquery.gritter.css', 'media'=>'screen', )); Script::add(array( 'type'=>'file', 'data'=>'js/jquery.gritter-1.5.js', )); Script::add(array( 'type'=>'stdin', 'data'=>sprintf( '$(document).ready(function() { $.extend($.gritter.options, { fade_in_speed: "medium", fade_out_speed: 2000, time: "3000", sticky: false, }); $.gritter.add({ title: "%s", text: "%s", image: "%s", });});', 'Cancelled','Invoice CANCELLED',URL::site().SystemMessage::image('info',true) ) )); Style::add(array( 'type'=>'stdin', 'data'=>' #watermark { color: #800000; font-size: 4em; -webkit-transform: rotate(-45deg); -moz-transform: rotate(-45deg); position: absolute; width: 100%; height: 100%; margin: 0; z-index: 1; left:250px; top:-20px; } ')); $output .= '

Invoice CANCELLED.

'; } Block::add(array( 'title'=>sprintf('%s: %s - %s',_('Invoice'),$io->refnum(),$io->account->name()), 'body'=>$output, )); } /** * 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; } } ?>