Bug 20421: Inform staff that patron does have the title checked out during placing...
authorJosef Moravec <josef.moravec@gmail.com>
Tue, 13 Mar 2018 14:57:49 +0000 (14:57 +0000)
committerNick Clemens <nick@bywatersolutions.com>
Mon, 29 Apr 2019 13:35:35 +0000 (13:35 +0000)
Test plan:
1) Enable the CheckPrevCheckout and DisplayMultiPlaceHold system preferences
2) Have a patron with some checkouts history
3) Try to place hold on one of titles from history for this patron
4) You should see an information at the top of confirm request page, but
you still should be able to place a hold
5) Try this with multiple titles - one or more of them should be from
history
6) You should see this information in "Information" column
7) There is also new column placed at the beggining with checkbox, you
could uncheck it for titles you do not want to place a hold on it
8) Confirm the hold is placed only on checked titles

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Signed-off-by: Bin Wen <bin.wen@inlibro.com>

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

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

koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt
reserve/request.pl

index c18ea10..0c51499 100644 (file)
     </form>
   [% ELSIF NOT noitems %]
 
+[% IF ( checked_previously && !multi_hold ) %]
+<div class="dialog alert">
+  <ul>
+    <li>Patron has previously checked out this title</li>
+  </ul>
+</div>
+[% END %]
+
 [% IF ( exceeded_maxreserves || exceeded_holds_per_record || alreadyreserved || none_available || alreadypossession || ageRestricted ) %]
     <div class="dialog alert">
 
 
     <table id="requesttitles">
       <tr>
+        <th>&nbsp;</th>
         <th>Title</th>
         [% UNLESS ( item_level_itypes ) %]
           <th>Item type</th>
           <tr>
         [% END %]
           <td>
+            [% UNLESS ( biblioloo.warn ) %]
+              <input class="multi_hold_item_checkbox" type="checkbox" checked="checked" title="[% biblioloo.biblionumber | html %]"/></td>
+            [% END %]
+            <td>
             <ul>
               <li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% biblioloo.biblionumber | uri %]">[% biblioloo.title | html %]</a></li>
               [% IF ( biblioloo.publicationyear ) %]
                 <li><span class="label">Publication year:</span> [% biblioloo.publicationyear | html %]</li>
               [% END %]
             </ul>
-            [% UNLESS ( biblioloo.warn ) %]
-              <span class="multi_hold_item" title="[% biblioloo.biblionumber | html %]"></span>
-            [% ELSE %]
+            [% IF ( biblioloo.warn ) %]
               <span class="not_holdable" title="[% biblioloo.biblionumber | html %]"></span>
             [% END %]
           </td>
           [% END %]
             <td>[% biblioloo.rank | html %]</td>
           <td>
+            [% IF ( biblioloo.checked_previously ) %]
+              <span class="alert">Patron has previously checked out this title</span><br/>
+            [% END %]
             [% IF ( biblioloo.alreadyres ) %]
               <ul>
             [% ELSE %]
             [% ELSIF ( none_available ) %]
                 <input type="submit" disabled="disabled" value="Place hold" />
             [% ELSE %]
-                <input type="submit" value="Place hold" />
+                [% IF ( multi_hold ) %]
+                    <input type="submit" value="Place hold" id="multi_hold_submit"/>
+                [% ELSE %]
+                    <input type="submit" value="Place hold" />
+                [% END %]
             [% END %]
         [% END %]
     </fieldset>
         }
 
         function checkMultiHold() {
-            var spans = $(".multi_hold_item");
+            var spans = $(".multi_hold_item_checkbox:checked");
             if ($(spans).size() == 0) {
                 alert(MSG_NO_ITEMS_AVAILABLE);
                 return false;
index 486c770..df9cae8 100755 (executable)
@@ -144,6 +144,7 @@ if ( $biblionumbers ) {
     push @biblionumbers, $input->multi_param('biblionumber');
 }
 
+my $multihold = scalar $input->param('multi_hold');
 # FIXME multi_hold should not be a variable but depends on the number of elements in @biblionumbers
 $template->param(multi_hold => scalar $input->param('multi_hold'));
 
@@ -209,6 +210,10 @@ my $patron = Koha::Patrons->find( $borrowernumber_hold );
 
 my $logged_in_patron = Koha::Patrons->find( $borrowernumber );
 
+my $wants_check;
+if ($patron) {
+    $wants_check = $patron->wants_check_for_previous_checkout;
+}
 my $itemdata_enumchron = 0;
 my $itemdata_ccode = 0;
 my @biblioloop = ();
@@ -374,7 +379,18 @@ foreach my $biblionumber (@biblionumbers) {
 
         foreach my $itemnumber ( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} } )    {
             my $item = $iteminfos_of->{$itemnumber};
-
+            my $do_check;
+            if ( $patron ) {
+                $do_check = $patron->do_check_for_previous_checkout($item) if $wants_check;
+                if ( $do_check && $wants_check ) {
+                    $item->{checked_previously} = $do_check;
+                    if ( $multihold ) {
+                        $biblioloopiter{checked_previously} = $do_check;
+                    } else {
+                        $template->param( checked_previously => $do_check );
+                    }
+                }
+            }
             $item->{force_hold_level} = $force_hold_level;
 
             unless (C4::Context->preference('item-level_itypes')) {