From bcdc6b62ab87c6a96aa48987d8a1d58447bd7adc 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 --- .../prog/en/modules/members/holdshistory.tt | 255 ++++++++++++------ members/holdshistory.pl | 45 +--- 2 files changed, 191 insertions(+), 109 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 c46227de21..797eac1afa 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/holdshistory.tt @@ -49,82 +49,61 @@
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') %] + [% SET show_itemtype_column = Koha.Preference('AllowHoldItemTypeSelection') %] -
- - - - - - - - - - - - - [% IF show_itemtype_column %] - +
+

Current holds

+ [% IF patron.holds.count %] +
TitleAuthorBarcodeCall numberLibraryHold dateExpiration dateWaiting dateCancellation dateRequested item type
+ + + + + + + + + + + + [% IF show_itemtype_column %] + + [% END %] + + + +
TitleAuthorBarcodeCall numberLibraryHold dateExpiration dateWaiting dateCancellation dateRequested item typeStatus
+ [% ELSE %] +
This patron has no current holds.
[% END %] - Status - - - - [% FOREACH hold IN holds %] - - [% 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 %] - - [% IF show_itemtype_column %] - - [% IF hold.itemtype %] - [% ItemTypes.GetDescription( hold.itemtype ) | html %] - [% ELSE %] - Any item type - [% END %] - - [% END %] - - [% 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 %] - - - [% END %] - - -
+

Historical holds

+ [% IF patron.old_holds.count %] + + + + + + + + + + + + + [% IF show_itemtype_column %] + + [% END %] + + + +
TitleAuthorBarcodeCall numberLibraryHold dateExpiration dateWaiting dateCancellation dateRequested item typeStatus
+ [% ELSE %] +
This patron has no historical holds.
+ [% END %] + [% END %] @@ -142,6 +121,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 8564c09a69..c77501ab3d 100755 --- a/members/holdshistory.pl +++ b/members/holdshistory.pl @@ -26,56 +26,33 @@ 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", - query => $input, - type => "intranet", - flagsrequired => {borrowers => 'edit_borrowers'}, - }); - -my $patron; +my ( $template, $loggedinuser, $cookie ) = get_template_and_user( + { + template_name => "members/holdshistory.tt", + query => $input, + type => "intranet", + flagsrequired => { borrowers => 'edit_borrowers' }, + } +); -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.30.2