public function addCommande($idCommande) { //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'); } $commande = Commande::getOneBy(array('_id' => new \MongoId($idCommande))); if (!$commande) { return Redirect::to('/livreur/commandes'); } //If the Commande already has a Livreur, redirect if ($commande->getLivreur()) { return Redirect::to('/livreur/commandes'); } $commande->setLivreur(Session::getUser()); $commande->setTimeAcceptation(time()); $commande->save(); return Redirect::to('/livreur/commande/' . $idCommande); }
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)); }
public function cancelCommand($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->delete(); return Redirect::to('/restaurant'); }