Exemplo n.º 1
0
 public function addArticle($idDesc)
 {
     if (!empty($idDesc)) {
         require_once $_SERVER['DOCUMENT_ROOT'] . 'exo-circulaire/views/admin/addarticle.php';
         // Si les champs ont étés remplis et validés
         if (!empty($_POST)) {
             // Planète
             if ($idDesc == 1) {
                 $nom = htmlspecialchars($_POST['nom']);
                 $description = htmlspecialchars($_POST['description']);
                 $diametre = htmlspecialchars($_POST['diametre']);
                 $gravity = htmlspecialchars($_POST['gravity']);
                 $temperature = htmlspecialchars($_POST['temperature']);
                 $lunes = htmlspecialchars($_POST['lunes']);
                 $prix = htmlspecialchars($_POST['prix']);
                 $quantite = htmlspecialchars($_POST['quantite']);
                 $urlImage = htmlspecialchars($_POST['urlImage']);
                 $admin = new Model_Admin();
                 $addArticle = $admin->addArticle1($nom, $description, $diametre, $gravity, $temperature, $lunes, $prix, $quantite, $urlImage, $idDesc);
                 if ($addArticle) {
                     header("Location: index.php?c=article&a=list");
                     die;
                 }
             } else {
                 if ($idDesc == 2) {
                     $nom = htmlspecialchars($_POST['nom']);
                     $description = htmlspecialchars($_POST['description']);
                     $diametre = htmlspecialchars($_POST['diametre']);
                     $gravity = htmlspecialchars($_POST['gravity']);
                     $temperature = htmlspecialchars($_POST['temperature']);
                     $prix = htmlspecialchars($_POST['prix']);
                     $quantite = htmlspecialchars($_POST['quantite']);
                     $urlImage = htmlspecialchars($_POST['urlImage']);
                     $admin = new Model_Admin();
                     $addArticle = $admin->addArticle2($nom, $description, $diametre, $gravity, $temperature, $prix, $quantite, $urlImage, $idDesc);
                     if ($addArticle) {
                         header("Location: index.php?c=article&a=list");
                         die;
                     }
                 } else {
                     if ($idDesc == 3) {
                         $nom = htmlspecialchars($_POST['nom']);
                         $description = htmlspecialchars($_POST['description']);
                         $diametre = htmlspecialchars($_POST['diametre']);
                         $gravity = htmlspecialchars($_POST['gravity']);
                         $temperature = htmlspecialchars($_POST['temperature']);
                         $prix = htmlspecialchars($_POST['prix']);
                         $quantite = htmlspecialchars($_POST['quantite']);
                         $urlImage = htmlspecialchars($_POST['urlImage']);
                         $admin = new Model_Admin();
                         $addArticle = $admin->addArticle3($nom, $description, $diametre, $gravity, $temperature, $prix, $quantite, $urlImage, $idDesc);
                         if ($addArticle) {
                             header("Location: index.php?c=article&a=list");
                             die;
                         }
                     } else {
                         if ($idDesc == 4) {
                             $nom = htmlspecialchars($_POST['nom']);
                             $description = htmlspecialchars($_POST['description']);
                             $prix = htmlspecialchars($_POST['prix']);
                             $quantite = htmlspecialchars($_POST['quantite']);
                             $urlImage = htmlspecialchars($_POST['urlImage']);
                             $admin = new Model_Admin();
                             $addArticle = $admin->addArticle4($nom, $description, $prix, $quantite, $urlImage, $idDesc);
                             if ($addArticle) {
                                 header("Location: index.php?c=article&a=list");
                                 die;
                             }
                         }
                     }
                 }
             }
         }
     } else {
         header("Location: exo-circulaire/views/admin/articles.php");
         die;
     }
 }