From 81a948c3470ca28bfd1fd38f7349b2060790c54c 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 --- .../prog/en/modules/reserve/request.tt | 16 ++- reserve/request.pl | 127 +++++++++--------- 2 files changed, 81 insertions(+), 62 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 f54ac0d32a..4d36b6cb78 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -881,12 +881,19 @@ [% END %] [% UNLESS ( patron ) %] + + + [% IF always_show_holds == 'DONT' %] + + Show holds + [% ELSE %] + + [% END %] [% IF ( reserveloop ) %]
[% IF ( multi_hold ) %] [% END %] -

Existing holds

@@ -1460,6 +1467,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 6ab8ba7ac5..0dadec6ce6 100755 --- a/reserve/request.pl +++ b/reserve/request.pl @@ -648,70 +648,75 @@ foreach my $biblionumber (@biblionumbers) { # 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 $priority = $res->priority(); - my %reserve; - my @optionloop; - for ( my $i = 1 ; $i <= $totalcount ; $i++ ) { - push( - @optionloop, - { - num => $i, - selected => ( $i == $priority ), - } - ); - } + 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 $priority = $res->priority(); + my %reserve; + my @optionloop; + for ( my $i = 1 ; $i <= $totalcount ; $i++ ) { + push( + @optionloop, + { + num => $i, + selected => ( $i == $priority ), + } + ); + } - 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; + 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{'optionloop'} = \@optionloop; - $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{'optionloop'} = \@optionloop; + $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.20.1