Invoice/Bill create/edit page javascript code line changes.
This commit is contained in:
		@@ -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',
 | 
			
		||||
 
 | 
			
		||||
@@ -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 '<span id="tax-add-new"><i class="fa fa-plus"> {{ trans('general.title.new', ['type' => trans_choice('general.tax_rates', 1)]) }}</span>';
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        });
 | 
			
		||||
 | 
			
		||||
                        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 '<span id="tax-add-new"><i class="fa fa-plus"> {{ trans('general.title.new', ['type' => trans_choice('general.tax_rates', 1)]) }}</span>';
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        });
 | 
			
		||||
 | 
			
		||||
                        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',
 | 
			
		||||
 
 | 
			
		||||
@@ -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 '<span id="tax-add-new"><i class="fa fa-plus"> {{ trans('general.title.new', ['type' => trans_choice('general.tax_rates', 1)]) }}</span>';
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        });
 | 
			
		||||
 | 
			
		||||
                        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 '<span id="tax-add-new"><i class="fa fa-plus"> {{ trans('general.title.new', ['type' => trans_choice('general.tax_rates', 1)]) }}</span>';
 | 
			
		||||
                                }
 | 
			
		||||
                            }
 | 
			
		||||
                        });
 | 
			
		||||
 | 
			
		||||
                        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',
 | 
			
		||||
 
 | 
			
		||||
@@ -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  = '<div class="discount box-body">';
 | 
			
		||||
                html += '    <div class="col-md-6">';
 | 
			
		||||
                html += '        <div class="input-group" id="input-discount">';
 | 
			
		||||
                html += '            {!! Form::number('pre-discount', null, ['id' => 'pre-discount', 'class' => 'form-control text-right']) !!}';
 | 
			
		||||
                html += '            <div class="input-group-addon"><i class="fa fa-percent"></i></div>';
 | 
			
		||||
                html += '        </div>';
 | 
			
		||||
                html += '    </div>';
 | 
			
		||||
                html += '    <div class="col-md-6">';
 | 
			
		||||
                html += '        <div class="discount-description">';
 | 
			
		||||
                html += '           {{ trans('invoices.discount_desc') }}';
 | 
			
		||||
                html += '        </div>';
 | 
			
		||||
                html += '    </div>';
 | 
			
		||||
                html += '</div>';
 | 
			
		||||
                html += '<div class="discount box-footer">';
 | 
			
		||||
                html += '    <div class="col-md-12">';
 | 
			
		||||
                html += '        <div class="form-group no-margin">';
 | 
			
		||||
                html += '            {!! Form::button('<span class="fa fa-save"></span>  ' . trans('general.save'), ['type' => 'button', 'id' => 'save-discount','class' => 'btn btn-success']) !!}';
 | 
			
		||||
                html += '            <a href="javascript:void(0)" id="cancel-discount" class="btn btn-default"><span class="fa fa-times-circle"></span>  {{ trans('general.cancel') }}</a>';
 | 
			
		||||
                html += '       </div>';
 | 
			
		||||
                html += '    </div>';
 | 
			
		||||
                html += '</div>';
 | 
			
		||||
 | 
			
		||||
                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  = '<div class="discount box-body">';
 | 
			
		||||
                html += '    <div class="col-md-6">';
 | 
			
		||||
                html += '        <div class="input-group" id="input-discount">';
 | 
			
		||||
                html += '            {!! Form::number('pre-discount', null, ['id' => 'pre-discount', 'class' => 'form-control text-right']) !!}';
 | 
			
		||||
                html += '            <div class="input-group-addon"><i class="fa fa-percent"></i></div>';
 | 
			
		||||
                html += '        </div>';
 | 
			
		||||
                html += '    </div>';
 | 
			
		||||
                html += '    <div class="col-md-6">';
 | 
			
		||||
                html += '        <div class="discount-description">';
 | 
			
		||||
                html += '           {{ trans('invoices.discount_desc') }}';
 | 
			
		||||
                html += '        </div>';
 | 
			
		||||
                html += '    </div>';
 | 
			
		||||
                html += '</div>';
 | 
			
		||||
                html += '<div class="discount box-footer">';
 | 
			
		||||
                html += '    <div class="col-md-12">';
 | 
			
		||||
                html += '        <div class="form-group no-margin">';
 | 
			
		||||
                html += '            {!! Form::button('<span class="fa fa-save"></span>  ' . trans('general.save'), ['type' => 'button', 'id' => 'save-discount','class' => 'btn btn-success']) !!}';
 | 
			
		||||
                html += '            <a href="javascript:void(0)" id="cancel-discount" class="btn btn-default"><span class="fa fa-times-circle"></span>  {{ trans('general.cancel') }}</a>';
 | 
			
		||||
                html += '       </div>';
 | 
			
		||||
                html += '    </div>';
 | 
			
		||||
                html += '</div>';
 | 
			
		||||
 | 
			
		||||
                return html;
 | 
			
		||||
            }
 | 
			
		||||
        });
 | 
			
		||||
 | 
			
		||||
        $(document).on('keyup', '#pre-discount', function(e){
 | 
			
		||||
            e.preventDefault();
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user