Bug 19383: Add ability to print hold receipts automatically
authorKyle M Hall <kyle@bywatersolutions.com>
Thu, 3 May 2018 12:23:13 +0000 (08:23 -0400)
committerNick Clemens <nick@bywatersolutions.com>
Thu, 30 Aug 2018 19:52:49 +0000 (19:52 +0000)
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 <severine.queune@bulac.fr>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

circ/returns.pl
installer/data/mysql/atomicupdate/bug_19383.sql [new file with mode: 0644]
installer/data/mysql/sysprefs.sql
koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/circulation.pref
koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt

index dada0c4..8b652a6 100755 (executable)
@@ -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 (file)
index 0000000..0fd6ab3
--- /dev/null
@@ -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');
index 80a03a7..dab6b6b 100644 (file)
@@ -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'),
index 217f48d..a7a1df1 100644 (file)
@@ -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
index ff9bce6..5306ff2 100644 (file)
 [% IF Koha.Preference('CircSidebar') %]<div class="yui-b">[% END %]
 <div class="yui-g">
 
+    [% IF hold_auto_filled %]
+        <div class="dialog alert hold-auto-filled">
+            [% IF ( reservenotes ) %]
+                <h4>Notes: [% reservenotes %]</h4>
+            [% END %]
+            <h3>Hold filled for:</h3>
+                <li>
+                    [% INCLUDE 'patron-title.inc' patron=patron %]
+                    <span class="patron-category"> - [% patron.category.description %]</span>
+                </li>
+
+                [% INCLUDE display_holdpatron_address %]
+
+                [% IF ( patron.phone ) %]
+                    <li>[% patron.phone  %]</li>
+                [% END %]
+
+                [% IF ( patron.email ) %]
+                    <li>
+                        [% IF ( transfertodo ) %]
+                            [% patron.email %]
+                        [% ELSE %]
+                            <a id="boremail" href="mailto:[% patron.email %]">[% patron.email %]</a>
+                        [% END %]
+                    </li>
+                [% END %]
+
+                [% UNLESS ( transfertodo) %]
+                    [% INCLUDE display_bormessagepref %]
+                [% END %]
+
+                [% IF ( patron.debarred ) %]
+                    <li class="error">Patron is RESTRICTED</li>
+                [% END %]
+
+                [% IF ( patron.gonenoaddress ) %]
+                    <li class="error">Patron's address is in doubt</li>
+                [% END %]
+
+            [% IF ( transfertodo ) %]
+                <h4><strong>Transfer to:</strong> [% Branches.GetName( destbranch ) %]</h4>
+            [% ELSE %]
+                <h4><strong>Hold at</strong> [% Branches.GetName( destbranch ) %]</h4>
+            [% END %]
+
+            <a href="#" class="btn btn-default print print-slip">
+                <i class="fa fa-print"></i> Print
+            </a>
+        </div>
+    [% END %]
+
 [% IF privacy == 2 AND NOT Koha.Preference('AnonymousPatron') %]
     <div class="dialog alert"><strong>Error:</strong> This patron has requested their circulation history be anonymized on check-in, but the AnonymousPatron system preference is empty or incorrect.</div>
 [% ELSIF NOT Koha.Preference('AnonymousPatron') AND Koha.Preference('OPACPrivacy') %]
 
             $(".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 %]&amp;biblionumber=[% biblionumber %]');
+            });
+
             [% IF print_slip %]
                 Dopop('hold-transfer-slip.pl?borrowernumber=[% borrowernumber | html %]&amp;biblionumber=[% biblionumber | html %]&amp;itemnumber=[% itemnumber | html %]');
             [% END %]