/** * IS: Terdeklarasinya filter dan param di session, dan page_row * FS: Mengirimkan ke viewer: cleanUrl, message, page_row, paginator, * all_area, all_category, filter_alert * Desc: Mengatur aksi yang dilakukan untuk halaman index */ public function indexAction() { $tbl = new Model_DbTable_Destination(); $tbl_categories = new Model_DbTable_Category(); $pageNumber = $this->_getParam('page'); if ($this->getRequest()->isPost()) { $post = $this->getRequest()->getPost(); switch ($post['action']) { case 'delete': $cultures = $post['cultures']; foreach ($cultures as $id) { $culture = $tbl->find($id)->current(); if (null != $culture) { if ($culture->status != 0) { $culture->setFromArray(array('status' => 0))->save(); $this->loggingaction('Culture', 'Archive', $id, 1); } else { // $culture->delete(); // $this->loggingaction('Culture', 'Delete', $id, 1); } } } $this->_helper->flashMessenger->addMessage('Item kebudayaan berhasil dihapus.'); break; case 'filter': $this->filter->culture = $post['filter']; break; case 'reset': $this->filter->unsetAll(); break; case 'sort': $this->filter->culture = $post['filter']; if ($this->filter->culture['order'] == 'ASC') { $this->filter->culture['order'] = 'DESC'; } else { $this->filter->culture['order'] = 'ASC'; } break; default: break; } $this->_helper->redirector("index"); } $data = $tbl->findAllWithDescription(1, $this->filter->culture); $statusesCount = $tbl->findStatusesCount(); if (!$this->_userInfo->canApprove) { $data = $tbl->findAllWithDescription(1, $this->filter->culture, $this->_userInfo->id); $statusesCount = $tbl->findStatusesCount($this->_userInfo->id); } $cultures = Zend_Paginator::factory($data); $cultures->setItemCountPerPage(5); $cultures->setCurrentPageNumber($pageNumber); if (isset($this->filter->culture['row'])) { $cultures->setItemCountPerPage($this->filter->culture['row']); } $categories = $tbl_categories->getCategories(); array_unshift($categories, 'Tampilkan Semua'); $messages = $this->_helper->flashMessenger->getMessages(); $this->view->categories = $categories; $this->view->statusesCount = $statusesCount; $this->view->filter = $this->filter->culture; $this->view->userInfo = $this->_userInfo; $this->view->messages = $messages; $this->view->cultures = $cultures; }