public function mealManagerAction() { $this->view->headTitle(Vi_Language::translate('Meal manager')); $this->view->menu = array('restaurant'); $config = Vi_Registry::getConfig(); $numRowPerPage = Vi_Registry::getConfig("defaultNumberRowPerPage"); $currentPage = $this->_getParam("page", 1); $displayNum = $this->_getParam('displayNum', false); $rid = $this->_getParam('rid', false); if (false == $rid) { $this->_redirect('restaurant/admin/manager'); } /** * Get number of meal per page */ if (false === $displayNum) { $displayNum = $this->session->mealDisplayNum; } else { $this->session->mealDisplayNum = $displayNum; } if (null != $displayNum) { $numRowPerPage = $displayNum; } /** * Get condition */ $condition = $this->_getParam('condition', false); if (false === $condition) { $condition = $this->session->mealCondition; } else { $this->session->mealCondition = $condition; $currentPage = 1; } if (false == $condition) { $condition = array(); } $condition['restaurant_id'] = $rid; /** * Load all meals */ $objMeal = new Models_Meal(); $allMeals = $objMeal->getAllMeals($condition, 'meal_id DESC', $numRowPerPage, ($currentPage - 1) * $numRowPerPage); /** * Count all meals */ $count = count($objMeal->getAllMeals()); /** * Modify all meals */ foreach ($allMeals as &$meal) { if (null != $meal['created_date']) { $meal['created_date'] = date($config['dateFormat'], $meal['created_date']); } } unset($meal); /** * Set values for tempalte */ $this->setPagination($numRowPerPage, $currentPage, $count); $this->view->allMeals = $allMeals; $this->view->mealMessage = $this->session->mealMessage; $this->session->mealMessage = null; $this->view->condition = $condition; $this->view->displayNum = $numRowPerPage; $this->view->rid = $rid; }