diff --git a/application/classes/Auth/OSB.php b/application/classes/Auth/OSB.php index 60a6b445..2da65507 100644 --- a/application/classes/Auth/OSB.php +++ b/application/classes/Auth/OSB.php @@ -44,10 +44,13 @@ class Auth_OSB extends Auth_ORM { if ($mmto->loaded()) { // Check that the token is for this URI $mo = ORM::factory('Module',array('name'=>Request::current()->controller())); - $mmo = ORM::factory('Module_Method',array( - 'module_id'=>$mo->id, - 'name'=>strtolower(Request::current()->directory() ? sprintf('%s:%s',Request::current()->directory(),Request::current()->action()) : Request::current()->action()) - )); + $mmo = $mo->module_method + ->where_open() + ->where('name','=',strtolower(Request::current()->directory() ? sprintf('%s:%s',Request::current()->directory(),Request::current()->action()) : Request::current()->action())) + // @todo No longer required after all method names have been colon delimited + ->or_where('name','=',strtolower(Request::current()->directory() ? sprintf('%s_%s',Request::current()->directory(),Request::current()->action()) : Request::current()->action())) + ->where_close() + ->find(); // Ignore the token if this is not the right method. if ($mmo->id == $mmto->method_id) { diff --git a/modules/invoice/classes/Controller/Invoice.php b/modules/invoice/classes/Controller/Invoice.php index df03cdc8..283bf025 100644 --- a/modules/invoice/classes/Controller/Invoice.php +++ b/modules/invoice/classes/Controller/Invoice.php @@ -10,129 +10,5 @@ * @license http://dev.osbill.net/license.html */ class Controller_Invoice extends Controller_TemplateDefault { - protected $secure_actions = array( - 'download'=>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; - } } ?> diff --git a/modules/invoice/classes/Controller/User/Invoice.php b/modules/invoice/classes/Controller/User/Invoice.php index 6a817e17..63175267 100644 --- a/modules/invoice/classes/Controller/User/Invoice.php +++ b/modules/invoice/classes/Controller/User/Invoice.php @@ -10,5 +10,80 @@ * @license http://dev.osbill.net/license.html */ class Controller_User_Invoice extends Controller_Invoice { + 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('mediapath',Route::get('default/media')) + ->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 .= '
Invoice CANCELLED.
'; + } + + Block::factory() + ->title(sprintf('%s: %s - %s',_('Invoice'),$io->refnum(),$io->account->name())) + ->title_icon('icon-list-alt') + ->body($output); + } } ?> diff --git a/modules/invoice/media/css/pages/invoice.css b/modules/invoice/media/css/pages/invoice.css new file mode 100644 index 00000000..dd6cec00 --- /dev/null +++ b/modules/invoice/media/css/pages/invoice.css @@ -0,0 +1,13 @@ +#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:350px; + top:-50px; +} diff --git a/modules/invoice/views/invoice/user/view.php b/modules/invoice/views/invoice/user/view.php index 40dc0839..6b36df10 100644 --- a/modules/invoice/views/invoice/user/view.php +++ b/modules/invoice/views/invoice/user/view.php @@ -1,84 +1,75 @@ - - - - - - - - - - - - - - -
- - - - - -
- name(); ?>
- taxid(); ?>
-
- address(); ?>
-
- contacts(); ?> -
-
  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
TAX INVOICEid(); ?>
Issue Datedisplay('date_orig'); ?>
Due Datedisplay('due_date'); ?>
Current Chargestotal_charges(TRUE); ?>
Payments Received to Datepayments_total(TRUE); ?>
Credits Applied to Datetotal_credits(TRUE); ?>
Total Charges Due This Invoicedue(TRUE); ?>
-
 
- - - - - items_index('period') as $rs => $items) { ?> +
+
+
+
+
Charges Detail:
- - - - - - - - + + - - - - - - - items_index('account')) { ?> - - - - - - - - - - - - - - - - - - total_credits()) { ?> - - - - - - - - total_discounts()) { ?> - - - - - - - - - - - - tax_summary() as $tid => $amount) { - $m = ORM::factory('Tax',$tid); ?> - - - - - - - - - - - - - - - - - - - -
uri(array('file'=>'img/toggle-closed.png')),array('alt'=>'+')); ?>
 Other Items + name(); ?>
+ taxid(); ?>
+
+ address(); ?>
+
+ contacts(); ?> +
  -
- - $service_id) { - $i = 0; - $lp = NULL; - $ito_tax = NULL; - foreach ($io->items_service($service_id) as $ito) { +
+
+ + +
+
+
+
Tax Invoice
+
id(); ?>
+
Issue Date
+
display('date_orig'); ?>
+
Due Date
+
display('due_date'); ?>
+
Current Charges
+
total_charges(TRUE); ?>
+
Payments Recieved
+
payments_total(TRUE); ?>
+
Credits Applied
+
total_credits(TRUE); ?>
+
Still Due
+
due(TRUE); ?>
+
+
+
+ + + +
+
+

Charge Details

+ +
+
+ + items_index('period') as $rs => $items) : ?> +
+ + + +
+ + +
+ + + $service_id) : + $i = 0; + $lp = NULL; + $ito_tax = NULL; + + foreach ($o->items_service($service_id) as $ito) { $ito_tax = $ito; // Our first line we show the Service Details if ($ito->item_type == 0 AND $ito->product_id != $lp) { @@ -87,7 +78,7 @@ - + @@ -106,40 +97,37 @@ - + - - + + + - + - - -
service_id),$ito->service->id()); ?> product->title(),$ito->service->name()); ?> (product_id; ?>)items_service_total($ito->service_id)) : ' ');?>items_service_total($ito->service_id)) : ' ');?>
  (items_service_discount($ito->service_id));?>)(items_service_discount($ito->service_id));?>)
  items_service_tax($ito->service_id));?> items_service_tax($ito->service_id));?> 
-
-
 
uri(array('file'=>'img/toggle-closed.png')),array('alt'=>'+')); ?>Other Invoice Items 
  -
- - items_index('account') as $id => $ito) { ?> + + + +
+
+ + + items_index('account')) : ?> + + +
+ + + items_index('account') as $id => $ito) : ?> @@ -152,67 +140,69 @@ - + - -
  trannum();?>
  items_service_tax($ito->service_id));?> items_service_tax($ito->service_id));?> 
-
-
 
Sub Total of Items:subtotal(TRUE); ?>
Credits Received:total_credits(TRUE); ?>
Discounts:(total_discounts(TRUE); ?>)
Taxes Included:
 description; ?>
Total This Invoice:total(TRUE); ?>
Total Outstanding This Account:account->invoices_due_total(NULL,TRUE); ?>
-
id),'Download detailed invoice'); ?>
+ + + + + + + + + + + + +
+
+
+
+ +
+
+
+ +
Sub Total
+
subtotal(TRUE); ?>
+ + + + total_credits()) : ?> +
Credits
+
total_credits(TRUE); ?>
+ + + + + total_discounts()) : ?> +
Discounts
+
total_discounts(TRUE); ?>
+ + + + +
Taxes Included:
+ tax_summary() as $tid => $amount) : + $m = ORM::factory('Tax',$tid); ?> +
description); ?>
+ + + + +
Total This Invoice:
+
total(TRUE); ?>
+ + +
Total Outstanding This Account:
+
account->invoices_due_total(NULL,TRUE); ?>
+ + +
+
+
+
+
+ +id),'Download detailed invoice',array('class'=>'btn btn-primary pull-right')); ?> diff --git a/modules/service/views/service/user/view.php b/modules/service/views/service/user/view.php index 6477ada4..5b0108a4 100644 --- a/modules/service/views/service/user/view.php +++ b/modules/service/views/service/user/view.php @@ -2,38 +2,38 @@
Service Information -
+
-
Account
-
account->name(),$o->account->accnum()); ?>
+
Account
+
account->name(),$o->account->accnum()); ?>
-
Service Active
-
label_bool('status',TRUE); ?>
+
Service Active
+
label_bool('status',TRUE); ?>
-
Billing Period
-
display('recur_schedule');?>
+
Billing Period
+
display('recur_schedule');?>
-
Cost
-
price(TRUE,TRUE); if ($o->pending_change()) echo ' *'; ?>
+
Cost
+
price(TRUE,TRUE); if ($o->pending_change()) echo ' *'; ?>
- price) OR ($o->price<=$o->product->price($o->price_group,$o->recur_schedule,'price_base'))) : ?> -
Service
-
product_id,$o->product->title()); ?>
- + price) OR ($o->price<=$o->product->price($o->price_group,$o->recur_schedule,'price_base'))) : ?> +
Service
+
product_id,$o->product->title()); ?>
+ -
Invoiced To
-
invoiced_to(TRUE); ?>
+
Invoiced To
+
invoiced_to(TRUE); ?>
-
Paid To
-
paid_to(TRUE); ?>
+
Paid To
+
paid_to(TRUE); ?>
-
Date Next Invoice
-
display('date_next_invoice'); ?>
+
Date Next Invoice
+
display('date_next_invoice'); ?>
-
Current Invoices Due
-
due(TRUE); ?>
+
Current Invoices Due
+
due(TRUE); ?>
-
+
product->feature_summary()) :