From 4550bd1241b8a398c16dca3ab987ecbdc611b326 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 12 Oct 2017 15:00:06 -0300 Subject: [PATCH] =?UTF-8?q?Bug=2019287:=20Add=20ability=20to=20mark=20an?= =?UTF-8?q?=20item=20=E2=80=98Lost=E2=80=99=20from=20=E2=80=98Holds=20awai?= =?UTF-8?q?ting=20pickup=E2=80=99=20list?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is the main patch of this new enhancement. The goal to this enhancement is to add the ability to mark items as lost from the ‘Holds awaiting pickup’ page. A new pref is added to control the behaviour, default is off To enable it, you need to set the new pref CanMarkHoldsAwaitingPickupAsLost to one of these two values: - "Allow to mark items as lost" => The item will be marked as lost and the hold will be cancelled - "Allow to mark items as lost and notify the patron" => Same as previously but the patron will be notified as well. The notification is done using a new notice template (code=CANCEL_HOLD_ON_LOST). Feel free to suggest another default wording. Test plan: You need to clearly know how this page is working currently to make sure this patch does not break existing behaviours 1/ Check 2 items out 2/ Add a hold on one of the items 3/ Add 2 holds on the other item 4/ Return the item to mark the hold as waiting 5/ From here you will be able to see entries in the "Circulation › Holds awaiting pickup" page 6/ I suggest to make a backup of this table, to avoid to repeat the previous steps. You will need to test the following steps using the different values of the pref 7/ Cancel the hold 8/ Mark the items as lost => You will receive feedback messages depending on different situations: * The CANCEL_HOLD_ON_LOST does not exist * The patron does not have an email address (but the notice has been enqueued! It is the current behaviour with other notices) * The notice has been enqueued * The hold has been cancelled QA Notes: 1/ C4::Circulation::LostItem is usually called with the second parameter set, which will mark the issue as returned. It is weird that this behaviour cannot be controlled by a pref. 2/ From which library do we want to pick the notice? This patch use reserves.branchcode --- circ/waitingreserves.pl | 41 ++++++++++++++++++++++ installer/data/mysql/atomicupdate/bug_19287.sql | 2 ++ .../prog/en/modules/circ/waitingreserves.tt | 36 +++++++++++++++++-- 3 files changed, 77 insertions(+), 2 deletions(-) diff --git a/circ/waitingreserves.pl b/circ/waitingreserves.pl index dfac75e5ba..6d10a2c5ec 100755 --- a/circ/waitingreserves.pl +++ b/circ/waitingreserves.pl @@ -72,6 +72,46 @@ my @cancel_result; if ( $op eq 'cancel_reserve' and $item) { my $res = cancel( $item, $borrowernumber, $fbr, $tbr ); push @cancel_result, $res if $res; +} elsif ( $op =~ m|^mark_as_lost| ) { + my $reserve_id = $input->param('reserve_id'); + my $hold = Koha::Holds->find( $reserve_id ); + die "wrong reserve_id" unless $hold; + if ( C4::Context->preference('CanMarkHoldsAwaitingPickupAsLost') =~ m|^yes| ) { + my $itemnumber = $hold->item->itemnumber; + my $patron = $hold->borrower; + C4::Circulation::LostItem( $itemnumber, 'MARK RETURNED' ); # FIXME Do we have to mark it returned? There is no pref for that? See other occurrences of 'LostItem(' + if ( $op eq 'mark_as_lost_and_notify' and C4::Context->preference('CanMarkHoldsAwaitingPickupAsLost') eq 'yes_and_notify' ) { + my $library = $hold->branch; + my $letter = C4::Letters::GetPreparedLetter( + module => 'reserves', + letter_code => 'CANCEL_HOLD_ON_LOST', + branchcode => $library->branchcode, # FIXME Is it what we want? + lang => $patron->lang, + tables => { + branches => $library->branchcode, + borrowers => $patron->borrowernumber, + items => $itemnumber, + biblio => $hold->biblionumber, + biblioitems => $hold->biblionumber, + reserves => $hold->unblessed, + }, + ); + if ( $letter ) { + my $admin_email_address = $library->branchemail || C4::Context->preference('KohaAdminEmailAddress'); + + C4::Letters::EnqueueLetter( + { letter => $letter, + borrowernumber => $patron->borrowernumber, + message_transport_type => 'email', + from_address => $admin_email_address, + } + ); + } + } + my $res = cancel( $itemnumber, $patron->borrowernumber, $fbr, $tbr ); + push @cancel_result, $res if $res; + }# else the url parameters have been modified and the user is not allowed to continue + } if ( C4::Context->preference('IndependentBranches') ) { @@ -103,6 +143,7 @@ foreach my $num (@getreserves) { my %getreserv = ( itemnumber => $itemnumber, borrowernum => $borrowernum, + reserve_id => $num->{reserve_id}, ); my $patron = Koha::Patrons->find( $num->{borrowernumber} ); diff --git a/installer/data/mysql/atomicupdate/bug_19287.sql b/installer/data/mysql/atomicupdate/bug_19287.sql index 5aad3d2f2c..7ae924b792 100644 --- a/installer/data/mysql/atomicupdate/bug_19287.sql +++ b/installer/data/mysql/atomicupdate/bug_19287.sql @@ -1 +1,3 @@ INSERT IGNORE INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES ('CanMarkHoldsAwaitingPickupAsLost','no','no|yes|yes_and_notify','Add a button on the "Holds awaiting pickup" screen to mark an item as lost and notify the patron.','Choice'); + +INSERT IGNORE INTO letter(module, code, branchcode, name, is_html, title, content, message_transport_type, lang) VALUES ('reserves', 'CANCEL_HOLD_ON_LOST', '', 'Hold has been cancelled', 0, "Hold has been cancelled", "Dear [% borrower.firstname %] [% borrower.surname %],\n\nWe regret to inform you that the following item cannot longer be placed on hold, it has been marked as lost\n\nTitle: [% biblio.title %]\nAuthor: [% biblio.author %]\nCopy: [% item.copynumber %]\nLocation: [% branch.branchname %]", 'email', 'default'); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt index d5678a385e..f4da1e14bd 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/waitingreserves.tt @@ -17,7 +17,8 @@ { "sType": "anti-the", "aTargets" : [ "anti-the" ] }, { "sType": "title-string", "aTargets" : [ "title-string" ] } ], - "sPaginationType": "four_button" + "sPaginationType": "four_button", + "autoWidth": true, })); }); //]]> @@ -127,6 +128,21 @@ [% END %] + [% IF Koha.Preference('CanMarkHoldsAwaitingPickupAsLost') != 'no' %] +
+ + + + + [% IF Koha.Preference('CanMarkHoldsAwaitingPickupAsLost') == 'yes' %] + + + [% ELSIF Koha.Preference('CanMarkHoldsAwaitingPickupAsLost') == 'yes_and_notify' %] + + + [% END %] +
+ [% END %] [% END %] @@ -194,7 +210,23 @@ [% ELSE %] [% END %] - + + [% IF Koha.Preference('CanMarkHoldsAwaitingPickupAsLost') != 'no' %] +
+ + + + + [% IF Koha.Preference('CanMarkHoldsAwaitingPickupAsLost') == 'yes' %] + + + [% ELSIF Koha.Preference('CanMarkHoldsAwaitingPickupAsLost') == 'yes_and_notify' %] + + + [% END %] +
+ [% END %] + [% END %] -- 2.11.0