/** * 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; }
/** * this action is used to get states based on country id. */ public function eraseweekAction() { $storage = new Zend_Auth_Storage_Session(); $sessionData = $storage->read(); $myTsModel = new Timemanagement_Model_MyTimesheet(); $selYrMon = $this->_getParam('selYrMon'); $callval = $this->getRequest()->getParam('call'); $week = $this->_getParam('week'); $calWeek = $this->_getParam('calWeek'); $yrMon = explode('-', $selYrMon); $statusData = array('modified_by' => $sessionData->id, 'modified' => Zend_Registry::get('currentdate')); $TasksData = array('modified_by' => $sessionData->id, 'modified' => Zend_Registry::get('currentdate')); $notesData = array('modified_by' => $sessionData->id, 'modified' => Zend_Registry::get('currentdate')); $weekDaysStatus = $myTsModel->getWeekDaysDailyStatus($sessionData->id, $yrMon[0], $yrMon[1], $week); foreach ($weekDaysStatus[0] as $key => $value) { if ($value == 'saved') { $dayName = substr($key, 0, 3); $statusData[$dayName . '_project_status'] = 'no_entry'; $statusData[$dayName . '_status'] = 'no_entry'; $statusData[$dayName . '_status_date'] = Zend_Registry::get('currentdate'); $TasksData[$dayName . '_duration'] = '00:00'; $notesData[$dayName . '_note'] = ''; } } if ($callval == 'ajaxcall') { $this->_helper->layout->disableLayout(); } $myTsModel->updateTimesheet($sessionData->id, $yrMon[0], $yrMon[1], $week, $TasksData); $myTsModel->updateTimesheetStatus($sessionData->id, $yrMon[0], $yrMon[1], $week, $statusData); $myTsModel->updateTimesheetNotes($sessionData->id, $yrMon[0], $yrMon[1], $week, $notesData); $myTsModel->updateWeekStatus($sessionData->id, $yrMon[0], $yrMon[1], $week); $myTsModel->updateWeekDuration($sessionData->id, $yrMon[0], $yrMon[1], $week); $this->view->status = 'success'; $this->view->message = 'Timesheet erased successfully for week ' . $week; }