Example #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");
 }
Example #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");
 }
Example #3
0
 private function addCommande()
 {
     $commandes = Commande::getBy(array());
     $mail = true;
     while (count($commandes) <= 5) {
         $commande = new Commande();
         $restaurant = Restaurant::getOneBy(array('name' => 'Ma Queue Mickey'));
         $item = ItemMenu::getOneBy(array('name' => 'Burger'));
         $address = Address::getOneBy(array('address' => '18 Rue des Roses'));
         $commande->setItem($item, 2);
         $commande->setStatus(Commande::COMMAND_STATUS_PAYED);
         $commande->setDatetime('12/12/12 12:12');
         $commande->createConfirmationCode();
         $commande->setAddress($address);
         $client = Client::getOneBy(array('_mail' => "*****@*****.**"));
         $commande->setClient($client);
         $commande->save();
         $restaurant->save();
         $commandes = Commande::getBy(array());
     }
 }
Example #4
0
 /**
  * Return the Client associated to the Commande
  * @return \App\Model\Client
  */
 function getClient()
 {
     return Client::getOneBy(array('_id' => $this->_client));
 }