mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04: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)
|
protected function returnBulk($entityType, $action, $ids)
|
||||||
{
|
{
|
||||||
|
if ( ! is_array($ids)) {
|
||||||
|
$ids = [$ids];
|
||||||
|
}
|
||||||
|
|
||||||
$isDatatable = filter_var(request()->datatable, FILTER_VALIDATE_BOOLEAN);
|
$isDatatable = filter_var(request()->datatable, FILTER_VALIDATE_BOOLEAN);
|
||||||
$entityTypes = Utils::pluralizeEntityType($entityType);
|
$entityTypes = Utils::pluralizeEntityType($entityType);
|
||||||
|
|
||||||
|
@ -413,10 +413,10 @@ class InvoiceController extends BaseController
|
|||||||
Session::flash('message', $message);
|
Session::flash('message', $message);
|
||||||
|
|
||||||
if ($action == 'email') {
|
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 = $request->input();
|
||||||
$data['documents'] = $request->file('documents');
|
$data['documents'] = $request->file('documents');
|
||||||
|
testindfasdfa();
|
||||||
$action = Input::get('action');
|
$action = Input::get('action');
|
||||||
$entityType = Input::get('entityType');
|
$entityType = Input::get('entityType');
|
||||||
|
|
||||||
@ -439,14 +439,14 @@ class InvoiceController extends BaseController
|
|||||||
Session::flash('message', $message);
|
Session::flash('message', $message);
|
||||||
|
|
||||||
if ($action == 'clone') {
|
if ($action == 'clone') {
|
||||||
return $this->cloneInvoice($request, $invoice->public_id);
|
return url(sprintf('%ss/%s/clone', $entityType, $invoice->public_id));
|
||||||
} elseif ($action == 'convert') {
|
} elseif ($action == 'convert') {
|
||||||
return $this->convertQuote($request, $invoice->public_id);
|
return $this->convertQuote($request, $invoice->public_id);
|
||||||
} elseif ($action == 'email') {
|
} 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 {
|
} else {
|
||||||
Session::flash('error', $response);
|
Session::flash('error', $response);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Redirect::to("{$entityType}s/{$invoice->public_id}/edit");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function emailRecurringInvoice(&$invoice)
|
private function emailRecurringInvoice(&$invoice)
|
||||||
@ -540,7 +538,7 @@ class InvoiceController extends BaseController
|
|||||||
|
|
||||||
Session::flash('message', trans('texts.converted_to_invoice'));
|
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)
|
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) {
|
function escapeRegExp(str) {
|
||||||
return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
|
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,7 +2138,8 @@ $LANG = array(
|
|||||||
'new_category' => 'New Category',
|
'new_category' => 'New Category',
|
||||||
'restore_product' => 'Restore Product',
|
'restore_product' => 'Restore Product',
|
||||||
'blank' => 'Blank',
|
'blank' => 'Blank',
|
||||||
|
'invoice_error' => 'There was an error saving your invoice.',
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
return $LANG;
|
return $LANG;
|
||||||
|
@ -18,6 +18,11 @@
|
|||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.btn-info:disabled {
|
||||||
|
background-color: #e89259;
|
||||||
|
border-color: #e89259;
|
||||||
|
}
|
||||||
|
|
||||||
#scrollable-dropdown-menu .tt-menu {
|
#scrollable-dropdown-menu .tt-menu {
|
||||||
max-height: 150px;
|
max-height: 150px;
|
||||||
overflow-y: auto;
|
overflow-y: auto;
|
||||||
@ -757,7 +762,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{!! Former::close() !!}
|
{!! Former::close() !!}
|
||||||
|
</form>
|
||||||
|
|
||||||
{!! Former::open("{$entityType}s/bulk")->addClass('bulkForm') !!}
|
{!! Former::open("{$entityType}s/bulk")->addClass('bulkForm') !!}
|
||||||
{!! Former::populateField('bulk_public_id', $invoice->public_id) !!}
|
{!! Former::populateField('bulk_public_id', $invoice->public_id) !!}
|
||||||
@ -1336,7 +1342,20 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@if (Auth::user()->canCreateOrEdit(ENTITY_INVOICE, $invoice))
|
@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
|
@else
|
||||||
return false;
|
return false;
|
||||||
@endif
|
@endif
|
||||||
@ -1344,7 +1363,7 @@
|
|||||||
|
|
||||||
function submitBulkAction(value) {
|
function submitBulkAction(value) {
|
||||||
$('#bulk_action').val(value);
|
$('#bulk_action').val(value);
|
||||||
$('.bulkForm').submit();
|
$('.bulkForm')[0].submit();
|
||||||
}
|
}
|
||||||
|
|
||||||
function isSaveValid() {
|
function isSaveValid() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user