<%@language = "javascript" %>
<%  Server.ScriptTimeout=6000; %>
<% /*
     $Revision$
     $Id$

    File:               inlezen_form.asp
    Description:        Laat een willekeurig bestand inlezen
    Parameters:
        imp_key         Importfunctie key
    Context:            Vanuit imp_list
    Note:               Na inlezen sluiten we onzelf

*/
%>

<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="imp.inc" -->

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

var import_app_key = getQParamInt("import_app_key"); // Importfunctiekey

// Heb ik rechten om in te lezen
var this_imp = imp.func_enabled_import_app(import_app_key);
user.auth_required_or_abort(this_imp.canWrite);

var sql = "SELECT i.fac_import_app_charset "
        + "  FROM fac_import_app i"
        + " WHERE i.fac_import_app_key = " + import_app_key;
var oRs = Oracle.Execute(sql);
var charset = oRs("fac_import_app_charset").value;
oRs.Close();

%>

<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script>
      function doSubmit()
      {
        // Standaard checks op verplichte velden, datum formaat, numeriek en float formaat, currency formaat.
        if (!validateForm("u2"))
          return false

        document.getElementById("inlezen").innerHTML = L("lcl_imp_please_wait");
        document.importForm.submit();
        // JGL: Omzetten naar een $.post kun je wel vergeten, die kent geen multipart/form-data
      }
    </script>
  </head>

  <body id="editbody">
    <form name="importForm" id="importForm" method="POST" enctype="multipart/form-data"
          target="hidFrame" action="imp_inlezen.asp?import_app_key=<%=import_app_key%>" onsubmit="" onreset="">
<%    BLOCK_START("fileupload", L("lcl_imp_lezen") + " " + L("lcl_imp_file").toLowerCase());%>
      <tr>
        <td>
          <label><%=L("fac_import_app_charset")%>: <%=charset || 'windows-1252'%></label>
        </td>
      </tr>
      <tr>
        <td>
          <label><%=L("lcl_imp_file_name")%>:</label>
        </td>
      </tr>
      <tr>
        <td>
          <input type="file" name="imp_file" id="imp_file" class="required" style="width: 100%">
        </td>
        <td></td>
      </tr>
      <tr>
        <td id="inlezen">
          &nbsp;
        </td>
      </tr>
<%    BLOCK_END();
      var buttons = [];
      buttons.push({id: "doupload", title: L("lcl_imp_lezen"), action: "doSubmit()"});
      CreateButtons(buttons);
IFACE.FORM_END();
%>
    </form>
    <iframe height=0 width=100% name="hidFrame" id="hidFrame" src="../shared/empty.asp">
  </body>
</html>
