close #767 Fixed: Modals dublicate action issue (Customer, Vendor, Tax, Payment etc)
This commit is contained in:
		| @@ -1,13 +1,17 @@ | ||||
| <div class="modal fade" id="modal-add-payment" style="display: none;"> | ||||
| <div class="modal fade add-payment-{{ $rand }}" id="modal-add-payment" style="display: none;"> | ||||
|     <div class="modal-dialog  modal-lg"> | ||||
|         <div class="modal-content"> | ||||
|             <div class="modal-header"> | ||||
|                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | ||||
|  | ||||
|                 <h4 class="modal-title">{{ trans('general.title.new', ['type' => trans_choice('general.payments', 1)]) }}</h4> | ||||
|             </div> | ||||
|  | ||||
|             <div class="modal-body"> | ||||
|                 <div class="modal-message"></div> | ||||
|  | ||||
|                 {!! Form::open(['id' => 'form-add-payment', 'role' => 'form', 'class' => 'form-loading-button']) !!} | ||||
|  | ||||
|                 <div class="row"> | ||||
|                     {{ Form::textGroup('paid_at', trans('general.date'), 'calendar',['id' => 'paid_at', 'class' => 'form-control', 'required' => 'required', 'data-inputmask' => '\'alias\': \'yyyy-mm-dd\'', 'data-mask' => '', 'autocomplete' => 'off'], Date::now()->toDateString()) }} | ||||
|  | ||||
| @@ -34,11 +38,14 @@ | ||||
|  | ||||
|                     {!! Form::hidden('bill_id', $bill->id, ['id' => 'bill_id', 'class' => 'form-control', 'required' => 'required']) !!} | ||||
|                 </div> | ||||
|  | ||||
|                 {!! Form::close() !!} | ||||
|             </div> | ||||
|  | ||||
|             <div class="modal-footer"> | ||||
|                 <div class="pull-left"> | ||||
|                     {!! Form::button('<span class="fa fa-save"></span>  ' . trans('general.save'), ['type' => 'button', 'id' =>'button-add-payment', 'class' => 'btn btn-success button-submit', 'data-loading-text' => trans('general.loading')]) !!} | ||||
|  | ||||
|                     <button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-times-circle"></span>  {{ trans('general.cancel') }}</button> | ||||
|                 </div> | ||||
|             </div> | ||||
| @@ -47,12 +54,12 @@ | ||||
| </div> | ||||
|  | ||||
| <script type="text/javascript"> | ||||
|     $('#modal-add-payment #amount').focus(); | ||||
|     $('.add-payment-{{ $rand }}#modal-add-payment #amount').focus(); | ||||
|  | ||||
|     $(document).ready(function(){ | ||||
|         $('#modal-add-payment').modal('show'); | ||||
|         $('.add-payment-{{ $rand }}#modal-add-payment').modal('show'); | ||||
|  | ||||
|         $("#modal-add-payment #amount").maskMoney({ | ||||
|         $(".add-payment-{{ $rand }}#modal-add-payment #amount").maskMoney({ | ||||
|             thousands : '{{ $currency->thousands_separator }}', | ||||
|             decimal : '{{ $currency->decimal_mark }}', | ||||
|             precision : {{ $currency->precision }}, | ||||
| @@ -64,9 +71,9 @@ | ||||
|             @endif | ||||
|         }); | ||||
|  | ||||
|         $('#modal-add-payment #amount').trigger('focusout'); | ||||
|         $('.add-payment-{{ $rand }}#modal-add-payment #amount').trigger('focusout'); | ||||
|  | ||||
|         $('#modal-add-payment #paid_at').datepicker({ | ||||
|         $('.add-payment-{{ $rand }}#modal-add-payment #paid_at').datepicker({ | ||||
|             format: 'yyyy-mm-dd', | ||||
|             todayBtn: 'linked', | ||||
|             weekStart: 1, | ||||
| @@ -74,28 +81,28 @@ | ||||
|             language: '{{ language()->getShortCode() }}' | ||||
|         }); | ||||
|  | ||||
|         $("#modal-add-payment #account_id").select2({ | ||||
|         $(".add-payment-{{ $rand }}#modal-add-payment #account_id").select2({ | ||||
|             placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.accounts', 1)]) }}" | ||||
|         }); | ||||
|  | ||||
|         $("#modal-add-payment #payment_method").select2({ | ||||
|         $(".add-payment-{{ $rand }}#modal-add-payment #payment_method").select2({ | ||||
|             placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.payment_methods', 1)]) }}" | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|     $(document).on('change', '#modal-add-payment  #account_id', function (e) { | ||||
|     $(document).on('change', '.add-payment-{{ $rand }}#modal-add-payment  #account_id', function (e) { | ||||
|         $.ajax({ | ||||
|             url: '{{ url("banking/accounts/currency") }}', | ||||
|             type: 'GET', | ||||
|             dataType: 'JSON', | ||||
|             data: 'account_id=' + $(this).val(), | ||||
|             success: function(data) { | ||||
|                 $('#modal-add-payment  #currency').val(data.currency_name); | ||||
|                 $('#modal-add-payment  #currency_code').val(data.currency_code); | ||||
|                 $('.add-payment-{{ $rand }}#modal-add-payment  #currency').val(data.currency_name); | ||||
|                 $('.add-payment-{{ $rand }}#modal-add-payment  #currency_code').val(data.currency_code); | ||||
|  | ||||
|                 amount = $('#modal-add-payment  #amount').maskMoney('unmasked')[0]; | ||||
|                 amount = $('.add-payment-{{ $rand }}#modal-add-payment  #amount').maskMoney('unmasked')[0]; | ||||
|  | ||||
|                 $("#modal-add-payment  #amount").maskMoney({ | ||||
|                 $(".add-payment-{{ $rand }}#modal-add-payment  #amount").maskMoney({ | ||||
|                     thousands : data.thousands_separator, | ||||
|                     decimal : data.decimal_mark, | ||||
|                     precision : data.precision, | ||||
| @@ -104,43 +111,43 @@ | ||||
|                     suffix : (data.symbol_first) ? '' : data.symbol | ||||
|                 }); | ||||
|  | ||||
|                 $('#modal-add-payment  #amount').val(amount); | ||||
|                 $('.add-payment-{{ $rand }}#modal-add-payment  #amount').val(amount); | ||||
|  | ||||
|                 $('#modal-add-payment #amount').focus(); | ||||
|                 $('.add-payment-{{ $rand }}#modal-add-payment #amount').focus(); | ||||
|             } | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|     $(document).on('click', '#button-add-payment', function (e) { | ||||
|         $('.help-block').remove(); | ||||
|     $(document).on('click', '.add-payment-{{ $rand }} #button-add-payment', function (e) { | ||||
|         $('.add-payment-{{ $rand }} .help-block').remove(); | ||||
|  | ||||
|         $.ajax({ | ||||
|             url: '{{ url("modals/bills/" . $bill->id . "/payment") }}', | ||||
|             type: 'POST', | ||||
|             dataType: 'JSON', | ||||
|             data: $("#form-add-payment").serialize(), | ||||
|             data: $(".add-payment-{{ $rand }} #form-add-payment").serialize(), | ||||
|             headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' }, | ||||
|             beforeSend: function() { | ||||
|                 $('#button-add-payment').button('loading'); | ||||
|                 $('.add-payment-{{ $rand }} #button-add-payment').button('loading'); | ||||
|  | ||||
|                 $('#modal-add-payment .modal-content').append('<div id="loading" class="text-center"><i class="fa fa-spinner fa-spin fa-5x checkout-spin"></i></div>'); | ||||
|                 $('.add-payment-{{ $rand }}#modal-add-payment .modal-content').append('<div id="loading" class="text-center"><i class="fa fa-spinner fa-spin fa-5x checkout-spin"></i></div>'); | ||||
|             }, | ||||
|             complete: function() { | ||||
|                 $('#button-add-payment').button('reset'); | ||||
|                 $('#loading').remove(); | ||||
|                 $('.add-payment-{{ $rand }} #button-add-payment').button('reset'); | ||||
|                 $('.add-payment-{{ $rand }} #loading').remove(); | ||||
|             }, | ||||
|             success: function(json) { | ||||
|                 if (json['error']) { | ||||
|                     $('#modal-add-payment .modal-message').append('<div class="alert alert-danger">' + json['message'] + '</div>'); | ||||
|                     $('div.alert-danger').delay(3000).fadeOut(350); | ||||
|                     $('.add-payment-{{ $rand }}#modal-add-payment .modal-message').append('<div class="alert alert-danger">' + json['message'] + '</div>'); | ||||
|                     $('.add-payment-{{ $rand }} div.alert-danger').delay(3000).fadeOut(350); | ||||
|                 } | ||||
|  | ||||
|                 if (json['success']) { | ||||
|                     $('#modal-add-payment .modal-message').before('<div class="alert alert-success">' + json['message'] + '</div>'); | ||||
|                     $('div.alert-success').delay(3000).fadeOut(350); | ||||
|                     $('.add-payment-{{ $rand }}#modal-add-payment .modal-message').before('<div class="alert alert-success">' + json['message'] + '</div>'); | ||||
|                     $('.add-payment-{{ $rand }} div.alert-success').delay(3000).fadeOut(350); | ||||
|  | ||||
|                     setTimeout(function(){ | ||||
|                         $("#modal-add-payment").modal('hide'); | ||||
|                         $(".add-payment-{{ $rand }}#modal-add-payment").modal('hide'); | ||||
|  | ||||
|                         location.reload(); | ||||
|                     }, 3000); | ||||
| @@ -151,30 +158,30 @@ | ||||
|  | ||||
|                 if (typeof errors !== 'undefined') { | ||||
|                     if (errors.paid_at) { | ||||
|                         $('#modal-add-payment #paid_at').parent().after('<p class="help-block">' + errors.paid_at + '</p>'); | ||||
|                         $('.add-payment-{{ $rand }}#modal-add-payment #paid_at').parent().after('<p class="help-block">' + errors.paid_at + '</p>'); | ||||
|                     } | ||||
|  | ||||
|                     if (errors.amount) { | ||||
|                         $('#modal-add-payment #amount').parent().after('<p class="help-block">' + errors.amount + '</p>'); | ||||
|                         $('.add-payment-{{ $rand }}#modal-add-payment #amount').parent().after('<p class="help-block">' + errors.amount + '</p>'); | ||||
|                     } | ||||
|  | ||||
|                     if (errors.account_id) { | ||||
|                         $('#modal-add-payment #account_id').parent().after('<p class="help-block">' + errors.account_id + '</p>'); | ||||
|                         $('.add-payment-{{ $rand }}#modal-add-payment #account_id').parent().after('<p class="help-block">' + errors.account_id + '</p>'); | ||||
|                     } | ||||
|  | ||||
|                     if (errors.currency_code) { | ||||
|                         $('#modal-add-payment #currency_code').parent().after('<p class="help-block">' + errors.currency_code + '</p>'); | ||||
|                         $('.add-payment-{{ $rand }}#modal-add-payment #currency_code').parent().after('<p class="help-block">' + errors.currency_code + '</p>'); | ||||
|                     } | ||||
|  | ||||
|                     if (errors.category_id) { | ||||
|                         $('#modal-add-payment #category_id').parent().after('<p class="help-block">' + errors.category_id + '</p>'); | ||||
|                         $('.add-payment-{{ $rand }}#modal-add-payment #category_id').parent().after('<p class="help-block">' + errors.category_id + '</p>'); | ||||
|                     } | ||||
|  | ||||
|                     if (errors.payment_method) { | ||||
|                         $('#modal-add-payment #payment_method').parent().after('<p class="help-block">' + errors.payment_method + '</p>'); | ||||
|                         $('.add-payment-{{ $rand }}#modal-add-payment #payment_method').parent().after('<p class="help-block">' + errors.payment_method + '</p>'); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|     }); | ||||
| </script> | ||||
| </script> | ||||
|   | ||||
| @@ -1,11 +1,13 @@ | ||||
| <div class="modal fade" id="modal-create-category" style="display: none;"> | ||||
| <div class="modal fade create-category-{{ $rand }}" id="modal-create-category" style="display: none;"> | ||||
|     <div class="modal-dialog  modal-lg"> | ||||
|         <div class="modal-content"> | ||||
|             <div class="modal-header"> | ||||
|                 <h4 class="modal-title">{{ trans('general.title.new', ['type' => trans_choice('general.categories', 1)]) }}</h4> | ||||
|             </div> | ||||
|  | ||||
|             <div class="modal-body"> | ||||
|                 {!! Form::open(['id' => 'form-create-category', 'role' => 'form', 'class' => 'form-loading-button']) !!} | ||||
|  | ||||
|                 <div class="row"> | ||||
|                     {{ Form::textGroup('name', trans('general.name'), 'id-card-o') }} | ||||
|  | ||||
| @@ -23,11 +25,14 @@ | ||||
|                     {!! Form::hidden('type', $type, []) !!} | ||||
|                     {!! Form::hidden('enabled', '1', []) !!} | ||||
|                 </div> | ||||
|  | ||||
|                 {!! Form::close() !!} | ||||
|             </div> | ||||
|  | ||||
|             <div class="modal-footer"> | ||||
|                 <div class="pull-left"> | ||||
|                     {!! Form::button('<span class="fa fa-save"></span>  ' . trans('general.save'), ['type' => 'button', 'id' =>'button-create-category', 'class' => 'btn btn-success button-submit', 'data-loading-text' => trans('general.loading')]) !!} | ||||
|  | ||||
|                     <button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-times-circle"></span>  {{ trans('general.cancel') }}</button> | ||||
|                 </div> | ||||
|             </div> | ||||
| @@ -37,34 +42,34 @@ | ||||
|  | ||||
| <script type="text/javascript"> | ||||
|     $(document).ready(function(){ | ||||
|         $('#modal-create-category').modal('show'); | ||||
|         $('.create-category-{{ $rand }}#modal-create-category').modal('show'); | ||||
|  | ||||
|         $('#category-color-picker').colorpicker(); | ||||
|         $('.create-category-{{ $rand }} #category-color-picker').colorpicker(); | ||||
|     }); | ||||
|  | ||||
|     $(document).on('click', '#button-create-category', function (e) { | ||||
|         $('#modal-create-category .modal-header').before('<span id="span-loading" style="position: absolute; height: 100%; width: 100%; z-index: 99; background: #6da252; opacity: 0.4;"><i class="fa fa-spinner fa-spin" style="font-size: 10em !important;margin-left: 35%;margin-top: 8%;"></i></span>'); | ||||
|     $(document).on('click', '.create-category-{{ $rand }} #button-create-category', function (e) { | ||||
|         $('.create-category-{{ $rand }}#modal-create-category .modal-header').before('<span id="span-loading" style="position: absolute; height: 100%; width: 100%; z-index: 99; background: #6da252; opacity: 0.4;"><i class="fa fa-spinner fa-spin" style="font-size: 10em !important;margin-left: 35%;margin-top: 8%;"></i></span>'); | ||||
|  | ||||
|         $.ajax({ | ||||
|             url: '{{ url("modals/categories") }}', | ||||
|             type: 'POST', | ||||
|             dataType: 'JSON', | ||||
|             data: $("#form-create-category").serialize(), | ||||
|             data: $(".create-category-{{ $rand }} #form-create-category").serialize(), | ||||
|             beforeSend: function () { | ||||
|                 $('#button-create-category').button('loading'); | ||||
|                 $('.create-category-{{ $rand }} #button-create-category').button('loading'); | ||||
|  | ||||
|                 $(".form-group").removeClass("has-error"); | ||||
|                 $(".help-block").remove(); | ||||
|                 $(".create-category-{{ $rand }} .form-group").removeClass("has-error"); | ||||
|                 $(".create-category-{{ $rand }} .help-block").remove(); | ||||
|             }, | ||||
|             complete: function() { | ||||
|                 $('#button-create-category').button('reset'); | ||||
|                 $('.create-category-{{ $rand }} #button-create-category').button('reset'); | ||||
|             }, | ||||
|             success: function(json) { | ||||
|                 var data = json['data']; | ||||
|  | ||||
|                 $('#span-loading').remove(); | ||||
|                 $('.create-category-{{ $rand }} #span-loading').remove(); | ||||
|  | ||||
|                 $('#modal-create-category').modal('hide'); | ||||
|                 $('.create-category-{{ $rand }}#modal-create-category').modal('hide'); | ||||
|  | ||||
|                 $('#category_id').append('<option value="' + data.id + '" selected="selected">' + data.name + '</option>'); | ||||
|                 $('#category_id').trigger('change'); | ||||
| @@ -77,18 +82,18 @@ | ||||
|                 @endif | ||||
|             }, | ||||
|             error: function(error, textStatus, errorThrown) { | ||||
|                 $('#span-loading').remove(); | ||||
|                 $('.create-category-{{ $rand }} #span-loading').remove(); | ||||
|  | ||||
|                 if (error.responseJSON.name) { | ||||
|                     $("#modal-create-category input[name='name']").parent().parent().addClass('has-error'); | ||||
|                     $("#modal-create-category input[name='name']").parent().after('<p class="help-block">' + error.responseJSON.name + '</p>'); | ||||
|                     $(".create-category-{{ $rand }}#modal-create-category input[name='name']").parent().parent().addClass('has-error'); | ||||
|                     $(".create-category-{{ $rand }}#modal-create-category input[name='name']").parent().after('<p class="help-block">' + error.responseJSON.name + '</p>'); | ||||
|                 } | ||||
|  | ||||
|                 if (error.responseJSON.color) { | ||||
|                     $("#modal-create-category input[name='color']").parent().parent().addClass('has-error'); | ||||
|                     $("#modal-create-category input[name='color']").parent().after('<p class="help-block">' + error.responseJSON.color + '</p>'); | ||||
|                     $(".create-category-{{ $rand }}#modal-create-category input[name='color']").parent().parent().addClass('has-error'); | ||||
|                     $(".create-category-{{ $rand }}#modal-create-category input[name='color']").parent().after('<p class="help-block">' + error.responseJSON.color + '</p>'); | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|     }); | ||||
| </script> | ||||
| </script> | ||||
|   | ||||
| @@ -1,11 +1,13 @@ | ||||
| <div class="modal fade" id="modal-create-customer" style="display: none;"> | ||||
| <div class="modal fade create-customer-{{ $rand }}" id="modal-create-customer" style="display: none;"> | ||||
|     <div class="modal-dialog  modal-lg"> | ||||
|         <div class="modal-content"> | ||||
|             <div class="modal-header"> | ||||
|                 <h4 class="modal-title">{{ trans('general.title.new', ['type' => trans_choice('general.customers', 1)]) }}</h4> | ||||
|             </div> | ||||
|  | ||||
|             <div class="modal-body"> | ||||
|                 {!! Form::open(['id' => 'form-create-customer', 'role' => 'form', 'class' => 'form-loading-button']) !!} | ||||
|  | ||||
|                 <div class="row"> | ||||
|                     {{ Form::textGroup('name', trans('general.name'), 'id-card-o') }} | ||||
|  | ||||
| @@ -19,11 +21,14 @@ | ||||
|  | ||||
|                     {!! Form::hidden('enabled', '1', []) !!} | ||||
|                 </div> | ||||
|  | ||||
|                 {!! Form::close() !!} | ||||
|             </div> | ||||
|  | ||||
|             <div class="modal-footer"> | ||||
|                 <div class="pull-left"> | ||||
|                     {!! Form::button('<span class="fa fa-save"></span>  ' . trans('general.save'), ['type' => 'button', 'id' =>'button-create-customer', 'class' => 'btn btn-success button-submit', 'data-loading-text' => trans('general.loading')]) !!} | ||||
|  | ||||
|                     <button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-times-circle"></span>  {{ trans('general.cancel') }}</button> | ||||
|                 </div> | ||||
|             </div> | ||||
| @@ -33,36 +38,36 @@ | ||||
|  | ||||
| <script type="text/javascript"> | ||||
|     $(document).ready(function(){ | ||||
|         $('#modal-create-customer').modal('show'); | ||||
|         $('.create-customer-{{ $rand }}#modal-create-customer').modal('show'); | ||||
|  | ||||
|         $("#modal-create-customer #currency_code").select2({ | ||||
|         $(".create-customer-{{ $rand }}#modal-create-customer #currency_code").select2({ | ||||
|             placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.currencies', 1)]) }}" | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|     $(document).on('click', '#button-create-customer', function (e) { | ||||
|         $('#modal-create-customer .modal-header').before('<span id="span-loading" style="position: absolute; height: 100%; width: 100%; z-index: 99; background: #6da252; opacity: 0.4;"><i class="fa fa-spinner fa-spin" style="font-size: 16em !important;margin-left: 35%;margin-top: 8%;"></i></span>'); | ||||
|     $(document).on('click', '.create-customer-{{ $rand }} #button-create-customer', function (e) { | ||||
|         $('.create-customer-{{ $rand }}#modal-create-customer .modal-header').before('<span id="span-loading" style="position: absolute; height: 100%; width: 100%; z-index: 99; background: #6da252; opacity: 0.4;"><i class="fa fa-spinner fa-spin" style="font-size: 16em !important;margin-left: 35%;margin-top: 8%;"></i></span>'); | ||||
|  | ||||
|         $.ajax({ | ||||
|             url: '{{ url("modals/customers") }}', | ||||
|             type: 'POST', | ||||
|             dataType: 'JSON', | ||||
|             data: $("#form-create-customer").serialize(), | ||||
|             data: $(".create-customer-{{ $rand }} #form-create-customer").serialize(), | ||||
|             beforeSend: function () { | ||||
|                 $('#button-create-customer').button('loading'); | ||||
|                 $('.create-customer-{{ $rand }} #button-create-customer').button('loading'); | ||||
|  | ||||
|                 $(".form-group").removeClass("has-error"); | ||||
|                 $(".help-block").remove(); | ||||
|                 $(".create-customer-{{ $rand }} .form-group").removeClass("has-error"); | ||||
|                 $(".create-customer-{{ $rand }} .help-block").remove(); | ||||
|             }, | ||||
|             complete: function() { | ||||
|                 $('#button-create-customer').button('reset'); | ||||
|                 $('.create-customer-{{ $rand }} #button-create-customer').button('reset'); | ||||
|             }, | ||||
|             success: function(json) { | ||||
|                 var data = json['data']; | ||||
|  | ||||
|                 $('#span-loading').remove(); | ||||
|                 $('.create-customer-{{ $rand }} #span-loading').remove(); | ||||
|  | ||||
|                 $('#modal-create-customer').modal('hide'); | ||||
|                 $('.create-customer-{{ $rand }}#modal-create-customer').modal('hide'); | ||||
|  | ||||
|                 $('#customer_id').append('<option value="' + data.id + '" selected="selected">' + data.name + '</option>'); | ||||
|                 $('#customer_id').trigger('change'); | ||||
| @@ -75,23 +80,23 @@ | ||||
|                 @endif | ||||
|             }, | ||||
|             error: function(error, textStatus, errorThrown) { | ||||
|                 $('#span-loading').remove(); | ||||
|                 $('.create-customer-{{ $rand }} #span-loading').remove(); | ||||
|  | ||||
|                 if (error.responseJSON.name) { | ||||
|                     $("#modal-create-customer input[name='name']").parent().parent().addClass('has-error'); | ||||
|                     $("#modal-create-customer input[name='name']").parent().after('<p class="help-block">' + error.responseJSON.name + '</p>'); | ||||
|                     $(".create-customer-{{ $rand }}#modal-create-customer input[name='name']").parent().parent().addClass('has-error'); | ||||
|                     $(".create-customer-{{ $rand }}#modal-create-customer input[name='name']").parent().after('<p class="help-block">' + error.responseJSON.name + '</p>'); | ||||
|                 } | ||||
|  | ||||
|                 if (error.responseJSON.email) { | ||||
|                     $("#modal-create-customer input[name='email']").parent().parent().addClass('has-error'); | ||||
|                     $("#modal-create-customer input[name='email']").parent().after('<p class="help-block">' + error.responseJSON.email + '</p>'); | ||||
|                     $(".create-customer-{{ $rand }}#modal-create-customer input[name='email']").parent().parent().addClass('has-error'); | ||||
|                     $(".create-customer-{{ $rand }}#modal-create-customer input[name='email']").parent().after('<p class="help-block">' + error.responseJSON.email + '</p>'); | ||||
|                 } | ||||
|  | ||||
|                 if (error.responseJSON.currency_code) { | ||||
|                     $("#modal-create-customer select[name='currency_code']").parent().parent().addClass('has-error'); | ||||
|                     $("#modal-create-customer select[name='currency_code']").parent().after('<p class="help-block">' + error.responseJSON.currency_code + '</p>'); | ||||
|                     $(".create-customer-{{ $rand }}#modal-create-customer select[name='currency_code']").parent().parent().addClass('has-error'); | ||||
|                     $(".create-customer-{{ $rand }}#modal-create-customer select[name='currency_code']").parent().after('<p class="help-block">' + error.responseJSON.currency_code + '</p>'); | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|     }); | ||||
| </script> | ||||
| </script> | ||||
|   | ||||
| @@ -1,13 +1,16 @@ | ||||
| <div class="modal fade" id="modal-add-payment" style="display: none;"> | ||||
| <div class="modal fade add-payment-{{ $rand }}" id="modal-add-payment" style="display: none;"> | ||||
|     <div class="modal-dialog  modal-lg"> | ||||
|         <div class="modal-content"> | ||||
|             <div class="modal-header"> | ||||
|                 <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button> | ||||
|  | ||||
|                 <h4 class="modal-title">{{ trans('general.title.new', ['type' => trans_choice('general.payments', 1)]) }}</h4> | ||||
|             </div> | ||||
|  | ||||
|             <div class="modal-body"> | ||||
|                 <div class="modal-message"></div> | ||||
|                 {!! Form::open(['id' => 'form-add-payment', 'role' => 'form', 'class' => 'form-loading-button']) !!} | ||||
|  | ||||
|                 <div class="row"> | ||||
|                     {{ Form::textGroup('paid_at', trans('general.date'), 'calendar',['id' => 'paid_at', 'class' => 'form-control', 'required' => 'required', 'data-inputmask' => '\'alias\': \'yyyy-mm-dd\'', 'data-mask' => '', 'autocomplete' => 'off'], Date::now()->toDateString()) }} | ||||
|  | ||||
| @@ -34,12 +37,16 @@ | ||||
|  | ||||
|                     {!! Form::hidden('invoice_id', $invoice->id, ['id' => 'invoice_id', 'class' => 'form-control', 'required' => 'required']) !!} | ||||
|                 </div> | ||||
|  | ||||
|                 {!! Form::close() !!} | ||||
|             </div> | ||||
|  | ||||
|             <div class="modal-footer"> | ||||
|                 <div class="pull-left"> | ||||
|                     {!! Form::button('<span class="fa fa-save"></span>  ' . trans('general.save'), ['type' => 'button', 'id' =>'button-add-payment', 'class' => 'btn btn-success button-submit', 'data-loading-text' => trans('general.loading')]) !!} | ||||
|  | ||||
|                     <a href="{{ url('apps/categories/payment-gateway') }}" class="btn btn-default"><span class="fa fa-money"></span>  {{ trans('invoices.accept_payments') }}</a> | ||||
|  | ||||
|                     <button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-times-circle"></span>  {{ trans('general.cancel') }}</button> | ||||
|                 </div> | ||||
|             </div> | ||||
| @@ -48,12 +55,12 @@ | ||||
| </div> | ||||
|  | ||||
| <script type="text/javascript"> | ||||
|     $('#modal-add-payment #amount').focus(); | ||||
|     $('.add-payment-{{ $rand }}#modal-add-payment #amount').focus(); | ||||
|  | ||||
|     $(document).ready(function(){ | ||||
|         $('#modal-add-payment').modal('show'); | ||||
|         $('.add-payment-{{ $rand }}#modal-add-payment').modal('show'); | ||||
|  | ||||
|         $("#modal-add-payment #amount").maskMoney({ | ||||
|         $(".add-payment-{{ $rand }}#modal-add-payment #amount").maskMoney({ | ||||
|             thousands : '{{ $currency->thousands_separator }}', | ||||
|             decimal : '{{ $currency->decimal_mark }}', | ||||
|             precision : {{ $currency->precision }}, | ||||
| @@ -65,9 +72,9 @@ | ||||
|             @endif | ||||
|         }); | ||||
|  | ||||
|         $('#modal-add-payment #amount').trigger('focusout'); | ||||
|         $('.add-payment-{{ $rand }}#modal-add-payment #amount').trigger('focusout'); | ||||
|  | ||||
|         $('#modal-add-payment #paid_at').datepicker({ | ||||
|         $('.add-payment-{{ $rand }}#modal-add-payment #paid_at').datepicker({ | ||||
|             format: 'yyyy-mm-dd', | ||||
|             todayBtn: 'linked', | ||||
|             weekStart: 1, | ||||
| @@ -75,28 +82,28 @@ | ||||
|             language: '{{ language()->getShortCode() }}' | ||||
|         }); | ||||
|  | ||||
|         $("#modal-add-payment #account_id").select2({ | ||||
|         $(".add-payment-{{ $rand }}#modal-add-payment #account_id").select2({ | ||||
|             placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.accounts', 1)]) }}" | ||||
|         }); | ||||
|  | ||||
|         $("#modal-add-payment #payment_method").select2({ | ||||
|         $(".add-payment-{{ $rand }}#modal-add-payment #payment_method").select2({ | ||||
|             placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.payment_methods', 1)]) }}" | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|     $(document).on('change', '#modal-add-payment  #account_id', function (e) { | ||||
|     $(document).on('change', '.add-payment-{{ $rand }}#modal-add-payment  #account_id', function (e) { | ||||
|         $.ajax({ | ||||
|             url: '{{ url("banking/accounts/currency") }}', | ||||
|             type: 'GET', | ||||
|             dataType: 'JSON', | ||||
|             data: 'account_id=' + $(this).val(), | ||||
|             success: function(data) { | ||||
|                 $('#modal-add-payment  #currency').val(data.currency_name); | ||||
|                 $('#modal-add-payment  #currency_code').val(data.currency_code); | ||||
|                 $('.add-payment-{{ $rand }}#modal-add-payment  #currency').val(data.currency_name); | ||||
|                 $('.add-payment-{{ $rand }}#modal-add-payment  #currency_code').val(data.currency_code); | ||||
|  | ||||
|                 amount = $('#modal-add-payment  #amount').maskMoney('unmasked')[0]; | ||||
|                 amount = $('.add-payment-{{ $rand }}#modal-add-payment  #amount').maskMoney('unmasked')[0]; | ||||
|  | ||||
|                 $("#modal-add-payment  #amount").maskMoney({ | ||||
|                 $(".add-payment-{{ $rand }}#modal-add-payment  #amount").maskMoney({ | ||||
|                     thousands : data.thousands_separator, | ||||
|                     decimal : data.decimal_mark, | ||||
|                     precision : data.precision, | ||||
| @@ -105,43 +112,43 @@ | ||||
|                     suffix : (data.symbol_first) ? '' : data.symbol | ||||
|                 }); | ||||
|  | ||||
|                 $('#modal-add-payment  #amount').val(amount); | ||||
|                 $('.add-payment-{{ $rand }}#modal-add-payment  #amount').val(amount); | ||||
|  | ||||
|                 $('#modal-add-payment #amount').focus(); | ||||
|                 $('.add-payment-{{ $rand }}#modal-add-payment #amount').focus(); | ||||
|             } | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|     $(document).on('click', '#button-add-payment', function (e) { | ||||
|         $('.help-block').remove(); | ||||
|     $(document).on('click', '.add-payment-{{ $rand }} #button-add-payment', function (e) { | ||||
|         $('.add-payment-{{ $rand }} .help-block').remove(); | ||||
|  | ||||
|         $.ajax({ | ||||
|             url: '{{ url("modals/invoices/" . $invoice->id . "/payment") }}', | ||||
|             type: 'POST', | ||||
|             dataType: 'JSON', | ||||
|             data: $("#form-add-payment").serialize(), | ||||
|             data: $(".add-payment-{{ $rand }} #form-add-payment").serialize(), | ||||
|             headers: { 'X-CSRF-TOKEN': '{{ csrf_token() }}' }, | ||||
|             beforeSend: function() { | ||||
|                 $('#button-add-payment').button('loading'); | ||||
|                 $('.add-payment-{{ $rand }} #button-add-payment').button('loading'); | ||||
|  | ||||
|                 $('#modal-add-payment .modal-content').append('<div id="loading" class="text-center"><i class="fa fa-spinner fa-spin fa-5x checkout-spin"></i></div>'); | ||||
|                 $('.add-payment-{{ $rand }}#modal-add-payment .modal-content').append('<div id="loading" class="text-center"><i class="fa fa-spinner fa-spin fa-5x checkout-spin"></i></div>'); | ||||
|             }, | ||||
|             complete: function() { | ||||
|                 $('#button-add-payment').button('reset'); | ||||
|                 $('#loading').remove(); | ||||
|                 $('.add-payment-{{ $rand }} #button-add-payment').button('reset'); | ||||
|                 $('.add-payment-{{ $rand }} #loading').remove(); | ||||
|             }, | ||||
|             success: function(json) { | ||||
|                 if (json['error']) { | ||||
|                     $('#modal-add-payment .modal-message').append('<div class="alert alert-danger">' + json['message'] + '</div>'); | ||||
|                     $('div.alert-danger').delay(3000).fadeOut(350); | ||||
|                     $('.add-payment-{{ $rand }}#modal-add-payment .modal-message').append('<div class="alert alert-danger">' + json['message'] + '</div>'); | ||||
|                     $('.add-payment-{{ $rand }} div.alert-danger').delay(3000).fadeOut(350); | ||||
|                 } | ||||
|  | ||||
|                 if (json['success']) { | ||||
|                     $('#modal-add-payment .modal-message').before('<div class="alert alert-success">' + json['message'] + '</div>'); | ||||
|                     $('div.alert-success').delay(3000).fadeOut(350); | ||||
|                     $('.add-payment-{{ $rand }}#modal-add-payment .modal-message').before('<div class="alert alert-success">' + json['message'] + '</div>'); | ||||
|                     $('.add-payment-{{ $rand }} div.alert-success').delay(3000).fadeOut(350); | ||||
|  | ||||
|                     setTimeout(function(){ | ||||
|                         $("#modal-add-payment").modal('hide'); | ||||
|                         $(".add-payment-{{ $rand }}#modal-add-payment").modal('hide'); | ||||
|  | ||||
|                         location.reload(); | ||||
|                     }, 3000); | ||||
| @@ -152,27 +159,27 @@ | ||||
|  | ||||
|                 if (typeof errors !== 'undefined') { | ||||
|                     if (errors.paid_at) { | ||||
|                         $('#modal-add-payment #paid_at').parent().after('<p class="help-block">' + errors.paid_at + '</p>'); | ||||
|                         $('.add-payment-{{ $rand }}#modal-add-payment #paid_at').parent().after('<p class="help-block">' + errors.paid_at + '</p>'); | ||||
|                     } | ||||
|  | ||||
|                     if (errors.amount) { | ||||
|                         $('#modal-add-payment #amount').parent().after('<p class="help-block">' + errors.amount + '</p>'); | ||||
|                         $('.add-payment-{{ $rand }}#modal-add-payment #amount').parent().after('<p class="help-block">' + errors.amount + '</p>'); | ||||
|                     } | ||||
|  | ||||
|                     if (errors.account_id) { | ||||
|                         $('#modal-add-payment #account_id').parent().after('<p class="help-block">' + errors.account_id + '</p>'); | ||||
|                         $('.add-payment-{{ $rand }}#modal-add-payment #account_id').parent().after('<p class="help-block">' + errors.account_id + '</p>'); | ||||
|                     } | ||||
|  | ||||
|                     if (errors.currency_code) { | ||||
|                         $('#modal-add-payment #currency_code').parent().after('<p class="help-block">' + errors.currency_code + '</p>'); | ||||
|                         $('.add-payment-{{ $rand }}#modal-add-payment #currency_code').parent().after('<p class="help-block">' + errors.currency_code + '</p>'); | ||||
|                     } | ||||
|  | ||||
|                     if (errors.category_id) { | ||||
|                         $('#modal-add-payment #category_id').parent().after('<p class="help-block">' + errors.category_id + '</p>'); | ||||
|                         $('.add-payment-{{ $rand }}#modal-add-payment #category_id').parent().after('<p class="help-block">' + errors.category_id + '</p>'); | ||||
|                     } | ||||
|  | ||||
|                     if (errors.payment_method) { | ||||
|                         $('#modal-add-payment #payment_method').parent().after('<p class="help-block">' + errors.payment_method + '</p>'); | ||||
|                         $('.add-payment-{{ $rand }}#modal-add-payment #payment_method').parent().after('<p class="help-block">' + errors.payment_method + '</p>'); | ||||
|                     } | ||||
|                 } | ||||
|             } | ||||
|   | ||||
| @@ -1,11 +1,13 @@ | ||||
| <div class="modal fade" id="modal-create-tax" style="display: none;"> | ||||
| <div class="modal fade create-tax-{{ $rand }}" id="modal-create-tax" style="display: none;"> | ||||
|     <div class="modal-dialog  modal-lg"> | ||||
|         <div class="modal-content"> | ||||
|             <div class="modal-header"> | ||||
|                 <h4 class="modal-title">{{ trans('general.title.new', ['type' => trans_choice('general.taxes', 1)]) }}</h4> | ||||
|             </div> | ||||
|  | ||||
|             <div class="modal-body"> | ||||
|                 {!! Form::open(['id' => 'form-create-tax', 'role' => 'form', 'class' => 'form-loading-button']) !!} | ||||
|  | ||||
|                 <div class="row"> | ||||
|                     {{ Form::textGroup('name', trans('general.name'), 'id-card-o') }} | ||||
|  | ||||
| @@ -15,11 +17,14 @@ | ||||
|  | ||||
|                     {!! Form::hidden('enabled', '1', []) !!} | ||||
|                 </div> | ||||
|  | ||||
|                 {!! Form::close() !!} | ||||
|             </div> | ||||
|  | ||||
|             <div class="modal-footer"> | ||||
|                 <div class="pull-left"> | ||||
|                     {!! Form::button('<span class="fa fa-save"></span>  ' . trans('general.save'), ['type' => 'button', 'id' =>'button-create-tax', 'class' => 'btn btn-success button-submit', 'data-loading-text' => trans('general.loading')]) !!} | ||||
|  | ||||
|                     <button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-times-circle"></span>  {{ trans('general.cancel') }}</button> | ||||
|                 </div> | ||||
|             </div> | ||||
| @@ -29,38 +34,38 @@ | ||||
|  | ||||
| <script type="text/javascript"> | ||||
|     $(document).ready(function(){ | ||||
|         $('#modal-create-tax').modal('show'); | ||||
|         $('.create-tax-{{ $rand }}#modal-create-tax').modal('show'); | ||||
|  | ||||
|         $('#rate').focus(); | ||||
|         $('.create-tax-{{ $rand }} #rate').focus(); | ||||
|  | ||||
|         $("#type").select2({ | ||||
|         $(".create-tax-{{ $rand }} #type").select2({ | ||||
|             placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.types', 1)]) }}" | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|     $(document).on('click', '#button-create-tax', function (e) { | ||||
|         $('#modal-create-tax .modal-header').before('<span id="span-loading" style="position: absolute; height: 100%; width: 100%; z-index: 99; background: #6da252; opacity: 0.4;"><i class="fa fa-spinner fa-spin" style="font-size: 16em !important;margin-left: 35%;margin-top: 8%;"></i></span>'); | ||||
|     $(document).on('click', '.create-tax-{{ $rand }} #button-create-tax', function (e) { | ||||
|         $('.create-tax-{{ $rand }}#modal-create-tax .modal-header').before('<span id="span-loading" style="position: absolute; height: 100%; width: 100%; z-index: 99; background: #6da252; opacity: 0.4;"><i class="fa fa-spinner fa-spin" style="font-size: 16em !important;margin-left: 35%;margin-top: 8%;"></i></span>'); | ||||
|  | ||||
|         $.ajax({ | ||||
|             url: '{{ url("modals/taxes") }}', | ||||
|             type: 'POST', | ||||
|             dataType: 'JSON', | ||||
|             data: $("#form-create-tax").serialize(), | ||||
|             data: $(".create-tax-{{ $rand }} #form-create-tax").serialize(), | ||||
|             beforeSend: function () { | ||||
|                 $('#button-create-tax').button('loading'); | ||||
|                 $('.create-tax-{{ $rand }} #button-create-tax').button('loading'); | ||||
|  | ||||
|                 $(".form-group").removeClass("has-error"); | ||||
|                 $(".help-block").remove(); | ||||
|                 $(".create-tax-{{ $rand }} .form-group").removeClass("has-error"); | ||||
|                 $(".create-tax-{{ $rand }} .help-block").remove(); | ||||
|             }, | ||||
|             complete: function() { | ||||
|                 $('#button-create-tax').button('reset'); | ||||
|                 $('.create-tax-{{ $rand }} #button-create-tax').button('reset'); | ||||
|             }, | ||||
|             success: function(json) { | ||||
|                 var data = json['data']; | ||||
|  | ||||
|                 $('#span-loading').remove(); | ||||
|                 $('.create-tax-{{ $rand }} #span-loading').remove(); | ||||
|  | ||||
|                 $('#modal-create-tax').modal('hide'); | ||||
|                 $('.create-tax-{{ $rand }}#modal-create-tax').modal('hide'); | ||||
|  | ||||
|                 $('#tax_id').append('<option value="' + data.id + '" selected="selected">' + data.name + '</option>'); | ||||
|                 $('#tax_id').trigger('change'); | ||||
| @@ -73,18 +78,18 @@ | ||||
|                 @endif | ||||
|             }, | ||||
|             error: function(error, textStatus, errorThrown) { | ||||
|                 $('#span-loading').remove(); | ||||
|                 $('.create-tax-{{ $rand }} #span-loading').remove(); | ||||
|  | ||||
|                 if (error.responseJSON.name) { | ||||
|                     $("#modal-create-tax input[name='name']").parent().parent().addClass('has-error'); | ||||
|                     $("#modal-create-tax input[name='name']").parent().after('<p class="help-block">' + error.responseJSON.name + '</p>'); | ||||
|                     $(".create-tax-{{ $rand }}#modal-create-tax input[name='name']").parent().parent().addClass('has-error'); | ||||
|                     $(".create-tax-{{ $rand }}#modal-create-tax input[name='name']").parent().after('<p class="help-block">' + error.responseJSON.name + '</p>'); | ||||
|                 } | ||||
|  | ||||
|                 if (error.responseJSON.rate) { | ||||
|                     $("#modal-create-tax input[name='rate']").parent().parent().addClass('has-error'); | ||||
|                     $("#modal-create-tax input[name='rate']").parent().after('<p class="help-block">' + error.responseJSON.rate + '</p>'); | ||||
|                     $(".create-tax-{{ $rand }}#modal-create-tax input[name='rate']").parent().parent().addClass('has-error'); | ||||
|                     $(".create-tax-{{ $rand }}#modal-create-tax input[name='rate']").parent().after('<p class="help-block">' + error.responseJSON.rate + '</p>'); | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|     }); | ||||
| </script> | ||||
| </script> | ||||
|   | ||||
							
								
								
									
										45
									
								
								resources/views/modals/vendors/create.blade.php
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										45
									
								
								resources/views/modals/vendors/create.blade.php
									
									
									
									
										vendored
									
									
								
							| @@ -1,11 +1,13 @@ | ||||
| <div class="modal fade" id="modal-create-vendor" style="display: none;"> | ||||
| <div class="modal fade create-vendor-{{ $rand }}" id="modal-create-vendor" style="display: none;"> | ||||
|     <div class="modal-dialog  modal-lg"> | ||||
|         <div class="modal-content"> | ||||
|             <div class="modal-header"> | ||||
|                 <h4 class="modal-title">{{ trans('general.title.new', ['type' => trans_choice('general.vendors', 1)]) }}</h4> | ||||
|             </div> | ||||
|  | ||||
|             <div class="modal-body"> | ||||
|                 {!! Form::open(['id' => 'form-create-vendor', 'role' => 'form', 'class' => 'form-loading-button']) !!} | ||||
|  | ||||
|                 <div class="row"> | ||||
|                     {{ Form::textGroup('name', trans('general.name'), 'id-card-o') }} | ||||
|  | ||||
| @@ -19,11 +21,14 @@ | ||||
|  | ||||
|                     {!! Form::hidden('enabled', '1', []) !!} | ||||
|                 </div> | ||||
|  | ||||
|                 {!! Form::close() !!} | ||||
|             </div> | ||||
|  | ||||
|             <div class="modal-footer"> | ||||
|                 <div class="pull-left"> | ||||
|                     {!! Form::button('<span class="fa fa-save"></span>  ' . trans('general.save'), ['type' => 'button', 'id' =>'button-create-vendor', 'class' => 'btn btn-success button-submit', 'data-loading-text' => trans('general.loading')]) !!} | ||||
|  | ||||
|                     <button type="button" class="btn btn-default" data-dismiss="modal"><span class="fa fa-times-circle"></span>  {{ trans('general.cancel') }}</button> | ||||
|                 </div> | ||||
|             </div> | ||||
| @@ -33,36 +38,36 @@ | ||||
|  | ||||
| <script type="text/javascript"> | ||||
|     $(document).ready(function(){ | ||||
|         $('#modal-create-vendor').modal('show'); | ||||
|         $('.create-vendor-{{ $rand }}#modal-create-vendor').modal('show'); | ||||
|  | ||||
|         $("#modal-create-vendor #currency_code").select2({ | ||||
|         $(".create-vendor-{{ $rand }}#modal-create-vendor #currency_code").select2({ | ||||
|             placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.currencies', 1)]) }}" | ||||
|         }); | ||||
|     }); | ||||
|  | ||||
|     $(document).on('click', '#button-create-vendor', function (e) { | ||||
|         $('#modal-create-vendor .modal-header').before('<span id="span-loading" style="position: absolute; height: 100%; width: 100%; z-index: 99; background: #6da252; opacity: 0.4;"><i class="fa fa-spinner fa-spin" style="font-size: 16em !important;margin-left: 35%;margin-top: 8%;"></i></span>'); | ||||
|     $(document).on('click', '.create-vendor-{{ $rand }} #button-create-vendor', function (e) { | ||||
|         $('.create-vendor-{{ $rand }}#modal-create-vendor .modal-header').before('<span id="span-loading" style="position: absolute; height: 100%; width: 100%; z-index: 99; background: #6da252; opacity: 0.4;"><i class="fa fa-spinner fa-spin" style="font-size: 16em !important;margin-left: 35%;margin-top: 8%;"></i></span>'); | ||||
|  | ||||
|         $.ajax({ | ||||
|             url: '{{ url("modals/vendors") }}', | ||||
|             type: 'POST', | ||||
|             dataType: 'JSON', | ||||
|             data: $("#form-create-vendor").serialize(), | ||||
|             data: $(".create-vendor-{{ $rand }} #form-create-vendor").serialize(), | ||||
|             beforeSend: function () { | ||||
|                 $('#button-create-vendor').button('loading'); | ||||
|                 $('.create-vendor-{{ $rand }} #button-create-vendor').button('loading'); | ||||
|  | ||||
|                 $(".form-group").removeClass("has-error"); | ||||
|                 $(".help-block").remove(); | ||||
|                 $(".create-vendor-{{ $rand }} .form-group").removeClass("has-error"); | ||||
|                 $(".create-vendor-{{ $rand }} .help-block").remove(); | ||||
|             }, | ||||
|             complete: function() { | ||||
|                 $('#button-create-vendor').button('reset'); | ||||
|                 $('.create-vendor-{{ $rand }} #button-create-vendor').button('reset'); | ||||
|             }, | ||||
|             success: function(json) { | ||||
|                 var data = json['data']; | ||||
|  | ||||
|                 $('#span-loading').remove(); | ||||
|                 $('.create-vendor-{{ $rand }} #span-loading').remove(); | ||||
|  | ||||
|                 $('#modal-create-vendor').modal('hide'); | ||||
|                 $('.create-vendor-{{ $rand }}#modal-create-vendor').modal('hide'); | ||||
|  | ||||
|                 $('#vendor_id').append('<option value="' + data.id + '" selected="selected">' + data.name + '</option>'); | ||||
|                 $('#vendor_id').trigger('change'); | ||||
| @@ -75,23 +80,23 @@ | ||||
|                 @endif | ||||
|             }, | ||||
|             error: function(error, textStatus, errorThrown) { | ||||
|                 $('#span-loading').remove(); | ||||
|                 $('.create-vendor-{{ $rand }} #span-loading').remove(); | ||||
|  | ||||
|                 if (error.responseJSON.name) { | ||||
|                     $("#modal-create-vendor input[name='name']").parent().parent().addClass('has-error'); | ||||
|                     $("#modal-create-vendor input[name='name']").parent().after('<p class="help-block">' + error.responseJSON.name + '</p>'); | ||||
|                     $(".create-vendor-{{ $rand }}#modal-create-vendor input[name='name']").parent().parent().addClass('has-error'); | ||||
|                     $(".create-vendor-{{ $rand }}#modal-create-vendor input[name='name']").parent().after('<p class="help-block">' + error.responseJSON.name + '</p>'); | ||||
|                 } | ||||
|  | ||||
|                 if (error.responseJSON.email) { | ||||
|                     $("#modal-create-vendor input[name='email']").parent().parent().addClass('has-error'); | ||||
|                     $("#modal-create-vendor input[name='email']").parent().after('<p class="help-block">' + error.responseJSON.email + '</p>'); | ||||
|                     $(".create-vendor-{{ $rand }}#modal-create-vendor input[name='email']").parent().parent().addClass('has-error'); | ||||
|                     $(".create-vendor-{{ $rand }}#modal-create-vendor input[name='email']").parent().after('<p class="help-block">' + error.responseJSON.email + '</p>'); | ||||
|                 } | ||||
|  | ||||
|                 if (error.responseJSON.currency_code) { | ||||
|                     $("#modal-create-vendor select[name='currency_code']").parent().parent().addClass('has-error'); | ||||
|                     $("#modal-create-vendor select[name='currency_code']").parent().after('<p class="help-block">' + error.responseJSON.currency_code + '</p>'); | ||||
|                     $(".create-vendor-{{ $rand }}#modal-create-vendor select[name='currency_code']").parent().parent().addClass('has-error'); | ||||
|                     $(".create-vendor-{{ $rand }}#modal-create-vendor select[name='currency_code']").parent().after('<p class="help-block">' + error.responseJSON.currency_code + '</p>'); | ||||
|                 } | ||||
|             } | ||||
|         }); | ||||
|     }); | ||||
| </script> | ||||
| </script> | ||||
|   | ||||
		Reference in New Issue
	
	Block a user