示例#1
0
文件: Menu.php 项目: chougron/LOG210
 /**
  * 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;
 }
示例#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());
     }
 }
 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());
 }
示例#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;
 }