From d390b2f7cfe947011a80c9441ca0a8a00e2f38f0 Mon Sep 17 00:00:00 2001 From: Agustin Moyano Date: Wed, 19 Aug 2020 18:12:32 -0300 Subject: [PATCH] Bug 22789: Add non priority feature to C4 classes and staff interface This patch implements necesary code to implement non priority feature To test: 1) Apply all patches. 2) Run updatedatabase. 3) Checkout a specific item for patron1. 4) Place a hold on the same item for patron2 (do not check non priority hold checkbox). 5) Try to renew the item for patron1. CHECK => in checkouts table, there is a message that the item could not be renewed because there was a hold. 6) Cleanup all checkouts and holds. 7) repeat steps 3 to 5, but this time check the non priority checkbox. SUCCESS => item was renewed 8) prove t/db_dependent/Holds.t Signed-off-by: Lisette Scheer Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- C4/Circulation.pm | 2 ++ C4/Reserves.pm | 11 ++++++++--- Koha/REST/V1/Holds.pm | 2 ++ api/v1/swagger/definitions/hold.json | 4 ++++ api/v1/swagger/paths/holds.json | 10 ++++++++++ .../intranet-tmpl/prog/en/modules/reserve/request.tt | 5 +++++ reserve/placerequest.pl | 4 ++++ 7 files changed, 35 insertions(+), 3 deletions(-) diff --git a/C4/Circulation.pm b/C4/Circulation.pm index db01b57cc2..7572bd12cd 100644 --- a/C4/Circulation.pm +++ b/C4/Circulation.pm @@ -2761,6 +2761,8 @@ sub CanBookBeRenewed { my ( $resfound, $resrec, undef ) = C4::Reserves::CheckReserves($itemnumber); + $resfound = 0 if $resrec->{non_priority}; + # This item can fill one or more unfilled reserve, can those unfilled reserves # all be filled by other available items? if ( $resfound diff --git a/C4/Reserves.pm b/C4/Reserves.pm index eb1a6f88f7..f1929a6c17 100644 --- a/C4/Reserves.pm +++ b/C4/Reserves.pm @@ -185,6 +185,7 @@ sub AddReserve { my $checkitem = $params->{itemnumber}; my $found = $params->{found}; my $itemtype = $params->{itemtype}; + my $non_priority = $params->{non_priority}; $resdate = output_pref( { str => dt_from_string( $resdate ), dateonly => 1, dateformat => 'iso' }) or output_pref({ dt => dt_from_string, dateonly => 1, dateformat => 'iso' }); @@ -248,6 +249,7 @@ sub AddReserve { expirationdate => $expdate, itemtype => $itemtype, item_level_hold => $checkitem ? 1 : 0, + non_priority => $non_priority ? 1 : 0, } )->store(); $hold->set_waiting() if $found && $found eq 'W'; @@ -1656,7 +1658,8 @@ sub _Findgroupreserve { biblioitems.biblioitemnumber AS biblioitemnumber, reserves.itemnumber AS itemnumber, reserves.reserve_id AS reserve_id, - reserves.itemtype AS itemtype + reserves.itemtype AS itemtype, + reserves.non_priority AS non_priority FROM reserves JOIN biblioitems USING (biblionumber) JOIN hold_fill_targets USING (biblionumber, borrowernumber, itemnumber) @@ -1691,7 +1694,8 @@ sub _Findgroupreserve { biblioitems.biblioitemnumber AS biblioitemnumber, reserves.itemnumber AS itemnumber, reserves.reserve_id AS reserve_id, - reserves.itemtype AS itemtype + reserves.itemtype AS itemtype, + reserves.non_priority AS non_priority FROM reserves JOIN biblioitems USING (biblionumber) JOIN hold_fill_targets USING (biblionumber, borrowernumber) @@ -1725,7 +1729,8 @@ sub _Findgroupreserve { reserves.timestamp AS timestamp, reserves.itemnumber AS itemnumber, reserves.reserve_id AS reserve_id, - reserves.itemtype AS itemtype + reserves.itemtype AS itemtype, + reserves.non_priority AS non_priority FROM reserves WHERE reserves.biblionumber = ? AND (reserves.itemnumber IS NULL OR reserves.itemnumber = ?) diff --git a/Koha/REST/V1/Holds.pm b/Koha/REST/V1/Holds.pm index 09b7b7ed15..e197f32334 100644 --- a/Koha/REST/V1/Holds.pm +++ b/Koha/REST/V1/Holds.pm @@ -74,6 +74,7 @@ sub add { my $expiration_date = $body->{expiration_date}; my $notes = $body->{notes}; my $hold_date = $body->{hold_date}; + my $non_priority = $body->{non_priority}; if(!C4::Context->preference( 'AllowHoldDateInFuture' ) && $hold_date) { return $c->render( @@ -174,6 +175,7 @@ sub add { itemnumber => $item_id, found => undef, # TODO: Why not? itemtype => $item_type, + non_priority => $non_priority, } ); diff --git a/api/v1/swagger/definitions/hold.json b/api/v1/swagger/definitions/hold.json index db4c90e209..6a018e916f 100644 --- a/api/v1/swagger/definitions/hold.json +++ b/api/v1/swagger/definitions/hold.json @@ -71,6 +71,10 @@ "format": "date-time", "description": "Date until which the hold has been suspended" }, + "non_priority": { + "description": "Set this hold as non priority", + "type": "boolean" + }, "item_type": { "type": ["string", "null"], "description": "If record level hold, the optional itemtype of the item the patron is requesting" diff --git a/api/v1/swagger/paths/holds.json b/api/v1/swagger/paths/holds.json index 847d3b83ca..8137f16a7f 100644 --- a/api/v1/swagger/paths/holds.json +++ b/api/v1/swagger/paths/holds.json @@ -103,6 +103,12 @@ "description": "Suspended until", "type": "string" }, + { + "name": "non_priority", + "in": "query", + "description": "Non priority hold", + "type": "boolean" + }, { "$ref": "../parameters.json#/match" }, @@ -201,6 +207,10 @@ "item_type": { "description": "Limit hold on one itemtype (ignored for item-level holds)", "type": [ "string", "null" ] + }, + "non_priority": { + "description": "Set this hold as non priority", + "type": [ "boolean", "null" ] } }, "required": [ "patron_id", "pickup_library_id" ] 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 f0832ffc37..820543d509 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -476,6 +476,11 @@ [% END %] [% END # /UNLESS multi_hold %] + +
  • + + +
  • [% UNLESS ( multi_hold ) %] diff --git a/reserve/placerequest.pl b/reserve/placerequest.pl index 0b4a12c206..ea81592ef0 100755 --- a/reserve/placerequest.pl +++ b/reserve/placerequest.pl @@ -52,6 +52,7 @@ my $title = $input->param('title'); my $checkitem = $input->param('checkitem'); my $expirationdate = $input->param('expiration_date'); my $itemtype = $input->param('itemtype') || undef; +my $non_priority = $input->param('non_priority'); my $borrower = Koha::Patrons->find( $borrowernumber ); $borrower = $borrower->unblessed if $borrower; @@ -114,6 +115,7 @@ if ( $type eq 'str8' && $borrower ) { itemnumber => $checkitem, found => $found, itemtype => $itemtype, + non_priority => $non_priority, } ); @@ -135,6 +137,7 @@ if ( $type eq 'str8' && $borrower ) { itemnumber => $checkitem, found => $found, itemtype => $itemtype, + non_priority => $non_priority, } ); } @@ -155,6 +158,7 @@ if ( $type eq 'str8' && $borrower ) { itemnumber => $checkitem, found => $found, itemtype => $itemtype, + non_priority => $non_priority, } ); } -- 2.39.5