diff --git a/app/Datatables/Botanic/SpeciesDataTable.php b/app/Datatables/Botanic/SpeciesDataTable.php index ac0a0c23..292f092e 100644 --- a/app/Datatables/Botanic/SpeciesDataTable.php +++ b/app/Datatables/Botanic/SpeciesDataTable.php @@ -13,7 +13,7 @@ class SpeciesDataTable extends DataTable public function query(Specie $model) { - $model = $model::withCount(['images','varieties','tags'])->with(['genre','image','tags']); + $model = $model::withCount(['images', 'varieties', 'tags'])->with(['genre', 'image', 'tags']); return $this->buildQuery($model); } @@ -29,7 +29,7 @@ class SpeciesDataTable extends DataTable ->editColumn('tags2', function (Specie $specie) { $html = ''; foreach ($specie->tags as $tag) { - $html .= '' . $tag->slug . ' '; + $html .= '' . $tag->slug . ' '; } return $html; }) diff --git a/app/Datatables/Botanic/VarietiesDataTable.php b/app/Datatables/Botanic/VarietiesDataTable.php index 9f6f432c..d25277af 100644 --- a/app/Datatables/Botanic/VarietiesDataTable.php +++ b/app/Datatables/Botanic/VarietiesDataTable.php @@ -13,8 +13,7 @@ class VarietiesDataTable extends DataTable public function query(Variety $model) { - // $model = $model::with('specie')->withCount('Articles')->select('botanic_varieties.*'); - $model = $model::joinRelationship('Specie')->select('botanic_varieties.*', 'botanic_species.name as specie_name')->with(['image', 'Specie'])->withCount(['Articles', 'tags']); + $model = $model::joinRelationship('Specie')->select('botanic_varieties.*', 'botanic_species.name as specie_name')->with(['image', 'Specie', 'tags'])->withCount(['Articles', 'tags', 'images']); return $this->buildQuery($model); } @@ -25,7 +24,14 @@ class VarietiesDataTable extends DataTable ->editColumn('thumb', function (Variety $variety) { return Varieties::getThumb($variety->image); }) - ->rawColumns(['thumb', 'action']); + ->editColumn('tags2', function (Variety $variety) { + $html = ''; + foreach ($variety->tags as $tag) { + $html .= '' . $tag->slug . ' '; + } + return $html; + }) + ->rawColumns(['thumb', 'tags2', 'action']); return parent::modifier($datatables); } @@ -36,8 +42,10 @@ class VarietiesDataTable extends DataTable Column::make('Specie.name')->data('specie_name')->title('Espèce'), Column::make('thumb')->title('')->searchable(false)->orderable(false)->width(40)->class('text-center'), Column::make('name')->title('Nom'), - Column::make('articles_count')->title('Nb articles')->class('text-right')->searchable(false), - Column::make('tags_count')->title('Nb tags')->class('text-right')->searchable(false), + Column::make('tags2')->title('Tags')->searchable(false)->orderable(false), + Column::make('articles_count')->title('#Art')->class('text-right')->searchable(false), + Column::make('tags_count')->title('#Tag')->class('text-right')->searchable(false), + Column::make('images_count')->title('#Pho')->class('text-right')->searchable(false), $this->makeColumnButtons(), ]; } diff --git a/app/Datatables/Shop/ArticlesDataTable.php b/app/Datatables/Shop/ArticlesDataTable.php index 3e0e2862..fcede020 100644 --- a/app/Datatables/Shop/ArticlesDataTable.php +++ b/app/Datatables/Shop/ArticlesDataTable.php @@ -15,7 +15,7 @@ class ArticlesDataTable extends DataTable public function query(Article $model) { - $model = $model::with(['article_nature', 'image'])->withCount(['categories', 'tags', 'offers']); + $model = $model::with(['article_nature', 'image'])->withCount(['categories', 'images', 'offers', 'tags']); $model = self::filterByArticleNature($model); return $this->buildQuery($model); } @@ -35,7 +35,14 @@ class ArticlesDataTable extends DataTable ->editColumn('article_nature.name', function (Article $article) { return $article->article_nature ? $article->article_nature->name : ''; }) - ->rawColumns(['thumb', 'action']); + ->editColumn('tags2', function (Article $article) { + $html = ''; + foreach ($article->tags as $tag) { + $html .= '' . $tag->slug . ' '; + } + return $html; + }) + ->rawColumns(['tags2', 'thumb', 'action']); return parent::modifier($datatables); } @@ -45,9 +52,11 @@ class ArticlesDataTable extends DataTable Column::make('article_nature.name')->title('Nature'), Column::make('thumb')->title('')->searchable(false)->orderable(false)->width(40)->class('text-center'), Column::make('name')->title('Nom'), - Column::make('tags_count')->title('Tags')->class('text-right')->searchable(false), - Column::make('categories_count')->title('Rayons')->class('text-right')->searchable(false), - Column::make('offers_count')->title('Offres')->class('text-right')->searchable(false), + Column::make('tags2')->title('Tags')->searchable(false)->orderable(false), + Column::make('tags_count')->title('#Tag')->class('text-right')->searchable(false), + Column::make('categories_count')->title('#Ray')->class('text-right')->searchable(false), + Column::make('offers_count')->title('#Ofr')->class('text-right')->searchable(false), + Column::make('images_count')->title('#Pho')->class('text-right')->searchable(false), $this->makeColumnButtons(), ]; } diff --git a/app/Datatables/Shop/OffersDataTable.php b/app/Datatables/Shop/OffersDataTable.php index 15ccd27e..2bfaf3db 100644 --- a/app/Datatables/Shop/OffersDataTable.php +++ b/app/Datatables/Shop/OffersDataTable.php @@ -9,6 +9,7 @@ use App\Models\Shop\Offer; class OffersDataTable extends DataTable { public $model_name = 'offers'; + public $sortedColumn = 1; public function query(Offer $model) { @@ -30,13 +31,36 @@ class OffersDataTable extends DataTable return $package_id ? $model->byPackage($package_id) : $model; } + public function modifier($datatables) + { + $datatables + ->editColumn('status_id', function (Offer $offer) { + return view("components.form.toggle", [ + 'value' => $offer->status_id, + 'on' => __('active'), + 'off' => __('inactive'), + 'meta' => 'data-id='.$offer->id, + 'size' => 'sm', + ]); + }) + ->editColumn('stock_delayed', function (Offer $offer) { + return $offer->stock_delayed . ' - ' . $offer->delay_type; + }) + ->rawColumns(['active', 'action']); + return parent::modifier($datatables); + } + protected function getColumns() { return [ + Column::make('status_id')->title('')->width(40), Column::make('article.name')->title('Article'), Column::make('article.article_nature.name')->title('Nature'), Column::make('variation.name')->title('Déclinaison'), Column::make('tariff.name')->title('Tarif'), + Column::make('stock_current')->title('Appro im'), + Column::make('stock_delayed')->title('Appro délai'), + Column::make('stock_ondemand')->title('Dmde'), $this->makeColumnButtons(), ]; } diff --git a/app/Datatables/Shop/TagsDataTable.php b/app/Datatables/Shop/TagsDataTable.php index 95c138b9..0f94b18e 100644 --- a/app/Datatables/Shop/TagsDataTable.php +++ b/app/Datatables/Shop/TagsDataTable.php @@ -13,18 +13,29 @@ class TagsDataTable extends DataTable public function query(Tag $model) { - $model = $model::with('group')->withCount(['articles', 'species', 'varieties']); + $model = $model::with('group')->withCount(['articles', 'shelves', 'species', 'varieties']); return $this->buildQuery($model); } + public function modifier($datatables) + { + $datatables + ->editColumn('name', function (Tag $tag) { + return $tag->name; + }) + ->rawColumns(['active', 'action']); + return parent::modifier($datatables); + } + protected function getColumns() { return [ Column::make('group.name')->title('Groupe'), Column::make('name')->title('Nom'), - Column::make('articles_count')->title('Articles')->class('text-right')->searchable(false), - Column::make('species_count')->title('Espèces')->class('text-right')->searchable(false), - Column::make('varieties_count')->title('Variétés')->class('text-right')->searchable(false), + Column::make('articles_count')->title('#Art')->class('text-right')->searchable(false), + Column::make('species_count')->title('#Esp')->class('text-right')->searchable(false), + Column::make('varieties_count')->title('#Var')->class('text-right')->searchable(false), + Column::make('shelves_count')->title('#Ray')->class('text-right')->searchable(false), $this->makeColumnButtons(), ]; } diff --git a/app/Datatables/Shop/TariffsDataTable.php b/app/Datatables/Shop/TariffsDataTable.php index 596cd362..662949a3 100644 --- a/app/Datatables/Shop/TariffsDataTable.php +++ b/app/Datatables/Shop/TariffsDataTable.php @@ -13,7 +13,7 @@ class TariffsDataTable extends DataTable public function query(Tariff $model) { - $model = $model->with(['sale_channel'])->select(['shop_tariffs.*']); + $model = $model->with(['sale_channels'])->select(['shop_tariffs.*']); return $this->buildQuery($model); } @@ -23,7 +23,14 @@ class TariffsDataTable extends DataTable ->editColumn('status', function (Tariff $tariff) { return Tariffs::getStatus($tariff['status_id']); }) - ->rawColumns(['action']) + ->editColumn('sale_channels2', function (Tariff $tariff) { + $html = ''; + foreach ($tariff->sale_channels as $sale_channel) { + $html .= $sale_channel->code . ', '; + } + return $html; + }) + ->rawColumns(['sale_channels2', 'action']) ; return parent::modifier($datatables); } @@ -33,7 +40,7 @@ class TariffsDataTable extends DataTable return [ Column::make('status_id')->data('status')->title('status'), Column::make('name')->title('Nom'), - Column::make('sale_channel.name')->title('Canal de vente par défaut'), + Column::make('sale_channels2')->title('Canaux de vente'), Column::make('code')->title('Code'), Column::make('ref')->title('Référence'), $this->makeColumnButtons(), diff --git a/app/Datatables/Shop/VariationsDataTable.php b/app/Datatables/Shop/VariationsDataTable.php index 45d977a0..7271e298 100644 --- a/app/Datatables/Shop/VariationsDataTable.php +++ b/app/Datatables/Shop/VariationsDataTable.php @@ -19,6 +19,9 @@ class VariationsDataTable extends DataTable public function modifier($datatables) { $datatables + ->editColumn('unity_value', function (Variation $variation) { + return $variation->unity ? $variation->unity->value : ''; + }) ->rawColumns(['description','action']) ; return parent::modifier($datatables); @@ -29,9 +32,9 @@ class VariationsDataTable extends DataTable return [ Column::make('package.value')->title('Package'), Column::make('quantity')->title('Quantité')->class('text-right')->with(80), - Column::make('unity.value')->title('Unité')->searchable(false)->with(80), + Column::make('unity_value')->title('Unité')->searchable(false)->with(80), Column::make('description')->title('Description'), - Column::make('offers_count')->title('Offres')->searchable(false)->class('text-right'), + Column::make('offers_count')->title('#Ofr')->searchable(false)->class('text-right'), $this->makeColumnButtons(), ]; } diff --git a/app/Http/Controllers/Admin/Shop/OfferController.php b/app/Http/Controllers/Admin/Shop/OfferController.php index dab91cac..440fb6e6 100644 --- a/app/Http/Controllers/Admin/Shop/OfferController.php +++ b/app/Http/Controllers/Admin/Shop/OfferController.php @@ -74,4 +74,11 @@ class OfferController extends Controller $data['tariff'] = Tariffs::getPrices($id); return view('Admin.Shop.Offers.partials.tariff', $data); } + + public function toggleActive(Request $request) + { + $data = Offers::toggle_active($request->input('id'), ($request->input('active') == 'true') ? 1 : 0); + return response()->json(['error' => 0]); + } + } diff --git a/app/Models/Shop/Shelve.php b/app/Models/Shop/Shelve.php index 03c3e3dc..0f630346 100644 --- a/app/Models/Shop/Shelve.php +++ b/app/Models/Shop/Shelve.php @@ -10,7 +10,7 @@ class Shelve extends Model use HasRelationships; protected $guarded = ['id']; - protected $table = 'shop_shelves'; + protected $table = 'shop_categories'; public function articles() { diff --git a/app/Models/Shop/Tag.php b/app/Models/Shop/Tag.php index 0f4fe11d..b847938e 100644 --- a/app/Models/Shop/Tag.php +++ b/app/Models/Shop/Tag.php @@ -5,6 +5,8 @@ namespace App\Models\Shop; use Illuminate\Database\Eloquent\Model; use Spatie\Translatable\HasTranslations; +use App\Models\Botanic\Specie; +use App\Models\Botanic\Variety; class Tag extends Model { @@ -25,19 +27,24 @@ class Tag extends Model return $this->morphedByMany(Article::class, 'taggable'); } - public function varieties() + public function group() { - return $this->morphedByMany(\App\Models\Botanic\Variety::class, 'taggable'); + return $this->hasOne(TagGroup::class, 'id', 'tag_group_id'); + } + + public function shelves() + { + return $this->morphedByMany(Shelve::class, 'taggable'); } public function species() { - return $this->morphedByMany(\App\Models\Botanic\Specie::class, 'taggable'); + return $this->morphedByMany(Specie::class, 'taggable'); } - public function group() + public function varieties() { - return $this->hasOne(TagGroup::class, 'id', 'tag_group_id'); + return $this->morphedByMany(Variety::class, 'taggable'); } public function scopeByGroup($query, $id) diff --git a/app/Models/Shop/Tariff.php b/app/Models/Shop/Tariff.php index c4d7e55a..d63d5dd7 100644 --- a/app/Models/Shop/Tariff.php +++ b/app/Models/Shop/Tariff.php @@ -21,6 +21,12 @@ class Tariff extends Model return $this->belongsTo(SaleChannel::class); } + public function sale_channels() + { + // return $this->HasManyThrough(SaleChannel::class, PriceList::class); + return $this->HasManyThrough(SaleChannel::class, PriceList::class, 'id', 'id', 'id', 'sale_channel_id'); + } + public function tariff_unity() { return $this->belongsTo(TariffUnity::class); diff --git a/app/Repositories/Shop/Offers.php b/app/Repositories/Shop/Offers.php index 425bd02f..4ad367c5 100644 --- a/app/Repositories/Shop/Offers.php +++ b/app/Repositories/Shop/Offers.php @@ -51,4 +51,10 @@ class Offers { return Offer::destroy($id); } + + public static function toggle_active($id, $active) + { + return self::update(['status_id' => $active], $id); + } + } diff --git a/app/Repositories/Shop/Unities.php b/app/Repositories/Shop/Unities.php index 86815ae1..1a26e2a3 100644 --- a/app/Repositories/Shop/Unities.php +++ b/app/Repositories/Shop/Unities.php @@ -23,7 +23,7 @@ class Unities public static function getName($id) { - return self::get($id)->value; + return self::get($id)->value ?? null; } public static function get($id) diff --git a/app/Repositories/Shop/Variations.php b/app/Repositories/Shop/Variations.php index 29000378..3c0a1b49 100644 --- a/app/Repositories/Shop/Variations.php +++ b/app/Repositories/Shop/Variations.php @@ -33,7 +33,7 @@ class Variations public static function getName($variation) { - return $variation->package->value . ' ' . $variation->quantity . ' ' . $variation->unity->value; + return $variation->package->value . ' ' . $variation->quantity . ' ' . ($variation->unity->value ?? null); } public static function buildName($data) diff --git a/resources/views/Admin/Botanic/Species/edit.blade.php b/resources/views/Admin/Botanic/Species/edit.blade.php index d82bf181..e7d91d6a 100644 --- a/resources/views/Admin/Botanic/Species/edit.blade.php +++ b/resources/views/Admin/Botanic/Species/edit.blade.php @@ -1,7 +1,7 @@ @extends('layout.index', [ - 'title' => __('Botanic.species.title'), - 'subtitle' => __('Botanic.species.edit'), - 'breadcrumb' => [__('Botanic.species.title'), __('Botanic.species.list')] + 'title' => __('botanic.species.title'), + 'subtitle' => __('botanic.species.edit'), + 'breadcrumb' => [__('botanic.species.title'), __('botanic.species.list')] ]) @section('content') diff --git a/resources/views/Admin/Botanic/Varieties/create.blade.php b/resources/views/Admin/Botanic/Varieties/create.blade.php index 2aac8f62..a39a9a75 100644 --- a/resources/views/Admin/Botanic/Varieties/create.blade.php +++ b/resources/views/Admin/Botanic/Varieties/create.blade.php @@ -1,16 +1,11 @@ @extends('layout.index', [ - 'title' => __('Botanic.varieties.title'), - 'subtitle' => __('Botanic.varieties.add'), - 'breadcrumb' => [__('Botanic.varieties.title'), __('Botanic.varieties.add')] + 'title' => __('botanic.varieties.title'), + 'subtitle' => __('botanic.varieties.add'), + 'breadcrumb' => [__('botanic.varieties.title'), __('botanic.varieties.add')] ]) -@include('boilerplate::load.fileinput') - @section('content') - {{ Form::open(['route' => 'Admin.Botanic.Varieties.store', 'id' => 'form', 'autocomplete' => 'off', 'files' => true]) }} - @include('Admin.Botanic.Varieties.form') - @endsection diff --git a/resources/views/Admin/Botanic/Varieties/edit.blade.php b/resources/views/Admin/Botanic/Varieties/edit.blade.php index 638ecfa6..1c63b7f2 100644 --- a/resources/views/Admin/Botanic/Varieties/edit.blade.php +++ b/resources/views/Admin/Botanic/Varieties/edit.blade.php @@ -5,10 +5,8 @@ ]) @section('content') - {{ Form::open(['route' => 'Admin.Botanic.Varieties.store', 'id' => 'form', 'autocomplete' => 'off', 'files' => true]) }} @include('Admin.Botanic.Varieties.form') - @endsection diff --git a/resources/views/Admin/Shop/Articles/partials/characteristics.blade.php b/resources/views/Admin/Shop/Articles/partials/characteristics.blade.php index f35b4fc6..137d27f3 100644 --- a/resources/views/Admin/Shop/Articles/partials/characteristics.blade.php +++ b/resources/views/Admin/Shop/Articles/partials/characteristics.blade.php @@ -4,7 +4,7 @@
{{ Form::label('model', 'Familles de produit') }}
- @include('components.form.select', ['name' => 'product_type', 'id_name' => 'product_type', 'list' => $models_options, 'value' => $article['product_type'] ?? null, 'class' => 'select2', 'with_empty' => '']) + @include('components.form.select', ['name' => 'product_type', 'id_name' => 'product_type', 'list' => $models_options, 'value' => $article['product_type'] ?? null, 'class' => 'select2', 'with_empty' => '', 'required' => true])
{{ Form::label('model_id', 'Produit') }}
diff --git a/resources/views/Admin/Shop/Offers/list.blade.php b/resources/views/Admin/Shop/Offers/list.blade.php index ba32531e..feaffac0 100644 --- a/resources/views/Admin/Shop/Offers/list.blade.php +++ b/resources/views/Admin/Shop/Offers/list.blade.php @@ -6,11 +6,24 @@ @section('content') @component('components.card') - @include('components.datatable', ['route' => route('Admin.Shop.Offers.index'), 'model' => 'offers', 'with_filters' => true]) + @include('components.datatable', ['route' => route('Admin.Shop.Offers.index'), 'model' => 'offers', 'with_filters' => true, 'callback' => 'handleOffer();']) @component('components.layout.modal', ['title' => 'Filtres', 'id' => 'modal-offers-filters']) @include('Admin.Shop.Offers.partials.filters', ['model' => 'offers']) @endcomponent @endcomponent @endsection -@include('load.form.select2') \ No newline at end of file +@include('load.form.select2') +@include('load.form.toggle') + +@push('js') + +@endpush diff --git a/resources/views/Admin/Shop/Offers/partials/article.blade.php b/resources/views/Admin/Shop/Offers/partials/article.blade.php index 9bc939c8..7d1d0351 100644 --- a/resources/views/Admin/Shop/Offers/partials/article.blade.php +++ b/resources/views/Admin/Shop/Offers/partials/article.blade.php @@ -6,11 +6,11 @@ {{ Form::label('ref', 'Référence') }}
{{ $article['ref'] ?? null }}
-
+
{{ Form::label('name', 'Nom') }}
{{ $article['name'] ?? null }}
-
+
{!! $article['image'] !!}
diff --git a/resources/views/Admin/Shop/PriceLists/partials/table-prices.blade.php b/resources/views/Admin/Shop/PriceLists/partials/table-prices.blade.php index b272ebf0..0e4f2f8e 100644 --- a/resources/views/Admin/Shop/PriceLists/partials/table-prices.blade.php +++ b/resources/views/Admin/Shop/PriceLists/partials/table-prices.blade.php @@ -3,7 +3,7 @@ @foreach ($prices as $price) - {{ $price['quantity'] ?? null }} : {{ $price['price'] ?? null }} € + {{ $price['code'] ?? null }} - {{ $price['quantity'] ?? null }} : {{ $price['price_taxed'] ?? null }} € @endforeach diff --git a/routes/Admin/Shop/Offers.php b/routes/Admin/Shop/Offers.php index 9d22b6f6..406c3234 100644 --- a/routes/Admin/Shop/Offers.php +++ b/routes/Admin/Shop/Offers.php @@ -10,4 +10,5 @@ Route::prefix('Offers')->name('Offers.')->group(function () { Route::get('previewArticle/{id?}', 'OfferController@previewArticle')->name('previewArticle'); Route::get('previewVariation/{id?}', 'OfferController@previewVariation')->name('previewVariation'); Route::get('previewTariff/{id?}', 'OfferController@previewTariff')->name('previewTariff'); + Route::post('toggleActive', 'OfferController@toggleActive')->name('toggleActive'); });