From f4e105a487fc90725d06f389589837875adebc33 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=UTF-8 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 --- circ/returns.pl | 58 +++++++++++++++++----- installer/data/mysql/atomicupdate/bug_19383.sql | 3 ++ installer/data/mysql/sysprefs.sql | 2 + .../en/modules/admin/preferences/circulation.pref | 12 +++++ .../intranet-tmpl/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 a82bdc1..5ac8a13 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 0000000..0fd6ab3 --- /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 0e39905..fc8f4fb 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 217f48d..a7a1df1 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 @@ -478,6 +478,18 @@ Circulation: - 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: yes: Block 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 fd712f7..f99c428 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') %] @@ -709,6 +760,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.1.4