<%@ LANGUAGE = JavaScript %>

<% /*
     $Revision$
     $Id$

    File:               res_xml.asp
    Description:        XML converter for reserveringen
    Parameters:
        res_key               required, key of the reservation to convert into XML
        print_rsv_ruimte_key  optional, key of res_rsv_ruimte if only part needs printing

    Context:            Called from: anywhere where res print icon is available
    Note:
*/
DOCTYPE_Disable = 1;
%>

<!-- #include file="../Shared/common.inc"-->
<!-- #include file="../Shared/xml_converter.inc" -->
<!-- #include file="./res.inc" -->

<%
    var res_key = getQParamInt("res_key", -1);

    // when print_rsv_ruimte_key == null, print whole reservation otherwise print part reservation with that specific res_rsv_ruimte_key
    var print_rsv_ruimte_key = getQParamInt("print_rsv_ruimte_key", null);
    if (print_rsv_ruimte_key)
    {
        chk_key = print_rsv_ruimte_key
    }
    else
    {
        // In theorie moeten we controleren of je *elke* deelreservering wel mag lezen
        // In de praktijk controleren we alleen of je de eerste mag lezen
        var sql = "SELECT MIN(res_rsv_ruimte_key) res_rsv_ruimte_key"
                + "  FROM res_v_aanwezigrsv_ruimte"
                + " WHERE res_reservering_key = " + res_key;
        var oRs = Oracle.Execute(sql);
        chk_key = oRs("res_rsv_ruimte_key").Value;
    }
    var this_res = res.func_enabled(chk_key);
    user.auth_required_or_abort(this_res.canReadAny);

    FCLT2XMLResponse({xmlnode: 'reservering', key: res_key, xtrakey: print_rsv_ruimte_key, srtnotificatie: 'OUTLOOK'});
    Response.ContentType = "text/Calendar";
    Response.AddHeader ("Content-Disposition", "filename=Facilitor_" + print_rsv_ruimte_key + ".ics;");
    Response.End;
%>
<% ASPPAGE_END(); %> 
