From 3748c253543315922a3d05c54f6640ec6efed276 Mon Sep 17 00:00:00 2001 From: Arthur Suzuki Date: Thu, 30 May 2019 01:16:55 +0200 Subject: [PATCH] Bug 23015 : Implements a new ILS-DI service to get available pickup libraries for an item or record test plan : 1 / Set a library A as available pickup location in the intranet 2 / query ILS-DI service with any record which has at least an item in A or an item which can be transfered to A => should send all informations about A 3 / Remove A from available pickup locations from the item in the intranet then repeat 2 => should give empty reply 4 / Try with unexisting patron, unexisting item or unexisting record, should throw an explicit error --- C4/ILSDI/Services.pm | 46 +++++++++++++++++++++++ koha-tmpl/opac-tmpl/bootstrap/en/modules/ilsdi.tt | 39 ++++++++++++++++++- opac/ilsdi.pl | 3 ++ 3 files changed, 87 insertions(+), 1 deletion(-) diff --git a/C4/ILSDI/Services.pm b/C4/ILSDI/Services.pm index 43935bbf8f..440d5f6ddc 100644 --- a/C4/ILSDI/Services.pm +++ b/C4/ILSDI/Services.pm @@ -599,6 +599,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 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 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. diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/ilsdi.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/ilsdi.tt index 7c882d4b3b..07b09f6e0a 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/ilsdi.tt +++ b/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,7 +63,10 @@ [% ELSIF ( GetServices ) %]
  • ILS-DI
  • GetServices
  • - [% ELSIF ( RenewLoan ) %] + [% ELSIF ( GetPickupLocation ) %] +
  • ILS-DI
  • +
  • GetPickupLocation
  • + [% ELSIF ( RenewLoan ) %]
  • ILS-DI
  • RenewLoan
  • [% ELSIF ( HoldTitle ) %] @@ -674,6 +679,38 @@ <AvailableFor>item level hold</AvailableFor> </GetServices> + [% ELSIF ( GetPickupLocation ) %] + +

    GetPickupLocation

    +

    Returns available pickup locations given a particular item or record and a particular patron.

    +

    Parameters

    +
    +
    patron_id (Required)
    +
    the unique patron identifier in the ILS; the same identifier returned by LookupPatron or AuthenticatePatron
    +
    id (Required)
    +
    system item identifier
    +
    id (Required)
    +
    system identifier type (either bib for biblio or item)
    +
    +

    Example call

    + + ilsdi.pl?service=GetPickupLocation&patron_id=1&id=1&id_type=item + +

    Example response

    +
    <?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

    diff --git a/opac/ilsdi.pl b/opac/ilsdi.pl index 290abad758..24880931cb 100755 --- a/opac/ilsdi.pl +++ b/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', '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' ], -- 2.11.0