public function indexAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $call = $this->_getParam('call');
     if ($call == 'ajaxcall') {
         $this->_helper->layout->disableLayout();
     }
     $employeesModel = new Default_Model_Employees();
     $empholidaygroup = $employeesModel->getHolidayGroupForEmployee($loginUserId);
     if (isset($empholidaygroup[0]['holiday_group']) && $empholidaygroup[0]['holiday_group'] != '') {
         $view = Zend_Layout::getMvcInstance()->getView();
         $objname = $this->_getParam('objname');
         $refresh = $this->_getParam('refresh');
         $dashboardcall = $this->_getParam('dashboardcall');
         $data = array();
         $searchQuery = '';
         $searchArray = array();
         $tablecontent = '';
         if ($refresh == 'refresh') {
             if ($dashboardcall == 'Yes') {
                 $perPage = DASHBOARD_PERPAGE;
             } else {
                 $perPage = PERPAGE;
             }
             $sort = 'DESC';
             $by = 'h.holidaydate';
             $perPage = 10;
             $pageNo = 1;
             $searchData = '';
         } else {
             $sort = $this->_getParam('sort') != '' ? $this->_getParam('sort') : 'DESC';
             $by = $this->_getParam('by') != '' ? $this->_getParam('by') : 'h.holidaydate';
             if ($dashboardcall == 'Yes') {
                 $perPage = $this->_getParam('per_page', DASHBOARD_PERPAGE);
             } else {
                 $perPage = $this->_getParam('per_page', PERPAGE);
             }
             $pageNo = $this->_getParam('page', 1);
             /** search from grid - START * */
             $searchData = $this->_getParam('searchData');
             $searchData = rtrim($searchData, ',');
             /** search from grid - END * */
         }
         $holidaydatesmodel = new Default_Model_Holidaydates();
         $objName = 'myholidaycalendar';
         $groupid = $empholidaygroup[0]['holiday_group'];
         $dataTmp = $holidaydatesmodel->getGrid($sort, $by, $perPage, $pageNo, $searchData, $call, $dashboardcall, $objName, $groupid);
         array_push($data, $dataTmp);
         $this->view->dataArray = $data;
         $this->view->call = $call;
     } else {
         $this->view->errormessage = "Not assigned to any group";
     }
     $this->view->controllergrid = 'myholidaycalendar';
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
 }
 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 holidaysAction()
 {
     if (defined('EMPTABCONFIGS')) {
         $empOrganizationTabs = explode(",", EMPTABCONFIGS);
         if (in_array('emp_holidays', $empOrganizationTabs)) {
             $tabName = "holidays";
             $objName = 'empholidays';
             $employeeData = array();
             $empdata = array();
             $auth = Zend_Auth::getInstance();
             if ($auth->hasIdentity()) {
                 $loginUserId = $auth->getStorage()->read()->id;
             }
             $id = $loginUserId;
             $call = $this->_getParam('call');
             if ($call == 'ajaxcall') {
                 $this->_helper->layout->disableLayout();
                 $userID = $this->_getParam('unitId') != '' ? $this->_getParam('unitId') : $this->_getParam('userid');
             }
             if ($id == '') {
                 $id = $userID;
             }
             $Uid = $id ? $id : $userID;
             $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)) {
                         $holidaydatesmodel = new Default_Model_Holidaydates();
                         $usersModel = new Default_Model_Users();
                         $call = $this->_getParam('call');
                         $objname = $this->_getParam('objname');
                         $refresh = $this->_getParam('refresh');
                         $data = array();
                         $searchQuery = '';
                         $searchArray = array();
                         $tablecontent = '';
                         if ($refresh == 'refresh') {
                             $sort = 'DESC';
                             $by = 'h.modifieddate';
                             $perPage = 10;
                             $pageNo = 1;
                             $searchData = '';
                         } else {
                             $sort = $this->_getParam('sort') != '' ? $this->_getParam('sort') : 'DESC';
                             $by = $this->_getParam('by') != '' ? $this->_getParam('by') : 'h.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) {
                                     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");
                             }
                             /** search from grid - END **/
                         }
                         $employeesModel = new Default_Model_Employees();
                         $empholidaydata = $employeesModel->getHolidayGroupForEmployee($id);
                         if (isset($empholidaydata[0]) && $empholidaydata[0]['holiday_group'] != '') {
                             $empGroupId = $empholidaydata[0]['holiday_group'];
                             $tableFields = array('action' => 'Action', 'holidayname' => 'Holiday', 'holidaydate' => 'Date', 'description' => 'Description');
                             $tablecontent = $holidaydatesmodel->getHolidayDatesData($sort, $by, $pageNo, $perPage, $searchQuery, $empGroupId);
                             $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 Holidays', 'formgrid' => 'true', 'unitId' => $Uid, 'call' => $call, 'context' => 'mydetails', 'search_filters' => array('holidaydate' => array('type' => 'datepicker')));
                             array_push($data, $dataTmp);
                             $this->view->dataArray = $data;
                             $this->view->call = $call;
                         }
                         if ($Uid) {
                             if (!empty($empdata)) {
                                 $this->view->empdata = $empdata[0];
                             } else {
                                 $this->view->empdata = $empdata;
                             }
                         }
                         $this->view->id = $id;
                         $this->view->messages = $this->_helper->flashMessenger->getMessages();
                     }
                     $this->view->empdata = $empdata;
                 }
             } catch (Exception $e) {
                 $this->view->rowexist = "norows";
             }
         } else {
             $this->_redirect('error');
         }
     } else {
         $this->_redirect('error');
     }
 }
Beispiel #4
0
 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;
 }