From b8b894a5f94ddc03ef9095157b56477d8872c8af Mon Sep 17 00:00:00 2001 From: Karl Cordes Date: Mon, 27 Mar 2023 16:45:38 +1100 Subject: [PATCH] Finish invoice changes - Closes #54 --- app/controllers/invoices_controller.php | 9 +-------- app/vendors/shells/invoice.php | 9 ++++++++- app/views/invoices/edit.ctp | 3 +++ app/views/invoices/index.ctp | 7 ++++--- 4 files changed, 16 insertions(+), 12 deletions(-) diff --git a/app/controllers/invoices_controller.php b/app/controllers/invoices_controller.php index ccb684fe..f880ca04 100755 --- a/app/controllers/invoices_controller.php +++ b/app/controllers/invoices_controller.php @@ -2,7 +2,7 @@ class InvoicesController extends AppController { var $name = 'Invoices'; - var $helpers = array('Html', 'Form', 'Time', 'Text','Javascript'); + var $helpers = array('Html', 'Form', 'Time', 'Text','Javascript', 'Number'); var $paginate = array( @@ -17,13 +17,6 @@ class InvoicesController extends AppController { } - function calculate() { - - - - } - - function printView() { $this->layout = 'minimal'; $this->Invoice->recursive = 0; diff --git a/app/vendors/shells/invoice.php b/app/vendors/shells/invoice.php index 27eb892e..28a2673a 100644 --- a/app/vendors/shells/invoice.php +++ b/app/vendors/shells/invoice.php @@ -31,6 +31,13 @@ class InvoiceShell extends Shell { $totals = $this->calculateTotals($document, $enquiry['Enquiry']['gst']); $invoice['Invoice']['amount_invoiced'] = $totals['total']; print_r($totals); + + $parts = explode(" ", $invoice['Invoice']['title'], 2); + if(count($parts) > 1) { + $invoice['Invoice']['title'] = $parts[0]; + $invoice['Invoice']['comments'] = $parts[1]; + } + echo "Saving invoice ".$invoice["Invoice"]["id"]."\n"; $this->LineItem->Document->Invoice->save($invoice); } @@ -64,7 +71,7 @@ class InvoiceShell extends Shell { function main() { - $q = "SELECT id, document_id FROM invoices i"; + $q = "SELECT id, document_id FROM invoices i ORDER BY id DESC"; $results = $this->Invoice->query($q); foreach($results as $row) { if($row["i"]["document_id"]) { diff --git a/app/views/invoices/edit.ctp b/app/views/invoices/edit.ctp index 5fee6d8f..f57d622b 100755 --- a/app/views/invoices/edit.ctp +++ b/app/views/invoices/edit.ctp @@ -9,6 +9,9 @@ echo $form->input('title', array('class'=>'disabled', 'readonly'=>'readonly')); echo $form->input('paid'); echo $form->input('payment_received_date'); + echo $form->input('amount_invoiced', array('class'=>'disabled', 'readonly'=>'readonly')); + echo $form->input('amount_received'); + echo $form->input('comments'); echo $form->input('enquiry_id', array('type'=>'hidden')); echo $form->input('job_id'); ?> diff --git a/app/views/invoices/index.ctp b/app/views/invoices/index.ctp index b723526f..0dd0e18d 100755 --- a/app/views/invoices/index.ctp +++ b/app/views/invoices/index.ctp @@ -15,6 +15,7 @@ Date Received Amount Invoiced Amount Received + Comments sort('Invoice Number');?> sort('Job Number');?> sort('enquiry_id');?> @@ -66,8 +67,9 @@ ?> - - TODO + currency($invoice['Invoice']['amount_invoiced'], $invoice['Currency']['iso4217']); ?> + currency($invoice['Invoice']['amount_received'], $invoice['Currency']['iso4217']);?> + @@ -101,4 +103,3 @@ -