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

    File:               res_select_room.asp
    Description:        Selecteer een (geschikte) ruimte via een planbord
    Parameters:         rsv_ruimte_key (mag -1 zijn voor nieuwe)
                        bezoekers
                        date_from
                        locatie_key

    Context:            Met knop uit res_edit_rsv_ruimte.asp
    Note:
*/ %>

<!-- #include file="../Shared/common.inc" -->
<!-- #include file="../res/res.inc" -->
<!-- #include file="../Shared/iface.inc" -->
<!-- #include file="../Shared/discxalg3d.inc"-->
<!-- #include file="res_plan_room_v2.inc" -->

<%
FCLTHeader.Requires({plugins: ["jQuery"],
                        css : ["../res/res.css"]})

// Required parameters
var urole = getQParamSafe("urole");
var rsv_ruimte_key = getQParamInt("rsv_ruimte_key");
var locatie_key = getQParamInt("locatie_key", -1);
var gebouw_key = getQParamInt("gebouw_key", -1);
var activiteit_key = getQParamInt("activiteit_key");

var sql = "SELECT res_srtactiviteit_key, "
        + lcl.xsqla('a.res_activiteit_omschrijving', 'a.res_activiteit_key')
        + "     , a.res_activiteit_duur"
        + "     , a.res_activiteit_posttime"
        + "  FROM res_activiteit a"
        + " WHERE res_activiteit_key = " + activiteit_key;
var oRs = Oracle.Execute(sql);
var act_posttime = oRs("res_activiteit_posttime").Value;
var srtact_key = oRs("res_srtactiviteit_key").Value;
oRs.Close();

if (rsv_ruimte_key > -1)
{
  var sql = "SELECT res_rsv_ruimte_van"
          + "     , res_rsv_ruimte_tot"
          + "  FROM res_rsv_ruimte"
          + " WHERE res_rsv_ruimte_key = " + rsv_ruimte_key;
  var oRs = Oracle.Execute(sql);
  var cur_date_from = new Date(oRs("res_rsv_ruimte_van").Value);
  var cur_date_to = new Date(oRs("res_rsv_ruimte_tot").Value);
  oRs.Close();
}

var res_ruimte_key = getQParamInt("res_ruimte_key", -1); // Filter default vergaderzaal

var date_from = getQParamDate("date_from");
var date_to = getQParamDate("date_to");
var ruimtecat = getQParamIntArray("s_ruimtecat", []);
var vis = getQParamInt("vis", null);

var autfunction = urole == "fe"? "WEB_RESUSE" : "WEB_RESFOF";

var width_px = getQParamInt("width_px", 1024);
%>
<html>
    <head>
    <%  FCLTHeader.Generate() %>
    </head>
<body class="fclt-modal" id="mod_res_selectroom">
<%
var params = {id: "tab_room_sched",
              cur_van: cur_date_from || null,
              cur_tot: cur_date_to || null,
              res_van: date_from,
              res_tot: date_to,
              loc_key_arr: locatie_key > 0 ? [locatie_key] : [],
              bld_key_arr: gebouw_key > 0 ? [gebouw_key] : [],
              ruimtecat: ruimtecat,
              res_ruimte_key: res_ruimte_key,
              rsv_ruimte_key: rsv_ruimte_key,
              vis: vis,
              act_key_arr: activiteit_key ? [activiteit_key] : [],
              act_post_time: act_posttime,
              srtact: srtact_key,
              forSelectRoom: true,
              authparams: user.checkAutorisation(autfunction, null, null, true), // pessimistisch
              urole: urole,
              width_px: width_px,
              isSelection: true,
              sort_on_count: S("res_lookhistory_days") > 0, // depending on new setting
              sort: getQParamSafe("sort", "")
             };

var plan_rooms_info = res.plan_rooms_info(params);
var plan_bezet_info = res.plan_bezet_info(params);
make_plan_room(plan_rooms_info, plan_bezet_info, params);

/* Extern is hier (nog) niet logisch?
var url = "http://sgf12/branch534/?API=RESINFO&APIKEY=E0E1EA02E3264324&fac_id=UWVA&pretty=1";

params.request = "plan_rooms_info";
var plan_rooms_info = HTTP.getJSON(url, { data: params });
params.request = "plan_bezet_info";
var plan_bezet_info = HTTP.getJSON(url, { data: params });
var vraag = JSON.stringify(params, null);

if (plan_rooms_info && plan_bezet_info)
    make_plan_room(plan_rooms_info, plan_bezet_info, params);
*/
%>
</body>
</html><% ASPPAGE_END(); %>
