public function saveupdateAction() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $id = $this->_request->getParam('id'); $gendercode = $this->_request->getParam('gendercode'); $gendername = $this->_request->getParam('gendername'); $description = $this->_request->getParam('description'); $genderform = new Default_Form_gender(); $gendermodel = new Default_Model_Gender(); $messages = $genderform->getMessages(); $actionflag = ''; $tableid = ''; if ($this->getRequest()->getPost()) { if ($genderform->isValid($this->_request->getPost())) { $data = array('gendercode' => trim($gendercode), 'gendername' => trim($gendername), 'description' => trim($description), 'modifiedby' => $loginUserId, 'modifieddate' => Zend_Registry::get('currentdate')); if ($id != '') { $where = array('id=?' => $id); $messages['message'] = 'Gender updated successfully.'; $actionflag = 2; } else { $data['createdby'] = $loginUserId; $data['createddate'] = Zend_Registry::get('currentdate'); $data['isactive'] = 1; $where = ''; $messages['message'] = 'Gender added successfully.'; $actionflag = 1; } $Id = $gendermodel->SaveorUpdateGenderData($data, $where); if ($Id == 'update') { $tableid = $id; } else { $tableid = $Id; } $menuID = GENDER; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); $messages['result'] = 'saved'; $this->_helper->json($messages); } else { $messages = $genderform->getMessages(); $messages['result'] = 'error'; $this->_helper->json($messages); } } }
public function addpopupAction() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $id = $this->getRequest()->getParam('id'); Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/"); $genderform = new Default_Form_gender(); $gendermodel = new Default_Model_Gender(); $genderform->setAction(DOMAIN . 'gender/addpopup'); $controllername = 'gender'; if ($this->getRequest()->getPost()) { if ($genderform->isValid($this->_request->getPost())) { $id = $this->_request->getParam('id'); $gendercode = $this->_request->getParam('gendercode'); $gendername = $this->_request->getParam('gendername'); $description = $this->_request->getParam('description'); $date = new Zend_Date(); $menumodel = new Default_Model_Menu(); $actionflag = ''; $tableid = ''; $data = array('gendercode' => trim($gendercode), 'gendername' => trim($gendername), 'description' => trim($description), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); if ($id != '') { $where = array('id=?' => $id); $actionflag = 2; } else { $data['createdby'] = $loginUserId; $data['createddate'] = gmdate("Y-m-d H:i:s"); $data['isactive'] = 1; $where = ''; $actionflag = 1; } $Id = $gendermodel->SaveorUpdateGenderData($data, $where); $tableid = $Id; $menuidArr = $menumodel->getMenuObjID('/gender'); $menuID = $menuidArr[0]['id']; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); $genderData = $gendermodel->fetchAll('isactive = 1', 'gendername')->toArray(); $opt = ''; foreach ($genderData as $record) { $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['gendername']); } $this->view->genderData = $opt; $this->view->eventact = 'added'; $close = 'close'; $this->view->popup = $close; } else { $messages = $genderform->getMessages(); foreach ($messages as $key => $val) { foreach ($val as $key2 => $val2) { $msgarray[$key] = $val2; break; } } $this->view->msgarray = $msgarray; } } $this->view->controllername = $controllername; $this->view->form = $genderform; }