@@ -, +, @@ pickup libraries for an item or record --- C4/ILSDI/Services.pm | 46 +++++++++++++++++++++++ koha-tmpl/opac-tmpl/bootstrap/en/modules/ilsdi.tt | 37 ++++++++++++++++++ opac/ilsdi.pl | 3 ++ 3 files changed, 86 insertions(+) --- a/C4/ILSDI/Services.pm +++ a/C4/ILSDI/Services.pm @@ -614,6 +614,52 @@ sub GetServices { return $out; } +=head2 GetPickupLocation + +Returns availables pickup locations given a particular item or record and a particular patron. + +Parameters: + + - patron_id (Required) + a borrowernumber + - id (Required) + an itemnumber or recordnumber + - id_type (Required) + either item or biblio (defines the id given above). + +=cut + +sub GetPickupLocation { + my ($cgi) = @_; + + # Get the borrower or return an error code + my $borrowernumber = $cgi->param('patron_id'); + my $patron = Koha::Patrons->find( $borrowernumber ); + return { error => 'PatronNotFound' } unless $patron; + + # Get all pickup locations + my @pickup_locations; + my $id_type = $cgi->param('id_type'); + if ( $id_type && $id_type eq 'item' ) { + my $itemnumber = $cgi->param('id'); + my $item = Koha::Items->find( $itemnumber ); + return { error => 'ItemNotFound' } unless $item; + @pickup_locations = Koha::Libraries->pickup_locations( { item => $item } ); + } + + elsif ( $id_type && $id_type eq 'bib' ) { + my $biblionumber = $cgi->param('id'); + my $biblio = Koha::Biblios->find( $biblionumber ); + return { error => 'RecordNotFound' } unless $biblio; + @pickup_locations = Koha::Libraries->pickup_locations( { biblio => $biblio } ); + } + + else { return { error => 'MissingParameter' }; } + + # Might be nice to filter against those in which the patron can actually pickup the book. + return { library => \@pickup_locations }; +} + =head2 RenewLoan Extends the due date for a borrower's existing issue. --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/ilsdi.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/ilsdi.tt @@ -17,6 +17,8 @@ ILS-DI › GetPatronStatus [% ELSIF ( GetServices ) %] ILS-DI › GetServices + [% ELSIF ( GetPickupLocation ) %] + ILS-DI › GetPickupLocation [% ELSIF ( RenewLoan ) %] ILS-DI › RenewLoan [% ELSIF ( HoldTitle ) %] @@ -61,6 +63,9 @@ [% ELSIF ( GetServices ) %]
Returns available pickup locations given a particular item or record and a particular patron.
+<?xml version="1.0" encoding="UTF-8"?> +<GetPickupLocation> +<pickup_locations> + <pickup_location> + <pickup_location_label>First library</pickup_location_label> + <pickup_location_id>1</pickup_location_id> + </pickup_location> + <pickup_location> + <pickup_location_label>Second library</pickup_location_label> + <pickup_location_id>2</pickup_location_id> + </pickup_location> +</pickup_locations> +</GetPickupLocation> + [% ELSIF ( RenewLoan ) %]RenewLoan
--- a/opac/ilsdi.pl +++ a/opac/ilsdi.pl @@ -67,6 +67,7 @@ my @services = ( 'GetPatronInfo', 'GetPatronStatus', 'GetServices', # FIXME Loans + 'GetPickupLocation', 'RenewLoan', 'HoldTitle', # FIXME Add dates support 'HoldItem', # FIXME Add dates support @@ -90,6 +91,7 @@ my %required = ( 'GetPatronInfo' => ['patron_id'], 'GetPatronStatus' => ['patron_id'], 'GetServices' => [ 'patron_id', 'item_id' ], + 'GetPickupLocation' => [ 'patron_id', 'id', 'id_type' ], 'RenewLoan' => [ 'patron_id', 'item_id' ], 'HoldTitle' => [ 'patron_id', 'bib_id', 'request_location' ], 'HoldItem' => [ 'patron_id', 'bib_id', 'item_id' ], @@ -107,6 +109,7 @@ my %optional = ( 'GetPatronInfo' => [ 'show_contact', 'show_fines', 'show_holds', 'show_loans', 'loans_per_page', 'loans_page', 'show_attributes' ], 'GetPatronStatus' => [], 'GetServices' => [], + 'GetPickupLocation' => [], 'RenewLoan' => ['desired_due_date'], 'HoldTitle' => [ 'pickup_location', 'needed_before_date', 'pickup_expiry_date' ], 'HoldItem' => [ 'pickup_location', 'needed_before_date', 'pickup_expiry_date' ], --