Element_OphTrOperationbooking_ScheduleOperation::validateNoDateRangeOverlap PHP Method

validateNoDateRangeOverlap() public method

validate a date is earlier or equal to another.
public validateNoDateRangeOverlap ( $attribute, $params )
$attribute - the element attribute that must be an earlier date
$params - 'later_date' is the attribute to compare it with
    public function validateNoDateRangeOverlap($attribute, $params)
    {
        $pstart = 'start_date';
        $pend = 'end_date';
        foreach ($this->{$attribute} as $i => $dr) {
            for ($j = $i + 1; $j < count($this->{$attribute}); ++$j) {
                if ($dr->{$pstart} < $this->{$attribute}[$j]->{$pend} && $dr->{$pend} > $this->{$attribute}[$j]->{$pstart}) {
                    $this->addError($attribute, 'Data ranges cannot overlap');
                }
            }
        }
    }