From 0bffbd1295788f37a23c398a6bf2473e92a76420 Mon Sep 17 00:00:00 2001 From: Sarobidy22 Date: Wed, 3 Sep 2025 15:54:09 +0300 Subject: [PATCH] push 04092025 --- app/Controllers/ProductCOntroller.php | 29 +++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/app/Controllers/ProductCOntroller.php b/app/Controllers/ProductCOntroller.php index 11748f9e..0f52a3e3 100644 --- a/app/Controllers/ProductCOntroller.php +++ b/app/Controllers/ProductCOntroller.php @@ -403,14 +403,14 @@ public function create() 'n° série' => 'sku', 'marque' => 'marque', 'désignation' => 'name', - 'fournisseur' => 'info', // À adapter selon votre besoin + 'fournisseur' => 'info', 'date d\'arrivage' => 'date_arivage', 'n° moteur' => 'numero_de_moteur', 'châssis' => 'chasis', 'puissance' => 'puissance', 'clé' => 'cler', 'prix d\'achat' => 'price', - 'prix ar' => 'prix_vente', + 'prix ar' => 'prix_vente', // Correction du mapping 'catégories' => 'categorie_id', 'magasin' => 'store_id', 'disponibilité' => 'availability', @@ -473,11 +473,25 @@ public function create() $data[$field] = date('Y-m-d', strtotime($value)); } break; - case 'price': - // Nettoyer "1 900 000 Ar" → 1900000.00 - $cleanedValue = str_replace(['Ar', ' ', ','], '', $value); - $data[$field] = (float)$cleanedValue; - break; + + case 'price': + case 'prix_vente': // Ajout de la gestion pour prix_vente + $cleanedValue = str_replace(['Ar', ' ', ','], '', $value); + $data[$field] = (float)$cleanedValue; + break; + + case 'categorie_id': + // Gestion des catégories si nécessaire + if (!empty($value)) { + $category = $CategoryModel->where('name', $value)->first(); + $data[$field] = $category ? $category['id'] : null; + } + break; + + case 'availability': + // Convertir la disponibilité en booléen + $data[$field] = (strtolower($value) == 'oui' || $value == '1') ? 1 : 0; + break; default: $data[$field] = $value; @@ -505,5 +519,4 @@ public function create() ]); } } - }