Example #1
0
 /**
  * Récupère la commande dont le numéro est passé en paramètre.
  *
  * @param int $id numéro d'une commande
  *
  * @return Commande $uneCommande
  *
  * @throws ErrorSQLException
  * @throws CollectionException
  */
 public static function getUneCommande($id)
 {
     try {
         $conn = MConnexion::getBdd();
         $req = $conn->prepare('SELECT * FROM commande WHERE numCde = ?');
         $req->execute([$id]);
         $req = $req->fetch();
         $unClient = MUtilisateur::getUnUser($req['numClt']);
         $uneCommande = new Commande($id, $unClient, $req['date'], $req['pointsUtilise']);
         $uneCommande->setLesArticles(MCommander::getUneCommande($uneCommande));
         return $uneCommande;
     } catch (PDOException $e) {
         throw new ErrorSQLException($e->getMessage());
     }
 }
Example #2
0
 /**
  * Permet d'annuler une réservation déjà validée (rembourse les points utilisés et gagnés)
  *
  * @param Reservation $uneReservation
  *
  * @throws ErrorSQLException
  */
 public static function annulerReservationValidee(Reservation $uneReservation)
 {
     $conn = MConnexion::getBdd();
     try {
         $conn->beginTransaction();
         $req = $conn->prepare('DELETE FROM echeance WHERE numRes = ?');
         $req->execute([$uneReservation->getId()]);
         $conn->commit();
         $conn->beginTransaction();
         $reqPrepare = $conn->prepare('DELETE FROM reservation WHERE numRes = ?');
         $reqPrepare->execute([$uneReservation->getId()]);
         $conn->commit();
         $points = MUtilisateur::getPoints($uneReservation->getUnClient()) - Build::newPoints($uneReservation->getPriceReservation()) + $uneReservation->getReduction();
         MUtilisateur::setPoints($uneReservation->getUnClient(), $points);
         $conn = null;
     } catch (PDOException $e) {
         $conn->rollBack();
         $uneReservation->setValid(false);
         throw new ErrorSQLException($e->getMessage());
     }
 }
Example #3
0
                } elseif (strlen($_POST['nomUser']) > 20) {
                    Connexion::setFlashMessage('Le nom entré est trop long', 'error');
                    header('Location:?page=inscription');
                } elseif (strlen($_POST['prenUser']) > 20) {
                    Connexion::setFlashMessage('Le prénom entré est trop long', 'error');
                    header('Location:?page=inscription');
                } elseif (strlen($_POST['cpUser']) !== 5) {
                    Connexion::setFlashMessage('Le code postal entré n\'est pas au bon format (ex: 30000)', 'error');
                    header('Location:?page=inscription');
                } elseif ($_POST['mdpUser'] !== $_POST['mdpConfUser']) {
                    Connexion::setFlashMessage('Les mots de passes ne sont pas identiques', 'error');
                    header('Location:?page=inscription');
                } else {
                    $unUser = new Utilisateur();
                    $unUser->setNom($_POST['nomUser'])->setPrenom($_POST['prenUser'])->setAdresse($_POST['adrUser'])->setCp($_POST['cpUser'])->setVille($_POST['villeUser'])->setMdp(sha1($_POST['mdpUser']))->setMail($_POST['mailUser'])->setPoints(10);
                    ConnexionSite::setAjoutUser($unUser);
                    Connexion::setFlashMessage('Inscription réussie, vous pouvez désormais vous connecter.', 'valid');
                    header('Location:?page=index');
                }
            } else {
                header('Location:?page=index');
            }
        } catch (Exception $e) {
            Connexion::setFlashMessage($e->getMessage(), 'error');
            header('Location:?page=inscription');
        }
        break;
    default:
        header('Location:?page=index');
        break;
}
Example #4
0
     } 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)) {
             if ($_POST['pointsUtilise'] > MUtilisateur::getPoints($_SESSION['Utilisateur'])) {
                 throw new \InvalidArgumentException('Vous n\'avez pas assez de points');
             }
             $_SESSION['Panier']->setPointsUtilise($_POST['pointsUtilise']);
             if (empty($_POST['pointsUtilise'])) {
                 $_SESSION['Panier']->setPointsUtilise(null);
             }
             echo "<script>window.location.replace('?page=monPanier&action=validerPanier')</script>";
         } else {
             require_once ROOT . 'src/Views/Panier/v_ValiderPanier.php';
         }
     } catch (\InvalidArgumentException $e) {
         Connexion::setFlashMessage($e->getMessage());
         echo "<script>window.location.replace('?page=monPanier&action=voirPanier')</script>";
     }
     break;
Example #5
0
use Nostromo\Classes\Exception\NotFoundException;
use Nostromo\Models\MUtilisateur;
use Nostromo\Models\MConnexion as Connexion;
use Nostromo\Models\MReservation;
$action = array_key_exists('action', $_GET) ? $_GET['action'] : 'voirForm';
switch ($action) {
    case 'voirForm':
        require_once ROOT . 'src/Views/Connexion/v_VoirForm.php';
        break;
    case 'seConnecter':
        try {
            try {
                if (!array_key_exists('mailUser', $_POST)) {
                    throw new NotFoundException('Cette page n\'existe pas.');
                }
                $unUtilisateur = MUtilisateur::getUser($_POST['mailUser']);
                if ($_POST['mailUser'] !== $unUtilisateur->getMail() && sha1($_POST['mdpUser']) !== $unUtilisateur->getMdp()) {
                    throw new InvalidArgumentException('E-mail ou mot de passe incorrecte.');
                } else {
                    $_SESSION['Utilisateur'] = $unUtilisateur;
                    $_SESSION['Reservation'] = MReservation::getReservationClient($_SESSION['Utilisateur']);
                    Connexion::setFlashMessage('Connecté avec succès', 'valid');
                    header('Location:?page=index');
                }
            } catch (NotFoundException $e) {
                Connexion::setFlashMessage($e->getMessage(), 'error');
                header('Location:?page=index');
            } catch (\InvalidArgumentException $e) {
                Connexion::setFlashMessage($e->getMessage(), 'error');
                header('Location:?page=connexion');
            }
Example #6
0
                     $_SESSION['Utilisateur']->setPrenom($_POST['firstname']);
                 }
                 if (!empty($_POST['cp']) && !empty($_POST['city']) && !empty($_POST['address'])) {
                     if (is_numeric($_POST['cp'])) {
                         $_SESSION['Utilisateur']->setAdresse($_POST['address'])->setCp($_POST['cp'])->setVille($_POST['city']);
                     } else {
                         throw new InvalidArgumentException('Le code postal doit être au format numérique.');
                     }
                 }
                 if (!empty($_POST['cp']) && !is_numeric($_POST['cp'])) {
                     throw new InvalidArgumentException('Le code postal doit être au format numérique.');
                 }
             } else {
                 throw new InvalidArgumentException('Mot de passe incorrect.');
             }
             ConnexionSite::updateUser($_SESSION['Utilisateur']);
             Connexion::setFlashMessage('Données mise à jour avec succès', 'valid');
             header('Location:?page=monCompte&action=edit');
         } else {
             $title = 'Modifier mes informations';
             require_once ROOT . 'src/Views/Compte/v_GabCompte.php';
             require_once ROOT . 'src/Views/Compte/v_EditProfile.php';
         }
     } catch (InvalidArgumentException $e) {
         Connexion::setFlashMessage($e->getMessage(), 'error');
         header('Location:?page=monCompte&action=edit');
     }
     break;
     // Fin Partie
 // Fin Partie
 case 'voirCommandes':
Example #7
0
                if (array_key_exists('Reservation', $_SESSION)) {
                    header('Location:?page=maReservation');
                }
                if ($_SESSION['Reservation']->isValid()) {
                    MConnexion::setFlashMessage('Vous avez déjà une réservation.
                            Veuillez contacter Nostromo pour annuler votre réservation.', 'error');
                }
                header('Location:?page=maReservation');
            } else {
                MConnexion::setFlashMessage('Le vol demandé n\'existe pas.', 'error');
                header('Location:?page=reserver');
            }
        } catch (NotConnectedException $e) {
            MConnexion::setFlashMessage($e->getMessage());
            header('Location:?page=connexion');
        } catch (InvalidArgumentException $e) {
            MConnexion::setFlashMessage($e->getMessage(), 'error');
            header('Location:?page=maReservation');
        } catch (UnexpectedValueException $e) {
            MConnexion::setFlashMessage($e->getMessage() . ', actuellement ' . MUtilisateur::getPoints($_SESSION['Utilisateur']) . ' points', 'error');
            header('Location:?page=reserver&action=reserverVol&vol=' . $_GET['vol']);
        } catch (Exception $e) {
            MConnexion::setFlashMessage($e->getMessage(), 'error');
            header('Location:?reserver');
        }
        break;
    default:
        MConnexion::setFlashMessage('Erreur 404 : page introuvable', 'error');
        header('Location:?page=index');
        break;
}
Example #8
0
?>
        </div>
    </nav>
    <?php 
if (array_key_exists('page', $_GET) && $_GET['page'] === 'index') {
    echo '
<div class="carousel">
    <img src="public/Resources/img/bg.png" alt="" width="100%">
</div>';
}
?>
    <div class='jumbotron'>
        <div class='container-fluid'>
            <?php 
if (MConnexion::sessionOuverte()) {
    $_SESSION['Utilisateur']->setPoints(MUtilisateur::getPoints($_SESSION['Utilisateur']));
    echo "<div class='col-md-8 col-xs-12 col-lg-9'>";
}
if (array_key_exists('page', $_GET)) {
    switch ($_GET['page']) {
        case 'index':
            require_once ROOT . 'src/Controllers/Index/c_Index.php';
            break;
        case 'reserver':
            require_once ROOT . 'src/Controllers/ReserveVol/c_ReserveVol.php';
            break;
        case 'connexion':
            require_once ROOT . 'src/Controllers/Connexion/c_ConnexionSite.php';
            break;
        case 'inscription':
            require_once ROOT . 'src/Controllers/Inscription/c_InscriptionSite.php';