From c3d43ab4806f11f131aa1d037fa101fb9600cf31 Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Tue, 3 Nov 2015 00:05:28 +0200 Subject: [PATCH] Bug fixes --- app/Http/Controllers/PaymentController.php | 15 ++++++--------- app/Ninja/Repositories/InvoiceRepository.php | 6 ++++-- public/js/built.js | 6 ++++++ public/js/pdf.pdfmake.js | 7 +++++++ resources/views/invoices/edit.blade.php | 2 +- resources/views/invoices/knockout.blade.php | 6 +++--- 6 files changed, 27 insertions(+), 15 deletions(-) diff --git a/app/Http/Controllers/PaymentController.php b/app/Http/Controllers/PaymentController.php index 5ec8d56ddb..6ed6f25620 100644 --- a/app/Http/Controllers/PaymentController.php +++ b/app/Http/Controllers/PaymentController.php @@ -524,6 +524,11 @@ class PaymentController extends BaseController return Redirect::to($invitation->getLink()); } + // PayFast transaction referencce + if ($accountGateway->isGateway(GATEWAY_PAYFAST) && Request::has('pt')) { + $token = Request::query('pt'); + } + try { if (method_exists($gateway, 'completePurchase') && !$accountGateway->isGateway(GATEWAY_TWO_CHECKOUT)) { $details = $this->paymentService->getPaymentDetails($invitation, $accountGateway); @@ -592,19 +597,11 @@ class PaymentController extends BaseController private function error($type, $error, $accountGateway, $exception = false) { - if (!$error) { - if ($exception) { - $error = $exception->getMessage(); - } else { - $error = trans('texts.payment_error'); - } - } - $message = ''; if ($accountGateway && $accountGateway->gateway) { $message = $accountGateway->gateway->name . ': '; } - $message .= $error; + $message .= $error ?: trans('texts.payment_error'); Session::flash('error', $message); Utils::logError("Payment Error [{$type}]: " . ($exception ? Utils::getErrorString($exception) : $message)); diff --git a/app/Ninja/Repositories/InvoiceRepository.php b/app/Ninja/Repositories/InvoiceRepository.php index b5daa89cdf..f43daea880 100644 --- a/app/Ninja/Repositories/InvoiceRepository.php +++ b/app/Ninja/Repositories/InvoiceRepository.php @@ -235,6 +235,9 @@ class InvoiceRepository extends BaseRepository $entityType = ENTITY_QUOTE; } $invoice = $account->createInvoice($entityType, $data['client_id']); + if (isset($data['has_tasks']) && $data['has_tasks']) { + $invoice->has_tasks = true; + } } else { $invoice = Invoice::scope($publicId)->firstOrFail(); } @@ -258,8 +261,7 @@ class InvoiceRepository extends BaseRepository $invoice->is_amount_discount = $data['is_amount_discount'] ? true : false; $invoice->partial = round(Utils::parseFloat($data['partial']), 2); $invoice->invoice_date = isset($data['invoice_date_sql']) ? $data['invoice_date_sql'] : Utils::toSqlDate($data['invoice_date']); - $invoice->has_tasks = isset($data['has_tasks']) ? ($data['has_tasks'] ? true : false) : false; - + if ($invoice->is_recurring) { if ($invoice->start_date && $invoice->start_date != Utils::toSqlDate($data['start_date'])) { $invoice->last_sent_date = null; diff --git a/public/js/built.js b/public/js/built.js index 103279c51c..35eb4201dc 100644 --- a/public/js/built.js +++ b/public/js/built.js @@ -31627,6 +31627,12 @@ function GetPdfMake(invoice, javascript, callback) { } } + if (key === 'footer') { + return function(page, pages) { + return page === pages ? val : ''; + } + } + // check for markdown if (key === 'text') { val = NINJA.parseMarkdownText(val, true); diff --git a/public/js/pdf.pdfmake.js b/public/js/pdf.pdfmake.js index ea7329ebb0..57118324d5 100644 --- a/public/js/pdf.pdfmake.js +++ b/public/js/pdf.pdfmake.js @@ -54,6 +54,13 @@ function GetPdfMake(invoice, javascript, callback) { } } + // only show the footer on the last page + if (key === 'footer') { + return function(page, pages) { + return page === pages ? val : ''; + } + } + // check for markdown if (key === 'text') { val = NINJA.parseMarkdownText(val, true); diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index 864fd1ba64..20d6715d0c 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -760,7 +760,7 @@ @endif $('#clientModal').on('shown.bs.modal', function () { - $('#name').focus(); + $('#client\\[name\\]').focus(); }).on('hidden.bs.modal', function () { if (model.clientBackup) { model.loadClient(model.clientBackup); diff --git a/resources/views/invoices/knockout.blade.php b/resources/views/invoices/knockout.blade.php index 5bf27743af..ae7bd45f30 100644 --- a/resources/views/invoices/knockout.blade.php +++ b/resources/views/invoices/knockout.blade.php @@ -118,8 +118,8 @@ function ViewModel(data) { trackEvent('/activity', '/view_client_form'); self.clientBackup = ko.mapping.toJS(self.invoice().client); - $('#emailError').css( "display", "none" ); - $('#clientModal').modal('show'); + $('#emailError').css( "display", "none" ); + $('#clientModal').modal('show'); } self.clientFormComplete = function() { @@ -228,7 +228,7 @@ function InvoiceModel(data) { self.balance = ko.observable(0); self.invoice_design_id = ko.observable(1); self.partial = ko.observable(0); - self.has_tasks = ko.observable(false); + self.has_tasks = ko.observable(); self.custom_value1 = ko.observable(0); self.custom_value2 = ko.observable(0);