public function parseEditData($postArr)
 {
     $tmpObj = new TimesheetSubmissionPeriod();
     $tmpObj->setTimesheetPeriodId($postArr['txtTimeshetPeriodId']);
     $tmpObj->setStartDay($postArr['cmbStartDay']);
     $this->parent_TimesheetSubmissionPeriod = $tmpObj;
     return $this->parent_TimesheetSubmissionPeriod;
 }
Example #2
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());
     }
 }
 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;
 }
Example #4
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();
 }