Bug 7298: (follow-up) various QA fixes
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / acqui / lateorders.tt
index 3eaf8a6..c76cf2d 100644 (file)
@@ -1,25 +1,71 @@
+[% USE KohaDates %]
 [% INCLUDE 'doc-head-open.inc' %]
 <title>Koha &rsaquo; Acquisitions &rsaquo; Late orders</title>
+<link rel="stylesheet" type="text/css" href="[% themelang %]/css/datatables.css" />
 [% INCLUDE 'doc-head-close.inc' %]
+[% INCLUDE 'datatables.inc' %]
 <script type="text/javascript" src="[% themelang %]/lib/jquery/plugins/jquery.checkboxes.min.js"></script>
+[% INCLUDE 'calendar.inc' %]
 <script type="text/javascript">
 //<![CDATA[
+[% IF (dateformat == 'metric') %]
+    dt_add_type_uk_date();
+[% END %]
+
+var late_orderst;
+function check_uncheck() {
+    var all_nodes = $(late_orderst.fnGetNodes());
+    if ( $(all_nodes).find("input:checkbox[name=ordernumber]:checked").length > 0) {
+        var booksellerid = $(all_nodes).find("input:checkbox[name=ordernumber]:checked:first").attr("data-booksellerid");
+        $(all_nodes).find("input:checkbox[name=ordernumber][data-booksellerid!="+booksellerid+"]").attr('disabled', 'disabled');
+    } else {
+        $("input:checkbox[name=ordernumber]").removeAttr('disabled');
+    }
+}
+
 $(document).ready(function() {
-    $("input:checkbox[name=claim_for]").click(function(){
-        var supplierid = $(this).attr('supplierid');
-        if ( $("input:checkbox[name=claim_for]:checked").length > 0) {
-            $("input:checkbox[name=claim_for][supplierid!="+supplierid+"]").attr('disabled', true);
-        } else {
-            $("input:checkbox[name=claim_for]").attr('disabled', false);
+
+    late_orderst = $("#late_orders").dataTable($.extend(true, {}, dataTablesDefaults, {
+        "aoColumnDefs": [
+            { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
+        ],
+        "sPaginationType": "four_button",
+        "bAutoWidth": false,
+        "fnDrawCallback": function() {
+            if ( typeof late_orderst != 'undefined' ) {
+                check_uncheck();
+                $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
+            };
+        }
+    } ) );
+    $('input:checkbox[name=ordernumber]').bind('click', check_uncheck);
+    $('#CheckAll').click(function(){ $(late_orderst.fnGetNodes()).find("td").checkCheckboxes();});
+    $('#CheckNone').click(function(){ $(late_orderst.fnGetNodes()).find("td").unCheckCheckboxes();});
+
+    // Generates a dynamic link for exporting the selection's data as CSV
+    $("#ExportSelected").click(function() {
+        var all_nodes = $(late_orderst.fnGetNodes());
+        var selected = $(all_nodes).find("input[name='ordernumber']:checked");
+
+        if (selected.length == 0) {
+            alert(_("Please select at least one item to export."));
+            return false;
+        }
+
+        // Building the url from currently checked boxes
+        var url = '/cgi-bin/koha/acqui/lateorders-export.pl?op=export';
+        for (var i = 0; i < selected.length; i++) {
+            url += '&amp;ordernumber=' + selected[i].value;
         }
+        // And redirecting to the CSV page
+        location.href = url;
+        return false;
     });
-    $('#CheckAll').click(function(){ $("#late_orders td").checkCheckboxes();});
-    $('#CheckNone').click(function(){ $("#late_orders td").unCheckCheckboxes();});
 });
 //]]>
 </script>
 </head>
-<body>
+<body id="acq_lateorders" class="acq">
 [% INCLUDE 'header.inc' %]
 [% INCLUDE 'acquisitions-search.inc' %]
 
@@ -48,7 +94,7 @@ $(document).ready(function() {
 <form action="lateorders.pl" name="claim" method="post">
   <input type="hidden" name="op" value="send_alert" />
   <input type="hidden" name="delay" value="[% delay %]" />
-  <input type="hidden" name="supplierid" value="[% SupplierId %]" />
+  <input type="hidden" name="booksellerid" value="[% booksellerid %]" />
        [% IF ( letters ) %]
        <p><label for="letter_code">Claim using notice: </label><select name="letter_code" id="letter_code">
          [% FOREACH letter IN letters %]
@@ -58,30 +104,42 @@ $(document).ready(function() {
        </p>
        [% END %]
     <table id="late_orders">
+      <thead>
         <tr>
-            <th>Order Date</th>
+            [% IF Supplier %]
+                <th><a id="CheckAll" href="#">Check all</a><br /><a id="CheckNone" href="#">Uncheck all</a></th>
+            [% ELSE %]
+                <th></th>
+            [% END %]
+            <th>Order date</th>
+            <th>Estimated delivery date</th>
             <th>Vendor</th>
             <th>Information</th>
             <th>Total cost</th>
             <th>Basket</th>
             <th>Claims count</th>
             <th>Claimed date</th>
-            [% IF Supplier %]
-                <th><a id="CheckAll" href="#">Check all</a><br /><a id="CheckNone" href="#">Uncheck all</a></th>
-            [% ELSE %]
-                <th></th>
-            [% END %]
         </tr>
-    [% FOREACH lateorder IN lateorders %]
+      </thead>
+      <tbody>
+      [% FOREACH lateorder IN lateorders %]
         [% UNLESS ( loop.odd ) %]<tr class="highlight">
         [% ELSE %]<tr>[% END %]
             <td>
-                ([% lateorder.supplierid %])
+                <input type="checkbox" value="[% lateorder.ordernumber %]" data-booksellerid="[% lateorder.supplierid %]" name="ordernumber">
+            </td>
+            <td>
                 [% lateorder.orderdate %]
                 ([% lateorder.latesince %] days)
             </td>
+            <td>
+                [% IF ( lateorder.estimateddeliverydate ) %]
+                    [% lateorder.estimateddeliverydate | $KohaDates  %]
+                [% END %]
+            </td>
             <td>
                 [% lateorder.supplier %]
+                ([% lateorder.supplierid %])
             </td>
             <td>
                 <b>[% lateorder.title |html %]</b>
@@ -107,27 +165,26 @@ $(document).ready(function() {
             </td>
             <td>[% lateorder.claims_count %]</td>
             <td>[% lateorder.claimed_date %]</td>
-            <td>
-                [% UNLESS lateorder.budget_lock %]
-                    <input type="checkbox" class="checkbox" name="claim_for" value="[% lateorder.ordernumber %]"  supplierid="[% lateorder.supplierid %]"/>
-                [% END %]
-             </td>
-            </td>
         </tr>
-        [% END %]
-        <tr> 
-            <th>Total</th>
-            <th colspan="2">&nbsp;</th>
+      [% END %]
+      </tbody>
+      <tfoot>
+        <tr>
+            <th colspan="5">Total</th>
             <th>[% total %]</th>
-            <th>&nbsp;</th>
-            <th>&nbsp;</th>
-            <th>&nbsp;</th>
-            <td>
-                <input type="submit" value="Claim Order" />
-            </td>
+            <th colspan="3">&nbsp;</th>
         </tr>
+      </tfoot>
     </table>
-     </form>
+    <div class="spacer"></div>
+
+    <p style="display:block;">
+        <input type="button" value="Export as CSV" id="ExportSelected" />
+        [% UNLESS lateorder.budget_lock %]
+            <input type="submit"  value="Claim order" />
+        [% END %]
+    </p>
+</form>
 [% ELSE %]<p>There are no late orders.</p>
 [% END %]
 </div>
@@ -136,13 +193,23 @@ $(document).ready(function() {
 <div class="yui-b">
 <form action="lateorders.pl" method="get">
 <fieldset class="brief">
-<h4>Filter Results:</h4>
+<h4>Filter results:</h4>
 [% FOREACH ERROR_LOO IN ERROR_LOOP %]
 [% IF ( ERROR_LOO.delay_digits ) %]<p class="error">The number of days ([% ERROR_LOO.bad_delay %]) must be a number between 0 and 999.</p>[% END %]
 [% END %]
-<ol><li><label for="delay">Order date:</label><input size="3" maxlength="3" id="delay" type="text" name="delay" value="[% delay %]" /> days ago</li>
-       <li><label for="supplierid">Vendor:</label>
-               <select id="supplierid" size="1" tabindex="" name="supplierid">
+<ol>
+    <li><label for="delay">Order date:</label><input size="3" maxlength="3" id="delay" type="text" name="delay" value="[% delay %]" /> days ago</li>
+    <li><label for="from">Estimated delivery date from: </label>
+        <input type="text" size="10" id="from" name="estimateddeliverydatefrom" value="[% estimateddeliverydatefrom %]" class="datepickerfrom" />
+        <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
+    </li>
+    <li><label for="to">To: </label>
+        <input type="text" size="10" id="to" name="estimateddeliverydateto" value="[% estimateddeliverydateto %]" class="datepickerto" />
+        <div class="hint">[% INCLUDE 'date-format.inc' %]</div>
+    </li>
+
+       <li><label for="booksellerid">Vendor:</label>
+               <select id="booksellerid" size="1" tabindex="" name="booksellerid">
                        <option value=""/>
                        [% FOREACH SUPPLIER_LOO IN SUPPLIER_LOOP %]
                 [% IF ( SUPPLIER_LOO.selected ) %]<option value="[% SUPPLIER_LOO.id %]" selected="selected">[% SUPPLIER_LOO.name %]</option>
@@ -150,7 +217,7 @@ $(document).ready(function() {
                [% END %]
                </select>
 </ol>
-       <fieldset class="action"><input type="submit" value="filter" /></fieldset>
+    <fieldset class="action"><input type="submit" value="Filter" /></fieldset>
 </fieldset>
     </form>
 [% INCLUDE 'acquisitions-menu.inc' %]