Ejemplo n.º 1
0
 /**
  * Adds the item and its price to the array.
  * @param \App\Model\ItemMenu $itemMenu
  */
 public function addItem(ItemMenu $menuItem)
 {
     $id = $menuItem->getId();
     //If the object doesn't have an id, return
     if (is_null($id)) {
         return;
     }
     //If the ItemMenu is already in the array, return
     foreach ($this->_menuItems as $idMenuItem) {
         if ($id->__toString() == $idMenuItem->__toString()) {
             return;
         }
     }
     $this->_menuItems[] = $id;
 }
Ejemplo n.º 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());
     }
 }
Ejemplo n.º 3
0
 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());
 }
Ejemplo n.º 4
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;
 }