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

(-)a/Koha/Biblio.pm (-40 lines)
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 })
(-)a/Koha/Item.pm (-43 / +1 lines)
Lines 535-541 Find the first booking that would conflict with the passed checkout dates for th Link Here
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
- 

Return to bug 35248