コード例 #1
0
ファイル: Bootstrap.php プロジェクト: lukkyrich/sentrifugo
 protected function _initAppAutoload()
 {
     $auth = Zend_Auth::getInstance();
     $storage = $auth->getStorage()->read();
     if (isset($storage)) {
         $usersModel = new Timemanagement_Model_Users();
         $tmRole = $usersModel->getUserTimemanagementRole($storage->id);
         Zend_Registry::set('tm_role', $tmRole);
     }
 }
コード例 #2
0
 /**
  * This action will display employee timesheet in the week format.
  */
 public function emptimesheetweeklyAction()
 {
     $storage = new Zend_Auth_Storage_Session();
     $data = $storage->read();
     $now = new DateTime();
     $selDay = "";
     $selYrMon = $this->_getParam('selYrMon');
     $user_id = $this->_getParam('user_id');
     $manager_id = $this->_getParam('manager_id');
     $week = $this->_getParam('hideweek');
     $emplistflag = $this->_getParam('emplistflag');
     $project_ids = "";
     if ($this->_getParam('day')) {
         $selDay = $this->_getParam('day');
     }
     if ($this->_getParam('project_ids')) {
         $project_ids = $this->_getParam('project_ids');
     }
     $usersModel = new Timemanagement_Model_Users();
     $empDoj = $usersModel->getEmployeeDoj($user_id);
     $dateEmpDoj = date('Y-m', strtotime($empDoj['date_of_joining']));
     $selYrMon = $selYrMon != '' ? $selYrMon : $now->format('Y-m');
     $yrMon = explode('-', $selYrMon);
     $year = $yrMon[0];
     $month = $yrMon[1];
     $lastday = date("t", mktime(0, 0, 0, $month, 1, $year));
     $firstCalWeek = strftime('%U', strtotime($year . '-' . $month . '-01'));
     $lastCalWeek = strftime('%U', strtotime($selYrMon . '-' . $lastday));
     $calenderWeek = array();
     $calenderWeeksArray = range($firstCalWeek, $lastCalWeek);
     $calWeek = $calenderWeeksArray[$week - 1];
     if ($calWeek == null || $calWeek == '') {
         $calWeek = strftime('%U', strtotime($selYrMon . '-01'));
     }
     $myTsModel = new Timemanagement_Model_MyTimesheet();
     $empTSModel = new Timemanagement_Model_Emptimesheets();
     $myTsWeekData = $empTSModel->getWeeklyTimesheetData($user_id, $yrMon[0], $yrMon[1], $week, $project_ids);
     $empHolidaysWeekendsData = $usersModel->getEmployeeHolidaysNWeekends($user_id, $yrMon[0], $yrMon[1], $calWeek);
     $startDate = date("Y-m-d", strtotime("{$yrMon[0]}-W{$calWeek}-7"));
     $endDate = date("Y-m-d", strtotime('next saturday', strtotime($startDate)));
     $empLeavesData = $usersModel->getEmpLeaves($user_id, $startDate, $endDate, 'all');
     $weekNotes = $myTsModel->getWeekNotes($user_id, $yrMon[0], $yrMon[1], $week);
     $weekDaysStatus = $myTsModel->getWeekDaysStatus($user_id, $yrMon[0], $yrMon[1], $week, $emplistflag, $project_ids);
     $empData = $empTSModel->getEmployeeTimsheetDetails($yrMon[0], $yrMon[1], $week, $user_id, $project_ids, $emplistflag);
     $this->view->empDoj = $empDoj['date_of_joining'];
     $this->view->selYrMon = $selYrMon;
     $this->view->user_id = $user_id;
     $this->view->manager_id = $manager_id;
     $this->view->hideweek = $week;
     $this->view->selWeek = $week;
     $this->view->type = "week";
     $this->view->myTsWeekData = $myTsWeekData;
     $this->view->weekNotesData = $weekNotes;
     $this->view->empHolidaysWeekends = $empHolidaysWeekendsData[0];
     $this->view->leavesData = $empLeavesData;
     $this->view->weekDaysStatus = $weekDaysStatus;
     $this->view->empData = $empData;
     $this->view->emplistflag = $emplistflag;
     if ($selDay != '') {
         $selDay = date("D", strtotime($selYrMon . '-' . $selDay));
     }
     $this->view->selDay = $selDay;
     $this->view->project_ids = $project_ids;
 }
コード例 #3
0
ファイル: Helper.php プロジェクト: rajbrt/sentrifugo
 public static function checkTmEnable()
 {
     $userModel = new Timemanagement_Model_Users();
     $checkTmEnable = $userModel->checkTmEnable();
     $auth = Zend_Auth::getInstance();
     $loginuserGroup = '';
     $result = 1;
     if ($auth->hasIdentity()) {
         $loginuserGroup = $auth->getStorage()->read()->group_id;
     }
     if (!$checkTmEnable || $loginuserGroup == USERS_GROUP) {
         $result = 0;
     }
     return $result;
 }
コード例 #4
0
 public function weekAction()
 {
     $usersModel = new Timemanagement_Model_Users();
     $storage = new Zend_Auth_Storage_Session();
     $now = new DateTime();
     $data = $storage->read();
     $selYrMon = $this->_getParam('selYrMon');
     $week = $this->_getParam('week') != '' ? $this->_getParam('week') : 1;
     $calWeek = $this->_getParam('calWeek');
     $timeFlag = $this->_getParam('flag');
     $selDay = $this->_getParam('day');
     if ($data->id == 1) {
         $this->_redirect('error');
     }
     $selYrMon = $selYrMon != '' ? $selYrMon : $now->format('Y-m');
     $yrMon = explode('-', $selYrMon);
     if ($timeFlag == 'time' && $selYrMon == $now->format('Y-m') && $calWeek == '') {
         $calWeek = strftime('%U', strtotime($selYrMon . '-' . $now->format('d')));
         $startCalWeek = strftime('%U', strtotime($selYrMon . '-01'));
         $week = $calWeek - $startCalWeek + 1;
     }
     $empDoj = $usersModel->getEmployeeDoj($data->id);
     $selYrMonArray = explode('-', $selYrMon);
     if ($selDay != '') {
         $calWeek = strftime('%U', strtotime($selYrMon . '-' . $selDay));
         $startCalWeek = strftime('%U', strtotime($selYrMon . '-01'));
         $week = $calWeek - $startCalWeek + 1;
     } else {
         if ($calWeek == '') {
             $calWeek = strftime('%U', strtotime($selYrMon . '-01'));
         }
     }
     $myTsModel = new Timemanagement_Model_MyTimesheet();
     if ($timeFlag == 'time') {
         $myTsWeekData = $myTsModel->getWeeklyTimesheetData($data->id, $selYrMonArray[0], $selYrMonArray[1], $week);
     } else {
         $myTsWeekData = $myTsModel->getWeeklyTimesheetData($data->id, $selYrMonArray[0], $selYrMonArray[1], $week, 'view');
     }
     $empHolidaysWeekendsData = $usersModel->getEmployeeHolidaysNWeekends($data->id, $yrMon[0], $yrMon[1], $calWeek);
     $startDate = date("Y-m-d", strtotime("{$yrMon[0]}-W{$calWeek}-7"));
     $endDate = date("Y-m-d", strtotime('next saturday', strtotime($startDate)));
     $empLeavesData = $usersModel->getEmpLeaves($data->id, $startDate, $endDate, 'all');
     $weekNotes = $myTsModel->getWeekNotes($data->id, $selYrMonArray[0], $selYrMonArray[1], $week);
     $weekDaysStatus = $myTsModel->getWeekDaysStatus($data->id, $selYrMonArray[0], $selYrMonArray[1], $week);
     $weekDaysProjStatus = $myTsModel->getWeekDaysProjStatus($data->id, $selYrMonArray[0], $selYrMonArray[1], $week);
     $noOfDaysMonth = date("t", mktime(0, 0, 0, $selYrMonArray[1], 1, $selYrMonArray[0]));
     $cronStartDay = "";
     $cronEndDay = "";
     $mon = $yrMon[1] + 1;
     $yr = $mon == 12 ? $selYrMonArray[0] + 1 : $selYrMonArray[0];
     if ($selDay != '') {
         $this->view->selDay = date("D", strtotime($selYrMon . '-' . $selDay));
     }
     $this->view->empDoj = $empDoj['date_of_joining'];
     $this->view->selYrMon = $selYrMon;
     $this->view->selWeek = $week;
     $this->view->myTsWeekData = $myTsWeekData;
     $this->view->weekNotesData = $weekNotes;
     $this->view->empHolidaysWeekends = $empHolidaysWeekendsData[0];
     $this->view->leavesData = $empLeavesData;
     $this->view->weekDaysStatus = $weekDaysStatus;
     $this->view->weekDaysProjStatus = $weekDaysProjStatus;
     $this->view->cronStartDay = $cronStartDay;
     $this->view->cronEndDay = $cronEndDay;
     //START code to show pending weeks for submit in current month
     $projmodel = new Timemanagement_Model_Projects();
     $prevweeks = $projmodel->getprevmonthweeks(date('Y-m'), date('d'));
     /*Leave request code starts*/
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $loginUserId = $auth->getStorage()->read()->id;
     }
     $leaverequestform = new Default_Form_leaverequest();
     $leaverequestform->setAttrib('action', BASE_URL . 'leaverequest');
     $leaverequestmodel = new Default_Model_Leaverequest();
     $employeeleavetypemodel = new Default_Model_Employeeleavetypes();
     $leavemanagementmodel = new Default_Model_Leavemanagement();
     $usersmodel = new Default_Model_Users();
     $employeesmodel = new Default_Model_Employees();
     $weekdaysmodel = new Default_Model_Weekdays();
     $holidaydatesmodel = new Default_Model_Holidaydates();
     $msgarray = array();
     $dateofjoiningArr = array();
     $holidayDateslistArr = array();
     $rMngr = 'No';
     $availableleaves = '';
     $rep_mang_id = '';
     $employeeemail = '';
     $reportingManageremail = '';
     $week_startday = '';
     $week_endday = '';
     $ishalf_day = '';
     $userfullname = '';
     $reportingmanagerName = '';
     $businessunitid = '';
     $hremailgroup = '';
     /* Start
     		   Queries to fetch user details,reporting manager details and weekend details from users table and employees table
     		*/
     if ($loginUserId != '' && $loginUserId != NULL) {
         $loggedinEmpId = $usersmodel->getUserDetailsByID($loginUserId);
         $loggedInEmployeeDetails = $employeesmodel->getLoggedInEmployeeDetails($loginUserId);
         if (!empty($loggedInEmployeeDetails)) {
             if ($loggedInEmployeeDetails[0]['date_of_joining'] != '') {
                 $date = new DateTime($loggedInEmployeeDetails[0]['date_of_joining']);
                 $datofjoiningtimestamp = $date->getTimestamp();
                 $dateofjoining = explode("-", $loggedInEmployeeDetails[0]['date_of_joining']);
                 $year = $dateofjoining[0];
                 $month = $dateofjoining[1];
                 $day = $dateofjoining[2];
                 $dateofjoiningArr = array('year' => $year, 'month' => $month, 'day' => $day, 'datetimestamp' => $datofjoiningtimestamp);
             }
             $reportingmanagerId = $loggedInEmployeeDetails[0]['reporting_manager'];
             $employeeDepartmentId = $loggedInEmployeeDetails[0]['department_id'];
             $employeeEmploymentStatusId = $loggedInEmployeeDetails[0]['emp_status_id'];
             $employeeHolidayGroupId = $loggedInEmployeeDetails[0]['holiday_group'];
             $reportingManagerDetails = $usersmodel->getUserDetailsByID($reportingmanagerId);
             $weekendDatailsArr = $leavemanagementmodel->getWeekendDetails($employeeDepartmentId);
             $employeeemail = $loggedinEmpId[0]['emailaddress'];
             $userfullname = $loggedinEmpId[0]['userfullname'];
             $businessunitid = $loggedInEmployeeDetails[0]['businessunit_id'];
             if (!empty($reportingManagerDetails)) {
                 $leaverequestform->rep_mang_id->setValue($reportingManagerDetails[0]['userfullname']);
                 $reportingManageremail = $reportingManagerDetails[0]['emailaddress'];
                 $reportingmanagerName = $reportingManagerDetails[0]['userfullname'];
                 $rep_mang_id = $reportingManagerDetails[0]['id'];
                 $rMngr = 'Yes';
             } else {
                 $msgarray['rep_mang_id'] = 'Reporting manager is not assigned yet. Please contact your HR.';
             }
             if (!empty($weekendDatailsArr)) {
                 $week_startday = $weekendDatailsArr[0]['weekendstartday'];
                 $week_endday = $weekendDatailsArr[0]['weekendday'];
                 $ishalf_day = $weekendDatailsArr[0]['is_halfday'];
                 $isskip_holidays = $weekendDatailsArr[0]['is_skipholidays'];
             } else {
                 $msgarray['from_date'] = 'Leave management options are not configured yet.';
                 $msgarray['to_date'] = 'Leave management options are not configured yet.';
             }
             if ($employeeHolidayGroupId != '' && $employeeHolidayGroupId != NULL) {
                 $holidayDateslistArr = $holidaydatesmodel->getHolidayDatesListForGroup($employeeHolidayGroupId);
             }
             if (defined('LV_HR_' . $businessunitid)) {
                 $hremailgroup = 'hremailgroupexists';
             } else {
                 $hremailgroup = '';
             }
             /* Search Filters */
             $isReportingManagerFlag = 'false';
             $searchRepFlag = 'false';
             $searchMeFlag = 'true';
             $filter = $this->_request->getParam('filter');
             if (!empty($filter)) {
                 if (in_array(2, $filter)) {
                     $searchRepFlag = 'true';
                 }
                 if (in_array(1, $filter)) {
                     $searchMeFlag = 'true';
                 } else {
                     $searchMeFlag = 'false';
                 }
             }
             if ($searchMeFlag == 'true') {
                 $leaverequestdetails = $leaverequestmodel->getUserApprovedOrPendingLeavesData($loginUserId);
             }
             /* Start -For Checking if logged in user is reporting manager */
             $isReportingManager = $employeesmodel->CheckIfReportingManager($loginUserId);
             if (!empty($isReportingManager) && $isReportingManager[0]['count'] > 0) {
                 if ($searchRepFlag == 'true') {
                     $managerrequestdetails = $leaverequestmodel->getManagerApprovedOrPendingLeavesData($loginUserId);
                 }
                 $isReportingManagerFlag = 'true';
             }
             /* End */
             $this->view->userfullname = $userfullname;
             $this->view->loggedinEmpId = $loggedinEmpId;
             $this->view->weekendDatailsArr = $weekendDatailsArr;
             $this->view->reportingManagerDetails = $reportingManagerDetails;
             $this->view->rMngr = $rMngr;
             $this->view->hremailgroup = $hremailgroup;
             $this->view->dateofjoiningArr = $dateofjoiningArr;
             $this->view->leaverequestdetails = !empty($leaverequestdetails) ? $leaverequestdetails : array();
             $this->view->holidayDateslistArr = $holidayDateslistArr;
             $this->view->managerrequestdetails = !empty($managerrequestdetails) ? $managerrequestdetails : array();
             $this->view->isReportingManagerFlag = $isReportingManagerFlag;
             $this->view->searchRepFlag = $searchRepFlag;
             $this->view->searchMeFlag = $searchMeFlag;
         } else {
             $msgarray['rep_mang_id'] = 'Reporting manager is not assigned yet. Please contact your HR.';
             $msgarray['from_date'] = 'Leave management options are not configured yet.';
             $msgarray['to_date'] = 'Leave management options are not configured yet.';
         }
     }
     /* End */
     /* 
      Start
      Query to fetch and build multioption for Leavetype dropdown
     */
     $leavetype = $employeeleavetypemodel->getactiveleavetype();
     if (!empty($leavetype)) {
         if (sizeof($leavetype) > 0) {
             foreach ($leavetype as $leavetyperes) {
                 $leaverequestform->leavetypeid->addMultiOption($leavetyperes['id'] . '!@#' . $leavetyperes['numberofdays'] . '!@#' . utf8_encode($leavetyperes['leavetype']), utf8_encode($leavetyperes['leavetype']));
             }
         }
     } else {
         $msgarray['leavetypeid'] = ' Leave types are not configured yet.';
     }
     $this->view->leavetype = $leavetype;
     /* End */
     /*
     START
     Query to get the number of available leaves for the employee 
     */
     $getavailbaleleaves = $leaverequestmodel->getAvailableLeaves($loginUserId);
     if (!empty($getavailbaleleaves)) {
         $leaverequestform->no_of_days->setValue($getavailbaleleaves[0]['remainingleaves']);
         $availableleaves = $getavailbaleleaves[0]['remainingleaves'];
     } else {
         $msgarray['no_of_days'] = 'You have not been allotted leaves for this financial year. Please contact your HR.';
     }
     $this->view->getavailbaleleaves = $getavailbaleleaves;
     /* END */
     $this->view->form = $leaverequestform;
     $this->view->msgarray = $msgarray;
     $this->view->loginUserId = $loginUserId;
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
     /*leave request code ends*/
     if ($timeFlag != '') {
         $this->_helper->viewRenderer('entertime');
     }
 }