public function editrecordsAction() { $recordsModel = new Records(); $searchQuery = $this->getRequest()->getParam('search', false); $sort = $this->getRequest()->getParam('sort'); $sorttype = $this->getRequest()->getParam('sorttype'); $this->view->sort = $sort; $this->view->sorttype = $sorttype; if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost(); if (!isset($data['method'])) { $id = $data['id']; unset($data['id']); if ($data['substitute'] == 129) { $data['acct'] = '5-000-0-0000-0000-00000-0000-0'; } $recordsModel->updateRecord($id, $data); } else { if ($data['method'] == 'remove') { $recordsModel->deleteMultiple($data['ids']); } if ($data['method'] == 'skipToPage') { $this->_redirect($this->view->url(array('page' => $data['gotopage']))); } if ($data['method'] == 'search') { unset($data['method']); $search = array(); if (trim($data['startdate']) != '') { $startdate = date('Y-m-d', strtotime($data['startdate'])); $search['startdate'] = $startdate; } if (trim($data['enddate']) != '') { $enddate = date('Y-m-d', strtotime($data['enddate'])); $search['enddate'] = $enddate; } if (trim($data['reason']) != '') { $search['reason'] = $reason; } unset($data['startdate']); unset($data['enddate']); foreach ($data as $key => $value) { if (trim($value) != '') { $search[$key] = $value; } } if (!empty($search)) { $searchString = urlencode(base64_encode(serialize($search))); $this->_redirect($this->view->url(array('search' => $searchString))); } } } } $this->view->searchQuery = $searchQuery; $searchArray = unserialize(base64_decode(urldecode($searchQuery))); $this->view->search = (object) $searchArray; if ($this->_me->admin == 1) { $records = $recordsModel->getAll($sort, $sorttype, $searchArray); } else { $records = $recordsModel->getAllByLocation($this->_me->location, true, $searchArray); } $page = $this->_getParam('page', 1); $this->view->page = $page; $paginator = Zend_Paginator::factory($records); $paginator->setItemCountPerPage(20); $paginator->setCurrentPageNumber($page); $this->view->records = $paginator; $substitutesModel = new Substitutes(); $this->view->substitutes = $substitutesModel->getAll(); $locationsModel = new Locations(); $this->view->locations = $locationsModel->getAll(); $employeesModel = new Employees(); if ($this->_me->admin == 1) { $this->view->employees = $employeesModel->getAll(); } else { $this->view->employees = $employeesModel->getAllByLocation($this->_me->location); } }