Add categories for generic prices
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
<div class="col-6 row-price">
|
||||
|
||||
<input type="hidden" name="prices[{{ $key }}][id]" value="@if (isset($price['id'])){{ $price['id'] }}@endif" class="price_id">
|
||||
|
||||
<div class="card card-light">
|
||||
<div class="card-body pt-2">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-2">
|
||||
{{ Form::label('quantity', 'Qté.') }}<br/>
|
||||
@include('components.number', ['name' => "prices[$key][quantity]", 'value' => $price['quantity'] ?? 1, 'required' => true, 'class' => 'form-control-sm'])
|
||||
</div>
|
||||
|
||||
<div class="col-3">
|
||||
{{ Form::label('tax_id', 'TVA') }}<br/>
|
||||
@include('components.select', ['name' => "prices[$key][tax_id]", 'value' => $price['tax_id'] ?? null, 'list' => $taxes ?? null, 'required' => true, 'class' => 'form-control-sm'])
|
||||
</div>
|
||||
|
||||
<div class="col-3">
|
||||
{{ Form::label('price', 'Prix HT') }}
|
||||
@include('components.money', ['name' => "prices[$key][price]", 'value' => $price['price'] ?? 0, 'required' => true, 'class' => 'form-control-sm price-item'])
|
||||
</div>
|
||||
|
||||
<div class="col-3">
|
||||
{{ Form::label('price_taxed', 'Prix TTC') }}
|
||||
@include('components.money', ['name' => "prices[$key][price_taxed]", 'value' => $price['price_taxed'] ?? 0, 'required' => true, 'class' => 'form-control-sm price-taxed-item'])
|
||||
</div>
|
||||
|
||||
<div class="col-1 text-right">
|
||||
<br/>
|
||||
<button type="button" class="btn btn-xs btn-danger delete-price-btn mt-2" data-card-widget="collapse" data-toggle="tooltip" title="supprimer">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,43 @@
|
||||
<div class="col-6 row-new-price row-price">
|
||||
|
||||
<input type="hidden" name="prices[][id]" value="">
|
||||
|
||||
<div class="card card-light">
|
||||
<div class="card-body pt-2">
|
||||
|
||||
<div class="row">
|
||||
|
||||
<div class="col-2">
|
||||
{{ Form::label('quantity', 'Quantité') }}<br/>
|
||||
@include('components.number', ['name' => 'prices[0][quantity]', 'value' => $quantity ?? 1, 'required' => true, 'class' => 'form-control-sm'])
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-3">
|
||||
{{ Form::label('tax_id', 'TVA') }}<br/>
|
||||
@include('components.select', ['name' => 'prices[0][tax_id]', 'value' => $tax_id ?? null, 'list' => $taxes ?? null, 'required' => true, 'class' => 'form-control-sm'])
|
||||
</div>
|
||||
|
||||
<div class="col-3">
|
||||
{{ Form::label('price', 'Prix HT') }}
|
||||
@include('components.money', ['name' => 'prices[0][price]', 'value' => $price ?? 0, 'required' => true, 'class' => 'form-control-sm price-item'])
|
||||
</div>
|
||||
|
||||
<div class="col-3">
|
||||
{{ Form::label('price_taxed', 'Prix TTC') }}
|
||||
@include('components.money', ['name' => 'prices[0][price_taxed]', 'value' => $price_taxed ?? 0, 'required' => true, 'class' => 'form-control-sm price-taxed-item'])
|
||||
</div>
|
||||
|
||||
<div class="col-1 text-right">
|
||||
<br/>
|
||||
<button type="button" class="btn btn-xs btn-danger delete-new-price-btn mt-2" data-card-widget="collapse" data-toggle="tooltip" title="supprimer">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,16 @@
|
||||
@if (isset($prices) && (count($prices)))
|
||||
@for ($i = 0; $i < count($prices); $i++)
|
||||
@include('Shop.Admin.PriceGenerics.partials.block_price', ['key' => $i, 'price' => $prices[$i]])
|
||||
@endfor
|
||||
@endif
|
||||
|
||||
@push('js')
|
||||
<script>
|
||||
$(function () {
|
||||
handle_delete_price();
|
||||
handle_prices();
|
||||
handle_prices_taxed();
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
@include('Shop.Admin.PriceGenerics.partials.block_price_new')
|
||||
|
||||
<div id="append_price" class="row">
|
||||
@include('Shop.Admin.PriceGenerics.partials.list-prices')
|
||||
</div>
|
||||
|
||||
<button type="button" class="btn btn-sm btn-primary add-new-price">Ajouter un tarif <i class="fa fa-plus"></i></button>
|
||||
|
||||
@push('js')
|
||||
<script>
|
||||
|
||||
function append_price() {
|
||||
handle_prices();
|
||||
handle_prices_taxed();
|
||||
// handle_append_attribute();
|
||||
// $('.select2').select2();
|
||||
}
|
||||
|
||||
$("#append_price").appender({
|
||||
rowSection: '.row-new-price',
|
||||
type: '.row-price',
|
||||
addBtn: '.add-new-price',
|
||||
appendEffect: 'slide',
|
||||
addClass: 'animated bounceInLeft',
|
||||
rowNumber: '.row-price-number',
|
||||
deleteBtn: '.delete-new-price-btn',
|
||||
callback: append_price,
|
||||
rowNumberStart: 2,
|
||||
hideSection: true
|
||||
});
|
||||
|
||||
|
||||
function handle_delete_price() {
|
||||
$('.delete-price-btn').click(function() {
|
||||
var $selector = $(this).parents('.row-price');
|
||||
var id = $selector.find('.price_id').val();
|
||||
|
||||
confirm_delete(id, laroute.route('Shop.Admin.PriceGenericValues.destroy', {id : id}), function() {
|
||||
$selector.remove();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function handle_prices() {
|
||||
$('.price-item').change(function() {
|
||||
$col_tax = $(this).parent().prev();
|
||||
tax_selected = $col_tax.find('select option:selected').text();
|
||||
price_taxed = $(this).val() * (1 + (tax_selected / 100));
|
||||
price_taxed = price_taxed.toFixed(2);
|
||||
$(this).parent().parent().find('.price-taxed-item').val(price_taxed);
|
||||
})
|
||||
}
|
||||
|
||||
function handle_prices_taxed() {
|
||||
$('.price-taxed-item').change(function() {
|
||||
$col_tax = $(this).parent().prev().prev();
|
||||
tax_selected = $col_tax.find('select option:selected').text();
|
||||
price = $(this).val() / (1 + (tax_selected / 100));
|
||||
price = price.toFixed(2);
|
||||
$(this).parent().parent().find('.price-item').val(price);
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
@endpush
|
||||
Reference in New Issue
Block a user