From f7fe10c6ff15fb9d980762d5082561ece882421c Mon Sep 17 00:00:00 2001 From: Kyle M Hall Date: Thu, 3 May 2018 08:23:13 -0400 Subject: [PATCH] Bug 19383: Add ability to print hold receipts automatically MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Some libraries don't wish to require librarians to confirm each hold during checkin. Instead they would like to only be alerted that a hold was filled. Test Plan: 1) Apply this patch 2) Run updatedatabase.pl 3) Enable the new syspref HoldsAutoFill 4) Check in an item that should be trapped for a hold 5) Note that instead of the modal asking if the hold should be filled, instead you get a message box showing the hold was filled, along with a button to print the hold slip. 6) Enable the new syspref HoldsAutoFillPrintSlip 7) Repeat step 4 8) Note the same behavior, but this time the print dialog displays automatically Signed-off-by: Séverine QUEUNE Signed-off-by: Katrin Fischer Signed-off-by: Nick Clemens --- circ/returns.pl | 58 ++++++++++++++----- .../data/mysql/atomicupdate/bug_19383.sql | 3 + installer/data/mysql/sysprefs.sql | 2 + .../admin/preferences/circulation.pref | 12 ++++ .../prog/en/modules/circ/returns.tt | 56 ++++++++++++++++++ 5 files changed, 118 insertions(+), 13 deletions(-) create mode 100644 installer/data/mysql/atomicupdate/bug_19383.sql diff --git a/circ/returns.pl b/circ/returns.pl index dada0c4635..8b652a61c6 100755 --- a/circ/returns.pl +++ b/circ/returns.pl @@ -415,7 +415,38 @@ if ( $messages->{'ResFound'}) { my $reserve = $messages->{'ResFound'}; my $patron = Koha::Patrons->find( $reserve->{borrowernumber} ); my $holdmsgpreferences = C4::Members::Messaging::GetMessagingPreferences( { borrowernumber => $reserve->{'borrowernumber'}, message_name => 'Hold_Filled' } ); - if ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) { + + if ( $reserve->{'ResFound'} eq "Reserved" && C4::Context->preference('HoldsAutoFill') ) { + my $item = Koha::Items->find( $itemnumber ); + my $biblio = $item->biblio; + + my $diffBranchSend = ($userenv_branch ne $reserve->{branchcode}) ? $reserve->{branchcode} : undef; + ModReserveAffect( $reserve->{itemnumber}, $reserve->{borrowernumber}, $diffBranchSend, $reserve->{reserve_id} ); + my ( $messages, $nextreservinfo ) = GetOtherReserves($reserve->{itemnumber}); + + my $patron = Koha::Patrons->find( $nextreservinfo ); + my $name = $patron ? $patron->surname . ", " . $patron->title . " " . $patron->firstname : ''; + + $template->param( + hold_auto_filled => 1, + print_slip => C4::Context->preference('HoldsAutoFillPrintSlip'), + patron => $patron, + borrowernumber => $patron->id, + biblionumber => $biblio->id, + ); + + if ( $messages->{'transfert'} ) { + $template->param( + itemtitle => $biblio->title, + itemnumber => $item->itemnumber, + itembiblionumber => $biblio->biblionumber, + iteminfo => $biblio->author, + name => $name, + diffbranch => 1, + ); + } + } + elsif ( $reserve->{'ResFound'} eq "Waiting" or $reserve->{'ResFound'} eq "Reserved" ) { if ( $reserve->{'ResFound'} eq "Waiting" ) { $template->param( waiting => ($userenv_branch eq $reserve->{'branchcode'} ? 1 : 0 ), @@ -429,19 +460,20 @@ if ( $messages->{'ResFound'}) { ); } - # same params for Waiting or Reserved - $template->param( - # FIXME The full patron object should be passed to the template - found => 1, - patron => $patron, - barcode => $barcode, - destbranch => $reserve->{'branchcode'}, - itemnumber => $reserve->{'itemnumber'}, - reservenotes => $reserve->{'reservenotes'}, - reserve_id => $reserve->{reserve_id}, - bormessagepref => $holdmsgpreferences->{'transports'}, - ); } # else { ; } # error? + + # same params for Waiting or Reserved + $template->param( + # FIXME The full patron object should be passed to the template + found => 1, + patron => $patron, + barcode => $barcode, + destbranch => $reserve->{'branchcode'}, + itemnumber => $reserve->{'itemnumber'}, + reservenotes => $reserve->{'reservenotes'}, + reserve_id => $reserve->{reserve_id}, + bormessagepref => $holdmsgpreferences->{'transports'}, + ); } # Error Messages diff --git a/installer/data/mysql/atomicupdate/bug_19383.sql b/installer/data/mysql/atomicupdate/bug_19383.sql new file mode 100644 index 0000000000..0fd6ab3f00 --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_19383.sql @@ -0,0 +1,3 @@ +INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES +('HoldsAutoFill','0',NULL,'If on, librarian will not be asked if hold should be filled, it will be filled automatically','YesNo'), +('HoldsAutoFillPrintSlip','0',NULL,'If on, hold slip print dialog will be displayed automatically','YesNo'); diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql index 80a03a7ee0..dab6b6b055 100644 --- a/installer/data/mysql/sysprefs.sql +++ b/installer/data/mysql/sysprefs.sql @@ -191,6 +191,8 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('HighlightOwnItemsOnOPAC','0','','If on, and a patron is logged into the OPAC, items from his or her home library will be emphasized and shown first in search results and item details.','YesNo'), ('HighlightOwnItemsOnOPACWhich','PatronBranch','PatronBranch|OpacURLBranch','Decides which branch\'s items to emphasize. If PatronBranch, emphasize the logged in user\'s library\'s items. If OpacURLBranch, highlight the items of the Apache var BRANCHCODE defined in Koha\'s Apache configuration file.','Choice'), ('HoldFeeMode','not_always','any_time_is_placed|not_always|any_time_is_collected','Set the hold fee mode','Choice'), +('HoldsAutoFill','0',NULL,'If on, librarian will not be asked if hold should be filled, it will be filled automatically','YesNo'), +('HoldsAutoFillPrintSlip','0',NULL,'If on, hold slip print dialog will be displayed automatically','YesNo'), ('HoldsLog','0',NULL,'If ON, log create/cancel/suspend/resume actions on holds.','YesNo'), ('HoldsQueueSkipClosed', '0', NULL, 'If enabled, any libraries that are closed when the holds queue is built will be ignored for the purpose of filling holds.', 'YesNo'), ('HoldsToPullStartDate','2',NULL,'Set the default start date for the Holds to pull list to this many days ago','Integer'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref index 217f48d3a4..a7a1df11a2 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref @@ -477,6 +477,18 @@ Circulation: no: Allow - his/her auto renewals. Checkin Policy: + - + - pref: HoldsAutoFill + choices: + yes: Do + no: "Don't" + - automatically fill holds instead of asking the librarian. + - + - pref: HoldsAutoFillPrintSlip + choices: + yes: Do + no: "Don't" + - automatically display the hold slip dialog for auto-filled holds. - - pref: BlockReturnOfWithdrawnItems choices: diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt index ff9bce63ae..5306ff2a7e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt @@ -52,6 +52,57 @@ [% IF Koha.Preference('CircSidebar') %]
[% END %]
+ [% IF hold_auto_filled %] +
+ [% IF ( reservenotes ) %] +

Notes: [% reservenotes %]

+ [% END %] +

Hold filled for:

+
  • + [% INCLUDE 'patron-title.inc' patron=patron %] + - [% patron.category.description %] +
  • + + [% INCLUDE display_holdpatron_address %] + + [% IF ( patron.phone ) %] +
  • [% patron.phone %]
  • + [% END %] + + [% IF ( patron.email ) %] +
  • + [% IF ( transfertodo ) %] + [% patron.email %] + [% ELSE %] + [% patron.email %] + [% END %] +
  • + [% END %] + + [% UNLESS ( transfertodo) %] + [% INCLUDE display_bormessagepref %] + [% END %] + + [% IF ( patron.debarred ) %] +
  • Patron is RESTRICTED
  • + [% END %] + + [% IF ( patron.gonenoaddress ) %] +
  • Patron's address is in doubt
  • + [% END %] + + [% IF ( transfertodo ) %] +

    Transfer to: [% Branches.GetName( destbranch ) %]

    + [% ELSE %] +

    Hold at [% Branches.GetName( destbranch ) %]

    + [% END %] + + + Print + +
    + [% END %] + [% IF privacy == 2 AND NOT Koha.Preference('AnonymousPatron') %]
    Error: This patron has requested their circulation history be anonymized on check-in, but the AnonymousPatron system preference is empty or incorrect.
    [% ELSIF NOT Koha.Preference('AnonymousPatron') AND Koha.Preference('OPACPrivacy') %] @@ -714,6 +765,11 @@ $(".modal").on('hidden.bs.modal', function (e) { $("#barcode").focus(); }); + $(".print-slip").on('click', function(e) { + e.preventDefault(); + Dopop('hold-transfer-slip.pl?borrowernumber=[% patron.borrowernumber %]&biblionumber=[% biblionumber %]'); + }); + [% IF print_slip %] Dopop('hold-transfer-slip.pl?borrowernumber=[% borrowernumber | html %]&biblionumber=[% biblionumber | html %]&itemnumber=[% itemnumber | html %]'); [% END %] -- 2.39.2