<%@ language = "JavaScript" %>
<%
/*
    $Revision$
    $Id$

    File:               get_ins_info_ajax.asp
    Description:        Ophalen van allerlei info om client-side data te hebben
    Parameters:         req_info:   "ins_discipline_key"    --> requires "ins_discipline_key"

    Context:
    Note:
    Sample:             appl/ins/get_ins_info_ajax.asp?req_info=ins_discipline_key&disc_key=1

*/ %>

<%
var JSON_Result = true;
%>

<!-- #include file="../Shared/common.inc"-->
<!-- #include file="../Shared/json2.js" -->
<!-- #include file="./ins.inc" -->
<%
var req_info = getQParam("req_info");
var result = {};
switch (req_info)
{
    case "ins_discipline_key":
    {
        var disc_key = getQParamInt("disc_key");
        result = ins.ins_disciplineinfo(disc_key);
        break;
    }
    case "ins_srtinstallatie":
    {
        var niveau = getQParam("niveau","");
        var install_key = getQParamInt("install_key");
        var init_key = getQParamInt("init_key", -1);

        var sql = "SELECT ins_srtinstallatie_key"
                + "     , DECODE(niveau, 'D', discipline_oms"
                + "                    , 'G', srtgroep_oms"
                + "                    , 'S', srtdeel_oms) ins_srtinstallatie_oms"
                + "  FROM ins_v_allsrtinstallatie"
                + " WHERE niveau = " + safe.quoted_sql(niveau);
        switch(niveau)
        {
            case "G": sql += " AND ins_discipline_key = " + install_key; break;
            case "S": sql += " AND ins_srtgroep_key = " + install_key; break;
        }
        sql += " ORDER BY 2"
        var new_lov = [];
        var oRs = Oracle.Execute(sql);
        while(!oRs.eof)
        {
            new_lov.push({key: oRs("ins_srtinstallatie_key").Value,
                          oms: oRs("ins_srtinstallatie_oms").Value,
                          sel: oRs("ins_srtinstallatie_key").Value == init_key});
            oRs.MoveNext();
        }
        oRs.Close();
        result.niveau = niveau;
        result.lov = new_lov;

        break;
    }
}

Response.Write(JSON.stringify(result));
%>
