fixes, add weight

This commit is contained in:
Ludovic CANDELLIER
2023-08-01 21:55:17 +02:00
parent 5f1ff26196
commit 6f2a985edc
11 changed files with 295 additions and 180 deletions

View File

@@ -22,18 +22,18 @@ class OffersDataTable extends DataTable
return $this->buildQuery($model); return $this->buildQuery($model);
} }
public static function filterByArticleNature($model, $article_nature_id = false) public static function filterByArticleNature($model, $articleNatureId = false)
{ {
$article_nature_id = $article_nature_id ? $article_nature_id : self::isFilteredByField('article_nature_id'); $articleNatureId = $articleNatureId ? $articleNatureId : self::isFilteredByField('article_nature_id');
return $article_nature_id ? $model->byArticleNature($article_nature_id) : $model; return $articleNatureId ? $model->byArticleNature($articleNatureId) : $model;
} }
public static function filterByPackage($model, $package_id = false) public static function filterByPackage($model, $packageId = false)
{ {
$package_id = $package_id ? $package_id : self::isFilteredByField('package_id'); $packageId = $packageId ? $packageId : self::isFilteredByField('package_id');
return $package_id ? $model->byPackage($package_id) : $model; return $packageId ? $model->byPackage($packageId) : $model;
} }
public function modifier($datatables) public function modifier($datatables)
@@ -49,7 +49,7 @@ class OffersDataTable extends DataTable
'on' => __('active'), 'on' => __('active'),
'off' => __('inactive'), 'off' => __('inactive'),
'meta' => 'data-id='.$offer->id, 'meta' => 'data-id='.$offer->id,
'size' => 'sm', 'size' => 'xs',
]); ]);
}) })
->editColumn('stock_delayed', function (Offer $offer) { ->editColumn('stock_delayed', function (Offer $offer) {
@@ -63,15 +63,16 @@ class OffersDataTable extends DataTable
protected function getColumns() protected function getColumns()
{ {
return [ return [
Column::make('status_id')->title('')->width(40), Column::make('status_id')->title('')->width(40)->searchable(false),
Column::make('article.article_nature.name')->title('Nature')->defaultContent(''), Column::make('article.article_nature.name')->title('Nature')->defaultContent('')->searchable(false),
Column::make('thumb')->title('')->width(40)->searchable(false)->order(false), Column::make('thumb')->title('')->width(30)->searchable(false)->addClass('text-center'),
Column::make('article.name')->title('Article')->defaultContent(''), Column::make('article.name')->title('Article')->defaultContent(''),
Column::make('variation.name')->title('Déclinaison')->defaultContent(''), Column::make('variation.name')->title('Déclinaison')->defaultContent('')->searchable(false),
Column::make('tariff.name')->title('Tarif')->defaultContent(''), Column::make('weight')->title('Poids')->searchable(false)->addClass('text-right'),
Column::make('stock_current')->title('Appro im')->searchable(false), Column::make('tariff.name')->title('Tarif')->defaultContent('')->searchable(false),
Column::make('stock_delayed')->title('Appro délai')->searchable(false), Column::make('stock_current')->title('Appro im')->searchable(false)->addClass('text-right'),
Column::make('stock_ondemand')->title('Dmde')->searchable(false), Column::make('stock_delayed')->title('Appro délai')->searchable(false)->addClass('text-right'),
Column::make('stock_ondemand')->title('Dmde')->searchable(false)->addClass('text-right'),
$this->makeColumnButtons(), $this->makeColumnButtons(),
]; ];
} }

View File

@@ -3,18 +3,19 @@
namespace App\Http\Controllers\Shop\Auth; namespace App\Http\Controllers\Shop\Auth;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Http\Requests\Shop\RegisterCustomer;
use App\Repositories\Shop\CustomerAddresses; use App\Repositories\Shop\CustomerAddresses;
use App\Repositories\Shop\Customers; use App\Repositories\Shop\Customers;
use Illuminate\Auth\Events\Registered;
use Illuminate\Foundation\Auth\EmailVerificationRequest; use Illuminate\Foundation\Auth\EmailVerificationRequest;
use Illuminate\Foundation\Auth\RegistersUsers; use Illuminate\Foundation\Auth\RegistersUsers;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\Validator;
use Sebastienheyd\Boilerplate\Rules\Password;
class RegisterController extends Controller class RegisterController extends Controller
{ {
use RegistersUsers; // use RegistersUsers;
protected $redirectTo; protected $redirectTo;
@@ -28,21 +29,31 @@ class RegisterController extends Controller
return route(config('boilerplate.app.redirectTo', 'boilerplate.dashboard')); return route(config('boilerplate.app.redirectTo', 'boilerplate.dashboard'));
} }
protected function validator(array $data)
{
return Validator::make($data, [
'last_name' => 'required|max:255',
'first_name' => 'required|max:255',
'email' => 'required|email|max:255|unique:shop_customers,email,NULL,id,deleted_at,NULL',
'password' => ['required', 'confirmed', new Password()],
]);
}
public function showRegistrationForm() public function showRegistrationForm()
{ {
return view('Shop.auth.register'); return view('Shop.auth.register');
} }
public function register(Request $request)
{
dump('ici');
exit;
// event(new Registered($user = $this->create($request->all())));
$user = $this->create($request->all());
dump($user);
exit;
$this->guard()->login($user);
if ($response = $this->registered($request, $user)) {
return $response;
}
return $request->wantsJson()
? new JsonResponse([], 201)
: redirect($this->redirectPath());
}
protected function create(array $data) protected function create(array $data)
{ {
$user = Customers::create($data); $user = Customers::create($data);

View File

@@ -0,0 +1,24 @@
<?php
namespace App\Http\Requests\Shop;
use Illuminate\Foundation\Http\FormRequest;
use Sebastienheyd\Boilerplate\Rules\Password;
class RegisterCustomer extends FormRequest
{
public function authorize()
{
return true;
}
public function rules()
{
return [
'last_name' => 'required|max:255',
'first_name' => 'required|max:255',
'email' => 'required|email|max:255|unique:shop_customers,email,NULL,id,deleted_at,NULL',
'password' => ['required', 'confirmed', new Password()],
];
}
}

View File

@@ -159,16 +159,17 @@ return [
'confirmdelete' => 'Confirmez-vous la suppression de l\'offre ?', 'confirmdelete' => 'Confirmez-vous la suppression de l\'offre ?',
], ],
'packages' => [ 'packages' => [
'title' => 'Packages', 'title' => 'Déclinaisons',
'description' => 'Gérer les packages', 'name' => 'Déclinaison',
'add' => 'Ajouter un package', 'description' => 'Gérer les déclinaisons',
'edit' => 'Editer un package', 'add' => 'Ajouter une déclinaison',
'del' => 'Effacer un package', 'edit' => 'Editer une déclinaison',
'list' => 'Liste des packages', 'del' => 'Effacer une déclinaison',
'successadd' => 'Le package été correctement ajouté', 'list' => 'Liste des déclinaisons',
'successmod' => 'Le package a été correctement modifié', 'successadd' => 'La déclinaison été correctement ajoutée',
'successdel' => 'Le package a été correctement effacé', 'successmod' => 'La déclinaison a été correctement modifiée',
'confirmdelete' => 'Confirmez-vous la suppression du package ?', 'successdel' => 'La déclinaison a été correctement effacée',
'confirmdelete' => 'Confirmez-vous la suppression de la déclinaison ?',
], ],
'prices' => [ 'prices' => [
'title' => 'Prix', 'title' => 'Prix',

View File

@@ -1,62 +1,103 @@
<div class="row mb-3"> <div class="row mb-3">
<div class="col-6"> <div class="col-8">
<div class="row mb-3"> <div class="row mb-3">
<div class="col-12"> <div class="col-12">
{{ Form::label('article_id', 'Article') }} @include('components.form.select', [
@include('components.form.select', ['name' => 'article_id', 'id_name' => 'article_id', 'list' => $articles ?? null, 'value' => $offer['article_id'] ?? null, 'with_empty' => '', 'class' => 'select2 select_article']) 'name' => 'article_id',
</div> 'id_name' => 'article_id',
</div> 'list' => $articles ?? null,
'value' => $offer['article_id'] ?? null,
'with_empty' => '',
'class' => 'select2 select_article',
'label' => 'Article',
])
</div>
</div>
<div class="row mb-3"> <div class="row mb-3">
<div class="col-12"> <div class="col-4">
{{ Form::label('variation_id', 'Déclinaison') }} @include('components.form.select', [
@include('components.form.select', ['name' => 'variation_id', 'id_name' => 'variation_id', 'list' => $variations ?? null, 'value' => $offer['variation_id'] ?? null, 'with_empty' => '', 'class' => 'select2 select_variation']) 'name' => 'variation_id',
</div> 'id_name' => 'variation_id',
</div> 'list' => $variations ?? null,
'value' => $offer['variation_id'] ?? null,
'with_empty' => '',
'class' => 'select2 select_variation',
'label' => __('shop.packages.name'),
'required' => true,
])
</div>
<div class="col-4">
@include('components.form.select', [
'name' => 'tariff_id',
'id_name' => 'tariff_id',
'list' => $tariffs ?? null,
'value' => $offer['tariff_id'] ?? null,
'with_empty' => '',
'class' => 'select2 select_tariffs',
'label' => 'Tarif',
'required' => true,
])
</div>
<div class="col-4">
@include('components.form.input', [
'name' => 'weight',
'value' => $offer['weight'] ?? null,
'label' => 'Poids en g',
])
</div>
</div>
<div class="row mb-3"> @component('components.card', ['title' => 'Disponibilité', 'class' => 'mt-5'])
<div class="col-12"> <div class="row mb-3 mt-3">
{{ Form::label('tariff_id', 'Tarif') }} <div class="col-4">
@include('components.form.select', ['name' => 'tariff_id', 'id_name' => 'tariff_id', 'list' => $tariffs ?? null, 'value' => $offer['tariff_id'] ?? null, 'with_empty' => '', 'class' => 'select2 select_tariffs']) @include('components.form.inputs.money', [
</div> 'name' => 'stock_current',
</div> 'value' => $offer['stock_current'] ?? 0,
'label' => 'Appro immédiate',
@component('components.card', ['title' => 'Disponibilité']) ])
<div class="row mb-3"> </div>
<div class="col-12 col-xl-6"> <div class="col-4">
{{ Form::label('stock_current', 'Appro immédiate') }} @include('components.form.inputs.money', [
@include('components.form.inputs.money', ['name' => 'stock_current', 'value' => $offer['stock_current'] ?? 0]) 'name' => 'stock_delayed',
</div> 'value' => $offer['stock_delayed'] ?? 0,
</div> 'label' => 'Appro sur delai',
<div class="row mb-3"> ])
<div class="col-6"> </div>
{{ Form::label('stock_delayed', 'Appro sur delai') }} <div class="col-4">
@include('components.form.inputs.money', ['name' => 'stock_delayed', 'value' => $offer['stock_delayed'] ?? 0]) @include('components.form.input', [
</div> 'name' => 'delay_type',
<div class="col-6"> 'value' => $offer['delay_type'] ?? null,
{{ Form::label('delay_type', 'Délai type') }} 'label' => 'Délai type',
@include('components.form.input', ['name' => 'delay_type', 'value' => $offer['delay_type'] ?? null]) ])
</div> </div>
</div> </div>
<div class="row mb-3"> <div class="row mb-3">
<div class="col-6"> <div class="col-6">
{{ Form::label('stock_ondemand', 'Appro sur demande') }} @include('components.form.toggle', [
@include('components.form.toggle', ['name' => 'stock_ondemand', 'value' => $offer['stock_ondemand'] ?? 0]) 'name' => 'stock_ondemand',
</div> 'value' => $offer['stock_ondemand'] ?? 0,
<div class="col-6"> 'label' => 'Appro sur demande',
{{ Form::label('minimum_ondemand', 'Minimum de quantité') }} 'size' => 'md',
@include('components.form.inputs.money', ['name' => 'minimum_ondemand', 'value' => $offer['minimum_ondemand'] ?? 0]) ])
</div> </div>
</div> <div class="col-6">
@endcomponent @include('components.form.inputs.money', [
</div> 'name' => 'minimum_ondemand',
<div class="col-6"> 'value' => $offer['minimum_ondemand'] ?? 0,
@component('components.card', ['title' => 'Previsualisation']) 'label' => 'Minimum de quantité',
<div id="preview-article"></div> ])
<div id="preview-variation"></div> </div>
<div id="preview-tariff"></div> </div>
@endcomponent @endcomponent
</div> </div>
<div class="col-4">
@component('components.card', ['title' => 'Previsualisation'])
<div id="preview-article"></div>
<div id="preview-variation"></div>
<div id="preview-tariff"></div>
@endcomponent
</div>
</div> </div>
@@ -67,60 +108,60 @@
@include('load.form.select2') @include('load.form.select2')
@push('js') @push('js')
<script> <script>
function handleArticle() { function handleArticle() {
$('.select_article').change(function() { $('.select_article').change(function() {
previewArticle($(this).val()); previewArticle($(this).val());
}) })
} }
function previewArticle(id) { function previewArticle(id) {
var url = '{{ route('Admin.Shop.Offers.previewArticle') }}/' + id; var url = '{{ route('Admin.Shop.Offers.previewArticle') }}/' + id;
$('#preview-article').load(url, function() { $('#preview-article').load(url, function() {
initChevron(); initChevron();
}); });
} }
function handleVariation() { function handleVariation() {
$('.select_variation').change(function() { $('.select_variation').change(function() {
previewVariation($(this).val()); previewVariation($(this).val());
}) })
} }
function previewVariation(id) { function previewVariation(id) {
var url = '{{ route('Admin.Shop.Offers.previewVariation') }}/' + id; var url = '{{ route('Admin.Shop.Offers.previewVariation') }}/' + id;
$('#preview-variation').load(url, function() { $('#preview-variation').load(url, function() {
initChevron(); initChevron();
}); });
} }
function handleTariff() { function handleTariff() {
$('.select_tariffs').change(function() { $('.select_tariffs').change(function() {
previewTariff($(this).val()); previewTariff($(this).val());
}) })
} }
function previewTariff(id) { function previewTariff(id) {
var url = '{{ route('Admin.Shop.Offers.previewTariff') }}/' + id; var url = '{{ route('Admin.Shop.Offers.previewTariff') }}/' + id;
$('#preview-tariff').load(url, function() { $('#preview-tariff').load(url, function() {
initChevron(); initChevron();
}); });
} }
function initPreview() { function initPreview() {
previewArticle("{{ $offer['article_id'] ?? null }}"); previewArticle("{{ $offer['article_id'] ?? null }}");
previewVariation("{{ $offer['variation_id'] ?? null }}"); previewVariation("{{ $offer['variation_id'] ?? null }}");
previewTariff("{{ $offer['tariff_id'] ?? null }}"); previewTariff("{{ $offer['tariff_id'] ?? null }}");
} }
handleArticle(); handleArticle();
handleVariation(); handleVariation();
handleTariff(); handleTariff();
initChevron(); initChevron();
initSaveForm('#offer-form'); initSaveForm('#offer-form');
initSelect2(); initSelect2();
@if ($offer['id'] ?? false) @if ($offer['id'] ?? false)
initPreview(); initPreview();
@endif @endif
</script> </script>
@endpush @endpush

View File

@@ -1,29 +1,34 @@
@extends('layout.index', [ @extends('layout.index', [
'title' => __('shop.offers.title'), 'title' => __('shop.offers.title'),
'subtitle' => __('shop.offers.list'), 'subtitle' => __('shop.offers.list'),
'breadcrumb' => [__('shop.offers.title')] 'breadcrumb' => [__('shop.offers.title')]
]) ])
@section('content') @section('content')
@component('components.card') @component('components.card')
@include('components.datatable', ['route' => route('Admin.Shop.Offers.index'), 'model' => 'offers', 'with_filters' => true, 'callback' => 'handleOffer();']) @include('components.datatable', [
@component('components.layout.modal', ['title' => 'Filtres', 'id' => 'modal-offers-filters']) 'route' => route('Admin.Shop.Offers.index'),
@include('Admin.Shop.Offers.partials.filters', ['model' => 'offers']) 'model' => 'offers',
@endcomponent 'with_filters' => true,
@endcomponent 'callback' => 'handleOffer();',
])
@component('components.layout.modal', ['title' => 'Filtres', 'id' => 'modal-offers-filters'])
@include('Admin.Shop.Offers.partials.filters', ['model' => 'offers'])
@endcomponent
@endcomponent
@endsection @endsection
@include('load.form.select2') @include('load.form.select2')
@include('load.form.toggle') @include('load.form.toggle')
@push('js') @push('js')
<script> <script>
function handleOffer() { function handleOffer() {
initToggle("{{ route('Admin.Shop.Offers.toggleActive') }}"); initToggle("{{ route('Admin.Shop.Offers.toggleActive') }}");
} }
$(document).ready(function () { $(document).ready(function () {
initSelect2(); initSelect2();
}); });
</script> </script>
@endpush @endpush

View File

@@ -1,14 +1,38 @@
<form id="{{ $model }}-filters"> <form id="{{ $model }}-filters">
<div class="row mb-3"> <div class="row mb-3">
<label class="col-4">{{ __('shop.article_natures.title') }}</label> <label class="col-4">{{ __('shop.article_natures.title') }}</label>
<div class="col-8"> <div class="col-8">
@include('components.form.select', ['name' => 'article_nature_id', 'list' => $article_natures ?? [], 'value' => $filters['article_nature_id'] ?? null, 'class' => 'form-control-sm select2', 'with_empty' => '']) @include('components.form.select', [
</div> 'name' => 'article_nature_id',
</div> 'list' => $article_natures ?? [],
<div class="row mb-3"> 'value' => $filters['article_nature_id'] ?? null,
<label class="col-4">{{ __('shop.packages.title') }}</label> 'class' => 'form-control-sm select2',
<div class="col-8"> 'with_empty' => '',
@include('components.form.select', ['name' => 'package_id', 'list' => $packages ?? [], 'value' => $filters['package_id'] ?? null, 'class' => 'form-control-sm select2', 'with_empty' => '']) ])
</div> </div>
</div> </div>
<div class="row mb-3">
<label class="col-4">{{ __('shop.packages.title') }}</label>
<div class="col-8">
@include('components.form.select', [
'name' => 'package_id',
'list' => $packages ?? [],
'value' => $filters['package_id'] ?? null,
'class' => 'form-control-sm select2',
'with_empty' => '',
])
</div>
</div>
<div class="row mb-3">
<label class="col-4">{{ __('shop.prices.title') }}</label>
<div class="col-8">
@include('components.form.select', [
'name' => 'tariff_id',
'list' => $prices ?? [],
'value' => $filters['tariff_id'] ?? null,
'class' => 'form-control-sm select2',
'with_empty' => '',
])
</div>
</div>
</form> </form>

View File

@@ -2,7 +2,8 @@
<a href="{{ route('Shop.Articles.show', ['id' => $article['id'] ?? false ]) }}" class="green-dark"> <a href="{{ route('Shop.Articles.show', ['id' => $article['id'] ?? false ]) }}" class="green-dark">
<div class="content"> <div class="content">
<div class="content-overlay"></div> <div class="content-overlay"></div>
<img class="content-image card-img-top" src="{{ App\Repositories\Shop\Articles::getPreviewSrc($article['image'] ?? false) }}" alt="{{ $product_name }}"> <img class="content-image card-img-top"
src="{{ App\Repositories\Shop\Articles::getPreviewSrc($article['image'] ?? false) }}" alt="{{ $product_name }}">
<div class="content-details fadeIn-bottom"> <div class="content-details fadeIn-bottom">
<h3 class="content-title d-none"></h3> <h3 class="content-title d-none"></h3>
<p class="content-text">{!! $article['description'] !!}</p> <p class="content-text">{!! $article['description'] !!}</p>
@@ -19,14 +20,16 @@
</div> </div>
@include('Shop.Articles.partials.article_' . $product_type) @include('Shop.Articles.partials.article_' . $product_type)
</a> </a>
@switch ($article_nature) @switch ($article_nature ?? 0)
@case(1) @case(1)
<button type="button" class="btn btn-link bg-green text-white w-100 basket" data-id="{{ $article['semences']['id'] ?? false }}"> <button type="button" class="btn btn-link bg-green text-white w-100 basket"
data-id="{{ $article['semences']['id'] ?? false }}">
Ajout rapide Ajout rapide
</button> </button>
@break @break
@case(2) @case(2)
<button type="button" class="btn btn-link bg-green text-white w-100 basket" data-id="{{ $article['plants']['id'] ?? false }}"> <button type="button" class="btn btn-link bg-green text-white w-100 basket"
data-id="{{ $article['plants']['id'] ?? false }}">
Ajout rapide Ajout rapide
</button> </button>
@break @break

View File

@@ -36,6 +36,7 @@
'name' => 'email', 'name' => 'email',
'value' => $customer['email'] ?? '', 'value' => $customer['email'] ?? '',
'label' => 'Email', 'label' => 'Email',
'required' => true,
]) ])
</div> </div>
<div class="col-6"> <div class="col-6">

View File

@@ -34,7 +34,10 @@
<div class="row d-none" id="address_delivery"> <div class="row d-none" id="address_delivery">
<div class="col-12"> <div class="col-12">
@include('Shop.Customers.partials.address', ['label' => 'Adresse de livraison', 'prefix' => 'delivery_']) @include('Shop.Customers.partials.address', [
'label' => 'Adresse de livraison',
'prefix' => 'delivery_'
])
</div> </div>
</div> </div>
@@ -50,8 +53,7 @@
</div> </div>
</div> </div>
{!! Form::close() !!} </form>
@push('js') @push('js')
<script> <script>

View File

@@ -1,3 +1,5 @@
@include('components.form.label')
<input type="checkbox" name="{{ $name ?? ''}}" id="{{ $id_name ?? $name ?? '' }}" <input type="checkbox" name="{{ $name ?? ''}}" id="{{ $id_name ?? $name ?? '' }}"
class="{{ $class ?? 'toggle'}}" class="{{ $class ?? 'toggle'}}"
value="{{ $val ?? 1}}" value="{{ $val ?? 1}}"