<% /*
    $Revision$
    $Id$

    File:        putorders.inc
    Description: Generieke functies voor putorders aanroepen vanuit asp.
    Parameters:
    Context:
    Note:

*/ %>
<%
var putorders = {
    _puo_Oracle: null,
    _puo_hook:
        function __puo_hook()
        {   // Gebruik rooturl ipv ../../ omdat we ook vanuit API's worden aangeroepen

            // Krijg je een syntax foutmelding op de *volgende* regel? Dan is er een syntaxfout *ergens* in UTILS\Putorders
            var hook = GetObject("script:" + Server.MapPath(rooturl + "/utils/putorders/puo_putorders.wsc"));

            if (!putorders._puo_Oracle)
            {
                putorders._puo_Oracle = new SafeOracle(Oracle.RealConnection);
                putorders._puo_Oracle.marker = "<span style='font-size:smaller'>(PutOrders)</span>";
            }
            settings.overrule_setting("bdradrfiles_path", Server.MapPath(custpath + "/bdradrfiles")); // Zo verwacht putorders het
            hook.initialize({ customerId: customerId,
                              S: S,
                              settings: settings,
                              Oracle: putorders._puo_Oracle,
                              custabspath: Server.MapPath(custpath),
                              PUO_LOGPATH: shared.tempFolder() + "/",
                              userident: Session("userident") || "<not logged in>"
                            });
            return hook;
        },
    sendMLDorders:
        function _sendMLDorders(pkey, params)
        {
            var hook = putorders._puo_hook();
            __Log("Sending order key={0}".format(pkey));
            var result = hook.sendMLDorders(pkey, params);
            hook = null;
            return result;
        },
    send_planrequest:
        function _send_planrequest(bedrijf_key, xml_content)
        {
            var hook = putorders._puo_hook();
            __Log("Sending planrequest to bedrijf={0}".format(bedrijf_key));
            var result = hook.puo_send_planrequest(bedrijf_key, xml_content);
            hook = null;
            return result;
        },
    sendMail:
        function _sendMail(adrTo, strSubj, strBody, params)
        {
            var hook = putorders._puo_hook();
            __Log("Mailing {0}".format(adrTo));
            var result = hook.puo_sendMail(adrTo, strSubj, strBody, params);
            hook = null;
            return result;
        },
    sendSMS:
        function _sendSMS(telnr, msg)
        {
            var hook = putorders._puo_hook();
            __Log("SMS {0} to {1}".format(msg, telnr));
            var result = hook.puo_sendSMS(telnr, msg);
            hook = null;
            return result;
        },
    sendAPP:
        function _sendAPP(prs_key, msg, url)
        {
            var hook = putorders._puo_hook();
            __Log("APP message {0} to {1} with url {2}".format(msg, prs_key, url));
            var result = hook.puo_sendAPP(prs_key, msg, url);
            hook = null;
            return result;
        }
    }
%>
