Esempio n. 1
0
 public function deleteAction()
 {
     $this->view->title = "Delete restaurant";
     $this->view->headTitle($this->view->title, 'PREPEND');
     if ($this->getRequest()->isPost()) {
         $del = $this->getRequest()->getPost('del');
         if ($del == 'Yes') {
             $id = $this->getRequest()->getPost('id');
             $restaurants = new Model_DbTable_Restaurants();
             $restaurants->deleteRestaurant($id);
         }
         $this->_redirect('/restaurant');
     } else {
         $id = $this->_getParam('id', 0);
         $restaurants = new Model_DbTable_Restaurants();
         $this->view->restaurant = $restaurants->getRestaurant($id);
     }
 }
Esempio n. 2
0
 public function addAction()
 {
     $auth = Zend_Auth::getInstance();
     $authStorage = $auth->getStorage();
     $userInfo = $authStorage->read();
     $userID = $userInfo->id;
     $id = $this->_getParam('id', 0);
     $dir = $this->_getParam('dir', 0);
     $dishes = new Model_DbTable_Dishes();
     $itemsRowset = $dishes->find($id);
     $thisDish = $itemsRowset->current();
     $dishName = $thisDish['name'];
     $restaurants = new Model_DbTable_Restaurants();
     $itemsRowset = $restaurants->find($thisDish['restaurant_id']);
     $thisRest = $itemsRowset->current();
     $restName = $thisRest['name'];
     $this->view->title = "Add Review for " . $dishName . " at " . $restName;
     $this->view->headTitle($this->view->title, 'PREPEND');
     $form = new Form_Review();
     $form->getElement('dish_id')->setValue($id);
     $form->getElement('user_id')->setValue($userID);
     if ($dir != '0') {
         $form->getElement('rating')->setValue($dir);
     }
     $form->submit->setLabel('Add');
     $this->view->form = $form;
     if ($this->getRequest()->isPost()) {
         $formData = $this->getRequest()->getPost();
         if ($form->isValid($formData)) {
             $userID = $form->getValue('user_id');
             $dishID = $form->getValue('dish_id');
             $rating = $form->getValue('rating');
             $ratVal = 0;
             if ($rating == 'pos' ? $ratVal = 1 : ($ratVal = -1)) {
             }
             $comments = $form->getValue('comments');
             $reviews = new Model_DbTable_Reviews();
             $reviews->addReview($userID, $dishID, $ratVal, $comments);
             $this->_redirect('/dish/detail/id/' . $id);
         } else {
             $form->populate($formData);
         }
     }
 }
Esempio n. 3
0
 public function showdishesAction()
 {
     $id = $this->_getParam('id', 0);
     if ($id > 0) {
         //show dishes in this category
         $fooditems = new Model_DbTable_FoodItems();
         $itemsRowset = $fooditems->find($id);
         $thisCategory = $itemsRowset->current();
         $catname = $thisCategory["name"];
         $this->view->catname = $catname;
         $this->view->title = "{$catname}s Found:";
         $this->view->headTitle($this->view->title, 'PREPEND');
         $dishesFound = $thisCategory->findModel_DbTable_DishesByCategory();
         $restaurants = new Model_DbTable_Restaurants();
         $foundRest = array();
         foreach ($dishesFound as $dish) {
             $restRowset = $restaurants->find($dish["restaurant_id"]);
             $curRest = $restRowset->current();
             $foundRest[$curRest["id"]] = $curRest["name"];
             //TODO: this should be replaced with a JOIN for more efficiency
         }
         $this->view->dishes = $dishesFound;
         $this->view->restaurants = $foundRest;
     }
 }
Esempio n. 4
0
 public function byrestaurantAction()
 {
     $id = $this->_getParam('rest_id', 0);
     if ($id > 0) {
         //show dishes from this restaurant id
         $restaurants = new Model_DbTable_Restaurants();
         $itemsRowset = $restaurants->find($id);
         $thisRest = $itemsRowset->current();
         $restName = $thisRest['name'];
         $restID = $thisRest['id'];
         $this->view->restaurant_id = $restID;
         $this->view->title = "Dishes at {$restName}";
         $this->view->headTitle("{$restName}", 'PREPEND');
         $dishes = new Model_DbTable_DishesComplete();
         $dishesFound = $thisRest->findDependentRowset('Model_DbTable_DishesComplete', 'Restaurant');
         $this->view->dishes = $dishesFound;
     }
 }