Bug 22330: Transfer limits should be respected for placing holds in staff interface...
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / reserve / request.tt
index 18dd63e..fd7571e 100644 (file)
@@ -5,6 +5,8 @@
 [% USE Branches %]
 [% USE Categories %]
 [% USE ItemTypes %]
+[% USE AuthorisedValues %]
+[% USE Price %]
 [% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 [% UNLESS ( multi_hold ) %]
@@ -13,7 +15,6 @@
     <title>Koha &rsaquo; Circulation &rsaquo; Holds &rsaquo; Confirm holds</title>
 [% END %]
 [% INCLUDE 'doc-head-close.inc' %]
-[% Asset.css("css/datatables.css") | $raw %]
 </head>
 
 <body id="circ_request" class="catalog">
@@ -68,7 +69,7 @@
         [% UNLESS borrowers %]
                 <label for="patron">Patron: </label>
                 <div class="hint">Enter patron card number or partial name:</div>
-                <input type="text" size="40" id="patron" class="focus" name="findborrower" />
+                <input type="text" size="40" id="patron" class="focus" name="findborrower" autocomplete="off" />
                 <input type="submit" value="Search" />
             [% IF multi_hold %]
                 <input type="hidden" name="multi_hold" value="[% multi_hold | html %]"/>
     [% END %]
 
     [% IF amount_outstanding && Koha.Preference('maxoutstanding') && amount_outstanding > Koha.Preference('maxoutstanding') %]
-    <li><a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a>: <strong>Patron has outstanding fines: [% amount_outstanding | format('%.2f') %]</strong></li>
+    <li><a href="/cgi-bin/koha/members/pay.pl?borrowernumber=[% patron.borrowernumber | uri %]">[% patron.firstname | html %] [% patron.surname | html %]</a>: <strong>Patron has outstanding fines: [% amount_outstanding | $Price %]</strong></li>
     [% END %]
 
     [% IF ( diffbranch ) %]
         <li>
             <label for="pickup">Pickup at:</label>
             <select name="pickup" size="1" id="pickup">
-                [% PROCESS options_for_libraries libraries => Branches.all({ search_params => { pickup_location => 1 } }) %]
+                [% PROCESS options_for_libraries libraries => Branches.all({ selected => pickup, search_params => { pickup_location => 1 } }) %]
             </select>
         </li>
 
                     <th>Barcode</th>
                     <th>Home library</th>
                     <th>Last location</th>
+                [% IF itemdata_ccode %]
+                    <th>Collection</th>
+                [% END %]
                     <th>Call no.</th>
                     <th>Copy number</th>
                 [% IF itemdata_enumchron %]
                                 Patron is from different library
                             [% ELSIF itemloo.not_holdable == 'itemAlreadyOnHold' %]
                                 Patron already has hold for this item
+                            [% ELSIF itemloo.not_holdable == 'cannotBeTransferred' %]
+                                Cannot be transferred to pickup library
                             [% ELSE %]
                                 [% itemloo.not_holdable | html %]
                             [% END %]
                     <td>
                         [% Branches.GetName( itemloo.holdingbranch ) | html %]
                     </td>
+                [% IF itemdata_ccode %]
+                    <td>
+                        [% IF ( itemloo.ccode ) %][% AuthorisedValues.GetByCode( 'CCODE', itemloo.ccode ) | html %][% END %]
+                    </td>
+                [% END %]
                     <td>
                         [% itemloo.itemcallnumber | html %]
                     </td>
                 [% END %]
                     <td>
                 [% IF ( itemloo.onloan ) %]
-                    <span title="[% itemloo.date_due | html %]" class="checkedout">Due [% itemloo.date_due | $KohaDates as_due_date => 1 | html %]</span>
+                    <span title="[% itemloo.date_due | html %]" class="checkedout">Due [% itemloo.date_due | $KohaDates  as_due_date => 1 %]</span>
                 [% ELSE %]
                     <span title="0000-00-00">
                         [% IF ( itemloo.transfertwhen ) %]
                             [% SET branchcodes = [] %]
 
                             [% FOREACH h IN biblioloo.reserveloop %]
-                                [% branchcodes.push( h.branchcode ) | $raw %]
+                                [% branchcodes.push( h.branchcode ) %]
                             [% END %]
                             [% branchcodes = branchcodes.unique %]
 
                                 [% SET holds_by_branch = [] %]
                                 [% FOREACH h IN biblioloo.reserveloop %]
                                     [% IF h.branchcode == b %]
-                                        [% holds_by_branch.push( h ) | $raw %]
+                                        [% holds_by_branch.push( h ) %]
                                     [% END %]
                                 [% END %]
                                 <fieldset>
 
                             [% FOREACH h IN biblioloo.reserveloop %]
                                 [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
-                                [% itemtypes.push( hold_itemtype ) | $raw %]
+                                [% itemtypes.push( hold_itemtype ) %]
                             [% END %]
                             [% itemtypes = itemtypes.unique %]
 
                                 [% FOREACH h IN biblioloo.reserveloop %]
                                     [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
                                     [% IF hold_itemtype == i %]
-                                        [% holds_by_itemtype.push( h ) | $raw %]
+                                        [% holds_by_itemtype.push( h ) %]
                                     [% END %]
                                 [% END %]
 
                             [% SET branchcodes = [] %]
 
                             [% FOREACH h IN biblioloo.reserveloop %]
-                                [% branchcodes.push( h.branchcode ) | $raw %]
+                                [% branchcodes.push( h.branchcode ) %]
                             [% END %]
                             [% branchcodes = branchcodes.unique %]
 
                                     [% SET holds_by_branch = [] %]
                                     [% FOREACH h IN biblioloo.reserveloop %]
                                         [% IF h.branchcode == b %]
-                                            [% holds_by_branch.push( h ) | $raw %]
+                                            [% holds_by_branch.push( h ) %]
                                         [% END %]
                                     [% END %]
 
                                     [% SET itemtypes = [] %]
                                     [% FOREACH h IN holds_by_branch %]
                                         [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
-                                        [% itemtypes.push( hold_itemtype ) | $raw %]
+                                        [% itemtypes.push( hold_itemtype ) %]
                                     [% END %]
                                     [% itemtypes = itemtypes.unique %]
 
                                             [% FOREACH h IN holds_by_branch %]
                                                 [% SET hold_itemtype = h.object.item.effective_itemtype || h.itemtype %]
                                                 [% IF hold_itemtype == i %]
-                                                    [% holds_by_itemtype.push( h ) | $raw %]
+                                                    [% holds_by_itemtype.push( h ) %]
                                                 [% END %]
                                             [% END %]
                                             [% INCLUDE holds_table.inc holds=holds_by_itemtype %]
 [% MACRO jsinclude BLOCK %]
     [% INCLUDE 'datatables.inc' %]
     [% INCLUDE 'calendar.inc' %]
+    [% INCLUDE 'columns_settings.inc' %]
     [% Asset.js("js/circ-patron-search-results.js") | $raw %]
     <script>
+        var biblionumber = "[% biblionumber %]";
+        var borrowernumber = "[% patron.borrowernumber %]";
         var MSG_CONFIRM_DELETE_HOLD   = _("Are you sure you want to cancel this hold?");
         var patron_homebranch = "[% Branches.GetName( patron.branchcode ) |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') | html %]";
         var override_items = {[% FOREACH bibitemloo IN bibitemloop %][% FOREACH itemloo IN bibitemloo.itemloop %][% IF ( itemloo.override ) %]
             [% END %][% END %][% END %]
         };
         var MSG_NO_ITEMS_AVAILABLE = _("A hold cannot be requested on any of these items.");
+        columns_settings_borrowers_table = [% ColumnsSettings.GetColumns( 'circ', 'circulation', 'table_borrowers', 'json' ) | $raw %]
 
         $(document).ready(function() {
             function ToggleHoldsToPlace() {
                 ToggleHoldsToPlace();
             });
 
+            [% IF Koha.Preference('UseBranchTransferLimits') %]
+                $("#pickup").on('change', function(){
+                    var pickup = $("#pickup").val();
+                    var url = "?pickup=" + pickup;
+                    url += "&borrowernumber=" + borrowernumber;
+                    url += "&biblionumber=" + biblionumber;
+                    window.location.replace(url);
+                });
+            [% END %]
+
             [% IF AutoResumeSuspendedHolds %]
                 $(".suspend_until_datepicker, .datepickerfrom, .datepickerto").datepicker("option", "minDate", 1);
             [% END %]
                 }
             });
             var prev_rank_request;
-            var priorities;
             $("select[name=rank-request]").on("focus", function() {
                 prev_rank_request = $(this).val();
                 var row = $(this).parents("tr:first");
-                priorities = row.parent().find("select[name=rank-request]").map( function() {
-                    return $(this).val();
-                }).get();
             }).change(function() {
                 var row = $(this).parents("tr:first");
                 var value = parseInt($(this).val());
-                var rowsCount = row.parent().children('tr').length - 1;
-                value = value > rowsCount ? rowsCount : value;
-                var after = row.parent().find("tr:nth-child("+(value+1)+")");
-
-                if (prev_rank_request > value) {
-                    row.insertBefore(after);
-                } else {
-                    row.insertAfter(after);
+                var found_holds = $("select[name='rank-request'][disabled='disabled']").length ; //Count how many are found
+                if( !isNaN(value) ) {  //If moved to 'del'
+                    var after = row.parent().find("tr:nth-child("+(value+1+found_holds )+")"); //Go to the row 1 after the new value (and skip found holds)
+                    if (prev_rank_request > value) {
+                        row.insertBefore(after);
+                    } else {
+                        row.insertAfter(after);
+                    }
                 }
 
-                var next_priority = 0;
-                row.parent().find("select[name=rank-request]").each(function () {
-                    $(this).val(priorities[next_priority]);
+                var next_priority = 1;
+                $("select[name=rank-request]").each(function () {
+                    if( isNaN( $(this).val() ) ){ return true; } //Don't reset found or del holds
+                    $(this).val(next_priority);
                     next_priority++;
                 });
             });