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

     File:           prs_show_bedrijfadres.asp
     Description:
     Parameters:     badr_key (required)

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

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

  var badr_key  = getQParamInt("badr_key");
  var autfunction = "WEB_PRSMGT";
  var authparams = user.checkAutorisation(autfunction);

  function Adrestype(oRs)
  {
    var rval = "?";
    switch (oRs("prs_bedrijfadres_type").value)
    {
      case "B": rval = L("lcl_prs_bedrijfadres_type_b"); break;
      case "O": rval = L("lcl_prs_bedrijfadres_type_o"); break;
      case "C": rval = L("lcl_prs_bedrijfadres_type_c"); break;
    }
    return rval;
  }

  sql = "SELECT a.prs_bedrijfadres_key"
      + ", a.prs_bedrijf_key"
      + ", b.prs_bedrijf_naam"
      + ", a.prs_bedrijfadres_type"
      + ", a.mld_typeopdr_key"
      + ", " + lcl.xsqla("t.mld_typeopdr_omschrijving", "t.mld_typeopdr_key")
      + ", a.prs_bedrijfadres_url"
      + ", a.prs_bedrijfadres_username"
      + ", a.prs_bedrijfadres_password"
      + ", a.prs_bedrijfadres_ordermode"
      + ", a.prs_bedrijfadres_certificate"
      + ", a.prs_bedrijfadres_xsl"
      + ", a.prs_bedrijfadres_ext"
      + ", a.prs_bedrijfadres_attachfile"
      + ", a.prs_bedrijfadres_flexfiles"
      + "  FROM prs_bedrijfadres a"
      + "     , prs_bedrijf b"
      + "     , mld_typeopdr t"
      + " WHERE b.prs_bedrijf_key = a.prs_bedrijf_key"
      + "   AND a.mld_typeopdr_key = t.mld_typeopdr_key(+)"
      + "   AND prs_bedrijfadres_key = " + badr_key;
  oRs = Oracle.Execute(sql);
  if (oRs.Eof)
    shared.record_not_found();

  var prs_bdrkey       = oRs("prs_bedrijf_key").value;
  var prs_bdrnaam      = oRs("prs_bedrijf_naam").value;
  var prs_type         = Adrestype(oRs);
  var prs_typeopdr     = oRs("mld_typeopdr_key").value;
  var prs_typeopdr_oms = oRs("mld_typeopdr_omschrijving").value;
  var prs_url          = oRs("prs_bedrijfadres_url").value;
  var username         = oRs('prs_bedrijfadres_username').value;
  var password         = oRs('prs_bedrijfadres_password').value;
  var prs_ordermode    = oRs("prs_bedrijfadres_ordermode").value;
  var prs_cert         = oRs("prs_bedrijfadres_certificate").value;
  var prs_xsl          = oRs("prs_bedrijfadres_xsl").value;
  var prs_ext          = oRs("prs_bedrijfadres_ext").value;
  var bijlage          = oRs('prs_bedrijfadres_attachfile').value;
  var flexfiles        = oRs('prs_bedrijfadres_flexfiles').value;

  oRs.Close();
%>
<html>
  <head>
<%
   FCLTHeader.Generate();
%>
<script type="text/javascript">
    function badr_change()
    {
      if (FcltMgr.startEdit(window))
        window.location.href = "prs_edit_bedrijfadres.asp?badr_key=<%=badr_key%>"
    }
    function badr_delete()
    {
      if (confirm(L("lcl_prs_del_txt_bedrijfadres")))
      {
        var data = { prs_type: "X"
                   };
        <% protectRequest.dataToken("data"); %>
        $.post( "prs_edit_bedrijfadres_save.asp?bedrijf_key=<%=prs_bdrkey%>&badr_key=<%=badr_key%>"
              , data
              , FcltCallbackClose
              , "json");
      }
    }
</script>
  </head>

  <body id="showbody">
<%
    var buttons = [];

    if (authparams.PRSwritelevel < 9)
    {
      buttons = [ {title: L("lcl_change"), action:"badr_change()", icon: "wijzigen.png" }
                , {title: L("lcl_delete"), action:"badr_delete()", icon: "delete.png" }
                ];
    }
    IFRAMER_HEADER(L("lcl_prs_bedrijfadres_frame"), buttons);
%>
    <div id="show">
      <form name=u2>
<%
      BLOCK_START("prsBedrijfadres", L("lcl_prs_basisblok"));
        ROFIELDTR("fld", L("lcl_prs_companies_name"),              prs_bdrnaam);
        ROFIELDTR("fld", L("lcl_prs_bedrijfadres_type"),           prs_type,         {suppressEmpty:true});
        ROFIELDTR("fld", L("lcl_mld_typeopdr"),                    prs_typeopdr_oms, {suppressEmpty:true});
        ROFIELDTR("fld", L("lcl_prs_bedrijfadres_url"),            prs_url,          {suppressEmpty:true});
        ROFIELDTR("fld", L("lcl_prs_bedrijfadres_username"),       username,         {suppressEmpty:true});
        ROFIELDTR("fld", L("lcl_prs_bedrijfadres_wachtwoord"),     password,         {suppressEmpty:true});
        ROFIELDTR("fld", L("lcl_prs_companies_order_mode"),        prs_ordermode,    {suppressEmpty:(prs_ordermode==0?false:true)});
        ROFIELDTR("fld", L("lcl_prs_companies_order_certificate"), prs_cert,         {suppressEmpty:true});
        ROFIELDTR("fld", L("lcl_prs_companies_xsl"),               prs_xsl,          {suppressEmpty:true});
        ROFIELDTR("fld", L("lcl_prs_bedrijfadres_ext"),            prs_ext,          {suppressEmpty:true});
        ROFIELDTR("fld", L("lcl_prs_bedrijfadres_bijlage"),        bijlage,          {suppressEmpty:true});
        ROCHECKBOXTR("fldcheck", L("lcl_puo_order_flexfiles"), flexfiles==0 && S("puo_order_flexfiles")==1 || flexfiles==1);
      BLOCK_END();

    IFACE.FORM_END();
%>
      </form>
    </div>
  </body>
</html>
