booked/lib/Application/Reservation/Validation/ReservationOverlappingRule.php
/**
	 * @param ReservationSeries $reservationSeries
	 * @param $retryParameters
	 * @return ReservationRuleResult
	 * @throws Exception
	 */
@param ReservationSeries $reservationSeries
@param $retryParameters
@return ReservationRuleResult
@throws Exception
@param ReservationSeries $reservationSeries @param $retryParameters @return ReservationRuleResult @throws Exception
public function Validate($reservationSeries, $retryParameters)
	{
		$instances = $reservationSeries->SortedInstances();
        $repeat = $reservationSeries->RepeatOptions();
        $overlap = array();
        $prev = null;
        foreach ($instances as $key => $value) {
            if (!$prev) {
                $prev = $value;
                continue;
            }
            $cur = $value;
            $end = $prev->EndDate();
            $start = $cur->StartDate();
            Log::Debug('End: %s, Start: %s', $end->ToTimezone($this->timezone), $start->ToTimezone($this->timezone));
            if ($start->DateCompare($end) < 0) {
                $overlap[] = new DateRange($end, $start);
                if ($repeat->RepeatType() == RepeatType::Daily || $repeat->RepeatType() == RepeatType::Weekly) {
                    break;
                }
            }
            $prev = $cur;
        }
        if (count($overlap) > 0) {
            return new ReservationRuleResult(
                false,
                $this->GetErrorString($overlap),
                true, 
                Resources::GetInstance()->GetString('RetrySkipConflicts'),
                array(new ReservationRetryParameter(ReservationRetryParameter::$SKIP_CONFLICTS, true)),
                false 
            );
        }
		return new ReservationRuleResult();
	}
public function Validate ( $ reservationSeries , $ retryParameters ) { $ instances = $ reservationSeries -> SortedInstances ( ) ; $ repeat = $ reservationSeries -> RepeatOptions ( ) ; $ overlap = array ( ) ; $ prev = null ; foreach ( $ instances as $ key => $ value ) { if ( ! $ prev ) { $ prev = $ value ; continue ; } $ cur = $ value ; $ end = $ prev -> EndDate ( ) ; $ start = $ cur -> StartDate ( ) ; Log :: Debug ( 'End: %s, Start: %s' , $ end -> ToTimezone ( $ this -> timezone ) , $ start -> ToTimezone ( $ this -> timezone ) ) ; if ( $ start -> DateCompare ( $ end ) < 0 ) { $ overlap [ ] = new DateRange ( $ end , $ start ) ; if ( $ repeat -> RepeatType ( ) == RepeatType :: Daily || $ repeat -> RepeatType ( ) == RepeatType :: Weekly ) { break ; } } $ prev = $ cur ; } if ( count ( $ overlap ) > 0 ) { return new ReservationRuleResult ( false , $ this -> GetErrorString ( $ overlap ) , true , Resources :: GetInstance ( ) -> GetString ( 'RetrySkipConflicts' ) , array ( new ReservationRetryParameter ( ReservationRetryParameter :: $ SKIP_CONFLICTS , true ) ) , false ) ; } return new ReservationRuleResult ( ) ; }
@param ReservationSeries $reservationSeries
 @param $retryParameters
 @return ReservationRuleResult
 @throws Exception
@param ReservationSeries $reservationSeries @param $retryParameters @return ReservationRuleResult @throws Exception
// retry // wait list