public function addpopupAction() { Zend_Layout::getMvcInstance()->setLayoutPath(APPLICATION_PATH . "/layouts/scripts/popup/"); $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $id = $this->getRequest()->getParam('id'); $msgarray = array(); $controllername = 'holidaygroups'; $holidaygroupsform = new Default_Form_holidaygroups(); $holidaygroupsform->setAction(DOMAIN . 'holidaygroups/addpopup'); if ($this->getRequest()->getPost()) { if ($holidaygroupsform->isValid($this->_request->getPost())) { $id = $this->_request->getParam('id'); $groupname = $this->_request->getParam('groupname'); $description = $this->_request->getParam('description'); $date = new Zend_Date(); $holidaygroupsmodel = new Default_Model_Holidaygroups(); $menumodel = new Default_Model_Menu(); $actionflag = ''; $tableid = ''; $data = array('groupname' => $groupname, '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 = $holidaygroupsmodel->SaveorUpdateGroupData($data, $where); $tableid = $Id; $menuidArr = $menumodel->getMenuObjID('/holidaygroups'); $menuID = $menuidArr[0]['id']; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $tableid); $holidaygroupData = $holidaygroupsmodel->fetchAll('isactive = 1', 'groupname')->toArray(); $opt = ''; foreach ($holidaygroupData as $record) { $opt .= sapp_Global::selectOptionBuilder($record['id'], $record['groupname']); } $this->view->holidaygroupData = $opt; $this->view->eventact = 'added'; $close = 'close'; $this->view->popup = $close; } else { $messages = $holidaygroupsform->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 = $holidaygroupsform; $this->view->ermsg = ''; }
public function deleteAction() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $id = $this->_request->getParam('objid'); $messages['message'] = ''; $messages['msgtype'] = ''; $actionflag = 3; if ($id) { $holidaygroupsmodel = new Default_Model_Holidaygroups(); $menumodel = new Default_Model_Menu(); $data = array('isactive' => 0); $where = array('id=?' => $id); $Id = $holidaygroupsmodel->SaveorUpdateGroupData($data, $where); if ($Id == 'update') { $menuidArr = $menumodel->getMenuObjID('/holidaygroups'); $menuID = $menuidArr[0]['id']; $result = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $id); $messages['message'] = 'Holiday group deleted successfully.'; $messages['msgtype'] = 'success'; } else { $messages['message'] = 'Holiday group cannot be deleted.'; $messages['msgtype'] = 'error'; } } else { $messages['message'] = 'Holiday group cannot be deleted.'; $messages['msgtype'] = 'error'; } $this->_helper->json($messages); }
public function saveholidaygroupAction() { $ajaxContext = $this->_helper->getHelper('AjaxContext'); $ajaxContext->addActionContext('saveholidaygroup', 'json')->initContext(); $this->_helper->layout->disableLayout(); $auth = Zend_Auth::getInstance(); $date = new Zend_Date(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; $loginuserRole = $auth->getStorage()->read()->emprole; $loginuserGroup = $auth->getStorage()->read()->group_id; } $result['result'] = ''; $result['id'] = ''; $result['groupname'] = ''; $result['description'] = ''; $holidaygroupsmodel = new Default_Model_Holidaygroups(); try { $holidaygroup = trim($this->_request->getParam('holidaygroup')); $description = $this->_request->getParam('description'); $isGroupExist = $holidaygroupsmodel->checkDuplicateGroupName($holidaygroup); if (!empty($isGroupExist)) { if ($isGroupExist[0]['count'] > 0) { $result['msg'] = 'Group name already exists.'; $result['id'] = ''; $result['groupname'] = ''; $result['address'] = ''; } else { $actionflag = ''; $tableid = ''; $data = array('groupname' => $holidaygroup, 'description' => $description != '' ? trim($description) : NULL, 'createdby' => $loginUserId, 'createddate' => $date->get('yyyy-MM-dd HH:mm:ss'), 'modifiedby' => $loginUserId, 'modifieddate' => gmdate("Y-m-d H:i:s")); $where = ''; $actionflag = 1; $Id = $holidaygroupsmodel->SaveorUpdateGroupData($data, $where); if ($Id) { $menuID = HOLIDAYGROUPS; $logresult = sapp_Global::logManager($menuID, $actionflag, $loginUserId, $Id); $result['msg'] = 'success'; $result['id'] = $Id; $result['groupname'] = $holidaygroup; $result['description'] = $description; } else { $result['msg'] = 'error'; $result['id'] = ''; $result['groupname'] = ''; $result['description'] = ''; } } } } catch (Exception $e) { $result['msg'] = $e->getMessage(); $result['id'] = ''; $result['groupname'] = ''; $result['description'] = ''; } $this->_helper->json($result); }