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

     File:        melding_menu.asp
     Description: Alternatieve interface om (eenvoudig) een melding te kunnen kiezen
                  Veronderstelt wel dat er niet al te schrikbarend veel meldingen zijn.
     Parameters:  lvl: het groeperingslevel,
                        0=vakgroeptype
                        1=vakgroep (default)
                        2=mld_stdmeldinggroep
                        9=stdmelding
                  urole: indien fo, dan wordt MLDFOF autorisatie gebruikt ipv MLDUSE
     Context:     -
     Note:        Beetje aan het experimenteren. De # bij de kleurcodes is nog inconsequent in de db (FCLT#64203)

*/%>

<!-- #include file="../Shared/common.inc" -->
<!-- #include file="./mobile.inc" -->
<!-- #include file="../Shared/FlexFiles.inc" -->
<!-- #include file="./iface.inc" -->
<!-- #include file="../mld/mld_fe_menu.inc" -->

<%
FCLTHeader.Requires({ plugins: ["jQuery"],
                      js: ["jQuery-ui.js"]
                    });

var urole = getQParamSafe("urole", "fe");
var lvl = getQParamInt("lvl", 1);

var disc_key_arr = getQParamIntArray("disc", []);
var srtdisc_key_arr = getQParamIntArray("srtdisc", []);
var stdmgroep_key_arr = getQParamIntArray("stdmgroepkey", []);

var fso = Server.CreateObject("Scripting.FileSystemObject");
function findImage(filename)
{
    filename = safe.filename(filename);
    if (fso.FileExists(Server.MapPath(S("mlds_image_path")) + "/" + filename))
        return S("mlds_image_path") + "/" + filename;
    return "";
}
%>
<html>
    <head>
<% FCLTMHeader.Generate({ title: L("lcl_mobile_newmelding") }); %>
    </head>
    <body>
<%
    PAGE_START();

    var page_title, imgModule;
    switch (lvl) {
        case 0:  page_title = L("lcl_mobile_selectmeldingtype"); imgModule = "MLDSD"; break;
        case 1:  page_title = L("lcl_mobile_selectmldisc");      imgModule = "MLDD";  break;
        case 2:  page_title = L("lcl_mobile_selectmldgroep");    imgModule = "MLDG";  break;
        case 9:
        default: page_title = L("lcl_mobile_selectmelding");     imgModule = "MLDS";  break;
    }

    HEADER({ title: page_title, home: true, back: true, location: false });
    CONTENT_START();

    var sql = mld_fe_menu.get_mobile_menu_sql(lvl, urole, { srtdisc_key_arr:    srtdisc_key_arr,
                                                            disc_key_arr:       disc_key_arr,
                                                            stdmgroep_key_arr:  stdmgroep_key_arr
                                                        });
    var oRs = Oracle.Execute(sql);

    var items = [];
    while (!oRs.eof) {
        if (lvl == 9)
        {
            items.push({
                "href": (oRs("mld_stdmelding_externurl").Value || "melding_new.asp?urole=" + urole + "&stdm=" + oRs("mld_stdmelding_key").Value),
                "desc":  oRs("mld_stdmelding_omschrijving").Value || "",
                "img":   SYMBOL(oRs("mld_stdmelding_image").Value, { "module": imgModule, "alt": oRs("mld_stdmelding_omschrijving").Value, "defVal": "fa-question fa-rotate-180" }),
                "color": oRs("mld_stdmelding_color").Value || ""
            });
            oRs.MoveNext();
        }
        else
        {
            var qs = buildTransitParam(["urole"]);
            var copy_arr = [];
            switch (lvl) {
                case 0: qs += "&srtdisc="      + oRs("ins_srtdiscipline_key").Value; break;
                case 1: qs += "&disc="         + oRs("ins_discipline_key").Value; break;
                case 2: qs += "&stdmgroepkey=" + oRs("mld_stdmeldinggroep_key").Value; break;
            }
            qs += (lvl != 0 && srtdisc_key_arr.length   ? "&srtdisc="      + srtdisc_key_arr.join(",")   : "")
                + (lvl != 1 && disc_key_arr.length      ? "&disc="         + disc_key_arr.join(",")      : "")
                + (lvl != 2 && stdmgroep_key_arr.length ? "&stdmgroepkey=" + stdmgroep_key_arr.join(",") : "");

            items.push({
                "href":  "melding_menu.asp?lvl=9" + qs,
                "desc":  oRs("descr").Value || "",
                "img":   SYMBOL(oRs("image").Value, { "module": imgModule, "alt": oRs("descr").Value, "defVal": "fa-question fa-rotate-180" }),
                "color": oRs("color").Value || ""
            });
            oRs.MoveNext();
        }
    }
    oRs.Close();

    ICON_GRID(items);

    CONTENT_END();
    FOOTER();
    PAGE_END();
PDA_PAGE_END(); %>
	</body>
</html>
<% ASPPAGE_END(); %>
