diff --git a/app/Repositories/Shop/Articles.php b/app/Repositories/Shop/Articles.php index 5a2ebe7b..7410d705 100644 --- a/app/Repositories/Shop/Articles.php +++ b/app/Repositories/Shop/Articles.php @@ -38,6 +38,7 @@ class Articles public static function getMeta(&$data = []) { $data['categories_options'] = Categories::getOptions(); + $data['price_generics'] = PriceGenericCategories::getOptionsWithChildrens(); $data['families_options'] = ArticleFamilies::getOptions(); $data['taxes_options'] = Taxes::getOptions(); $data['attribute_families_options'] = PriceFamilies::getOptions(); @@ -64,7 +65,7 @@ class Articles public static function getPricesByArticle($article) { - return Prices::getByArticle($article->id)->toArray(); + return Prices::getByArticle($article->id); } public static function get($id) diff --git a/app/Repositories/Shop/PriceGenericCategories.php b/app/Repositories/Shop/PriceGenericCategories.php index 8a394ccd..5f23bf24 100644 --- a/app/Repositories/Shop/PriceGenericCategories.php +++ b/app/Repositories/Shop/PriceGenericCategories.php @@ -33,6 +33,21 @@ class PriceGenericCategories return PriceGenericCategory::get()->pluck('name','id')->toArray(); } + public static function getOptionsWithChildrens() + { + $prices = PriceGenericCategory::with('price_generics')->get(); + $data = []; + foreach ($prices as $key => $price) + { + $data[$key]['label'] = $price->name; + foreach($price->price_generics as $generic) + { + $data[$key]['options'][$generic->id] = $generic->name; + } + } + return $data; + } + public static function store($data) { $id = isset($data['id']) ? $data['id'] : false; diff --git a/app/Repositories/Shop/PriceGenerics.php b/app/Repositories/Shop/PriceGenerics.php index 5fd2ef3c..1d34cc47 100644 --- a/app/Repositories/Shop/PriceGenerics.php +++ b/app/Repositories/Shop/PriceGenerics.php @@ -29,6 +29,13 @@ class PriceGenerics return Datatables::of($model)->make(true); } + public static function getOptions() + { + $model = PriceGeneric::with('category')->get()->toArray(); + dump($model); + exit; + } + public static function getAll() { return PriceGeneric::orderBy('name','asc')->get(); diff --git a/app/Repositories/Shop/Prices.php b/app/Repositories/Shop/Prices.php index 3f82ca55..6f371ef3 100644 --- a/app/Repositories/Shop/Prices.php +++ b/app/Repositories/Shop/Prices.php @@ -16,8 +16,7 @@ class Prices public static function getByArticle($id) { - $prices = Article::byArticle($id)->with('prices.price')->get()->pluck('prices')->toArray()[0]; - // dump($prices); + $prices = Price::byArticle($id)->with('price')->get()->toArray(); $data = []; foreach ($prices as $price) { @@ -32,7 +31,7 @@ class Prices } } } - dump($data); + return $data; } public static function getDatatable() diff --git a/resources/views/Shop/Admin/Articles/partials/prices.blade.php b/resources/views/Shop/Admin/Articles/partials/prices.blade.php index 2f8a1e6f..2ba55d6c 100644 --- a/resources/views/Shop/Admin/Articles/partials/prices.blade.php +++ b/resources/views/Shop/Admin/Articles/partials/prices.blade.php @@ -72,7 +72,7 @@ function load_attribute_values($selector, family_id) { $.ajax({ - url : "{{ route('Shop.Admin.ArticleAttributeValues.getOptionsByFamily') }}", + url : "{{ route('Shop.Admin.PriceFamilyValues.getOptionsByFamily') }}", method : 'POST', data: { family_id: family_id }, success : function(data) { diff --git a/resources/views/Shop/Admin/Articles/partials/prices/block_price.blade.php b/resources/views/Shop/Admin/Articles/partials/prices/block_price.blade.php index 2abcf0f5..2c0d4389 100644 --- a/resources/views/Shop/Admin/Articles/partials/prices/block_price.blade.php +++ b/resources/views/Shop/Admin/Articles/partials/prices/block_price.blade.php @@ -7,35 +7,39 @@
-
- {{ Form::label('quantity', 'Qté.') }}
- @include('components.number', ['name' => "prices[$key][quantity]", 'value' => $price['quantity'] ?? 1, 'required' => true, 'class' => 'form-control-sm']) +
+ {{ Form::label('price_generic_id', 'Générique') }}
+ @include('components.select-tree', ['name' => "prices[$key][article_price_generic_id]", 'value' => $price['article_price_generic_id'] ?? null, 'list' => $price_generics ?? null, 'required' => false, 'class' => 'form-control-sm'])
-
- @include('Shop.Admin.Articles.partials.prices.block_attribute', ['attribute' => $price['article_attribute']]) -
- -
+
-
- {{ Form::label('tax_id', 'TVA') }}
- @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']) +
+ {{ Form::label('quantity', 'Qté.') }}
+ @include('components.number', ['name' => "prices[$key][quantity]", 'value' => $price['quantity'] ?? 1, 'required' => true, 'class' => 'form-control-sm'])
-
- {{ Form::label('price_generic_id', 'Générique') }}
- @include('components.select', ['name' => "prices[$key][article_price_generic_id]", 'value' => $price['article_price_generic_id'] ?? null, 'list' => $price_generics ?? null, 'required' => false, 'class' => 'form-control-sm']) +
+ @include('Shop.Admin.Articles.partials.prices.block_attribute', ['attribute' => $price['article_attribute'] ?? null])
-
- {{ Form::label('price', 'Prix HT') }} - @include('components.money', ['name' => "prices[$key][price]", 'value' => $price['price'] ?? 0, 'required' => true, 'class' => 'form-control-sm price-item']) -
+
+
+
+ {{ Form::label('tax_id', 'TVA') }}
+ @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']) +
-
- {{ 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']) +
+ {{ Form::label('price', 'Prix HT') }} + @include('components.money', ['name' => "prices[$key][price]", 'value' => $price['price'] ?? 0, 'required' => true, 'class' => 'form-control-sm price-item']) +
+ +
+ {{ 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']) +
+
diff --git a/resources/views/Shop/Admin/Articles/partials/prices/block_price_new.blade.php b/resources/views/Shop/Admin/Articles/partials/prices/block_price_new.blade.php index bd75d2e8..69123267 100644 --- a/resources/views/Shop/Admin/Articles/partials/prices/block_price_new.blade.php +++ b/resources/views/Shop/Admin/Articles/partials/prices/block_price_new.blade.php @@ -7,6 +7,11 @@
+
+ {{ Form::label('price_generic_id', 'Générique') }}
+ @include('components.select-tree', ['name' => "prices[0][article_price_generic_id]", 'value' => $price['article_price_generic_id'] ?? null, 'list' => $price_generics ?? null, 'required' => false, 'class' => 'form-control-sm']) +
+
{{ Form::label('quantity', 'Quantité') }}
@include('components.number', ['name' => 'prices[0][quantity]', 'value' => $quantity ?? 1, 'required' => true, 'class' => 'form-control-sm']) @@ -23,11 +28,6 @@ @include('components.select', ['name' => 'prices[0][tax_id]', 'value' => $tax_id ?? null, 'list' => $taxes_options ?? null, 'required' => true, 'class' => 'form-control form-control-sm'])
-
- {{ Form::label('price_generic_id', 'Générique') }}
- @include('components.select', ['name' => "prices[0][article_price_generic_id]", 'value' => $price['article_price_generic_id'] ?? null, 'list' => $price_generics ?? null, 'required' => false, 'class' => 'form-control-sm']) -
-
{{ Form::label('price', 'Prix HT') }} @include('components.money', ['name' => 'prices[0][price]', 'value' => $price ?? 0, 'required' => true, 'class' => 'form-control-sm price-item']) diff --git a/resources/views/Shop/Admin/PriceFamilies/create.blade.php b/resources/views/Shop/Admin/PriceFamilies/create.blade.php new file mode 100644 index 00000000..c6df45b6 --- /dev/null +++ b/resources/views/Shop/Admin/PriceFamilies/create.blade.php @@ -0,0 +1,28 @@ +@extends('layout.index', [ + 'title' => __('article_attributes.title'), + 'subtitle' => __('article_attributes.create.title'), + 'breadcrumb' => [__('article_attributes.title'), __('article_attributes.create.title')] +]) + +@include('boilerplate::load.fileinput') + +@section('content') + + {{ Form::open(['route' => 'Shop.Admin.ArticleAttributes.store', 'id' => 'article-attribute-form', 'autocomplete' => 'off', 'files' => true]) }} + +
+
+ + {{ __('article_attributes.list.title') }} + + + + @include('components.button-save') + +
+
+ + @include('Shop.Admin.ArticleAttributeValues.form') + + +@endsection diff --git a/resources/views/Shop/Admin/PriceFamilies/edit.blade.php b/resources/views/Shop/Admin/PriceFamilies/edit.blade.php new file mode 100644 index 00000000..ac7a4833 --- /dev/null +++ b/resources/views/Shop/Admin/PriceFamilies/edit.blade.php @@ -0,0 +1,29 @@ +@extends('layout.index', [ + 'title' => 'Attributs d\'articles', + 'subtitle' => 'Edition d\'un attribut d\'article', + 'breadcrumb' => ['Articles'] +]) + +@include('boilerplate::load.fileinput') + +@section('content') + + {{ Form::open(['route' => 'Shop.Admin.ArticleAttributeValues.update', 'id' => 'article-attribute-form', 'autocomplete' => 'off', 'files' => true]) }} + +
+
+ + {{ __('article_attributes.list.title') }} + + + + @include('components.button-save') + +
+
+ + + @include('Shop.Admin.ArticleAttributeValues.form') + + +@endsection diff --git a/resources/views/Shop/Admin/PriceFamilies/form.blade.php b/resources/views/Shop/Admin/PriceFamilies/form.blade.php new file mode 100644 index 00000000..d6a4b4c7 --- /dev/null +++ b/resources/views/Shop/Admin/PriceFamilies/form.blade.php @@ -0,0 +1,29 @@ +@include('boilerplate::load.tinymce') + + +
+
+ {{ Form::label('name', 'Nom') }} + @include('components.input', ['name' => 'name', 'value' => (isset($family['name'])) ? $family['name'] : null, 'required' => true]) + + {{ Form::label('description', 'Description') }} + @include('components.textarea', ['name' => 'description', 'value' => isset($description) ? $description : null, 'class' => 'editor', 'required' => false]) + +
+
+ +
+
+
+ @include('components.button-save') +
+
+
+ +@push('js') + +@endpush \ No newline at end of file diff --git a/resources/views/Shop/Admin/PriceFamilies/index.blade.php b/resources/views/Shop/Admin/PriceFamilies/index.blade.php new file mode 100644 index 00000000..feb97f13 --- /dev/null +++ b/resources/views/Shop/Admin/PriceFamilies/index.blade.php @@ -0,0 +1,49 @@ +@extends('layout.index', [ + 'title' => __('Shop.article_attribute_families.title'), + 'subtitle' => __('Shop.article_attribute_families.list'), + 'breadcrumb' => [__('Shop.article_attribute_families.title')] +]) + +@include('boilerplate::load.select2') + +@section('content') + + + +
+ +
+ @section('content') + @include('components.datatable', ['route' => route('Shop.Admin.ArticleAttributeFamilies.index'), 'model' => 'ArticleAttributefamilies']) + @endsection +
+ +
+ @section('content') + @component('components.card') + @include('components.datatable', ['route' => route('Shop.Admin.ArticleAttributeValues.index'), 'model' => 'articleattributevalues']) + @endcomponent + + @component('components.layout.modal', ['title' => 'Filtres', 'id' => 'modal-filters']) + @include('Shop.Admin.ArticleAttributeValues.partials.filters') + @endcomponent + @endsection +
+ +
+ +@endsection + +@push('scripts') + @include('components.js.datatable', ['route' => route('Shop.Admin.ArticleAttributeFamilies.index'), 'model' => 'ArticleAttributeFamilies']) + @include('components.js.datatable', ['route' => route('Shop.Admin.ArticleAttributeValues.index'), 'model' => 'ArticleAttributeValues']) +@endpush \ No newline at end of file diff --git a/resources/views/Shop/Admin/PriceFamilies/list.blade.php b/resources/views/Shop/Admin/PriceFamilies/list.blade.php new file mode 100644 index 00000000..75982115 --- /dev/null +++ b/resources/views/Shop/Admin/PriceFamilies/list.blade.php @@ -0,0 +1,16 @@ +@extends('layout.index', [ + 'title' => __('Shop.article_attribute_values.title'), + 'subtitle' => __('Shop.article_attribute_values.list'), + 'breadcrumb' => [__('Shop.article_attribute_values.title')] +]) + +@section('content') + @component('components.card') + @include('components.datatable', ['route' => route('Shop.Admin.ArticleAttributeValues.index'), 'model' => 'ArticleAttributeValues']) + @endcomponent + + @component('components.layout.modal', ['title' => 'Filtres', 'id' => 'modal-filters']) + @include('Shop.Admin.ArticleAttributeValues.partials.filters') + @endcomponent + +@endsection diff --git a/resources/views/Shop/Admin/PriceFamilies/partials/filters.blade.php b/resources/views/Shop/Admin/PriceFamilies/partials/filters.blade.php new file mode 100644 index 00000000..16ce4981 --- /dev/null +++ b/resources/views/Shop/Admin/PriceFamilies/partials/filters.blade.php @@ -0,0 +1,9 @@ +
+
+ +
+ @include('components.select', ['name' => 'article_attribute_family_id', 'list' => (isset($families)) ? $families : [], 'value' => (isset($filters['article_attribute_family_id'])) ? $filters['article_attribute_family_id'] : null, 'class' => 'form-control-sm select2', 'with_empty' => ' ']) +
+
+ +
diff --git a/resources/views/Shop/Admin/PriceFamilies/show.blade.php b/resources/views/Shop/Admin/PriceFamilies/show.blade.php new file mode 100644 index 00000000..1e1cd729 --- /dev/null +++ b/resources/views/Shop/Admin/PriceFamilies/show.blade.php @@ -0,0 +1,36 @@ +@extends('layout.index', [ + 'title' => __('products.title'), + 'subtitle' => __('products.title'), + 'breadcrumb' => [__('products.title')] +]) + +@section('content') +
+ +
+ +
+ +
+
+
+

{{ name }}

+

+ {{ $product.section.name }}
+

+
+
+

{{ $prix_total }} €

+

{{ $residence['type_produit']['name'] }}

+
+ +
+ @include('Hestimmo.modules.Lot.partials.carousel') +
+
+
+
+
+
+ +@endsection diff --git a/resources/views/components/options-tree.blade.php b/resources/views/components/options-tree.blade.php index 149023ee..11874b62 100644 --- a/resources/views/components/options-tree.blade.php +++ b/resources/views/components/options-tree.blade.php @@ -1,7 +1,7 @@ @if (isset($list) && count($list)) @foreach($list as $key => $optgroup) - @include('components.options', ['list' => $optgroup['options']]) + @include('components.options', ['list' => $optgroup['options'] ?? null]) @endforeach @endif diff --git a/routes/Shop/Admin/PriceFamilies.php b/routes/Shop/Admin/PriceFamilies.php new file mode 100644 index 00000000..80ed9b20 --- /dev/null +++ b/routes/Shop/Admin/PriceFamilies.php @@ -0,0 +1,4 @@ +name('PriceFamilyValues.')->group(function () { + Route::post('getOptionsByFamily', 'PriceFamilyValueController@getOptionsByFamily')->name('getOptionsByFamily'); +}); \ No newline at end of file diff --git a/routes/Shop/Admin/route.php b/routes/Shop/Admin/route.php index 77a3fc2a..ad8b36ff 100644 --- a/routes/Shop/Admin/route.php +++ b/routes/Shop/Admin/route.php @@ -16,6 +16,8 @@ Route::middleware('auth')->prefix('Admin')->namespace('Admin')->name('Admin.')-> include __DIR__ . '/Invoices.php'; include __DIR__ . '/OrderPayments.php'; include __DIR__ . '/Orders.php'; + include __DIR__ . '/PriceFamilies.php'; + include __DIR__ . '/PriceFamilyValues.php'; include __DIR__ . '/PriceGenerics.php'; include __DIR__ . '/Tags.php'; include __DIR__ . '/TagGroups.php';