public function substitutesAction() { $locationsModel = new Locations(); $this->view->locations = $locationsModel->getAll(); $substitutesModel = new Substitutes(); if ($this->getRequest()->isPost()) { $data = $this->getRequest()->getPost(); if (@$data['method'] == 'create') { //CREATE NEW Location unset($data['method']); if ($data['firstname'] == '') { $this->view->error = "Please Provide a Name for the New Substitute."; $this->view->data = $data; } else { if ($data['lastname'] == '') { $this->view->error = "Please Provide a Name for the New Substitute."; $this->view->data = $data; } else { if ($data['payrate'] == '') { $this->view->error = "Please Provide a Payrate for the New Substitute."; $this->view->data = $data; } else { $substitutesModel->insert($data); $this->view->success = "New Substitute Created."; } } } } if (@$data['method'] == 'update') { //UPDATE Location unset($data['method']); $substitutesModel->updateRecord($data['id'], $data); $this->view->success = "Substitute Record Updated."; } if (@$data['method'] == 'delete') { //DELETE Location $where = "id=" . $data['id']; $substitutesModel->delete($where); $this->view->success = "Substitute Removed."; } } $term = $this->getRequest()->getParam('term', false); $substitutes = $substitutesModel->getAllTotal($term); $page = $this->_getParam('page', 1); $paginator = Zend_Paginator::factory($substitutes); $paginator->setItemCountPerPage(20); $paginator->setCurrentPageNumber($page); $this->view->substitutes = $paginator; }