public function resolveTimesheet($submissionPeriodId = null) { if ($this->getTimesheetId() == null) { $timesheetObj = new Timesheet(); $timesheetSubmissionPeriodObj = new TimesheetSubmissionPeriod(); if ($submissionPeriodId != null) { $timesheetSubmissionPeriodObj->setTimesheetPeriodId($submissionPeriodId); } $timesheetSubmissionPeriods = $timesheetSubmissionPeriodObj->fetchTimesheetSubmissionPeriods(); $startTime = $this->getStartTime(); if (!isset($startTime)) { $startTime = $this->getReportedDate(); } $currTime = strtotime($startTime); $day = date('N', $currTime); $diff = $timesheetSubmissionPeriods[0]->getStartDay() - $day; if ($diff > 0) { $diff = $diff - 7; } $sign = $diff < 0 ? "" : "+"; $timesheetObj->setStartDate(date('Y-m-d', strtotime("{$sign}{$diff} day", $currTime))); $diff = $timesheetSubmissionPeriods[0]->getEndDay() - $day; if (0 > $diff) { $diff = $diff + 7; } $sign = $diff < 0 ? "" : "+"; $timesheetObj->setEndDate(date('Y-m-d', strtotime("{$sign}{$diff} day", $currTime)) . " 23:59:59"); $timesheetObj->setTimesheetPeriodId($timesheetSubmissionPeriods[0]->getTimesheetPeriodId()); $timesheetObj->setEmployeeId($this->getEmployeeId()); $timesheets = $timesheetObj->fetchTimesheets(); if (!$timesheets || !$timesheets[0]) { $timesheetObj->setStatus(Timesheet::TIMESHEET_STATUS_NOT_SUBMITTED); $timesheetObj->addTimesheet(); $timesheetObj->setTimesheetId(null); $timesheets = $timesheetObj->fetchTimesheets(); } $this->setTimesheetId($timesheets[0]->getTimesheetId()); } }
/** * Build the object with fetched records * * @access private * @return Timesheet[] array of timesheets */ private function _buildObjArr($result) { $objArr = null; while ($row = mysql_fetch_assoc($result)) { $tmpTimeArr = new Timesheet(); $tmpTimeArr->setTimesheetId($row[self::TIMESHEET_DB_FIELD_TIMESHEET_ID]); $tmpTimeArr->setEmployeeId($row[self::TIMESHEET_DB_FIELD_EMPLOYEE_ID]); $tmpTimeArr->setTimesheetPeriodId($row[self::TIMESHEET_DB_FIELD_TIMESHEET_PERIOD_ID]); $tmpTimeArr->setStartDate(date('Y-m-d', strtotime($row[self::TIMESHEET_DB_FIELD_START_DATE]))); $tmpTimeArr->setEndDate(date('Y-m-d', strtotime($row[self::TIMESHEET_DB_FIELD_END_DATE]))); $tmpTimeArr->setStatus($row[self::TIMESHEET_DB_FIELD_STATUS]); $tmpTimeArr->setComment($row[self::TIMESHEET_DB_FIELD_COMMENT]); $objArr[] = $tmpTimeArr; } return $objArr; }
public function viewDefineEmployeeTimeReport() { $path = "/templates/time/defineEmployeeTimeReport.php"; $roles = array(authorize::AUTHORIZE_ROLE_ADMIN, authorize::AUTHORIZE_ROLE_SUPERVISOR); $role = $this->authorizeObj->firstRole($roles); if (!$role) { $this->redirect('UNAUTHORIZED_FAILURE', '?timecode=Time&action=View_Timesheet'); } $employees = null; $pendingTimesheets = null; $pending = false; if ($this->authorizeObj->isSupervisor()) { $empRepObj = new EmpRepTo(); $employees = $empRepObj->getEmpSubDetails($_SESSION['empID']); $timesheetObj = new Timesheet(); $timesheetObj->setStatus(Timesheet::TIMESHEET_STATUS_SUBMITTED); for ($i = 0; $i < count($employees); $i++) { $timesheetObj->setEmployeeId($employees[$i][0]); $newTimesheets = $timesheetObj->fetchTimesheets(); $pendingTimesheets[$employees[$i][0]] = $newTimesheets; if (isset($newTimesheets) && $newTimesheets) { $pending = true; } } } $customerObj = new Customer(); $projectObj = new Projects(); $customers = $customerObj->fetchCustomers(); $projects = $projectObj->fetchProjects(); $dataArr[0] = $role; $dataArr[1] = $employees; $dataArr[2] = $projects; $template = new TemplateMerger($dataArr, $path); $template->display(); }
/** * Create and return a timesheet object with given parameters. */ private function _getTimesheet($timesheetId, $employeeId, $timesheetPeriodId, $startDate, $endDate, $status) { $timesheet = new Timesheet(); $timesheet->setTimesheetId($timesheetId); $timesheet->setTimesheetId($timesheetPeriodId); $timesheet->setEmployeeId($employeeId); $timesheet->setStartDate($startDate); $timesheet->setEndDate($endDate); $timesheet->setStatus($status); return $timesheet; }
function approveAction() { $this->_helper->layout->disableLayout(); $this->_helper->viewRenderer->setNoRender(TRUE); $session = SessionWrapper::getInstance(); $config = Zend_Registry::get("config"); $this->_translate = Zend_Registry::get("translate"); $formvalues = $this->_getAllParams(); debugMessage($formvalues); // exit; if (!isArrayKeyAnEmptyString('id', $formvalues)) { if (isArrayKeyAnEmptyString('status', $formvalues)) { $formvalues['status'] = 3; } $timesheet = new Timesheet(); $timesheet->populate(decode($formvalues['id'])); $timesheet->setStatus($formvalues['status']); if (!isEmptyString($timesheet->getDateIn()) && !isEmptyString($timesheet->getDateOut())) { $timesheet->setHours($timesheet->getComputedHours()); } $timesheet->setDateApproved(DEFAULT_DATETIME); $timesheet->setApprovedByID($session->getVar('userid')); if (!isArrayKeyAnEmptyString('reason', $formvalues)) { $timesheet->setComments("<br/>Rejected with remarks: " . $formvalues['reason']); } // debugMessage($timesheet->toArray()); try { if ($timesheet->save()) { $session->setVar(SUCCESS_MESSAGE, "Successfully Approved"); } $timesheet->afterApprove(); } catch (Exception $e) { $session->setVar(ERROR_MESSAGE, $e->getMessage()); } } // exit; if (!isArrayKeyAnEmptyString('ids', $formvalues)) { $idsarray = array_remove_empty(explode(',', $formvalues['ids'])); // debugMessage($idsarray); if (isArrayKeyAnEmptyString('status', $formvalues)) { $formvalues['status'] = 3; } $timesheet_collection = new Doctrine_Collection(Doctrine_Core::getTable("Timesheet")); if (count($idsarray) > 0) { $hrs = 0; foreach ($idsarray as $key => $id) { $timesheet = new Timesheet(); $timesheet->populate($id); $timesheet->setStatus($formvalues['status']); $timesheet->setHours($timesheet->getComputedHours()); // debugMessage($timesheet->getComputedHours()); $timesheet->setDateApproved(DEFAULT_DATETIME); $timesheet->setApprovedByID($session->getVar('userid')); $timesheet_collection->add($timesheet); // debugMessage($timesheet->toArray()); } try { if ($timesheet_collection->save()) { $msg = "Successfully Approved"; if ($formvalues['status'] == 4) { $msg = "Successfully Rejected"; } $session->setVar(SUCCESS_MESSAGE, $msg); foreach ($timesheet_collection as $timesheet) { $timesheet->afterApprove(); } } } catch (Exception $e) { $session->setVar(ERROR_MESSAGE, $e->getMessage()); } } } $this->_helper->redirector->gotoUrl(decode($this->_getParam(URL_SUCCESS))); }