FSN#33278 API2 code afsplitsen externe interface
svn path=/Website/trunk/; revision=25638
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
$Id$
|
||||
|
||||
File: api2.inc
|
||||
Description: Functies voor API's
|
||||
Notes: Hier wordt van alles met de 'buitenwereld' gecommuniceerd.
|
||||
Doel is dat de model's puur op json-data hoeven te werken
|
||||
Description: Functies voor manipuleren van de modellen
|
||||
Notes: Hier wordt weinig met de 'buitenwereld' gecommuniceerd,
|
||||
dat gebeurt voornamelijk in api2_rest.inc
|
||||
|
||||
Status: Nog TODO's wegwerken
|
||||
|
||||
@@ -14,246 +14,6 @@
|
||||
<!-- #include file="../Shared/save2db.inc" -->
|
||||
<%
|
||||
api2 = {
|
||||
authenticate: function _authenticate(model)
|
||||
{
|
||||
var APIKEY;
|
||||
if (S("fac_api_key_in_url"))
|
||||
APIKEY = getQParam("APIKEY", "");
|
||||
if (!APIKEY && Request.ServerVariables("HTTP_X_FACILITOR_API_KEY").Count)
|
||||
APIKEY = String(Request.ServerVariables("HTTP_X_FACILITOR_API_KEY")); // Meegegeven als X-FACILITOR-API-Key
|
||||
|
||||
if (!APIKEY && Session("user_key") > 0)
|
||||
{
|
||||
user_key = Session("user_key"); // Hierdoor is de API intern te gebruiken zonder authenticatie
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Session("user_key") > 0)
|
||||
{} // Tijdens ontwikkeling heb je soms in tweede tab de GUI open. Laat dat ongemoeid.
|
||||
else
|
||||
Session.Abandon(); // Altijd, voor de zekerheid
|
||||
|
||||
var sql = "SELECT prs_perslid_key, prs_perslid_naam"
|
||||
+ " FROM prs_perslid"
|
||||
+ " WHERE prs_perslid_verwijder IS NULL"
|
||||
+ " AND prs_perslid_apikey = " + safe.quoted_sql(APIKEY);
|
||||
var oRs = Oracle.Execute(sql);
|
||||
if (oRs.Eof || !APIKEY)
|
||||
{
|
||||
Response.Status = "401 Unauthorized";
|
||||
//Response.AddHeader("WWW-Authenticate", "Basic realm=\"FACILITOR API\"");
|
||||
Response.End;
|
||||
};
|
||||
__Log("API2 User is: " + oRs("prs_perslid_naam").Value);
|
||||
/* global */ user_key = oRs("prs_perslid_key").Value;
|
||||
|
||||
if (typeof NO_ADDHEADER == "undefined" && Request.Servervariables("HTTP_FCLT_VERSION").Count > 0)
|
||||
{ // wordt opgepikt door FCLTAPI.DLL voor in de logging en daarna gestript. Niet in Fiddler dus
|
||||
Response.AddHeader ("FCLT_USERID", customerId + "\\" + String(user_key));
|
||||
}
|
||||
|
||||
oRs.Close();
|
||||
}
|
||||
/* global */ user = new Perslid(user_key);
|
||||
CheckForLogging(Request.QueryString("logging")); // Nu pas kan autorisatie via user gecontrolerd worden
|
||||
|
||||
// Impersonate?
|
||||
var IMPERS;
|
||||
if (S("fac_api_key_in_url"))
|
||||
IMPERS = getQParam("SWITCHUSER", "");
|
||||
if (!IMPERS && Request.ServerVariables("HTTP_X_FACILITOR_SWITCH_USER").Count)
|
||||
IMPERS = String(Request.ServerVariables("HTTP_X_FACILITOR_SWITCH_USER")); // Meegegeven als X-FACILITOR-SWITCH-USER
|
||||
if (IMPERS && S("fac_api_allow_impersonate"))
|
||||
{
|
||||
var sql = "SELECT prs_perslid_key, prs_perslid_naam"
|
||||
+ " FROM prs_perslid"
|
||||
+ " WHERE prs_perslid_verwijder IS NULL"
|
||||
+ " AND prs_perslid_oslogin = " + safe.quoted_sql_upper(IMPERS);
|
||||
var oRs = Oracle.Execute(sql);
|
||||
if (oRs.Eof)
|
||||
{
|
||||
Response.Status = "412 Invalid X-Facilitor-Switch-User header";
|
||||
Response.End;
|
||||
};
|
||||
__Log("IMPERS User is: " + oRs("prs_perslid_naam").Value);
|
||||
var other_user_key = oRs("prs_perslid_key").Value;
|
||||
oRs.Close();
|
||||
if (model.impersonate_auth)
|
||||
{
|
||||
var xfunc = user.func_enabled2(model.module, { prs_key: other_user_key, isOptional: true });
|
||||
var can = (xfunc && xfunc.canRead(model.impersonate_auth));
|
||||
if (can)
|
||||
/* global */ user_key = other_user_key;
|
||||
}
|
||||
if (user_key != other_user_key)
|
||||
{
|
||||
Response.Status = "412 Unauthorized X-Facilitor-Switch-User header";
|
||||
Response.End;
|
||||
}
|
||||
}
|
||||
},
|
||||
process: function _process(model)
|
||||
{
|
||||
Session.Codepage = 65001; // We doen *uitsluitend* utf-8
|
||||
Response.Charset = 'utf-8';
|
||||
|
||||
if (typeof model == "function") // Nieuwe stijl is het een function. Even compatible.
|
||||
model = new model();
|
||||
|
||||
api2.authenticate(model);
|
||||
|
||||
var method = String(Request.ServerVariables("REQUEST_METHOD"));
|
||||
|
||||
if (!/GET|PUT|POST|DELETE/.test(method)) // Overigens houdt IIS deze al eerder tegen
|
||||
{
|
||||
Response.Status = "405 Method not allowed";
|
||||
Response.End;
|
||||
}
|
||||
if (!("REST_" + method in model))
|
||||
{
|
||||
Response.Status = "501 Not Implemented";
|
||||
// TODO The response MUST include an Allow header containing a list of valid methods for the requested resource.
|
||||
Response.End;
|
||||
}
|
||||
var jsondata = {};
|
||||
var filter = api2.qs2json();
|
||||
filter = api2.plugin.transform_filter(filter);
|
||||
var requestparams = { filter: filter, include: getQParamArray("include", []) };
|
||||
|
||||
if (/PUT|POST/.test(method)) // Dan is er in de body data meegestuurd
|
||||
{
|
||||
switch (getQParamSafe("format", "invalid").toLowerCase())
|
||||
{
|
||||
case "json":
|
||||
{
|
||||
var parsed = RequestJSON();
|
||||
if (parsed.error)
|
||||
api2.error(500, "Error parsing input JSON: " + parsed.error);
|
||||
jsondata = api2.plugin.transform_incoming(requestparams, parsed.json);
|
||||
if (!jsondata)
|
||||
api2.error(500, "Error parsing input JSON: Empty");
|
||||
break;
|
||||
}
|
||||
case "xml":
|
||||
{
|
||||
var parsed = RequestXML();
|
||||
if (parsed.error)
|
||||
api2.error(500, "Error parsing input XML: " + parsed.error);
|
||||
jsondata = api2.xml2json(parsed.xml);
|
||||
if (!jsondata)
|
||||
api2.error(500, "Error parsing input XML: Empty");
|
||||
break;
|
||||
}
|
||||
default:
|
||||
UNKNOWN_FORMAT_TYPE;
|
||||
}
|
||||
if (!jsondata || !(model.record_name in jsondata || (model.multi_update && model.records_name in jsondata)))
|
||||
{
|
||||
api2.error(500, "No '{0}' found in input".format(model.record_name));
|
||||
}
|
||||
}
|
||||
var key = getQParamInt("id", -1); // Voor POST/PUT/DELETE
|
||||
var isSingle = /PUT|POST|DELETE/.test(method) || (key>0); // PUT, POST en DELETE altijd single
|
||||
|
||||
if (getQParamSafe("format", "json") == "doc")
|
||||
{
|
||||
// Dan hoeven we verder niets te doen
|
||||
}
|
||||
else if (getQParamSafe("format", "json") == "api")
|
||||
{
|
||||
// TODO: Onderstaande in een of ander standaardformaat opleveren?
|
||||
var result = { id: model.records_name,
|
||||
methods: [],
|
||||
includes: [],
|
||||
fields: []
|
||||
};
|
||||
for (var i in model.includes)
|
||||
result.includes.push(i);
|
||||
if ("REST_GET" in model)
|
||||
result.methods.push("GET");
|
||||
if ("REST_PUT" in model)
|
||||
result.methods.push("PUT");
|
||||
if ("REST_POST" in model)
|
||||
result.methods.push("POST");
|
||||
if ("REST_DELETE" in model)
|
||||
result.methods.push("DELETE");
|
||||
|
||||
for (var fld in model.fields)
|
||||
{ // TODO: We missen hard-coded filters als reservableequipment/allowedinroom nu nog
|
||||
if (!model.fields.hidden)
|
||||
result.fields.push({ id: fld,
|
||||
filter: model.fields[fld].filter,
|
||||
type: model.fields[fld].typ,
|
||||
label: model.fields[fld].label
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (method == "DELETE")
|
||||
{
|
||||
var result = model["REST_" + method]( requestparams, key );
|
||||
}
|
||||
else if (method == "GET" || model.record_name in jsondata)
|
||||
{
|
||||
var result = model["REST_" + method]( requestparams, jsondata, key );
|
||||
}
|
||||
else
|
||||
{ // Loop door de multiple records en geef de REST_ functie altijd <20><>n record
|
||||
for (var record in jsondata[model.records_name])
|
||||
{
|
||||
var thisdata = {};
|
||||
thisdata[model.record_name] = jsondata[model.records_name][record];
|
||||
var result = model["REST_" + method]( requestparams, thisdata, thisdata[model.record_name].id );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
switch (method)
|
||||
{
|
||||
case "DELETE":
|
||||
{
|
||||
Response.Status = "204 No Content";
|
||||
Response.End;
|
||||
break;
|
||||
}
|
||||
case "GET":
|
||||
{
|
||||
data = result;
|
||||
break;
|
||||
}
|
||||
case "PUT":
|
||||
case "POST":
|
||||
{
|
||||
var key = result.key;
|
||||
if (key)
|
||||
{
|
||||
var params = { filter: api2.qs2json(), include: getQParamArray("include", []) }, jsondata, key
|
||||
// requestparams.include is mogelijk uitgebreid met wat er in de body stond
|
||||
data = model.REST_GET({ filter: { id: key }, include: requestparams.include }); // resulterende data weer terug
|
||||
__Log(data);
|
||||
}
|
||||
else
|
||||
{
|
||||
data = [];
|
||||
isSingle = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
api2.deliver(data, model, getQParamSafe("format", "json"),
|
||||
isSingle);
|
||||
|
||||
},
|
||||
qs2json: function _qs2json(params)
|
||||
{
|
||||
var filter = {};
|
||||
for (var i = 1; i<= Request.QueryString.Count; i++)
|
||||
{
|
||||
filter[Request.QueryString.key(i)] = String(Request.QueryString(i));
|
||||
}
|
||||
return filter;
|
||||
},
|
||||
form2JSONdata: function _form2JSONdata(model, params, formfields) // Maak een jsondata-object voor gebruik vanuit model_xxx.inc
|
||||
{
|
||||
var jsondata = {};
|
||||
@@ -1115,302 +875,10 @@ api2 = {
|
||||
model.total_count = total_count;
|
||||
return data;
|
||||
},
|
||||
// Data is een array met 'records'
|
||||
deliver: function _deliver(data, model, format, single )
|
||||
{
|
||||
if (single && !data.length)
|
||||
{
|
||||
Response.Status = "404 Not Found";
|
||||
Response.End;
|
||||
}
|
||||
|
||||
if (format == "html" || format == "json")
|
||||
{
|
||||
var result = { };
|
||||
if (single)
|
||||
result[model.record_name] = data[0];
|
||||
else
|
||||
{
|
||||
result.total_count = model.total_count;
|
||||
result.limit = model.limit;
|
||||
result.offset = 0;
|
||||
result[model.records_name] = data;
|
||||
}
|
||||
|
||||
var resultdata = api2.plugin.transform_outgoing({}, result);
|
||||
}
|
||||
switch (format)
|
||||
{
|
||||
case "api":
|
||||
{
|
||||
var xml_antwoord = api2.json2xml(data, model, single);
|
||||
Response.ContentType = "application/json";
|
||||
break;
|
||||
}
|
||||
case "doc":
|
||||
{
|
||||
Response.ContentType = "text/html";
|
||||
var str_antwoord = simple_json2xml(model, "api");
|
||||
var xml_antwoord = new ActiveXObject("MSXML2.DOMDocument.6.0");
|
||||
xml_antwoord.loadXML(str_antwoord);
|
||||
var style = new ActiveXObject("MSXML2.DOMDocument.6.0");
|
||||
style.async = false;
|
||||
style.resolveExternals = false;
|
||||
style.load(Server.MapPath(rooturl + "/appl/api2/reference.xsl")); // De stylesheet laden. API's redeneren vanuit de root
|
||||
//style.load(Server.MapPath(rooturl + "/appl/shared/indent.xsl")); // De stylesheet laden. API's redeneren vanuit de root
|
||||
if (style.parseError.errorCode)
|
||||
{
|
||||
abort_with_warning("XSL error: " + style.parseError.reason + " @ " + style.parseError.line + "." + style.parseError.linepos );
|
||||
}
|
||||
var str_antwoord = xml_antwoord.transformNode(style); // terugstoppen in antwoord
|
||||
break;
|
||||
}
|
||||
case "json":
|
||||
var str_antwoord = JSON.stringify(resultdata, null, getQParam("pretty","0")=="1"?2:0);
|
||||
var jsonp = getQParam("jsonp", getQParam("callback",""));
|
||||
if (jsonp)
|
||||
{
|
||||
str_antwoord = jsonp + "(" + str_antwoord + ")";
|
||||
Response.ContentType = "application/javascript";
|
||||
}
|
||||
else
|
||||
Response.ContentType = "application/json";
|
||||
break;
|
||||
case "html":
|
||||
Response.ContentType = "text/html";
|
||||
var antwoord = JSON.stringify(resultdata, null, 2);
|
||||
var str_antwoord = "<!DOCTYPE html><html><head></head><body><pre>"
|
||||
+ Server.HTMLEncode(antwoord)
|
||||
+ "</pre></body></html>";
|
||||
break;
|
||||
case "xml":
|
||||
Response.ContentType = "text/xml";
|
||||
var xml_antwoord = api2.json2xml(data, model, single);
|
||||
// TODO: Output XSL transform ondersteunen?
|
||||
if (getQParam("pretty","0")=="1")
|
||||
{
|
||||
var style = new ActiveXObject("MSXML2.DOMDocument.6.0");
|
||||
style.async = false;
|
||||
style.resolveExternals = false;
|
||||
style.load(Server.MapPath(rooturl + "/appl/shared/indent.xsl")); // De stylesheet laden. API's redeneren vanuit de root
|
||||
if (style.parseError.errorCode)
|
||||
{
|
||||
abort_with_warning("XSL error: " + style.parseError.reason + " @ " + style.parseError.line + "." + style.parseError.linepos );
|
||||
}
|
||||
var str_antwoord = xml_antwoord.transformNode(style); // terugstoppen in antwoord
|
||||
}
|
||||
else
|
||||
var str_antwoord = xml_antwoord.xml;
|
||||
//Response.ContentType = "application/json";
|
||||
//var str_antwoord = JSON.stringify(api2.xml2json(xml_antwoord), null, 2);;
|
||||
break;
|
||||
default:
|
||||
WRONG_FORMAT;
|
||||
}
|
||||
|
||||
// str_antwoord heeft nu het te versturen antwoord
|
||||
// Bepaal eTag
|
||||
var oCrypto = new ActiveXObject("SLNKDWF.Crypto");
|
||||
var eTag = '"' + oCrypto.hex_sha1(String(S("cache_changecounter")) + "_" + str_antwoord).toLowerCase() + '"';
|
||||
Response.AddHeader("ETag", eTag);
|
||||
if (Request.ServerVariables("HTTP_IF_NONE_MATCH") == eTag)
|
||||
{ // We hebben een match! Effectief besparen wel alleen op dataverkeer, de queries zijn al geweest
|
||||
Response.Clear();
|
||||
Response.Status = "304 Not modified";
|
||||
Response.End;
|
||||
}
|
||||
|
||||
// if (API.apidata.loglevel) __Log2File(str_antwoord, APIname + "_OUT");
|
||||
Response.write(str_antwoord);
|
||||
},
|
||||
|
||||
// TODO: Wanneer attributes gebruiken en wanneer (sub)-elements?
|
||||
// Streven: data == xml2json(json2xml(data))
|
||||
json2xml: function _json2xml(data, model, single)
|
||||
{
|
||||
var rootname = model.records_name;
|
||||
var record_name = model.record_name;
|
||||
var xmlDoc = new ActiveXObject("MSXML2.DOMDocument.6.0");
|
||||
xmlDoc.appendChild(xmlDoc.createProcessingInstruction("xml", "version=\"1.0\" encoding=\"utf-8\""));
|
||||
|
||||
var record2json = function(record, record_name)
|
||||
{
|
||||
var elementRecord = xmlDoc.createElement(record_name);
|
||||
for (var fld in record)
|
||||
{
|
||||
var elementField = xmlDoc.createElement(fld);
|
||||
if (record[fld] instanceof Date)
|
||||
{
|
||||
var elementFieldText = xmlDoc.createTextNode(String(record[fld].toJSON()));
|
||||
elementField.appendChild(elementFieldText);
|
||||
}
|
||||
else if (record[fld] instanceof Array)
|
||||
{
|
||||
var inc_record_name;
|
||||
for (var ii in model.includes)
|
||||
{
|
||||
if (model.includes[ii].model.records_name == fld)
|
||||
inc_record_name = model.includes[ii].model.record_name;
|
||||
}
|
||||
for (var i = 0; i < record[fld].length; i++)
|
||||
elementField.appendChild(record2json(record[fld][i], inc_record_name));
|
||||
}
|
||||
else if (record[fld] && typeof record[fld] == "object") // Veronderstelt dat dit foreign met name/key is
|
||||
{
|
||||
if ("name" in record[fld] && "id" in record[fld])
|
||||
{
|
||||
elementField.setAttribute("name", fld);
|
||||
elementField.setAttribute("id", record[fld].id);
|
||||
}
|
||||
else
|
||||
elementField = record2json(record[fld], fld);
|
||||
}
|
||||
else
|
||||
{
|
||||
var elementFieldText = xmlDoc.createTextNode(record[fld]||"");
|
||||
elementField.appendChild(elementFieldText);
|
||||
}
|
||||
elementRecord.appendChild(elementField);
|
||||
}
|
||||
return elementRecord;
|
||||
};
|
||||
|
||||
if (single)
|
||||
{
|
||||
xmlDoc.appendChild(record2json(data[0], record_name));
|
||||
}
|
||||
else
|
||||
{
|
||||
var arrayElement = xmlDoc.createElement(rootname);
|
||||
for (var i = 0; i < data.length; i++)
|
||||
arrayElement.appendChild(record2json(data[i], record_name));
|
||||
xmlDoc.appendChild(arrayElement);
|
||||
}
|
||||
return xmlDoc;
|
||||
},
|
||||
// Streven: data == json2xml(xml2json(xml))
|
||||
// http://davidwalsh.name/convert-xml-json maar @attributes er uit gehaald
|
||||
xml2json: function _xml2json(xml)
|
||||
{
|
||||
// Create the return object
|
||||
var obj = {};
|
||||
|
||||
if (xml.nodeType == 1)
|
||||
{ // element
|
||||
// do attributes
|
||||
if (xml.attributes.length > 0)
|
||||
{
|
||||
// JGL removed: obj["@attributes"] = {};
|
||||
for (var j = 0; j < xml.attributes.length; j++)
|
||||
{
|
||||
var attribute = xml.attributes.item(j);
|
||||
obj[attribute.nodeName] = attribute.nodeValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (xml.nodeType == 3)
|
||||
{ // text
|
||||
obj = xml.nodeValue;
|
||||
}
|
||||
|
||||
// do children
|
||||
if (xml.hasChildNodes())
|
||||
{
|
||||
for(var i = 0; i < xml.childNodes.length; i++)
|
||||
{
|
||||
var item = xml.childNodes.item(i);
|
||||
var nodeName = item.nodeName;
|
||||
if (typeof(obj[nodeName]) == "undefined")
|
||||
{
|
||||
// JGL Added: Only one Textnode is simplified. Autodetect data
|
||||
if (item.nodeType == 3 && xml.childNodes.length == 1)
|
||||
{
|
||||
var dt = myJSON.internal_parsedate(null, item.nodeValue);
|
||||
if (dt && dt instanceof Date)
|
||||
return dt;
|
||||
return item.nodeValue;
|
||||
}
|
||||
|
||||
obj[nodeName] = api2.xml2json(item);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (typeof(obj[nodeName].push) == "undefined")
|
||||
{
|
||||
var old = obj[nodeName];
|
||||
obj[nodeName] = [];
|
||||
obj[nodeName].push(old);
|
||||
}
|
||||
obj[nodeName].push(api2.xml2json(item));
|
||||
}
|
||||
}
|
||||
}
|
||||
return obj;
|
||||
},
|
||||
error: function (code, msg)
|
||||
{
|
||||
abort_with_warning(msg, code)
|
||||
},
|
||||
find_plugin: function()
|
||||
{
|
||||
var plugin_name = getQParamSafe("plugin", "").toLowerCase();
|
||||
if (!plugin_name)
|
||||
return {};
|
||||
var fso = new ActiveXObject("Scripting.FileSystemObject");
|
||||
var paths = ["/cust/" + customerId, "/cust", "/appl/api2"]; // Hieronder zoeken naar '/plugins' folder
|
||||
for (var p in paths)
|
||||
{
|
||||
var ppath = Server.MapPath(rooturl + paths[p] + "/plugins/" + plugin_name + ".wsc")
|
||||
//__Log(ppath);
|
||||
if (fso.FileExists(ppath))
|
||||
{
|
||||
try
|
||||
{
|
||||
var hook = GetObject("script:" + ppath);
|
||||
}
|
||||
catch(e)
|
||||
{
|
||||
api2.error(500, "Loading {0} failed: {1}".format(ppath, e.description));
|
||||
}
|
||||
hook.initialize({ S: S, Oracle: Oracle, customerId: customerId, safe: safe });
|
||||
return hook;
|
||||
}
|
||||
}
|
||||
api2.error(500, "Undefined plugin {0}".format(plugin_name));
|
||||
},
|
||||
plugin: {
|
||||
transform_filter: function(filter)
|
||||
{
|
||||
var outdata = filter;
|
||||
var hook = api2.find_plugin();
|
||||
if ("transform_filter" in hook)
|
||||
{
|
||||
outdata = hook.transform_filter(filter);
|
||||
}
|
||||
hook = null;
|
||||
return outdata;
|
||||
},
|
||||
transform_incoming: function(params, data)
|
||||
{
|
||||
var outdata = data;
|
||||
var hook = api2.find_plugin();
|
||||
if ("transform_incoming" in hook)
|
||||
{
|
||||
outdata = hook.transform_incoming(params, data);
|
||||
}
|
||||
hook = null;
|
||||
return outdata;
|
||||
},
|
||||
transform_outgoing: function(params, data)
|
||||
{
|
||||
var outdata = data;
|
||||
var hook = api2.find_plugin();
|
||||
if ("transform_outgoing" in hook)
|
||||
outdata = hook.transform_outgoing(params, data);
|
||||
hook = null;
|
||||
return outdata;
|
||||
}
|
||||
},
|
||||
find_fieldindex_by_dbsname: function(array, value)
|
||||
{
|
||||
for(var i = 0; i < array.length; i++)
|
||||
@@ -1485,29 +953,6 @@ api2 = {
|
||||
}
|
||||
}
|
||||
|
||||
// LET OP: Verwacht wordt dat de JSON-code in de body utf-8 encoded is, niet windows-1252!
|
||||
// (in de praktijk moet je *moeite* doen om windows-1252 te krijgen dus dit is handiger)
|
||||
function RequestJSON()
|
||||
{
|
||||
var jvraag;
|
||||
if(Request.TotalBytes > 0)
|
||||
{
|
||||
var lngBytesCount = Request.TotalBytes;
|
||||
jvraag = BytesToStr(Request.BinaryRead(lngBytesCount));
|
||||
}
|
||||
__Log("Vraag: " + jvraag);
|
||||
try
|
||||
{
|
||||
var vraag = myJSON.parse(jvraag);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
__DoLog("JSON eval faalt met: {0}<br>{1}".format(e.description, jvraag), "ffff00");
|
||||
return { error: e.description };
|
||||
}
|
||||
return { json: vraag };
|
||||
}
|
||||
|
||||
function generic_REST_GET(model)
|
||||
{
|
||||
user.checkAutorisation(model.autfunction); // Als je zelfs geen readrechten hebt ben je heel fout bezig
|
||||
@@ -1614,69 +1059,6 @@ function generic_REST_DELETE(model)
|
||||
}
|
||||
}
|
||||
|
||||
function RequestXML()
|
||||
{
|
||||
try
|
||||
{
|
||||
var inputXML = Server.CreateObject("MSXML2.DOMDocument.6.0");
|
||||
inputXML.load(Request);
|
||||
}
|
||||
catch (e)
|
||||
{
|
||||
return { error: e.description };
|
||||
}
|
||||
if (inputXML.parseError.errorCode)
|
||||
{
|
||||
return { error: inputXML.parseError.reason + " @ " + inputXML.parseError.line + "." + inputXML.parseError.linepos };
|
||||
}
|
||||
return { xml: inputXML };
|
||||
}
|
||||
|
||||
function BytesToStr(bytes)
|
||||
{
|
||||
var stream = Server.CreateObject("ADODB.Stream");
|
||||
stream.type = 1;
|
||||
stream.open;
|
||||
stream.write(bytes);
|
||||
stream.position = 0;
|
||||
stream.type = 2; // Text
|
||||
stream.charset = "utf-8";
|
||||
|
||||
var sOut = stream.readtext();
|
||||
stream.close;
|
||||
return sOut;
|
||||
}
|
||||
|
||||
function getQParamISODate(pName, defVal)
|
||||
{
|
||||
return _get_ParamISODate(Request.Querystring, pName, defVal)
|
||||
}
|
||||
function getFParamISODate(pName, defVal)
|
||||
{
|
||||
return _get_ParamISODate(Request.Form, pName, defVal)
|
||||
}
|
||||
function _get_ParamISODate(pColl, pName, defVal)
|
||||
{
|
||||
var strval = _get_Param(pColl, pName, defVal, true); // force: een lege waarde wordt als afwezig beschouwd
|
||||
if (strval)
|
||||
{
|
||||
var dt = myJSON.internal_parsedate(null, strval);
|
||||
if (dt && dt instanceof Date)
|
||||
return dt;
|
||||
}
|
||||
|
||||
if (defVal instanceof Date)
|
||||
{
|
||||
return defVal;
|
||||
}
|
||||
if (defVal === null) // bewust triple===
|
||||
{
|
||||
return null;
|
||||
}
|
||||
// Error message will get to client and/or IIS logfiles
|
||||
eval("INTERNAL_ERROR_PARAMETER_" + pName + "_IS_NOT_ISODATE");
|
||||
}
|
||||
|
||||
// Backwards compatible FACMGT_LCL
|
||||
var __F = [];
|
||||
function F(tekst)
|
||||
@@ -1688,32 +1070,4 @@ function F(tekst)
|
||||
return tekst;
|
||||
}
|
||||
|
||||
var simple_json2xml = (function (undefined) {
|
||||
"use strict";
|
||||
var tag = function (name, closing) {
|
||||
return "\n<" + (closing ? "/" : "") + name + ">";
|
||||
};
|
||||
return function (obj, rootname) {
|
||||
var xml = "";
|
||||
for (var i in obj) {
|
||||
if (obj.hasOwnProperty(i)) {
|
||||
var value = obj[i],
|
||||
type = typeof value;
|
||||
if (value instanceof Array && type == 'object') {
|
||||
for (var sub in value) {
|
||||
xml += simple_json2xml(value[sub]);
|
||||
}
|
||||
} else if (value instanceof Object && type == 'object') {
|
||||
xml += tag(i) + simple_json2xml(value) + tag(i, 1);
|
||||
} else {
|
||||
xml += tag(i) + value + tag(i, {
|
||||
closing: 1
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return rootname ? tag(rootname) + xml + tag(rootname, 1) : xml;
|
||||
};
|
||||
})(simple_json2xml || {});
|
||||
%>
|
||||
@@ -15,13 +15,11 @@
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api/api_apis.asp";
|
||||
|
||||
// Session("logging")=1;
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./model_apis.inc" -->
|
||||
<%
|
||||
api2.process(model_apis);
|
||||
api2_rest.process(model_apis);
|
||||
%>
|
||||
@@ -15,13 +15,11 @@
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api/api_appointments.asp";
|
||||
|
||||
// Session("logging")=1;
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./model_appointments.inc" -->
|
||||
<%
|
||||
api2.process(model_appointments);
|
||||
api2_rest.process(model_appointments);
|
||||
%>
|
||||
@@ -18,9 +18,9 @@
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./model_approvals.inc" -->
|
||||
<%
|
||||
api2.process(model_approvals);
|
||||
api2_rest.process(model_approvals);
|
||||
%>
|
||||
@@ -15,13 +15,11 @@
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api/api_buildings.asp";
|
||||
|
||||
// Session("logging")=1;
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./model_buildings.inc" -->
|
||||
<%
|
||||
api2.process(model_buildings);
|
||||
api2_rest.process(model_buildings);
|
||||
%>
|
||||
@@ -18,8 +18,8 @@
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="./model_cadcontours.inc" -->
|
||||
<%
|
||||
api2.process(model_cadcontours);
|
||||
api2_rest.process(model_cadcontours);
|
||||
%>
|
||||
@@ -15,13 +15,11 @@
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api/api_companies.asp";
|
||||
|
||||
// Session("logging")=1;
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./model_companies.inc" -->
|
||||
<%
|
||||
api2.process(model_companies);
|
||||
api2_rest.process(model_companies);
|
||||
%>
|
||||
@@ -15,13 +15,11 @@
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api/api_contracts.asp";
|
||||
|
||||
// Session("logging")=1;
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./model_contracts.inc" -->
|
||||
<%
|
||||
api2.process(model_contracts);
|
||||
api2_rest.process(model_contracts);
|
||||
%>
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./model_districts.inc" -->
|
||||
<%
|
||||
api2.process(model_districts);
|
||||
api2_rest.process(model_districts);
|
||||
%>
|
||||
@@ -15,13 +15,11 @@
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api/api_floors.asp";
|
||||
|
||||
// Session("logging")=1;
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./model_floors.inc" -->
|
||||
<%
|
||||
api2.process(model_floors);
|
||||
api2_rest.process(model_floors);
|
||||
%>
|
||||
@@ -15,13 +15,11 @@
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api/api_invoices.asp";
|
||||
|
||||
// Session("logging")=1;
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="./model_invoices.inc" -->
|
||||
<%
|
||||
api2.process(model_invoices);
|
||||
api2_rest.process(model_invoices);
|
||||
%>
|
||||
@@ -15,13 +15,11 @@
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api/api_issues.asp";
|
||||
|
||||
// Session("logging")=1;
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./model_issues.inc" -->
|
||||
<%
|
||||
api2.process(model_issues);
|
||||
api2_rest.process(model_issues);
|
||||
%>
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./model_locations.inc" -->
|
||||
<%
|
||||
api2.process(model_locations);
|
||||
api2_rest.process(model_locations);
|
||||
%>
|
||||
@@ -15,13 +15,11 @@
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api/api_notes.asp";
|
||||
|
||||
// Session("logging")=1;
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="./model_notes.inc" -->
|
||||
<%
|
||||
api2.process(model_notes);
|
||||
api2_rest.process(model_notes);
|
||||
%>
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./model_objects.inc" -->
|
||||
<%
|
||||
api2.process(model_objects);
|
||||
api2_rest.process(model_objects);
|
||||
%>
|
||||
@@ -15,13 +15,11 @@
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api/api_orders.asp";
|
||||
|
||||
// Session("logging")=1;
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./model_orders.inc" -->
|
||||
<%
|
||||
api2.process(model_orders);
|
||||
api2_rest.process(model_orders);
|
||||
%>
|
||||
@@ -15,13 +15,11 @@
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api/api_persons.asp";
|
||||
|
||||
// Session("logging")=1;
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./model_persons.inc" -->
|
||||
<%
|
||||
api2.process(model_persons);
|
||||
api2_rest.process(model_persons);
|
||||
%>
|
||||
@@ -17,9 +17,9 @@
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./model_regions.inc" -->
|
||||
<%
|
||||
api2.process(model_regions);
|
||||
api2_rest.process(model_regions);
|
||||
%>
|
||||
@@ -15,15 +15,14 @@
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api/api_reportsx.asp";
|
||||
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./model_reports.inc" -->
|
||||
<%
|
||||
var usrrap_key = getQParamInt("usrrap_key");
|
||||
var model = model_reports(usrrap_key);
|
||||
|
||||
api2.process(model);
|
||||
api2_rest.process(model);
|
||||
%>
|
||||
@@ -15,12 +15,11 @@
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api/api_reportsx.asp";
|
||||
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./model_reportsx.inc" -->
|
||||
<%
|
||||
api2.process(model_reportsx);
|
||||
api2_rest.process(model_reportsx);
|
||||
%>
|
||||
@@ -14,11 +14,12 @@
|
||||
DOCTYPE_Disable = true;
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api2/api_reservableconsumables.asp";
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="./model_reservableconsumables.inc" -->
|
||||
<%
|
||||
api2.process(model_reservableconsumables);
|
||||
api2_rest.process(model_reservableconsumables);
|
||||
%>
|
||||
|
||||
@@ -14,12 +14,13 @@
|
||||
DOCTYPE_Disable = true;
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api/api_reservableequipment.asp";
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../res/res.inc" -->
|
||||
<!-- #include file="./model_reservableequipment.inc" -->
|
||||
<%
|
||||
api2.process(model_reservableequipment);
|
||||
api2_rest.process(model_reservableequipment);
|
||||
%>
|
||||
@@ -14,12 +14,13 @@
|
||||
DOCTYPE_Disable = true;
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api/api_reservablerooms.asp";
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="../res/res.inc"-->
|
||||
<!-- #include file="./model_reservablerooms.inc" -->
|
||||
<%
|
||||
api2.process(model_reservablerooms);
|
||||
api2_rest.process(model_reservablerooms);
|
||||
%>
|
||||
@@ -14,12 +14,13 @@
|
||||
DOCTYPE_Disable = true;
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api2/api_reservationconsumables.asp";
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../res/res.inc"-->
|
||||
<!-- #include file="./model_reservationconsumables.inc" -->
|
||||
<%
|
||||
api2.process(model_reservationconsumables);
|
||||
api2_rest.process(model_reservationconsumables);
|
||||
%>
|
||||
@@ -14,12 +14,13 @@
|
||||
DOCTYPE_Disable = true;
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api2/api_reservationequipment.asp";
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../res/res.inc"-->
|
||||
<!-- #include file="./model_reservationequipment.inc" -->
|
||||
<%
|
||||
api2.process(model_reservationequipment);
|
||||
api2_rest.process(model_reservationequipment);
|
||||
%>
|
||||
@@ -15,13 +15,11 @@
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api/api_reservations.asp";
|
||||
|
||||
// Session("logging")=1;
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="./model_reservations.inc" -->
|
||||
<%
|
||||
api2.process(model_reservations);
|
||||
api2_rest.process(model_reservations);
|
||||
%>
|
||||
@@ -18,8 +18,8 @@
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="./model_rooms.inc" -->
|
||||
<%
|
||||
api2.process(model_rooms);
|
||||
api2_rest.process(model_rooms);
|
||||
%>
|
||||
@@ -15,13 +15,11 @@
|
||||
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
|
||||
THIS_FILE = "appl/api/api_visitors.asp";
|
||||
|
||||
// Session("logging")=1;
|
||||
|
||||
%>
|
||||
<!-- #include file="../Shared/common.inc" -->
|
||||
<!-- #include file="./api2.inc" -->
|
||||
<!-- #include file="./api2_rest.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="./model_visitors.inc" -->
|
||||
<%
|
||||
api2.process(model_visitors);
|
||||
api2_rest.process(model_visitors);
|
||||
%>
|
||||
@@ -55,7 +55,7 @@
|
||||
// Overrule scaffolding_list
|
||||
scaffolding_list = function _styled_report_scaffolding_list(model, scf_params)
|
||||
{
|
||||
var xxx_params = { filter : scf_params.filter || api2.qs2json() };
|
||||
var xxx_params = { filter : scf_params.filter || shared.qs2json() };
|
||||
|
||||
rapport.addfixedfilters(xxx_params.filter);
|
||||
var wheres = api2.sqlfilter(xxx_params, rapport);
|
||||
@@ -174,7 +174,7 @@ function fac_usrrap_list_graph (model, scf_params)
|
||||
if (!scf_params.list.columns.length && "list" in model)
|
||||
scf_params.list.columns = model.list.columns;
|
||||
|
||||
var xxx_params = { filter : scf_params.filter || api2.qs2json(), columns: scf_params.list.columns, groupby: scf_params.list.groups };
|
||||
var xxx_params = { filter : scf_params.filter || shared.qs2json(), columns: scf_params.list.columns, groupby: scf_params.list.groups };
|
||||
var xxx_array = model.REST_GET(xxx_params);
|
||||
|
||||
graphData = { teller: xxx_array.length
|
||||
|
||||
@@ -22,11 +22,10 @@ JSON_Result = true;
|
||||
var usrrap_key = getQParamInt("usrrap_key");
|
||||
var rapport = model_reports(usrrap_key);
|
||||
|
||||
var filter = api2.qs2json();
|
||||
var distinct = getQParam("distinct"); // deze kolom zoeken we
|
||||
var columns = [distinct.replace(/^(start_|end_)/,"")];
|
||||
|
||||
var xxx_params = { filter : api2.qs2json(), columns: columns, groupby: ["U"] }; // U=distinct
|
||||
var xxx_params = { filter : shared.qs2json(), columns: columns, groupby: ["U"] }; // U=distinct
|
||||
xxx_params.filter.showall = 1;
|
||||
xxx_params.filter.limit = 9999;
|
||||
var result = { distinct: columns[0], values: rapport.REST_GET(xxx_params) };
|
||||
|
||||
@@ -41,6 +41,8 @@ if (mode == "save" || mode == "delete")
|
||||
<%
|
||||
function scaffolding(model, scf_params)
|
||||
{
|
||||
if (typeof model == "function") // Nieuwe stijl is het een function. Even compatible.
|
||||
model = new model();
|
||||
scf_params = scf_params || {};
|
||||
|
||||
var imodel = getQParam("model", ""); // include model
|
||||
|
||||
@@ -108,7 +108,7 @@ function scaffolding_list(model, scf_params)
|
||||
buttons.push({ icon: "plus.png", title: L("lcl_add"), action: "FcltMgr.openDetail('" + addurl + "', '" + L("lcl_add") + " " + model.record_title + "')" });
|
||||
}
|
||||
|
||||
var xxx_params = { filter : scf_params.filter || api2.qs2json(), columns: scf_params.list.columns, groupby: scf_params.list.groups };
|
||||
var xxx_params = { filter : scf_params.filter || shared.qs2json(), columns: scf_params.list.columns, groupby: scf_params.list.groups };
|
||||
if (!("limit" in xxx_params.filter))
|
||||
{
|
||||
xxx_params.filter.limit = showAll?S("qp_maxrows2"):S("qp_maxrows")
|
||||
|
||||
@@ -71,7 +71,7 @@ function scaffolding_m_list(model, scf_params)
|
||||
buttons.push({ icon: "plus.png", title: L("lcl_add"), action: "FcltMgr.openDetail('" + addurl + "', '" + L("lcl_add") + " " + model.record_title + "')" });
|
||||
}
|
||||
|
||||
var xxx_params = { filter : scf_params.filter || api2.qs2json(), columns: scf_params.list.columns, groupby: scf_params.list.groups };
|
||||
var xxx_params = { filter : scf_params.filter || shared.qs2json(), columns: scf_params.list.columns, groupby: scf_params.list.groups };
|
||||
var xxx_array = model.REST_GET(xxx_params);
|
||||
|
||||
function fnHeader(oRs)
|
||||
|
||||
@@ -96,7 +96,7 @@ function scaffolding_search(model, scf_params)
|
||||
<input type='hidden' name='groups' id='groups'>
|
||||
<input type='hidden' name='graph' id='graph'>
|
||||
<%
|
||||
var defaults = api2.qs2json(); // TODO: Ook via scf_params
|
||||
var defaults = shared.qs2json(); // TODO: Ook via scf_params
|
||||
|
||||
for (var fld in model.fields)
|
||||
{
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
*/ %>
|
||||
<!-- #include file="../Shared/logger.inc" -->
|
||||
<!-- #include file="../Shared/json2.js" -->
|
||||
<!-- #include file="../api2/api2.inc" -->
|
||||
<!-- #include file="../api2/api2_rest.inc" -->
|
||||
<%
|
||||
try { Response.Clear; } catch (e) {};
|
||||
|
||||
@@ -68,8 +68,7 @@ if (String(Request.ServerVariables("HTTP_ACCEPT")).match(/application\/json/) !=
|
||||
if (format == "xml")
|
||||
{
|
||||
Response.ContentType = "text/xml";
|
||||
var xml_antwoord = api2.json2xml([data.error], "errors", "error", true);
|
||||
// TODO: Output XSL transform ondersteunen?
|
||||
var xml_antwoord = api2_rest.json2xml([data.error], { records_name: "errors", record_name: "error"}, true);
|
||||
Response.Write(xml_antwoord.xml);
|
||||
}
|
||||
else if (format == "scf" || format == 'html')
|
||||
|
||||
@@ -179,8 +179,16 @@ var shared = {
|
||||
fields.push({ dbs: dbsname + ".tijdsduur", obj: "MLD_T_UITVOERTIJD", typ: "float", val: null, track: (track? track.tracktijdsduur : null) },
|
||||
{ dbs: dbsname + ".eenheid", obj: "MLD_T_UITVOERTIJD", typ: "varchar", val: null, track: (track? track.trackeenheid : null) });
|
||||
return fields;
|
||||
},
|
||||
qs2json: function _qs2json(params)
|
||||
{
|
||||
var filter = {};
|
||||
for (var i = 1; i<= Request.QueryString.Count; i++)
|
||||
{
|
||||
filter[Request.QueryString.key(i)] = String(Request.QueryString(i));
|
||||
}
|
||||
return filter;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
// Check for parameter pName and return the value
|
||||
|
||||
Reference in New Issue
Block a user