Bug 25261: Require confirmation of multiple parts items
authorMartin Renvoize <martin.renvoize@ptfs-europe.com>
Wed, 5 Aug 2015 12:52:09 +0000 (13:52 +0100)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 1 Oct 2020 08:33:10 +0000 (10:33 +0200)
Test plan
1/ Catalogue an item to contain multiple parts by populating 'Materials
specified (bound volume or other part)'
2/ Enable the new system preference 'CircConfirmParts'
3/ Attempt to checkout the item created in step 1 to a user and note
that confirmation is now required.
4/ Checkout the item
5/ Attempt to checkin the item you have just checked out and note that
confirmation is required.
6/ Signoff

Sponsored-by: Royal College of Music [https://www.rcm.ac.uk/]
Sponsored-by: PTFS Europe [https://ptfs-europe.com/]
Signed-off-by: Frédéric Demians <f.demians@tamil.fr>
Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
C4/Circulation.pm
circ/returns.pl
koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt
koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt

index ed2b43f..cf638ab 100644 (file)
@@ -897,6 +897,12 @@ sub CanBookBeIssued {
         }
     }
 
+    # Additional Materials Check
+    my $no_of_parts = $item_object->materials;
+    if ( $no_of_parts > 0 ) {
+        $needsconfirmation{additional_materials} = $no_of_parts;
+    }
+
     #
     # CHECK IF BOOK ALREADY ISSUED TO THIS BORROWER
     #
index a7556c7..01efe87 100755 (executable)
@@ -271,18 +271,18 @@ if ($barcode) {
         my $checkout = $item->checkout;
         my $biblio   = $item->biblio;
         $template->param(
-            title            => $biblio->title,
-            homebranch       => $item->homebranch,
-            holdingbranch    => $item->holdingbranch,
-            returnbranch     => $returnbranch,
-            author           => $biblio->author,
-            itembarcode      => $item->barcode,
-            itemtype         => $item->effective_itemtype,
-            ccode            => $item->ccode,
-            itembiblionumber => $biblio->biblionumber,
-            biblionumber     => $biblio->biblionumber,
+            title                => $biblio->title,
+            homebranch           => $item->homebranch,
+            holdingbranch        => $item->holdingbranch,
+            returnbranch         => $returnbranch,
+            author               => $biblio->author,
+            itembarcode          => $item->barcode,
+            itemtype             => $item->effective_itemtype,
+            ccode                => $item->ccode,
+            itembiblionumber     => $biblio->biblionumber,
+            biblionumber         => $biblio->biblionumber,
             additional_materials => $materials,
-            issue            => $checkout,
+            issue                => $checkout,
         );
     } # FIXME else we should not call AddReturn but set BadBarcode directly instead
 
@@ -294,9 +294,18 @@ if ($barcode) {
 
     my $return_date = $dropboxmode ? $dropboxdate : $return_date_override_dt;
 
+    # Block return if multi-part and confirm has not been received
+    my $needs_confirm = 0;
+    if ( C4::Context->preference("CircConfirmParts") ) {
+        if ( $item->materials > 0 && !$query->param('multiple_confirm') ) {
+                $needs_confirm = 1;
+        }
+    }
+
     # do the return
     ( $returned, $messages, $issue, $borrower ) =
-      AddReturn( $barcode, $userenv_branch, $exemptfine, $return_date );
+      AddReturn( $barcode, $userenv_branch, $exemptfine, $return_date )
+      unless $needs_confirm;
 
     if ($returned) {
         my $time_now = dt_from_string()->truncate( to => 'minute');
@@ -337,13 +346,17 @@ if ($barcode) {
                 );
             }
         }
-    } elsif ( C4::Context->preference('ShowAllCheckins') and !$messages->{'BadBarcode'} ) {
+    } elsif ( C4::Context->preference('ShowAllCheckins') and !$messages->{'BadBarcode'} and !$needs_confirm ) {
         $input{duedate}   = 0;
         $returneditems{0} = $barcode;
         $riduedate{0}     = 0;
         push( @inputloop, \%input );
     }
     $template->param( privacy => $borrower->{privacy} );
+
+    if ( $needs_confirm ) {
+        $template->param( needs_confirm => $needs_confirm );
+    }
 }
 $template->param( inputloop => \@inputloop );
 
index 1a0afc2..851b370 100644 (file)
@@ -82,7 +82,7 @@
 
                     [% IF ( NEEDSCONFIRMATION ) %]
                         <div id="circ_needsconfirmation" class="dialog alert audio-alert-action">
-                            [% IF CAN_user_circulate_force_checkout %]
+                            [% IF CAN_user_circulate_force_checkout or additional_materials %]
                                 <h3>Please confirm checkout</h3>
                             [% ELSE %]
                               <h3>Cannot check out</h3>
@@ -98,6 +98,7 @@
                                     </li>
                                 [% END %]
 
+
                                 [% IF ( DEBT ) %]
                                     <li>The patron has a debt of [% DEBT | $Price %].</li>
                                 [% END %]
                                         [% END %]
                                     </li>
                                 [% END %]
+
+                                [% IF additional_materials %]
+                                    <li>
+                                        Please confirm that the accompanying materials are present: [% additional_materials | html %]
+                                    </li>
+                                [% END %]
                             </ul>
 
                             [% IF CAN_user_circulate_force_checkout or HIGHHOLDS %]
index 8293979..0790f66 100644 (file)
                                 </div>
                             [% END %]
 
-                            [% IF additional_materials %]
-                                <div class="dialog message" id="materials">
-                                    Note about the accompanying materials: <br />
-                                    [% additional_materials | html %]
+                            [% IF needs_confirm %]
+                                <div id="circ_needsconfirmation" class="dialog alert audio-alert-action">
+                                    <h3>Please confirm checkin</h3>
+                                    <ul>
+                                        [% IF additional_materials %]
+                                        <li>
+                                        Please confirm that the accompanying materials are present: [% additional_materials | html %]
+                                        </li>
+                                        [% END %]
+                                    </ul>
+
+                                    <form method="post" action="/cgi-bin/koha/circ/returns.pl" autocomplete="off">
+                                        <input type="hidden" name="barcode" value="[% itembarcode | html %]" />
+
+                                        [% IF additional_materials %]
+                                        <input type="hidden" name="multiple_confirm" value="1" />
+                                        [% END %]
+
+                                        <button type="submit" class="approve" accesskey="y"><i class="fa fa-check"></i> Yes, checkin (Y)</button>
+                                        <button type="submit" class="deny" accesskey="n"><i class="fa fa-times"></i> No, don't checkin (N)</button>
+                                    </form>
+                                </div>
+                            [% ELSE %]
+                                [% IF additional_materials %]
+                                <div class="dialog alert">
+                                    <ul>
+                                        <li>
+                                        Note about the accompanying materials: [% additional_materials | html %]
+                                        </li>
+                                    </ul>
                                 </div>
+                                [% END %]
                             [% END %]
 
                             [% IF ( collectionItemNeedsTransferred ) %]