178 lines
6.5 KiB
PHP
Raw Normal View History

2017-09-14 22:21:00 +03:00
@extends('layouts.admin')
@section('title', trans('general.title.edit', ['type' => trans_choice('general.items', 1)]))
@section('content')
<!-- Default box -->
<div class="box box-success">
{!! Form::model($item, [
'method' => 'PATCH',
'files' => true,
2018-06-11 03:47:32 +03:00
'route' => ['items.update', $item->id],
2018-09-17 13:57:03 +03:00
'role' => 'form',
'class' => 'form-loading-button'
2017-09-14 22:21:00 +03:00
]) !!}
<div class="box-body">
{{ Form::textGroup('name', trans('general.name'), 'id-card-o') }}
{{ Form::textGroup('sku', trans('items.sku'), 'key') }}
{{ Form::textareaGroup('description', trans('general.description')) }}
{{ Form::textGroup('sale_price', trans('items.sales_price'), 'money') }}
{{ Form::textGroup('purchase_price', trans('items.purchase_price'), 'money') }}
{{ Form::textGroup('quantity', trans_choice('items.quantities', 1), 'cubes') }}
2017-10-06 16:22:31 +03:00
{{ Form::selectGroup('tax_id', trans_choice('general.taxes', 1), 'percent', $taxes, null, []) }}
2017-09-14 22:21:00 +03:00
2017-10-06 16:22:31 +03:00
{{ Form::selectGroup('category_id', trans_choice('general.categories', 1), 'folder-open-o', $categories, null, []) }}
2017-09-14 22:21:00 +03:00
{{ Form::fileGroup('picture', trans_choice('general.pictures', 1)) }}
{{ Form::radioGroup('enabled', trans('general.enabled')) }}
</div>
<!-- /.box-body -->
2018-06-10 02:48:51 +03:00
@permission('update-common-items')
2017-09-14 22:21:00 +03:00
<div class="box-footer">
2018-06-10 02:48:51 +03:00
{{ Form::saveButtons('common/items') }}
2017-09-14 22:21:00 +03:00
</div>
<!-- /.box-footer -->
@endpermission
{!! Form::close() !!}
</div>
@endsection
2017-11-13 21:55:15 +03:00
@push('js')
2017-09-14 22:21:00 +03:00
<script src="{{ asset('public/js/bootstrap-fancyfile.js') }}"></script>
2017-11-13 21:55:15 +03:00
@endpush
2017-09-14 22:21:00 +03:00
2017-11-13 21:55:15 +03:00
@push('css')
2017-09-14 22:21:00 +03:00
<link rel="stylesheet" href="{{ asset('public/css/bootstrap-fancyfile.css') }}">
2017-11-13 21:55:15 +03:00
@endpush
2017-09-14 22:21:00 +03:00
2017-11-13 21:55:15 +03:00
@push('scripts')
2017-09-14 22:21:00 +03:00
<script type="text/javascript">
var text_yes = '{{ trans('general.yes') }}';
var text_no = '{{ trans('general.no') }}';
$(document).ready(function(){
/*$("#sale_price").maskMoney({
thousands : '{{ $currency->thousands_separator }}',
decimal : '{{ $currency->decimal_mark }}',
precision : {{ $currency->precision }},
allowZero : true,
@if($currency->symbol_first)
prefix : '{{ $currency->symbol }}'
@else
suffix : '{{ $currency->symbol }}'
@endif
});
$("#purchase_price").maskMoney({
thousands : '{{ $currency->thousands_separator }}',
decimal : '{{ $currency->decimal_mark }}',
precision : {{ $currency->precision }},
allowZero : true,
@if($currency->symbol_first)
prefix : '{{ $currency->symbol }}'
@else
suffix : '{{ $currency->symbol }}'
@endif
});
$("#sale_price").focusout();
$("#purchase_price").focusout();*/
2018-12-22 16:52:46 +03:00
$('#tax_id').select2({
placeholder: {
id: '-1', // the value of the option
text: "{{ trans('general.form.select.field', ['field' => trans_choice('general.taxes', 1)]) }}"
2018-12-22 16:52:46 +03:00
},
escapeMarkup: function (markup) {
return markup;
},
language: {
noResults: function () {
return '<span id="tax-add-new"><i class="fa fa-plus"></i> {{ trans('general.title.new', ['type' => trans_choice('general.tax_rates', 1)]) }}</span>';
2018-12-22 16:52:46 +03:00
}
}
2017-09-14 22:21:00 +03:00
});
$("#category_id").select2({
placeholder: "{{ trans('general.form.select.field', ['field' => trans_choice('general.categories', 1)]) }}"
});
$('#picture').fancyfile({
text : '{{ trans('general.form.select.file') }}',
style : 'btn-default',
@if($item->picture)
2019-02-02 14:02:26 +03:00
placeholder : '{{ $item->picture->basename }}'
@else
placeholder : '{{ trans('general.form.no_file_selected') }}'
@endif
2017-09-14 22:21:00 +03:00
});
@if($item->picture)
2019-02-02 14:02:26 +03:00
$.ajax({
url: '{{ url('uploads/' . $item->picture->id . '/show') }}',
type: 'GET',
data: {column_name: 'picture'},
dataType: 'JSON',
success: function(json) {
if (json['success']) {
$('.fancy-file').after(json['html']);
}
}
});
@permission('delete-common-uploads')
$(document).on('click', '#remove-picture', function (e) {
confirmDelete("#picture-{!! $item->picture->id !!}", "{!! trans('general.attachment') !!}", "{!! trans('general.delete_confirm', ['name' => '<strong>' . $item->picture->basename . '</strong>', 'type' => strtolower(trans('general.attachment'))]) !!}", "{!! trans('general.cancel') !!}", "{!! trans('general.delete') !!}");
});
@endpermission
@endif
2017-09-14 22:21:00 +03:00
});
2018-12-22 16:52:46 +03:00
$(document).on('click', '.select2-results__option.select2-results__message', function(e) {
tax_name = $('.select2-search__field').val();
$('body > .select2-container.select2-container--default.select2-container--open').remove();
$('#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']);
}
}
});
});
2018-12-24 18:00:53 +03:00
$(document).on('hidden.bs.modal', '#modal-create-tax', function () {
$('#tax_id').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-circle"></i> {{ trans('general.title.new', ['type' => trans_choice('general.tax_rates', 1)]) }}</span>';
}
}
});
});
2017-09-14 22:21:00 +03:00
</script>
2017-11-13 21:55:15 +03:00
@endpush