Rename Admin views directory, add some functions on models

This commit is contained in:
Ludovic CANDELLIER
2021-07-27 22:12:58 +02:00
parent daeece59c9
commit 9a0601d473
229 changed files with 81 additions and 349 deletions

View File

@@ -0,0 +1,13 @@
@extends('layout.index', [
'title' => __('Shop.articles.title'),
'subtitle' => __('Shop.articles.add'),
'breadcrumb' => [__('Shop.articles.title'), __('Shop.articles.add')]
])
@section('content')
{{ Form::open(['route' => 'Admin.Shop.Articles.store', 'id' => 'article-form', 'autocomplete' => 'off', 'files' => true]) }}
@include('Admin.Shop.Articles.form')
</form>
@endsection

View File

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

View File

@@ -0,0 +1,101 @@
<div class="row mt-3">
<div class="col-12">
<div class="card card-primary card-outline card-outline-tabs">
<div class="card-header p-0 border-bottom-0">
<ul class="card-title nav nav-tabs ml-auto" role="tablist">
<li class="nav-item">
<a href="#characteristics" class="nav-link active" data-toggle="tab" aria-expanded="true">
Caractéristiques
</a>
</li>
<li class="nav-item">
<a href="#offers" class="nav-link" data-toggle="tab" aria-expanded="true">
{{ __('Shop.offers.title') }}
@if(isset($offers_count))<span class="badge">{{ $offers_count }}</span>@endif
</a>
</li>
<li class="nav-item">
<a href="#shipping" class="nav-link" data-toggle="tab" aria-expanded="true">
Livraison
@if(isset($shipping_count))<span class="badge">{{ $shipping_count }}</span>@endif
</a>
</li>
<li class="nav-item">
<a href="#stock" class="nav-link" data-toggle="tab" aria-expanded="true">
Stock
@if(isset($stock_count))<span class="badge">{{ $stock_count }}</span>@endif
</a>
</li>
<li class="nav-item">
<a href="#seo" class="nav-link" data-toggle="tab" aria-expanded="true">
Référencement
</a>
</li>
</ul>
<div class="card-tools">
Actif
<input type="checkbox" name="active" class="active-checkbox" data-toggle="toggle" data-size="mini" data-width="50" data-height="25" data-onstyle="success" data-offstyle="danger">
</div>
</div>
<div class="card-body">
<div class="tab-content">
<div class="tab-pane active" id="characteristics">
@include('Admin.Shop.Articles.partials.characteristics')
</div>
<div class="tab-pane" id="offers">
</div>
<div class="tab-pane" id="shipping">
@include('Admin.Shop.Articles.partials.shipping')
</div>
<div class="tab-pane" id="stock">
@include('Admin.Shop.Articles.partials.stock')
</div>
<div class="tab-pane" id="seo">
@include('Admin.Shop.Articles.partials.seo')
</div>
</div>
</div>
</div>
</div>
</div>
@include('components.save')
@include('load.form.appender')
@include('load.form.editor')
@include('load.form.save')
@include('load.form.select2')
@include('load.form.set_options')
@include('load.form.toggle')
@include('load.form.upload.fileinput')
@include('load.layout.chevron')
@push('js')
<script>
$(function() {
$('.active-checkbox').bootstrapToggle();
$('.active-checkbox').off('change').on('change', function(e) {
var id = $('#id').val();
// handleAdmin.toggle(id, $(this).prop('checked'));
});
initChevron();
initEditor();
initSaveForm('#article-form');
initSelect2();
});
</script>
@endpush

View File

@@ -0,0 +1,15 @@
@extends('layout.index', [
'title' => __('Shop.articles.title'),
'subtitle' => __('Shop.articles.list'),
'breadcrumb' => [__('Shop.articles.title')]
])
@section('content')
@include('components.datatable', ['route' => route('Admin.Shop.Articles.index'), 'model' => 'articles', 'with_filters' => true])
@component('components.layout.modal', ['title' => 'Filtres', 'id' => 'modal-articles-filters'])
@include('Admin.Shop.Articles.partials.filters')
@endcomponent
@endsection

View File

@@ -0,0 +1,102 @@
<div class="row">
<div class="col-md-8">
<div class="row mb-3">
<div class="col-3">
{{ Form::label('model', 'Familles de produit') }}<br>
@include('components.select', ['name' => 'product_type', 'id_name' => 'product_type', 'list' => $models_options, 'value' => $article['product_type'] ?? null, 'class' => 'select2'])
</div>
<div class="col-6">
{{ Form::label('model_id', 'Produit') }}<br>
@include('components.select', ['name' => 'product_id', 'id_name' => 'product_id', 'list' => $products ?? [], 'value' => $article['product_id'] ?? null, 'class' => 'select2'])
</div>
<div class="col-3">
{{ Form::label('ref', 'Référence') }}<br>
@include('components.input', ['name' => 'ref', 'value' => $article['ref'] ?? null])
</div>
</div>
<div class="row mb-3">
<div class="col-8">
{{ Form::label('name', 'Nom') }}<br>
@include('components.input', ['name' => 'name', 'value' => $article['name'] ?? null, 'required' => true])
</div>
<div class="col-4">
{{ Form::label('article_nature_id', __('Shop.article_natures.name')) }}<br>
@include('components.select', ['name' => 'article_nature_id', 'list' => $natures_options, 'value' => $article['article_nature_id'] ?? null, 'class' => 'select2'])
</div>
</div>
<div class="row mb-3">
<div class="col-12">
{{ Form::label('categories', __('Shop.shelves.title')) }}<br>
@include('components.select', ['name' => 'categories[]', 'list' => $categories_options, 'values' => $article['categories'] ?? null, 'class' => 'select2', 'multiple' => true])
</div>
</div>
<div class="row mb-3">
<div class="col-12">
{{ Form::label('tags', 'Tags') }}<br>
@include('components.select-tree', ['name' => 'tags[]', 'list' => $tags_list, 'values' => $article['tags'] ?? null, 'class' => 'select2', 'multiple' => true])
</div>
</div>
<div class="row mb-3">
<div class="col-12">
@include('Admin.Shop.Articles.partials.product.description')
</div>
</div>
<div class="row mb-3">
<div class="col-12">
{{ Form::label('description', 'Description') }}
@include('components.textarea', ['name' => 'description', 'value' => $article['description'] ?? null, 'class' => 'editor', 'required' => true])
</div>
</div>
</div>
<div class="col-md-4">
@include('Admin.Shop.Articles.partials.product.images')
@include('components.uploader.widget', ['load_url' => route('Admin.Shop.Articles.getImages', ['id' => $article['id'] ?? false]), 'delete_url' => route('Admin.Shop.Articles.deleteImage'), 'title' => 'Photos', 'name' => 'images' ])
@include('Admin.Core.Comments.partials.comments')
</div>
</div>
@push('js')
<script>
$("#product_id").change( function(e) {
var product = $('#product_id').select2('data');
var name = product[0]['text'];
$('input[name="name"]').val(name);
});
$('#product_type').change( function() {
var product_type = $(this).val();
switch (product_type) {
case 'App\\Models\\Botanic\\Specie':
var url = '{{ route('Admin.Botanic.Species.getSelect') }}';
break;
case 'App\\Models\\Botanic\\Variety':
default:
var url = '{{ route('Admin.Botanic.Varieties.getSelect') }}';
break;
}
loadProducts(url);
});
function loadProducts(url) {
$.ajax({
url : url,
method : 'POST',
data: {model: $('#product_type').val()},
success : function(data) {
setOptions('#product_id', data);
// $("#product_id").select2({data: data});
// $("#product_id").trigger('change');
}
});
}
</script>
@endpush

View File

@@ -0,0 +1,8 @@
<form id="articles-filters">
<div class="row">
<label class="col-4">Familles d'articles</label>
<div class="col-8">
@include('components.select', ['name' => 'family_id', 'list' => (isset($families)) ? $families : [], 'value' => (isset($filters['family_id'])) ? $filters['family_id'] : null, 'class' => 'form-control-sm select2', 'with_empty' => ' '])
</div>
</div>
</form>

View File

@@ -0,0 +1,4 @@
<div id="attributes" class="appender" data-id="">
@include('Admin.Shop.Articles.partials.prices.block_attribute_new')
<div class="append_attribute"></div>
</div>

View File

@@ -0,0 +1,28 @@
<div class="row row-attribute">
<input type="hidden" name="prices[{{ $key }}][article_attribute][quantity]" value="1">
<input type="hidden" name="prices[{{ $key }}][article_attribute][id]" value="{{ (isset($attribute['id'])) ? $attribute['id'] : null }}">
<div class="col-12 col-lg-7">
{{ Form::label('attribute_family_id', 'Attributs') }}<br/>
@include('components.select', [
'name' => "prices[$key][attribute][attribute_family_id]",
'value' => $attribute['attribute_value']['article_attribute_family_id'] ?? null,
'list' => $attribute_families_options,
'required' => true,
'class' => 'select2 form-control-sm attributes-family'
])
</div>
<div class="col-12 col-lg-5">
{{ Form::label('attribute_value_id', 'Valeur') }}<br/>
@include('components.select', [
'name' => "prices[$key][attribute][attribute_value_id]",
'value' => $attribute['article_attribute_value_id'] ?? null,
'list' => $attribute_values ?? null,
'required' => true,
'class' => 'select2 form-control-sm attributes-value w-100',
'meta' => (isset($attribute['article_attribute_value_id'])) ? 'data-id="' . $attribute['article_attribute_value_id'] . '"' : ''
])
</div>
</div>

View File

@@ -0,0 +1,24 @@
<div class="row row-new-attribute row-attribute">
<input type="hidden" name="prices[][attribute][quantity]" value="1">
<div class="col-12 col-lg-6 1">
{{ Form::label('attribute_family_id', 'Attributs') }}<br/>
@include('components.select', [
'name' => 'prices[][attribute][attribute_family_id]',
'value' => $attribute_value['article_attribute_family_id'] ?? null,
'list' => $attribute_families_options,
'required' => true,
'class' => 'select2 form-control-sm attributes-family'
])
</div>
<div class="col-12 col-lg-6 2">
{{ Form::label('attribute_value_id', 'Valeur') }}<br/>
@include('components.select', [
'name' => 'prices[][attribute][attribute_value_id]',
'value' => $attribute_value['id'] ?? null,
'list' => $attribute_values ?? null,
'required' => true,
'class' => 'select2 form-control-sm attributes-value'
])
</div>
</div>

View File

@@ -0,0 +1,8 @@
<div class="col-12 row-generic">
<input type="hidden" name="generics[id][]" value="{{ $generic['id'] ?? null }}">
<input type="hidden" name="generics[price_generic_id][]" value="{{ $generic['price_generic_id'] ?? null }}">
@include('Admin.Shop.PriceGenerics.partials.table-prices', ['generic' => $generic['generic'] ?? null ])
</div>

View File

@@ -0,0 +1,5 @@
<div class="col-12 row-new-generic row-generic">
@include('Admin.Shop.PriceGenerics.partials.table-prices', ['generic' => $generic['generic'] ?? null ])
</div>

View File

@@ -0,0 +1,51 @@
<div id="append_generic_price" class="row">
@include('Admin.Shop.Articles.partials.generic_prices.list-generic_prices')
</div>
<div class="row mt-3">
<div class="col-6">
@include('components.select-tree', ['name' => "article_price_generic_id", 'id_name' => "article_price_generic_id", 'value' => $price['article_price_generic_id'] ?? null, 'list' => $price_generics ?? null, 'required' => false, 'class' => 'form-control-sm w-100'])
</div>
<div class="col-6">
<button type="button" class="btn btn-sm btn-primary" id="add-new-generic_price">Associer un tarif générique <i class="fa fa-plus"></i></button>
</div>
</div>
@push('js')
<script>
function append_generic_price() {
$('.select2').select2();
handleAddGeneric();
}
function handleAddGeneric() {
$('#add-new-generic_price').click(function() {
var id = $('#article_price_generic_id').val();
var content = $.get("{{ route('Admin.Shop.PriceGenerics.getPrice') }}/" + id, function(data) {
$('#append_generic_price').html(data);
handleDeleteGenericPrice();
});
});
}
function handleDeleteGenericPrice() {
$('.delete-generic_price-btn').off().click(function(e) {
console.log('ici');
e.preventDefault();
// $('#append_generic_price').html('');
/*
confirm_delete(id, "{## route('Admin.Shop.GenericPrices.destroy') }}", function() {
$selector.remove();
});
*/
});
}
$(function() {
append_generic_price();
});
</script>
@endpush

View File

@@ -0,0 +1,14 @@
@if (isset($generics) && (count($generics)))
@foreach ($generics as $generic)
@include('Admin.Shop.Articles.partials.generic_prices.block_generic_price')
@endforeach
@endif
@push('js')
<script>
$(function () {
handleDeleteGenericPrice();
});
</script>
@endpush

View File

@@ -0,0 +1,2 @@
@include('Admin.Shop.Articles.partials.prices.prices', ['prices' => $article['prices']['prices'] ?? null])
@include('Admin.Shop.Articles.partials.generic_prices.generic_prices', ['generics' => $article['prices']['generics'] ?? null])

View File

@@ -0,0 +1,4 @@
<div id="attributes" class="appender" data-id="">
@include('Admin.Shop.Articles.partials.prices.block_attribute_new')
<div class="append_attribute"></div>
</div>

View File

@@ -0,0 +1,75 @@
<div class="col-12 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-lg-1">
{{ 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-lg-3">
{{ Form::label('package_id', 'Type Package') }}<br/>
@include('components.select', [
'name' => "prices[$key][package_id]",
'value' => $price['package_id'] ?? null,
'list' => $packages ?? null,
'required' => true,
'class' => 'select2 form-control-sm packages w-100',
])
</div>
<div class="col-lg-1">
{{ Form::label('package_qty', 'Pack Qté') }}<br/>
@include('components.number', [
'name' => "prices[$key][package_quantity]",
'value' => $price['package_quantity'] ?? null,
'required' => true,
'class' => 'form-control-sm',
])
</div>
<div class="col-lg-3">
{{ Form::label('unity_id', 'Unité') }}<br/>
@include('components.select', [
'name' => "prices[$key][unity_id]",
'value' => $price['unity_id'] ?? null,
'list' => $unities ?? null,
'required' => true,
'class' => 'select2 form-control-sm unities w-100',
'with_empty' => ''
])
</div>
<div class="col-lg-3">
<div class="row">
<div class="col-4">
{{ Form::label('tax_id', 'TVA') }}<br/>
@include('components.select', ['name' => "prices[$key][tax_id]", 'value' => $price['tax_id'] ?? null, 'list' => $taxes_options ?? null, 'required' => true, 'class' => 'form-control form-control-sm'])
</div>
<div class="col-4">
{{ 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-4">
{{ 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>
</div>
<div class="col-lg-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,80 @@
<div class="col-12 row-new-price row-price">
<input type="hidden" name="prices[0][article_id]" value="{{ $id ?? null }}">
<div class="card card-light">
<div class="card-body pt-2">
<div class="row">
<div class="col-lg-1">
{{ 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-lg-3">
{{ Form::label('package_id', 'Type Package') }}<br/>
@include('components.select', [
'name' => "prices[0][package_id]",
'value' => $price['package_id'] ?? null,
'list' => $packages ?? null,
'required' => true,
'class' => 'select2 form-control-sm packages w-100',
])
</div>
<div class="col-lg-1">
{{ Form::label('package_qty', 'Pack Qté') }}<br/>
@include('components.number', [
'name' => "prices[0][package_quantity]",
'value' => $price['package_quantity'] ?? null,
'required' => true,
'class' => 'form-control-sm',
])
</div>
<div class="col-lg-3">
{{ Form::label('unity_id', 'Unité') }}<br/>
@include('components.select', [
'name' => "prices[0][unity_id]",
'value' => $price['unity_id'] ?? null,
'list' => $unities ?? null,
'required' => true,
'class' => 'select2 form-control-sm unities w-100',
'with_empty' => ''
])
</div>
<div class="col-lg-3">
<div class="row">
<div class="col-4">
{{ Form::label('tax_id', 'TVA') }}<br/>
@include('components.select', ['name' => 'prices[0][tax_id]', 'value' => $tax_id ?? null, 'list' => $taxes_options ?? null, 'required' => true, 'class' => 'form-control form-control-sm'])
</div>
<div class="col-4">
{{ 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-4">
{{ 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>
</div>
<div class="col-lg-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,18 @@
@if (isset($prices) && (count($prices)))
@for ($i = 0; $i < count($prices); $i++)
@include('Admin.Shop.Articles.partials.prices.block_price', ['key' => $i, 'price' => $prices[$i]])
@endfor
@endif
@push('js')
<script>
$(function () {
handle_delete_price();
init_unities();
handle_change_package();
handle_prices();
handle_prices_taxed();
});
</script>
@endpush

View File

@@ -0,0 +1,98 @@
@include('Admin.Shop.Articles.partials.prices.block_price_new')
<div id="append_price" class="row">
@include('Admin.Shop.Articles.partials.prices.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() {
$('.select2').select2();
handle_change_package();
load_unities($('.unities'), $('.packages').val());
}
$("#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_change_package() {
$('.packages').change( function() {
var package_id = $(this).val();
var $package = $(this);
var $parent = $package.parent().parent();
var $selector = $parent.find('.unities');
load_unities($selector, package_id);
});
}
function init_unities() {
$('.packages').each( function() {
var package_id = $(this).val();
var $package = $(this);
var $parent = $package.parent().parent();
var $selector = $parent.find('.unities');
load_unities($selector, package_id);
value_id = $selector.data('id');
$selector.val(value_id).trigger('change');
});
}
function load_unities($selector, package_id) {
$.ajax({
url : "{{ route('Admin.Shop.Unities.getOptionsByPackage') }}",
method : 'POST',
data: { package_id: package_id },
success : function(data) {
setOptions($selector, data);
// $selector.empty().select2({data: data});
}
});
}
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('Admin.Shop.ArticlePrices.destroy', {id : id}), function() {
$selector.remove();
});
});
}
function handle_prices() {
$('.price-item').change(function() {
tax_selected = $(this).parent().prev().find('select option:selected').text();
price_taxed = $(this).val() * (1 + (tax_selected / 100));
$(this).parent().parent().find('.price-taxed-item').val(price_taxed);
})
}
function handle_prices_taxed() {
$('.price-taxed-item').change(function() {
tax_selected = $(this).parent().prev().find('select option:selected').text();
console.log($(this).parent().prev());
price = $(this).val() / (1 + (tax_selected / 100));
$(this).parent().parent().find('.price-item').val(price);
})
}
$(function() {
handle_change_package();
});
</script>
@endpush

View File

@@ -0,0 +1,16 @@
@if (!empty($article['product']['description']))
@component('components.layout.box-collapse', ['id' => 'product_description', 'title' => 'Informations héritées'])
@foreach ($article['inherited'] as $inherited)
@component('components.card', ['title' => $inherited['name'], 'class' => 'mb-3'])
{!! $inherited['description'] !!}
@if ($inherited['tags'])
<h6> Tags</h6>
@foreach ($inherited['tags'] as $tag)
<span class="btn btn-xs">{{ $tag['name'] }}</span>
@endforeach
@endif
@endcomponent
@endforeach
@endcomponent
@endif

View File

@@ -0,0 +1 @@
@include('components.uploader.widget', ['load_url' => route('Admin.Botanic.Varieties.getImages', ['id' => $article['product_id'] ?? false, 'can_edit' => 0]), 'name' => 'images', 'title' => 'Photos produits', 'prefix' => 'product_', 'can_edit' => false, 'collapsed' => true ])

View File

@@ -0,0 +1,7 @@
@if (!empty($article['product']['tags']))
@component('components.layout.box-collapse', ['id' => 'product_tags', 'title' => 'Tags produit'])
@foreach ($article['product']['tags'] as $tag)
{{ $tag['name'] }}
@endforeach
@endcomponent
@endif

View File

@@ -0,0 +1,36 @@
@extends('layout.index', [
'title' => __('products.title'),
'subtitle' => __('products.title'),
'breadcrumb' => [__('products.title')]
])
@section('content')
<form action="{{ route('Shop.Products') }}" method="GET">
<div class="row">
<div class="col-md-offset-2 col-md-8">
<div class="box box-info">
<div class="box-body">
<div class="col-md-6">
<h3>{{ name }}</h3>
<h4>
{{ $product.section.name }}<br>
</h4>
</div>
<div class="col-md-6 text-right">
<h2>{{ $prix_total }} </h2>
<h4>{{ $residence['type_produit']['name'] }}</h4>
</div>
<div class="col-md-12">
@include('Hestimmo.modules.Lot.partials.carousel')
</div>
</div>
</div>
</div>
</div>
</form>
@endsection