Bugzilla – Attachment 142106 Details for
Bug 31692
Let librarians change item level holds to record level holds when possible
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31692: Allow librarians to change hold type in staff client
Bug-31692-Allow-librarians-to-change-hold-type-in-.patch (text/plain), 6.33 KB, created by
Lari Taskula
on 2022-10-18 22:16:45 UTC
(
hide
)
Description:
Bug 31692: Allow librarians to change hold type in staff client
Filename:
MIME Type:
Creator:
Lari Taskula
Created:
2022-10-18 22:16:45 UTC
Size:
6.33 KB
patch
obsolete
>From e3b9f1c13508d782c26a95c2dd2d984d5255233a Mon Sep 17 00:00:00 2001 >From: Lari Taskula <lari.taskula@hypernova.fi> >Date: Wed, 5 Oct 2022 16:04:59 +0000 >Subject: [PATCH] Bug 31692: Allow librarians to change hold type in staff > client > >To test: >1. Apply patch >2. Add item level hold to a record/item, make sure patron has no other > holds on that record >3. Go to /cgi-bin/koha/reserve/request.pl?biblionumber=xxx where xxx is > the record you placed the hold for >4. Under "Existing holds" table, in "Details" column you should see > "Only item <barcode> X". Click the red X and click Update hold(s) >5. Observe "Only item <barcode>" has changed to "Next available" >6. Cancel the hold and add two item level holds >7. Under "Existing holds" table, in "Details" column you should see > "Only item <barcode>", but no red X for either holds. >--- > .../prog/en/includes/holds_table.inc | 9 +++++++++ > koha-tmpl/intranet-tmpl/prog/js/holds.js | 20 +++++++++++++++++++ > reserve/modrequest.pl | 18 ++++++++++++++++- > reserve/request.pl | 11 ++++++++++ > 4 files changed, 57 insertions(+), 1 deletion(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >index 536bd16484..ff162d7c86 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >@@ -175,6 +175,15 @@ > <span>No barcode</span> > [%- END -%] > </a> >+ [%- IF hold.change_hold_type_allowed -%] >+ [%- IF hold.itemtype -%] >+ <span style="display:none">Next available [% ItemTypes.GetDescription( hold.itemtype ) | html %] item</span> >+ [%- ELSE -%] >+ <span style="display:none">Next available</span> >+ [%- END -%] >+ <a id="change_hold_type_icon" href="#" class="clear_date fa fa-fw fa-remove" aria-label="Change to next available item"></a> >+ <input id="change_hold_type" type="hidden" name="changeHoldType" value="0"> >+ [%- END -%] > </em> > [%- ELSE -%] > [%- IF hold.itemtype -%] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/holds.js b/koha-tmpl/intranet-tmpl/prog/js/holds.js >index 58ecb622c2..35c2a4b716 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/holds.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/holds.js >@@ -441,4 +441,24 @@ $(document).ready(function() { > window.location.href='request.pl?action=toggleSuspend&reserve_id=' + reserve_id + '&biblionumber=' + biblionumber + '&suspend_until=' + suspend_until; > return false; > }); >+ >+ $("a#change_hold_type_icon").on('click', function(e) { >+ e.preventDefault(); >+ let change_type = $("input#change_hold_type").val(); >+ let only_item = $(this).siblings("span:first"); >+ let only_itemlink = $(this).siblings("a:first"); >+ let next_available = $(this).siblings("span:last"); >+ if (change_type==="1") { >+ $("input#change_hold_type").val("0"); >+ next_available.hide(); >+ only_itemlink.show(); >+ only_item.show(); >+ } else { >+ $("input#change_hold_type").val("1"); >+ only_itemlink.hide(); >+ only_item.hide(); >+ next_available.show(); >+ } >+ return false; >+ }); > }); >diff --git a/reserve/modrequest.pl b/reserve/modrequest.pl >index ec78f683be..83f8dfe3b5 100755 >--- a/reserve/modrequest.pl >+++ b/reserve/modrequest.pl >@@ -59,6 +59,8 @@ my $CancelBiblioNumber = $query->param('CancelBiblioNumber'); > my $CancelBorrowerNumber = $query->param('CancelBorrowerNumber'); > my $CancelItemnumber = $query->param('CancelItemnumber'); > >+my $change_hold_type = $query->param('changeHoldType'); >+ > # 2 possibilitys : cancel an item reservation, or modify or cancel the queded list > > # 1) cancel an item reservation by function ModReserveCancelAll (in reserves.pm) >@@ -94,7 +96,21 @@ else { > } else { > $_->rethrow; > } >- } >+ }; >+ >+ if ( $change_hold_type ) { >+ my $hold = Koha::Holds->find( $reserve_id[$i] ); >+ >+ try { >+ $hold->change_type; >+ } catch { >+ if ($_->isa('Koha::Exceptions::Hold::CannotChangeHoldType')){ >+ warn $_; >+ } else { >+ $_->rethrow; >+ } >+ } >+ }; > } > my @biblio_ids = uniq @biblionumber; > Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue->new->enqueue( >diff --git a/reserve/request.pl b/reserve/request.pl >index 2c28f2c58f..93abe66a4b 100755 >--- a/reserve/request.pl >+++ b/reserve/request.pl >@@ -593,6 +593,13 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) > $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 $holds_count_per_patron = { map { $_->{borrowernumber} => $_->{hold_count} } >+ @{ Koha::Holds->search( { biblionumber=> $biblionumber }, { >+ select => [ "borrowernumber", { count => { distinct => "reserve_id" } } ], >+ as => [ qw( borrowernumber hold_count ) ], >+ group_by => [ qw( borrowernumber ) ] } >+ )->unblessed >+ } }; > my @reserves = Koha::Holds->search( { biblionumber => $biblionumber }, { order_by => 'priority' } )->as_list; > foreach my $res ( > sort { >@@ -643,6 +650,10 @@ if ( ( $findborrower && $borrowernumber_hold || $findclub && $club_hold ) > $reserve{non_priority} = $res->non_priority(); > $reserve{object} = $res; > >+ if ( $holds_count_per_patron->{ $reserve{'borrowernumber'} } == 1 ) { >+ $reserve{'change_hold_type_allowed'} = 1; >+ } >+ > push( @reserveloop, \%reserve ); > } > } >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31692
:
141388
|
141390
|
142102
|
142103
|
142104
|
142106
|
142107
|
142108
|
142109
|
142114
|
142115
|
142116
|
142117
|
142118
|
142586
|
142587
|
142595
|
142596
|
142818
|
142819
|
143151
|
143160
|
143161
|
143162
|
143614
|
143615
|
143616
|
143617
|
143618
|
143619
|
143627
|
143628
|
143629