Prevent downloading PDF if this invoice hasn't been saved

This commit is contained in:
Hillel Coren 2016-06-01 16:39:07 +03:00
parent 78bafbbf09
commit 901464380e

View File

@ -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") !!} {!! 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 @endif
@if ( ! $invoice->is_recurring) @if ( $invoice->exists && ! $invoice->is_recurring)
{!! Button::primary(trans('texts.download_pdf'))->withAttributes(array('onclick' => 'onDownloadClick()'))->appendIcon(Icon::create('download-alt')) !!} {!! Button::primary(trans('texts.download_pdf'))
->withAttributes(['onclick' => 'onDownloadClick()', 'id' => 'downloadPdfButton'])
->appendIcon(Icon::create('download-alt')) !!}
@endif @endif
@if ($invoice->isClientTrashed()) @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() { $('#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() { setTimeout(function() {
refreshPDF(true); refreshPDF(true);
}, 1); }, 1);
@ -1078,6 +1081,7 @@
if ($(event.target).hasClass('handled')) { if ($(event.target).hasClass('handled')) {
return; return;
} }
$('#downloadPdfButton').attr('disabled', true);
onItemChange(); onItemChange();
refreshPDF(true); refreshPDF(true);
}); });
@ -1219,7 +1223,7 @@
function onSaveClick() { function onSaveClick() {
if (model.invoice().is_recurring()) { if (model.invoice().is_recurring()) {
// warn invoice will be emailed when saving new recurring invoice // 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") !!}")) { if (confirm("{!! trans("texts.confirm_recurring_email_$entityType") !!}" + '\n\n' + getSendToEmails() + '\n' + "{!! trans("texts.confirm_recurring_timing") !!}")) {
submitAction(''); submitAction('');
} }