From e9c7402138b3c4ebe6c4557727a44a73ad91cc10 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=BCneyt=20=C5=9Eent=C3=BCrk?= Date: Tue, 20 Nov 2018 11:57:44 +0300 Subject: [PATCH] Invoice/Bill create/edit page javascript code line changes. --- .../views/expenses/bills/create.blade.php | 42 +++-- resources/views/expenses/bills/edit.blade.php | 134 ++++++++-------- .../views/incomes/invoices/create.blade.php | 114 +++++++------- .../views/incomes/invoices/edit.blade.php | 144 +++++++++--------- 4 files changed, 213 insertions(+), 221 deletions(-) diff --git a/resources/views/expenses/bills/create.blade.php b/resources/views/expenses/bills/create.blade.php index 67046ee68..12a2055e4 100644 --- a/resources/views/expenses/bills/create.blade.php +++ b/resources/views/expenses/bills/create.blade.php @@ -174,9 +174,7 @@ var item_row = '{{ $item_row }}'; var autocomplete_path = "{{ url('common/items/autocomplete') }}"; - $(document).ready(function(){ - var currency_code = $('#currency_code').val(); - + $(document).ready(function() { @if (old('item')) $('#vendor_id').trigger('change'); @endif @@ -258,7 +256,7 @@ url: '{{ url("expenses/bills/addItem") }}', type: 'GET', dataType: 'JSON', - data: {item_row: item_row, currency_code : currency_code}, + data: {item_row: item_row, currency_code : $('#currency_code').val()}, success: function(json) { if (json['success']) { $('#items tbody #addItem').before(json['html']); @@ -300,24 +298,6 @@ }); }); - $(document).on('click', '#tax-add-new', function(e){ - tax_name = $('.select2-search__field').val(); - - $('#modal-create-tax').remove(); - - $.ajax({ - url: '{{ url("modals/taxes/create") }}', - type: 'GET', - dataType: 'JSON', - data: {name: tax_name}, - success: function(json) { - if (json['success']) { - $('body').append(json['html']); - } - } - }); - }); - $(document).on('click', '.form-control.typeahead', function() { input_id = $(this).attr('id').split('-'); @@ -356,6 +336,24 @@ }); }); + $(document).on('click', '#tax-add-new', function(e) { + tax_name = $('.select2-search__field').val(); + + $('#modal-create-tax').remove(); + + $.ajax({ + url: '{{ url("modals/taxes/create") }}', + type: 'GET', + dataType: 'JSON', + data: {name: tax_name}, + success: function(json) { + if (json['success']) { + $('body').append(json['html']); + } + } + }); + }); + $('a[rel=popover]').popover({ html: true, placement: 'bottom', diff --git a/resources/views/expenses/bills/edit.blade.php b/resources/views/expenses/bills/edit.blade.php index 7e940bf04..cd52b2f8c 100644 --- a/resources/views/expenses/bills/edit.blade.php +++ b/resources/views/expenses/bills/edit.blade.php @@ -155,74 +155,7 @@ var item_row = '{{ $item_row }}'; var autocomplete_path = "{{ url('common/items/autocomplete') }}"; - $(document).on('click', '#button-add-item', function (e) { - $.ajax({ - url: '{{ url("expenses/bills/addItem") }}', - type: 'GET', - dataType: 'JSON', - data: {item_row: item_row, currency_code : currency_code}, - success: function(json) { - if (json['success']) { - $('#items tbody #addItem').before(json['html']); - //$('[rel=tooltip]').tooltip(); - - $('[data-toggle="tooltip"]').tooltip('hide'); - - $('#item-row-' + item_row + ' .tax-select2').select2({ - placeholder: { - id: '-1', // the value of the option - text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}" - }, - escapeMarkup: function (markup) { - return markup; - }, - language: { - noResults: function () { - return ' {{ trans('general.title.new', ['type' => trans_choice('general.tax_rates', 1)]) }}'; - } - } - }); - - var currency = json['data']['currency']; - - $('#item-price-' + item_row).maskMoney({ - thousands : currency.thousands_separator, - decimal : currency.decimal_mark, - precision : currency.precision, - allowZero : true, - prefix : (currency.symbol_first) ? currency.symbol : '', - suffix : (currency.symbol_first) ? '' : currency.symbol - }); - - $('#item-price-' + item_row).trigger('focusout'); - - item_row++; - } - } - }); - }); - - $(document).on('click', '#tax-add-new', function(e){ - tax_name = $('.select2-search__field').val(); - - $('#modal-create-tax').remove(); - - $.ajax({ - url: '{{ url("modals/taxes/create") }}', - type: 'GET', - dataType: 'JSON', - data: {name: tax_name}, - success: function(json) { - if (json['success']) { - $('body').append(json['html']); - } - } - }); - }); - - $(document).ready(function(){ - var currency_code = $('#currency_code').val(); - + $(document).ready(function() { $('#vendor_id').trigger('change'); itemTableResize(); @@ -326,6 +259,53 @@ }); @endif + $(document).on('click', '#button-add-item', function (e) { + $.ajax({ + url: '{{ url("expenses/bills/addItem") }}', + type: 'GET', + dataType: 'JSON', + data: {item_row: item_row, currency_code : $('#currency_code').val()}, + success: function(json) { + if (json['success']) { + $('#items tbody #addItem').before(json['html']); + //$('[rel=tooltip]').tooltip(); + + $('[data-toggle="tooltip"]').tooltip('hide'); + + $('#item-row-' + item_row + ' .tax-select2').select2({ + placeholder: { + id: '-1', // the value of the option + text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}" + }, + escapeMarkup: function (markup) { + return markup; + }, + language: { + noResults: function () { + return ' {{ trans('general.title.new', ['type' => trans_choice('general.tax_rates', 1)]) }}'; + } + } + }); + + var currency = json['data']['currency']; + + $('#item-price-' + item_row).maskMoney({ + thousands : currency.thousands_separator, + decimal : currency.decimal_mark, + precision : currency.precision, + allowZero : true, + prefix : (currency.symbol_first) ? currency.symbol : '', + suffix : (currency.symbol_first) ? '' : currency.symbol + }); + + $('#item-price-' + item_row).trigger('focusout'); + + item_row++; + } + } + }); + }); + $(document).on('click', '.form-control.typeahead', function() { input_id = $(this).attr('id').split('-'); @@ -364,6 +344,24 @@ }); }); + $(document).on('click', '#tax-add-new', function(e) { + tax_name = $('.select2-search__field').val(); + + $('#modal-create-tax').remove(); + + $.ajax({ + url: '{{ url("modals/taxes/create") }}', + type: 'GET', + dataType: 'JSON', + data: {name: tax_name}, + success: function(json) { + if (json['success']) { + $('body').append(json['html']); + } + } + }); + }); + $('a[rel=popover]').popover({ html: true, placement: 'bottom', diff --git a/resources/views/incomes/invoices/create.blade.php b/resources/views/incomes/invoices/create.blade.php index e4c3e86f0..aa75cebc7 100644 --- a/resources/views/incomes/invoices/create.blade.php +++ b/resources/views/incomes/invoices/create.blade.php @@ -174,56 +174,7 @@ var item_row = '{{ $item_row }}'; var autocomplete_path = "{{ url('common/items/autocomplete') }}"; - $(document).on('click', '#button-add-item', function (e) { - $.ajax({ - url: '{{ url("incomes/invoices/addItem") }}', - type: 'GET', - dataType: 'JSON', - data: {item_row: item_row, currency_code : currency_code}, - success: function(json) { - if (json['success']) { - $('#items tbody #addItem').before(json['html']); - //$('[rel=tooltip]').tooltip(); - - $('[data-toggle="tooltip"]').tooltip('hide'); - - $('#item-row-' + item_row + ' .tax-select2').select2({ - placeholder: { - id: '-1', // the value of the option - text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}" - }, - escapeMarkup: function (markup) { - return markup; - }, - language: { - noResults: function () { - return ' {{ trans('general.title.new', ['type' => trans_choice('general.tax_rates', 1)]) }}'; - } - } - }); - - var currency = json['data']['currency']; - - $('#item-price-' + item_row).maskMoney({ - thousands : currency.thousands_separator, - decimal : currency.decimal_mark, - precision : currency.precision, - allowZero : true, - prefix : (currency.symbol_first) ? currency.symbol : '', - suffix : (currency.symbol_first) ? '' : currency.symbol - }); - - $('#item-price-' + item_row).trigger('focusout'); - - item_row++; - } - } - }); - }); - - $(document).ready(function(){ - var currency_code = $('#currency_code').val(); - + $(document).ready(function() { itemTableResize(); @if (old('item')) @@ -300,19 +251,48 @@ @endif }); - $(document).on('click', '#tax-add-new', function(e){ - tax_name = $('.select2-search__field').val(); - - $('#modal-create-tax').remove(); - + $(document).on('click', '#button-add-item', function (e) { $.ajax({ - url: '{{ url("modals/taxes/create") }}', + url: '{{ url("incomes/invoices/addItem") }}', type: 'GET', dataType: 'JSON', - data: {name: tax_name}, + data: {item_row: item_row, currency_code : $('#currency_code').val()}, success: function(json) { if (json['success']) { - $('body').append(json['html']); + $('#items tbody #addItem').before(json['html']); + //$('[rel=tooltip]').tooltip(); + + $('[data-toggle="tooltip"]').tooltip('hide'); + + $('#item-row-' + item_row + ' .tax-select2').select2({ + placeholder: { + id: '-1', // the value of the option + text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}" + }, + escapeMarkup: function (markup) { + return markup; + }, + language: { + noResults: function () { + return ' {{ trans('general.title.new', ['type' => trans_choice('general.tax_rates', 1)]) }}'; + } + } + }); + + var currency = json['data']['currency']; + + $('#item-price-' + item_row).maskMoney({ + thousands : currency.thousands_separator, + decimal : currency.decimal_mark, + precision : currency.precision, + allowZero : true, + prefix : (currency.symbol_first) ? currency.symbol : '', + suffix : (currency.symbol_first) ? '' : currency.symbol + }); + + $('#item-price-' + item_row).trigger('focusout'); + + item_row++; } } }); @@ -356,6 +336,24 @@ }); }); + $(document).on('click', '#tax-add-new', function(e) { + tax_name = $('.select2-search__field').val(); + + $('#modal-create-tax').remove(); + + $.ajax({ + url: '{{ url("modals/taxes/create") }}', + type: 'GET', + dataType: 'JSON', + data: {name: tax_name}, + success: function(json) { + if (json['success']) { + $('body').append(json['html']); + } + } + }); + }); + $('a[rel=popover]').popover({ html: true, placement: 'bottom', diff --git a/resources/views/incomes/invoices/edit.blade.php b/resources/views/incomes/invoices/edit.blade.php index 7b972f7e3..c2840cab2 100644 --- a/resources/views/incomes/invoices/edit.blade.php +++ b/resources/views/incomes/invoices/edit.blade.php @@ -259,83 +259,12 @@ }); @endif - $(document).on('click', '.form-control.typeahead', function() { - input_id = $(this).attr('id').split('-'); - - item_id = parseInt(input_id[input_id.length-1]); - - $(this).typeahead({ - minLength: 3, - displayText:function (data) { - return data.name + ' (' + data.sku + ')'; - }, - source: function (query, process) { - $.ajax({ - url: autocomplete_path, - type: 'GET', - dataType: 'JSON', - data: 'query=' + query + '&type=invoice¤cy_code=' + $('#currency_code').val(), - success: function(data) { - return process(data); - } - }); - }, - afterSelect: function (data) { - $('#item-id-' + item_id).val(data.item_id); - $('#item-quantity-' + item_id).val('1'); - $('#item-price-' + item_id).val(data.sale_price); - $('#item-tax-' + item_id).val(data.tax_id); - - // This event Select2 Stylesheet - $('#item-price-' + item_id).trigger('focusout'); - $('#item-tax-' + item_id).trigger('change'); - - $('#item-total-' + item_id).html(data.total); - - totalItem(); - } - }); - }); - - $('a[rel=popover]').popover({ - html: true, - placement: 'bottom', - title: '{{ trans('invoices.discount') }}', - content: function () { - html = '
'; - html += '
'; - html += '
'; - html += ' {!! Form::number('pre-discount', null, ['id' => 'pre-discount', 'class' => 'form-control text-right']) !!}'; - html += '
'; - html += '
'; - html += '
'; - html += '
'; - html += '
'; - html += ' {{ trans('invoices.discount_desc') }}'; - html += '
'; - html += '
'; - html += '
'; - html += ''; - - return html; - } - }); - $(document).on('click', '#button-add-item', function (e) { - var currency_code = $('#currency_code').val(); - $.ajax({ url: '{{ url("incomes/invoices/addItem") }}', type: 'GET', dataType: 'JSON', - data: {item_row: item_row, currency_code : currency_code}, + data: {item_row: item_row, currency_code : $('#currency_code').val()}, success: function(json) { if (json['success']) { $('#items tbody #addItem').before(json['html']); @@ -377,7 +306,45 @@ }); }); - $(document).on('click', '#tax-add-new', function(e){ + $(document).on('click', '.form-control.typeahead', function() { + input_id = $(this).attr('id').split('-'); + + item_id = parseInt(input_id[input_id.length-1]); + + $(this).typeahead({ + minLength: 3, + displayText:function (data) { + return data.name + ' (' + data.sku + ')'; + }, + source: function (query, process) { + $.ajax({ + url: autocomplete_path, + type: 'GET', + dataType: 'JSON', + data: 'query=' + query + '&type=invoice¤cy_code=' + $('#currency_code').val(), + success: function(data) { + return process(data); + } + }); + }, + afterSelect: function (data) { + $('#item-id-' + item_id).val(data.item_id); + $('#item-quantity-' + item_id).val('1'); + $('#item-price-' + item_id).val(data.sale_price); + $('#item-tax-' + item_id).val(data.tax_id); + + // This event Select2 Stylesheet + $('#item-price-' + item_id).trigger('focusout'); + $('#item-tax-' + item_id).trigger('change'); + + $('#item-total-' + item_id).html(data.total); + + totalItem(); + } + }); + }); + + $(document).on('click', '#tax-add-new', function(e) { tax_name = $('.select2-search__field').val(); $('#modal-create-tax').remove(); @@ -395,6 +362,37 @@ }); }); + $('a[rel=popover]').popover({ + html: true, + placement: 'bottom', + title: '{{ trans('invoices.discount') }}', + content: function () { + html = '
'; + html += '
'; + html += '
'; + html += ' {!! Form::number('pre-discount', null, ['id' => 'pre-discount', 'class' => 'form-control text-right']) !!}'; + html += '
'; + html += '
'; + html += '
'; + html += '
'; + html += '
'; + html += ' {{ trans('invoices.discount_desc') }}'; + html += '
'; + html += '
'; + html += '
'; + html += ''; + + return html; + } + }); + $(document).on('keyup', '#pre-discount', function(e){ e.preventDefault();