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

    File:           fac_locale_edit_std.asp
    Status:
    Description:    Bewerkscherm voor overrulen van één standaard lcl

    Parameters:     lcl_label lcl_complain

    Context:        Vanuit fac_locale_list_std
    Note:           Modal popupje
                    Altijd voor alle talen tegelijk

*/ %>
<!--#include file="../Shared/common.inc" -->
<!--#include file="../Shared/selector.inc" -->
<!--#include file="../Shared/iface.inc" -->

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

var autfunction = "WEB_LCLSYS";
var authparams = user.checkAutorisation(autfunction);

var submitting = getQParamInt("submit", 0) == 1;
var lcl_label = getQParam("lcl_label");

maxlen = 2000; // fac_locale_xsl_cust
%>

<html>
  <head>
<%
    FCLTHeader.Generate();

    if (submitting) {
        protectRequest.validateToken();
        for (l in S("language_toggles"))
        {
            var tekst = getFParam("lcl_cust_" + S("language_toggles")[l], "");
            var sql = "UPDATE fac_locale_xsl"
                    + "   SET fac_locale_xsl_cust = " + safe.quoted_sql(tekst, maxlen)
                    + " WHERE fac_locale_xsl_lang = " + safe.quoted_sql(S("language_toggles")[l])
                    + "   AND fac_locale_xsl_label = " + safe.quoted_sql(lcl_label)
                    + "   AND fac_locale_xsl_module = 'ASP'";
            Oracle.Execute(sql);
        }

%>
      <script type="text/javascript">
        FcltMgr.closeDetail( window, { success: true });
      </script>
<%
      Response.End;
    }
%>

  </head>
  <body class="modal" id="localebody">
      <form id="lclform" name="lclform" action="fac_locale_edit_std.asp?submit=1&lcl_label=<%=safe.htmlattr(lcl_label)%>" method="post">
<%
        BLOCK_START("lcl_locale_std", L("lcl_lcl_xsl_label") + ": " + safe.html(lcl_label));

        //kolomkeydata
        var talen_arr = [];
        var nn=0;
        for (l in S("language_toggles"))
        {
            talen_arr.push("SELECT " + safe.quoted_sql(S("language_toggles")[l]) + " fac_locale_lang, "+(nn++)+"volgorde FROM DUAL");
        }

        var talen = talen_arr.join(" UNION ");
        var sql = "SELECT tl.fac_locale_lang"
                + "     , l.fac_locale_xsl_tekst"
                + "     , l.fac_locale_xsl_cust"
                + "  FROM fac_locale_xsl l, ("+talen+") tl"
                + " WHERE l.fac_locale_xsl_label = " + safe.quoted_sql(lcl_label)
                + "   AND l.fac_locale_xsl_module = 'ASP'"
                + "   AND l.fac_locale_xsl_lang = tl.fac_locale_lang"
                + " ORDER BY volgorde";
        var oRs = Oracle.Execute(sql);

        while (!oRs.eof)
        {
            var fldname = "lcl_cust_"+oRs("fac_locale_lang").Value;
            ROFIELDTR("fldlclstd",
                      lcl.languages[oRs("fac_locale_lang").Value],
                      oRs("fac_locale_xsl_tekst").Value, {maxlength: maxlen });
            RWFIELDTR(fldname, "fldlclstd",
                      /*lcl.languages[oRs("fac_locale_lang").Value]*/"",
                      oRs("fac_locale_xsl_cust").Value, {maxlength: maxlen });

            oRs.MoveNext();
        }

        sql = "SELECT COUNT(DISTINCT fac_locale_xref_filepath)"
              + "  FROM fac_locale_xsl l,"
              + "       fac_locale_xref x"
              + " WHERE fac_locale_xsl_module = 'ASP'"
              + "   AND x.fac_locale_xsl_key = l.fac_locale_xsl_key"
              + "   AND l.fac_locale_xsl_label = " + safe.quoted_sql(lcl_label);
        var oRs = Oracle.Execute(sql);
        var n_records = oRs(0).Value;
        oRs.Close();

/*
        var res = FCLTselector("mldstatusmulti",
                      sql,
                      { label: L("lcl_lcl_infiles"),
                        trclass:"hidden",
                        multi: true,
                        size: 10
                      });
*/
        %><tr><td colspan="2"><%=L("lcl_lcl_n_file") + ": " + n_records%></td></tr><%
        BLOCK_END();

        var buttons =  [ {title: L("lcl_submit"), icon: "opslaan.png", action: "document.forms.lclform.submit()" },
                         {title: L("lcl_cancel"), icon: "undo.png", action: "FcltMgr.closeDetail(window, { cancel: true } )" }];
        CreateButtons(buttons)
IFACE.FORM_END();
%>
      </form>
  </body>
</html>
