From 045641e687fed712261c4b8110e949de9b469b94 Mon Sep 17 00:00:00 2001 From: ludo Date: Fri, 3 Jan 2025 03:46:45 +0100 Subject: [PATCH] fixes --- .../Admin/Shop/ContentsDataTable.php | 1 + .../Admin/Shop/InvoicePaymentController.php | 19 ++++-- .../Shop/Auth/RegisterController.php | 9 --- .../Controllers/Shop/CustomerController.php | 8 +++ app/Http/Controllers/Shop/OrderController.php | 8 ++- .../Controllers/Shop/PayboxController.php | 15 ++-- app/Http/Requests/Shop/RegisterCustomer.php | 12 ++++ app/Http/Requests/Shop/StoreOrderPost.php | 14 +++- app/Mail/ConfirmationCommande.php | 14 ++-- app/Models/Botanic/Specie.php | 14 ++++ app/Models/Botanic/Variety.php | 18 +++++ app/Models/Shop/Article.php | 8 +++ app/Models/Shop/InvoicePayment.php | 11 +++ app/Models/Shop/Tag.php | 62 ++++++++++++++++- app/Repositories/Shop/Contents.php | 26 +++++++ app/Repositories/Shop/CustomerAddresses.php | 30 +++++++- app/Repositories/Shop/Invoices.php | 28 +++++++- app/Repositories/Shop/TagGroups.php | 27 ++++++++ .../Shop/InvoicePayments/create.blade.php | 1 - .../Admin/Shop/InvoicePayments/form.blade.php | 5 +- .../views/Admin/Shop/Invoices/edit.blade.php | 2 +- .../views/Admin/Shop/Invoices/form.blade.php | 1 + .../Shop/Invoices/partials/payments.blade.php | 19 +++++- .../Baskets/partials/basketTotal.blade.php | 6 +- .../Shop/Customers/partials/address.blade.php | 24 ++++--- .../Customers/partials/addresses.blade.php | 9 ++- .../Customers/partials/registration.blade.php | 19 +++--- .../views/Shop/Orders/confirmed.blade.php | 12 ++-- resources/views/Shop/Orders/order.blade.php | 14 +++- .../Shop/Orders/partials/addresses.blade.php | 3 +- .../Shop/Orders/partials/deliveries.blade.php | 6 +- .../Shop/Orders/partials/payments.blade.php | 13 ++-- .../views/Shop/auth/partials/login.blade.php | 68 +++++++++---------- .../Shop/auth/partials/register.blade.php | 7 +- resources/views/load/form/save.blade.php | 1 - resources/views/paybox/aborted.blade.php | 7 -- resources/views/paybox/accepted.blade.php | 9 --- resources/views/paybox/paybox.blade.php | 11 +++ resources/views/paybox/refused.blade.php | 7 -- resources/views/paybox/send.blade.php | 23 ++++--- resources/views/paybox/waiting.blade.php | 9 --- routes/Admin/Shop/InvoicePayments.php | 4 +- routes/Admin/Shop/Invoices.php | 2 +- routes/Shop/Customers.php | 1 + 44 files changed, 442 insertions(+), 165 deletions(-) delete mode 100644 resources/views/Admin/Shop/InvoicePayments/create.blade.php delete mode 100644 resources/views/paybox/aborted.blade.php delete mode 100644 resources/views/paybox/accepted.blade.php create mode 100644 resources/views/paybox/paybox.blade.php delete mode 100644 resources/views/paybox/refused.blade.php delete mode 100644 resources/views/paybox/waiting.blade.php diff --git a/app/Datatables/Admin/Shop/ContentsDataTable.php b/app/Datatables/Admin/Shop/ContentsDataTable.php index 58341960..0aa49f32 100644 --- a/app/Datatables/Admin/Shop/ContentsDataTable.php +++ b/app/Datatables/Admin/Shop/ContentsDataTable.php @@ -25,6 +25,7 @@ class ContentsDataTable extends DataTable protected function getColumns() { return [ + Column::make('id')->title('id'), Column::make('text')->title('Texte'), $this->makeColumnButtons(), ]; diff --git a/app/Http/Controllers/Admin/Shop/InvoicePaymentController.php b/app/Http/Controllers/Admin/Shop/InvoicePaymentController.php index e5d91a76..47fadeca 100644 --- a/app/Http/Controllers/Admin/Shop/InvoicePaymentController.php +++ b/app/Http/Controllers/Admin/Shop/InvoicePaymentController.php @@ -5,6 +5,7 @@ namespace App\Http\Controllers\Admin\Shop; use App\Datatables\Admin\Shop\InvoicePaymentsDataTable; use App\Http\Controllers\Controller; use App\Repositories\Shop\InvoicePayments; +use App\Repositories\Shop\Invoices; use Illuminate\Http\Request; class InvoicePaymentController extends Controller @@ -14,18 +15,21 @@ class InvoicePaymentController extends Controller return $dataTable->render('Admin.Shop.InvoicePayments.list'); } - public function create() + public function create($invoice_id) { $data = InvoicePayments::init(); + $data['invoice_id'] = $invoice_id; - return view('Admin.Shop.InvoicePayments.create', $data); + return view('Admin.Shop.InvoicePayments.form', $data); } public function store(Request $request) { - $ret = InvoicePayments::store($request->all()); + $data = $request->all(); + $ret = InvoicePayments::store($data); + Invoices::checkPayments($data['invoice_id']); - return redirect()->route('Admin.Shop.InvoicePayments.index'); + return redirect()->route('Admin.Shop.Invoices.edit', ['id' => $request->input('invoice_id')]); } public function show($id) @@ -40,12 +44,15 @@ class InvoicePaymentController extends Controller { $data = InvoicePayments::init(); $data['invoice_payment'] = InvoicePayments::getArray($id); + $data['invoice_id'] = $data['invoice_payment']['invoice_id']; - return view('Admin.Shop.InvoicePayments.edit', $data); + return view('Admin.Shop.InvoicePayments.form', $data); } public function destroy($id) { - return InvoicePayments::destroy($id); + $payment = InvoicePayments::get($id); + InvoicePayments::destroy($id); + Invoices::checkPayments($payment->invoice_id); } } diff --git a/app/Http/Controllers/Shop/Auth/RegisterController.php b/app/Http/Controllers/Shop/Auth/RegisterController.php index 2b24940d..0aab6ed2 100644 --- a/app/Http/Controllers/Shop/Auth/RegisterController.php +++ b/app/Http/Controllers/Shop/Auth/RegisterController.php @@ -10,7 +10,6 @@ use Illuminate\Foundation\Auth\EmailVerificationRequest; use Illuminate\Http\JsonResponse; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; -use Sebastienheyd\Boilerplate\Rules\Password; class RegisterController extends Controller @@ -24,14 +23,6 @@ class RegisterController extends Controller public function register(RegisterCustomer $request) { - $request->validateWithBag('Errors', [ - '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()], - - ]); - if (back()->getTargetUrl() === route('Shop.Orders.store')) { $route = 'Shop.Orders.order'; } else { diff --git a/app/Http/Controllers/Shop/CustomerController.php b/app/Http/Controllers/Shop/CustomerController.php index 4bf58e5c..76615cbe 100644 --- a/app/Http/Controllers/Shop/CustomerController.php +++ b/app/Http/Controllers/Shop/CustomerController.php @@ -2,6 +2,7 @@ namespace App\Http\Controllers\Shop; +use App\Repositories\Shop\CustomerAddresses; use App\Repositories\Shop\Customers; use Illuminate\Http\Request; @@ -54,4 +55,11 @@ class CustomerController extends Controller return redirect()->route('Shop.Customers.edit'); } + + public function delete_address($id) + { + $ret = CustomerAddresses::destroy($id); + + return redirect()->route('Shop.Customers.edit'); + } } diff --git a/app/Http/Controllers/Shop/OrderController.php b/app/Http/Controllers/Shop/OrderController.php index eec82c06..66e10dd5 100644 --- a/app/Http/Controllers/Shop/OrderController.php +++ b/app/Http/Controllers/Shop/OrderController.php @@ -3,8 +3,10 @@ namespace App\Http\Controllers\Shop; use App\Datatables\Shop\CustomerOrdersDataTable; +use App\Http\Requests\Shop\StoreOrderPost; use App\Repositories\Core\User\ShopCart; use App\Repositories\Shop\Baskets; +use App\Repositories\Shop\Contents; use App\Repositories\Shop\Customers; use App\Repositories\Shop\Deliveries; use App\Repositories\Shop\DeliveryTypes; @@ -61,13 +63,14 @@ class OrderController extends Controller return redirect()->route('home'); } - public function store(Request $request) + public function store(StoreOrderPost $request) { $data = $request->all(); $data['customer_id'] = Customers::getId(); $data['sale_channel_id'] = $data['sale_channel_id'] ?? SaleChannels::getDefaultID(); $data['basket'] = Baskets::getBasketSummary($data['sale_channel_id'], $data['delivery_type_id'] ?? false); $order = Orders::saveOrder($data); + if ($order) { if ($data['payment_type'] === '1') { return Paybox::makeAuthorizationRequest($order); @@ -83,8 +86,9 @@ class OrderController extends Controller public function confirmed() { ShopCart::clear(); + $content = Contents::getOrderConfirmedContent(); - return view('Shop.Orders.confirmed'); + return view('Shop.Orders.confirmed', ['content' => $content]); } public function getPdf($uuid) diff --git a/app/Http/Controllers/Shop/PayboxController.php b/app/Http/Controllers/Shop/PayboxController.php index cacf813e..83650e16 100644 --- a/app/Http/Controllers/Shop/PayboxController.php +++ b/app/Http/Controllers/Shop/PayboxController.php @@ -3,38 +3,33 @@ namespace App\Http\Controllers\Shop; use App\Http\Controllers\Controller; +use App\Repositories\Shop\Contents; use Illuminate\Http\Request; class PayboxController extends Controller { public function accepted() { - return view('paybox.accepted'); + return view('paybox.paybox', ['content' => Contents::getPayboxConfirmedContent()]); } public function refused(Request $request) { - dump($request->all()); - exit; - - return view('paybox.refused'); + return view('paybox.paybox', ['content' => Contents::getPayboxRefusedContent()]); } public function aborted() { - return view('paybox.aborted'); + return view('paybox.paybox', ['content' => Contents::getPayboxAbortedContent()]); } public function waiting() { - return view('paybox.waiting'); + return view('paybox.waiting', ['content' => Contents::getPayboxWaitingContent()]); } public function process(Request $request) { - dump($request); - exit; - return view('paybox.send'); } } diff --git a/app/Http/Requests/Shop/RegisterCustomer.php b/app/Http/Requests/Shop/RegisterCustomer.php index d73e6c84..1ea214df 100644 --- a/app/Http/Requests/Shop/RegisterCustomer.php +++ b/app/Http/Requests/Shop/RegisterCustomer.php @@ -2,7 +2,9 @@ namespace App\Http\Requests\Shop; +use Illuminate\Contracts\Validation\Validator; use Illuminate\Foundation\Http\FormRequest; +use Illuminate\Validation\ValidationException; use Sebastienheyd\Boilerplate\Rules\Password; class RegisterCustomer extends FormRequest @@ -21,4 +23,14 @@ class RegisterCustomer extends FormRequest 'password' => ['required', 'confirmed', new Password()], ]; } + + protected function failedValidation(Validator $validator) + { + $response = redirect() + ->back() + ->withInput() + ->withErrors($validator->errors(), 'registration'); + + throw new ValidationException($validator, $response); + } } diff --git a/app/Http/Requests/Shop/StoreOrderPost.php b/app/Http/Requests/Shop/StoreOrderPost.php index 9d1b6366..74702170 100644 --- a/app/Http/Requests/Shop/StoreOrderPost.php +++ b/app/Http/Requests/Shop/StoreOrderPost.php @@ -14,7 +14,19 @@ class StoreOrderPost extends FormRequest public function rules() { return [ - 'user_id' => 'required', + 'invoice.invoice_address_id' => 'required', + 'delivery_id' => 'required', + 'payment_type' => 'required', + 'agree' => 'required', + ]; + } + + public function messages() + { + return [ + 'delivery_id.required' => 'Il est nécessaire de choisir un mode de livraison', + 'payment_type.required' => 'Il est nécessaire de choisir un mode de paiement', + 'agree.required' => 'Il est nécessaire d\'adhérer à nos conditions de vente', ]; } } diff --git a/app/Mail/ConfirmationCommande.php b/app/Mail/ConfirmationCommande.php index 8295f15e..3d5335f3 100644 --- a/app/Mail/ConfirmationCommande.php +++ b/app/Mail/ConfirmationCommande.php @@ -42,14 +42,16 @@ class ConfirmationCommande extends TemplateMailable public function __construct($order) { + $facturation_address = $order->invoice->address ? $order->invoice->address : $customer; + $delivery_address = $order->delivery_address ? $order->delivery_address : $customer; $this->prenom = $order->customer->first_name; $this->nom = $order->customer->last_name; - $this->facturation_adresse = $order->address->address; - $this->facturation_cp = $order->address->zipcode; - $this->facturation_ville = $order->address->city; - $this->livraison_adresse = $order->delivery_address->address; - $this->livraison_cp = $order->delivery_address->zipcode; - $this->livraison_ville = $order->delivery_address->city; + $this->facturation_adresse = $facturation_address->address; + $this->facturation_cp = $facturation_address->zipcode; + $this->facturation_ville = $facturation_address->city; + $this->livraison_adresse = $delivery_address->address; + $this->livraison_cp = $delivery_address->zipcode; + $this->livraison_ville = $delivery_address->city; $this->societe = $order->customer->company; $this->email = $order->customer->email; $this->numero_commande = $order->ref; diff --git a/app/Models/Botanic/Specie.php b/app/Models/Botanic/Specie.php index ac179508..70b0600b 100644 --- a/app/Models/Botanic/Specie.php +++ b/app/Models/Botanic/Specie.php @@ -47,4 +47,18 @@ class Specie extends Model implements HasMedia { return $query->where($this->table.'.name', $name); } + + public function scopeByTag($query, $tagId) + { + return $tagId ? $query->whereHas('tags', function ($query) use ($tagId) { + $query->byId($tagId); + }) : $query; + } + + public function scopeByTags($query, $tags) + { + return $tags ? $query->whereHas('tags', function ($query) use ($tags) { + $query->byIds($tags); + }) : $query; + } } diff --git a/app/Models/Botanic/Variety.php b/app/Models/Botanic/Variety.php index 1d9d2a88..93ba1a3a 100644 --- a/app/Models/Botanic/Variety.php +++ b/app/Models/Botanic/Variety.php @@ -37,4 +37,22 @@ class Variety extends Model implements HasMedia { return $this->morphToMany(Tag::class, 'taggable'); } + + public function scopeByTag($query, $tagId) + { + return $tagId ? $query->whereHas('tags', function ($query) use ($tagId) { + $query->byId($tagId); + })->orWhereHas('Specie', function($query) use ($tagId) { + $query->byTag($tagId); + }) : $query; + } + + public function scopeByTags($query, $tags) + { + return $tags ? $query->whereHas('tags', function ($query) use ($tags) { + $query->byIds($tags); + })->orWhereHas('Specie', function($query) use ($tags) { + $query->byTags($tags); + }) : $query; + } } diff --git a/app/Models/Shop/Article.php b/app/Models/Shop/Article.php index be93e1b2..d9c6bdfd 100644 --- a/app/Models/Shop/Article.php +++ b/app/Models/Shop/Article.php @@ -191,6 +191,10 @@ class Article extends Model implements HasMedia { return $tagId ? $query->whereHas('tags', function ($query) use ($tagId) { $query->byId($tagId); + })->orWhereHasMorph('product', [Variety::class], function($query) use ($tagId) { + $query->whereHas('tags', function ($query) use ($tagId) { + $query->where('id', $tagId); + }); }) : $query; } @@ -198,6 +202,10 @@ class Article extends Model implements HasMedia { return $tags ? $query->whereHas('tags', function ($query) use ($tags) { $query->byIds($tags); + })->orWhereHasMorph('product', [Variety::class], function($query) use ($tags) { + $query->whereHas('tags', function ($query) use ($tags) { + $query->whereIntegerInRaw('id', $tags); + }); }) : $query; } diff --git a/app/Models/Shop/InvoicePayment.php b/app/Models/Shop/InvoicePayment.php index d8acad5c..bc5e0a6f 100644 --- a/app/Models/Shop/InvoicePayment.php +++ b/app/Models/Shop/InvoicePayment.php @@ -2,6 +2,7 @@ namespace App\Models\Shop; +use App\Repositories\Core\DateTime; use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Venturecraft\Revisionable\RevisionableTrait; @@ -47,4 +48,14 @@ class InvoicePayment extends Model { return $query->where('payment_type', $paymentType); } + + public function getDateAttribute($value) + { + return DateTime::dateToLocale($value); + } + + public function setDateAttribute($value) + { + $this->attributes['date'] = DateTime::convert($value); + } } diff --git a/app/Models/Shop/Tag.php b/app/Models/Shop/Tag.php index ef71e485..c2fb0869 100644 --- a/app/Models/Shop/Tag.php +++ b/app/Models/Shop/Tag.php @@ -6,6 +6,7 @@ use App\Models\Botanic\Specie; use App\Models\Botanic\Variety; use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\MorphToMany; +use Illuminate\Support\Facades\DB; use Rinvex\Tags\Models\Tag as parentTag; class Tag extends parentTag @@ -78,6 +79,65 @@ class Tag extends parentTag ]); } + public static function countArticles($categoryId) + { + DB::table('tags') + // Articles directement liés au tag, filtrés par catégorie + ->leftJoin('taggables as direct', function ($join) { + $join->on('tags.id', '=', 'direct.tag_id') + ->where('direct.taggable_type', '=', Article::class); + }) + ->leftJoin('shop_articles', 'direct.taggable_id', '=', 'shop_articles.id') + ->whereExists(function ($query) use ($categoryId) { + $query->select(DB::raw(1)) + ->from('categories') + ->whereColumn('categories.id', 'shop_articles.category_id') + ->where('_lft', '>=', DB::raw("(SELECT _lft FROM categories WHERE id = {$categoryId})")) + ->where('_rgt', '<=', DB::raw("(SELECT _rgt FROM categories WHERE id = {$categoryId})")); + }) + + // Articles liés via une variété ayant le tag, filtrés par catégorie + ->leftJoin('taggables as via_variety', function ($join) { + $join->on('tags.id', '=', 'via_variety.tag_id') + ->where('via_variety.taggable_type', '=', Variety::class); + }) + ->leftJoin('botanic_varieties', 'via_variety.taggable_id', '=', 'botanic_varieties.id') + ->leftJoin('shop_articles as indirect_articles', function ($join) { + $join->on('varieties.id', '=', 'indirect_articles.product_id') + ->where('indirect_articles.product_type', '=', Variety::class); + }) + ->whereExists(function ($query) use ($categoryId) { + $query->select(DB::raw(1)) + ->from('categories') + ->whereColumn('categories.id', 'indirect_articles.category_id') + ->where('_lft', '>=', DB::raw("(SELECT _lft FROM categories WHERE id = {$categoryId})")) + ->where('_rgt', '<=', DB::raw("(SELECT _rgt FROM categories WHERE id = {$categoryId})")); + }) + + // Combinaison des deux types de liens et comptage + ->select('tags.id', 'tags.name', DB::raw('COUNT(DISTINCT shop_articles.id) + COUNT(DISTINCT indirect_articles.id) as article_count')) + ->groupBy('tags.id', 'tags.name') + ->get(); + } + + public function scopeWithFilteredArticleCounts($query, $categoryId) + { + return $query->withCount([ + // Articles directement liés au tag et filtrés par catégorie + 'articles as direct_article_count' => function ($query) use ($categoryId) { + $query->byCategoryParent($categoryId); + }, + + // Articles liés via Variety et filtrés par catégorie sur les articles eux-mêmes + 'articles as indirect_article_count' => function ($query) use ($categoryId) { + $query->whereHasMorph('product', [Variety::class], function ($subQuery) { + // Pas de catégorie sur Variety, pas de filtre ici + })->byCategoryParent($categoryId); + }, + ]) + ->havingRaw('(COALESCE(direct_article_count, 0) + COALESCE(indirect_article_count, 0)) > 0'); // Filtre les tags avec au moins un article + } + public function scopeById($query, $id) { return $query->where($this->table.'.id', $id); @@ -85,6 +145,6 @@ class Tag extends parentTag public function scopeByIds($query, $ids) { - return $query->whereIn($this->table.'.id', $ids); + return $query->whereIntegerInRaw($this->table.'.id', $ids); } } diff --git a/app/Repositories/Shop/Contents.php b/app/Repositories/Shop/Contents.php index 882f259a..69c6a09b 100644 --- a/app/Repositories/Shop/Contents.php +++ b/app/Repositories/Shop/Contents.php @@ -36,6 +36,32 @@ class Contents return self::get(4)->text ?? ''; } + public static function getOrderConfirmedContent() + { + return self::get(5)->text ?? 'Votre commande a été confirmée'; + } + + public static function getPayboxConfirmedContent() + { + return self::get(6)->text ?? 'Merci pour votre règlement. Votre commande sera traitée sous peu.'; + } + + public static function getPayboxRefusedContent() + { + return self::get(7)->text ?? 'Le paiement a été refusé.'; + } + + public static function getPayboxAbortedContent() + { + return self::get(8)->text ?? 'Le paiement a été annulé.'; + } + + public static function getPayboxWaitingContent() + { + return self::get(9)->text ?? 'Votre paiement est en attente. Cela peut prendre un certain temps jusqu\'à ce qu\'il soit terminé.'; + } + + public static function getModel() { return Content::query(); diff --git a/app/Repositories/Shop/CustomerAddresses.php b/app/Repositories/Shop/CustomerAddresses.php index 05e82a98..f384bbf1 100644 --- a/app/Repositories/Shop/CustomerAddresses.php +++ b/app/Repositories/Shop/CustomerAddresses.php @@ -10,18 +10,44 @@ class CustomerAddresses use Basic; public static function add($userId, $data) + { + self::addDeliveryAddress($userId, $data); + self::addInvoiceAddress($userId, $data); + } + + public static function addDeliveryAddress($userId, $data) { $name = $data['company'] ? $data['company'] : $data['first_name'].' '.$data['last_name']; $delivery = $data['use_for_delivery'] ?? false; - return self::store([ + $data = [ 'customer_id' => $userId, + 'type' => 2, 'name' => $name, 'address' => $delivery ? $data['delivery_address'] : $data['address'], 'address2' => $delivery ? $data['delivery_address2'] : $data['address2'], 'zipcode' => $delivery ? $data['delivery_zipcode'] : $data['zipcode'], 'city' => $delivery ? $data['delivery_city'] : $data['city'], - ]); + ]; + + return self::store($data); + } + + public static function addInvoiceAddress($userId, $data) + { + $name = $data['company'] ? $data['company'] : $data['first_name'].' '.$data['last_name']; + + $data = [ + 'customer_id' => $userId, + 'type' => 1, + 'name' => $name, + 'address' => $data['address'], + 'address2' => $data['address2'], + 'zipcode' => $data['zipcode'], + 'city' => $data['city'], + ]; + + return self::store($data); } public static function getInvoiceAddress($customerId) diff --git a/app/Repositories/Shop/Invoices.php b/app/Repositories/Shop/Invoices.php index 873b9b49..aee0edab 100644 --- a/app/Repositories/Shop/Invoices.php +++ b/app/Repositories/Shop/Invoices.php @@ -43,6 +43,31 @@ class Invoices return $data; } + public static function checkPayments($invoice_id) + { + $invoice = self::get($invoice_id); + $total = self::getPayments($invoice_id); + if ($total) { + $status = $total === (float) $invoice->total_shipped ? 2 : 1; + } else { + $status = 0; + } + $invoice->status = $status; + $invoice->save(); + } + + public static function getPayments($invoice_id) + { + $total = 0; + $invoice = self::get($invoice_id); + $payments = $invoice->payments; + foreach ($payments as $payment) { + $total += $payment->amount; + } + + return $total; + } + public static function getFullByUUID($id) { return self::getByUUID($id, self::full()); @@ -61,6 +86,7 @@ class Invoices 'order.delivery_address', 'order.detail', 'order.sale_channel', + 'order.customer', 'payments', ]; } @@ -106,7 +132,7 @@ class Invoices public static function statuses() { - return ['En attente', 'Paiement partiel', 'Soldée', 'Paiement rejeté']; + return ['En attente', 'Paiement partiel', 'Soldée']; } public static function getModel() diff --git a/app/Repositories/Shop/TagGroups.php b/app/Repositories/Shop/TagGroups.php index d24426dc..d2556e8b 100644 --- a/app/Repositories/Shop/TagGroups.php +++ b/app/Repositories/Shop/TagGroups.php @@ -2,6 +2,7 @@ namespace App\Repositories\Shop; +use App\Models\Botanic\Variety; use App\Models\Shop\Tag; use App\Models\Shop\TagGroup; use App\Traits\Model\Basic; @@ -15,6 +16,8 @@ class TagGroups { $data = []; $tags = Tag::withCountArticlesByCategory($category_id)->get()->toArray(); + dump($tags); + exit; $tagGroups = TagGroup::pluck('name', 'id')->toArray(); foreach ($tags as $tag) { if (! $tag['articles_count']) { @@ -31,6 +34,30 @@ class TagGroups return $data; } + public static function getWithTagsAndCountOffers2($categoryId = false) + { + return Tag::withCount([ + 'articles as direct_article_count' => function ($query) use ($categoryId) { + $query->byCategoryParent($categoryId); + }, + 'articles as indirect_article_count' => function ($query) use ($categoryId) { + $query->whereHasMorph('product', [Variety::class], function ($subQuery) use ($categoryId) { + $subQuery->whereHas('categories', function ($categoryQuery) use ($categoryId) { + $categoryQuery->byCategoryParent($categoryId); + }); + }); + }, + ]) + ->get() + ->map(function ($tag) { + $tag->total_articles = $tag->direct_article_count + $tag->indirect_article_count; + return $tag; + }) + ->filter(function ($tag) { + return $tag->total_articles > 0; // Garde uniquement les tags ayant des articles + }); + } + public static function isTagGroupHaveSelected($tagsSelected, $tags) { foreach ($tags as $tag) { diff --git a/resources/views/Admin/Shop/InvoicePayments/create.blade.php b/resources/views/Admin/Shop/InvoicePayments/create.blade.php deleted file mode 100644 index af874935..00000000 --- a/resources/views/Admin/Shop/InvoicePayments/create.blade.php +++ /dev/null @@ -1 +0,0 @@ -@include('Admin.Shop.InvoicePayments.form') diff --git a/resources/views/Admin/Shop/InvoicePayments/form.blade.php b/resources/views/Admin/Shop/InvoicePayments/form.blade.php index e9b9f98c..de5868ac 100644 --- a/resources/views/Admin/Shop/InvoicePayments/form.blade.php +++ b/resources/views/Admin/Shop/InvoicePayments/form.blade.php @@ -1,5 +1,7 @@ -f{{ Form::open(['route' => 'Admin.Shop.InvoicePayments.store', 'id' => 'invoice_payment-form', 'autocomplete' => 'off']) }} +{{ Form::open(['route' => 'Admin.Shop.InvoicePayments.store', 'id' => 'invoice_payment-form', 'autocomplete' => 'off']) }} + +
@@ -43,4 +45,5 @@ f{{ Form::open(['route' => 'Admin.Shop.InvoicePayments.store', 'id' => 'invoice_ diff --git a/resources/views/Admin/Shop/Invoices/edit.blade.php b/resources/views/Admin/Shop/Invoices/edit.blade.php index 246ed4b9..5123ce2a 100644 --- a/resources/views/Admin/Shop/Invoices/edit.blade.php +++ b/resources/views/Admin/Shop/Invoices/edit.blade.php @@ -1,7 +1,7 @@ @extends('layout.index', [ 'title' => 'Factures', 'subtitle' => 'Edition d\'une facture', - 'breadcrumb' => ['Articles'], + 'breadcrumb' => ['Factures'], ]) @section('content') diff --git a/resources/views/Admin/Shop/Invoices/form.blade.php b/resources/views/Admin/Shop/Invoices/form.blade.php index 1d19393f..a33ef76c 100644 --- a/resources/views/Admin/Shop/Invoices/form.blade.php +++ b/resources/views/Admin/Shop/Invoices/form.blade.php @@ -67,3 +67,4 @@ @include('load.layout.modal') +@include('load.form.save') diff --git a/resources/views/Admin/Shop/Invoices/partials/payments.blade.php b/resources/views/Admin/Shop/Invoices/partials/payments.blade.php index e79fba5f..d40ab98c 100644 --- a/resources/views/Admin/Shop/Invoices/partials/payments.blade.php +++ b/resources/views/Admin/Shop/Invoices/partials/payments.blade.php @@ -21,6 +21,10 @@ {{ $payment_types[$payment['payment_type']] }} {{ sprintf('%01.2f', $payment['amount']) }} € {{ $payment['reference'] }} + + + + @endforeach @@ -34,9 +38,15 @@ $('#add_payment').click(function() { InvoicePaymentCreate(); }); + $('.payment-edit').click(function() { + InvoicePaymentEdit($(this).data('id')); + }); + $('.payment-delete').click(function() { + InvoicePaymentDelete($(this).data('id')); + }); function InvoicePaymentCreate() { - var url_open = "{{ route('Admin.Shop.InvoicePayments.create') }}"; + var url_open = "{{ route('Admin.Shop.InvoicePayments.create') }}/{{ $invoice['id'] }}"; var url_save = "{{ route('Admin.Shop.InvoicePayments.store') }}"; openModal("Ajouter un paiement", '#invoice_payment-form', url_open, url_save, "InvoicePaymentRefresh();", 'sm'); @@ -49,8 +59,11 @@ "InvoicePaymentRefresh();", 'sm'); } - function InvoicePaymentRefresh() { - + function InvoicePaymentDelete(id) { + var url = "{{ route('Admin.Shop.InvoicePayments.destroy') }}/" + id; + $.get(url, function() { + window.location = "{{ route('Admin.Shop.Invoices.edit') }}/{{ $invoice['id'] }}"; + }); } @endpush diff --git a/resources/views/Shop/Baskets/partials/basketTotal.blade.php b/resources/views/Shop/Baskets/partials/basketTotal.blade.php index 3d24e1bc..e589358d 100644 --- a/resources/views/Shop/Baskets/partials/basketTotal.blade.php +++ b/resources/views/Shop/Baskets/partials/basketTotal.blade.php @@ -14,7 +14,7 @@
- {{ $basket['total_taxed'] ?? 0 }} + {{ number_format($basket['total_taxed'] ?? 0, 2, '.') }}
@@ -25,7 +25,7 @@
- {{ $basket['shipping'] }} + {{ number_format($basket['shipping'], 2, '.') }}
@@ -38,7 +38,7 @@
- {{ $basket['total_shipped'] ?? 0 }} + {{ number_format($basket['total_shipped'] ?? 0, 2, '.') }}
diff --git a/resources/views/Shop/Customers/partials/address.blade.php b/resources/views/Shop/Customers/partials/address.blade.php index 1f0e5f92..b8d6ea2f 100644 --- a/resources/views/Shop/Customers/partials/address.blade.php +++ b/resources/views/Shop/Customers/partials/address.blade.php @@ -2,8 +2,8 @@
@include('components.form.input', [ - 'name' => $prefix ?? false ? $prefix . "['name']" : 'name', - 'value' => $customer['name'] ?? '', + 'name' => $prefix ?? false ? $prefix . '[name]' : 'name', + 'value' => $customer['name'] ?? (old('name') ?? ''), 'label' => 'Nom', ])
@@ -13,9 +13,10 @@
@include('components.form.input', [ - 'name' => $prefix ?? false ? $prefix . "['address']" : 'address', - 'value' => $customer['address'] ?? '', + 'name' => $prefix ?? false ? $prefix . '[address]' : 'address', + 'value' => $customer['address'] ?? (old('address') ?? ''), 'label' => $label ?? '', + 'required' => $required ?? false, ])
@@ -23,9 +24,10 @@
@include('components.form.input', [ - 'name' => $prefix ?? false ? $prefix . "['address2']" : 'address2', - 'value' => $customer['address2'] ?? '', + 'name' => $prefix ?? false ? $prefix . '[address2]' : 'address2', + 'value' => $customer['address2'] ?? (old('address2') ?? ''), 'label' => 'Complément d\'adresse', + 'required' => false, ])
@@ -33,16 +35,18 @@
@include('components.form.input', [ - 'name' => $prefix ?? false ? $prefix . "['zipcode']" : 'zipcode', - 'value' => $customer['zipcode'] ?? '', + 'name' => $prefix ?? false ? $prefix . '[zipcode]' : 'zipcode', + 'value' => $customer['zipcode'] ?? (old('zipcode') ?? ''), 'label' => 'Code postal', + 'required' => $required ?? false, ])
@include('components.form.input', [ - 'name' => $prefix ?? false ? $prefix . "['city']" : 'city', - 'value' => $customer['city'] ?? '', + 'name' => $prefix ?? false ? $prefix . '[city]' : 'city', + 'value' => $customer['city'] ?? (old('city') ?? ''), 'label' => 'Ville', + 'required' => $required ?? false, ])
diff --git a/resources/views/Shop/Customers/partials/addresses.blade.php b/resources/views/Shop/Customers/partials/addresses.blade.php index 6b3ead2d..1bcc5aa7 100644 --- a/resources/views/Shop/Customers/partials/addresses.blade.php +++ b/resources/views/Shop/Customers/partials/addresses.blade.php @@ -4,9 +4,9 @@
-
+
@if ($with_name ?? false) - {{ $address['name'] }}
> + {{ $address['name'] }}
@endif {{ $address['address'] }}
@if ($address['address2']) @@ -14,6 +14,11 @@ @endif {{ $address['zipcode'] }} {{ $address['city'] }}
+
+ + + +
@endforeach diff --git a/resources/views/Shop/Customers/partials/registration.blade.php b/resources/views/Shop/Customers/partials/registration.blade.php index 2e6557b3..8414daca 100644 --- a/resources/views/Shop/Customers/partials/registration.blade.php +++ b/resources/views/Shop/Customers/partials/registration.blade.php @@ -1,7 +1,7 @@ -@if ($errors->any()) +@if ($errors->registration->any())
@@ -12,7 +12,7 @@
@include('components.form.input', [ 'name' => 'first_name', - 'value' => $customer['first_name'] ?? '', + 'value' => $customer['first_name'] ?? (old('first_name') ?? ''), 'label' => 'Prénom', 'required' => true, ]) @@ -20,7 +20,7 @@
@include('components.form.input', [ 'name' => 'last_name', - 'value' => $customer['last_name'] ?? '', + 'value' => $customer['last_name'] ?? (old('last_name') ?? ''), 'label' => 'Nom', 'required' => true, ]) @@ -30,14 +30,14 @@
@include('components.form.input', [ 'name' => 'company', - 'value' => $customer['company'] ?? '', + 'value' => $customer['company'] ?? (old('company') ?? ''), 'label' => 'Société', ])
@include('components.form.input', [ 'name' => 'tva', - 'value' => $customer['tva'] ?? '', + 'value' => $customer['tva'] ?? (old('tva') ?? ''), 'label' => 'N° de TVA', ])
@@ -46,18 +46,19 @@
@include('components.form.input', [ 'name' => 'email', - 'value' => $customer['email'] ?? '', + 'value' => $customer['email'] ?? (old('email') ?? ''), 'label' => 'Email', 'required' => true, ]) + {!! $errors->registration->first('email', '

:message

') !!}
@include('components.form.input', [ 'name' => 'phone', - 'value' => $customer['phone'] ?? '', + 'value' => $customer['phone'] ?? (old('phone') ?? ''), 'label' => 'Téléphone', ])
-@include('Shop.Customers.partials.address', ['label' => 'Adresse']) +@include('Shop.Customers.partials.address', ['label' => 'Adresse', 'required' => true]) diff --git a/resources/views/Shop/Orders/confirmed.blade.php b/resources/views/Shop/Orders/confirmed.blade.php index 0fe7c0be..68a97a1f 100644 --- a/resources/views/Shop/Orders/confirmed.blade.php +++ b/resources/views/Shop/Orders/confirmed.blade.php @@ -1,11 +1,11 @@ @extends('Shop.layout.layout', [ - 'title' => __('Commande confirmée'), + 'title' => __('Commande confirmée'), ]) @section('content') -
-
- Votre commande a été confirmée -
-
+
+
+ {!! $content !!} +
+
@endsection diff --git a/resources/views/Shop/Orders/order.blade.php b/resources/views/Shop/Orders/order.blade.php index cd071070..d0e09ae4 100644 --- a/resources/views/Shop/Orders/order.blade.php +++ b/resources/views/Shop/Orders/order.blade.php @@ -3,6 +3,15 @@ ]) @section('content') + @php + if ($errors->registration) { + $classIdent = 'd-none'; + $classRegister = ''; + } else { + $classIdent = ''; + $classRegister = 'd-none'; + } + @endphp
@if (App\Repositories\Shop\Customers::isNotConnected()) @@ -11,12 +20,13 @@

- + @include('Shop.auth.partials.login') + class="{{ $classRegister }} personal_data rounded-lg" uncollapsed=true> @include('Shop.auth.partials.register') @else diff --git a/resources/views/Shop/Orders/partials/addresses.blade.php b/resources/views/Shop/Orders/partials/addresses.blade.php index 83fc2b18..ec3e3d12 100644 --- a/resources/views/Shop/Orders/partials/addresses.blade.php +++ b/resources/views/Shop/Orders/partials/addresses.blade.php @@ -6,7 +6,8 @@ 'name' => $name, 'val' => $address['id'], 'id' => $prefix . '_address_' . $address['id'], - 'value' => $address['priority'] || count($addresses) === 1 ? $address['id'] : false, + 'value' => + old($name) ?? $address['priority'] || count($addresses) === 1 ? $address['id'] : false, ])
diff --git a/resources/views/Shop/Orders/partials/deliveries.blade.php b/resources/views/Shop/Orders/partials/deliveries.blade.php index 91f5eb43..7667943e 100644 --- a/resources/views/Shop/Orders/partials/deliveries.blade.php +++ b/resources/views/Shop/Orders/partials/deliveries.blade.php @@ -4,6 +4,7 @@ @include('components.form.radios.icheck', [ 'name' => 'delivery_id', 'val' => $delivery['id'], + 'value' => (int) old('delivery_id') === $delivery['id'] ? $delivery['id'] : null, 'id' => 'delivery_' . $delivery['id'], 'class' => 'delivery_mode' . ($delivery['at_house'] ? ' at_house' : ''), ]) @@ -15,11 +16,14 @@
@endforeach -Si vous voulez laisser un message à propos de votre commande, merci de bien vouloir le renseigner dans le champs +{!! $errors->first('delivery_id', '

:message

') !!} + +Si vous voulez laisser un message à propos de votre commande, merci de bien vouloir le renseigner dans le champ ci-contre @include('components.form.textarea', [ 'name' => 'comment', + 'value' => old('comment') ?? '', ]) @push('js') diff --git a/resources/views/Shop/Orders/partials/payments.blade.php b/resources/views/Shop/Orders/partials/payments.blade.php index b1ec68d5..2fdb2151 100644 --- a/resources/views/Shop/Orders/partials/payments.blade.php +++ b/resources/views/Shop/Orders/partials/payments.blade.php @@ -1,6 +1,6 @@
- +
PAIEMENT PAR CARTE BANCAIRE @@ -9,7 +9,7 @@
- +
PAIEMENT PAR CHEQUE @@ -18,20 +18,23 @@
- +
PAIEMENT PAR VIREMENT BANCAIRE
+{!! $errors->first('payment_type', '

:message

') !!} +
- +
J'ai lu les conditions générales de vente et j'y adhère sans réserve
+ {!! $errors->first('agree', '

:message

') !!}
- \ No newline at end of file + diff --git a/resources/views/Shop/auth/partials/login.blade.php b/resources/views/Shop/auth/partials/login.blade.php index 2d31e159..2069038c 100644 --- a/resources/views/Shop/auth/partials/login.blade.php +++ b/resources/views/Shop/auth/partials/login.blade.php @@ -1,42 +1,42 @@ -{!! Form::open(['route' => 'Shop.login.post', 'method' => 'post', 'autocomplete'=> 'off']) !!} +{!! Form::open(['route' => 'Shop.login.post', 'method' => 'post', 'autocomplete' => 'off']) !!} -
-
- {{ Form::email('email', old('email'), ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.email'), 'required', 'autofocus']) }} -
-
- -
-
- {!! $errors->first('email','

:message

') !!} -
-
-
-
- {{ Form::password('password', ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.password'), 'required']) }} -
-
- -
+
+
+ {{ Form::email('email', old('email'), ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.email'), 'required', 'autofocus']) }} +
+
+
- {!! $errors->first('password','

:message

') !!} + {!! $errors->first('email', '

:message

') !!}
- @if ($errors->any()) -
-

- {{ $errors->first('msg') }} -

-
- @endif -
-
- +
+
+
+ {{ Form::password('password', ['class' => 'form-control', 'placeholder' => __('boilerplate::auth.fields.password'), 'required']) }} +
+
+ +
+
+ {!! $errors->first('password', '

:message

') !!} +
+@if ($errors->any()) +
+

+ {{ $errors->first('msg') }} +

+
+@endif +
+
+ +
-
+
{!! Form::close() !!} diff --git a/resources/views/Shop/auth/partials/register.blade.php b/resources/views/Shop/auth/partials/register.blade.php index 62a74698..1ddd50a3 100644 --- a/resources/views/Shop/auth/partials/register.blade.php +++ b/resources/views/Shop/auth/partials/register.blade.php @@ -14,7 +14,7 @@ 'placeholder' => __('boilerplate::auth.fields.password'), 'required', ]) }} - {!! $errors->first('password', '

:message

') !!} + {!! $errors->registration->first('password', '

:message

') !!}
@@ -25,7 +25,10 @@ 'placeholder' => __('boilerplate::auth.fields.password_confirm'), 'required', ]) }} - {!! $errors->first('password_confirmation', '

:message

') !!} + {!! $errors->registration->first( + 'password_confirmation', + '

:message

', + ) !!}
diff --git a/resources/views/load/form/save.blade.php b/resources/views/load/form/save.blade.php index 6fe83722..663614c1 100644 --- a/resources/views/load/form/save.blade.php +++ b/resources/views/load/form/save.blade.php @@ -2,7 +2,6 @@ @push('scripts') + +
+ @foreach ($parameters as $name => $value) + + @endforeach + + +
+ + diff --git a/resources/views/paybox/waiting.blade.php b/resources/views/paybox/waiting.blade.php deleted file mode 100644 index bb84b4ec..00000000 --- a/resources/views/paybox/waiting.blade.php +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - -Your payment is waiting. It might take some time until it is completed. - - \ No newline at end of file diff --git a/routes/Admin/Shop/InvoicePayments.php b/routes/Admin/Shop/InvoicePayments.php index ef1d146a..d906ad51 100644 --- a/routes/Admin/Shop/InvoicePayments.php +++ b/routes/Admin/Shop/InvoicePayments.php @@ -2,8 +2,8 @@ Route::prefix('InvoicePayments')->name('InvoicePayments.')->group(function () { Route::get('', 'InvoicePaymentController@index')->name('index'); - Route::get('create', 'InvoicePaymentController@create')->name('create'); - Route::delete('destroy', 'InvoicePaymentController@destroy')->name('destroy'); + Route::get('create/{invoice_id?}', 'InvoicePaymentController@create')->name('create'); + Route::get('destroy/{id?}', 'InvoicePaymentController@destroy')->name('destroy'); Route::post('update', 'InvoicePaymentController@update')->name('update'); Route::post('store', 'InvoicePaymentController@store')->name('store'); Route::get('edit/{id?}', 'InvoicePaymentController@edit')->name('edit'); diff --git a/routes/Admin/Shop/Invoices.php b/routes/Admin/Shop/Invoices.php index f103ea0c..d96c0abe 100644 --- a/routes/Admin/Shop/Invoices.php +++ b/routes/Admin/Shop/Invoices.php @@ -6,5 +6,5 @@ Route::prefix('Invoices')->name('Invoices.')->group(function () { Route::delete('destroy', 'InvoiceController@destroy')->name('destroy'); Route::post('update', 'InvoiceController@update')->name('update'); Route::post('store', 'InvoiceController@store')->name('store'); - Route::get('edit/{id}', 'InvoiceController@edit')->name('edit'); + Route::get('edit/{id?}', 'InvoiceController@edit')->name('edit'); }); diff --git a/routes/Shop/Customers.php b/routes/Shop/Customers.php index f03b9007..28d674ab 100644 --- a/routes/Shop/Customers.php +++ b/routes/Shop/Customers.php @@ -7,4 +7,5 @@ Route::prefix('Clients')->name('Customers.')->group(function () { Route::get('edit', 'CustomerController@edit')->name('edit'); Route::post('storeProfileAjax', 'CustomerController@storeProfileAjax')->name('storeProfileAjax'); Route::post('store', 'CustomerController@store')->name('store'); + Route::get('delete_address/{$id?}', 'CustomerController@delete_address')->name('delete_address'); });