Lines 532-541
sub bookings {
Link Here
|
532 |
|
532 |
|
533 |
Find the first booking that would conflict with the passed checkout dates for this item. |
533 |
Find the first booking that would conflict with the passed checkout dates for this item. |
534 |
|
534 |
|
535 |
FIXME: This can be simplified, it was originally intended to iterate all biblio level bookings |
535 |
FIXME: This can be simplified, it was originally intended to iterate all biblio level bookings |
536 |
to catch cases where this item may be the last available to satisfy a biblio level only booking. |
536 |
to catch cases where this item may be the last available to satisfy a biblio level only booking. |
537 |
However, we dropped the biblio level functionality prior to push as bugs were found in it's |
537 |
However, we dropped the biblio level functionality prior to push as bugs were found in it's |
538 |
implimentation. |
538 |
implementation. |
539 |
|
539 |
|
540 |
=cut |
540 |
=cut |
541 |
|
541 |
|
Lines 662-708
sub check_booking {
Link Here
|
662 |
return $bookings_count ? 0 : 1; |
662 |
return $bookings_count ? 0 : 1; |
663 |
} |
663 |
} |
664 |
|
664 |
|
665 |
=head3 place_booking |
|
|
666 |
|
667 |
my $booking = $item->place_booking( |
668 |
{ |
669 |
patron => $patron, |
670 |
start_date => $datetime, |
671 |
end_date => $datetime |
672 |
} |
673 |
); |
674 |
|
675 |
Add a booking for this item for the dates passed. |
676 |
|
677 |
Returns the Koha::Booking object or throws an exception if the item cannot be booked for the given dates. |
678 |
|
679 |
=cut |
680 |
|
681 |
sub place_booking { |
682 |
my ( $self, $params ) = @_; |
683 |
|
684 |
# check for mandatory params |
685 |
my @mandatory = ( 'start_date', 'end_date', 'patron' ); |
686 |
for my $param (@mandatory) { |
687 |
unless ( defined( $params->{$param} ) ) { |
688 |
Koha::Exceptions::MissingParameter->throw( error => "The $param parameter is mandatory" ); |
689 |
} |
690 |
} |
691 |
my $patron = $params->{patron}; |
692 |
|
693 |
# New booking object |
694 |
my $booking = Koha::Booking->new( |
695 |
{ |
696 |
start_date => $params->{start_date}, |
697 |
end_date => $params->{end_date}, |
698 |
patron_id => $patron->borrowernumber, |
699 |
biblio_id => $self->biblionumber, |
700 |
item_id => $self->itemnumber, |
701 |
} |
702 |
)->store(); |
703 |
return $booking; |
704 |
} |
705 |
|
706 |
=head3 request_transfer |
665 |
=head3 request_transfer |
707 |
|
666 |
|
708 |
my $transfer = $item->request_transfer( |
667 |
my $transfer = $item->request_transfer( |
709 |
- |
|
|