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

    File:
    Description:
    Parameters:
    Note:

*/
%>

<!-- #include file="../../appl/Shared/common.inc" -->
<!-- #include file="../../appl/Shared/selector.inc" -->
<!-- #include file="../../appl/ins/ins.inc" -->
<!-- #include file="../../appl/ins/ins_flexkenmerksrtcontrole.inc" -->
<!-- #include file="../../appl/pda/mobile.inc" -->
<!-- #include file="../../appl/pda/iface.inc" -->
<!-- #include file="../../appl/pda/resultset_table.inc" -->

<%
// Get parameters

var qrc=0;
var locatie = getQParam("locatie", "None");
var locatie_key = getQParamInt("locatie_key", -1);

%>
  <html>
    <head>
<%    FCLTMHeader.Generate({}); %>
    </head>
    <body>
<%

if (locatie_key != -1)
{
  PAGE_START();
  HEADER({title: "Locatie ingevuld", back:0, home:1});
  CONTENT_START();
   var sql = 
          " SELECT DISTINCT ins_deel_key, ins_srtcontrole_key, p.prs_perslid_key from asdl_v_rap_schoonmaak_today s, prs_kenmerklink kl, prs_perslid p"
          + " WHERE s.ins_srtcontroledl_xcp_groep = kl.prs_kenmerklink_waarde "
          + "   AND kl.prs_kenmerk_key = 1000 "
          + "   AND p.prs_perslid_key = " + user_key
          + "   AND kl.prs_link_key = " + user_key
          + "   AND alg_locatie_key = p.alg_onroerendgoed_keys ";
   oRs = Oracle.Execute(sql);
   while (!oRs.eof)
   {
      sqll = "INSERT INTO ins_deelsrtcontrole (ins_deelsrtcontrole_datum, ins_deel_key, ins_srtcontrole_key, ins_controlemode_key, prs_perslid_key, ins_deelsrtcontrole_datum_org) "
           + " VALUES (SYSDATE, " + oRs("ins_deel_key").Value
           + ", " + oRs("ins_srtcontrole_key").Value
           + ", 10, " + oRs("prs_perslid_key").Value
           + ", SYSDATE )";
      Oracle.Execute(sqll);
      oRs.MoveNext();
   }
   oRs.Close();

   ROFIELD("sel_srtcontrole_oms", "Locatie", locatie, {});
}
else
{

  PAGE_START();
  HEADER({title: "Deze locatie compleet afmelden?", back:!qrc, home:1});
  CONTENT_START();

  function fncolLink(oRs)
  {
    return "../../cust/asdl/afmelden_locatie.asp?locatie_key=" + oRs("alg_locatie_key").Value+"&locatie=" + oRs("alg_locatie_omschrijving").Value;
  };


  var sql = "SELECT  DISTINCT alg_locatie_key, alg_locatie_omschrijving, alg_locatie_x from asdl_v_rap_schoonmaak_today s, prs_kenmerklink kl, prs_perslid p"
          + " WHERE s.ins_srtcontroledl_xcp_groep = kl.prs_kenmerklink_waarde "
          + "   AND kl.prs_kenmerk_key = 1000 "
          + "   AND p.prs_perslid_key = " + user_key
          + "   AND kl.prs_link_key = " + user_key
          + "   AND alg_locatie_key = p.alg_onroerendgoed_keys "
          + " ORDER BY alg_locatie_x"

  var rst = new ResultsetTable({sql: sql,
                                keyColumn: "alg_locatie_key",
                                linkColumn: fncolLink,
                                detailColumn: "alg_locatie_omschrijving",
                                ID: "srtcontroletable",
                                showAll: true
                                });

  var cnt = rst.processResultset();

  CONTENT_END();
  FOOTER();
  PAGE_END();
}
%>
    </body>
  </html>
