/* global dataTablesDefaults __ template_path */ $(document).ready(function() { $("#Aform").preventDoubleFormSubmit(); $("#files").dataTable($.extend(true, {}, dataTablesDefaults, { "columnDefs": [ { "orderable": false, "searchable": false, "targets": [ 'NoSort' ] }, { "type": "anti-the", "targets": [ "anti-the" ] } ], "pagingType": "full", "order": [] }) ); checkOrderBudgets(); var all_budget_id = $("#all_budget_id"); $("#all_budget_id,[name='budget_id'],.budget_code_item,[name='import_record_id']").on("change", function(){ checkOrderBudgets(); }); $(".order_details").hide(); $('input:checkbox[name="import_record_id"]').change(function(){ var container = $(this).parents("tr"); if ( $(this).is(':checked') ) { $(container).addClass("selected"); $(container).removeClass("unselected"); $(container).find(".order_details").toggle(true); } else { $(container).addClass("unselected"); $(container).removeClass("selected"); $(container).find(".order_details").toggle(false); } } ); $("input:checkbox").prop("checked", false); $("div.biblio.unselected select").prop('disabled', false); $("div.biblio.unselected input").prop('disabled', false); $("#checkAll").click(function(e){ e.preventDefault(); $("input:checkbox[name='import_record_id']").prop("checked", true).change(); }); $("#unCheckAll").click(function(e){ e.preventDefault(); $("input:checkbox[name='import_record_id']").prop("checked", false).change(); }); $("input#add_order").on("click", function(e){ e.preventDefault(); if ( $("input:checkbox[name='import_record_id']:checked").length < 1 ) { alert( __("There is no record selected") ); return false; } var error = 0; $("input:checkbox[name='import_record_id']:checked").parents('fieldset').find('input[name="quantity"]').each(function(){ if ( $(this).val().length < 1 || isNaN( $(this).val() ) ) { error++; } }); if ( error > 0 ) { alert(error + " " + __("quantity values are not filled in or are not numbers") ); return false; } error = checkOrderBudgets(); if ( error > 0 ) { alert( __("Some funds are not defined in item records") ); return false; } if (0 < CheckMandatorySubfields(this.form)) { // Open the item tab $('.nav-tabs .items_info').tab('show'); alert(__('Some required item subfields are not set')); return false; } disableUnchecked($(this.form)); $(this.form).submit(); }); $(".previewData").on("click", function(e){ e.preventDefault(); var ltitle = $(this).text(); var page = $(this).attr("href"); $("#dataPreviewLabel").text(ltitle); $("#dataPreview .modal-body").load(page + " div"); $('#dataPreview').modal({show:true}); }); $("#dataPreview").on("hidden.bs.modal", function(){ $("#dataPreviewLabel").html(""); $("#dataPreview .modal-body").html("