当前位置: 首页>>代码示例>>PHP>>正文


PHP CommonFunctions::checkTimeOverlap方法代码示例

本文整理汇总了PHP中CommonFunctions::checkTimeOverlap方法的典型用法代码示例。如果您正苦于以下问题:PHP CommonFunctions::checkTimeOverlap方法的具体用法?PHP CommonFunctions::checkTimeOverlap怎么用?PHP CommonFunctions::checkTimeOverlap使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CommonFunctions的用法示例。


在下文中一共展示了CommonFunctions::checkTimeOverlap方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCheckTimeOverlap

 public function testCheckTimeOverlap()
 {
     $this->assertFalse(CommonFunctions::checkTimeOverlap('08:00', '09:00', '09:01', '13:00'));
     // start 2 = end 1 -> no overlap
     $this->assertFalse(CommonFunctions::checkTimeOverlap('08:00', '09:00', '09:00', '13:00'));
     $this->assertTrue(CommonFunctions::checkTimeOverlap('13:00', '21:00', '09:00', '14:00'));
     $this->assertTrue(CommonFunctions::checkTimeOverlap('11:00', '15:00', '13:00', '18:00'));
     $this->assertTrue(CommonFunctions::checkTimeOverlap('11:00', '15:00', '10:00', '18:00'));
     $this->assertTrue(CommonFunctions::checkTimeOverlap('17:00', '21:00', '18:00', '18:30'));
 }
开发者ID:noikiy,项目名称:owaspbwa,代码行数:10,代码来源:CommonFunctionsTest.php

示例2: addLeave

 public function addLeave()
 {
     $tmpObj = $this->getObjLeave();
     $fromDate = $tmpObj->getLeaveFromDate();
     $toDate = $tmpObj->getLeaveToDate();
     $authorizeObj = $this->authorize;
     if ($authorizeObj->isESS()) {
         $fromDateArray = explode("-", $fromDate);
         $toDateArray = explode("-", $toDate);
         if ($fromDateArray[0] == $toDateArray[0]) {
             $tmpLeaveQuota = new LeaveQuota();
             $tmpLeaveQuota->setEmployeeId($tmpObj->getEmployeeId());
             $tmpLeaveQuota->setYear($fromDateArray[0]);
             $tmpLeaveQuota->setLeaveTypeId($tmpObj->getLeaveTypeId());
             if ($tmpLeaveQuota->isBalanceZero()) {
                 $message = "BALANCE_ZERO";
                 return $message;
             }
         } else {
             $tmpLeaveQuota = new LeaveQuota();
             $tmpLeaveQuota->setEmployeeId($tmpObj->getEmployeeId());
             $tmpLeaveQuota->setYear($fromDateArray[0]);
             $tmpLeaveQuota->setLeaveTypeId($tmpObj->getLeaveTypeId());
             $tmpLeaveQuota1 = new LeaveQuota();
             $tmpLeaveQuota1->setEmployeeId($tmpObj->getEmployeeId());
             $tmpLeaveQuota1->setYear($toDateArray[0]);
             $tmpLeaveQuota1->setLeaveTypeId($tmpObj->getLeaveTypeId());
             if ($tmpLeaveQuota->isBalanceZero() && $tmpLeaveQuota1->isBalanceZero()) {
                 $message = "BALANCE_ZERO";
                 return $message;
             }
         }
     }
     $tmpLeave = new Leave();
     $duplicateList = $tmpLeave->retrieveDuplicateLeave($tmpObj->getEmployeeId(), $fromDate, $toDate);
     $rejects = array();
     $duplicates = array();
     if (!empty($duplicateList)) {
         foreach ($duplicateList as $dup) {
             if ($dup->getLeaveStatus() == Leave::LEAVE_STATUS_LEAVE_REJECTED) {
                 $rejects[] = $dup;
             } else {
                 $duplicates[] = $dup;
             }
         }
         /* Only rejected leave conflicts with current leave request */
         if (count($duplicates) == 0) {
             /* Change status of rejected leave requests to cancelled */
             foreach ($rejects as $rej) {
                 $rej->setLeaveStatus(Leave::LEAVE_STATUS_LEAVE_CANCELLED);
                 $res = $rej->changeLeaveStatus();
                 if (!$res) {
                     return "APPLY_FAILURE";
                 }
             }
         } else {
             /* If multiple day leave request, we don't need to check leave times.
              * Just throw an exception.
              */
             if ($fromDate != $toDate) {
                 throw new DuplicateLeaveException($duplicates);
             } else {
                 /* A single day leave request. We need to check leave times. */
                 // Count total hours and check for greater than workshift hours
                 $shift = Leave::LEAVE_LENGTH_FULL_DAY;
                 $workShift = Workshift::getWorkshiftForEmployee($tmpObj->getEmployeeId());
                 if (isset($workShift)) {
                     $shift = $workShift->getHoursPerDay();
                 }
                 $totalHours = 0;
                 foreach ($duplicates as $dup) {
                     $totalHours += $dup->getLeaveLengthHours();
                 }
                 if ($totalHours + $tmpObj->getLeaveLengthHours() > $shift) {
                     throw new DuplicateLeaveException($duplicates);
                 }
                 /* Check for overlapping leave times*/
                 $startTime = $tmpObj->getStartTime();
                 $endTime = $tmpObj->getEndTime();
                 if (!empty($startTime) && !empty($endTime)) {
                     foreach ($duplicates as $dup) {
                         $dupStartTime = $dup->getStartTime();
                         $dupEndTime = $dup->getEndTime();
                         if (!empty($dupStartTime) && !empty($dupEndTime)) {
                             $overlap = CommonFunctions::checkTimeOverlap($startTime, $endTime, $dupStartTime, $dupEndTime);
                             if ($overlap) {
                                 throw new DuplicateLeaveException($duplicates);
                             }
                         }
                     }
                 }
                 /* Show warning (Only if we haven't shown the warning before (in previous requst) for this date')*/
                 if (!isset($_POST['confirmDate']) || $_POST['confirmDate'] != $fromDate) {
                     throw new DuplicateLeaveException($duplicates, true);
                 }
             }
         }
     }
     $res = $tmpObj->applyLeaveRequest();
     $mailNotificaton = new MailNotifications();
//.........这里部分代码省略.........
开发者ID:noikiy,项目名称:owaspbwa,代码行数:101,代码来源:LeaveController.php


注:本文中的CommonFunctions::checkTimeOverlap方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。