From d3d8d0737753a9214ccec78be84ebe27aa2b6b41 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 25 Mar 2024 17:23:00 +0100 Subject: [PATCH] Bug 35560: Use the REST API for holds This patch uses the new REST API endpoint to retrieve the old holds. We can now have 2 tables, one for the current holds and one for the old ones. Test plan: Have several holds with several statuses. Notice that you see the holds in the respective tables. Test the usual sorting filtering DT feature and confirm that everything works as expected. Signed-off-by: Lucas Gass Signed-off-by: Jonathan Druart Signed-off-by: David Nind --- .../prog/en/modules/members/holdshistory.tt | 238 +++++++++++++----- members/holdshistory.pl | 32 +-- 2 files changed, 178 insertions(+), 92 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt index 5b3cd3c49e6..e5985d09a58 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt @@ -47,74 +47,60 @@
Staff members are not allowed to access patron's holds history
[% ELSIF is_anonymous %]
This is the anonymous patron, so no holds history is displayed.
- [% ELSIF ( !holds ) %] -
This patron has no holds history.
[% ELSE %] [% SET show_itemtype_column = Koha.Preference('AllowHoldItemTypeSelection') %]
- - - - - - - - - - - - - [% IF show_itemtype_column %] - - [% END %] - - - - - [% FOREACH hold IN holds %] +

Current holds

+ [% IF patron.holds.count %] +
TitleAuthorBarcodeCall numberLibraryHold dateExpiration dateWaiting dateCancellation dateRequested item typeStatus
+ + + + + + + + + + + + [% IF show_itemtype_column %] + + [% END %] + + + +
TitleAuthorBarcodeCall numberLibraryHold dateExpiration dateWaiting dateCancellation dateRequested item typeStatus
+ [% ELSE %] +
This patron has no current holds.
+ [% END %] + +

Historical holds

+ [% IF patron.old_holds.count %] + + - - - - - - - - - + + + + + + + + + [% IF show_itemtype_column %] - + [% END %] - + - [% END %] - -
[% INCLUDE 'biblio-title.inc' biblio=hold.biblio link = 1 %][% hold.biblio.author | html %][% hold.item.barcode | html %][% hold.item.itemcallnumber | html %][% Branches.GetName( hold.branchcode ) | html %][% hold.reservedate | $KohaDates %] [% hold.expirationdate | $KohaDates %] [% hold.waitingdate | $KohaDates %] [% hold.cancellationdate | $KohaDates %] TitleAuthorBarcodeCall numberLibraryHold dateExpiration dateWaiting dateCancellation date - [% IF hold.itemtype %] - [% ItemTypes.GetDescription( hold.itemtype ) | html %] - [% ELSE %] - Any item type - [% END %] - Requested item type - [% IF hold.found == 'F' %] - Fulfilled - [% ELSIF hold.cancellationdate %] - Cancelled - [% IF hold.cancellation_reason %] - ([% AuthorisedValues.GetByCode('HOLD_CANCELLATION', hold.cancellation_reason) | html %]) - [% END %] - [% ELSIF hold.found == 'W' %] - Waiting - [% ELSIF hold.found == 'P' %] - Processing - [% ELSIF hold.found == 'T' %] - In transit - [% ELSE %] - Pending - [% END %] - Status
+ + + [% ELSE %] +
This patron has no historical holds.
+ [% END %]
[% END %] [% END %] @@ -124,6 +110,7 @@ [% INCLUDE 'columns_settings.inc' %] [% INCLUDE 'str/members-menu.inc' %] [% Asset.js("js/members-menu.js") | $raw %] + [% INCLUDE 'js-biblio-format.inc' %] [% END %] diff --git a/members/holdshistory.pl b/members/holdshistory.pl index 538614ac340..9980542f0eb 100755 --- a/members/holdshistory.pl +++ b/members/holdshistory.pl @@ -26,10 +26,6 @@ use Koha::Patrons; my $input = CGI->new; -my $borrowernumber; -my $cardnumber; -my @all_holds; - my ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => "members/holdshistory.tt", @@ -39,47 +35,25 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); -my $patron; - -if ( $input->param('cardnumber') ) { - $cardnumber = $input->param('cardnumber'); - $patron = Koha::Patrons->find( { cardnumber => $cardnumber } ); -} -if ( $input->param('borrowernumber') ) { - $borrowernumber = $input->param('borrowernumber'); - $patron = Koha::Patrons->find($borrowernumber); -} +my $cardnumber = $input->param('cardnumber'); +my $borrowernumber = $input->param('borrowernumber'); +my $patron = Koha::Patrons->find( $cardnumber ? { cardnumber => $cardnumber } : $borrowernumber ); unless ($patron) { print $input->redirect("/cgi-bin/koha/circ/circulation.pl?borrowernumber=$borrowernumber"); exit; } -my $holds; -my $old_holds; - if ( $borrowernumber eq C4::Context->preference('AnonymousPatron') ) { # use of 'eq' in the above comparison is intentional -- the # system preference value could be blank $template->param( is_anonymous => 1 ); -} else { - $holds = $patron->holds; - $old_holds = $patron->old_holds; - - while ( my $hold = $holds->next ) { - push @all_holds, $hold; - } - - while ( my $hold = $old_holds->next ) { - push @all_holds, $hold; - } } $template->param( holdshistoryview => 1, patron => $patron, - holds => \@all_holds, ); output_html_with_http_headers $input, $cookie, $template->output; -- 2.39.5