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

    File:           prs_edit_contactpersoon.asp
    Status:         90%
    Description:    edit or add persons
    Parameters:     dloc_key (required)


    Context:
    Note:

*/ %>

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

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

var prs_bdrkey = getQParamInt("bedrijf_key", -1);
var dloc_key = getQParamInt("dloc_key", -1);

var intern = getQParamInt("intern", 0) == 1;
if (intern)
    var autfunction = 'WEB_PRSMAN';
else
    var autfunction = 'WEB_RELMAN';

var authparams = user.checkAutorisation(autfunction)
// Veronderstel even dat ik schrijfrechten had om hier te komen
if (dloc_key > -1)
{
  sql = "SELECT   b.prs_bedrijf_key, "
      + "         b.prs_bedrijf_naam, "
      + "         d.prs_dienst_key, "
      + lcl.xsqla('d.prs_dienst_omschrijving', 'd.prs_dienst_key')
      + "    FROM prs_bedrijf b, "
      + "         prs_bedrijfdienstlocatie dl, "
      + "         prs_dienst d "
      + "   WHERE b.prs_bedrijf_intern IS NULL "
      + "     AND b.prs_bedrijf_verwijder IS NULL "
      + "     AND b.prs_bedrijf_key = dl.prs_bedrijf_key "
      + "     AND dl.prs_dienst_key = d.prs_dienst_key "
      + "     AND prs_bedrijfdienstlocatie_key = " + dloc_key
      + "ORDER BY UPPER("+lcl.xsql('d.prs_dienst_omschrijving', 'd.prs_dienst_key')+") ASC "

  oRs = Oracle.Execute(sql);

  var prs_bdrkey  = oRs("prs_bedrijf_key").value;
  var prs_dnstkey = oRs("prs_dienst_key").value;

  oRs.Close();
}
%>
<html>
  <head>
<%  FCLTHeader.Generate(); %>
    <script  type="text/javascript" >
      function dloc_submit()
      {
          document.activeElement.blur(); // trigger laatste onChanges
          if (!validateForm("u2"))
              return false;
          document.forms.u2.submit();
      }
      function dloc_cancel()
      {
          FcltMgr.closeDetail(window, { cancel: true } );
      }
    </script>
  </head>

  <body id="editbody">
<%  var buttons =  [ {title: L("lcl_submit"), action:"dloc_submit()", icon: "opslaan.png" },
                     {title: L("lcl_cancel"), action:"dloc_cancel()", icon: "undo.png" }];

    IFRAMER_HEADER(L("lcl_prs_dienst_frame"), buttons);
%>
    <div id="edit">
      <form name="u2"
            action="prs_edit_dienst_save.asp?dloc_key=<%=dloc_key%>&"
            method="post"
            target="hidFrameSubmit"
            onSubmit="dloc_submit();">
<%
        BLOCK_START("prsPerslid", L("lcl_prs_basisblok"));
%>      <input type="hidden" name="prs_bdrkey" value="<%=prs_bdrkey%>"><%
        sql = "SELECT   prs_bedrijf_key, "
            + "         prs_bedrijf_naam "
            + "    FROM prs_v_aanwezigbedrijf "
            + "   WHERE prs_bedrijf_intern IS NULL "
            + "ORDER BY prs_bedrijf_naam_upper "

        FCLTselector("prs_bdrkey2", sql,
                    { label: L("lcl_prs_dept_company"),
                      initKey: prs_bdrkey,
                      emptyOption: "",
                      readonly: true
                   });

        sql = "SELECT d.prs_dienst_key, "
            + lcl.xsqla('prs_dienst_omschrijving', 'prs_dienst_key')
            + " FROM  prs_dienst d"
            + " ORDER BY UPPER("+lcl.xsql('prs_dienst_omschrijving', 'prs_dienst_key')+")";

        FCLTselector("prs_dnstkey", sql,
                    { label: L("lcl_prs_companies_dienst"),
                      initKey: prs_dnstkey,
                      emptyOption: ""
                   });
        BLOCK_END();
IFACE.FORM_END();
%>
      </form>
      <iframe src="../Shared/empty.html" name="hidFrameSubmit" style="display:none"></iframe>
    </div>
  </body>
</html>
