public function indexAction() { try { $service_form = new Application_Form_ServiceMasterForm(); $this->view->form = $service_form; $serviceMasterMapper = new Application_Model_ServiceMasterMapper(); $services = new Application_Model_ServiceMasters(); $request = $this->getRequest(); if ($request->isPost()) { $request_type = $request->getParam("request_type", false); if ($request_type) { if ($request_type == "add") { $params = $request->getParams(); if ($service_form->isValid($params)) { foreach ($params as $param => $value) { $services->__set($param, $value); } if ($serviceMasterMapper->addNewServiceMaster($services)) { $this->view->message = "Service added successfully"; $this->view->hasMessage = true; $this->view->messageType = "success"; } else { $this->view->message = "Error occured while adding. Please try again"; $this->view->hasMessage = true; $this->view->messageType = "danger"; } } else { $this->view->message = "Error occured while Adding. Please fill form correctly"; $this->view->hasMessage = true; $this->view->messageType = "danger"; } } elseif ($request_type == "delete") { $id = $request->getParam("id"); if ($serviceMasterMapper->deleteServiceMasterById($id)) { $this->view->hasMessage = true; $this->view->messageType = "success"; $this->view->message = "Service deleted successfully."; } else { $this->view->hasMessage = true; $this->view->messageType = "danger"; $this->view->message = "Error occured while deleting. Please try again."; } } } } $services = $serviceMasterMapper->getAllServiceMasters(); $this->view->services = $services; $this->authorised = true; } catch (Exception $ex) { $this->authorised = false; $this->view->hasMessage = true; $this->view->messageType = "danger"; $this->view->message = $ex->getMessage(); } }
public function updateServiceMaster(Application_Model_ServiceMasters $serviceMaster) { $data = array('service_name' => $serviceMaster->__get("service_name")); $where = "service_id = " . $serviceMaster->__get("service_id"); $result = $this->_db_table->update($data, $where); if (count($result) == 0) { return false; } else { return true; } }