diff --git a/ensiie-project/src/Controller/commande_form.php b/ensiie-project/src/Controller/commande_form.php new file mode 100644 index 0000000000000000000000000000000000000000..2150df9ab9b9b6bc9d8f15e4b38c308d27d6c0e9 --- /dev/null +++ b/ensiie-project/src/Controller/commande_form.php @@ -0,0 +1,155 @@ +<html> +<body> +<div class="panel-body"> + <form action="../Model/set_commande.php" method="POST"> + <?php + $current_commande['food_type_id'] = 0; + $current_commande['sauces_count'] = 0; + $current_commande['meats_choice'] = 0; + $current_commande['size_choice'] = 0; + + foreach ($foods as $food_id => $food) + { + if ($current_commande['food_type_id'] != $food['food_type_id']) + { + if ($current_commande['food_type_id'] != 0) + { + if ($current_commande['meats_choice'] != 0 || $current_commande['sauces_count'] != 0 || $current_commande['size_choice'] != 0) + {?> + <div id=<?php echo 'hidden-'.$current_commande['food_type_id']?> class="well" style="margin: 15px 10px;"> + <?php + if ($current_commande['sauces_count'] != 0) + display_sauces($current_commande['food_type_id'], $current_commande['sauces_count']); + if ($current_commande['meats_choice'] != 0 && $current_commande['sauces_count'] != 0) + echo '<br/>'; + if ($current_commande['meats_choice'] != 0) + display_meats($current_commande['food_type_id']); + if ($current_commande['size_choice'] != 0) + display_sizes($current_commande['food_type_id']); + echo '</div>'; + } + }?> + + <div class="input-group"> + <label for=<?php echo $food['food_type_id'] ?>:food class="input-group-addon"><?php echo $food['food_type_title']?></label> + <select name=<?php echo $food['food_type_id']?>:food class="form-control" data-food-type=<?php echo $food['food_type_id']?>> + <option value="0">Cliquez pour voir les choix</option> + <?php + $current_commande['food_type_id'] = $food['food_type_id']; + $current_commande['sauces_count'] = $food['sauces_count']; + $current_commande['meats_choice'] = $food['meats_choice']; + $current_commande['size_choice'] = $food['size_choice']; + } + if ($food['price'] != 0) + {?> + <option value=<?php echo $food_id?> data-max-meats=<?php echo $food['meats_count']?>><?php echo $food['food_title'].":".$food['price']."€"?></option>'; + <?php + } + else + {?> + <option value=<?php echo $food_id?> data-max-meats=<?php $food['meats_count']?>><?php echo $food['food_title']?></option> + <?php + } + echo '</div>'; + + if ($current_commande['meats_choice'] != 0 || $current_commande['sauces_count'] != 0 || $current_commande['size_choice'] != 0) + { + echo '<div id="hidden-'.$current_commande['food_type_id'].'" class="well" style="margin: 15px 10px;">'; + if ($current_commande['sauces_count'] != 0) + display_sauces($current_commande['food_type_id'], $current_commande['sauces_count']); + if ($current_commande['meats_choice'] != 0 && $current_commande['sauces_count'] != 0) + echo '<br/>'; + if ($current_commande['meats_choice'] != 0) + display_meats($current_commande['food_type_id']); + if ($current_commande['size_choice'] != 0) + display_sizes($current_commande['food_type_id']); + echo '</div>'; + echo '<hr/>';?> + <input type="hidden" name="submitted"/> + <button class="btn btn-primary btn-block btn-lg" type="submit">Commander</button> + <?php + } + }?> + </form> +</div> + + +<script type="text/javascript"> +var current_max_meats = 0; + +$('select').change(function () +{ + var food_type_id = $(this).attr('data-food-type'); + var parent_sauces = $('#sauce-checkboxes-'+food_type_id).attr('id'); + var parent_meats = $('#meat-checkboxes-'+food_type_id).attr('id'); + current_max_meats = parseInt($('select[name="'+$(this).attr('name')+'"] option:selected').attr('data-max-meats')); + + if ($(this).val() === "0") { + $("#hidden-"+food_type_id).slideUp(200); + refresh_sauce_checkboxes(parent_sauces, true); + refresh_meat_checkboxes(parent_meats, true); + } + else + $("#hidden-"+food_type_id).slideDown(200); + + if ($(this).val() === "0") + $('#meat-message-'+food_type_id).html('<strong>Choisissez votre ou vos viandes :</strong>'); + else + if (current_max_meats === 1) + $('#meat-message-'+food_type_id).html('<strong>Choisissez votre viande :</strong>'); + else + $('#meat-message-'+food_type_id).html('<strong>Choisissez vos viandes <span class="text-danger">('+current_max_meats+' au maximum)</span> :</strong>'); + + refresh_meat_checkboxes(parent_meats); +}) + +$('input[type="checkbox"]').click(function () +{ + var parent_sauces = $(this).parents('[id^="sauce-checkboxes-"]').attr('id'); + refresh_sauce_checkboxes(parent_sauces); + + var parent_meats = $(this).parents('[id^="meat-checkboxes-"]').attr('id'); + refresh_meat_checkboxes(parent_meats); +}) + +$('[id^="reset-sauces-"]').click(function () +{ + var id_div = $(this).attr('data-food-type'); + refresh_sauce_checkboxes('sauce-checkboxes-'+id_div, true); +}) + +$('[id^="reset-meats-"]').click(function () +{ + var id_div = $(this).attr('data-food-type'); + refresh_meat_checkboxes('meat-checkboxes-'+id_div, true); +}) + +function refresh_sauce_checkboxes(parent_sauces, clear=false) +{ + var number_checked_sauces = $('#'+parent_sauces+' input[type="checkbox"]:checked').length; + + if (number_checked_sauces > 2 || clear) + $('#'+parent_sauces+' input[type="checkbox"]').prop('checked', false).prop('disabled', false); + else if (number_checked_sauces === 2) + $('#'+parent_sauces+' input[type="checkbox"]').not(':checked').prop('disabled', true); + else + $('#'+parent_sauces+' input[type="checkbox"]').not(':checked').prop('disabled', false); +} + +function refresh_meat_checkboxes(parent_meats, clear=false) +{ + var number_checked_meats = $('#'+parent_meats+' input[type="checkbox"]:checked').length; + + if (number_checked_meats > current_max_meats || clear) + $('#'+parent_meats+' input[type="checkbox"]').prop('checked', false).prop('disabled', false); + else if (number_checked_meats === current_max_meats) + $('#'+parent_meats+' input[type="checkbox"]').not(':checked').prop('disabled', true); + else + $('#'+parent_meats+' input[type="checkbox"]').not(':checked').prop('disabled', false); +} + +$('[id^="hidden-"]').hide(); +</script> + +</body> +</html> \ No newline at end of file diff --git a/ensiie-project/src/Controller/connexion_bouton.php b/ensiie-project/src/Controller/connexion_bouton.php index 7fa0971665f88f11df1ee521fa2454a4446b0d4a..3afe81aca47e52ee68fe63af25119a88317ada4f 100644 --- a/ensiie-project/src/Controller/connexion_bouton.php +++ b/ensiie-project/src/Controller/connexion_bouton.php @@ -1,21 +1,35 @@ <?php - if ($utilisateur == NULL) {?> - <button onclick="window.open('Controller/connexion_form.php');" class="btn btn-primary btn-xs" name="login" style="float: right; margin-bottom: 10px;">Connexion</button> + <button onclick="login()" class="btn btn-primary btn-xs" name="login" style="float: right; margin-bottom: 10px;">Connexion</button> <?php } else {?> <p style="float: right;"> <?php - if ($utilisateur->isAdmin) + if ($utilisateur->getIsAdmin()) {?> <span class="label label-success" style="font-size: small; display: inline-block;">Admin</span> <?php }?> - <span class="label label-primary" style="font-size: small; display: inline-block;"><?php echo $utilisateur->pseudo; ?></span> - <button onclick="window.open('Model/logout.php');" class="btn btn-primary btn-xs" type="submit" name="logout">Déconnexion</button> + <span class="label label-primary" style="font-size: small; display: inline-block;"><?php echo $utilisateur->getPseudo(); ?></span> + <button onclick="logout()" class="btn btn-danger btn-xs" type="submit" name="logout">Déconnexion</button> </p> + <?php -}?> \ No newline at end of file +}?> + +<br/> +<br/> + +<script> + function login() + { + window.location.href = "Controller/connexion_form.php" + } + function logout() + { + window.location.href = "Model/logout.php" + } +</script> diff --git a/ensiie-project/src/Model/Classes/Commande.php b/ensiie-project/src/Model/Classes/Commande.php index 255c832bb1bcc57966de898c94ba1a78642b62f5..81f99cfbf4325883b1873ebc6c9617eac57b503a 100644 --- a/ensiie-project/src/Model/Classes/Commande.php +++ b/ensiie-project/src/Model/Classes/Commande.php @@ -1,6 +1,5 @@ <?php -namespace Commande; - +require_once('Menu.php'); class Commande { /** @@ -11,33 +10,32 @@ class Commande /** * @var int ID de l'utilisateur qui a commandé */ - private $userID; + private $utilisateurID; /** - * @var string "2019-04-04 18:25:10.000000" par exemple. Je suis sur si tu cherche "mysql datetime to php" tu va trouver des jolies fonction qui rtansforment la string en une belle date + * @var string "2019-04-04 18:25:10.000000" par exemple. Je suis sur si tu cherche "mysql datetime to php" tu va trouver des jolies fonctions qui transforment la string en une belle date */ - private $dateTimeCommande; + private $date; - /** * @var boolean Si la commande a été payée ou pas */ private $isPaid; /** - * @var array<ItemCommande> Le tableau qui contient les différentes nourritures + * @var array<Menu> Le tableau qui contient les différents menus */ - private $items; + private $menus; /** * Constructeur valué */ - public function Commande($idIt,$user,$date, $paid, $nourriture) + public function __construct($idCommande, $utilisateurID, $date, $isPaid, $menus) { - $this->idCommande = $idIt; - $this->userID = $user; - $this->dateTimeCommande = $date; - $this->isPaid = $paid; - $this->items = $nourriture; + $this->idCommande = $idCommande; + $this->utilisateurID = $utilisateurID; + $this->date = $date; + $this->isPaid = $isPaid; + $this->menus = $menus; } public function getIDCommande() @@ -45,14 +43,14 @@ class Commande return $this->idCommande; } - public function getUserID() + public function getUtilisateurID() { - return $this->userID; + return $this->utilisateurID; } - public function getDateTimeCommande() + public function getDate() { - return $this->dateTimeCommande; + return $this->date; } public function getPaid() //je trouve ca drole comme blague :/ @@ -60,13 +58,13 @@ class Commande return $this->isPaid; } - public function getItems() //je trouve ca drole comme blague :/ + public function getMenus() //je trouve ca drole comme blague :/ { - return $this->items; + return $this->menus; } - public function addItem($item){ - array_push($this->items, $item); + public function addMenus($menu){ + array_push($this->menus, $menu); } } diff --git a/ensiie-project/src/Model/Classes/Evenement.php b/ensiie-project/src/Model/Classes/Evenement.php new file mode 100644 index 0000000000000000000000000000000000000000..de1f522b7e90249fc444f821e780c502860ab886 --- /dev/null +++ b/ensiie-project/src/Model/Classes/Evenement.php @@ -0,0 +1,75 @@ +<?php + +class Evenement +{ + /** + * @var int id de la BDD + */ + private $idEvenement; + + /** + * @var string "NJV" ou "ObiLAN" + */ + private $type; + + /** + * @var int Numero de l'event + */ + private $numero; + + /** + * @var time Date de l'évènement + */ + private $date; + + /** + * Constructeur valué + */ + public function __construct($idEvenement,$type,$numero,$date) + { + $this->idEvenement = $idEvenement; + $this->type = $type; + $this->numero = $numero; + $this->date = $date; + } + + public function getIDEvenement() + { + return $this->idEvenement; + } + + public function setIDEvenement($id) + { + $this->idEvenement = $id; + } + + public function getType() + { + return $this->type; + } + + public function setType($type) + { + $this->type = $type; + } + + public function getNumero() + { + return $this->numero; + } + + public function setNumero($numero) + { + $this->numero = $numero; + } + + public function getDate() + { + return $this->date; + } + + //TODO fonction qui donne si l'évènement est déjà passé + +} + +?> \ No newline at end of file diff --git a/ensiie-project/src/Model/Classes/Event.php b/ensiie-project/src/Model/Classes/Event.php deleted file mode 100644 index af081a86fa5305e90152dc69ade64f2fb8153cc5..0000000000000000000000000000000000000000 --- a/ensiie-project/src/Model/Classes/Event.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php -namespace Event; - -class Event -{ - /** - * @var int id de la BDD - */ - private $idEvent; - - /** - * @var string "NJV" ou "ObiLAN" - */ - private $typeEvent; - - /** - * @var int Numero de l'event - */ - private $numEvent; - - /** - * Constructeur valué - */ - public function Event($idEve,$type,$num,) - { - $this->idEvent = $idEve; - $this->typeEvent = $type; - $this->numEvent = $num; - } - - public function getIDEvent() - { - return $this->idEvent; - } - - public function setIDEvent($id) - { - $this->idEvent = $id; - } - - public function getTypeEvent() - { - return $this->typeEvent; - } - - public function setTypeEvent($id) - { - $this->typeEvent = $id; - } - - public function getNumEvent() - { - return $this->numEvent; - } - - public function setNumEvent($id) - { - $this->numEvent = $id; - } - -} - -?> \ No newline at end of file diff --git a/ensiie-project/src/Model/Classes/ItemCommande.php b/ensiie-project/src/Model/Classes/ItemCommande.php deleted file mode 100644 index e7802976f5a7af3e39f6cf1034b079c6b10a4fbb..0000000000000000000000000000000000000000 --- a/ensiie-project/src/Model/Classes/ItemCommande.php +++ /dev/null @@ -1,63 +0,0 @@ -<?php -namespace ItemCommande; - -class ItemCommande -{ - /** - * @var int id de la BDD - */ - private $idItem; - - /** - * @var Nourriture contennat les infos de ce qui est acheté - */ - private $foodCommande; - - /** - * @var array<Special> contenant les sauces, viandes, etc... - */ - private $specialsFood; - - /** - * Constructeur valué - */ - public function ItemCommande($idIt,$foodCom,$specials,) - { - $this->idItem = $idIt; - $this->foodCommande = $foodCom; - $this->specialsFood = $specials; - } - - public function getIDItem() - { - return $this->idItem; - } - - public function setIDItem($id) - { - $this->idItem = $id; - } - - public function getNourriture() - { - return $this->foodCommande; - } - - public function setNourriture($id) - { - $this->foodCommande = $id; - } - - public function getSpecials() - { - return $this->numEvent; - } - - public function setSpecials($id) - { - $this->specialsFood = $id; - } - -} - -?> \ No newline at end of file diff --git a/ensiie-project/src/Model/Classes/Menu.php b/ensiie-project/src/Model/Classes/Menu.php new file mode 100644 index 0000000000000000000000000000000000000000..2306d01d903f508d295b621b8a756cdf17b91183 --- /dev/null +++ b/ensiie-project/src/Model/Classes/Menu.php @@ -0,0 +1,63 @@ +<?php +require_once('Nourriture.php'); +require_once('Special.php'); +class Menu +{ + /** + * @var int id de la BDD + */ + private $idMenu; + + /** + * @var Nourriture contennat les infos de ce qui est acheté + */ + private $nourriture; + + /** + * @var array<Special> contenant les sauces, viandes, etc... + */ + private $specials; + + /** + * Constructeur valué + */ + public function __construct($idMenu,$nourriture,$specials) + { + $this->idMenu = $idMenu; + $this->nourriture = $nourriture; + $this->specials= $specials; + } + + public function getIDMenu() + { + return $this->idMenu; + } + + public function setIDMenu($id) + { + $this->idMenu = $id; + } + + public function getNourriture() + { + return $this->nourriture; + } + + public function setNourriture($nourriture) + { + $this->nourriture = $nourriture; + } + + public function getSpecials() + { + return $this->specials; + } + + public function setSpecials($specials) + { + $this->specials = $specials; + } + +} + +?> \ No newline at end of file diff --git a/ensiie-project/src/Model/Classes/Nourriture.php b/ensiie-project/src/Model/Classes/Nourriture.php index bc18e292e9ebd7efac380a0028c16c0eb29619fd..d6198e9a5a9c6ed2e978cac5182d8e6c0353ee17 100644 --- a/ensiie-project/src/Model/Classes/Nourriture.php +++ b/ensiie-project/src/Model/Classes/Nourriture.php @@ -6,23 +6,23 @@ class Nourriture /** * @var int id de la BDD */ - private $idFood; + private $idNourriture; /** * @var string "Pizza", "Tacos", etc... */ - private $foodType; + private $Type; /** * @var int Id du type de nourriture dans la BDD */ - private $foodTypeID; + private $idType; /** * @var string "Calzone (Tomates, Oignons)", "Tacos XXL", etc... */ - private $nomFood; + private $nom; /** * @var string "Le Palais", "Obigdelice", etc... @@ -37,51 +37,51 @@ class Nourriture /** * @var string "6.5 €", "8€", Le prix que VONT PAYER LES IIENS */ - private $pricePaid; + private $prixIIENS; /** * @var string "6.5 €", "8€", Le prix que L'ONT DOIT AU PART (moins cher que pricePaid) */ - private $pricePart; + private $prixLP; /** * Constructeur valué */ - public function Nourriture($idIt,$foodTypeName,$foodTypeid, $nameFood, $namePart, $idPartenariat, $coutPourIIEN, $coutPourLP) + public function __construct($idNourriture,$type,$idType, $nom, $nomPart, $idPart, $prixIIENs, $prixLP) { - $this->idFood = $idIt; - $this->foodType = $foodTypeName; - $this->nomFood = $nameFood; - $this->nomPart = $namePart; - $this->idPart = $idPartenariat; - $this->pricePaid = $coutPourIIEN; - $this->pricePart = $coutPourLP; + $this->idNourriture = $idNourriture; + $this->type = $type; + $this->nom = $nom; + $this->nomPart = $nomPart; + $this->idPart = $idPart; + $this->prixIIENS = $prixIIENS; + $this->prixLP = $prixLP; } - public function getIDFood() + public function getIDNourriture() { - return $this->idFood; + return $this->idNourriture; } - public function setIDFood($id) + public function setIDNourriture($id) { - $this->idFood = $id; + $this->idNourriture = $id; } - public function getFoodType() + public function getType() { - return $this->foodType; + return $this->type; } - public function getNomFood() + public function getNom() { - return $this->nomFood; + return $this->nom; } public function getNomPart() { - return $this->foodType; + return $this->nomPart; } public function getIDPart() @@ -89,14 +89,14 @@ class Nourriture return $this->idPart; } - public function getPriceIIEN() + public function getPrixIIENS() { - return $this->pricePaid; + return $this->prixIIENS; } - public function getPricePart() + public function getPrixLP() { - return $this->pricePart; + return $this->prixLP; } } diff --git a/ensiie-project/src/Model/Classes/Special.php b/ensiie-project/src/Model/Classes/Special.php index c51b9a61243e7a0ef031578c2592cf47e173b9d3..ddaaa4b9afef1c827bc3ece95e5aa289111c9905 100644 --- a/ensiie-project/src/Model/Classes/Special.php +++ b/ensiie-project/src/Model/Classes/Special.php @@ -11,31 +11,31 @@ class Special /** * @var string "Sauce", "Viande", etc... */ - private $specialType; + private $type; /** * @var int Id du type de nourriture dans la BDD */ - private $specialTypeID; + private $idType; /** * @var string "Algérienne", "Poulet", etc... */ - private $nomSpecial; + private $nom; /** * Constructeur valué */ - public function Special($idIt,$specTypeName,$specTypeid, $nameSpec) + public function __construct($idSpecial,$type,$idType, $nom) { - $this->idSpecial = $idIt; - $this->specialType = $specTypeName; - $this->specialTypeID = $specTypeid; - $this->nomSpecial = $nameSpec; + $this->idSpecial = $idSpecial; + $this->type = $type; + $this->idType = $idType; + $this->nom = $nom; } - public function getIDFood() + public function getIDSpecial() { return $this->idSpecial; } @@ -45,19 +45,19 @@ class Special $this->idSpecial = $id; } - public function getSpecialType() + public function getType() { - return $this->specialType; + return $this->type; } - public function getIDTypeSpecial() + public function getIDType() { - return $this->specialTypeID; + return $this->idType; } - public function getNomSpecial() + public function getNom() { - return $this->nomSpecial; + return $this->nom; } } ?> \ No newline at end of file diff --git a/ensiie-project/src/Model/Classes/Utilisateur.php b/ensiie-project/src/Model/Classes/Utilisateur.php index b7a3bdda9313124bdd5b80232c31c8bcd9b0d8f4..dc4609cd6634cae2b9ae93ef5ae0dd72deaa40ef 100644 --- a/ensiie-project/src/Model/Classes/Utilisateur.php +++ b/ensiie-project/src/Model/Classes/Utilisateur.php @@ -1,6 +1,5 @@ <?php -namespace Utilisateur; - +require_once('Commande.php'); class Utilisateur { /** @@ -29,7 +28,7 @@ class Utilisateur private $isAdmin; /** - * @var array<commande> Commandes de l'evenement courrant + * @var array<Commande> Commandes de l'evenement courrant */ private $commandes; @@ -37,14 +36,14 @@ class Utilisateur /** * Constructeur valué */ - public function Utilisateur($ariseID,$prenom,$nom,$pseudo,$isAdmin,$commande) + public function __construct($ariseID,$prenom,$nom,$pseudo,$isAdmin,$commandes) { $this->ariseID = $ariseID; $this->prenom = $prenom; $this->nom = $nom; $this->pseudo = $pseudo; $this->isAdmin = $isAdmin; - $this->commandes = $commande; + $this->commandes = $commandes; } /** diff --git a/ensiie-project/src/Model/Utilisateur/set_utilisateur.php b/ensiie-project/src/Model/Utilisateur/set_utilisateur.php deleted file mode 100644 index 0424e1d031c92697388241ecb2841bbe9eba31fb..0000000000000000000000000000000000000000 --- a/ensiie-project/src/Model/Utilisateur/set_utilisateur.php +++ /dev/null @@ -1,13 +0,0 @@ -<?php -// on teste si nos variables sont définies -if (isset($_SESSION['login'])) -{ - //$db_utilisateur = NULL; // Appel à la base pour récupérer l'utilisateur selon son ariseID = $_SESSION['login'] - //$utilisateur = new Utilisateur($db_utilisateur['ariseID'],$db_utilisateur['prenom'],$db_utilisateur['nom'],$db_utilisateur['pseudo'],$db_utilisateur['isAdmin']); - //$utilisateur->setCommandes($db_utilisateur['commandes']); - $utilisateur = NULL; -} -else -{ - $utilisateur = NULL; -} diff --git a/ensiie-project/src/Model/infos_njv.php b/ensiie-project/src/Model/infos_njv.php index 0bb4eafe8ebd284223b3d1fa78b3c078a02b33a3..d608ae554c1ea1a62e79e1e643527f97e8839835 100644 --- a/ensiie-project/src/Model/infos_njv.php +++ b/ensiie-project/src/Model/infos_njv.php @@ -2,13 +2,14 @@ setlocale(LC_TIME, "fr_FR"); -$NJV_NUMERO = 47; // Numéro de la NJV ou ObiLAN en cours -$NJV_TYPE = 'ObiLAN'; // Type de NJV en cours - {ObiLAN, NJV} -$NJV_DATE = strtotime("05/11/2019 08:00:00"); // Date de début de la NJV ou ObiLAN à 2h près (20h = début effectif à 18h) - -$date_fin_premiere_commande = strtotime("-20 hours -1 second", $NJV_DATE); -$date_fin_seconde_commande = strtotime("-1 hours", $NJV_DATE); -$date_fin_seconde_commande_battement = strtotime("-30minutes", $NJV_DATE); -$date_fin_NJV = strtotime("+9 hour", $NJV_DATE); +$EVT_NUMERO = 47; // Numéro de la NJV ou ObiLAN en cours +$EVT_TYPE = 'ObiLAN'; // Type de NJV en cours - {ObiLAN, NJV} +$EVT_DATE = strtotime("05/11/2019 08:00:00"); // Date de début de la NJV ou ObiLAN à 2h près (20h = début effectif à 18h) +$evenement = new Evenement($id=0, $EVT_TYPE, $EVT_NUMERO, $EVT_DATE); + +$date_fin_premiere_commande = strtotime("-20 hours -1 second", $evenement->getDate()); +$date_fin_seconde_commande = strtotime("-1 hours", $evenement->getDate()); +$date_fin_seconde_commande_battement = strtotime("-30minutes", $evenement->getDate()); +$date_fin_NJV = strtotime("+9 hour", $evenement->getDate()); ?> \ No newline at end of file diff --git a/ensiie-project/src/Model/login.php b/ensiie-project/src/Model/login.php index d48333aa7167a5d65b5261f902ee891e13972bfc..d839bc57d2252d954c1fde98138bd91567cc183f 100644 --- a/ensiie-project/src/Model/login.php +++ b/ensiie-project/src/Model/login.php @@ -1,14 +1,13 @@ <?php -// TODO On interroge notre base de données afin de savoir si le visiteur qui se connecte est bien membre du site -$login_valide = "invite"; -$pwd_valide = "abc"; // on teste si nos variables sont définies if (isset($_POST['login']) && isset($_POST['pwd'])) { - + // TODO On interroge notre base de données afin de savoir si le visiteur qui se connecte est bien membre du site + //Le couple ($_POST['login'],$_POST['pwd']) doit exister dans la base + $isMember = TRUE; // on vérifie les informations du formulaire, à savoir si le pseudo saisi est bien un pseudo autorisé, de même pour le mot de passe - if ($login_valide == $_POST['login'] && $pwd_valide == $_POST['pwd']) + if ($isMember) { // dans ce cas, tout est ok, on peut démarrer notre session diff --git a/ensiie-project/src/Model/set_commande.php b/ensiie-project/src/Model/set_commande.php new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/ensiie-project/src/Model/set_utilisateur.php b/ensiie-project/src/Model/set_utilisateur.php new file mode 100644 index 0000000000000000000000000000000000000000..f90bcdbde2e7322ffcdbe63023c04f570e54d8b7 --- /dev/null +++ b/ensiie-project/src/Model/set_utilisateur.php @@ -0,0 +1,28 @@ +<?php +// on teste si nos variables sont définies +if (isset($_SESSION['login'])) +{ + //$db_utilisateur = NULL; // TODO Appel à la base pour récupérer l'utilisateur selon son ariseID = $_SESSION['login'] + //$utilisateur = new Utilisateur($db_utilisateur['ariseID'],$db_utilisateur['prenom'],$db_utilisateur['nom'],$db_utilisateur['pseudo'],$db_utilisateur['isAdmin']); + //$utilisateur->setCommandes($db_utilisateur['commandes']); + if ($_SESSION['login'] == "begue2018") + { + $utilisateur = new Utilisateur($_SESSION['login'],"Olivier","BEGUE","Jed",FALSE,array()); + } + elseif ($_SESSION['login'] == "gabbay2018") + { + $utilisateur = new Utilisateur($_SESSION['login'],"Milan","GABBAY","Jalik",TRUE,array()); + } + elseif ($_SESSION['login'] == "invite") + { + $utilisateur = new Utilisateur($_SESSION['login'],"Invité","","",FALSE,array()); + } + else + { + $utilisateur = NULL; + } +} +else +{ + $utilisateur = NULL; +} diff --git a/ensiie-project/src/View/accueil_utilisateur.php b/ensiie-project/src/View/accueil_utilisateur.php deleted file mode 100644 index ad1892a5630afb318f962e20e6f5887d5cdd6445..0000000000000000000000000000000000000000 --- a/ensiie-project/src/View/accueil_utilisateur.php +++ /dev/null @@ -1,13 +0,0 @@ -<!DOCTYPE html> -<html> -<body> -<?php -if ($utilisateur == NULL) -{?> - <div class="alert alert-danger"> - <strong>Veuillez vous connecter</strong> - </div> -<?php -}?> -</body> -</html> \ No newline at end of file diff --git a/ensiie-project/src/View/commande.php b/ensiie-project/src/View/commande.php deleted file mode 100644 index b8ef4733729f463a0f8a71a1ae9d43670a1d785a..0000000000000000000000000000000000000000 --- a/ensiie-project/src/View/commande.php +++ /dev/null @@ -1,15 +0,0 @@ -<!DOCTYPE html> -<html> -<body> -<?php - -foreach( $commande in $utilisateur->commandes){ -?> - <div class="truc"> - <p>Vous avez commandé : <?php $commande['titre']?></p> - </div> - <?php -} -?> -</body> -</html> diff --git a/ensiie-project/src/View/not_connected.php b/ensiie-project/src/View/not_connected.php new file mode 100644 index 0000000000000000000000000000000000000000..fe4ec4c12a4a39645f50f846b2b4e4bcd442cd7c --- /dev/null +++ b/ensiie-project/src/View/not_connected.php @@ -0,0 +1,7 @@ +<html> +<body> +<div class="text-center"> + <div><strong class="text-danger">Merci de vous identifier à AriseID pour commander !</strong></div> +</div> +</body> +</html> \ No newline at end of file diff --git a/ensiie-project/src/View/page_titre.php b/ensiie-project/src/View/page_titre.php new file mode 100644 index 0000000000000000000000000000000000000000..7dd3a1f63426fc8d4fa9f076521a3bc18edf8bd5 --- /dev/null +++ b/ensiie-project/src/View/page_titre.php @@ -0,0 +1,6 @@ +<?php +if ($evenement->getType() == 'ObiLAN') + $page_title = 'Commander pour l\'ObiLAN '.$evenement->getNumero(); +if ($evenement->getType() == 'NJV') + $page_title = 'Commander pour la NJV '.$evenement->getNumero(); +?> \ No newline at end of file diff --git a/ensiie-project/src/View/panel_commande.php b/ensiie-project/src/View/panel_commande.php new file mode 100644 index 0000000000000000000000000000000000000000..c61458159cddba41a902c0f7dbbcb9f5a736e153 --- /dev/null +++ b/ensiie-project/src/View/panel_commande.php @@ -0,0 +1,20 @@ +<!DOCTYPE html> +<html> +<body> +<?php + +foreach($utilisateur->getCommandes() as $commande){ +?> + <div class="truc"> + <?php + foreach($commande->getMenus() as $menu) + {?> + <p>Vous avez commandé : <?php echo $menu->getNourriture()->getNom().', '.$menu->getSpecial()->getType().' '.$menu->getSpecial()->getNom()?></p> + <?php + }?> + </div> + <?php +} +?> +</body> +</html> diff --git a/ensiie-project/src/View/selection_repas.php b/ensiie-project/src/View/selection_repas.php new file mode 100644 index 0000000000000000000000000000000000000000..e7ef586c982dd5c56c4fa27a33290dec9a498877 --- /dev/null +++ b/ensiie-project/src/View/selection_repas.php @@ -0,0 +1,10 @@ +<!DOCTYPE html> +<html> +<body> +<div class="panel panel-default"> + <div class="panel-heading text-center"> + <strong>Choisissez votre repas ! • Plus de détails <a href="http://www.obigdelice.fr">ici</a></strong><br/> + <small>(Pour commander la même chose plusieurs fois, faites une nouvelle commande)</small> + </div> +</body> +</html> \ No newline at end of file diff --git a/ensiie-project/src/index.php b/ensiie-project/src/index.php index bffaacfbebff309cfff72da3326f3b0fae174643..181dc8e83aa3fbac48a6eb0a3655e95ca66f6c4d 100644 --- a/ensiie-project/src/index.php +++ b/ensiie-project/src/index.php @@ -1,14 +1,15 @@ <?php session_start(); -require_once('Model/Utilisateur/utilisateur.php'); -require_once("Model/Utilisateur/set_utilisateur.php"); +require_once('Model/Classes/Utilisateur.php'); +require_once('Model/Classes/Commande.php'); +require_once('Model/Classes/Evenement.php'); +require_once('Model/Classes/Menu.php'); +require_once('Model/Classes/Special.php'); +require_once("Model/set_utilisateur.php"); require_once('Model/infos_njv.php'); -if ($NJV_TYPE == 'ObiLAN') - $page_title = 'Commander pour l\'ObiLAN '.$NJV_NUMERO; -if ($NJV_TYPE == 'NJV') - $page_title = 'Commander pour la NJV '.$NJV_NUMERO; +include('View/page_titre.php'); include('View/head.php'); @@ -21,6 +22,12 @@ include('View/accueil_utilisateur.php'); if ($utilisateur != NULL) { include('View/deadline_commande.php'); + include('View/panel_commande.php'); + include('Controller/commande_form.php'); +} +else +{ + include("View/not_connected.php"); } include('View/footer.php');