public function parseEditData($postArr)
 {
     $tmpObj = new TimesheetSubmissionPeriod();
     $tmpObj->setTimesheetPeriodId($postArr['txtTimeshetPeriodId']);
     $tmpObj->setStartDay($postArr['cmbStartDay']);
     $this->parent_TimesheetSubmissionPeriod = $tmpObj;
     return $this->parent_TimesheetSubmissionPeriod;
 }
 $clientTime = null;
 $punchIn = false;
 $new = false;
 $return = null;
 switch ($_GET['action']) {
     case 'View_Current_Timesheet':
         $current = true;
         $clientTimezoneOffset = @$_GET['clientTimezoneOffset'];
         settype($clientTimezoneOffset, 'integer');
         $serverTimezoneOffset = (int) date('Z') / 60;
         $timeZoneDiff = $clientTimezoneOffset - $serverTimezoneOffset;
         if ($clientTimezoneOffset != $serverTimezoneOffset) {
             $useClientTime = true;
             $clientTimestamp = time() + $timeZoneDiff * 60;
             $day = date('N', $clientTimestamp);
             $objSubmissionPeriods = new TimesheetSubmissionPeriod();
             $timesheetSubmissionPeriods = $objSubmissionPeriods->fetchTimesheetSubmissionPeriods();
             $timesheetSubmissionDay = $timesheetSubmissionPeriods[0]->getStartDay();
             $dayDiff = $timesheetSubmissionDay - $day;
             if ($dayDiff > 0) {
                 $dayDiff -= 7;
             }
             $sign = $dayDiff < 0 ? "" : "+";
             $clientStartDateTimestamp = strtotime("{$sign}{$dayDiff} day", time() + $timeZoneDiff * 60);
             $clientStartDate = date('Y-m-d', $clientStartDateTimestamp);
             $clientEndDate = date('Y-m-d', strtotime("+6 day", $clientStartDateTimestamp));
         }
     case 'View_Timesheet':
         if ($current && $useClientTime) {
             $timesheetPeriodId = $timesheetSubmissionPeriods[0]->getTimesheetPeriodId();
             $obj = $timesheetExtractor->parseViewDataWithTimezoneDiff($clientStartDate, $clientEndDate, $timesheetPeriodId);
示例#3
0
 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());
     }
 }
示例#4
0
 /**
  * Generates the current timesheet start date and end date
  *
  * This will be called if start date of a time sheet is not set
  */
 private function _getNewDates()
 {
     $timesheetSubmissionPeriodObj = new TimesheetSubmissionPeriod();
     $timesheetSubmissionPeriods = $timesheetSubmissionPeriodObj->fetchTimesheetSubmissionPeriods();
     if ($this->getStartDate() == null) {
         $day = date('N');
         $diff = $timesheetSubmissionPeriods[0]->getStartDay() - $day;
         if ($diff > 0) {
             $diff -= 7;
         }
         $sign = $diff < 0 ? "" : "+";
         $this->setStartDate(date('Y-m-d', strtotime("{$sign}{$diff} day", time())));
         $diff1 = $timesheetSubmissionPeriods[0]->getEndDay() - $day;
         if ($diff1 - $diff <= 6) {
             $diff1 += 6 - ($diff1 - $diff);
         }
         $sign = $diff1 < 0 ? "" : "+";
         $this->setEndDate(date('Y-m-d', strtotime("{$sign}{$diff1} day", time())) . " 23:59:59");
         $this->setTimesheetPeriodId($timesheetSubmissionPeriods[0]->getTimesheetPeriodId());
     }
 }
 private function _buildObjArr($result)
 {
     $objArr = null;
     while ($row = mysql_fetch_assoc($result)) {
         $tmpTimeArr = new TimesheetSubmissionPeriod();
         $tmpTimeArr->setTimesheetPeriodId($row[self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_TIMESHEET_PERIOD_ID]);
         $tmpTimeArr->setName($row[self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_NAME]);
         $tmpTimeArr->setFrequency($row[self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_FREQUENCY]);
         $tmpTimeArr->setPeriod($row[self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_PERIOD]);
         $tmpTimeArr->setStartDay($row[self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_START_DAY]);
         $tmpTimeArr->setEndDay($row[self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_END_DAY]);
         $tmpTimeArr->setDescription($row[self::TIMESHEET_SUBMISSION_PERIOD_DB_FIELD_DESCRIPTION]);
         $objArr[] = $tmpTimeArr;
     }
     return $objArr;
 }
示例#6
0
 /**
  * View timesheets in bulk
  *
  * Introduced for printing timesheets.
  * $fileterValues can optionally contain the following. Order is important.
  *	1. Employee Id
  * 	2. Division Id
  *	3. Supervisor Id
  *	4. Employment Status
  *
  * From and To date should be set as the timeobj
  *
  * @param String[] filterValues Filter timesheets with the values
  */
 public function viewTimesheelBulk($filterValues, $page = 1)
 {
     $path = "/templates/time/printTimesheetPage.php";
     $employeeObj = new EmpInfo();
     $timesheetObj = $this->getObjTime();
     $employeeIds = $employeeObj->getEmployeeIdsFilterMultiParams($filterValues);
     $timsheetIds = $this->_getTimesheetIds($employeeIds, $timesheetObj);
     $timesheets = $timesheetObj->fetchTimesheetsByTimesheetIdBulk($page, $timsheetIds);
     $dataArr = null;
     $timesheetSubmissionPeriodObj = new TimesheetSubmissionPeriod();
     for ($i = 0; $i < count($timesheets); $i++) {
         list($dataArr[0][$i]['durationArr'], $dataArr[0][$i]['dailySum'], $dataArr[0][$i]['activitySum'], $dataArr[0][$i]['totalTime']) = $this->_generateTimesheet($timesheets[$i]);
         $employees = $employeeObj->filterEmpMain($timesheets[$i]->getEmployeeId());
         $dataArr[0][$i]['employee'] = $employees[0];
         $dataArr[0][$i]['timesheet'] = $timesheets[$i];
         $timesheetSubmissionPeriodObj->setTimesheetPeriodId($timesheets[$i]->getTimesheetPeriodId());
         $timesheetSubmissionPeriod = $timesheetSubmissionPeriodObj->fetchTimesheetSubmissionPeriods();
         $dataArr[0][$i]['timesheetSubmissionPeriod'] = $timesheetSubmissionPeriod[0];
     }
     $dataArr[1] = $page;
     $dataArr[2] = $timesheetObj->getStartDate();
     $dataArr[3] = $timesheetObj->getEndDate();
     $template = new TemplateMerger($dataArr, $path, "stubHeader.php", "stubFooter.php");
     $template->display();
 }