mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2024-11-10 05:02:36 +01:00
Enable resubmitting form if invoice fails to save
This commit is contained in:
parent
f529b2ed06
commit
f3a9f88107
@ -24,6 +24,10 @@ class BaseController extends Controller
|
||||
|
||||
protected function returnBulk($entityType, $action, $ids)
|
||||
{
|
||||
if ( ! is_array($ids)) {
|
||||
$ids = [$ids];
|
||||
}
|
||||
|
||||
$isDatatable = filter_var(request()->datatable, FILTER_VALIDATE_BOOLEAN);
|
||||
$entityTypes = Utils::pluralizeEntityType($entityType);
|
||||
|
||||
|
@ -413,10 +413,10 @@ class InvoiceController extends BaseController
|
||||
Session::flash('message', $message);
|
||||
|
||||
if ($action == 'email') {
|
||||
return $this->emailInvoice($invoice, Input::get('pdfupload'));
|
||||
$this->emailInvoice($invoice, Input::get('pdfupload'));
|
||||
}
|
||||
|
||||
return redirect()->to($invoice->getRoute());
|
||||
return url($invoice->getRoute());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -429,7 +429,7 @@ class InvoiceController extends BaseController
|
||||
{
|
||||
$data = $request->input();
|
||||
$data['documents'] = $request->file('documents');
|
||||
|
||||
testindfasdfa();
|
||||
$action = Input::get('action');
|
||||
$entityType = Input::get('entityType');
|
||||
|
||||
@ -439,14 +439,14 @@ class InvoiceController extends BaseController
|
||||
Session::flash('message', $message);
|
||||
|
||||
if ($action == 'clone') {
|
||||
return $this->cloneInvoice($request, $invoice->public_id);
|
||||
return url(sprintf('%ss/%s/clone', $entityType, $invoice->public_id));
|
||||
} elseif ($action == 'convert') {
|
||||
return $this->convertQuote($request, $invoice->public_id);
|
||||
} elseif ($action == 'email') {
|
||||
return $this->emailInvoice($invoice, Input::get('pdfupload'));
|
||||
$this->emailInvoice($invoice, Input::get('pdfupload'));
|
||||
}
|
||||
|
||||
return redirect()->to($invoice->getRoute());
|
||||
return url($invoice->getRoute());
|
||||
}
|
||||
|
||||
|
||||
@ -473,8 +473,6 @@ class InvoiceController extends BaseController
|
||||
} else {
|
||||
Session::flash('error', $response);
|
||||
}
|
||||
|
||||
return Redirect::to("{$entityType}s/{$invoice->public_id}/edit");
|
||||
}
|
||||
|
||||
private function emailRecurringInvoice(&$invoice)
|
||||
@ -540,7 +538,7 @@ class InvoiceController extends BaseController
|
||||
|
||||
Session::flash('message', trans('texts.converted_to_invoice'));
|
||||
|
||||
return Redirect::to('invoices/' . $clone->public_id);
|
||||
return url('invoices/' . $clone->public_id);
|
||||
}
|
||||
|
||||
public function cloneInvoice(InvoiceRequest $request, $publicId)
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -1143,3 +1143,19 @@ function searchData(data, key, fuzzy) {
|
||||
function escapeRegExp(str) {
|
||||
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
||||
}
|
||||
|
||||
function firstJSONError(json) {
|
||||
for (var key in json) {
|
||||
if ( ! json.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
var item = json[key];
|
||||
for (var subKey in item) {
|
||||
if ( ! item.hasOwnProperty(subKey)) {
|
||||
continue;
|
||||
}
|
||||
return item[subKey];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -2138,6 +2138,7 @@ $LANG = array(
|
||||
'new_category' => 'New Category',
|
||||
'restore_product' => 'Restore Product',
|
||||
'blank' => 'Blank',
|
||||
'invoice_error' => 'There was an error saving your invoice.',
|
||||
|
||||
);
|
||||
|
||||
|
@ -18,6 +18,11 @@
|
||||
float: left;
|
||||
}
|
||||
|
||||
.btn-info:disabled {
|
||||
background-color: #e89259;
|
||||
border-color: #e89259;
|
||||
}
|
||||
|
||||
#scrollable-dropdown-menu .tt-menu {
|
||||
max-height: 150px;
|
||||
overflow-y: auto;
|
||||
@ -758,6 +763,7 @@
|
||||
</div>
|
||||
|
||||
{!! Former::close() !!}
|
||||
</form>
|
||||
|
||||
{!! Former::open("{$entityType}s/bulk")->addClass('bulkForm') !!}
|
||||
{!! Former::populateField('bulk_public_id', $invoice->public_id) !!}
|
||||
@ -1336,7 +1342,20 @@
|
||||
}
|
||||
|
||||
@if (Auth::user()->canCreateOrEdit(ENTITY_INVOICE, $invoice))
|
||||
return true;
|
||||
if ($('#saveButton').is(':disabled')) {
|
||||
return false;
|
||||
}
|
||||
$('#saveButton, #emailButton').attr('disabled', true);
|
||||
// if save fails ensure user can try again
|
||||
$.post('{{ url($url) }}', $('.main-form').serialize(), function(data) {
|
||||
NINJA.formIsChanged = false;
|
||||
location.href = data;
|
||||
}).fail(function(data) {
|
||||
$('#saveButton, #emailButton').attr('disabled', false);
|
||||
var error = firstJSONError(data.responseJSON) || data.statusText;
|
||||
swal("{!! trans('texts.invoice_error') !!}", error);
|
||||
});
|
||||
return false;
|
||||
@else
|
||||
return false;
|
||||
@endif
|
||||
@ -1344,7 +1363,7 @@
|
||||
|
||||
function submitBulkAction(value) {
|
||||
$('#bulk_action').val(value);
|
||||
$('.bulkForm').submit();
|
||||
$('.bulkForm')[0].submit();
|
||||
}
|
||||
|
||||
function isSaveValid() {
|
||||
|
Loading…
Reference in New Issue
Block a user