public function getStartAndEndDates($employeeId) { $timesheetService = new TimesheetService(); $timesheets = $timesheetService->getTimesheetByEmployeeId($employeeId); $dateOptions = array(); $dateOptionsToDrpDwn = array(); $userRoleManager = sfContext::getInstance()->getUserRoleManager(); $user = $userRoleManager->getUser(); $excludeRoles = array(); $includeRoles = $employeeId == $user->getEmpNumber() ? array('ESS') : array(); $entities = array('Employee' => $employeeId); $i = 0; if ($timesheets != null) { $dataGroupPermissions = $userRoleManager->getDataGroupPermissions(array('time_employee_timesheets'), array(), array(), $employeeId == $user->getEmpNumber(), $entities); foreach ($timesheets as $timesheet) { $allowedActions = $userRoleManager->getAllowedActions(WorkflowStateMachine::FLOW_TIME_TIMESHEET, $timesheet->getState(), $excludeRoles, $includeRoles, $entities); if (isset($allowedActions[WorkflowStateMachine::TIMESHEET_ACTION_VIEW]) || $dataGroupPermissions->canRead()) { $dateOptions[$i] = $timesheet->getStartDate() . " " . __("to") . " " . $timesheet->getEndDate(); $dateOptionsToDrpDwn[$i] = set_datepicker_date_format($timesheet->getStartDate()) . " " . __("to") . " " . set_datepicker_date_format($timesheet->getEndDate()); $i++; } } } $this->dateOptions = array_reverse($dateOptions); return array_reverse($dateOptionsToDrpDwn); }
public function getStartAndEndDates($employeeId) { $userEmployeeNumber = null; $timesheetService = new TimesheetService(); $timesheets = $timesheetService->getTimesheetByEmployeeId($employeeId); $dateOptions = array(); $dateOptionsToDrpDwn = array(); $userObj = sfContext::getInstance()->getUser()->getAttribute('user'); $userId = $userObj->getUserId(); $userEmployeeNumber = $userObj->getEmployeeNumber(); if ($userEmployeeNumber == $employeeId) { $user = new User(); $decoratedUser = new EssUserRoleDecorator($user); } else { $userRoleFactory = new UserRoleFactory(); $decoratedUser = $userRoleFactory->decorateUserRole($userId, $employeeId, $userEmployeeNumber); } $i = 0; if ($timesheets != null) { foreach ($timesheets as $timesheet) { $allowedActions = $decoratedUser->getAllowedActions(WorkflowStateMachine::FLOW_TIME_TIMESHEET, $timesheet->getState()); if (in_array(WorkflowStateMachine::TIMESHEET_ACTION_VIEW, $allowedActions)) { $dateOptions[$i] = $timesheet->getStartDate() . " " . __("to") . " " . $timesheet->getEndDate(); $dateOptionsToDrpDwn[$i] = set_datepicker_date_format($timesheet->getStartDate()) . " " . __("to") . " " . set_datepicker_date_format($timesheet->getEndDate()); $i++; } } } $this->dateOptions = array_reverse($dateOptions); return array_reverse($dateOptionsToDrpDwn); }
public function getConvertTime() { $timesheetService = new TimesheetService(); $timeInSecs = $this->getDuration(); if ($timeInSecs == null) { return null; } else { return $timesheetService->convertDurationToHours($this->getDuration()); } }
public function executeDeleteRows(sfWebRequest $request) { $employeeId = $request->getParameter("employeeId"); $timesheetId = $request->getParameter("timesheetId"); $projectId = $request->getParameter('projectId'); $activityId = $request->getParameter('activityId'); $timesheetService = new TimesheetService(); $this->state = $timesheetService->deleteTimesheetItems($employeeId, $timesheetId, $projectId, $activityId); }
public function executeDeleteRows(sfWebRequest $request) { $form = new DefaultListForm(); $employeeId = $request->getParameter("employeeId"); $timesheetId = $request->getParameter("timesheetId"); $projectId = $request->getParameter('projectId'); $activityId = $request->getParameter('activityId'); $timesheetService = new TimesheetService(); if ($form->getCSRFToken() == $request->getParameter('t')) { $this->state = $timesheetService->deleteTimesheetItems($employeeId, $timesheetId, $projectId, $activityId); } }
public function getTimesheetTimeFormat() { if (is_null(self::$timesheetTimeFormat)) { self::$timesheetTimeFormat = $this->getTimesheetDao()->getTimesheetTimeFormat(); } return self::$timesheetTimeFormat; }
public function getCustomerProjectListAsJson() { $timesheetService = new TimesheetService(); $timesheetService->setTimesheetDao(new TimesheetDao()); $jsonArray = array(); $projectList = $timesheetService->getProjectNameList(); foreach ($projectList as $project) { if ($this->projectId != $project['projectId']) { $jsonArray[] = array('name' => $project['customerName'] . " - ##" . $project['projectName'], 'id' => $project['projectId']); } } $jsonString = json_encode($jsonArray); return $jsonString; }