/** * Parse edit data in the UI form * * @param mixed $postArr * @return Leave[] */ public function parseEditData($postArr) { $objArr = null; if (isset($_POST['txtDay']) && is_array($_POST['txtDay'])) { for ($i = 0; $i < count($_POST['txtDay']); $i++) { $tmpWeekend = new Weekends(); if (isset($_POST['txtDay'][$i])) { $tmpWeekend->setDay($_POST['txtDay'][$i]); } if (isset($_POST['sltLeaveLength'][$i])) { $tmpWeekend->setLength($_POST['sltLeaveLength'][$i]); } $objArr[] = $tmpWeekend; } } return $objArr; }
if (!empty($holiday) && is_a($holiday, 'Holidays')) { echo $holiday->getDescription(); } else { echo $lang_Leave_Closed; } ?> <input type="hidden" name="cmbStatus[]" value="<?php echo $record->getLeaveStatus(); ?> " /> <?php } ?> <?php } else { if (Weekends::isWeekend($record->getLeaveDate())) { echo $lang_Leave_Closed; } else { echo $statusArr[$record->getLeaveStatus()]; } ?> <input type="hidden" name="cmbStatus[]" value="<?php echo $record->getLeaveStatus(); ?> " /> <input type="hidden" name="id[]" value="<?php echo $record->getLeaveId(); ?> " /> <?php }
/** * Builds an array of Weekend objects * * @access private * @param resource $result * @return Weekend[] $objArr */ private function _buildObjArr($result) { $objArr = null; if ($result) { while ($row = mysql_fetch_assoc($result)) { $tmpObjWeekends = new Weekends(); if (isset($row[self::WEEKENDS_TABLE_DAY])) { $tmpObjWeekends->setDay($row[self::WEEKENDS_TABLE_DAY]); } if (isset($row[self::WEEKENDS_TABLE_LENGTH])) { $tmpObjWeekends->setLength($row[self::WEEKENDS_TABLE_LENGTH]); } $objArr[] = $tmpObjWeekends; } } return $objArr; }
public function displayDefineHolidays($modifier = "specific", $edit = false) { $this->_authenticateViewHoliday(); $record = null; if ($edit) { $holidayObj = new Holidays(); $record = $holidayObj->fetchHoliday($this->getId()); } switch ($modifier) { case "specific": $path = "/templates/leave/specificHolidaysDefine.php"; break; case "weekend": $path = "/templates/leave/weekendHolidaysDefine.php"; $weekendsObj = new Weekends(); $record = $weekendsObj->fetchWeek(); break; } $template = new TemplateMerger($record, $path); $modifier = $edit; $template->display($modifier); }
public function displayDefineHolidays($modifier = "specific", $edit = false) { $this->_authenticateViewHoliday(); $record = null; if ($edit) { $holidayObj = new Holidays(); $record = $holidayObj->fetchHoliday($this->getId()); } switch ($modifier) { case "specific": $holiday = new Holidays(); $record['holidayList'] = $holiday->listHolidays(); $path = "/templates/leave/specificHolidaysDefine.php"; break; case "weekend": $path = "/templates/leave/weekendHolidaysDefine.php"; $weekendsObj = new Weekends(); $record = $weekendsObj->fetchWeek(); break; } $record['rights'] = $_SESSION['localRights']; $record['changeWeekends'] = Leave::isLeaveTableEmpty(); $template = new TemplateMerger($record, $path); $modifier = $edit; $template->display($modifier); }
public function __construct() { $weekendObj = new Weekends(); $this->weekends = $weekendObj->fetchWeek(); }
public static function updateHolidaysForLeavesOnDelete() { $dbConnection = new DMLFunctions(); $approved = Leave::LEAVE_STATUS_LEAVE_APPROVED; $pendingApproval = Leave::LEAVE_STATUS_LEAVE_PENDING_APPROVAL; $taken = Leave::LEAVE_STATUS_LEAVE_TAKEN; $holiday = Leave::LEAVE_STATUS_LEAVE_HOLIDAY; $lengthFullDay = Leave::LEAVE_LENGTH_FULL_DAY; $query = "UPDATE hs_hr_leave SET leave_status = {$pendingApproval}, leave_length_hours = {$lengthFullDay}, " . "leave_length_days = 1, leave_comments = Null " . "WHERE leave_status = {$holiday} AND leave_date > CURDATE() " . "AND leave_date NOT IN(SELECT date FROM hs_hr_holidays ) "; $result = $dbConnection->executeQuery($query); #$query = "UPDATE hs_hr_leave SET leave_status = $taken, leave_length_hours = $lengthFullDay, " . #"leave_length_days = 1, leave_comments = Null " . #"WHERE leave_status = $holiday AND leave_date <= CURDATE()" . #"AND leave_date NOT IN(SELECT date FROM hs_hr_holidays ) "; #$result = $dbConnection -> executeQuery($query); Weekends::updateWeekendsForLeaves(); }
public function testGetWeekendLength() { $sunday = Weekends::getWeekendLength('2009-02-15'); $saturday = Weekends::getWeekendLength('2009-02-14'); $friday = Weekends::getWeekendLength('2009-02-13'); $this->assertEquals(8, $sunday, 'Invalid length'); $this->assertEquals(4, $saturday, 'Invalid Length'); $this->assertEquals(0, $friday, 'Invalid Length'); }
/** * Adds Leave * * @access protected */ protected function _addLeave() { $this->leaveId = UniqueIDGenerator::getInstance()->getNextID('hs_hr_leave', 'leave_id'); $this->_getLeaveTypeName(); $this->setDateApplied(date('Y-m-d')); $this->_adjustLeaveLength(); $insertFields[0] = '`leave_id`'; $insertFields[1] = '`leave_date`'; $insertFields[2] = '`leave_length_hours`'; $insertFields[3] = '`leave_length_days`'; $insertFields[4] = '`leave_status`'; $insertFields[5] = '`leave_comments`'; $insertFields[6] = '`leave_request_id`'; $insertFields[7] = '`leave_type_id`'; $insertFields[8] = '`employee_id`'; $arrRecordsList[0] = $this->getLeaveId(); $arrRecordsList[1] = "'" . $this->getLeaveDate() . "'"; $arrRecordsList[2] = "'" . $this->getLeaveLengthHours() . "'"; $arrRecordsList[3] = "'" . $this->getLeaveLengthDays() . "'"; $hours = $this->getLeaveLengthHours(); $days = $this->getLeaveLengthDays(); if ($hours == 0 && $days == 0) { $arrRecordsList[4] = self::LEAVE_STATUS_LEAVE_CANCELLED; } else { $arrRecordsList[4] = $this->statusLeavePendingApproval; } $holidays = new Holidays(); $weekends = new Weekends(); if ($weekends->isWeekend($this->getLeaveDate())) { $arrRecordsList[4] = self::LEAVE_STATUS_LEAVE_WEEKEND; } elseif ($holidays->isHoliday($this->getLeaveDate())) { $arrRecordsList[4] = self::LEAVE_STATUS_LEAVE_HOLIDAY; } $arrRecordsList[5] = "'" . $this->getLeaveComments() . "'"; $arrRecordsList[6] = "'" . $this->getLeaveRequestId() . "'"; $arrRecordsList[7] = "'" . $this->getLeaveTypeId() . "'"; $arrRecordsList[8] = "'" . $this->getEmployeeId() . "'"; if ($this->getStartTime() != null && $this->getEndTime() != null) { $insertFields[9] = '`start_time`'; $arrRecordsList[9] = "'" . $this->getStartTime() . "'"; $insertFields[10] = '`end_time`'; $arrRecordsList[10] = "'" . $this->getEndTime() . "'"; } $arrTable = "`hs_hr_leave`"; $sqlBuilder = new SQLQBuilder(); $query = $sqlBuilder->simpleInsert($arrTable, $arrRecordsList, $insertFields); $dbConnection = new DMLFunctions(); $result = $dbConnection->executeQuery($query); return $result; }
public function testIsWeekend() { $this->assertTrue(Weekends::isWeekend("2008-07-27")); $this->assertFalse(Weekends::isWeekend("2008-07-26")); $this->assertFalse(Weekends::isWeekend("2008-07-25")); }