/** * This method controls what happens when you move to /dashboard/index in your app. */ public function index($pageToShow = 0) { $page = false; if (isset($_POST['suggestion'])) { $suggestion = $_POST['suggestion']; } else { $suggestion = ''; } if (isset($pageToShow)) { $page = $pageToShow; } if (isset($_POST['itemsToShow'])) { $itemsToShow = $_POST['itemsToShow']; } else { $itemsToShow = 3; } if (isset($_POST['orderBy'])) { $orderBy = $_POST['orderBy']; } else { $orderBy = 'material_id'; } if (!$page) { $start = 0; $page = 1; } else { $start = ($page - 1) * $itemsToShow; } $numTotalRegister = MaterialModel::getNumRowAllMaterialsSuggested($suggestion); $totalPages = ceil($numTotalRegister / $itemsToShow); $this->View->render('dashboard/index', array('totalPages' => $totalPages, 'page' => $page, 'suggestion' => $suggestion, 'itemsToShow' => $itemsToShow, 'orderBy' => $orderBy, 'oeuvres' => OeuvreModel::getAllOeuvreByEmployee(Session::get('user_id')), 'oeuvres_materials' => DashboardModel::getAllOeuvreMaterials(), 'oeuvres_photos' => DashboardModel::getAllOeuvrePhotos(), 'materials' => MaterialModel::getMaterialsSuggestedPaginatedOrderBy($suggestion, $start, $itemsToShow, $orderBy))); }