|
Lines 321-366
sub assign_item_for_booking {
Link Here
|
| 321 |
return $bookable_items->single->itemnumber; |
321 |
return $bookable_items->single->itemnumber; |
| 322 |
} |
322 |
} |
| 323 |
|
323 |
|
| 324 |
=head3 place_booking |
|
|
| 325 |
|
| 326 |
my $booking = $biblio->place_booking( |
| 327 |
{ |
| 328 |
patron => $patron, |
| 329 |
start_date => $datetime, |
| 330 |
end_date => $datetime |
| 331 |
} |
| 332 |
); |
| 333 |
|
| 334 |
Add a booking for this item for the dates passed. |
| 335 |
|
| 336 |
Returns the Koha::Booking object or throws an exception if the item cannot be booked for the given dates. |
| 337 |
|
| 338 |
=cut |
| 339 |
|
| 340 |
sub place_booking { |
| 341 |
my ( $self, $params ) = @_; |
| 342 |
|
| 343 |
# check for mandatory params |
| 344 |
my @mandatory = ( 'start_date', 'end_date', 'patron' ); |
| 345 |
for my $param (@mandatory) { |
| 346 |
unless ( defined( $params->{$param} ) ) { |
| 347 |
Koha::Exceptions::MissingParameter->throw( error => "The $param parameter is mandatory" ); |
| 348 |
} |
| 349 |
} |
| 350 |
my $patron = $params->{patron}; |
| 351 |
|
| 352 |
# New booking object |
| 353 |
my $booking = Koha::Booking->new( |
| 354 |
{ |
| 355 |
start_date => $params->{start_date}, |
| 356 |
end_date => $params->{end_date}, |
| 357 |
patron_id => $patron->borrowernumber, |
| 358 |
biblio_id => $self->biblionumber |
| 359 |
} |
| 360 |
)->store(); |
| 361 |
return $booking; |
| 362 |
} |
| 363 |
|
| 364 |
=head3 can_be_transferred |
324 |
=head3 can_be_transferred |
| 365 |
|
325 |
|
| 366 |
$biblio->can_be_transferred({ to => $to_library, from => $from_library }) |
326 |
$biblio->can_be_transferred({ to => $to_library, from => $from_library }) |