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

    File:               cad/loadDatumFilterOptions.asp.asp
    Description:        Aanmaken van de options voor een datumfilter
    Context:            Vanuit CAD als een label of thema is gekozen.
    Note:               Authorisatiecontrole is overkill omdat je alleen datums kunt opvragen
*/

DOCTYPE_Disable = true;
%>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../Shared/selector.inc" -->
<%

var label_key  = getQParamInt("label", -1);
var thema_key  = getQParamInt("thema", -1);

if (label_key > 0)
{
    var sql = "SELECT cad_label_view"
            + "  FROM cad_label"
            + " WHERE cad_label_key = " + label_key;
    var oRs = Oracle.Execute(sql);
    var viewname = oRs("cad_label_view").Value;
    oRs.Close();
}
else // moet thema_key > 0  zijn
{
    var sql = "SELECT cad_thema_view"
            + "  FROM cad_thema"
            + " WHERE cad_thema_key = " + thema_key;
    var oRs = Oracle.Execute(sql);
    var viewname = oRs("cad_thema_view").Value;
    oRs.Close();
}

var sql = "SELECT DISTINCT(fclt_f_datum) fclt_f_datum FROM {0} ORDER BY fclt_f_datum".format(viewname);
var oRs = Oracle.Execute(sql);
while (!oRs.Eof)
{
    var datum = new Date(oRs("fclt_f_datum").Value);
    var option = "\n<option value="+datum.getTime() + ">" + toDateString(datum) + "</option>";
    Response.Write(option);
    oRs.MoveNext();
}
oRs.Close();

ASPPAGE_END();
%>
