close #620 Fixed: Invoice/Bill edit not change customer/vendor information

This commit is contained in:
cuneytsenturk 2018-11-12 12:04:01 +03:00
parent 393fb6ede7
commit 0a5d945452
6 changed files with 895 additions and 961 deletions

View File

@ -170,65 +170,19 @@
@push('scripts') @push('scripts')
<script type="text/javascript"> <script type="text/javascript">
var focus = false;
var item_row = '{{ $item_row }}'; var item_row = '{{ $item_row }}';
$(document).on('click', '#button-add-item', function (e) {
var currency_code = $('#currency_code').val(); var currency_code = $('#currency_code').val();
var autocomplete_path = "{{ url('common/items/autocomplete') }}";
$.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).ready(function(){ $(document).ready(function(){
itemTableResize();
@if (old('item')) @if (old('item'))
$('#vendor_id').trigger('change'); $('#vendor_id').trigger('change');
@endif @endif
$(".input-price").maskMoney({ itemTableResize();
$('.input-price').maskMoney({
thousands : '{{ $currency->thousands_separator }}', thousands : '{{ $currency->thousands_separator }}',
decimal : '{{ $currency->decimal_mark }}', decimal : '{{ $currency->decimal_mark }}',
precision : {{ $currency->precision }}, precision : {{ $currency->precision }},
@ -260,7 +214,7 @@
language: '{{ language()->getShortCode() }}' language: '{{ language()->getShortCode() }}'
}); });
$(".tax-select2").select2({ $('.tax-select2').select2({
placeholder: { placeholder: {
id: '-1', // the value of the option id: '-1', // the value of the option
text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}" text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}"
@ -275,15 +229,15 @@
} }
}); });
$("#vendor_id").select2({ $('#vendor_id').select2({
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.vendors', 1)]) }}" placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.vendors', 1)]) }}"
}); });
$("#currency_code").select2({ $('#currency_code').select2({
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.currencies', 1)]) }}" placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.currencies', 1)]) }}"
}); });
$("#category_id").select2({ $('#category_id').select2({
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.categories', 1)]) }}" placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.categories', 1)]) }}"
}); });
@ -293,6 +247,58 @@
placeholder : '{{ trans('general.form.no_file_selected') }}' placeholder : '{{ trans('general.form.no_file_selected') }}'
}); });
@if(old('item'))
totalItem();
@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},
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){ $(document).on('click', '#tax-add-new', function(e){
tax_name = $('.select2-search__field').val(); tax_name = $('.select2-search__field').val();
@ -311,8 +317,6 @@
}); });
}); });
var autocomplete_path = "{{ url('common/items/autocomplete') }}";
$(document).on('click', '.form-control.typeahead', function() { $(document).on('click', '.form-control.typeahead', function() {
input_id = $(this).attr('id').split('-'); input_id = $(this).attr('id').split('-');
@ -406,8 +410,6 @@
totalItem(); totalItem();
}); });
var focus = false;
$(document).on('focusin', '#items .input-price', function(){ $(document).on('focusin', '#items .input-price', function(){
focus = true; focus = true;
}); });
@ -470,9 +472,35 @@
}); });
}); });
@if(old('item')) $(document).on('click', '#button-vendor', function (e) {
totalItem(); $('#modal-create-vendor').remove();
@endif
$.ajax({
url: '{{ url("modals/vendors/create") }}',
type: 'GET',
dataType: 'JSON',
success: function(json) {
if (json['success']) {
$('body').append(json['html']);
}
}
});
});
$(document).on('click', '#button-category', function (e) {
$('#modal-create-category').remove();
$.ajax({
url: '{{ url("modals/categories/create") }}',
type: 'GET',
dataType: 'JSON',
data: {type: 'expense'},
success: function(json) {
if (json['success']) {
$('body').append(json['html']);
}
}
});
}); });
function totalItem() { function totalItem() {
@ -520,36 +548,5 @@
} }
}); });
} }
$(document).on('click', '#button-vendor', function (e) {
$('#modal-create-vendor').remove();
$.ajax({
url: '{{ url("modals/vendors/create") }}',
type: 'GET',
dataType: 'JSON',
success: function(json) {
if (json['success']) {
$('body').append(json['html']);
}
}
});
});
$(document).on('click', '#button-category', function (e) {
$('#modal-create-category').remove();
$.ajax({
url: '{{ url("modals/categories/create") }}',
type: 'GET',
dataType: 'JSON',
data: {type: 'expense'},
success: function(json) {
if (json['success']) {
$('body').append(json['html']);
}
}
});
});
</script> </script>
@endpush @endpush

View File

@ -151,11 +151,12 @@
@push('scripts') @push('scripts')
<script type="text/javascript"> <script type="text/javascript">
var focus = false;
var item_row = '{{ $item_row }}'; var item_row = '{{ $item_row }}';
var currency_code = $('#currency_code').val();
var autocomplete_path = "{{ url('common/items/autocomplete') }}";
$(document).on('click', '#button-add-item', function (e) { $(document).on('click', '#button-add-item', function (e) {
var currency_code = $('#currency_code').val();
$.ajax({ $.ajax({
url: '{{ url("expenses/bills/addItem") }}', url: '{{ url("expenses/bills/addItem") }}',
type: 'GET', type: 'GET',
@ -185,7 +186,7 @@
var currency = json['data']['currency']; var currency = json['data']['currency'];
$("#item-price-" + item_row).maskMoney({ $('#item-price-' + item_row).maskMoney({
thousands : currency.thousands_separator, thousands : currency.thousands_separator,
decimal : currency.decimal_mark, decimal : currency.decimal_mark,
precision : currency.precision, precision : currency.precision,
@ -194,7 +195,7 @@
suffix : (currency.symbol_first) ? '' : currency.symbol suffix : (currency.symbol_first) ? '' : currency.symbol
}); });
$("#item-price-" + item_row).trigger('focusout'); $('#item-price-' + item_row).trigger('focusout');
item_row++; item_row++;
} }
@ -221,13 +222,11 @@
}); });
$(document).ready(function(){ $(document).ready(function(){
$('#vendor_id').trigger('change');
itemTableResize(); itemTableResize();
@if (old('item')) $('.input-price').maskMoney({
$('#vendor_id').trigger('change');
@endif
$(".input-price").maskMoney({
thousands : '{{ $currency->thousands_separator }}', thousands : '{{ $currency->thousands_separator }}',
decimal : '{{ $currency->decimal_mark }}', decimal : '{{ $currency->decimal_mark }}',
precision : {{ $currency->precision }}, precision : {{ $currency->precision }},
@ -261,7 +260,7 @@
language: '{{ language()->getShortCode() }}' language: '{{ language()->getShortCode() }}'
}); });
$(".tax-select2").select2({ $('.tax-select2').select2({
placeholder: { placeholder: {
id: '-1', // the value of the option id: '-1', // the value of the option
text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}" text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}"
@ -276,15 +275,15 @@
} }
}); });
$("#vendor_id").select2({ $('#vendor_id').select2({
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.vendors', 1)]) }}" placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.vendors', 1)]) }}"
}); });
$("#currency_code").select2({ $('#currency_code').select2({
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.currencies', 1)]) }}" placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.currencies', 1)]) }}"
}); });
$("#category_id").select2({ $('#category_id').select2({
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.categories', 1)]) }}" placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.categories', 1)]) }}"
}); });
@ -313,14 +312,19 @@
attachment_html += '</span>'; attachment_html += '</span>';
$('.fancy-file .fake-file').append(attachment_html); $('.fancy-file .fake-file').append(attachment_html);
@endif
@if(old('item'))
totalItem();
@endif
});
@if($bill->attachment)
$(document).on('click', '#remove-attachment', function (e) { $(document).on('click', '#remove-attachment', function (e) {
confirmDelete("#attachment-{!! $bill->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $bill->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); confirmDelete("#attachment-{!! $bill->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $bill->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
}); });
@endif @endif
var autocomplete_path = "{{ url('common/items/autocomplete') }}";
$(document).on('click', '.form-control.typeahead', function() { $(document).on('click', '.form-control.typeahead', function() {
input_id = $(this).attr('id').split('-'); input_id = $(this).attr('id').split('-');
@ -414,7 +418,6 @@
totalItem(); totalItem();
}); });
var focus = false;
$(document).on('focusin', '#items .input-price', function(){ $(document).on('focusin', '#items .input-price', function(){
focus = true; focus = true;
}); });
@ -477,11 +480,6 @@
}); });
}); });
@if(old('item'))
totalItem();
@endif
});
function totalItem() { function totalItem() {
$.ajax({ $.ajax({
url: '{{ url("common/items/totalItem") }}', url: '{{ url("common/items/totalItem") }}',

View File

@ -446,39 +446,11 @@
@push('scripts') @push('scripts')
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){
$(document).on('click', '#button-email', function (e) {
$('#email-modal').remove();
var html = '<div class="modal fade" id="email-modal" tabindex="-1" role="dialog" aria-labelledby="emailModalLabel">';
html += ' <div class="modal-dialog" role="document">';
html += ' <div class="modal-content">';
html += ' <div class="modal-header">';
html += ' <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
html += ' <h4 class="modal-title" id="emailModalLabel">Overflowing text</h4>';
html += ' </div>';
html += ' <div class="modal-body">';
html += ' {{ trans('general.na') }}';
html += ' </div>';
html += ' <div class="modal-footer">';
html += ' <button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('general.cancel') }}</button>';
html += ' <button type="button" class="btn btn-success">Save changes</button>';
html += ' </div>';
html += ' </div>';
html += ' </div>';
html += '</div>';
$('body').append(html);
$('#email-modal').modal('show');
});
@if($bill->attachment) @if($bill->attachment)
$(document).on('click', '#remove-attachment', function (e) { $(document).on('click', '#remove-attachment', function (e) {
confirmDelete("#attachment-{!! $bill->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $bill->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); confirmDelete("#attachment-{!! $bill->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $bill->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
}); });
@endif @endif
});
$(document).on('click', '#button-payment', function (e) { $(document).on('click', '#button-payment', function (e) {
$('#modal-add-payment').remove(); $('#modal-add-payment').remove();

View File

@ -170,11 +170,12 @@
@push('scripts') @push('scripts')
<script type="text/javascript"> <script type="text/javascript">
var focus = false;
var item_row = '{{ $item_row }}'; var item_row = '{{ $item_row }}';
var currency_code = $('#currency_code').val();
var autocomplete_path = "{{ url('common/items/autocomplete') }}";
$(document).on('click', '#button-add-item', function (e) { $(document).on('click', '#button-add-item', function (e) {
var currency_code = $('#currency_code').val();
$.ajax({ $.ajax({
url: '{{ url("incomes/invoices/addItem") }}', url: '{{ url("incomes/invoices/addItem") }}',
type: 'GET', type: 'GET',
@ -204,7 +205,7 @@
var currency = json['data']['currency']; var currency = json['data']['currency'];
$("#item-price-" + item_row).maskMoney({ $('#item-price-' + item_row).maskMoney({
thousands : currency.thousands_separator, thousands : currency.thousands_separator,
decimal : currency.decimal_mark, decimal : currency.decimal_mark,
precision : currency.precision, precision : currency.precision,
@ -213,7 +214,7 @@
suffix : (currency.symbol_first) ? '' : currency.symbol suffix : (currency.symbol_first) ? '' : currency.symbol
}); });
$("#item-price-" + item_row).trigger('focusout'); $('#item-price-' + item_row).trigger('focusout');
item_row++; item_row++;
} }
@ -228,7 +229,7 @@
$('#customer_id').trigger('change'); $('#customer_id').trigger('change');
@endif @endif
$(".input-price").maskMoney({ $('.input-price').maskMoney({
thousands : '{{ $currency->thousands_separator }}', thousands : '{{ $currency->thousands_separator }}',
decimal : '{{ $currency->decimal_mark }}', decimal : '{{ $currency->decimal_mark }}',
precision : {{ $currency->precision }}, precision : {{ $currency->precision }},
@ -260,7 +261,7 @@
language: '{{ language()->getShortCode() }}' language: '{{ language()->getShortCode() }}'
}); });
$(".tax-select2").select2({ $('.tax-select2').select2({
placeholder: { placeholder: {
id: '-1', // the value of the option id: '-1', // the value of the option
text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}" text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}"
@ -275,15 +276,15 @@
} }
}); });
$("#customer_id").select2({ $('#customer_id').select2({
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.customers', 1)]) }}" placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.customers', 1)]) }}"
}); });
$("#currency_code").select2({ $('#currency_code').select2({
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.currencies', 1)]) }}" placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.currencies', 1)]) }}"
}); });
$("#category_id").select2({ $('#category_id').select2({
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.categories', 1)]) }}" placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.categories', 1)]) }}"
}); });
@ -293,6 +294,11 @@
placeholder : '{{ trans('general.form.no_file_selected') }}' placeholder : '{{ trans('general.form.no_file_selected') }}'
}); });
@if(old('item'))
totalItem();
@endif
});
$(document).on('click', '#tax-add-new', function(e){ $(document).on('click', '#tax-add-new', function(e){
tax_name = $('.select2-search__field').val(); tax_name = $('.select2-search__field').val();
@ -311,8 +317,6 @@
}); });
}); });
var autocomplete_path = "{{ url('common/items/autocomplete') }}";
$(document).on('click', '.form-control.typeahead', function() { $(document).on('click', '.form-control.typeahead', function() {
input_id = $(this).attr('id').split('-'); input_id = $(this).attr('id').split('-');
@ -406,8 +410,6 @@
totalItem(); totalItem();
}); });
var focus = false;
$(document).on('focusin', '#items .input-price', function(){ $(document).on('focusin', '#items .input-price', function(){
focus = true; focus = true;
}); });
@ -470,9 +472,35 @@
}); });
}); });
@if(old('item')) $(document).on('click', '#button-customer', function (e) {
totalItem(); $('#modal-create-customer').remove();
@endif
$.ajax({
url: '{{ url("modals/customers/create") }}',
type: 'GET',
dataType: 'JSON',
success: function(json) {
if (json['success']) {
$('body').append(json['html']);
}
}
});
});
$(document).on('click', '#button-category', function (e) {
$('#modal-create-category').remove();
$.ajax({
url: '{{ url("modals/categories/create") }}',
type: 'GET',
dataType: 'JSON',
data: {type: 'income'},
success: function(json) {
if (json['success']) {
$('body').append(json['html']);
}
}
});
}); });
function totalItem() { function totalItem() {
@ -520,36 +548,5 @@
} }
}); });
} }
$(document).on('click', '#button-customer', function (e) {
$('#modal-create-customer').remove();
$.ajax({
url: '{{ url("modals/customers/create") }}',
type: 'GET',
dataType: 'JSON',
success: function(json) {
if (json['success']) {
$('body').append(json['html']);
}
}
});
});
$(document).on('click', '#button-category', function (e) {
$('#modal-create-category').remove();
$.ajax({
url: '{{ url("modals/categories/create") }}',
type: 'GET',
dataType: 'JSON',
data: {type: 'income'},
success: function(json) {
if (json['success']) {
$('body').append(json['html']);
}
}
});
});
</script> </script>
@endpush @endpush

View File

@ -151,83 +151,16 @@
@push('scripts') @push('scripts')
<script type="text/javascript"> <script type="text/javascript">
var focus = false;
var item_row = '{{ $item_row }}'; var item_row = '{{ $item_row }}';
var autocomplete_path = "{{ url('common/items/autocomplete') }}";
$(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},
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(){ $(document).ready(function(){
$('#customer_id').trigger('change');
itemTableResize(); itemTableResize();
@if (old('item')) $('.input-price').maskMoney({
$('#customer_id').trigger('change');
@endif
$(".input-price").maskMoney({
thousands : '{{ $currency->thousands_separator }}', thousands : '{{ $currency->thousands_separator }}',
decimal : '{{ $currency->decimal_mark }}', decimal : '{{ $currency->decimal_mark }}',
precision : {{ $currency->precision }}, precision : {{ $currency->precision }},
@ -261,7 +194,7 @@
language: '{{ language()->getShortCode() }}' language: '{{ language()->getShortCode() }}'
}); });
$(".tax-select2").select2({ $('.tax-select2').select2({
placeholder: { placeholder: {
id: '-1', // the value of the option id: '-1', // the value of the option
text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}" text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}"
@ -276,15 +209,15 @@
} }
}); });
$("#customer_id").select2({ $('#customer_id').select2({
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.customers', 1)]) }}" placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.customers', 1)]) }}"
}); });
$("#currency_code").select2({ $('#currency_code').select2({
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.currencies', 1)]) }}" placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.currencies', 1)]) }}"
}); });
$("#category_id").select2({ $('#category_id').select2({
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.categories', 1)]) }}" placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.categories', 1)]) }}"
}); });
@ -313,14 +246,19 @@
attachment_html += '</span>'; attachment_html += '</span>';
$('.fancy-file .fake-file').append(attachment_html); $('.fancy-file .fake-file').append(attachment_html);
@endif
@if(old('item'))
totalItem();
@endif
});
@if($invoice->attachment)
$(document).on('click', '#remove-attachment', function (e) { $(document).on('click', '#remove-attachment', function (e) {
confirmDelete("#attachment-{!! $invoice->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $invoice->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); confirmDelete("#attachment-{!! $invoice->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $invoice->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
}); });
@endif @endif
var autocomplete_path = "{{ url('common/items/autocomplete') }}";
$(document).on('click', '.form-control.typeahead', function() { $(document).on('click', '.form-control.typeahead', function() {
input_id = $(this).attr('id').split('-'); input_id = $(this).attr('id').split('-');
@ -390,6 +328,73 @@
} }
}); });
$(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},
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).on('keyup', '#pre-discount', function(e){ $(document).on('keyup', '#pre-discount', function(e){
e.preventDefault(); e.preventDefault();
@ -414,8 +419,6 @@
totalItem(); totalItem();
}); });
var focus = false;
$(document).on('focusin', '#items .input-price', function(){ $(document).on('focusin', '#items .input-price', function(){
focus = true; focus = true;
}); });
@ -478,11 +481,6 @@
}); });
}); });
@if(old('item'))
totalItem();
@endif
});
function totalItem() { function totalItem() {
$.ajax({ $.ajax({
url: '{{ url("common/items/totalItem") }}', url: '{{ url("common/items/totalItem") }}',

View File

@ -474,39 +474,11 @@
@push('scripts') @push('scripts')
<script type="text/javascript"> <script type="text/javascript">
$(document).ready(function(){
$(document).on('click', '#button-email', function (e) {
$('#email-modal').remove();
var html = '<div class="modal fade" id="email-modal" tabindex="-1" role="dialog" aria-labelledby="emailModalLabel">';
html += ' <div class="modal-dialog" role="document">';
html += ' <div class="modal-content">';
html += ' <div class="modal-header">';
html += ' <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>';
html += ' <h4 class="modal-title" id="emailModalLabel">Overflowing text</h4>';
html += ' </div>';
html += ' <div class="modal-body">';
html += ' {{ trans('general.na') }}';
html += ' </div>';
html += ' <div class="modal-footer">';
html += ' <button type="button" class="btn btn-default" data-dismiss="modal">{{ trans('general.cancel') }}</button>';
html += ' <button type="button" class="btn btn-success">Save changes</button>';
html += ' </div>';
html += ' </div>';
html += ' </div>';
html += '</div>';
$('body').append(html);
$('#email-modal').modal('show');
});
@if($invoice->attachment) @if($invoice->attachment)
$(document).on('click', '#remove-attachment', function (e) { $(document).on('click', '#remove-attachment', function (e) {
confirmDelete("#attachment-{!! $invoice->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $invoice->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}"); confirmDelete("#attachment-{!! $invoice->attachment->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $invoice->attachment->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
}); });
@endif @endif
});
$(document).on('click', '#button-payment', function (e) { $(document).on('click', '#button-payment', function (e) {
$('#modal-add-payment').remove(); $('#modal-add-payment').remove();