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

    File:           fac_preview_xsl.asp
    Description:    Preview van een rapport
    Parameters:
        xmlnode     required
        key         required
        mode        E-mail of Summary
        srtnoti     Srtnotificatiecode
    Context:
    Note:           PRSSYS nodig (je kunt tenslotte elke bon opvragen)
 */
 %>

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

<%
FCLTHeader.Requires({ plugins: ["jQuery"], js: ["jQuery-ui.js"]
                    })

var autfunction = "WEB_PRSSYS";
var authparams = user.checkAutorisation(autfunction);

var xmlnode = getQParamSafe("xmlnode");
var srtnoti = getQParam("srtnoti");
var mode = getQParam("mode", "email");
var key = getQParamInt("key", -1, true);
var xtrakey = getQParamInt("xkey", -1, true);

if (xmlnode == customerId)
{
    var sql = "SELECT fac_srtnotificatie_xmlnode"
            + "  FROM fac_srtnotificatie"
            + " WHERE fac_srtnotificatie_code = " + safe.quoted_sql(srtnoti)
            + " ORDER BY 1";
    var oRs = Oracle.Execute(sql);
    var xmlnode = oRs("fac_srtnotificatie_xmlnode").Value;
    oRs.Close()
}

try
{
    FCLT2XMLResponse({xmlnode: xmlnode,
                      key: key,
                      xtrakey: xtrakey > 0? xtrakey: null,
                      mode: mode=="emailsend"?"email":mode,
                      srtnotificatie: srtnoti,
                      nostyle:getQParam("mode")=="xml", // overruled de rest
                      concept: (xmlnode != customerId),
                      mailto: (mode=="emailsend"?S("puo_forcemailaddress") || user.prs_perslid_email():""),
                      subject: "Preview {3} xmlnode '{0}' srtnoti '{1}' key {2}".format(xmlnode, srtnoti, key, customerId)
                     });
}
catch(e)
{
    if (String(e.description).indexOf("ORA-01403")>=0)
        shared.simpel_page(L("lcl_xsl_nodata"));
    else
        shared.simpel_page(L("lcl_xsl_nopreview")+"<p><blockquote>{0}</blockquote>".format(safe.html(e.description)));
}
%><% ASPPAGE_END(); %>
