diff --git a/resources/views/expenses/bills/create.blade.php b/resources/views/expenses/bills/create.blade.php
index 8342431b9..8b897a4bb 100644
--- a/resources/views/expenses/bills/create.blade.php
+++ b/resources/views/expenses/bills/create.blade.php
@@ -12,7 +12,7 @@
{!! Form::label('vendor_id', trans_choice('general.vendors', 1), ['class' => 'control-label']) !!}
- {!! Form::select('vendor_id', $vendors, null, array_merge(['class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.vendors', 1)])])) !!}
+ {!! Form::select('vendor_id', $vendors, null, array_merge(['id' => 'vendor_id', 'class' => 'form-control', 'placeholder' => trans('general.form.select.field', ['field' => trans_choice('general.vendors', 1)])])) !!}
@@ -344,22 +344,30 @@
}
$(document).on('click', '#button-create-vendor', function (e) {
+ $('#modal-create-vendor .modal-header').before('
');
+
$.ajax({
url: '{{ url("expenses/vendors/vendor") }}',
type: 'POST',
dataType: 'JSON',
data: $("#form-create-vendor").serialize(),
beforeSend: function () {
+ $('#modal-create-vendor .modal-content').append();
+
$(".form-group").removeClass("has-error");
$(".help-block").remove();
},
success: function(data) {
+ $('#span-loading').remove();
+
$('#modal-create-vendor').modal('hide');
$("#vendor_id").append('
');
$("#vendor_id").select2('refresh');
},
error: function(error, textStatus, errorThrown) {
+ $('#span-loading').remove();
+
if (error.responseJSON.name) {
$("input[name='name']").parent().parent().addClass('has-error');
$("input[name='name']").parent().after('
' + error.responseJSON.name + '
');
diff --git a/resources/views/expenses/payments/create.blade.php b/resources/views/expenses/payments/create.blade.php
index dccc4f5e8..6b78af2ea 100644
--- a/resources/views/expenses/payments/create.blade.php
+++ b/resources/views/expenses/payments/create.blade.php
@@ -28,7 +28,16 @@
{{ Form::selectGroup('category_id', trans_choice('general.categories', 1), 'folder-open-o', $categories) }}
- {{ Form::selectGroup('vendor_id', trans_choice('general.vendors', 1), 'user', $vendors, null, []) }}
+
{{ Form::selectGroup('payment_method', trans_choice('general.payment_methods', 1), 'credit-card', $payment_methods, setting('general.default_payment_method')) }}
@@ -101,5 +110,118 @@
});
});
});
+
+ function createVendor() {
+ $('#modal-create-vendor').remove();
+
+ modal = '
';
+ modal += '
';
+ modal += '
';
+ modal += ' ';
+ modal += '
';
+ modal += ' {!! Form::open(['id' => 'form-create-vendor', 'role' => 'form']) !!}';
+ modal += '
';
+ modal += '
';
+ modal += '
';
+ modal += '
';
+ modal += '
';
+ modal += '
';
+ modal += ' ';
+ modal += ' ';
+ modal += '
';
+ modal += ' {!! Form::hidden('enabled', '1', []) !!}';
+ modal += '
';
+ modal += ' {!! Form::close() !!}';
+ modal += '
';
+ modal += ' ';
+ modal += '
';
+ modal += '
';
+ modal += '
';
+
+ $('body').append(modal);
+
+ $("#modal-create-vendor #currency_code").select2({
+ placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.currencies', 1)]) }}"
+ });
+
+ $('#modal-create-vendor').modal('show');
+ }
+
+ $(document).on('click', '#button-create-vendor', function (e) {
+ $('#modal-create-vendor .modal-header').before('
');
+
+ $.ajax({
+ url: '{{ url("expenses/vendors/vendor") }}',
+ type: 'POST',
+ dataType: 'JSON',
+ data: $("#form-create-vendor").serialize(),
+ beforeSend: function () {
+ $(".form-group").removeClass("has-error");
+ $(".help-block").remove();
+ },
+ success: function(data) {
+ $('#span-loading').remove();
+
+ $('#modal-create-vendor').modal('hide');
+
+ $("#vendor_id").append('
');
+ $("#vendor_id").select2('refresh');
+ },
+ error: function(error, textStatus, errorThrown) {
+ $('#span-loading').remove();
+
+ if (error.responseJSON.name) {
+ $("input[name='name']").parent().parent().addClass('has-error');
+ $("input[name='name']").parent().after('
' + error.responseJSON.name + '
');
+ }
+
+ if (error.responseJSON.email) {
+ $("input[name='email']").parent().parent().addClass('has-error');
+ $("input[name='email']").parent().after('
' + error.responseJSON.email + '
');
+ }
+
+ if (error.responseJSON.currency_code) {
+ $("select[name='currency_code']").parent().parent().addClass('has-error');
+ $("select[name='currency_code']").parent().after('
' + error.responseJSON.currency_code + '
');
+ }
+ }
+ });
+ });
@endpush
diff --git a/resources/views/incomes/invoices/create.blade.php b/resources/views/incomes/invoices/create.blade.php
index cf31c8e31..fcfdccb58 100644
--- a/resources/views/incomes/invoices/create.blade.php
+++ b/resources/views/incomes/invoices/create.blade.php
@@ -345,6 +345,8 @@
}
$(document).on('click', '#button-create-customer', function (e) {
+ $('#modal-create-customer .modal-header').before('
');
+
$.ajax({
url: '{{ url("incomes/customers/customer") }}',
type: 'POST',
@@ -355,12 +357,16 @@
$(".help-block").remove();
},
success: function(data) {
+ $('#span-loading').remove();
+
$('#modal-create-customer').modal('hide');
$("#customer_id").append('
');
$("#customer_id").select2('refresh');
},
error: function(error, textStatus, errorThrown) {
+ $('#span-loading').remove();
+
if (error.responseJSON.name) {
$("input[name='name']").parent().parent().addClass('has-error');
$("input[name='name']").parent().after('
' + error.responseJSON.name + '
');
diff --git a/resources/views/incomes/revenues/create.blade.php b/resources/views/incomes/revenues/create.blade.php
index 7578c1733..16b697287 100644
--- a/resources/views/incomes/revenues/create.blade.php
+++ b/resources/views/incomes/revenues/create.blade.php
@@ -28,7 +28,16 @@
{{ Form::selectGroup('category_id', trans_choice('general.categories', 1), 'folder-open-o', $categories) }}
- {{ Form::selectGroup('customer_id', trans_choice('general.customers', 1), 'user', $customers, null, []) }}
+
{{ Form::selectGroup('payment_method', trans_choice('general.payment_methods', 1), 'credit-card', $payment_methods, setting('general.default_payment_method')) }}
@@ -101,5 +110,118 @@
});
});
});
+
+ function createCustomer() {
+ $('#modal-create-customer').remove();
+
+ modal = '
';
+ modal += '
';
+ modal += '
';
+ modal += ' ';
+ modal += '
';
+ modal += ' {!! Form::open(['id' => 'form-create-customer', 'role' => 'form']) !!}';
+ modal += '
';
+ modal += '
';
+ modal += '
';
+ modal += '
';
+ modal += '
';
+ modal += '
';
+ modal += ' ';
+ modal += ' ';
+ modal += '
';
+ modal += ' {!! Form::hidden('enabled', '1', []) !!}';
+ modal += '
';
+ modal += ' {!! Form::close() !!}';
+ modal += '
';
+ modal += ' ';
+ modal += '
';
+ modal += '
';
+ modal += '
';
+
+ $('body').append(modal);
+
+ $("#modal-create-customer #currency_code").select2({
+ placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.currencies', 1)]) }}"
+ });
+
+ $('#modal-create-customer').modal('show');
+ }
+
+ $(document).on('click', '#button-create-customer', function (e) {
+ $('#modal-create-customer .modal-header').before('
');
+
+ $.ajax({
+ url: '{{ url("incomes/customers/customer") }}',
+ type: 'POST',
+ dataType: 'JSON',
+ data: $("#form-create-customer").serialize(),
+ beforeSend: function () {
+ $(".form-group").removeClass("has-error");
+ $(".help-block").remove();
+ },
+ success: function(data) {
+ $('#span-loading').remove();
+
+ $('#modal-create-customer').modal('hide');
+
+ $("#customer_id").append('
');
+ $("#customer_id").select2('refresh');
+ },
+ error: function(error, textStatus, errorThrown) {
+ $('#span-loading').remove();
+
+ if (error.responseJSON.name) {
+ $("input[name='name']").parent().parent().addClass('has-error');
+ $("input[name='name']").parent().after('
' + error.responseJSON.name + '
');
+ }
+
+ if (error.responseJSON.email) {
+ $("input[name='email']").parent().parent().addClass('has-error');
+ $("input[name='email']").parent().after('
' + error.responseJSON.email + '
');
+ }
+
+ if (error.responseJSON.currency_code) {
+ $("select[name='currency_code']").parent().parent().addClass('has-error');
+ $("select[name='currency_code']").parent().after('
' + error.responseJSON.currency_code + '
');
+ }
+ }
+ });
+ });
@endpush