Add categories for generic prices

This commit is contained in:
Ludovic CANDELLIER
2020-08-31 00:44:29 +02:00
parent 3b6108b449
commit c9198de890
26 changed files with 471 additions and 242 deletions

View File

@@ -1,28 +0,0 @@
@extends('layout.index', [
'title' => __('article_price_generics.title'),
'subtitle' => __('article_price_generics.create.title'),
'breadcrumb' => [__('article_price_generics.title'), __('article_price_generics.create.title')]
])
@include('boilerplate::load.fileinput')
@section('content')
{{ Form::open(['route' => 'Shop.Admin.ArticlePriceGenerics.store', 'id' => 'article-price-generic-form', 'autocomplete' => 'off', 'files' => true]) }}
<div class="row">
<div class="col-sm-12 mbl">
<a href="{{ route("Shop.Admin.ArticlePriceGenerics.index") }}" class="btn btn-default">
{{ __('article_price_generics.list.title') }}
</a>
<span class="btn-group pull-right">
@include('components.button-save')
</span>
</div>
</div>
@include('Shop.Admin.ArticlePriceGenerics.form')
</form>
@endsection

View File

@@ -1,14 +0,0 @@
@extends('layout.index', [
'title' => __('article_price_generics.title'),
'subtitle' => __('article_price_generics.edit.title'),
'breadcrumb' => [__('article_price_generics.title'), __('article_price_generics.edit.title')]
])
@section('content')
{{ Form::open(['route' => 'Shop.Admin.ArticlePriceGenerics.update', 'id' => 'article-price-generic-form', 'autocomplete' => 'off', 'files' => true]) }}
<input type="hidden" name="id" value="{{ $generic['id'] }}">
@include('Shop.Admin.ArticlePriceGenerics.form')
</form>
@endsection

View File

@@ -1,64 +0,0 @@
<div class="row">
<div class="col-md-4">
{{ Form::label('name', 'Nom') }}
@include('components.input', ['name' => 'name', 'value' => $generic['name'] ?? null, 'required' => true])
</div>
</div>
<div class="row">
<div class="col-md-8">
<div class="row">
<div class="col-4">
{{ Form::label('tax_id', 'TVA') }}
@include('components.select', ['name' => 'tax_id', 'value' => $generic['tax_id'] ?? null, 'list' => $taxes ?? null, 'class' => 'tva', 'required' => true])
</div>
<div class="col-4">
{{ Form::label('price', 'Prix HT') }}
@include('components.input', ['name' => 'price', 'value' => $generic['price'] ?? null, 'class' => 'price', 'required' => true])
</div>
<div class="col-4">
{{ Form::label('price_taxed', 'Prix TTC') }}
@include('components.input', ['name' => 'price_taxed', 'value' => $generic['price_taxed'] ?? null, 'class' => 'price_taxed', 'required' => true])
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-8">
<div class="float-right mt-3">
@include('components.button-save')
</div>
</div>
</div>
@push('js')
<script>
function set_price(item) {
$row = $(item).parent();
tva = $row.find('.tva').val();
price_taxed = $row.find('.price_taxed').val();
console.log(tva);
console.log(price_taxed);
}
function set_price_taxed(item) {
$row = $(item).parent();
tva = $row.find('.tva').val();
price = $row.find('.price').val();
console.log(tva);
console.log(price);
}
$('.price_taxed').change(function() {
set_price(this);
});
$('.price').change(function() {
set_price_taxed(this);
});
</script>
@endpush

View File

@@ -1,8 +0,0 @@
@extends('layout.index', [
'title' => __('article_price_generics.title'),
'subtitle' => __('article_price_generics.list.title'),
'breadcrumb' => [__('article_price_generics.title')]
])
@section('content')
@include('components.datatable', ['route' => route('Shop.Admin.ArticlePriceGenerics.index'), 'model' => 'article-price-generics'])
@endsection

View File

@@ -0,0 +1,26 @@
@extends('layout.index', [
'title' => __('price_generics.title'),
'subtitle' => __('price_generics.create.title'),
'breadcrumb' => [__('price_generics.title'), __('price_generics.create.title')]
])
@section('content')
{{ Form::open(['route' => 'Shop.Admin.PriceGenerics.store', 'id' => 'price-generic-form', 'autocomplete' => 'off']) }}
<div class="row">
<div class="col-sm-12 mbl">
<a href="{{ route("Shop.Admin.PriceGenerics.index") }}" class="btn btn-default">
{{ __('price_generics.list.title') }}
</a>
<span class="btn-group pull-right">
@include('components.button-save')
</span>
</div>
</div>
@include('Shop.Admin.PriceGenerics.form')
</form>
@endsection

View File

@@ -0,0 +1,14 @@
@extends('layout.index', [
'title' => __('price_generics.title'),
'subtitle' => __('price_generics.edit.title'),
'breadcrumb' => [__('price_generics.title'), __('price_generics.edit.title')]
])
@section('content')
{{ Form::open(['route' => 'Shop.Admin.PriceGenerics.store', 'id' => 'price-generic-form', 'autocomplete' => 'off']) }}
<input type="hidden" name="id" value="{{ $generic['id'] }}">
@include('Shop.Admin.PriceGenerics.form')
</form>
@endsection

View File

@@ -0,0 +1,23 @@
<div class="row">
<div class="col-md-6">
{{ Form::label('name', 'Catégorie') }}
@include('components.select', ['name' => 'category_id', 'list' => $categories, 'value' => $generic['category_id'] ?? null, 'required' => true])
</div>
</div>
<div class="row mb-3">
<div class="col-md-6">
{{ Form::label('name', 'Nom') }}
@include('components.input', ['name' => 'name', 'value' => $generic['name'] ?? null, 'required' => true])
</div>
</div>
@include('Shop.Admin.PriceGenerics.partials.prices', ['prices' => $generic['values'] ?? null ])
<div class="row">
<div class="col-md-8">
<div class="float-right mt-3">
@include('components.button-save')
</div>
</div>
</div>

View File

@@ -0,0 +1,8 @@
@extends('layout.index', [
'title' => __('price_generics.title'),
'subtitle' => __('price_generics.list.title'),
'breadcrumb' => [__('price_generics.title')]
])
@section('content')
@include('components.datatable', ['route' => route('Shop.Admin.PriceGenerics.index'), 'model' => 'price-generics'])
@endsection

View File

@@ -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>

View File

@@ -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>

View File

@@ -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

View File

@@ -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