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

     Stuur een bericht via SMS
*/
var JSON_Result = true;
%>
<!--#include file="../Shared/common.inc"-->
<%
protectRequest.validateToken();
var canSendSMS = ( S("puo_uid") && S("puo_pwd") && S("bez_can_send_sms") );
if (!canSendSMS)
{
    shared.simpel_page(L("lcl_no_auth"));
}

var perslid_key = getFParamIntArray("prs_key", []);
var txt = getFParam("smstekst");
var mob = [];

if (perslid_key.length)
{
    var sql = "SELECT p.prs_perslid_mobiel"
          + "    FROM prs_perslid p"
          + "   WHERE p.prs_perslid_mobiel IS NOT NULL"
          + "     AND p.prs_perslid_key IN (" + perslid_key.join(",") + ")";
    var oRs = Oracle.Execute(sql);
    while (!oRs.eof)
    {
        var smsnr = oRs("prs_perslid_mobiel").Value;
        mob.push(smsnr);
        oRs.MoveNext();
    }
    oRs.Close();
}

var result = { success: mob.length > 0 };

for (var i=0; i<mob.length; i++)
{
    var puo_result = putorders.sendSMS(mob[i], txt);
    __Log ("SMS bericht verzonden naar: " + mob[i] );
}

Response.Write(JSON.stringify(result));

ASPPAGE_END(); %>
