View | Details | Raw Unified | Return to bug 35248
Collapse All | Expand All

(-)a/Koha/Booking.pm (-34 lines)
Lines 142-180 sub store { Link Here
142
    return $self;
142
    return $self;
143
}
143
}
144
144
145
=head3 intersects
146
147
  my $intersects = $booking1->intersects($booking2);
148
149
Returns a boolean denoting whether booking1 interfers/overlaps/clashes with booking2.
150
151
=cut
152
153
sub intersects {
154
    my ( $self, $comp ) = @_;
155
156
    # Start date of comparison booking is after end date of this booking.
157
    return 0
158
        if (
159
        DateTime->compare(
160
            dt_from_string( $comp->start_date ),
161
            dt_from_string( $self->end_date )
162
        ) >= 0
163
        );
164
165
    # End date of comparison booking is before start date of this booking.
166
    return 0
167
        if (
168
        DateTime->compare(
169
            dt_from_string( $comp->end_date ),
170
            dt_from_string( $self->start_date )
171
        ) <= 0
172
        );
173
174
    # Bookings must overlap
175
    return 1;
176
}
177
178
=head3 get_items_that_can_fill
145
=head3 get_items_that_can_fill
179
146
180
    my $items = $bookings->get_items_that_can_fill();
147
    my $items = $bookings->get_items_that_can_fill();
181
- 

Return to bug 35248