diff --git a/ensiie-project/src/Controller/admin_set_utilisateur.php b/ensiie-project/src/Controller/admin_set_utilisateur.php new file mode 100644 index 0000000000000000000000000000000000000000..fa0a156ff921bff21c9e076f616aff53a5842260 --- /dev/null +++ b/ensiie-project/src/Controller/admin_set_utilisateur.php @@ -0,0 +1,21 @@ +<?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'],$db_utilisateur['commandes']); + + if ($_SESSION['login'] == "gabbay2018") + { + $utilisateur = new Utilisateur($_SESSION['login'],"Milan","GABBAY","Jalik",TRUE,array()); + } + else + { + $utilisateur = NULL; + } + +} +else +{ + $utilisateur = NULL; +} diff --git a/ensiie-project/src/Controller/set_utilisateur.php b/ensiie-project/src/Controller/set_utilisateur.php index 8c196a33cddc66b96619c258179bd48609887000..371e676fb64b098a09a09c7b8f1c61bc780f8fe4 100644 --- a/ensiie-project/src/Controller/set_utilisateur.php +++ b/ensiie-project/src/Controller/set_utilisateur.php @@ -4,18 +4,23 @@ 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'],$db_utilisateur['commandes']); - + if ($_SESSION['login'] == "begue2018") { - $utilisateur = new Utilisateur($_SESSION['login'],"Olivier","BEGUE","Jed",FALSE,array()); + $commande0 = new Commande(0,0,"2019-04-04 18:25:10.0",FALSE,array($menu0,$menu2)); + $utilisateur = new Utilisateur($_SESSION['login'],"Olivier","BEGUE","Jed",FALSE,array($commande0)); } elseif ($_SESSION['login'] == "gabbay2018") { - $utilisateur = new Utilisateur($_SESSION['login'],"Milan","GABBAY","Jalik",TRUE,array()); + $commande1 = new Commande(1,1,"2019-04-04 18:25:10.0",FALSE,array($menu3)); + $utilisateur = new Utilisateur($_SESSION['login'],"Milan","GABBAY","Jalik",TRUE,array($commande1,$commande1)); } elseif ($_SESSION['login'] == "invite") { - $utilisateur = new Utilisateur($_SESSION['login'],"","","Invité",FALSE,array()); + $commande2 = new Commande(2,2,"2019-04-04 18:25:10.0",FALSE,array($menu0,$menu2)); + $commande3 = new Commande(3,2,"2019-04-04 18:25:10.0",FALSE,array($menu1)); + $commande4 = new Commande(4,2,"2019-04-04 18:25:10.0",FALSE,array($menu3)); + $utilisateur = new Utilisateur($_SESSION['login'],"","","Invité",FALSE,array($commande2,$commande3,$commande4)); } else { diff --git a/ensiie-project/src/Model/Classes/Commande.php b/ensiie-project/src/Model/Classes/Commande.php index 81f99cfbf4325883b1873ebc6c9617eac57b503a..7c6c10e662da491b5b3004b2af10c9c40696c0d2 100644 --- a/ensiie-project/src/Model/Classes/Commande.php +++ b/ensiie-project/src/Model/Classes/Commande.php @@ -25,7 +25,7 @@ class Commande /** * @var array<Menu> Le tableau qui contient les différents menus */ - private $menus; + private $menus = array(); /** * Constructeur valué */ @@ -48,11 +48,16 @@ class Commande return $this->utilisateurID; } - public function getDate() + public function getDate() { return $this->date; } + public function setDate($date) + { + $this->date = $date + } + public function getPaid() //je trouve ca drole comme blague :/ { return $this->isPaid; @@ -65,7 +70,16 @@ class Commande public function addMenus($menu){ array_push($this->menus, $menu); - } + } + + public function toString(){ + $str = ""; + foreach($this->getMenus() as $menu) + { + $str = $str."-".$menu->toString()."<br/>"; + } + return $str; + } } ?> \ No newline at end of file diff --git a/ensiie-project/src/Model/Classes/Menu.php b/ensiie-project/src/Model/Classes/Menu.php index 2306d01d903f508d295b621b8a756cdf17b91183..c363ccc18129ecd49ccce438a033c002752bc04c 100644 --- a/ensiie-project/src/Model/Classes/Menu.php +++ b/ensiie-project/src/Model/Classes/Menu.php @@ -58,6 +58,29 @@ class Menu $this->specials = $specials; } + public getNbSauces() + { + $nb = 0; + foreach($specials as $special) + { + if ($special->getType() == "Sauce") + { + $nb++; + } + } + return $nb; + } + + public function toString() + { + $str = ""; + $str = $str.$this->getNourriture()->toString(); + foreach($this->getSpecials() as $special) + { + $str = $str.", ".$special->toString(); + } + return $str; + } } ?> \ 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 d6198e9a5a9c6ed2e978cac5182d8e6c0353ee17..8324716ee7d620e39722d55113a80f3fa30e8bbe 100644 --- a/ensiie-project/src/Model/Classes/Nourriture.php +++ b/ensiie-project/src/Model/Classes/Nourriture.php @@ -1,5 +1,4 @@ <?php -namespace Nourriture; class Nourriture { @@ -17,7 +16,6 @@ class Nourriture * @var int Id du type de nourriture dans la BDD */ private $idType; - /** * @var string "Calzone (Tomates, Oignons)", "Tacos XXL", etc... @@ -48,7 +46,7 @@ class Nourriture /** * Constructeur valué */ - public function __construct($idNourriture,$type,$idType, $nom, $nomPart, $idPart, $prixIIENs, $prixLP) + public function __construct($idNourriture,$type,$idType, $nom, $nomPart, $idPart, $prixIIENS, $prixLP) { $this->idNourriture = $idNourriture; $this->type = $type; @@ -98,6 +96,13 @@ class Nourriture { return $this->prixLP; } + + public function toString() + { + $str = ""; + $str = $str.$this->getType().": ".$this->getNom()."(".$this->getPrixIIENS().")"; + return $str; + } } ?> \ No newline at end of file diff --git a/ensiie-project/src/Model/Classes/Special.php b/ensiie-project/src/Model/Classes/Special.php index ddaaa4b9afef1c827bc3ece95e5aa289111c9905..644554f8a2aa6ffcea1e4512dff6c743bde49ad2 100644 --- a/ensiie-project/src/Model/Classes/Special.php +++ b/ensiie-project/src/Model/Classes/Special.php @@ -1,5 +1,4 @@ <?php -namespace Special; class Special { @@ -59,5 +58,10 @@ class Special { return $this->nom; } + + public function toString() + { + return $this->getNom(); + } } ?> \ 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 dc4609cd6634cae2b9ae93ef5ae0dd72deaa40ef..381157efa4067ff956b27c8b2bfd2b7be118bb9f 100644 --- a/ensiie-project/src/Model/Classes/Utilisateur.php +++ b/ensiie-project/src/Model/Classes/Utilisateur.php @@ -154,9 +154,23 @@ class Utilisateur return $this; } - public function addCommande($com){ + public function addCommande($com) + { array_push($this->commandes, $com); - } + } + + public function removeCommande($com) + { + $arr = array(); + foreach($this->getCommandes() as $commande) + { + if ($commande != $com) + { + array_push($arr,$commande); + } + } + $utilisateur->setCommandes($arr); + } } ?> \ No newline at end of file diff --git a/ensiie-project/src/View/admin_body_titre.php b/ensiie-project/src/View/admin_body_titre.php new file mode 100644 index 0000000000000000000000000000000000000000..800449a91953e8eeb0a30f226ee12a1334de3b2b --- /dev/null +++ b/ensiie-project/src/View/admin_body_titre.php @@ -0,0 +1,9 @@ +<!DOCTYPE html> +<html> +<body> + +<div class="container" style="max-width: 900px;"> + <h2 class="text-center">Gérer les évènements</h2> + <hr/> +</body> +</html> \ No newline at end of file diff --git a/ensiie-project/src/View/admin_head.php b/ensiie-project/src/View/admin_head.php new file mode 100644 index 0000000000000000000000000000000000000000..348ce535595528652ed72ac68c9404be4bcb0709 --- /dev/null +++ b/ensiie-project/src/View/admin_head.php @@ -0,0 +1,32 @@ +<!DOCTYPE html> +<html> +<head> + <title>LanpartIIE - Admin</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport"> + <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> + <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/awesome-bootstrap-checkbox/1.0.0/awesome-bootstrap-checkbox.min.css"> + <link rel="icon" type="image/png" href="http://lanpartiie.iiens.net/sith/webroot/img/icons/member.png"> + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> + + <meta http-equiv="Expires" content="Tue, 01 Jan 1995 12:12:12 GMT"> + <meta http-equiv="Pragma" content="no-cache"> + <meta name="theme-color" content="#829A30"> + + <style> + * { outline: 0 !important; } + body { padding: 25px 0; } + .input-group { margin-bottom: 5px; width: 100%; } + .input-group:last-of-type { margin-bottom: 10px; } + .input-group-addon { cursor: default; font-weight: bold; width: 160px; text-align: left; } + textarea { resize: vertical; } + + .abc-checkbox { margin-left: -5px; } + .abc-checkbox input[type=checkbox]:checked + label:after { font-family: 'Glyphicons Halflings'; content: "\e013"; } + .abc-checkbox label:after { padding-left: 0; padding-top: 2px; font-size: 9px; } + .servie-label { color: #666; font-size: 10px; font-weight: bold; } + </style> + +</head> +</html> diff --git a/ensiie-project/src/View/body_titre.php b/ensiie-project/src/View/body_titre.php index 06b5d22795ca5266f1b76377659247d35171db92..ddb984df20ad4d6928c1fc3f1a47e720e7ed9ab9 100644 --- a/ensiie-project/src/View/body_titre.php +++ b/ensiie-project/src/View/body_titre.php @@ -4,6 +4,6 @@ <div class="container" style="max-width: 900px;"> <h2 class="text-center"><?php echo $page_title; ?></h2> - <hr> + <hr/> </body> </html> \ No newline at end of file diff --git a/ensiie-project/src/View/commande_finie.php b/ensiie-project/src/View/commande_finie.php index c61458159cddba41a902c0f7dbbcb9f5a736e153..dfdf5b91df0e9c22fefdfc60501bd1f417a6652a 100644 --- a/ensiie-project/src/View/commande_finie.php +++ b/ensiie-project/src/View/commande_finie.php @@ -1,20 +1,36 @@ <!DOCTYPE html> <html> <body> +<div class="panel panel-default"> +<div class="panel-heading text-center"> +<strong>Voici vos commandes :</strong><br/> +</div> <?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 class="panel panel-default"> + <div class="panel-body"> + <div class="text-left"> + Vous avez commandé : <br/><?php echo $commande->toString();?> + </div> + <html> + <form method="post"> + <button class="btn btn-danger btn-xs" name="supprime" style="float: right; margin-bottom: 10px;">Supprimer</button> + </form> + </div> </div> - <?php +<?php } ?> +</div> +<hr/> </body> + +<?php +if(isset($_POST['supprime'])) +{ + $utilisateur->getCommandes($commande); +} +?> + </html> diff --git a/ensiie-project/src/View/commande_form.php b/ensiie-project/src/View/commande_form.php index 96b2e4a85c22f03eccb69c955d8e9a76f060c652..9f76ff6c37e6958da79907ea5b6b9c28556664ca 100644 --- a/ensiie-project/src/View/commande_form.php +++ b/ensiie-project/src/View/commande_form.php @@ -9,73 +9,33 @@ <div class="panel-body"> <form action="../Controller/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>'; + foreach ($parts as $part) + {?> + <div class="panel-heading text-center"> + <strong><?php echo $part['nom']?></strong> + </div> + <div class='panel-body'> <?php - } - else + foreach($part['typeFood'] as $typeFood) {?> - <option value=<?php echo $food_id?> data-max-meats=<?php $food['meats_count']?>><?php echo $food['food_title']?></option> + <div class="input-group"> + <label class="input-group-addon"><?php echo $typeFood?></label> + <select name=<?php echo $typeFood['nomType']?> class="form-control"> + <option value="0">Cliquez pour voir les choix</option> + <?php + foreach($typeFood['Foods'] as $food) + {?> + <option value=<?php echo $food['nameFood']?>><?php echo $food['nameFood']." (".$food['priceFood'].")"?></option> + <?php + }?> + </select> + </div> <?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 - } - }?> + }?> + </div> + <?php + }?> + </form> </div> </div> @@ -155,7 +115,7 @@ function refresh_meat_checkboxes(parent_meats, clear=false) } $('[id^="hidden-"]').hide(); -</script> +</script> </body> </html> \ No newline at end of file diff --git a/ensiie-project/src/View/connexion_bouton.php b/ensiie-project/src/View/connexion_bouton.php index 8c59b692a7be122deea427609962feb1b80c23ce..79c8d575c80ab393ace0c410ed4c2c2e49e50e41 100644 --- a/ensiie-project/src/View/connexion_bouton.php +++ b/ensiie-project/src/View/connexion_bouton.php @@ -10,7 +10,7 @@ else <?php if ($utilisateur->getIsAdmin()) {?> - <span class="label label-success" style="font-size: small; display: inline-block;">Admin</span> + <button onclick="admin()" class="btn btn-success btn-xs" name="admin" style="font-size: small; display: inline-block;">Admin</button> <?php }?> <span class="label label-primary" style="font-size: small; display: inline-block;"><?php echo $utilisateur->getPseudo(); ?></span> @@ -26,10 +26,14 @@ else <script> function login() { - window.location.href = "View/connexion_form.php" + window.location.href = "View/connexion_form.php" } function logout() { window.location.href = "Controller/logout.php" } + function admin() + { + window.location.href = "admin.php" + } </script> diff --git a/ensiie-project/src/admin.php b/ensiie-project/src/admin.php index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..023aeffdb89360f3bc8c3c7d4ce44f1c56deb653 100644 --- a/ensiie-project/src/admin.php +++ b/ensiie-project/src/admin.php @@ -0,0 +1,23 @@ +<?php +session_start(); + +require_once('Model/Classes/Utilisateur.php'); +require_once("Controller/admin_set_utilisateur.php"); + +include('View/admin_head.php'); + +include('View/admin_body_titre.php'); + +include("View/connexion_bouton.php"); + + +if ($utilisateur != NULL) +{ + +} +else +{ +} + +include('View/footer.php'); +?> diff --git a/ensiie-project/src/index.php b/ensiie-project/src/index.php index 065c169d4edccda9f01c771713cec82b661e8f9e..18a1afc5f7e9d579da5ae87d77581308f02b06a0 100644 --- a/ensiie-project/src/index.php +++ b/ensiie-project/src/index.php @@ -6,6 +6,27 @@ require_once('Model/Classes/Commande.php'); require_once('Model/Classes/Evenement.php'); require_once('Model/Classes/Menu.php'); require_once('Model/Classes/Special.php'); + + +//Bouffe de test +$special0 = new Special(0,"Sauce",0,"blanche"); +$special1 = new Special(1,"Sauce",0,"barbecue"); +$special2 = new Special(2,"Viande",1,"cordon bleu"); +$special3 = new Special(3,"Sauce",0,"caramel"); +$special4 = new Special(4,"Parfum",2,"daim"); + +$nourriture0 = new Nourriture(0,"Pizza",0,"raclette","pizza hut",0,"9€","8€"); +$nourriture1 = new Nourriture(1,"Dessert",1,"McFlurry","McDonald",1,"4.50€","4€"); +$nourriture2 = new Nourriture(2,"Boisson",2,"Coca Cola","McdDonald",1,"1.50€","1€"); +$nourriture3 = new Nourriture(3,"Tacos",3,"Taille M","O'bigDelice",2,"5.5€","5€"); + +$menu0 = new Menu(0,$nourriture0,array()); +$menu1 = new Menu(1,$nourriture1,array($special3,$special4)); +$menu2 = new Menu(2,$nourriture2,array()); +$menu3 = new Menu(3,$nourriture3,array($special0,$special1,$special2)); + + + require_once("Controller/set_utilisateur.php"); require_once('Model/infos_njv.php'); @@ -21,6 +42,7 @@ include('View/deadline_commande.php'); if ($utilisateur != NULL) { + include('View/commande_finie.php'); include('View/commande_form.php'); }