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

    File:           make_qrcode.asp
    Description:    Maakt een korte qrcode en toont het bijbehorende plaatje
    Parameters:     url      Bookmark die in de bookmark tabel moet zitten
    Context:        Handmatig?
    Note:           Welbeschouwd is dit gewoon een url-shortener
                    http://sgf12/Facilitor5iWork/?bm=J448UIrR43

                    JGL: volgens mij is dit bestand anno maart 2015 niet in gebruik?
*/

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

    FCLTHeader.Requires({plugins:["suggest","jQuery"], js: []})
    user.checkAutorisation("WEB_PRSSYS"); // we zijn nog streng

    var url = getFParam("url", "");
    var naam = getFParam("naam", "");
    var submitting = getQParamInt("submit", 0) == 1;
    var proto = (Request.ServerVariables("SERVER_PORT") == "443")?"https":"http";
    var sitenoroot = proto + "://" + Request.ServerVariables("SERVER_NAME");
    var site = sitenoroot + rooturl;

    if (submitting)
    {
        var qm = url.indexOf("?");
        if (qm != -1)
        {
            path = url.substr(0, qm);
            query = url.substr(qm+1);
        }
        else
        {
            path = url;
            query = "";
        }
        var bookmark_id = shared.random(16);
        var sql = "INSERT INTO fac_bookmark"
                + " (fac_bookmark_id, fac_bookmark_path, fac_bookmark_query, fac_bookmark_naam, prs_perslid_key, fac_bookmark_flags)"
                + " VALUES ("+safe.quoted_sql(bookmark_id)
                             +", "+safe.quoted_sql(path)+", "
                             +safe.quoted_sql(query)
                             +", "
                             +safe.quoted_sql(naam)
                             +", " + user_key
                             +", 1+4" // zichtbaar en wijzigbaar PRSSYS
                             + ")";
        Oracle.Execute(sql);
    }
%>
<html>
<head>
<script language="javascript">
    function bm_submit()
    {
        if (!validateForm("u2"))
            return false;
        document.forms.u2.submit();
    }
    function bm_cancel()
    {
        FcltMgr.closeDetail(window, { cancel: true } );
    }
</script>
<%  FCLTHeader.Generate(); %>
</head>
<body id="editbody">
<%
    IFRAMER_HEADER(L("lcl_make_qrc_frame"));
%>
<div id="edit">
<form name="u2"
      action="fac_make_qrcode.asp?submit=1"
      method="post"
      onSubmit="bm_submit();">
<%
manRWFIELD = RWFIELDTR;
BLOCK_START("qrcInfo", L("lcl_make_qrc_title"));
    manRWFIELD("url",  "fld",  site+ "+" /*+ " " + site*/,        url,  {required: true, maxlength: 255});
    manRWFIELD("naam", "fld",   L("lcl_qrc_bookmark"),   naam, {required: true, maxlength: 60});
    var buttons =  [ {title: L("lcl_make_qrc"), action:"bm_submit()", icon: "qr.png" } ];
BLOCK_END();
    CreateButtons(buttons);

if(submitting) {
    BLOCK_START("qrcInfo", L("lcl_make_qrc_title2")+" "+safe.html(naam));
    %><tr><td colspan='2'><img class='QRC' src='../shared/qrcode.asp?text=<%=Server.URLEncode("/?u=" + bookmark_id)%>'></td></tr><%
    manRWFIELD("url",  "fld",   L("lcl_qrc_url"),   site+     "/"+url,  {readonly: true});
    BLOCK_END();
}
%>
</form>
</div>
</body>
</html>
