[% 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() {
- var late_orderst = $("#late_orders").dataTable($.extend(true, {}, dataTablesDefaults, {
+
+ late_orderst = $("#late_orders").dataTable($.extend(true, {}, dataTablesDefaults, {
"aoColumnDefs": [
- { "aTargets": [ -1 ], "bSortable": false, "bSearchable": false },
+ { "aTargets": [ 0 ], "bSortable": false, "bSearchable": false },
],
- "sPaginationType": "four_button"
+ "sPaginationType": "four_button",
+ "bAutoWidth": false,
+ "fnDrawCallback": function() {
+ if ( typeof late_orderst != 'undefined' ) {
+ 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;
+ }
- $("input:checkbox[name=claim_for]").click(function(){
- var booksellerid = $(this).attr('booksellerid');
- if ( $("input:checkbox[name=claim_for]:checked").length > 0) {
- $("input:checkbox[name=claim_for][booksellerid!="+booksellerid+"]").attr('disabled', true);
- } else {
- $("input:checkbox[name=claim_for]").attr('disabled', 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 += '&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>
</p>
[% END %]
<table id="late_orders">
- <thead>
+ <thead>
<tr>
+ [% 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>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>
- </thead>
- <tbody>
- [% FOREACH lateorder IN lateorders %]
+ </thead>
+ <tbody>
+ [% FOREACH lateorder IN lateorders %]
[% UNLESS ( loop.odd ) %]<tr class="highlight">
[% ELSE %]<tr>[% END %]
+ <td>
+ <input type="checkbox" value="[% lateorder.ordernumber %]" data-booksellerid="[% lateorder.supplierid %]" name="ordernumber">
+ </td>
<td>
([% lateorder.supplierid %])
[% lateorder.orderdate %]
</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 %]" booksellerid="[% lateorder.supplierid %]"/>
- [% END %]
- </td>
- </td>
</tr>
- [% END %]
- </tbody>
- <tfoot>
- <tr>
- <th>Total</th>
- <th> </th>
- <th> </th>
- <th> </th>
+ [% END %]
+ </tbody>
+ <tfoot>
+ <tr>
+ <th colspan="5">Total</th>
<th>[% total %]</th>
- <th> </th>
- <th> </th>
- <th> </th>
- <td>
- <input type="submit" value="Claim Order" />
- </td>
+ <th colspan="3"> </th>
</tr>
- </tfoot>
+ </tfoot>
</table>
+ <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 %]