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 editpopupAction() { 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'); $bunitid = $this->getRequest()->getParam('unitId'); $callval = $this->getRequest()->getParam('call'); if ($callval == 'ajaxcall') { $this->_helper->layout->disableLayout(); } $holidaydatesform = new Default_Form_holidaydates(); $holidaydatesmodel = new Default_Model_Holidaydates(); $holidaygroupsmodel = new Default_Model_Holidaygroups(); $holidaydatesform->submit->setLabel('Update'); if ($id) { $data = $holidaydatesmodel->getParticularHolidayDateData($id); if (!empty($data)) { $data = $data[0]; $groupdataArr = $holidaygroupsmodel->getParticularGroupData($data['groupid']); if (sizeof($groupdataArr) > 0) { $holidaydatesform->groupid->addMultiOption($groupdataArr[0]['id'], utf8_encode($groupdataArr[0]['groupname'])); } $holidaydatesform->populate($data); $holidaydate = sapp_Global::change_date($data['holidaydate'], 'view'); $holidaydatesform->holidaydate->setValue($holidaydate); $holidaydatesform->setAttrib('action', DOMAIN . 'holidaydates/editpopup/id/' . $id . '/unitId/' . $bunitid); } else { $this->view->rowexist = "rows"; } } else { $this->view->rowexist = "norows"; } $this->view->form = $holidaydatesform; $this->view->groupid = $bunitid; $this->view->controllername = 'holidaydates'; if ($this->getRequest()->getPost()) { $result = $this->popupsave($holidaydatesform); $this->view->msgarray = $result; } }
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 viewAction() { if (defined('EMPTABCONFIGS')) { $empOrganizationTabs = explode(",", EMPTABCONFIGS); if (in_array('emp_holidays', $empOrganizationTabs)) { $conText = ""; $userID = ''; $msgarray = array(); $empGroupId = ''; $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $id = $this->getRequest()->getParam('userid'); $call = $this->_getParam('call'); if ($call == 'ajaxcall') { $this->_helper->layout->disableLayout(); $userID = $this->_getParam('unitId') != '' ? $this->_getParam('unitId') : $this->_getParam('userid'); $conText = $this->_getParam('context') != '' ? $this->_getParam('context') : $this->getRequest()->getParam('context'); } if ($id == '') { $id = $userID; } $Uid = $id ? $id : $userID; if ($Uid != "") { //TO dispaly EMployee Profile information..... $usersModel = new Default_Model_Users(); $employeeData = $usersModel->getUserDetailsByIDandFlag($Uid); } $employeesModel = new Default_Model_Employees(); $holidaydatesmodel = new Default_Model_Holidaydates(); $employeeModal = new Default_Model_Employee(); try { if ($id && is_numeric($id) && $id > 0 && $id != $loginUserId) { $isrowexist = $employeeModal->getsingleEmployeeData($id); if ($isrowexist == 'norows') { $this->view->rowexist = "norows"; } else { $this->view->rowexist = "rows"; } $empdata = $employeeModal->getActiveEmployeeData($id); if (!empty($empdata)) { if ($id) { $empholidaysform = new Default_Form_empholidays(); $holidaygroupModel = new Default_Model_Holidaygroups(); $holidaygroupArr = $holidaygroupModel->getAllGroupData(); if (sizeof($holidaygroupArr) > 0) { $empGroupId = $holidaygroupArr[0]['id']; foreach ($holidaygroupArr as $holidaygroupres) { $empholidaysform->holiday_group->addMultiOption($holidaygroupres['id'], $holidaygroupres['groupname']); } } else { $msgarray['empholidaysform'] = 'Holiday groups not configured yet'; } $data = $employeesModel->getHolidayGroupForEmployee($id); if ($data[0]['holiday_group'] != '') { $singleholidaygroupArr = $holidaygroupModel->getsingleGroupData($data[0]['holiday_group']); $empholidaysform->populate($data[0]); $empholidaysform->setDefault('holiday_group', $data[0]['holiday_group']); $empGroupId = $data[0]['holiday_group']; $this->view->data = $data; } $empholidaysform->setAttrib('action', BASE_URL . 'empholidays/edit/userid/' . $id); $this->view->form = $empholidaysform; } if ($this->getRequest()->getPost()) { $result = $this->save($empholidaysform, $id); $this->view->msgarray = $result; } $objname = $this->_getParam('objname'); $refresh = $this->_getParam('refresh'); $dashboardcall = $this->_getParam('dashboardcall', null); $data = array(); $searchQuery = ''; $searchArray = array(); $tablecontent = ''; if ($refresh == 'refresh') { if ($dashboardcall == 'Yes') { $perPage = DASHBOARD_PERPAGE; } else { $perPage = PERPAGE; } $sort = 'DESC'; $by = 'h.modifieddate'; $pageNo = 1; $searchData = ''; $searchQuery = ''; $searchArray = array(); } else { $sort = $this->_getParam('sort') != '' ? $this->_getParam('sort') : 'DESC'; $by = $this->_getParam('by') != '' ? $this->_getParam('by') : 'h.modifieddate'; if ($dashboardcall == 'Yes') { $perPage = $this->_getParam('per_page', DASHBOARD_PERPAGE); } else { $perPage = $this->_getParam('per_page', PERPAGE); } $pageNo = $this->_getParam('page', 1); $searchData = $this->_getParam('searchData'); $searchData = rtrim($searchData, ','); } $objName = 'empholidays'; $dataTmp = $holidaydatesmodel->getGrid($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $objName, $empGroupId, $Uid, $conText); array_push($data, $dataTmp); $this->view->dataArray = $data; $this->view->call = $call; $this->view->id = $id; $this->view->messages = $this->_helper->flashMessenger->getMessages(); if (!empty($employeeData)) { $this->view->employeedata = $employeeData[0]; } } $this->view->empdata = $empdata; } else { $this->view->rowexist = "norows"; } } catch (Exception $e) { $this->view->rowexist = "norows"; } } else { $this->_redirect('error'); } } else { $this->_redirect('error'); } }
public function getGrid($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $objName, $unitId = '', $userid = '', $conText = '') { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { $loginUserId = $auth->getStorage()->read()->id; } $searchQuery = ''; $searchArray = array(); $data = array(); $dataTmp = array(); if ($objName == 'holidaydates') { if ($searchData != '' && $searchData != 'undefined') { $searchValues = json_decode($searchData); foreach ($searchValues as $key => $val) { if ($key == "description") { $searchQuery .= " h." . $key . " like '%" . $val . "%' AND "; } else { if ($key == 'holidaydate') { $searchQuery .= " " . $key . " like '%" . sapp_Global::change_date($val, 'database') . "%' AND "; } else { $searchQuery .= " " . $key . " like '%" . $val . "%' AND "; } } $searchArray[$key] = $val; } $searchQuery = rtrim($searchQuery, " AND"); } if ($searchQuery == null) { $searchQuery = $searchData; } $tableFields = array('action' => 'Action', 'holidayname' => 'Holiday', 'holidaydate' => 'Date', 'description' => 'Description'); $tablecontent = $this->getHolidayDatesData($sort, $by, $pageNo, $perPage, $searchQuery, $unitId); if (isset($unitId) && $unitId != '') { $formgrid = 'true'; } else { $formgrid = ''; } $dataTmp = array('sort' => $sort, 'by' => $by, 'pageNo' => $pageNo, 'perPage' => $perPage, 'tablecontent' => $tablecontent, 'objectname' => $objName, 'extra' => array(), 'tableheader' => $tableFields, 'jsGridFnName' => 'getAjaxgridData', 'jsFillFnName' => '', 'searchArray' => $searchArray, 'add' => 'add', 'formgrid' => $formgrid, 'unitId' => $unitId, 'menuName' => 'Holidays', 'call' => $call, 'dashboardcall' => $dashboardcall, 'search_filters' => array('holidaydate' => array('type' => 'datepicker'))); } else { if ($objName == 'myholidaycalendar') { if ($unitId == '') { $employeesModel = new Default_Model_Employees(); $empholidaygroup = $employeesModel->getHolidayGroupForEmployee($loginUserId); if (isset($empholidaygroup[0]['holiday_group']) && $empholidaygroup[0]['holiday_group'] != '') { $unitId = $empholidaygroup[0]['holiday_group']; } } if ($searchData != '' && $searchData != 'undefined') { $searchValues = json_decode($searchData); foreach ($searchValues as $key => $val) { if ($key == "description") { $searchQuery .= " h." . $key . " like '%" . $val . "%' AND "; } else { if ($key == 'holidaydate') { $searchQuery .= " " . $key . " like '%" . sapp_Global::change_date($val, 'database') . "%' AND "; } else { $searchQuery .= " " . $key . " like '%" . $val . "%' AND "; } } $searchArray[$key] = $val; } $searchQuery = rtrim($searchQuery, " AND"); } $tableFields = array('action' => 'Action', 'holidayname' => 'Holiday', 'holidaydate' => 'Date', 'description' => 'Description'); $tablecontent = $this->getHolidayDatesData($sort, $by, $pageNo, $perPage, $searchQuery, $unitId); $dataTmp = array('sort' => $sort, 'by' => $by, 'pageNo' => $pageNo, 'perPage' => $perPage, 'tablecontent' => $tablecontent, 'objectname' => $objName, 'extra' => array(), 'tableheader' => $tableFields, 'jsGridFnName' => 'getAjaxgridData', 'jsFillFnName' => '', 'searchArray' => $searchArray, 'menuName' => 'My Holiday Calendar', 'add' => 'add', 'call' => $call, 'dashboardcall' => $dashboardcall, 'search_filters' => array('holidaydate' => array('type' => 'datepicker'))); } else { if ($objName == 'empholidays') { $groupname = ''; if ($searchData != '' && $searchData != 'undefined') { $searchValues = json_decode($searchData); foreach ($searchValues as $key => $val) { if ($key == 'holidaydate') { $searchQuery .= " " . $key . " like '%" . sapp_Global::change_date($val, 'database') . "%' AND "; } else { if ($key == "description") { $searchQuery .= " h." . $key . " like '%" . $val . "%' AND "; } else { $searchQuery .= " " . $key . " like '%" . $val . "%' AND "; } } $searchArray[$key] = $val; } $searchQuery = rtrim($searchQuery, " AND"); } $tableFields = array('action' => 'Action', 'groupname' => 'Holiday Group', 'holidayname' => 'Holiday', 'holidaydate' => 'Date', 'description' => 'Description'); $tablecontent = $this->getHolidayDatesData($sort, $by, $pageNo, $perPage, $searchQuery, $unitId); $holidaygroupModel = new Default_Model_Holidaygroups(); $groupnameArr = $holidaygroupModel->getParticularGroupData($unitId); if (!empty($groupnameArr)) { $groupname = $groupnameArr[0]['groupname'] . ' - Holidays'; } else { $groupname = 'Holidays'; } $dataTmp = array('userid' => $userid, 'sort' => $sort, 'by' => $by, 'pageNo' => $pageNo, 'perPage' => $perPage, 'tablecontent' => $tablecontent, 'objectname' => $objName, 'extra' => array(), 'tableheader' => $tableFields, 'jsGridFnName' => 'getEmployeeAjaxgridData', 'jsFillFnName' => '', 'searchArray' => $searchArray, 'add' => 'add', 'menuName' => $groupname, 'formgrid' => 'true', 'unitId' => $userid, 'dashboardcall' => $dashboardcall, 'call' => $call, 'context' => $conText, 'search_filters' => array('holidaydate' => array('type' => 'datepicker'))); } } } return $dataTmp; }
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); }