122 lines
4.0 KiB
JavaScript
122 lines
4.0 KiB
JavaScript
$(document).ready(function () {
|
|
setTimeout("init_budget()", 100);
|
|
});
|
|
|
|
function init_budget()
|
|
{
|
|
$("#budgetdiscipline").change(function() {change_discipline(); });
|
|
$("#budgetproject").change(function() {change_project(); });
|
|
$("#budgetcostcategory").change(function() {change_rubriek(); });
|
|
$("#costtypegroup").change(function() {change_groep(); });
|
|
$("#costtype").change(function() {change_soort(); });
|
|
|
|
var init_niveau = "";
|
|
var init_key = -1;
|
|
if ($("#budgetdiscipline").val() != -1) { init_niveau = "D"; init_key = $("#budgetdiscipline").val(); }
|
|
if ($("#budgetproject").val() != -1) { init_niveau = "P"; init_key = $("#budgetproject").val(); }
|
|
if ($("#budgetcostcategory").val() != -1) { init_niveau = "R"; init_key = $("#budgetcostcategory").val(); }
|
|
if ($("#costtypegroup").val() != -1) { init_niveau = "G"; init_key = $("#costtypegroup").val(); }
|
|
if ($("#costtype").val() != -1) { init_niveau = "S"; init_key = $("#costtype").val(); }
|
|
|
|
if (init_key > 0)
|
|
{
|
|
$.getJSON( "../bgt/get_bgt_info_ajax.asp",
|
|
{ req_info: "initsearch",
|
|
niveau: init_niveau,
|
|
parent_key: -1,
|
|
init_key: init_key
|
|
},
|
|
re_init);
|
|
}
|
|
}
|
|
|
|
function re_init(data)
|
|
{
|
|
fill_rubriekselector("D", -1 , data.parents.D);
|
|
fill_rubriekselector("P", data.parents.D, data.parents.P);
|
|
fill_rubriekselector("R", data.parents.P, data.parents.R);
|
|
fill_rubriekselector("G", data.parents.R, data.parents.G);
|
|
fill_rubriekselector("S", data.parents.G, data.parents.S);
|
|
}
|
|
|
|
function change_discipline()
|
|
{
|
|
var discipline_key = $("#budgetdiscipline").val();
|
|
process_info({niveau:"R",lov:[]});
|
|
process_info({niveau:"G",lov:[]});
|
|
process_info({niveau:"S",lov:[]});
|
|
fill_rubriekselector("P", discipline_key);
|
|
}
|
|
function change_project()
|
|
{
|
|
var project_key = $("#budgetproject").val();
|
|
process_info({niveau:"G",lov:[]});
|
|
process_info({niveau:"S",lov:[]});
|
|
fill_rubriekselector("R", project_key);
|
|
}
|
|
function change_rubriek()
|
|
{
|
|
var rubriek_key = $("#budgetcostcategory").val();
|
|
process_info({niveau:"S",lov:[]});
|
|
fill_rubriekselector("G", rubriek_key);
|
|
}
|
|
function change_groep()
|
|
{
|
|
var groep_key = $("#costtypegroup").val();
|
|
fill_rubriekselector("S", groep_key);
|
|
}
|
|
function change_soort()
|
|
{
|
|
var soort_key = $("#costtype").val();
|
|
if ($("#contingency").length)
|
|
$("#contingency").prop("disabled", (soort_key > 0 ? false: true) );
|
|
}
|
|
|
|
function fill_rubriekselector(niveau, parent_key, init_key)
|
|
{
|
|
$.getJSON( "../bgt/get_bgt_info_ajax.asp",
|
|
{ req_info: "projectsearch",
|
|
niveau: niveau,
|
|
parent_key: parent_key,
|
|
init_key: init_key
|
|
},
|
|
process_info);
|
|
}
|
|
|
|
|
|
function process_info(data)
|
|
{
|
|
var select;
|
|
switch(data.niveau)
|
|
{
|
|
case "D": select = $("#budgetdiscipline"); break;
|
|
case "P": select = $("#budgetproject"); break;
|
|
case "R": select = $("#budgetcostcategory"); break;
|
|
case "G": select = $("#costtypegroup"); break;
|
|
case "S": select = $("#costtype"); break;
|
|
}
|
|
|
|
var sel_key = -1;
|
|
var new_lov = '<option value="-1" ></option>';
|
|
if (data.lov.length > 0)
|
|
{
|
|
for (i=0; i<data.lov.length;i++)
|
|
{
|
|
var opt = data.lov[i];
|
|
new_lov += '<option value="' + opt.key + '"' + (opt.sel?"selected":"") + '>'+ opt.oms + '</option>';
|
|
if (opt.sel) sel_key = opt.key;
|
|
}
|
|
select.prop("disabled", false);
|
|
}
|
|
else
|
|
{
|
|
select.prop("disabled", true);
|
|
}
|
|
select.empty().append(new_lov);
|
|
if (sel_key > -1)
|
|
select.val(sel_key);
|
|
|
|
if ($("#contingency").length) // dit veld bestaat alleen in bgt_budget.
|
|
$("#contingency").prop("disabled", true);
|
|
}
|