Exemplo n.º 1
0
 /**
  * Récupère les articles d'un commande via la commande.
  *
  * @param Commande $uneCommande numéro d'une commande
  * @param bool $index
  *
  * @return Collection
  *
  * @throws CollectionException
  * @throws ErrorSQLException
  */
 public static function getUneCommande(Commande $uneCommande, $index = false)
 {
     $lesArticles = new Collection();
     try {
         $conn = MConnexion::getBdd();
         $conn->beginTransaction();
         $req = !$index ? $conn->prepare('SELECT * FROM commander INNER JOIN article ON commander.numArt = article.numArt WHERE numCde = ? ORDER BY pu DESC') : $conn->prepare('SELECT * FROM commander INNER JOIN article ON commander.numArt = article.numArt WHERE numCde = ? ORDER BY pu DESC LIMIT 2');
         $req->execute(array($uneCommande->getId()));
         $req = $req->fetchAll();
         foreach ($req as $tabs) {
             $unArticle = MArticle::getArticle($tabs['numArt']);
             $unArticle->setQte($tabs['qte']);
             $lesArticles->ajouter($unArticle);
         }
         $conn->commit();
     } catch (PDOException $e) {
         throw new ErrorSQLException('Impossible de récupérer la commande n°' . $uneCommande->getId() . ' Détails : ' . $e->getMessage());
     }
     return $lesArticles;
 }
Exemplo n.º 2
0
     } catch (Exception $e) {
         Connexion::setFlashMessage($e->getMessage());
         header('Location:?page=materiel&action=voirArticle&article=' . $_GET['ref']);
     }
     break;
 case 'supprimerProduit':
     $_SESSION['Panier']->supprimerUnProduit($_GET['article']);
     if ($_SESSION['Panier']->getNbProd() === 0) {
         unset($_SESSION['Panier']);
     }
     header('Location:?page=monPanier');
     break;
 case 'augmenterProduit':
     try {
         $_SESSION['Panier']->augmenterQuantiteProduit($_GET['article'], 1);
         $prod = MArticle::getArticle($_GET['article']);
     } catch (Exception $e) {
         Connexion::setFlashMessage($e->getMessage(), 'error');
     }
     header('Location:?page=monPanier');
     break;
 case 'diminuerProduit':
     $_SESSION['Panier']->diminuerQuantiteProduit($_GET['article'], 1);
     if ($_SESSION['Panier']->getNbProd() === 0) {
         unset($_SESSION['Panier']);
     }
     header('Location:?page=monPanier');
     break;
 case 'validerPanier':
     try {
         if (array_key_exists('pointsUtilise', $_POST)) {
Exemplo n.º 3
0
use Nostromo\Models\MArticle;
use Nostromo\Models\MConnexion as Connexion;
$action = array_key_exists('action', $_GET) ? $_GET['action'] : 'voirBoutique';
switch ($action) {
    case 'voirBoutique':
        try {
            $tabArt = MArticle::getArticles();
            require_once ROOT . 'src/Views/Boutique/v_VoirBoutique.php';
        } catch (InvalidArgumentException $e) {
            Connexion::setFlashMessage($e->getMessage(), 'error');
            header('Location:?page=error404');
        }
        break;
    case 'voirArticle':
        try {
            if (!Connexion::sessionOuverte()) {
                throw new NotConnectedException();
            }
        } catch (NotConnectedException $e) {
            Connexion::setFlashMessage($e->getMessage());
            header('?page=connexion');
            echo "<script>window.location.replace('?page=connexion')</script>";
            exit;
        }
        $article = MArticle::getArticle($_GET['article']);
        require_once ROOT . 'src/Views/Boutique/v_VoirArticle.php';
        break;
    default:
        $_SESSION['error'] = "Impossible d'accéder à la page demandé.";
        header('Location:?page=index');
}