예제 #1
0
 public function index()
 {
     //If the register form was sent
     if (Form::exists('login_form')) {
         //Check if User exists
         $user = Client::getOneBy(array('_mail' => Form::get('mail')));
         //Confirm if PW matches
         if ($user && $user->getPassword() == Client::encryptPassword(Form::get('password'))) {
             Session::connect($user);
             return \App\Component\Redirect::to('/');
         }
         $error = "Vos informations de connexion sont incorrects. Merci de réessayer.";
         return View::render("login/index.php", array('error' => $error));
     }
     return View::render("index/index.php");
 }
예제 #2
0
 public function index()
 {
     //If the register form was sent
     if (Form::exists('register_form')) {
         //We check if all the input are filled
         if (Form::checkEmpty(array('mainAddress', 'firstName', 'mail', 'name', 'password', 'password_check', 'phoneNumber', 'birthday'))) {
             $error = "Veuillez remplir tous les champs";
             return View::render("register/index.php", array('error' => $error));
         }
         //We check if the mail address is not already taken
         if (Client::getOneBy(array('_mail' => Form::get('mail')))) {
             $error = "Cette adresse e-mail est déjà associée à un compte. Veuillez en choisir une autre.";
             return View::render("register/index.php", array('error' => $error));
         }
         //We check if the password and the check are the same
         if (Form::get('password') != Form::get('password_check')) {
             $error = "Les mots de passe ne correspondent pas.";
             return View::render("register/index.php", array('error' => $error));
         }
         //We create a new User, and associate the values
         $user = new Client();
         $user->setFirstName(Form::get('firstName'));
         $user->setMail(Form::get('mail'));
         $user->setName(Form::get('name'));
         $user->setPassword(Form::get('password'));
         $user->setPhoneNumber(Form::get('phoneNumber'));
         $user->setBirthday(Form::get('birthday'));
         //We save this User in the DB
         $user->save();
         $address = new \App\Model\Address();
         $address->setAddress(Form::get('mainAddress'));
         $address->setUser($user);
         $address->save();
         $user->setAddress($address);
         $user->save();
         return View::render("register/complete.php", array('user' => $user));
     }
     return View::render("register/index.php");
 }
예제 #3
0
 public function index()
 {
     //If the register form was sent
     if (Form::exists('profile_form')) {
         //We check if all the input are filled
         if (Form::checkEmpty(array('mainAddress', 'firstName', 'mail', 'name', 'password', 'password_check', 'phoneNumber', 'birthday'))) {
             $error = "Veuillez remplir tous les champs";
             return View::render("register/index.php", array('error' => $error));
         }
         $user = Session::getUser();
         //We check if the password and the check are the same
         if (Form::exists('password') && Form::get('password') != "") {
             if (Form::get('password') != Form::get('password_check')) {
                 $error = "Les mots de passe ne correspondent pas.";
                 return View::render("register/index.php", array('error' => $error));
             } else {
                 $user->setPassword(Form::get('password'));
             }
         }
         //associate the values
         $user->setFirstName(Form::get('firstName'));
         $user->setName(Form::get('name'));
         $user->setPhoneNumber(Form::get('phoneNumber'));
         $user->setBirthday(Form::get('birthday'));
         //We save this User in the DB
         $user->save();
         $adress = new \App\Model\Address();
         $adress->setAddress(Form::get('mainAddress'));
         $adress->setUser($user);
         $adress->save();
         $user->setAddress($adress);
         $user->save();
         Session::connect($user);
         return View::render("profile/complete.php", array('user' => $user));
     }
     $user = Session::getUser();
     return View::render("profile/index.php", array('user' => $user));
 }
예제 #4
0
 public function gererCommande($id = 0)
 {
     $restaurateur = Restaurateur::getOneBy(array('_id' => new \MongoId(Session::getUser()->getId())));
     //If we are not connected as a Restaurateur, send to the login page
     if (!Session::isConnected() || Session::getUser()->getType() != USER_RESTAURATEUR) {
         return Redirect::to('/restaurateur/login');
     }
     //If no restaurant is specified, display the list
     if ($id == 0) {
         $commandes = Commande::getByRestaurateur($restaurateur);
         return View::render("restaurateur/gestionCommande.php", array('commandes' => $commandes));
     }
     $commande = Commande::getOneBy(array('_id' => new \MongoId($id)));
     if ($commande->getStatus() < Commande::COMMAND_STATUS_PREPARING) {
         $commande->setStatus(Commande::COMMAND_STATUS_PREPARING);
         $commande->save();
     }
     if (Form::exists('finir_commande_form')) {
         $commande->setStatus(commande::COMMAND_STATUS_READY);
         $commande->save();
         $commandes = Commande::getByRestaurateur($restaurateur);
         return View::render("restaurateur/gestionCommande.php", array('commandes' => $commandes));
     }
     return View::render("restaurateur/prepareCommande.php", array('commande' => $commande));
 }
예제 #5
0
 public function payCommand($commandId)
 {
     //If User is not logged in
     if (!Session::isConnected() || Session::getUser()->getType() != USER_CLIENT) {
         Session::addFlashMessage("Non connecté", "error", "Veuillez vous connecter avant de continuer.");
         Redirect::to('/restaurant');
     }
     //If it doesn't exist, return to the list
     $command = Commande::getOneBy(array('_id' => new \MongoId($commandId)));
     if (!$command) {
         Redirect::to('/restaurant');
     }
     $command->setStatus(Commande::COMMAND_STATUS_PAYED);
     $command->createConfirmationCode();
     $command->save();
     MailSender::sendConfirmationMail($command);
     return View::render("restaurant/endCommand.php", array('command' => $command));
 }
예제 #6
0
 public function mesCommandes()
 {
     //If we are not connected as a livreur, send to the login page
     if (!Session::isConnected() || Session::getUser()->getType() != USER_LIVREUR) {
         Session::disconnect();
         return Redirect::to('/livreur/login');
     }
     $commandes = Commande::getBy(array('_livreur' => Session::getUser()->getId()));
     return View::render("livreur/mesCommandes.php", array('commandes' => $commandes));
 }
예제 #7
0
 public function error404()
 {
     return View::render("error/error404.php");
 }
예제 #8
0
 public function supprimeRestaurant()
 {
     //If we are not connected as an entrepreneur, send to the login page
     if (!Session::isConnected() || Session::getUser()->getType() != USER_ENTREPRENEUR) {
         Redirect::to('/entrepreneur/login');
     }
     //We get all the restaurateurs
     $restaurants = Restaurant::getBy(array());
     return View::render("entrepreneur/supprimeRestaurant.php", array('restaurants' => $restaurants));
 }
예제 #9
0
파일: index.php 프로젝트: OrigiHor/s5cw.dev
<?php

use App\Component\View;
View::render(['template' => $_SERVER['DOCUMENT_ROOT'] . '/private/template/layout.php', 'data' => ['content' => 'It\'s work']]);