From 901464380e71253f48159cd9bae5a9a8c9ea54ba Mon Sep 17 00:00:00 2001 From: Hillel Coren Date: Wed, 1 Jun 2016 16:39:07 +0300 Subject: [PATCH] Prevent downloading PDF if this invoice hasn't been saved --- resources/views/invoices/edit.blade.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/resources/views/invoices/edit.blade.php b/resources/views/invoices/edit.blade.php index fa4b0178aefc..dd7b00f24126 100644 --- a/resources/views/invoices/edit.blade.php +++ b/resources/views/invoices/edit.blade.php @@ -524,8 +524,10 @@ {!! Former::select('invoice_design_id')->style('display:inline;width:150px;background-color:white !important')->raw()->fromQuery($invoiceDesigns, 'name', 'id')->data_bind("value: invoice_design_id") !!} @endif - @if ( ! $invoice->is_recurring) - {!! Button::primary(trans('texts.download_pdf'))->withAttributes(array('onclick' => 'onDownloadClick()'))->appendIcon(Icon::create('download-alt')) !!} + @if ( $invoice->exists && ! $invoice->is_recurring) + {!! Button::primary(trans('texts.download_pdf')) + ->withAttributes(['onclick' => 'onDownloadClick()', 'id' => 'downloadPdfButton']) + ->appendIcon(Icon::create('download-alt')) !!} @endif @if ($invoice->isClientTrashed()) @@ -923,6 +925,7 @@ } $('#invoice_footer, #terms, #public_notes, #invoice_number, #invoice_date, #due_date, #start_date, #po_number, #discount, #currency_id, #invoice_design_id, #recurring, #is_amount_discount, #partial, #custom_text_value1, #custom_text_value2').change(function() { + $('#downloadPdfButton').attr('disabled', true); setTimeout(function() { refreshPDF(true); }, 1); @@ -1078,6 +1081,7 @@ if ($(event.target).hasClass('handled')) { return; } + $('#downloadPdfButton').attr('disabled', true); onItemChange(); refreshPDF(true); }); @@ -1219,7 +1223,7 @@ function onSaveClick() { if (model.invoice().is_recurring()) { // warn invoice will be emailed when saving new recurring invoice - if ({{ $invoice->exists() ? 'false' : 'true' }}) { + if ({{ $invoice->exists ? 'false' : 'true' }}) { if (confirm("{!! trans("texts.confirm_recurring_email_$entityType") !!}" + '\n\n' + getSendToEmails() + '\n' + "{!! trans("texts.confirm_recurring_timing") !!}")) { submitAction(''); }