+
+ $("select[name='budget_id']").change(function(){
+ var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
+ var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
+ var destination_sort1 = $(this).parents('fieldset').find('li.sort1').find('input[name="sort1"]');
+ var sort1 = $(destination_sort1).val() || "";
+ if ( destination_sort1.length < 1 ) {
+ destination_sort1 = $(this).parents('fieldset').find('li.sort1 > select[name="sort1"]');
+ }
+ var destination_sort2 = $(this).parents('fieldset').find('li.sort2').find('input[name="sort2"]');
+ var sort2 = $(destination_sort2).val() || "";
+ if ( destination_sort2.length < 1 ) {
+ destination_sort2 = $(this).parents('fieldset').find('li.sort2').find('select[name="sort2"]');
+ }
+ getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1, sort1 );
+
+ getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2, sort2 );
+ } );
+
+ $("select[name='budget_id']").change();
+
+ $("select[name='all_budget_id']").change(function(){
+ var sort1_authcat = $(this).find("option:selected").attr('data-sort1-authcat');
+ var sort2_authcat = $(this).find("option:selected").attr('data-sort2-authcat');
+ var destination_sort1 = $(this).parent().siblings('li').find('input[name="all_sort1"]');
+ if ( destination_sort1.length < 1 ) {
+ destination_sort1 = $(this).parent().siblings('li').find('select[name="all_sort1"]');
+ }
+ var destination_sort2 = $(this).parent().siblings('li').find('input[name="all_sort2"]');
+ if ( destination_sort2.length < 1 ) {
+ destination_sort2 = $(this).parent().siblings('li').find('select[name="all_sort2"]');
+ }
+ getAuthValueDropbox( 'sort1', sort1_authcat, destination_sort1 );
+ getAuthValueDropbox( 'sort2', sort2_authcat, destination_sort2 );
+ $(this).parent().siblings('li').find('select[name="sort1"]').attr('name', 'all_sort1');
+ $(this).parent().siblings('li').find('input[name="sort1"]').attr('name', 'all_sort1');
+ $(this).parent().siblings('li').find('select[name="sort2"]').attr('name', 'all_sort2');
+ $(this).parent().siblings('li').find('input[name="sort2"]').attr('name', 'all_sort2');
+ } );
+
+ $("#records_to_import fieldset.rows ol").hide();
+ $('input:checkbox[name="import_record_id"]').change(function(){
+ var container = $(this).parents("fieldset");
+ if ( $(this).is(':checked') ) {
+ $(container).addClass("selected");
+ $(container).removeClass("unselected");
+ $(container).find("ol").toggle();
+ } else {
+ $(container).addClass("unselected");
+ $(container).removeClass("selected");
+ $(container).find("ol").toggle();
+ }
+ } );
+
+ $("input:checkbox").attr("checked", false);
+ $("div.biblio.unselected select").attr("disabled", false);
+ $("div.biblio.unselected input").attr("disabled", false);
+
+ $("#checkAll").click(function(){
+ $("#Aform").checkCheckboxes();
+ $("input:checkbox[name='import_record_id']").change();
+ return false;
+ });
+ $("#unCheckAll").click(function(){
+ $("#Aform").unCheckCheckboxes();
+ $("input:checkbox[name='import_record_id']").change();
+ return false;
+ });
+
+ $("#Aform").on("submit", function(){
+ 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 or not a number"));
+ return false;
+ }
+
+ return disableUnchecked($(this));
+ });