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

    File:           fac_functie.asp

    Description:    Ingang via functies om autorisaties te beheren
                    Ook: als je ?editmode=1 meegeeft kun je de omschrijving
                    bewerken van userfuncties

    Context:        Vanuit het menu

    Notes:
*/
%>

<!-- #include file="../scf/scaffolding.inc" -->
<!-- #include file="../mgt/mgt_tools.inc" -->
<!-- #include file="../api2/model_fac_functie.inc" -->

<%
    var editmode = getQParamInt("editmode", 0);

    var groep_key = getQParamInt("fac_groep", -1);
    var disc_key = getQParamInt("ins_discipline", -1);
    var model = new model_fac_functie(null, { groep_key: groep_key, disc_key: disc_key });

    if (editmode == 1)
    {
        model.gparams.GET.wheres =["fac_functie_code LIKE 'WEB_USER%'"];
        model.REST_PUT = generic_REST_PUT(model);
    }

    settings.overrule_setting("qp_maxrows", 250); // Toon alle 186 (DB28) functies direct

    function fnrowData(oRs)
    {
      var data = { funcdisc: oRs.Fields("discipline").Value.id };
      return JSON.stringify(data);
    }

    var scf_params =
        {
            "search": {
                "autosearch": !!model.module,
                "filters": [
                    "module",
                    "description"
                ]
            },
            "list": {
                "columns": [
                    "id",
                    //"module",
                    "name",
                    "description",
                    "discipline"
                  ],
                "orderby": [
                    "module",
                    "name",
                    "description"
                 ],
                "fnRowData": fnrowData,
                "requires": {
                  js: ["./fac_functie.js"]
                },
                "script": "window.groep_key = " + groep_key + "; window.disc_key = " + disc_key
            },
            "edit":{
                "modal": true
            },
            "transit": {
                "fac_groep": groep_key,
                "ins_discipline" : disc_key,
                "editmode" : editmode
            }
        };
    if (editmode == 1)
    {
        scf_params.search.filters.shift(); // "module" filter er uit
        scf_params.search.autosearch = true;
    }
    else
    {
        scf_params.list.default_action = "edit_rechten";
    }

    if (groep_key > 0)
    {
        var groep_desc = Oracle.Get("fac_groep_omschrijving", "fac_groep", groep_key);
        scf_params.search.title = groep_desc;
        scf_params.search.labels.push({ "lbl": L("fac_groep"), "txt" : groep_desc});
        scf_params.search.labels.push({ "lbl": L("fac_groep_opmerking"), "txt" : Oracle.Get("fac_groep_opmerking", "fac_groep", groep_key)});
        scf_params.list.columns.push(
                    "authorization.ins_discipline",
                    "authorization.prs_level_read",
                    "authorization.prs_level_write",
                    "authorization.alg_level_read",
                    "authorization.alg_level_write"
                    );
    }
    if (disc_key > 0)
    {
        scf_params.search.labels.push({ "lbl": L("ins_discipline_key"), "txt" : Oracle.Get("ins_discipline_omschrijving", "ins_tab_discipline", "ins_discipline_key", disc_key)});
        scf_params.list.columns.pop(); // Discipline kolom mag er nu wel tussenuit
        scf_params.list.columns.push(
                    "authorization.fac_groep",
                    "authorization.prs_level_read",
                    "authorization.prs_level_write",
                    "authorization.alg_level_read",
                    "authorization.alg_level_write"
                    );
    }
    else
            scf_params.search.filters.push("name");
    scaffolding(model, scf_params);
%>
