Bugzilla – Attachment 106442 Details for
Bug 19889
LocalHoldsPriority needs exclusions
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 19889: Make it possible to exclude items and categories from local holds priority
Bug-19889-Make-it-possible-to-exclude-items-and-ca.patch (text/plain), 15.32 KB, created by
ByWater Sandboxes
on 2020-06-30 18:39:39 UTC
(
hide
)
Description:
Bug 19889: Make it possible to exclude items and categories from local holds priority
Filename:
MIME Type:
Creator:
ByWater Sandboxes
Created:
2020-06-30 18:39:39 UTC
Size:
15.32 KB
patch
obsolete
>From 4f333bbead8b9de0130e9175aff6f3a06f4fcf6c Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Wed, 10 Jun 2020 16:18:01 -0300 >Subject: [PATCH] Bug 19889: Make it possible to exclude items and categories > from local holds priority > >This patch adds the ability to exclude patrons (by category) from local >holds, and items, by editing the item itself or by batch item >modification tool. > >To test: >1. apply patches >2. updatedatabase >3. Enable LocalHoldsPriority preference, and leave > LocalHoldsPriorityPatronControl in pickup library, and >LocalHoldsPriorityItemControl in holding library. >4. Search for a biblio with one item. >5. Place a hold with a patron (patron1) and set pickup location to a different > library of the item's home library >6. Place another hold with another patron (patron2) and set pickup location to be > the same as the item's home library >7. ./misc/cronjobs/holds/build_holds_queue.pl >8. Go to circulation -> holds queue >9. Search by the item's home library >CHECK => only the hold for patron2 (with the pickup location the same as the >item's home library) appears in the table >10. Go back to the biblio details page and click on "Items" tab >CHECK => There is a new section in the item's details between "Statuses" >and "History" called "Priority" >11. Set exclude to "Yes" and update >12. repeat steps 7 to 9 >SUCCESS => only the hold for patron1 now appears, even the other hold had local >hold priority >13. Repeat step 10 and 11 but this time set exclude to "No" >14. repeat steps 7 to 9 >CHECK => the hold for patron2 is back >15. Edit patron2's category and set exclude from local holds priority to > "Yes" >16. Repeat steps 7 to 9 >SUCCESS => the hold for patron1 is back >17. Go to tools -> Batch item modification and in barcode list place > several (existing) barcodes and press continue >CHECK => There is a new section in the bottom called "Priority" >18. Set exclude to "Yes" and save >SUCCESS => all items in the list now have exclude setted to "Yes" >19. Try to checkout the first item to a patron3 >SUCCESS => Alert message appears saying that patron1 has a hold on that >item >20. Click on Yes and then checkin that item >SUCCESS => There is a modal window saying that a hold was found for >patron1 >21. prove t/db_dependent/HoldsQueue.t t/db_dependent/Holds/LocalHoldsPriority.t >22. Sign off > >Sponsored-by: Cooperative Information Network (CIN) > >Signed-off-by: Christopher Brannon <cbrannon@cdalibrary.org> >--- > C4/HoldsQueue.pm | 5 +++- > C4/Reserves.pm | 24 +++++++++-------- > admin/categories.pl | 3 +++ > catalogue/updateitem.pl | 3 +++ > .../prog/en/modules/admin/categories.tt | 13 ++++++++++ > .../prog/en/modules/catalogue/moredetail.tt | 30 ++++++++++++++++++++-- > .../prog/en/modules/tools/batchMod-edit.tt | 15 +++++++++++ > tools/batchMod.pl | 2 ++ > 8 files changed, 81 insertions(+), 14 deletions(-) > >diff --git a/C4/HoldsQueue.pm b/C4/HoldsQueue.pm >index 339156a5eb..920c1d0b8e 100755 >--- a/C4/HoldsQueue.pm >+++ b/C4/HoldsQueue.pm >@@ -401,13 +401,16 @@ sub MapItemsToHoldRequests { > > foreach my $request (@$hold_requests) { > last if $num_items_remaining == 0; >+ my $patron = Koha::Patrons->find($request->{borrowernumber}); >+ next if $patron->category->exclude_from_local_holds_priority; > > my $local_hold_match; > foreach my $item (@$available_items) { > next > if ( !$item->{holdallowed} ) > || ( $item->{holdallowed} == 1 >- && $item->{homebranch} ne $request->{borrowerbranch} ); >+ && $item->{homebranch} ne $request->{borrowerbranch} >+ || $item->{_object}->exclude_from_local_holds_priority ); > > next if $request->{itemnumber} && $request->{itemnumber} != $item->{itemnumber}; > >diff --git a/C4/Reserves.pm b/C4/Reserves.pm >index 2c17d53235..895f28cb24 100644 >--- a/C4/Reserves.pm >+++ b/C4/Reserves.pm >@@ -831,17 +831,19 @@ sub CheckReserves { > $patron = Koha::Patrons->find( $res->{borrowernumber} ); > $item = Koha::Items->find($itemnumber); > >- my $local_holds_priority_item_branchcode = >- $item->$LocalHoldsPriorityItemControl; >- my $local_holds_priority_patron_branchcode = >- ( $LocalHoldsPriorityPatronControl eq 'PickupLibrary' ) >- ? $res->{branchcode} >- : ( $LocalHoldsPriorityPatronControl eq 'HomeLibrary' ) >- ? $patron->branchcode >- : undef; >- $local_hold_match = >- $local_holds_priority_item_branchcode eq >- $local_holds_priority_patron_branchcode; >+ unless ($item->exclude_from_local_holds_priority || $patron->category->exclude_from_local_holds_priority) { >+ my $local_holds_priority_item_branchcode = >+ $item->$LocalHoldsPriorityItemControl; >+ my $local_holds_priority_patron_branchcode = >+ ( $LocalHoldsPriorityPatronControl eq 'PickupLibrary' ) >+ ? $res->{branchcode} >+ : ( $LocalHoldsPriorityPatronControl eq 'HomeLibrary' ) >+ ? $patron->branchcode >+ : undef; >+ $local_hold_match = >+ $local_holds_priority_item_branchcode eq >+ $local_holds_priority_patron_branchcode; >+ } > } > > # See if this item is more important than what we've got so far >diff --git a/admin/categories.pl b/admin/categories.pl >index f9144e7ced..8fdc293cb4 100755 >--- a/admin/categories.pl >+++ b/admin/categories.pl >@@ -94,6 +94,7 @@ elsif ( $op eq 'add_validate' ) { > my $default_privacy = $input->param('default_privacy'); > my $reset_password = $input->param('reset_password'); > my $change_password = $input->param('change_password'); >+ my $exclude_from_local_holds_priority = $input->param('exclude_from_local_holds_priority'); > my @branches = grep { $_ ne q{} } $input->multi_param('branches'); > > $reset_password = undef if $reset_password eq -1; >@@ -129,6 +130,7 @@ elsif ( $op eq 'add_validate' ) { > $category->default_privacy($default_privacy); > $category->reset_password($reset_password); > $category->change_password($change_password); >+ $category->exclude_from_local_holds_priority($exclude_from_local_holds_priority); > eval { > $category->store; > $category->replace_branch_limitations( \@branches ); >@@ -157,6 +159,7 @@ elsif ( $op eq 'add_validate' ) { > default_privacy => $default_privacy, > reset_password => $reset_password, > change_password => $change_password, >+ exclude_from_local_holds_priority => $exclude_from_local_holds_priority, > }); > eval { > $category->store; >diff --git a/catalogue/updateitem.pl b/catalogue/updateitem.pl >index f8295a0314..9d112166d4 100755 >--- a/catalogue/updateitem.pl >+++ b/catalogue/updateitem.pl >@@ -40,6 +40,7 @@ my $itemnotes=$cgi->param('itemnotes'); > my $itemnotes_nonpublic=$cgi->param('itemnotes_nonpublic'); > my $withdrawn=$cgi->param('withdrawn'); > my $damaged=$cgi->param('damaged'); >+my $exclude_from_local_holds_priority = $cgi->param('exclude_from_local_holds_priority'); > > my $confirm=$cgi->param('confirm'); > my $dbh = C4::Context->dbh; >@@ -71,6 +72,8 @@ elsif ( $op eq "set_public_note" ) { # i.e., itemnotes parameter passed from for > $item->itemlost($itemlost); > } elsif ( $op eq "set_withdrawn" && $withdrawn ne $item_data_hashref->{'withdrawn'}) { > $item->withdrawn($withdrawn); >+} elsif ( $op eq "set_exclude_priority" && $exclude_from_local_holds_priority ne $item_data_hashref->{'exclude_from_local_holds_priority'}) { >+ $item->exclude_from_local_holds_priority($exclude_from_local_holds_priority); > } elsif ( $op eq "set_damaged" && $damaged ne $item_data_hashref->{'damaged'}) { > $item->damaged($damaged); > } else { >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt >index 77146a78db..8f39dbfe82 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/categories.tt >@@ -297,6 +297,19 @@ > </select> > <span>Controls how long a patrons checkout history is kept for new patrons of this category. "Never" anonymizes checkouts on return, and "Forever" keeps a patron's checkout history indefinitely. When set to "Default", the amount of history kept is controlled by the cronjob <i>batch_anonymise.pl</i> which should be set up by your system administrator.</span> > </li> >+ <li> >+ <label for="exclude_from_local_holds_priority">Exclude from local holds priority:</label> >+ <select id="exclude_from_local_holds_priority" name="exclude_from_local_holds_priority"> >+ [% IF category.exclude_from_local_holds_priority %] >+ <option value="1" selected>Yes</option> >+ <option value="0">No</option> >+ [% ELSE %] >+ <option value="1">Yes</option> >+ <option value="0" selected>No</option> >+ [% END %] >+ </select> >+ <span>If <i>Yes</i>, holds placed by patrons of this category will not be given priority</span> >+ </li> > </ol> > </fieldset> > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >index 62352fc4cd..b7cfba2d84 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/moredetail.tt >@@ -8,7 +8,7 @@ > [% INCLUDE 'doc-head-open.inc' %] > <title>Koha › Catalog › Item details for [% INCLUDE 'biblio-title-head.inc' %]</title> > [% INCLUDE 'doc-head-close.inc' %] >-<style>h3{padding-top: 1em; border-top: 2px solid #CCCCCC;}#exportLabelexportModal_{border-top: 0px;}</style> >+<style>h3{padding-top: 1em; border-top: 2px solid #CCCCCC; clear: both}#exportLabelexportModal_{border-top: 0px;}</style> > </head> > <body id="catalog_moredetail" class="catalog"> > [% USE KohaDates %] >@@ -43,7 +43,7 @@ > [% IF ( volumeddesc ) %]<li><span class="label">Volume:</span> [% volumeddesc | html %]</li>[% END %] > <li><span class="label">Physical details:</span> [% pages | html %] [% illus | html %] [% size | html %] </li> > [% IF ( bnotes ) %]<li><span class="label">Notes:</span> [% bnotes | html %]</li>[% END %] >- <li><span class="label">No. of items:</span> [% count | html %] [% IF ( hiddencount ) %]total ([% showncount | html %] shown / [% hiddencount | html %] hidden) >+ <li><span class="label">No. of items:</span> [% count | html %] [% IF ( hiddencount ) %]total ([% showncount | html %] shown / [% hiddencount | html %] hidden) > <a href="/cgi-bin/koha/catalogue/moredetail.pl?biblionumber=[% biblionumber | uri %]&showallitems=1">Show all items</a>[% END %]</li> > </ol> > </div> >@@ -205,6 +205,32 @@ > [% END %] > > </ol></div></div> >+ >+ <div class="listgroup"><h4>Priority</h4> >+ <div class="rows"> >+ <ol class="bibliodetails"> >+ <li> >+ <span class="label">Exclude from local holds priority:</span> >+ <form action="updateitem.pl" method="post"> >+ <input type="hidden" name="biblionumber" value="[% ITEM_DAT.biblionumber | html %]" /> >+ <input type="hidden" name="biblioitemnumber" value="[% ITEM_DAT.biblioitemnumber | html %]" /> >+ <input type="hidden" name="itemnumber" value="[% ITEM_DAT.itemnumber | html %]" /> >+ <select id="exclude_from_local_holds_priority" name="exclude_from_local_holds_priority"> >+ [% IF ITEM_DAT.exclude_from_local_holds_priority %] >+ <option value="1" selected>Yes</option> >+ <option value="0">No</option> >+ [% ELSE %] >+ <option value="1">Yes</option> >+ <option value="0" selected>No</option> >+ [% END %] >+ </select> >+ <input type="hidden" name="op" value="set_exclude_priority" /> >+ <input type="submit" name="submit" class="submit" value="Update" /></form> >+ </li> >+ </ol> >+ </div> >+ </div> >+ > <div class="listgroup"><h4>History</h4> > <div class="rows"> > <ol class="bibliodetails"> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt >index 283ef381ef..863a3a23fd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-edit.tt >@@ -335,6 +335,21 @@ $(document).ready(function(){ > [% END %] > </ol> > </fieldset> >+ <fieldset class="rows"> >+ <legend>Priority</legend> >+ <ol> >+ <li> >+ <div class="subfield_line"> >+ <label for="exclude_from_local_holds_priority">Exclude from local holds priority:</label> >+ <select id="exclude_from_local_holds_priority" name="exclude_from_local_holds_priority" class="input_marceditor" style="width: 50px"> >+ <option selected></option> >+ <option value="1">Yes</option> >+ <option value="0">No</option> >+ </select> >+ </div> >+ </li> >+ </ol> >+ </fieldset> > <fieldset class="action"> > <div id="jobpanel"> > <div id="jobstatus" class="progress_panel">Job progress: <div id="jobprogress"></div> <span id="jobprogresspercent">0</span>%</div> >diff --git a/tools/batchMod.pl b/tools/batchMod.pl >index fe40f84c7e..672d1d5ded 100755 >--- a/tools/batchMod.pl >+++ b/tools/batchMod.pl >@@ -57,6 +57,7 @@ my $completedJobID = $input->param('completedJobID'); > my $runinbackground = $input->param('runinbackground'); > my $src = $input->param('src'); > my $use_default_values = $input->param('use_default_values'); >+my $exclude_from_local_holds_priority = $input->param('exclude_from_local_holds_priority'); > > my $template_name; > my $template_flag; >@@ -230,6 +231,7 @@ if ($op eq "action") { > } > } > else { >+ $item->exclude_from_local_holds_priority($exclude_from_local_holds_priority)->store if defined $exclude_from_local_holds_priority; > if ( $values_to_modify || $values_to_blank ) { > my $localmarcitem = Item2Marc($itemdata); > my $modified = 0; >-- >2.11.0
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 19889
:
105715
|
105716
|
105717
|
105718
|
106435
|
106436
|
106437
|
106438
|
106439
|
106440
|
106441
|
106442
|
107180
|
107187
|
107188
|
107189
|
107190
|
107191
|
107192
|
107193
|
107194
|
107195
|
107196
|
107908
|
107909
|
107910
|
107911
|
107912
|
107913
|
107926
|
107927
|
107928
|
107929
|
107930
|
107931
|
107948
|
108213
|
108214
|
108215
|
108216
|
108217
|
108218
|
108219
|
108220
|
108593
|
108594
|
108595
|
108725
|
108726
|
108728
|
109131
|
109132
|
109285
|
109364
|
109419