Lines 11-36
$(document).ready(function() {
Link Here
|
11 |
"aaSorting": [] |
11 |
"aaSorting": [] |
12 |
}) ); |
12 |
}) ); |
13 |
|
13 |
|
|
|
14 |
checkOrderBudgets(); |
14 |
var all_budget_id = $("#all_budget_id"); |
15 |
var all_budget_id = $("#all_budget_id"); |
15 |
|
16 |
|
16 |
if( !all_budget_id.val() ){ |
17 |
$("#all_budget_id,[name='budget_id'],.budget_code_item,[name='import_record_id']").on("change", function(){ |
17 |
$(".fund label, .fund select").addClass("required").prop("required", true); |
18 |
checkOrderBudgets(); |
18 |
$(".fund span.required").show(); |
|
|
19 |
} |
20 |
|
21 |
all_budget_id.on("change", function(){ |
22 |
if( $(this).val() != "" ){ |
23 |
$(".fund label, .fund select").removeClass("required").prop("required", false); |
24 |
$(".fund select").each(function(){ |
25 |
if( $(this).val() == '' ){ |
26 |
$(this).val( all_budget_id.val() ); |
27 |
} |
28 |
}); |
29 |
$(".fund span.required").hide(); |
30 |
} else { |
31 |
$(".fund label, .fund select").addClass("required").prop("required", true); |
32 |
$(".fund span.required").show(); |
33 |
} |
34 |
}); |
19 |
}); |
35 |
|
20 |
|
36 |
$("#records_to_import fieldset.rows div").hide(); |
21 |
$("#records_to_import fieldset.rows div").hide(); |
Lines 80-97
$(document).ready(function() {
Link Here
|
80 |
|
65 |
|
81 |
} |
66 |
} |
82 |
|
67 |
|
83 |
if (! all_budget_id.val() ) { |
68 |
error = checkOrderBudgets(); |
84 |
// If there is no default fund |
69 |
if ( error > 0 ) { |
85 |
error = 0; |
70 |
alert( ERR_FUNDS_MISSING ); |
86 |
$(".selected [name='budget_id']").each(function(){ |
71 |
return false; |
87 |
if (!$(this).val()) { |
|
|
88 |
error++; |
89 |
} |
90 |
}); |
91 |
if ( error > 0 ) { |
92 |
alert( ERR_FUNDS_MISSING ); |
93 |
return false; |
94 |
} |
95 |
} |
72 |
} |
96 |
|
73 |
|
97 |
return disableUnchecked($(this)); |
74 |
return disableUnchecked($(this)); |
Lines 117-120
function disableUnchecked(){
Link Here
|
117 |
$(this).remove(); |
94 |
$(this).remove(); |
118 |
}); |
95 |
}); |
119 |
return 1; |
96 |
return 1; |
120 |
} |
97 |
} |
|
|
98 |
|
99 |
function checkOrderBudgets(){ |
100 |
var unset_funds = 0; |
101 |
var all_budget_id = $("#all_budget_id"); |
102 |
// If we don't have an overarching default set we need to check each selected order |
103 |
if ( !all_budget_id.val() ) { |
104 |
$("fieldset.biblio.rows.selected").each(function(){ |
105 |
var default_order_fund = $(this).find("[name='budget_id']"); |
106 |
// For each order we see if budget is set for order |
107 |
if( !default_order_fund.val() ){ |
108 |
$(this).find(".item_fund.required").show(); |
109 |
//If not we need to check each item on the order |
110 |
var item_funds = $(this).find(".budget_code_item"); |
111 |
if( item_funds.length ){ |
112 |
item_funds.each(function(){ |
113 |
if( !$(this).val() ){ |
114 |
$(this).addClass('required').prop("required", true); |
115 |
unset_funds++; |
116 |
} else { |
117 |
$(this).removeClass('required').prop("required", false); |
118 |
} |
119 |
}); |
120 |
} else { |
121 |
//If the order has no items defined then the order level fund is required |
122 |
default_order_fund.addClass('required').prop("required", true); |
123 |
$(this).find(".fund span.required").show(); |
124 |
$(this).find(".item_fund.required").hide(); |
125 |
unset_funds++; |
126 |
} |
127 |
} else { |
128 |
$(this).find(".fund span.required").hide(); |
129 |
// If fund is set for order then none of the others are required |
130 |
$(this).find(".budget_code_item").each(function(){ |
131 |
if( !$(this).val() ){ |
132 |
$(this).val( default_order_fund.val() ); |
133 |
$(this).removeClass('required').prop("required", false); |
134 |
} |
135 |
}); |
136 |
$(this).removeClass('required').prop("required", false); |
137 |
} |
138 |
}); |
139 |
} else { |
140 |
// Default is set overall, we just need to populate it through |
141 |
// to each order/item |
142 |
$("[name='budget_id'],.budget_code_item").each(function(){ |
143 |
if( !$(this).val() ){ |
144 |
$(this).val( all_budget_id.val() ); |
145 |
$(this).removeClass('required').prop("required", false); |
146 |
$(".item_fund.required").hide(); |
147 |
$(".fund span.required").hide(); |
148 |
} |
149 |
}); |
150 |
} |
151 |
return unset_funds; |
152 |
} |
153 |
|
154 |
|
155 |
|
121 |
- |
|
|