From 18c66195d94398d393a09ac8f9fc69b760f8850d Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Mon, 20 Sep 2021 11:17:50 +0000 Subject: [PATCH] Bug 29058: Add 'Always show holds' checkbox to request.pl This patch adds a new cookie 'awalys_show_holds' and utlises it on request.pl to determine if the existing holds table should be loaded. If the cookie does not exist, the table is loaded to preserve exiting behaviour. If the cookie exists and is set to 'DONT' a new button 'Show holds' is added to the page to allow force loading the table To test: 1 - Place some holds on a record 2 - Click 'Holds' tab or 'Place a hold' from details page 3 - Note search box to place hold and table of existing holds 4 - Apply patch 5 - Reload the holds page and note new checkbox 'Always show holds' 6 - Confirm the box is checked 7 - Uncheck it 8 - Reload the page and confirm holds do not automatically load 9 - Click the new 'Show holds' button 10 - Confirm the existing holds load, and that 'Always show holds' is unchecked 11 - Check 'Always show holds' 12 - Reload page and confirm holds don't show 13 - Uncheck the box, load holds for another record, confirm it remains unchecked 14 - Bring up browser console (F12) 15 - In 'Storage' tab, under 'Cookies', delete the cookie for 'always_show_holds' 16 - Reload holds page, confirm holds load and check box is checked Signed-off-by: Andrew Fuerste-Henry Bug 29058: (follow-up) Add hold count and don't display show options if no holds Signed-off-by: Jonathan Druart --- .../prog/en/modules/reserve/request.tt | 18 +++ reserve/request.pl | 103 +++++++++--------- 2 files changed, 72 insertions(+), 49 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt index 7d89d9f5241..e9488ea1826 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -3,6 +3,7 @@ [% USE Asset %] [% USE JSON.Escape %] [% USE Koha %] +[% USE Biblio %] [% USE KohaDates %] [% USE Branches %] [% USE Categories %] @@ -904,6 +905,16 @@ [% END %] [% UNLESS ( patron ) %] + [% SET hold_count = Biblio.HoldsCount( biblio.biblionumber ) | html %] + [% IF hold_count %] + + [% IF always_show_holds == 'DONT' %] + + Show holds ([% hold_count %]) + [% ELSE %] + + [% END %] + [% END %] [% IF ( reserveloop ) %]
[% IF ( multi_hold ) %] @@ -1399,6 +1410,13 @@ } $(document).ready(function() { + $("#always_show_holds").change(function(){ + if( $(this).prop('checked') ){ + document.cookie = 'always_show_holds=DO'; + } else { + document.cookie = 'always_show_holds=DONT'; + } + }); $("input.needsoverride").click(function() { // This must be before the radio button/checkbox switch logic var itemnumber = this.value; var msg = ''; diff --git a/reserve/request.pl b/reserve/request.pl index ebc578ee74a..9bad2e8faa6 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -678,57 +678,62 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) # existingreserves building my @reserveloop; - my @reserves = Koha::Holds->search( { biblionumber => $biblionumber }, { order_by => 'priority' } ); - foreach my $res ( - sort { - my $a_found = $a->found() || ''; - my $b_found = $a->found() || ''; - $a_found cmp $b_found; - } @reserves - ) - { - my %reserve; - if ( $res->is_found() ) { - $reserve{'holdingbranch'} = $res->item()->holdingbranch(); - $reserve{'biblionumber'} = $res->item()->biblionumber(); - $reserve{'barcodenumber'} = $res->item()->barcode(); - $reserve{'wbrcode'} = $res->branchcode(); - $reserve{'itemnumber'} = $res->itemnumber(); - $reserve{'wbrname'} = $res->branch()->branchname(); - $reserve{'atdestination'} = $res->is_at_destination(); - $reserve{'desk_name'} = ( $res->desk() ) ? $res->desk()->desk_name() : '' ; - $reserve{'found'} = $res->is_found(); - $reserve{'inprocessing'} = $res->is_in_processing(); - $reserve{'intransit'} = $res->is_in_transit(); - } - elsif ( $res->priority() > 0 ) { - if ( my $item = $res->item() ) { - $reserve{'itemnumber'} = $item->id(); - $reserve{'barcodenumber'} = $item->barcode(); - $reserve{'item_level_hold'} = 1; + my $always_show_holds = $input->cookie('always_show_holds'); + $template->param( always_show_holds => $always_show_holds ); + my $show_holds_now = $input->param('show_holds_now'); + unless( (defined $always_show_holds && $always_show_holds eq 'DONT') && !$show_holds_now ){ + my @reserves = Koha::Holds->search( { biblionumber => $biblionumber }, { order_by => 'priority' } ); + foreach my $res ( + sort { + my $a_found = $a->found() || ''; + my $b_found = $a->found() || ''; + $a_found cmp $b_found; + } @reserves + ) + { + my %reserve; + if ( $res->is_found() ) { + $reserve{'holdingbranch'} = $res->item()->holdingbranch(); + $reserve{'biblionumber'} = $res->item()->biblionumber(); + $reserve{'barcodenumber'} = $res->item()->barcode(); + $reserve{'wbrcode'} = $res->branchcode(); + $reserve{'itemnumber'} = $res->itemnumber(); + $reserve{'wbrname'} = $res->branch()->branchname(); + $reserve{'atdestination'} = $res->is_at_destination(); + $reserve{'desk_name'} = ( $res->desk() ) ? $res->desk()->desk_name() : '' ; + $reserve{'found'} = $res->is_found(); + $reserve{'inprocessing'} = $res->is_in_processing(); + $reserve{'intransit'} = $res->is_in_transit(); + } + elsif ( $res->priority() > 0 ) { + if ( my $item = $res->item() ) { + $reserve{'itemnumber'} = $item->id(); + $reserve{'barcodenumber'} = $item->barcode(); + $reserve{'item_level_hold'} = 1; + } } - } - $reserve{'expirationdate'} = $res->expirationdate; - $reserve{'date'} = $res->reservedate; - $reserve{'borrowernumber'} = $res->borrowernumber(); - $reserve{'biblionumber'} = $res->biblionumber(); - $reserve{'patron'} = $res->borrower; - $reserve{'notes'} = $res->reservenotes(); - $reserve{'waiting_date'} = $res->waitingdate(); - $reserve{'ccode'} = $res->item() ? $res->item()->ccode() : undef; - $reserve{'barcode'} = $res->item() ? $res->item()->barcode() : undef; - $reserve{'priority'} = $res->priority(); - $reserve{'lowestPriority'} = $res->lowestPriority(); - $reserve{'suspend'} = $res->suspend(); - $reserve{'suspend_until'} = $res->suspend_until(); - $reserve{'reserve_id'} = $res->reserve_id(); - $reserve{itemtype} = $res->itemtype(); - $reserve{branchcode} = $res->branchcode(); - $reserve{non_priority} = $res->non_priority(); - $reserve{object} = $res; - - push( @reserveloop, \%reserve ); + $reserve{'expirationdate'} = $res->expirationdate; + $reserve{'date'} = $res->reservedate; + $reserve{'borrowernumber'} = $res->borrowernumber(); + $reserve{'biblionumber'} = $res->biblionumber(); + $reserve{'patron'} = $res->borrower; + $reserve{'notes'} = $res->reservenotes(); + $reserve{'waiting_date'} = $res->waitingdate(); + $reserve{'ccode'} = $res->item() ? $res->item()->ccode() : undef; + $reserve{'barcode'} = $res->item() ? $res->item()->barcode() : undef; + $reserve{'priority'} = $res->priority(); + $reserve{'lowestPriority'} = $res->lowestPriority(); + $reserve{'suspend'} = $res->suspend(); + $reserve{'suspend_until'} = $res->suspend_until(); + $reserve{'reserve_id'} = $res->reserve_id(); + $reserve{itemtype} = $res->itemtype(); + $reserve{branchcode} = $res->branchcode(); + $reserve{non_priority} = $res->non_priority(); + $reserve{object} = $res; + + push( @reserveloop, \%reserve ); + } } # get the time for the form name... -- 2.25.1