public function doSupprimeItemMenu($id)
 {
     //If we are not connected as an entrepreneur, send to the login page
     if (!Session::isConnected() || Session::getUser()->getType() != USER_RESTAURATEUR) {
         Redirect::to('/restaurateur/login/');
     }
     $itemMenu = ItemMenu::getOneBy(array('_id' => new \MongoId($id)));
     $menu = $itemMenu->getMenu();
     if (!$itemMenu) {
         //If the restaurateur doesn't exist, we redirect to the list
         Session::addFlashMessage("Suppression impossible :", 'error', "Cet item n'existe pas.");
         Redirect::to("/restaurateur/editeMenu/" . $menu->getId());
     }
     //Then we delete the restaurateur
     $itemMenu->delete();
     Session::addFlashMessage("Item supprimé", 'success', "L'item a été supprimé avec succès.");
     Redirect::to("/restaurateur/editeMenu/" . $menu->getId());
 }
Exemple #2
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());
     }
 }
Exemple #3
0
 /**
  * Get all the Commande from the corresponding Restaurateur
  * @param \App\Model\Restaurateur $restaurateur
  * @return \App\Model\Commande[]
  */
 public static function getByRestaurateur(Restaurateur $restaurateur)
 {
     $commandes = self::getBy(array());
     $foundCommandes = array();
     foreach ($commandes as $commande) {
         $items = $commande->getItems();
         $item = ItemMenu::getOneBy(array('_id' => $items[0]->getId()));
         if ($item->getMenu()->getRestaurant()->getRestaurateur() && $item->getMenu()->getRestaurant()->getRestaurateur()->getId() == $restaurateur->getId()) {
             $foundCommandes[] = $commande;
         }
     }
     return $foundCommandes;
 }