コード例 #1
0
 public function leavesAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('emp_leaves', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
                 $loginUserRole = $auth->getStorage()->read()->emprole;
                 $loginuserGroup = $auth->getStorage()->read()->group_id;
             }
             $id = $loginUserId;
             $call = $this->_getParam('call');
             if ($call == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
                 $userID = $this->_getParam('unitId') != '' ? $this->_getParam('unitId') : $this->_getParam('userid');
             }
             $Uid = $id ? $id : $userID;
             $employeeleavesModel = new Default_Model_Employeeleaves();
             $leavemanagementModel = new Default_Model_Leavemanagement();
             $employeeModal = new Default_Model_Employee();
             try {
                 $empdata = $employeeModal->getsingleEmployeeData($Uid);
                 if ($empdata == 'norows') {
                     $this->view->rowexist = "norows";
                     $this->view->empdata = "";
                 } else {
                     $this->view->rowexist = "rows";
                     if (!empty($empdata)) {
                         if ($Uid) {
                             $empleavesform = new Default_Form_empleaves();
                             $employeeleavesModal = new Default_Model_Employeeleaves();
                             $currentdata = '';
                             $leavetransferArr = $leavemanagementModel->getWeekendDetails($empdata[0]['department_id']);
                             $prevyeardata = $employeeleavesModal->getPreviousYearEmployeeleaveData($Uid);
                             $currentyeardata = $employeeleavesModal->getsingleEmployeeleaveData($Uid);
                             if (empty($currentyeardata)) {
                                 $currentdata = "empty";
                                 $currentyearleavecount = '';
                             } else {
                                 $currentdata = "notempty";
                                 $currentyearleavecount = $currentyeardata[0]['emp_leave_limit'];
                             }
                             $this->view->currentdata = $currentdata;
                             $leavetransfercount = '';
                             $previousyear = '';
                             $isleavetrasnferset = '';
                             $data = $employeeleavesModal->getsingleEmployeeleaveData($id);
                             $used_leaves = 0;
                             $date = date('Y');
                             if (!empty($data)) {
                                 $empleavesform->populate($data[0]);
                                 $used_leaves = $data[0]['used_leaves'];
                             }
                             $empleavesform->alloted_year->setValue($date);
                             if (!empty($leavetransferArr) && $leavetransferArr[0]['is_leavetransfer'] == 1 && !empty($prevyeardata) && is_numeric($prevyeardata[0]['remainingleaves']) && (int) $prevyeardata[0]['remainingleaves'] > 0 && $prevyeardata[0]['alloted_year'] != '' && empty($currentyeardata)) {
                                 $leavetransfercount = $prevyeardata[0]['remainingleaves'];
                                 $previousyear = $prevyeardata[0]['alloted_year'];
                                 $isleavetrasnferset = 1;
                                 $empleavesform->submitbutton->setAttrib('onClick', 'return showleavealert(' . $leavetransfercount . ',' . $previousyear . ')');
                                 $empleavesform->setAttrib('action', DOMAIN . 'mydetails/leaves/');
                             } else {
                                 $empleavesform->setAttrib('action', DOMAIN . 'mydetails/leaves/');
                             }
                             $this->view->form = $empleavesform;
                             $this->view->data = $data;
                             $this->view->id = $Uid;
                             $this->view->leavetransfercount = $leavetransfercount;
                         }
                         //Post values....
                         if ($this->getRequest()->getPost()) {
                             $result = $this->empaddorremoveleaves($empleavesform, $Uid, $used_leaves, $leavetransfercount, $isleavetrasnferset, $currentyearleavecount);
                             $this->view->msgarray = $result;
                         }
                         $objname = $this->_getParam('objname');
                         $refresh = $this->_getParam('refresh');
                         $data = array();
                         $searchQuery = '';
                         $searchArray = array();
                         $tablecontent = '';
                         if ($refresh == 'refresh') {
                             $sort = 'DESC';
                             $by = 'e.modifieddate';
                             $perPage = 10;
                             $pageNo = 1;
                             $searchData = '';
                         } else {
                             $sort = $this->_getParam('sort') != '' ? $this->_getParam('sort') : 'DESC';
                             $by = $this->_getParam('by') != '' ? $this->_getParam('by') : 'e.modifieddate';
                             $perPage = $this->_getParam('per_page', 10);
                             $pageNo = $this->_getParam('page', 1);
                             $searchData = $this->_getParam('searchData');
                             $searchData = rtrim($searchData, ',');
                             /** search from grid - START **/
                             $searchData = $this->_getParam('searchData');
                             if ($searchData != '' && $searchData != 'undefined') {
                                 $searchValues = json_decode($searchData);
                                 foreach ($searchValues as $key => $val) {
                                     $searchQuery .= " " . $key . " like '%" . $val . "%' AND ";
                                     $searchArray[$key] = $val;
                                 }
                                 $searchQuery = rtrim($searchQuery, " AND");
                             }
                             /** search from grid - END **/
                         }
                         $objName = 'empleaves';
                         $tableFields = array('action' => 'Action', 'emp_leave_limit' => 'Alloted leave limit', 'used_leaves' => 'Used leaves', 'remainingleaves' => 'Leave balance', 'alloted_year' => 'Alloted year');
                         $tablecontent = $employeeleavesModel->getEmpLeavesData($sort, $by, $pageNo, $perPage, $searchQuery, $Uid);
                         $dataTmp = array('userid' => $Uid, 'sort' => $sort, 'by' => $by, 'pageNo' => $pageNo, 'perPage' => $perPage, 'tablecontent' => $tablecontent, 'objectname' => $objName, 'extra' => array(), 'tableheader' => $tableFields, 'jsGridFnName' => 'getEmployeeAjaxgridData', 'jsFillFnName' => '', 'searchArray' => $searchArray, 'add' => 'add', 'menuName' => 'Employee Leaves', 'formgrid' => 'true', 'unitId' => $Uid, 'call' => $call, 'context' => 'mydetails');
                         array_push($data, $dataTmp);
                         $permission = sapp_Global::_checkprivileges(EMPLOYEE, $loginuserGroup, $loginUserRole, 'edit');
                         $this->view->dataArray = $data;
                         $this->view->call = $call;
                         $this->view->id = $Uid;
                         $this->view->messages = $this->_helper->flashMessenger->getMessages();
                         $this->view->employeedata = $empdata[0];
                         $this->view->usergroup = $loginuserGroup;
                         $this->view->permission = $permission;
                     }
                     $this->view->empdata = $empdata;
                 }
             } catch (Exception $e) {
                 $this->view->rowexist = "norows";
             }
             $this->view->usergroup = $loginuserGroup;
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
コード例 #2
0
 public function viewAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('emp_leaves', $empOrganizationTabs)) {
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
             }
             $id = $this->getRequest()->getParam('userid');
             $conText = "";
             $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');
             }
             $usersModel = new Default_Model_Users();
             if ($id == '') {
                 $id = $userID;
             }
             $Uid = $id ? $id : $userID;
             if ($Uid != "") {
                 $employeeData = $usersModel->getUserDetailsByIDandFlag($Uid);
             }
             $employeeleavesModel = new Default_Model_Employeeleaves();
             $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)) {
                         $usersModel = new Default_Model_Users();
                         if ($id) {
                             $empleavesform = new Default_Form_empleaves();
                             $employeeleavesModal = new Default_Model_Employeeleaves();
                             $data = $employeeleavesModal->getsingleEmployeeleaveData($id);
                             $used_leaves = 0;
                             $date = date('Y');
                             if (!empty($data)) {
                                 $empleavesform->populate($data[0]);
                                 $used_leaves = $data[0]['used_leaves'];
                             }
                             $empleavesform->alloted_year->setValue($date);
                             $empleavesform->setAttrib('action', BASE_URL . 'empleaves/edit/userid/' . $id);
                             $this->view->form = $empleavesform;
                             $this->view->data = $data;
                             $this->view->id = $id;
                         }
                         $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 = 'e.modifieddate';
                             $pageNo = 1;
                             $searchData = '';
                             $searchQuery = '';
                             $searchArray = array();
                         } else {
                             $sort = $this->_getParam('sort') != '' ? $this->_getParam('sort') : 'DESC';
                             $by = $this->_getParam('by') != '' ? $this->_getParam('by') : 'e.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, ',');
                         }
                         $dataTmp = $employeeleavesModel->getGrid($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $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');
     }
 }
コード例 #3
0
 public function viewAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
         $loginuserGroup = $auth->getStorage()->read()->group_id;
         $loginuserbusinessunit_id = $auth->getStorage()->read()->businessunit_id;
     }
     $objName = 'addemployeeleaves';
     $id = $this->getRequest()->getParam('id');
     $msgarray = array();
     $callval = $this->getRequest()->getParam('call');
     if ($callval == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     try {
         if ($id && is_numeric($id) && $id > 0) {
             $addemployeeleavesModel = new Default_Model_Addemployeeleaves();
             $addEmpLeavesForm = new Default_Form_addemployeeleaves();
             $employeeleavesModel = new Default_Model_Employeeleaves();
             $empModel = new Default_Model_Employee();
             $currentYearData = $employeeleavesModel->getsingleEmployeeleaveData($id);
             $permission = sapp_Global::_checkprivileges(176, $loginuserGroup, $loginuserRole, 'edit');
             $this->view->editpermission = $permission;
             $empDetails = $empModel->getEmp_from_summary($id);
             if (!empty($empDetails)) {
                 $addEmpLeavesForm->businessunit_id->setValue($empDetails['businessunit_id']);
                 $addEmpLeavesForm->department_id->setValue($empDetails['department_id']);
                 $addEmpLeavesForm->user_id->setValue($empDetails['user_id']);
                 $addEmpLeavesForm->leave_limit->setAttrib("disabled", "disabled");
                 if (!empty($currentYearData)) {
                     $addEmpLeavesForm->leave_limit->setValue($currentYearData[0]['emp_leave_limit']);
                 }
                 $addEmpLeavesForm->alloted_year->setValue(date('Y'));
                 $this->view->form = $addEmpLeavesForm;
                 $this->view->empdetails = $empDetails;
                 $this->view->msgarray = $msgarray;
                 $this->view->ermsg = '';
                 $this->view->controllername = $objName;
                 $this->view->id = $id;
             } else {
                 $this->view->ermsg = "norows";
             }
         } else {
             $this->view->ermsg = "norows";
         }
     } catch (Exception $e) {
         $this->view->ermsg = "norows";
     }
 }