} catch (Exception $e) { Main::setFlashMessage($e->getMessage(), 'error'); } break; case 'supprimerProduit': $_SESSION['Panier']->supprimerUnProduit($_GET['ref']); if ($_SESSION['Panier']->getNbProd() == 0) { unset($_SESSION['Panier']); header('Location:?uc=Panier'); } else { header('Location:?uc=Panier'); } break; case 'augmenterProduit': try { $unProduit = MLivre::getUnLivre($_GET['ref']); if ($_SESSION['Panier']->getCollProduit()->getElement($_GET['ref'])->getQte() > $unProduit->getQuantiteStock() - 1) { Main::setFlashMessage('Quantitée en stock insuffisante.', 'error'); } else { $_SESSION['Panier']->augmenterQuantiteProduit($_GET['ref'], 1); } } catch (Exception $e) { Main::setFlashMessage($e->getMessage(), 'error'); } header('Location:?uc=Panier'); break; case 'diminuerProduit': $_SESSION['Panier']->diminuerQuantiteProduit($_GET['ref'], 1); if ($_SESSION['Panier']->getNbProd() == 0) { unset($_SESSION['Panier']); } else {
Main::setFlashMessage($e->getMessage(), 'error'); header('Location:?uc=livre'); } break; case 'voirauteur': try { if (isset($_POST['Auteur'])) { $auteur = $_POST['Auteur']; } else { $auteur = '0'; } $tabAuteur = MAuteur::getLesAuteurs(); $unAuteur = MAuteur::getunAuteur($auteur); $tabLesLivreDunAuteur = MLivre::getLesLivresAuteur($unAuteur); require_once ROOT . 'Views/Livre/vue_auteur.php'; } catch (Exception $e) { Main::setFlashMessage($e->getMessage(), 'error'); header('Location:?uc=livre'); } break; case 'voirDetails': try { $Livre = MLivre::getUnLivre($_GET['livre']); $TabCom = MCommentaire::getLesCommentaires($_GET['livre']); $_SESSION['NoLivre'] = $Livre->getNumLivre(); require_once ROOT . 'Views/Livre/vue_details.php'; } catch (Exception $e) { Main::setFlashMessage($e->getMessage(), 'error'); header('Location:?uc=livre'); } }
/** * @param Commande $commande * @return Collection */ public static function getLivresbyCommande(Commande $commande) { $LesLivres = new Collection(); try { $conn = Main::BDDConnexionPDO(); $req = $conn->prepare("SELECT * FROM Quantite\n\t\t\t INNER JOIN Commande ON Quantite.NoCommande = Commande.NumCommande\n\t\t\t WHERE NoCommande = ?"); $req->execute(array($commande->getNumCommande())); $req = $req->fetchAll(); foreach ($req as $unLivre) { $livre = MLivre::getUnLivre($unLivre['NoLivres']); $commande = MPanier::getUneCommande($unLivre['NoCommande']); $quantite = new Quantite($livre, $commande, $unLivre['Quantite']); $LesLivres->ajouter($quantite); } return $LesLivres; } catch (\Exception $e) { Main::setFlashMessage($e->getMessage(), 'error'); } }
<?php /** * Created by PhpStorm. * User: ocean * Date: 25/04/2016 * Time: 09:54 */ use BiblioNet\Models\Main; use BiblioNet\Models\MLivre; if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; } else { $action = "Accueil"; } switch ($action) { case 'Accueil': try { $TabLivre = MLivre::getLivreRand(); require_once ROOT . 'Views/Accueil/vue_accueil.php'; } catch (Exception $e) { Main::setFlashMessage($e->getMessage(), 'error'); header('Location:?uc=Accueil'); } break; }
<?php use BiblioNet\Models\MLivre; use BiblioNet\Models\MCommentaire; use BiblioNet\Classes\Commentaire; use BiblioNet\Models\MConnexion; use BiblioNet\Models\Main; if (isset($_REQUEST['action'])) { $action = $_REQUEST['action']; } else { $action = "voirCommentaire"; } switch ($action) { case "ValiderCommentaire": try { if (isset($_POST['Contenu'])) { $unUser = MConnexion::getUnUserbyId($_SESSION['user']); $unLivre = MLivre::getUnLivre($_SESSION['NoLivre']); $Com = new Commentaire(date('Y-m-d H:i:s'), $unUser, $unLivre, $_POST['Contenu']); MCommentaire::ajouterCommentaire($Com); Main::setFlashMessage('Votre Commentaire a été ajouté.', 'valid'); header('Location:?uc=Livre&action=voirDetails&livre=' . $unLivre->getNumLivre()); } } catch (Exception $e) { Main::setFlashMessage($e->getMessage(), 'error'); header('Location:?uc=Accueil'); } break; }