102 lines
3.1 KiB
C++
102 lines
3.1 KiB
C++
<% /*
|
|
$Revision$
|
|
$Id$
|
|
|
|
File: FcltJquery.js
|
|
Note: JSONP compatible
|
|
*/ %>
|
|
<!-- #include file="../json2.js" -->
|
|
<%
|
|
var maxNormal = 10;
|
|
var maxFull = 500;
|
|
// sql
|
|
// bAll: haal alle records op (met nog steeds een maximum van 500)
|
|
// bStoreDesc: Hoewel we zoeken op fldName slaan we uiteindelijk fldDesc op in het suggest veld
|
|
// (vooral gebruikt voor zoeken op telefoonnummer)
|
|
|
|
var callback = getQParam("callback", null);
|
|
|
|
// Deprecated vesion
|
|
function WriteResult(sql, bAll, fldName, fldKey, fldDesc, fldExtraParam, fldTitle, bStoreDesc, checkExist)
|
|
{
|
|
return WriteResult2(sql, { bAll: bAll,
|
|
fldName: fldName,
|
|
fldKey: fldKey,
|
|
fldDesc: fldDesc,
|
|
fldExtraParam: fldExtraParam,
|
|
fldTitle: fldTitle,
|
|
bStoreDesc: bStoreDesc,
|
|
checkExist: checkExist
|
|
});
|
|
}
|
|
|
|
// Params bAll, fldName, fldKey, fldDesc, fldExtraParam, fldTitle, bStoreDesc, checkExist of similarSQL
|
|
// foto
|
|
function WriteResult2(sql, params)
|
|
{
|
|
var jsonResult = { } ;
|
|
if (!params.bAll)
|
|
sql = "SELECT * FROM (" + sql + ") WHERE ROWNUM < " + (maxNormal + 1);
|
|
else
|
|
sql = "SELECT * FROM (" + sql + ") WHERE ROWNUM < " + (maxFull + 1);
|
|
|
|
var oRs = Oracle.Execute(sql);
|
|
if (oRs.eof && params.SimilarSql)
|
|
{
|
|
oRs = Oracle.Execute(params.SimilarSql);
|
|
jsonResult.similar = true;
|
|
}
|
|
var cnt = 1;
|
|
var lijst = [];
|
|
while (!oRs.eof && cnt < (params.bAll? maxFull : maxNormal))
|
|
{
|
|
cnt++;
|
|
// JSON Syntax
|
|
var result = { txt: oRs(params.fldName).Value,
|
|
key: oRs(params.fldKey).Value,
|
|
desc: oRs(params.fldDesc).Value || "" // Indien null dan lege string weergeven
|
|
};
|
|
if (params.fldExtraParam && oRs(params.fldExtraParam).Value)
|
|
result.extra = oRs(params.fldExtraParam).Value;
|
|
if (params.fldTitle && oRs(params.fldTitle).Value)
|
|
result.title = oRs(params.fldTitle).Value;
|
|
if (params.fnFoto)
|
|
{
|
|
var foto = params.fnFoto(oRs);
|
|
if (foto)
|
|
{
|
|
result.foto = foto;
|
|
jsonResult.anyfoto = true;
|
|
}
|
|
}
|
|
|
|
lijst.push(result);
|
|
oRs.MoveNext();
|
|
}
|
|
jsonResult.result = lijst;
|
|
if (!oRs.eof)
|
|
{
|
|
jsonResult.hasMore = true;
|
|
if (params.bAll)
|
|
jsonResult.hasMoreMsg = L("lcl_shared_suggest_toomany");
|
|
else
|
|
jsonResult.hasMoreMsg = L("lcl_shared_suggest_more");
|
|
}
|
|
oRs.close();
|
|
|
|
if (params.bAll)
|
|
jsonResult.isAll = true;
|
|
if (params.bStoreDesc)
|
|
jsonResult.storeDesc = true;
|
|
if (params.checkExist)
|
|
jsonResult.checkExist = true;
|
|
|
|
if (callback)
|
|
{
|
|
Response.ContentType = "application/javascript";
|
|
Response.Write(callback + "(" + JSON.stringify(jsonResult) + ")");
|
|
}
|
|
else
|
|
Response.Write(JSON.stringify(jsonResult));
|
|
}
|
|
%> |