Bug 19654: Move tools templates JavaScript to the footer: Batch MARC tools
authorOwen Leonard <oleonard@myacpl.org>
Tue, 12 Dec 2017 14:38:01 +0000 (14:38 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 18 Dec 2017 15:16:26 +0000 (12:16 -0300)
This patch modifies the staff client patron lists templates so that
JavaScript is included in the footer instead of the header.

To test, apply the patch and test the JavaScript-driven features of
each modified template: All button controls, DataTables functionality,
form validation, etc.

Revised: My original patch included changes to batchMod-edit.tt but
didn't take into account the MARC plugins which are loaded in the item
edit form. I have discarded those changes for now.

Tools -> Batch record modification
  - Page highlighting in the sidebar
  - Patron autocomplete in the "Check out" tab
  - Submit records for deletion
    - Page highlighting in the sidebar
    - Checkbox selection links
    - Warning when no records selected
    - Patron autocomplete in the "Check out" tab
Tools -> Batch item modification
  - Page highlighting in the sidebar
  - Patron autocomplete in the "Check out" tab
Tools -> Batch item deletion
  - Page highlighting in the sidebar
  - Patron autocomplete in the "Check out" tab
  - Submit items for deletion
    - Patron autocomplete in the "Check out" tab
    - Checkbox selection links
    - Column-hiding checkboxes
    - Datatables
Tools -> Batch record modification
  - Page highlighting in the sidebar
  - Patron autocomplete in the "Check out" tab
  - Submit records for modification
      - Page highlighting in the sidebar
      - Patron autocomplete in the "Check out" tab
      - Checkbox selection links
      - Datatables
      - MARC preview
      - Warning when no records selected
      - Progress bar after submitting items for modification

Signed-off-by: Claire Gravely <claire.gravely@bsz-bw.de>
Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod-del.tt
koha-tmpl/intranet-tmpl/prog/en/modules/tools/batchMod.tt
koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_delete_records.tt
koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_record_modification.tt

index 5ad6195..7987756 100644 (file)
@@ -1,26 +1,8 @@
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Batch item deletion</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
-[% INCLUDE 'datatables.inc' %]
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/pages/batchMod.js"></script>
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
-<script type="text/javascript">
-//<![CDATA[
-
-// Prepare array of all column headers, incrementing each index by
-// two to accommodate control and title columns
-var allColumns = new Array([% FOREACH item_header_loo IN item_header_loop %]'[% loop.count %]'[% UNLESS ( loop.last ) %],[% END %][% END %]);
-for( x=0; x<allColumns.length; x++ ){
-  allColumns[x] = Number(allColumns[x]) + 2;
-}
-$(document).ready(function(){
-    $("#mainformsubmit").on("click",function(){
-        return submitBackgroundJob(this.form);
-    });
-});
-//]]>
-</script>
 <!--[if IE]>
 <style type="text/css">#selections { display: none; }</style>
 <![endif]-->
@@ -30,42 +12,42 @@ $(document).ready(function(){
 [% INCLUDE 'cat-search.inc' %]
 
 <div id="breadcrumbs">
-       <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
-       <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
-       <a href="/cgi-bin/koha/tools/batchMod.pl?del=1">Batch item deletion</a>
+    <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
+    <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
+    <a href="/cgi-bin/koha/tools/batchMod.pl?del=1">Batch item deletion</a>
 </div>
 
 <div id="doc3" class="yui-t7">
     <div id="bd">
         <div id="yui-main">
                 [% IF ( show ) %]<h1>Batch item deletion</h1>[% ELSE %]<h1>Batch item deletion results</h1>[% END %]
-           [% IF ( barcode_not_unique ) %]<div class="dialog alert"><strong>Error saving item</strong>: Barcode must be unique.</div>[% END %]
-           [% IF ( no_next_barcode ) %]<div class="dialog alert"><strong>Error saving items</strong>: Unable to automatically determine values for barcodes. No item has been inserted.</div>[% END %]
+        [% IF ( barcode_not_unique ) %]<div class="dialog alert"><strong>Error saving item</strong>: Barcode must be unique.</div>[% END %]
+        [% IF ( no_next_barcode ) %]<div class="dialog alert"><strong>Error saving items</strong>: Unable to automatically determine values for barcodes. No item has been inserted.</div>[% END %]
         [% IF ( book_on_loan ) %]<div class="dialog alert"><strong>Cannot delete</strong>: item is checked out.</div>[% END %]
         [% IF ( book_reserved ) %]<div class="dialogalert"><strong>Cannot delete</strong>: item has a waiting hold.</div>[% END %]
 
     [% UNLESS ( action ) %]
 
     [% IF ( notfoundbarcodes ) %]
-           <div class="dialog alert">
-           [% IF ( itemresults ) %]<p>Warning, the following barcodes were not found:</p>[% ELSE %]<p>Warning: no barcodes were found</p>[% END %]
-               </div>
-           <table style="margin:auto;">
-               <thead>
-                   <tr>
-                       <th>Barcode</th>
-                   </tr>
-               </thead>
-               <tbody>
-                   [% FOREACH notfoundbarcode IN notfoundbarcodes %]
+        <div class="dialog alert">
+        [% IF ( itemresults ) %]<p>Warning, the following barcodes were not found:</p>[% ELSE %]<p>Warning: no barcodes were found</p>[% END %]
+        </div>
+        <table style="margin:auto;">
+        <thead>
+            <tr>
+            <th>Barcode</th>
+            </tr>
+        </thead>
+        <tbody>
+            [% FOREACH notfoundbarcode IN notfoundbarcodes %]
             <tr><td>[% notfoundbarcode.barcode |html %]</td></tr>
-                   [% END %]
-               </tbody>
-           </table>
-           [% UNLESS ( too_many_items ) %]
-           [% IF ( item_loop ) %]<h4>The following barcodes were found: </h4>[% END %]
-           [% END %]
-       [% END %]
+            [% END %]
+        </tbody>
+        </table>
+        [% UNLESS ( too_many_items ) %]
+        [% IF ( item_loop ) %]<h4>The following barcodes were found: </h4>[% END %]
+        [% END %]
+    [% END %]
 
 
 <form name="f" action="batchMod.pl" method="post">
@@ -80,33 +62,33 @@ $(document).ready(function(){
 
 [% IF ( item_loop ) %]
     [% IF ( show ) %]<div id="toolbar"><a id="selectallbutton" href="#"><i class="fa fa-check"></i> Select all</a> | <a id="clearallbutton" href="#"><i class="fa fa-remove"></i> Clear all</a></div>[% END %]
-       <div id="cataloguing_additem_itemlist">
-
-       <p id="selections"><strong>Show/hide columns:</strong> <span class="selected"><input type="checkbox" checked="checked" id="showall"/><label for="showall">Show all columns</label></span> <span><input type="checkbox" id="hideall"/><label for="hideall">Hide all columns</label></span>
-               [% FOREACH item_header_loo IN item_header_loop %]
-               <span class="selected"><input id="checkheader[% loop.count %]" type="checkbox" checked="checked" /> <label for="checkheader[% loop.count %]">[% item_header_loo.header_value %]</label> </span>
-               [% END %]
-       </p>
-
-               <table id="itemst">
-                   <thead>
-                       <tr>
-                           [% IF ( show ) %]<th>&nbsp;</th>[% END %]
+    <div id="cataloguing_additem_itemlist">
+
+    <p id="selections"><strong>Show/hide columns:</strong> <span class="selected"><input type="checkbox" checked="checked" id="showall"/><label for="showall">Show all columns</label></span> <span><input type="checkbox" id="hideall"/><label for="hideall">Hide all columns</label></span>
+        [% FOREACH item_header_loo IN item_header_loop %]
+        <span class="selected"><input id="checkheader[% loop.count %]" type="checkbox" checked="checked" /> <label for="checkheader[% loop.count %]">[% item_header_loo.header_value %]</label> </span>
+        [% END %]
+    </p>
+
+        <table id="itemst">
+            <thead>
+            <tr>
+                [% IF ( show ) %]<th>&nbsp;</th>[% END %]
                 <th class="anti-the">Title</th>
-                           [% FOREACH item_header_loo IN item_header_loop %]
-                           <th> [% item_header_loo.header_value %] </th>
-                           [% END %]
-                       </tr>
-                   </thead>
-                   <tbody>
+                [% FOREACH item_header_loo IN item_header_loop %]
+                <th> [% item_header_loo.header_value %] </th>
+                [% END %]
+            </tr>
+            </thead>
+            <tbody>
             [% FOREACH item_loo IN item_loop %] <tr> [% IF ( show ) %][% IF ( item_loo.nomod ) %] <td class="error">Cannot edit</td>[% ELSE %]<td><input type="checkbox" name="itemnumber" value="[% item_loo.itemnumber %]" id="row[% item_loo.itemnumber %]" checked="checked" /></td>[% END %][% END %]
-                   <td><label for="row[% item_loo.itemnumber %]"><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% item_loo.biblionumber %]">[% item_loo.title %]</a>[% IF ( item_loo.author ) %], by [% item_loo.author %][% END %]</label></td>
-                       [% FOREACH item_valu IN item_loo.item_value %] <td>[% item_valu.field |html %]</td> 
-                                       [% END %] </tr>
-                   [% END %]
-                   </tbody>
-               </table>
-       </div>
+            <td><label for="row[% item_loo.itemnumber %]"><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=[% item_loo.biblionumber %]">[% item_loo.title %]</a>[% IF ( item_loo.author ) %], by [% item_loo.author %][% END %]</label></td>
+            [% FOREACH item_valu IN item_loo.item_value %] <td>[% item_valu.field |html %]</td>
+                    [% END %] </tr>
+            [% END %]
+            </tbody>
+        </table>
+    </div>
 [% END %]
 
 [% IF ( simple_items_display ) %]
@@ -127,14 +109,14 @@ $(document).ready(function(){
     [% FOREACH itemnumber IN itemnumbers_array %]
         <input type="hidden" name="itemnumber" value="[% itemnumber %]" />
     [% END %]
-[% END %]   
+[% END %]
 
 [% IF ( itemresults ) %]
-               <div id="cataloguing_additem_newitem">
-            <input type="hidden" name="op" value="[% op %]" />
-            <p>This will delete [% IF ( too_many_items ) %]all the[% ELSE %]the selected[% END %] items.</p>
-            <input type="hidden" name="del" value="1" />
-            <fieldset class="action">    
+        <div id="cataloguing_additem_newitem">
+         <input type="hidden" name="op" value="[% op %]" />
+         <p>This will delete [% IF ( too_many_items ) %]all the[% ELSE %]the selected[% END %] items.</p>
+         <input type="hidden" name="del" value="1" />
+         <fieldset class="action">
         <input type="checkbox" name="del_records" id="del_records" /> <label for="del_records">Delete records if no items remain.</label>
         [% IF too_many_items %]
             <input type="submit" name="mainformsubmit" value="Delete ALL submitted items" />
@@ -142,18 +124,18 @@ $(document).ready(function(){
             <input type="submit" name="mainformsubmit" value="Delete selected items" />
         [% END %]
 
-               <a href="/cgi-bin/koha/tools/batchMod.pl?del=1" class="cancel">Cancel</a>
-           </fieldset>
-       </div>
-       [% ELSE %]
-       <p><a href="/cgi-bin/koha/tools/batchMod.pl?del=1">Return to batch item deletion</a></p>
-       [% END %]
-       [% END %]
-       </form>
+        <a href="/cgi-bin/koha/tools/batchMod.pl?del=1" class="cancel">Cancel</a>
+        </fieldset>
+    </div>
+    [% ELSE %]
+    <p><a href="/cgi-bin/koha/tools/batchMod.pl?del=1">Return to batch item deletion</a></p>
+    [% END %]
+    [% END %]
+    </form>
     [% END %]
 
 [% IF ( action ) %]
-       <div class="dialog message">
+    <div class="dialog message">
             <p>[% deleted_items %] item(s) deleted.</p>
             [% IF delete_records %] <p>[% deleted_records %] record(s) deleted.</p> [% END %]
             [% IF src == 'CATALOGUING' # from catalogue/detail.pl > Delete items in a batch%]
@@ -164,31 +146,31 @@ $(document).ready(function(){
                 <a href="/cgi-bin/koha/tools/batchMod.pl?del=1">Return to batch item deletion</a>
             [% END %]
         </div>
-       [% IF ( not_deleted_items ) %]
-       <div style="width:55%;margin:auto;">
-           <p>[% not_deleted_items %] item(s) could not be deleted: [% FOREACH not_deleted_itemnumber IN not_deleted_itemnumbers %][% not_deleted_itemnumber.itemnumber %][% END %]</p>
-       [% IF ( not_deleted_loop ) %]
-       <table id="itemst">
-               <thead>
-                   <tr>
-                       <th>Itemnumber</th>
-                       <th>Barcode</th>
-                       <th>Reason</th>
-                   </tr>
-               </thead>
-               <tbody>
-                   [% FOREACH not_deleted_loo IN not_deleted_loop %]
-                       <tr>
-                           <td>[% not_deleted_loo.itemnumber %]</td>
-                           <td>[% IF ( CAN_user_editcatalogue_edit_items ) %]<a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&amp;biblionumber=[% not_deleted_loo.biblionumber %]&amp;itemnumber=[% not_deleted_loo.itemnumber %]">[% not_deleted_loo.barcode %]</a>[% ELSE %][% not_deleted_loo.barcode %][% END %]</td>
-                           <td>[% IF ( not_deleted_loo.book_on_loan ) %]Item is checked out[% ELSIF ( not_deleted_loo.book_reserved ) %]Item has a waiting hold[% END %]</td>
-                       </tr>
-                   [% END %]
-               </tbody>
-           </table>
-       [% END %]
-       </div>
-       [% END %]
+    [% IF ( not_deleted_items ) %]
+    <div style="width:55%;margin:auto;">
+        <p>[% not_deleted_items %] item(s) could not be deleted: [% FOREACH not_deleted_itemnumber IN not_deleted_itemnumbers %][% not_deleted_itemnumber.itemnumber %][% END %]</p>
+    [% IF ( not_deleted_loop ) %]
+    <table id="itemst">
+        <thead>
+            <tr>
+            <th>Itemnumber</th>
+            <th>Barcode</th>
+            <th>Reason</th>
+            </tr>
+        </thead>
+        <tbody>
+            [% FOREACH not_deleted_loo IN not_deleted_loop %]
+            <tr>
+                <td>[% not_deleted_loo.itemnumber %]</td>
+                <td>[% IF ( CAN_user_editcatalogue_edit_items ) %]<a href="/cgi-bin/koha/cataloguing/additem.pl?op=edititem&amp;biblionumber=[% not_deleted_loo.biblionumber %]&amp;itemnumber=[% not_deleted_loo.itemnumber %]">[% not_deleted_loo.barcode %]</a>[% ELSE %][% not_deleted_loo.barcode %][% END %]</td>
+                <td>[% IF ( not_deleted_loo.book_on_loan ) %]Item is checked out[% ELSIF ( not_deleted_loo.book_reserved ) %]Item has a waiting hold[% END %]</td>
+            </tr>
+            [% END %]
+        </tbody>
+        </table>
+    [% END %]
+    </div>
+    [% END %]
 
     <p>
         [% IF src == 'CATALOGUING' # from catalogue/detail.pl > Delete items in a batch%]
@@ -202,4 +184,25 @@ $(document).ready(function(){
 [% END %]
     </div>
     </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
+    [% INCLUDE 'datatables.inc' %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/pages/batchMod.js"></script>
+    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
+    <script type="text/javascript">
+        // Prepare array of all column headers, incrementing each index by
+        // two to accommodate control and title columns
+        var allColumns = new Array([% FOREACH item_header_loo IN item_header_loop %]'[% loop.count %]'[% UNLESS ( loop.last ) %],[% END %][% END %]);
+        for( x=0; x<allColumns.length; x++ ){
+          allColumns[x] = Number(allColumns[x]) + 2;
+        }
+        $(document).ready(function(){
+            $("#mainformsubmit").on("click",function(){
+                return submitBackgroundJob(this.form);
+            });
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 115e4ea..fef86dd 100644 (file)
@@ -1,3 +1,4 @@
+[% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; [% IF ( del ) %]Batch item deletion[% ELSE %]Batch item modification[% END %] </title>
 [% INCLUDE 'doc-head-close.inc' %]
@@ -7,13 +8,13 @@
 [% INCLUDE 'cat-search.inc' %]
 
 <div id="breadcrumbs">
-       <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
-       <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
-       [% IF ( del ) %]
-       <a href="/cgi-bin/koha/tools/batchMod.pl?del=1">Batch item deletion</a>
-       [% ELSE %]
-       <a href="/cgi-bin/koha/tools/batchMod.pl">Batch item modification</a>
-       [% END %]
+    <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo;
+    <a href="/cgi-bin/koha/tools/tools-home.pl">Tools</a> &rsaquo;
+    [% IF ( del ) %]
+    <a href="/cgi-bin/koha/tools/batchMod.pl?del=1">Batch item deletion</a>
+    [% ELSE %]
+    <a href="/cgi-bin/koha/tools/batchMod.pl">Batch item modification</a>
+    [% END %]
 </div>
 
 <div id="doc3" class="yui-t2">
                         <form method="post" enctype="multipart/form-data" action="/cgi-bin/koha/tools/batchMod.pl">
                             <fieldset class="rows">
                                 <legend>Use a file</legend>
-                                     <ol>
-                                     <li>
+                                  <ol>
+                      <li>
                     <label for="barcode_file">Barcode file: </label><input type="radio" name="filecontent" value="barcode_file" id="barcode_file" checked="checked" /></li>
                     <li>
                     <label for="itemid_file">Item number file: </label><input type="radio" name="filecontent" value="itemid_file" id="itemid_file" />
-                                     </li>
+                      </li>
                                     <li><label for="uploadfile">File: </label> <input type="file" id="uploadfile" name="uploadfile" /></li>
                                 </ol>
                             </fieldset>
                             [% IF ( del ) %]<input type="hidden" name="del" value="1" />[% END %]
                             <fieldset class="action">
                                 <input type="submit" value="Continue" class="button" />
-                               <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
+                <a class="cancel" href="/cgi-bin/koha/tools/tools-home.pl">Cancel</a>
                             </fieldset>
 
                         </form>
                     </div>
-                   </div>
+            </div>
        <div class="yui-b">
             [% INCLUDE 'tools-menu.inc' %]
         </div>
     </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 06805e3..aee52e1 100644 (file)
@@ -1,85 +1,11 @@
+[% SET footerjs = 1 %]
 [% PROCESS 'authorities-search-results.inc' %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Batch record deletion</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
-[% INCLUDE 'datatables.inc' %]
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
-<script type="text/javascript">
-//<![CDATA[
-var MSG_CANNOT_BE_DELETED = _("This record cannot be deleted, at least one item is currently checked out.");
-$(document).ready(function() {
-  $("#selectall").click(function(e){
-    e.preventDefault();
-    $(".records").checkCheckboxes();
-  });
-  $("#clearall").click(function(e){
-    e.preventDefault();
-    $(".records").unCheckCheckboxes();
-  });
-  $("#selectwithoutitems").click(function(e){
-    e.preventDefault();
-    $("#biblios").checkCheckboxes(":input[data-items='0']:not(:disabled)");
-  });
-  $("#selectnotreserved").click(function(e){
-    e.preventDefault();
-    $("#biblios").checkCheckboxes(":input[data-reserves='0']:not(:disabled)");
-
-  });
-  $("#clearlinkedtobiblio").click(function(e){
-    e.preventDefault();
-    $("#authorities").unCheckCheckboxes(":not(input[data-usage='0'])");
-  });
-  $("#selectall").click();
-
-  [% IF recordtype == 'biblio' %]
-    $(".records input:checkbox[data-issues!='0']").each(function(){
-      $(this).attr('title', MSG_CANNOT_BE_DELETED)
-      $(this).prop('disabled', true);
-      $(this).prop('checked', false);
-      $(this).parents('tr').find('td').css('background-color', '#ffff99');
-    });
-  [% END %]
-
-  $("table#biblios").dataTable($.extend(true, {}, dataTablesDefaults, {
-    "aoColumnDefs": [
-      { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
-      { "aTargets": [ 3, 4 ], "sType": "num-html" }
-    ],
-    "sDom": 't',
-    "aaSorting": [],
-    "bPaginate": false
-  }));
-
-  $("table#authorities").dataTable($.extend(true, {}, dataTablesDefaults, {
-    "aoColumnDefs": [
-      { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
-      { "aTargets": [ 3 ], "sType": "num-html" }
-    ],
-    "sDom": 't',
-    "aaSorting": [],
-    "bPaginate": false
-  }));
-
-  $("#selectrecords").on("submit",function(){
-    var nb_checked = $("#selectrecords").find("input[type='checkbox'][name='record_id']:checked").size();
-    if (nb_checked == 0){
-      alert(_("No records have been selected."));
-      return false;
-    }
-  });
-
-  $("#selectauths").on("submit",function(){
-    var checked = $("#selectauths").find("input[type='checkbox'][name='record_id']:checked").size();
-    if (checked == 0) {
-      alert(_("No authorities have been selected."));
-      return false;
-    }
-  });
-});
-//]]>
-</script>
 </head>
+
 <body id="tools_batch_delete_records" class="tools">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'cat-search.inc' %]
@@ -249,4 +175,83 @@ $(document).ready(function() {
   [% INCLUDE 'tools-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
+    [% INCLUDE 'datatables.inc' %]
+    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
+    <script type="text/javascript">
+        var MSG_CANNOT_BE_DELETED = _("This record cannot be deleted, at least one item is currently checked out.");
+        $(document).ready(function() {
+          $("#selectall").click(function(e){
+            e.preventDefault();
+            $(".records").checkCheckboxes();
+          });
+          $("#clearall").click(function(e){
+            e.preventDefault();
+            $(".records").unCheckCheckboxes();
+          });
+          $("#selectwithoutitems").click(function(e){
+            e.preventDefault();
+            $("#biblios").checkCheckboxes(":input[data-items='0']:not(:disabled)");
+          });
+          $("#selectnotreserved").click(function(e){
+            e.preventDefault();
+            $("#biblios").checkCheckboxes(":input[data-reserves='0']:not(:disabled)");
+
+          });
+          $("#clearlinkedtobiblio").click(function(e){
+            e.preventDefault();
+            $("#authorities").unCheckCheckboxes(":not(input[data-usage='0'])");
+          });
+          $("#selectall").click();
+
+          [% IF recordtype == 'biblio' %]
+            $(".records input:checkbox[data-issues!='0']").each(function(){
+              $(this).attr('title', MSG_CANNOT_BE_DELETED)
+              $(this).prop('disabled', true);
+              $(this).prop('checked', false);
+              $(this).parents('tr').find('td').css('background-color', '#ffff99');
+            });
+          [% END %]
+
+          $("table#biblios").dataTable($.extend(true, {}, dataTablesDefaults, {
+            "aoColumnDefs": [
+              { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
+              { "aTargets": [ 3, 4 ], "sType": "num-html" }
+            ],
+            "sDom": 't',
+            "aaSorting": [],
+            "bPaginate": false
+          }));
+
+          $("table#authorities").dataTable($.extend(true, {}, dataTablesDefaults, {
+            "aoColumnDefs": [
+              { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
+              { "aTargets": [ 3 ], "sType": "num-html" }
+            ],
+            "sDom": 't',
+            "aaSorting": [],
+            "bPaginate": false
+          }));
+
+          $("#selectrecords").on("submit",function(){
+            var nb_checked = $("#selectrecords").find("input[type='checkbox'][name='record_id']:checked").size();
+            if (nb_checked == 0){
+              alert(_("No records have been selected."));
+              return false;
+            }
+          });
+
+          $("#selectauths").on("submit",function(){
+            var checked = $("#selectauths").find("input[type='checkbox'][name='record_id']:checked").size();
+            if (checked == 0) {
+              alert(_("No authorities have been selected."));
+              return false;
+            }
+          });
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]
index 4a6ad6a..d6432fa 100644 (file)
@@ -1,81 +1,11 @@
+[% SET footerjs = 1 %]
 [% PROCESS 'authorities-search-results.inc' %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Tools &rsaquo; Batch record modification</title>
 [% INCLUDE 'doc-head-close.inc' %]
 <link rel="stylesheet" type="text/css" href="[% interface %]/[% theme %]/css/datatables.css" />
-[% INCLUDE 'datatables.inc' %]
-<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
-<script type="text/javascript" src="[% interface %]/[% theme %]/js/background-job-progressbar.js"></script>
-<script type="text/javascript">
-//<![CDATA[
-$(document).ready(function() {
-  $("#selectall").click(function(e){
-    e.preventDefault();
-    $(".records").checkCheckboxes();
-  });
-  $("#clearall").click(function(e){
-    e.preventDefault();
-    $(".records").unCheckCheckboxes();
-  });
-  $("#selectall").click();
-
-  $("table#biblios").dataTable($.extend(true, {}, dataTablesDefaults, {
-    "aoColumnDefs": [
-      { "aTargets": [ 0, 3 ], "bSortable": false, "bSearchable": false },
-      { "aTargets": [ 1 ], "sType": "num-html" }
-    ],
-    "sDom": 't',
-    "aaSorting": [],
-    "bPaginate": false
-  }));
-
-  $("table#authorities").dataTable($.extend(true, {}, dataTablesDefaults, {
-    "aoColumnDefs": [
-      { "aTargets": [ 0, 3 ], "bSortable": false, "bSearchable": false },
-      { "aTargets": [ 1 ], "sType": "num-html" }
-    ],
-    "sDom": 't',
-    "aaSorting": [],
-    "bPaginate": false
-  }));
-
-  $("#mainformsubmit").click(function(){
-    if ($("input[type=checkbox][name='record_id']:checked").length == 0 ) {
-      alert(_("Please select at least one record to process"));
-      return false;
-    }
-    if ( $("#marc_modification_template_id").val() <= 0 ) {
-      alert(_("Please select a modification template."));
-      return false;
-    }
-    return submitBackgroundJob(document.getElementById("process"));
-  });
-
-  $("#marc_modification_template_id").change(function(){
-    var url = "/cgi-bin/koha/svc/records/preview?"
-    var mmtid = $(this).val();
-    $("a.previewMARC").each(function(){
-      $(this).attr("href", url + "record_type=" + $(this).attr("data-record_type") + "&record_id=" + $(this).attr("data-record_id") + "&mmtid=" + mmtid);
-    });
-  });
-
-    $("body").on("click",".previewMARC", function(e){
-        e.preventDefault();
-        var ltitle = $(this).text();
-        var page = $(this).attr("href");
-        $("#marcPreviewLabel").text(ltitle);
-        $("#marcPreview .modal-body").load(page + " div");
-        $('#marcPreview').modal({show:true});
-    });
-    $("#marcPreview").on("hidden", function(){
-        $("#marcPreviewLabel").html("");
-        $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface %]/[% theme %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
-    });
-
-});
-//]]>
-</script>
 </head>
+
 <body id="tools_batch_record_modification" class="tools">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'cat-search.inc' %]
@@ -303,4 +233,79 @@ $(document).ready(function() {
   [% INCLUDE 'tools-menu.inc' %]
 </div>
 </div>
+
+[% MACRO jsinclude BLOCK %]
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/tools-menu.js"></script>
+    [% INCLUDE 'datatables.inc' %]
+    <script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
+    <script type="text/javascript" src="[% interface %]/[% theme %]/js/background-job-progressbar.js"></script>
+    <script type="text/javascript">
+        $(document).ready(function() {
+          $("#selectall").click(function(e){
+            e.preventDefault();
+            $(".records").checkCheckboxes();
+          });
+          $("#clearall").click(function(e){
+            e.preventDefault();
+            $(".records").unCheckCheckboxes();
+          });
+          $("#selectall").click();
+
+          $("table#biblios").dataTable($.extend(true, {}, dataTablesDefaults, {
+            "aoColumnDefs": [
+              { "aTargets": [ 0, 3 ], "bSortable": false, "bSearchable": false },
+              { "aTargets": [ 1 ], "sType": "num-html" }
+            ],
+            "sDom": 't',
+            "aaSorting": [],
+            "bPaginate": false
+          }));
+
+          $("table#authorities").dataTable($.extend(true, {}, dataTablesDefaults, {
+            "aoColumnDefs": [
+              { "aTargets": [ 0, 3 ], "bSortable": false, "bSearchable": false },
+              { "aTargets": [ 1 ], "sType": "num-html" }
+            ],
+            "sDom": 't',
+            "aaSorting": [],
+            "bPaginate": false
+          }));
+
+          $("#mainformsubmit").click(function(){
+            if ($("input[type=checkbox][name='record_id']:checked").length == 0 ) {
+              alert(_("Please select at least one record to process"));
+              return false;
+            }
+            if ( $("#marc_modification_template_id").val() <= 0 ) {
+              alert(_("Please select a modification template."));
+              return false;
+            }
+            return submitBackgroundJob(document.getElementById("process"));
+          });
+
+          $("#marc_modification_template_id").change(function(){
+            var url = "/cgi-bin/koha/svc/records/preview?"
+            var mmtid = $(this).val();
+            $("a.previewMARC").each(function(){
+              $(this).attr("href", url + "record_type=" + $(this).attr("data-record_type") + "&record_id=" + $(this).attr("data-record_id") + "&mmtid=" + mmtid);
+            });
+          });
+
+            $("body").on("click",".previewMARC", function(e){
+                e.preventDefault();
+                var ltitle = $(this).text();
+                var page = $(this).attr("href");
+                $("#marcPreviewLabel").text(ltitle);
+                $("#marcPreview .modal-body").load(page + " div");
+                $('#marcPreview').modal({show:true});
+            });
+            $("#marcPreview").on("hidden", function(){
+                $("#marcPreviewLabel").html("");
+                $("#marcPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface %]/[% theme %]/img/spinner-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
+            });
+
+        });
+    </script>
+[% END %]
+
 [% INCLUDE 'intranet-bottom.inc' %]