FSN#32922 model herzien savepoint

svn path=/Website/trunk/; revision=25750
This commit is contained in:
Jos Groot Lipman
2015-07-29 09:14:12 +00:00
parent 7f34c4a6a4
commit 1e23181fa9
26 changed files with 580 additions and 349 deletions

View File

@@ -81,10 +81,6 @@ api2 = {
var wheres = [];
if (params.filter)
{
if (model.parent_key in params.filter)
wheres.push(model.table + "." + model.parent_key + " = " + parseInt(params.filter[model.parent_key], 10));
else if ("pid" in params.filter)
wheres.push(model.table + "." + model.parent_key + " = " + parseInt(params.filter["pid"], 10));
for (var fld in model.fields)
{
var field = model.fields[fld];
@@ -133,7 +129,8 @@ api2 = {
else if (String(filterval).indexOf(",") != -1) // let op: bij buildings/1234.json is id al numeriek gemaakt
// NB: index=-1 als het geen array is.
{
safe_val = getQParamIntArray(fld).join(","); // TODO: Niet via getQParamIntArray
var arr = params.filter[fld].split(",");
safe_val = safe.int_array(arr).join(",");
if (typeof filter != 'function')
safe_val = "(" + safe_val + ")";
operand = " IN ";
@@ -443,6 +440,10 @@ api2 = {
}
inccnt ++;
inc.model.aliasprefix = "I" + inccnt + "_";
// Zorg dat de parent_key niet genoemd wordt bij de children. Dat is redundant
if (inc.joinfield in inc.model.fields)
inc.model.fields[inc.joinfield].hidden = true;
var incquery = api2.sqlfields(params, inc.model);
selects = selects.concat (incquery.selects);
@@ -466,7 +467,7 @@ api2 = {
// gedrag wel fijn.
orderbys.push(inc.model.aliasprefix + inc.model.primary);
// simpel op joinfield
wheres.push ( model.table + "." + model.primary + "=" + inc.model.table + "." + inc.joinfield + "(+)");
wheres.push ( model.table + "." + model.primary + "=" + inc.model.table + "." + inc.model.fields[inc.joinfield].dbs + "(+)");
}
}
}
@@ -702,6 +703,17 @@ api2 = {
options.push("<option value='" + safe.htmlattr(l) + "'" + (l == current?" selected='1'":"") + ">" + safe.html(spl[l]) + "</option>");
return "<select>" + options.join("") + "</select>";
},
// ['xxx','yyy','zzz'] ==> "0;xxx;1;yyy;2;zzz"
makeLOV: function _makeLOV(arr)
{
var LOVarr = [];
for (var i = 0; i < arr.length; i++)
{
LOVarr.push(String(i));
LOVarr.push(arr[i]);
}
return LOVarr.join(";");
},
// Geef alle velden van een record terug
sql2jsonfields: function (oRs, model)
{
@@ -957,23 +969,26 @@ api2 = {
}
NOT_A_DATE;
},
generic_REST: function(model)
generic_REST: function(model, gparams)
{
gparams = gparams || {};
if (typeof model == "function") // Nieuwe stijl is het een function. Even compatible.
model = new model();
if (!model.autfunction)
GENERIC_ONLY_WITH_AUTFUNCTION;
model.REST_GET = generic_REST_GET(model);
model.REST_POST = generic_REST_POST(model);
model.REST_PUT = generic_REST_PUT(model);
model.REST_DELETE = generic_REST_DELETE(model);
model.REST_GET = generic_REST_GET(model, gparams);
model.REST_POST = generic_REST_POST(model, gparams);
model.REST_PUT = generic_REST_PUT(model, gparams);
model.REST_DELETE = generic_REST_DELETE(model, gparams);
}
}
function generic_REST_GET(model)
function generic_REST_GET(model, gparams)
{
gparams = gparams || {};
gparams.GET = gparams.GET || {};
user.checkAutorisation(model.autfunction); // Als je zelfs geen readrechten hebt ben je heel fout bezig
return function _generic_REST_GET(params, jsondata)
@@ -983,6 +998,12 @@ function generic_REST_GET(model)
var wheres = api2.sqlfilter(params, model);
query.wheres = query.wheres.concat(wheres);
if (gparams.GET.tables)
query.tables = query.tables.concat(gparams.GET.tables);
if (gparams.GET.wheres)
query.wheres = query.wheres.concat(gparams.GET.wheres);
if (model.soft_delete && params.filter.show_deleted != "on")
query.wheres.push(model.soft_delete + " IS NULL");
@@ -999,8 +1020,9 @@ function generic_REST_GET(model)
}
}
function generic_REST_POST(model)
function generic_REST_POST(model, gparams)
{
gparams = gparams || {};
var autparams = user.checkAutorisation(model.autfunction, true);
if (!autparams || autparams.PRSwritelevel == 9 || autparams.ALGwritelevel == 9)
return false;
@@ -1026,8 +1048,9 @@ function generic_REST_POST(model)
}
}
function generic_REST_PUT(model)
function generic_REST_PUT(model, gparams)
{
gparams = gparams || {};
var autparams = user.checkAutorisation(model.autfunction, true);
if (!autparams || autparams.PRSwritelevel == 9 || autparams.ALGwritelevel == 9)
return false;
@@ -1049,8 +1072,9 @@ function generic_REST_PUT(model)
}
}
function generic_REST_DELETE(model)
function generic_REST_DELETE(model, gparams)
{
gparams = gparams || {};
var autparams = user.checkAutorisation(model.autfunction, true);
if (!autparams || autparams.PRSwritelevel == 9 || autparams.ALGwritelevel == 9)
return false;

View File

@@ -0,0 +1,25 @@
<%@ language = "JavaScript" %>
<% /*
$Revision$
$Id$
File: api_issuedisciplines.asp
Description: MLD_DISCIPLINE API
Parameters:
Context:
Notes:
*/
DOCTYPE_Disable = true;
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
THIS_FILE = "appl/api/api_issuedisciplines.asp";
%>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="./api2_rest.inc" -->
<!-- #include file="../Shared/json2.js" -->
<!-- #include file="./model_issuedisciplines.inc" -->
<%
api2_rest.process(model_issuedisciplines);
%>

View File

@@ -0,0 +1,25 @@
<%@ language = "JavaScript" %>
<% /*
$Revision$
$Id$
File: api_issuetypes.asp
Description: MLD_STDMELDING API
Parameters:
Context:
Notes:
*/
DOCTYPE_Disable = true;
ANONYMOUS_Allowed = 1; // Eigenlijk niet waar. We regelen echter alles zelf
THIS_FILE = "appl/api/api_issuetypes.asp";
%>
<!-- #include file="../Shared/common.inc" -->
<!-- #include file="./api2_rest.inc" -->
<!-- #include file="../Shared/json2.js" -->
<!-- #include file="./model_issuetypes.inc" -->
<%
api2_rest.process(model_issuetypes);
%>

View File

@@ -50,7 +50,7 @@ model_appointments =
},
list: { columns: ["id", "from", "to"] },
includes: {"visitors": { model: model_visitors,
joinfield: "bez_afspraak_key",
joinfield: "appointment",
enable_update: true
},
"tracking": {

View File

@@ -22,7 +22,7 @@ function model_custom_fields(formodel, flexModule, flexParams)
flexParams = flexParams || {};
this.module = flexModule;
this.table = "flex";
this.primary = "flexparentkey";
this.primary = "kenmerk_key";
this.records_name = "custom_fields";
this.record_name = "custom_field";
// this.records_title = L("lcl_orders");
@@ -32,12 +32,15 @@ function model_custom_fields(formodel, flexModule, flexParams)
this.tablesql = "(" + theSqlFlex + ") flex"
this.fields =
{ "id": { dbs: "kenmerk_key", typ: "key" },
"pid": { dbs: "flexparentkey", typ: "key" },
{ "id": { dbs: "kenmerk_key", typ: "key" }, // TODO: dit klopt niet helemaal. De echte unieke waarde is bez_kenmerkwaarde_key
"value": { dbs: "waarde", typ: "varchar" },
"type": { dbs: "kenmerktype", typ: "varchar" },
"sequence": { dbs: "volgnummer", typ: "number" },
"label": { dbs: "omschrijving", typ: "varchar" }
"label": { dbs: "omschrijving", typ: "varchar" },
"flexparentkey": { dbs: "flexparentkey", typ: "key" },
// TODO: record.flexparentid wordt er uitgestript vanwege niet teruglinken naar de parent
// we hebben hem echter wel nodig. Dit moet beter....
"xflexparentkey": { dbs: "xflexparentkey", typ: "key", sql: "flexparentkey" }
};
// Deze functie wordt na de GET aangeroepen. De bijlagen zijn zo afwijkend
// dat ik dat niet fatsoenlijk in 'fields' verwerkt kreeg
@@ -45,7 +48,8 @@ function model_custom_fields(formodel, flexModule, flexParams)
{
if (record.type == 'F' || record.type == 'M')
{
var flexparam = flexProps(flexModule, record.pid, String(record.id), flexParams.pNiveau, { getFiles: true, api2name: formodel.records_name });
var flexparam = flexProps(flexModule, record.xflexparentkey, String(record.id), flexParams.pNiveau,
{ getFiles: true, api2name: formodel.records_name });
record.attachments = [];
for (var f in flexparam.files)
{
@@ -57,6 +61,7 @@ function model_custom_fields(formodel, flexModule, flexParams)
digest: file.digest })
};
}
delete record["xflexparentkey"]; // nu niet meer nodig
}
this.streamattachment = function(filter, flexfields)
{
@@ -85,6 +90,12 @@ function model_custom_fields(formodel, flexModule, flexParams)
}
}
}
this.list = { columns: ["id", "label", "value"] },
// TODO: Hoe controleren dat ik wel rechten heb op deze tracking?
this.autfunction = "WEB_RESUSE"; // valsspelen TODO
this.REST_GET = generic_REST_GET(this, {});
}
function set_custom_field(jsondata, kenmerk_key, val)

View File

@@ -20,7 +20,6 @@ model_districts =
primary: "alg_district_key",
records_name: "districts",
record_name: "district",
parent_key: "alg_regio_key",
fields: {"id" : { dbs: "alg_district_key", typ: "key", label: "Key", filter: "exact" },
"name" : { dbs: "alg_district_omschrijving", typ: "varchar", label: L("lcl_district")},
"region": { dbs: "alg_regio_key", typ: "key", foreign: "alg_regio"}
@@ -42,7 +41,7 @@ model_districts =
var sql = "SELECT " + query.selects.join(", ")
+ " FROM " + query.tables.join(", ")
+ " WHERE " + query.wheres.join(" AND " )
+ " ORDER BY alg_district_omschrijving";
+ " ORDER BY alg_district_key, alg_district_omschrijving";
var json = api2.sql2json (params, sql, model_districts);

View File

@@ -31,8 +31,8 @@ model_invoicelines =
"vat" : { dbs: "fin_factuurregel_btw", typ: "float", track: true, label: L("lcl_fin_total_sum_inBTW") },
"reference": { dbs: "fin_factuurregel_referentie", typ: "varchar", track: true, label: L("lcl_fin_referencecode"), filter: "like" },
"vatvalue" : { dbs: "fin_btwtabelwaarde_key", typ: "key", foreign: "fin_btwtabelwaarde", track: true, label: L("lcl_fin_btwtarief"), filter: "exact" },
"costtype" : { dbs: "prs_kostensoort_key", typ: "key", foreign: "prs_kostensoort", track: true, label: L("lcl_shared_charge_type"), filter: "exact" }
// niet terug linken{ name: "factuur", dbs: "fin_factuur_key", typ: "key", foreign: "fac_factuur", filter: "exact" }
"costtype" : { dbs: "prs_kostensoort_key", typ: "key", foreign: "prs_kostensoort", track: true, label: L("lcl_shared_charge_type"), filter: "exact" },
"fin_factuur_key": { dbs: "fin_factuur_key", typ: "key", filter: "exact" }
},
_pre_analyze_fields: function (params, jsondata) /* analyseer inkomende jsondata, common voor PUT en POST */

View File

@@ -0,0 +1,174 @@
<% /*
$Revision$
$Id$
File: model_issuedisciplines.inc
Description: Vanuit CodeCharge gegenereerd model voor mld_discipline
Context:
Notes: TODO: De mld_disc_params er ook bij natuurlijk
*/
%>
<!-- xx#xxinclude file="model_child.inc" -->
<%
model_issuedisciplines =
{
"table": "ins_tab_discipline",
"primary": "ins_discipline_key",
"records_name": "issuedisciplines",
"record_name": "issuediscipline",
"fields": {
"id": {
"dbs": "ins_discipline_key",
"label": "Key",
"typ": "key",
"filter": "exact",
"seq": "ins_s_ins_discipline_key"
},
"disciplinetype": {
"dbs": "ins_srtdiscipline_key",
"label": L("ins_srtdiscipline_key"),
"typ": "key",
"comment": "Pas op: lookupSQL is dynamisch: \"&sqlINS_SRTDISCIPLINE_KEY&\"",
"foreign" : {
"tbl": "ins_srtdiscipline",
"key": "ins_srtdiscipline_key",
"desc": "ins_srtdiscipline_omschrijving"
},
"filter": "like",
label: L("lcl_mld_categorie")
},
"name": {
"dbs": "ins_discipline_omschrijving",
"label": L("ins_discipline_omschrijving"),
"typ": "memo",
"translate": true
},
"costtype": {
"dbs": "prs_kostensoort_key",
"label": L("prs_kostensoort_key"),
"typ": "key",
"foreign": {
"tbl": "PRS_KOSTENSOORT",
"key": "PRS_KOSTENSOORT_KEY",
"desc": "PRS_KOSTENSOORT_OMS"
},
"LOVinit": ""
},
"ins_discipline_kpnverplicht": {
"dbs": "ins_discipline_kpnverplicht",
"label": L("ins_discipline_kpnverplicht"),
"typ": "check"
},
"ins_discipline_module": {
"dbs": "ins_discipline_module",
"label": L("ins_discipline_module"),
"typ": "memo"
},
"ins_discipline_email": {
"dbs": "ins_discipline_email",
"label": L("ins_discipline_email"),
"typ": "memo"
},
"ins_discipline_ktopercentage": {
"dbs": "ins_discipline_ktopercentage",
"label": L("ins_discipline_ktopercentage"),
"typ": "number"
},
"ins_discipline_ktodrempel": {
"dbs": "ins_discipline_ktodrempel",
"label": L("ins_discipline_ktodrempel"),
"typ": "number"
}
},
"list": {
"columns": [
"id",
"name",
"costtype",
"disciplinetype"
]
},
"search": {
"autosearch": true,
"filters": ["disciplinetype"]
},
"autfunction": "WEB_MLDMGT",
"record_title": L("ins_tab_discipline"),
"records_title": L("ins_tab_discipline_m")
}
api2.generic_REST(model_issuedisciplines, { GET: { wheres: [ " ins_discipline_module = 'MLD'" ] } });
/*
FACXSL_LCL('ins_srtdiscipline_key', 'Vakgroeptype', 'Discipline type', 'Innendiensttyp', 'Type de groupe de service')
FACXSL_LCL('ins_discipline_omschrijving', 'Omschrijving', 'Description', 'Umschreibung', 'Description')
FACXSL_LCL('prs_kostensoort_key', 'Kostensoort', 'Cost category', 'Kostenart', 'Type de co<63>ts')
FACXSL_LCL('ins_discipline_kpnverplicht', 'Kostenplaats verplicht', 'Cost centre required', 'Kostenstelle erfordlich', 'Centre de co<63>ts obligatoire')
FACXSL_LCL('ins_discipline_module', 'INS_DISCIPLINE_MODULE', '@@', '@@', '@@')
FACXSL_LCL('ins_discipline_email', 'E-mail afzender notificaties', 'E-mail sender notifications', 'E-mail Absender Notifikationen', 'Exp<78>diteur e-mail des notifications')
FACXSL_LCL('ins_discipline_ktopercentage', 'Klanttevredenheidsmeting percentage', 'Customer satisfaction survey %', 'Befragung zur Kundenzufriedenheit %', 'Enqu<71>te')
FACXSL_LCL('ins_discipline_ktodrempel', 'Klanttevredenheidsmeting drempel', 'Customer satisfaction survey threshold', 'Befragung zur Kundenzufriedenheit Schwelle', 'Seuil d''enqu<71>te')
FACXSL_LCL('ins_tab_discipline', 'Vakgroep', 'Discipline', 'Innendienst', 'Groupe de service')
FACXSL_LCL('ins_tab_discipline_m', 'Vakgroepen', '@@', '@@', '@@')
----------------------------
Page event show:
'Zoek het vakgroeptype op
if fldINS_SRTDISCIPLINE_KEY <> "" then
sqlOmschrijving = "select ins_srtdiscipline_omschrijving "&_
"from ins_srtdiscipline "&_
"where ins_srtdiscipline_key = " & ToSQL(fldINS_SRTDISCIPLINE_KEY, "Number")
openrs rsOmschrijving, sqlOmschrijving
if not rsOmschrijving.EOF then
fldINS_SRTDISCIPLINE_KEY = getValue(rsOmschrijving,"ins_srtdiscipline_omschrijving")
end if
rsOmschrijving.Close
end if
----------------------------
Page event open:
tmpWhere = ""
pINS_DISCIPLINE_OMSCHRIJVING = getParam("sINS_DISCIPLINE_OMSCHRIJVING")
if not isEmpty(pINS_DISCIPLINE_OMSCHRIJVING) then
hasParam = true
tmpWhere = tmpWhere & " Upper(INS_DISCIPLINE_OMSCHRIJVING) like '%" & UCase(replace(pINS_DISCIPLINE_OMSCHRIJVING,"'","''")) & "%'"
end if
if tmpWhere <> "" then
sSQL = sSQL & " AND (" & tmpWhere & ")"
end if
----------------------------
Form event show:
'Zoek het vakgroeptype op
if fldINS_SRTDISCIPLINE_KEY <> "" then
sqlOmschrijving = "select ins_srtdiscipline_omschrijving "&_
"from ins_srtdiscipline "&_
"where ins_srtdiscipline_key = " & ToSQL(fldINS_SRTDISCIPLINE_KEY, "Number")
openrs rsOmschrijving, sqlOmschrijving
if not rsOmschrijving.EOF then
fldINS_SRTDISCIPLINE_KEY = getValue(rsOmschrijving,"ins_srtdiscipline_omschrijving")
end if
rsOmschrijving.Close
end if
----------------------------
Form event open:
tmpWhere = ""
pINS_DISCIPLINE_OMSCHRIJVING = getParam("sINS_DISCIPLINE_OMSCHRIJVING")
if not isEmpty(pINS_DISCIPLINE_OMSCHRIJVING) then
hasParam = true
tmpWhere = tmpWhere & " Upper(INS_DISCIPLINE_OMSCHRIJVING) like '%" & UCase(replace(pINS_DISCIPLINE_OMSCHRIJVING,"'","''")) & "%'"
end if
if tmpWhere <> "" then
sSQL = sSQL & " AND (" & tmpWhere & ")"
end if
*/
%>

View File

@@ -18,10 +18,10 @@ model_issueobjects =
records_name: "issueobjects",
record_name: "issueobject",
fields: {"id" : { dbs: "mld_melding_object_key", typ: "key", filter: "exact" },
//"issue": { dbs: "mld_melding_key", typ: "key", xforeign: "mld_melding" }, // niet teruglinken // mld_melding zit niet in save2db.foreignKeyTable()
"object": { dbs: "ins_deel_key", typ: "key", foreign: "ins_deel" }
"object" : { dbs: "ins_deel_key", typ: "key", foreign: "ins_deel" },
"mld_melding_key": { dbs: "mld_melding_key", typ: "key" }
},
parent_key: "MLD_MELDING_KEY",
list: { columns: ["object"] },
_analyze_fields: function (dbfields, params, jsondata) /* analyseer inkomende data, common voor PUT en POST */

View File

@@ -69,17 +69,12 @@ function model_issues(mld_key, params)
joinfield: "fac_tracking_refkey"
},
"notes": {
model: model_notes,
joinfield: "parent_key",
joinfunction: function (params)
{
/* gaat uit dat die wordt geimplementeerd met een view fac_v_notes (module, key, columns....) */
return "(module='MLD' OR module IS NULL) AND fac_v_notes.parent_key(+) = mld_melding.mld_melding_key";
}
model: new model_notes("MLD"),
joinfield: "parent"
},
"orders": {
model: new model_orders(),
joinfield: "mld_melding_key"
joinfield: "issue"
},
"custom_fields" : { model: new model_custom_fields(this, "MLD", { pNiveau: "M", readman: true, readuse: true }),
joinfield: "flexparentkey"
@@ -189,79 +184,8 @@ function model_issues(mld_key, params)
function _pre_analyze_fields (params, jsondata) /* analyseer inkomende jsondata voor POST */
{
params.data = {};
var issuetype = api2.get_jdata_refkey(jsondata.issuetype);
var account = api2.get_jdata_refkey(jsondata.account);
var mld_key = jsondata.id;
if (params.isNew)
{ // analyseer inkomende jsondata voor POST
var msgError = "";
var hasError = true;
//
// Voor een nieuwe melding moet er een geldige stdmelding zijn.
msgError = "Missing issuetype";
if (jsondata.issuetype)
{
msgError = "Invalid issuetype";
var sql_stdm = "SELECT sm.mld_stdmelding_omschrijving"
+ " , sm.mld_ins_discipline_key"
+ " , md.ins_srtdiscipline_key"
+ " , COALESCE(sm.mld_stdmelding_directklaar, dp.mld_disc_params_directklaar, 0) mld_directklaar"
+ " FROM mld_stdmelding sm"
+ " , mld_discipline md"
+ " , mld_disc_params dp"
+ " WHERE sm.mld_ins_discipline_key = md.ins_discipline_key"
+ " AND sm.mld_ins_discipline_key = dp.mld_ins_discipline_key"
+ " AND sm.mld_stdmelding_key = " + issuetype;
var oRs_stdm = Oracle.Execute(sql_stdm);
if (!oRs_stdm.eof)
{
params.data.mld_ins_discipline_key = oRs_stdm("mld_ins_discipline_key").Value;
params.data.ins_srtdiscipline_key = oRs_stdm("ins_srtdiscipline_key").Value;
params.data.mld_directklaar = oRs_stdm("mld_directklaar").Value;
hasError = false;
}
oRs_stdm.Close();
}
if (hasError) api2.error(500, msgError);
//
// Bepaal de kostenplaats, indien verplicht.
var stdm_info = mld.mld_stdmeldinginfo(issuetype);
var kpkey = (account ? account : -1);
if (stdm_info.kpnverplicht && kpkey < 0)
{ // Kostenplaats is verplicht, maar is niet meegegeven. Bepaal default kostenplaats.
kpkey = (user.afdeling().prs_kostenplaats_key() || -1); // User kostenplaats key
}
if (stdm_info.kpnverplicht && kpkey < 0)
{ // Kon ook geen default kostenplaats vinden.
msgError = "Account could not be validated";
api2.error(500, msgError);
}
jsondata.account = kpkey;
params.data.is_kto_antwoord = stdm_info.is_kto_antwoord;
//
//
if (!jsondata.contact) jsondata.contact = user_key; // Als er geen aanvrager opgegeven is, dan de huidige gebruiker invullen.
// Als de setting niet is gezet is "Melding voor" gelijk aan contactpersoon.
if (S("mld_allow_for_others") == 0)
{
jsondata.requestor = jsondata.contact;
}
}
else
{
// Bestaande melding: Haal de gegevens op.
var sql = "SELECT mld_stdmelding_key"
+ " FROM mld_melding"
+ " WHERE mld_melding_key = " + mld_key;
var oRs = Oracle.Execute(sql);
jsondata.issuetype = oRs("mld_stdmelding_key").Value;
oRs.Close();
}
//
//
var stdm_info = mld.mld_stdmeldinginfo(jsondata.issuetype);
@@ -345,15 +269,6 @@ function model_issues(mld_key, params)
alg_onroerendgoed_keys = gebouwkey;
}
params.data.alg_onroerendgoed_keys = alg_onroerendgoed_keys;
if (!params.isNew)
{ // Verwijder voor PUT wat niet gewijzigd mag worden.
delete jsondata.name;
delete jsondata.contact;
delete jsondata.requestor;
delete jsondata.issuetype;
delete jsondata.location;
}
};
function _analyze_fields (dbfields, params, jsondata) /* analyseer inkomende data, common voor PUT en POST */
@@ -421,24 +336,35 @@ function model_issues(mld_key, params)
}
else
{
msgError = "Issue can not be closed";
api2.error(500, msgError);
api2.error(500, "Issue can not be closed");
}
};
this.REST_PUT = function (params, jsondata, the_key) /* update issue */
{
if (jsondata[this.record_name])
jsondata = jsondata[this.record_name]; // dereference
if (!jsondata.id) jsondata.id = the_key;
var mld_key = the_key;
var old_mld = new model_issues(mld_key);
var mld_key = jsondata.id;
// Vul jsondata aan met actuele 'oude' data
var old_mld = new model_issues(mld_key).data;
for (var fld in old_mld)
{
if (!(fld in jsondata))
jsondata[fld] = old_mld[fld];
}
api2.cleanup_data(this, jsondata); // Doet een generieke dereference van alle foreign's
var this_mld = mld.func_enabled_melding(mld_key);
user.auth_required_or_abort(this_mld.canChange); // Geen wijzigingen toestaan bij onvoldoende rechten.
_pre_analyze_fields(params, jsondata);
// Verwijder voor PUT wat niet gewijzigd mag worden.
delete jsondata.name;
delete jsondata.contact;
delete jsondata.requestor;
delete jsondata.issuetype;
delete jsondata.location;
var dbfields = api2.update_fields(params, this, jsondata); // Build updater
_analyze_fields(dbfields, params, jsondata);
_validate_fields(dbfields, params, jsondata);
@@ -450,29 +376,55 @@ function model_issues(mld_key, params)
if (err.friendlyMsg)
abort_with_warning(err.friendlyMsg);
params.data.module = "MLD"; // model_notes moet weten bij wekle module de notes horen.
var mldtrack = api2.process_includes(params, this, jsondata, mld_key);
shared.trackaction("MLDUPD",
mld_key,
L("lcl_mld_is_mldupdtrack").format(mld_key) + (mldUpd.trackarray.length > 0? "\n" : "") + mldUpd.trackarray.join("\n"));
status = jsondata["status"].id;
if (status > 0)
mld.setmeldingstatus(mld_key, status, "");
if (jsondata.status > 0)
mld.setmeldingstatus(mld_key, jsondata.status, "");
return { key: mld_key };
};
this.REST_POST = function (params, jsondata) /* new call */
{
if (jsondata[this.record_name])
jsondata = jsondata[this.record_name]; // dereference
api2.cleanup_data(this, jsondata); // Doet een generieke dereference van alle foreign's
//
// Voor een nieuwe melding moet er een geldige stdmelding zijn.
if (!jsondata.issuetype)
api2.error(500, "Missing issuetype")
var stdm = new model_issuetypes(jsondata.issuetype).data;
//
// Bepaal de kostenplaats, indien verplicht.
var stdm_info = mld.mld_stdmeldinginfo(jsondata.issuetype);
var kpkey = (jsondata.account ? jsondata.account : -1);
if (stdm_info.kpnverplicht && kpkey < 0)
{ // Kostenplaats is verplicht, maar is niet meegegeven. Bepaal default kostenplaats.
kpkey = (user.afdeling().prs_kostenplaats_key() || -1); // User kostenplaats key
}
if (stdm_info.kpnverplicht && kpkey < 0)
{ // Kon ook geen default kostenplaats vinden.
api2.error(500, "Account could not be validated");
}
jsondata.account = kpkey;
//
if (!jsondata.contact) jsondata.contact = user_key; // Als er geen aanvrager opgegeven is, dan de huidige gebruiker invullen.
// Als de setting niet is gezet is "Melding voor" gelijk aan contactpersoon.
if (S("mld_allow_for_others") == 0)
{
jsondata.requestor = jsondata.contact;
}
params.isNew = true;
_pre_analyze_fields(params, jsondata);
var this_mld = mld.func_enabled_mld(params.data.mld_ins_discipline_key, "D");
var this_mld = mld.func_enabled_mld(stdm.discipline.id, "D");
user.auth_required_or_abort(this_mld.canFEwrite || this_mld.canFOwrite);
//
var dbfields = api2.update_fields(params, this, jsondata); // Build updater
@@ -486,18 +438,14 @@ function model_issues(mld_key, params)
var mldIns = buildInsert("mld_melding", dbfields, { noValidateToken: true });
var new_key = mldIns.sequences["mld_melding_key"];
var sql = "BEGIN "
+ mldIns.sql + ";"
+ "END;";
var sql = mldIns.sql;
Oracle.Execute(mldIns.sql);
mld.setmeldingstatus(new_key, (params.data.mld_directklaar? 0 : 2)); // Zorgt ook voor tracking & daarmee notificatie
mld.setmeldingstatus(new_key, (stdm.xmld_directklaar? 0 : 2)); // Zorgt ook voor tracking & daarmee notificatie
if (params.data.is_kto_antwoord) // die direct afmelden
if (stdm_info.xis_kto_answer) // die direct afmelden
mld.setmeldingstatus(new_key, 5);
params.data.module = "MLD"; // model_notes moet weten bij wekle module de notes horen.
return { key: new_key };
};

View File

@@ -8,17 +8,21 @@
Context:
Notes:
Notes: Normaal gesproken krijg je bij een foreign alleen de id en de de name
Voor discipline maken we hier echter een uitzondering: in de praktijk
heb je de info daarvan er eigenlijk altijd ook wel bij nodig
*/
%>
<!-- #include file="./model_issuedisciplines.inc" -->
<%
function model_issuetypes(stdm_key, params)
{
params = params || {};
this.table = "mld_stdmelding";
this.primary = "mld_stdmelding_key";
this.records_name = "issuetypes";
this.record_name = "issuetype";
this.fields= {
this.fields = {
"id": {
"dbs": "mld_stdmelding_key",
"label": "Key",
@@ -30,18 +34,18 @@ function model_issuetypes(stdm_key, params)
discipline: { dbs: "mld_ins_discipline_key", typ: "key", "foreign": "MLD_DISCIPLINE", label: L("lcl_mld_vakgroep") },
description: { dbs: "mld_stdmelding_omschrijving", typ: "varchar", label: L("lcl_mld_inf_Omschrijving") },
// { dbs: "mld_stdmelding_notfrontend", typ: "check0", frm: "notfrontend" },
costtype: { dbs: "prs_kostensoort_key", typ: "key", foreign: "prs_kostensoort", track: true, label: L("lcl_shared_charge_type"), filter: "exact" },
costtype: { dbs: "prs_kostensoort_key", typ: "key", foreign: "prs_kostensoort", label: L("lcl_shared_charge_type"), filter: "exact" },
// { dbs: "alg_onrgoed_niveau", typ: "varchar", frm: "onrgoed_niveau" },
// { dbs: "mld_stdmelding_notify", typ: "check0", frm: "notify" },
// { dbs: "mld_stdmelding_planbaar", typ: "check0", frm: "planbaar" },
// { dbs: "mld_stdmelding_freetext", typ: "key", frm: "freetext" },
// { dbs: "ins_srtinst_verplicht", typ: "check0", frm: "obj_verplicht" },
// { dbs: "mld_stdmelding_hint", typ: "varchar", frm: "aanwijzing" },
"hint": { dbs: "mld_stdmelding_hint", typ: "varchar", label: L("lcl_mld_hint") },
"autoorder": { dbs: "mld_stdmelding_autoorder", typ: "check0", label: L("lcl_mld_autoorder") },
requireservice: { dbs: "mld_stdmelding_vereisdienst", typ: "check0", label: L("lcl_mld_vereisdienst") },
issuegroup: { dbs: "mld_stdmeldinggroep_key", typ: "key", label: L("lcl_mld_meldinggroep") },
service: { dbs: "prs_dienst_key", typ: "key", label: L("lcl_mld_behandel_dienst"), foreign: "prs_dienst" },
ordertype: { dbs: "mld_typeopdr_key", typ: "key", label: L("lcl_mld_typeopdr") }
ordertype: { dbs: "mld_typeopdr_key", typ: "key", label: L("lcl_mld_typeopdr") },
// { dbs: "mld_stdmelding_regime", typ: "key", frm: "regime" },
// { dbs: "mld_stdmelding_malus", typ: "float", frm: "malus" },
// { dbs: "mld_stdmelding_afhankelijk", typ: "check0", frm: "afhankelijk" },
@@ -55,7 +59,8 @@ function model_issuetypes(stdm_key, params)
// { dbs: "bes_ins_discipline_key", typ: "key", frm: "bes_disc_key" },
// { dbs: "mld_stdmelding_vervaldatum", typ: "date", frm: "vervaldatum" },
// { dbs: "mld_stdmelding_opdrtypevast", typ: "check0", frm: "opdrtypevast" },
// { dbs: "mld_stdmelding_directklaar", typ: "key", frm: "directklaar" },
immediateready: { dbs: "mld_stdmelding_directklaar", typ: "key", label: L("lcl_mld_directklaar"), LOV: api2.makeLOV([L("lcl_No"), L("lcl_Yes"), L("lcl_mld_initieel_fo")]) },
ximmediateready: { dbs: "xmld_stdmelding_directklaar", typ: "key", sql: "COALESCE(mld_stdmelding_directklaar, mld_disc_params_directklaar, 0)" }
// { dbs: "mld_stdmelding_slabewaken", typ: "check0", frm: "slabewaken" },
// { dbs: "alg_onrgoed_obj_niveau", typ: "varchar", frm: "obj_show_niveau" },
// { dbs: "alg_org_obj_niveau", typ: "number", frm: "org_obj_niveau" },
@@ -78,11 +83,29 @@ function model_issuetypes(stdm_key, params)
"filters": ["discipline"]
};
this.soft_delete = "mld_stdmelding_verwijder";
this.autfunction = "WEB_RESMSU";
this.autfunction = "WEB_MLDMGT";
this.record_title = L("lcl_mld_standaardmelding");
this.records_title = L("lcl_mld_stdmeldingen");
api2.generic_REST(this);
api2.generic_REST(this, { GET: { tables: [ "ins_tab_discipline, mld_disc_params, ins_srtdiscipline" ],
wheres: [ "ins_tab_discipline.ins_discipline_key = mld_stdmelding.mld_ins_discipline_key",
"mld_disc_params.mld_ins_discipline_key = mld_stdmelding.mld_ins_discipline_key",
"ins_tab_discipline.ins_srtdiscipline_key = ins_srtdiscipline.ins_srtdiscipline_key"
]
}
});
if (stdm_key > 0)
{
params.filter = params.filter || {};
params.filter.id = stdm_key;
var xxx_array = this.REST_GET(params);
if (!xxx_array.length)
shared.record_not_found();
this.data = xxx_array[0];
this.data.discipline = new model_discipline("MLD", this.data.discipline.id);
}
}

View File

@@ -8,7 +8,7 @@
Parameters:
Context:
Notes:
Notes: table en fields worden dynamisch per module bepaald
*/
/*
@@ -62,32 +62,13 @@ SELECT 'PRJ'
<!-- #include file="model_objects.inc"-->
<%
model_notes =
function model_notes(module)
{
module: "FAC",
table: "fac_v_notes",
primary: "key",
records_name: "notes",
record_name: "note",
fields: {"id" : { dbs: "key", typ: "key", filter: "exact" },
"writer" : { dbs: "writer_key", typ: "key", foreign: "prs_perslid", filter: "exact" },
"description" : { dbs: "omschrijving", typ: "varchar", filter: "like" },
"createdate" : { dbs: "aanmaak", typ: "datetime" }
// { name: "module", dbs: "module", typ: "varchar", filter: "exact" }
// { name: "parent", dbs: "parent_key", typ: "key", filter: "exact" } //niet terug linken
},
this.module = module;
// this.table = "fac_v_notes";
this.records_name = "notes";
this.record_name = "note";
_analyze_fields: function (dbfields, params, jsondata) /* analyseer inkomende data, common voor PUT en POST */
{
},
_validate_fields: function (dbfields, params, jsondata) /* valideer dbfields, alle constraints die niet door de database worden afgevangen */
{
},
_getNoteTable: function (module)
{
var tabel = {}; // De tabel met notes die aangepast moet worden.
switch (module)
{
@@ -122,73 +103,72 @@ model_notes =
break;
}
}
return tabel;
},
this.table = tabel.naam;
this.primary = tabel.parent + "_note_key";
this.fields =
{ "id" : { dbs: tabel.naam + "_key", typ: "key", seq: tabel.seq, filter: "exact" },
"author" : { dbs: "prs_perslid_key", typ: "key", foreign: "prs_perslid", filter: "exact" },
"description" : { dbs: tabel.naam + "_omschrijving", typ: "varchar", filter: "like" },
"createdate" : { dbs: tabel.naam + "_aanmaak", typ: "datetime" },
// { name: "module", dbs: "module", typ: "varchar", filter: "exact" }
"parent" : { dbs: tabel.parent + "_key", typ: "key", filter: "exact" }
};
REST_GET: function _GET(params)
this.list = {
"columns": [
"id",
"author",
"description",
"createdate"
]
};
this.REST_GET = function _GET(params)
{
var query = api2.sqlfields(params, model_notes );
var wheres = api2.sqlfilter(params, model_notes);
var query = api2.sqlfields(params, this );
var wheres = api2.sqlfilter(params, this);
query.wheres = query.wheres.concat(wheres);
var sql = "SELECT " + query.selects.join(", ")
+ " FROM " + query.tables.join(", ")
+ (params.filter.id || params.filter.parent ? " WHERE " + query.wheres.join(" AND " ) : "");
+ " FROM " + query.tables.join(", ");
if (query.wheres.length)
sql += " WHERE " + query.wheres.join(" AND " );
var json = api2.sql2json (params, sql, model_notes );
var json = api2.sql2json (params, sql, this );
return json;
},
};
REST_PUT: function (params, jsondata, the_key) /* update note */
this.REST_PUT = function (params, jsondata, the_key) /* update note */
{
// Een note kan alleen worden aangepast door de persoon die hem geschreven heeft.
// Alleen van de meest recente note bij een (melding/opdrachte/...) kan de omschrijving worden aangepast.
// Alleen van de meest recente note bij een (melding/opdracht/...) kan de omschrijving worden aangepast.
//
var dbfields = api2.update_fields(params, model_notes, jsondata); // Build updater
var dbfields = api2.update_fields(params, this, jsondata); // Build updater
var xxx_tabel = model_notes._getNoteTable(params.data.module); // De tabel met notes die aangepast moet worden.
// Wijzig de veldnamen overeenkomstig de te gebruiken tabel
for (i in dbfields)
{
if (dbfields[i].dbs == "writer_key")
dbfields[i].dbs = "prs_perslid_key";
else
dbfields[i].dbs = xxx_tabel.naam + "_" + dbfields[i].dbs;
}
var wheres = [ xxx_tabel.naam+"_key = " + the_key];
var xxxUpd = buildTrackingUpdate(xxx_tabel.naam, wheres.join(" AND " ), dbfields, { noValidateToken: true });
var wheres = [ this.id.dbs + " = " + the_key];
wheres.push("prs_perslid = " + user_key);
var xxxUpd = buildTrackingUpdate(this.table, wheres.join(" AND " ), dbfields, { noValidateToken: true });
Oracle.Execute(xxxUpd.sql);
return { key: the_key };
},
};
REST_POST: function (params, jsondata) /* new note */
this.REST_POST = function (params, jsondata) /* new note */
{
params.isNew = true;
//
var xxx_tabel = model_notes._getNoteTable(params.data.module); // De tabel met notes die aangepast moet worden.
var dbfields = [];
dbfields["writer"] = { dbs: "prs_perslid_key", typ: "key", val: user_key };
dbfields["parent"] = { dbs: xxx_tabel.parent+"_key", typ: "key", val: params.filter.id };
dbfields["created"] = { dbs: xxx_tabel.naam+"_aanmaak", typ: "datetime", val: new Date() };
dbfields["description"] = { dbs: xxx_tabel.naam+"_omschrijving", typ: "varchar", val: jsondata.description };
dbfields["id"] = { dbs: xxx_tabel.naam+"_key", typ: "key", seq: xxx_tabel.seq };
var xxxIns = buildInsert(xxx_tabel.naam, dbfields, { noValidateToken: true });
var xxxIns = buildInsert(this.table, dbfields, { noValidateToken: true });
var new_key = xxxIns.sequences[xxx_tabel.naam];
var sql = "BEGIN "
+ xxxIns.sql + ";"
+ "END;";
Oracle.Execute(xxxIns.sql);
return { key: new_key };
},
REST_DELETE: function (params, the_key) /* delete note */
{ // Niet van toepassing.
}
// REST_DELETE = function (params, the_key) /* delete note doen we niet */
}
%>

View File

@@ -79,15 +79,10 @@ function model_orders(opdr_key, params)
// list: { columns: ["id", "name"], canGroup: true },
this.includes = {
"notes": {
model: model_notes,
joinfield: "parent_key",
joinfunction: function (params)
{
/* gaat uit dat die wordt geimplementeerd met een view fac_v_notes (module, key, columns....) */
return "(module='ORD' OR module IS NULL) AND fac_v_notes.parent_key(+) = mld_opdr.mld_opdr_key";
}
model: new model_notes("MLD"),
joinfield: "mld_opdr_key"
},
"custom_fields" : { model: new model_custom_fields(this, "OPDR", { pNiveau: "O", readman: true, readuse: true }),
"custom_fields" : { model: new model_custom_fields(this, "MLD", { pNiveau: "O", readman: true, readuse: true }),
joinfield: "flexparentkey"
},
"tracking": {

View File

@@ -26,7 +26,7 @@ model_regions =
"name" : { dbs: "alg_regio_omschrijving", typ: "varchar", label: L("lcl_estate_regio_descr")},
"deleted": { dbs: "alg_regio_verwijder", typ: "datetime"}
},
includes: { "districts": { model: model_districts }
includes: { "districts": { model: model_districts, joinfield: "region" }
},
_check_authorization: function(params, method)
@@ -83,7 +83,7 @@ model_regions =
var sql = "SELECT " + query.selects.join(", ")
+ " FROM " + query.tables.join(", ")
+ (query.wheres.length ? " WHERE " + query.wheres.join(" AND " ) : "")
+ " ORDER BY alg_regio_omschrijving";
+ " ORDER BY alg_regio_key, alg_regio_omschrijving";
var json = api2.sql2json (params, sql, model_regions);
return json;

View File

@@ -22,7 +22,6 @@ function model_reportcolumns(usrrap_key, params)
this.record_name = "column";
this.records_title = L("lcl_rap_columns");
this.record_title = L("lcl_rap_column");
this.parent_key = "fac_usrrap_key",
this.autfunction = "WEB_PRSSYS",
this.fields =
@@ -41,7 +40,9 @@ function model_reportcolumns(usrrap_key, params)
LOV: L("lcl_rap_visibleLOV")}, // "V;Visible;I;Invisible;H;hidden"
"group" : { dbs: "fac_usrrap_cols_group", typ: "varchar", label: L("lcl_rap_groupby"),
required: true,
LOV: L("lcl_rap_groupbyLOV") }
LOV: L("lcl_rap_groupbyLOV") },
"fac_usrrap_key" : { dbs: "fac_usrrap_key", typ: "key" }
};
this.list = { columns: ["sequence", "name", "caption", "datatype", "visible", "filter", "group"] };

View File

@@ -127,7 +127,7 @@ function model_reportsx(usrrap_key, params)
sql += ", fac_usrrap_cols_volgnr";
var json = api2.sql2json (params, sql, this);
if (json.length == 1 && params.include && json[0].columns.length == 0)
if (json.length == 1 && params.include && "columns" in params.include && json[0].columns.length == 0)
{
this.includes["columns"].model._view2columns(params.filter.id);
var json = api2.sql2json (params, sql, this );

View File

@@ -28,14 +28,13 @@ model_reservationconsumables =
primary: "res_rsv_artikel_key",
records_name: "reservationconsumables",
record_name: "reservationconsumable",
parent_key: "res_rsv_ruimte_key",
fields: { "id" : { dbs: "res_rsv_artikel_key", typ: "key", filter: "exact" },
"reservation": { dbs: "res_rsv_ruimte_key", typ: "key", filter: "exact", foreign: "res_rsv_ruimte" },
"consumable" : { dbs: "res_artikel_key", typ: "key", filter: "exact", foreign: "res_artikel" },
"amount" : { dbs: "res_rsv_artikel_aantal", typ: "number"},
"status" : { dbs: "res_status_bo_key", typ: "number", filter: "exact", foreign: status_bo },
"reservation": { dbs: "res_rsv_ruimte_key", typ: "key", filter: "exact", foreign: "res_rsv_ruimte" },
"from" : { dbs: "res_rsv_artikel_levering", typ: "date", filter: "exact" },
"from" : { dbs: "res_rsv_artikel_levering", typ: "time", filter: "exact" },
//: "to" { dbs: "res_rsv_artikel_tot", typ: "date" },
"price" : { dbs: "res_rsv_artikel_prijs", typ: "float" },
"processed" : { dbs: "res_rsv_artikel_verwerkt", typ: "datetime" },
@@ -43,6 +42,7 @@ model_reservationconsumables =
"changed" : { dbs: "res_rsv_artikel_mutatie", typ: "datetime" },
"dirtlevel" : { dbs: "res_rsv_artikel_dirtlevel", typ: "number", filter: "exact" }
},
list: { columns: [ "id", "from", "amount", "consumable", "price" ] },
REST_GET: function _GET(params)
{

View File

@@ -32,9 +32,9 @@ model_reservationequipment =
primary: "res_rsv_deel_key",
records_name: "reservationequipment",
record_name: "reservationequipment",
parent_key: "res_rsv_ruimte_key",
fields: {"id" : { dbs: "res_rsv_deel_key", typ: "key", filter: "exact" },
"reservation": { dbs: "res_rsv_ruimte_key", typ: "key", filter: "exact", foreign: "res_rsv_ruimte" },
"equipment" : { dbs: "res_deel_key", typ: "key", filter: "exact", foreign: "res_deel" },
"status" : { dbs: "res_status_bo_key", typ: "key", filter: "exact", foreign: res.getbostatustext },
"from" : { dbs: "res_rsv_deel_van", typ: "datetime", filter: "exact" },
@@ -45,9 +45,10 @@ model_reservationequipment =
"changed" : { dbs: "res_rsv_deel_mutatie", typ: "datetime" },
"dirtlevel" : { dbs: "res_rsv_deel_dirtlevel", typ: "number", filter: "exact" }
// altijd 1 { name: "number", dbs: "res_rsv_deel_aantal", typ: "number", filter: "exact" }
// niet terug linken { name: "reservation", dbs: "res_rsv_ruimte_key", typ: "key", filter: "exact", foreign: "res_rsv_ruimte" }
},
list: { columns: [ "id", "from", "to", "equipment", "price" ] },
REST_GET: function _GET(params)
{
var urole = "fe"; // TODO: Moet echt niet ter zake doen

View File

@@ -66,11 +66,11 @@ function model_reservations(rsv_key, params)
this.list = { columns: ["id", "name", "from", "to"] };
this.includes =
{"reservationequipment": { model: model_reservationequipment,
joinfield: "res_rsv_ruimte_key",
joinfield: "reservation",
enable_update: true
},
"reservationconsumables": { model: model_reservationconsumables,
joinfield: "res_rsv_ruimte_key"
joinfield: "reservation"
},
"tracking": {
model: new model_tracking(['reservering', 'xreservering']),

View File

@@ -20,7 +20,6 @@ function model_tracking(xmlnodes)
this.primary = "fac_tracking_key";
this.records_name = "tracking";
this.record_name = "tracking";
this.parent_key = "fac_tracking_refkey";
this.tablesql = "(SELECT fac_tracking_key,"
+ " ft.fac_srtnotificatie_key,"
@@ -37,10 +36,17 @@ function model_tracking(xmlnodes)
this.fields =
{ "id": { dbs: "fac_tracking_key", typ: "key" },
"notification": { dbs: "fac_srtnotificatie_key", typ: "key", foreign: "FAC_SRTNOTIFICATIE" },
"date": { dbs: "fac_tracking_datum", typ: "date" },
"date": { dbs: "fac_tracking_datum", typ: "datetime" },
"description": { dbs: "fac_tracking_oms", typ: "varchar" },
"person": { dbs: "prs_perslid_key", typ: "varchar", foreign: "PRS_PERSLID" }
"person": { dbs: "prs_perslid_key", typ: "varchar", foreign: "PRS_PERSLID" },
"fac_tracking_refkey": { dbs: "fac_tracking_refkey", typ: "key" }
};
this.list = { columns: ["id", "date", "notification", "description", "person"] },
// TODO: Hoe controleren dat ik wel rechten heb op deze tracking?
this.autfunction = "WEB_RESUSE"; // valsspelen TODO
this.REST_GET = generic_REST_GET(this, {});
}
%>

View File

@@ -20,15 +20,14 @@ model_visitors =
primary: "bez_bezoekers_key",
records_name: "visitors",
record_name: "visitor",
parent_key: "bez_afspraak_key",
fields: {"id" : { dbs: "bez_bezoekers_key", typ: "key", filter: "exact" },
"name" : { dbs: "bez_afspraak_naam", typ: "varchar", label: L("lcl_vis_name")},
"company": { dbs: "bez_afspraak_bedrijf", typ: "varchar", label: L("lcl_vis_company")},
"company" : { dbs: "bez_afspraak_bedrijf", typ: "varchar", label: L("lcl_vis_company")},
"badge" : { dbs: "bez_bezoekers_pasnr", typ: "varchar", label: L("lcl_vis_badgenr")},
"in" : { dbs: "bez_bezoekers_done", typ: "datetime", label: L("lcl_bez_done_date")},
"out" : { dbs: "bez_bezoekers_out", typ: "datetime", label: L("lcl_bez_out_date")}
// niet teruglinken, { name: "appointment", dbs: "bez_afspraak_key", typ: "key", foreign: "bez_afspraak"}
"out" : { dbs: "bez_bezoekers_out", typ: "datetime", label: L("lcl_bez_out_date")},
"appointment": { dbs: "bez_afspraak_key", typ: "key", xforeign: "bez_afspraak"}
},
list: { columns: ["name", "company", "in", "out"] },

View File

@@ -8,7 +8,7 @@
Context:
Note:
*/
if (!this.JSON_Result)
if (!this.JSON_Result && !Request.QueryString("api2").Count)
FCLTHeader.Requires({css: ["../res/res.css"] });
res = {

View File

@@ -48,6 +48,7 @@ function scaffolding(model, scf_params)
var imodel = getQParam("model", ""); // include model
if (model.includes && imodel in model.includes)
{
scf_params.incsetting = model.includes[imodel];
model = model.includes[imodel].model;
if (typeof model == "function") // Nieuwe stijl is het een function. Even compatible.
model = new model();

View File

@@ -109,6 +109,12 @@ function scaffolding_list(model, scf_params)
}
var xxx_params = { filter : scf_params.filter || shared.qs2json(), columns: scf_params.list.columns, groupby: scf_params.list.groups };
if (scf_params.incsetting && "id" in xxx_params.filter) // Zijn we eigenlijk een include?
{ // dan moet de id-filter op het joinfield
xxx_params.filter[scf_params.incsetting.joinfield] = xxx_params.filter["id"];
delete xxx_params.filter["id"];
}
if (!("limit" in xxx_params.filter))
{
xxx_params.filter.limit = showAll?S("qp_maxrows2"):S("qp_maxrows")

View File

@@ -73,11 +73,11 @@ function scaffolding_wrap(model, scf_params)
for (var inc in model.includes)
{
var include = model.includes[inc];
if (include.joinfield == model.fields["id"].dbs)
if (!include.joinfunction) // die is te ingewikkeld?
{
var filter = {};
filter[include.joinfield] = key;
var url = scf_params.this_fullpath + "?mode=list&model=" + inc + "&pid=" + key;
var url = scf_params.this_fullpath + "?mode=list&model=" + inc;
// Vanuit fac_reportx heeft fullpath geen id in zich verwerkt. Daarom nog maar een keer in de url
url += "&id=" + key;
IFRAMER("xxxFrame", url, { FcltClose: "scfClose" } );
}
}

View File

@@ -798,6 +798,19 @@ safe = {
return "NULL";
return safe.quoted_sql(tekst.toUpperCase().replace(/\*/g, "%"), maxlen);
},
// converteer alle waarden in arr naar integer.
// waar dat niet lukt worden ze gewoon verwijderd(?)
int_array: function (arr)
{
var safe_arr = [];
for (var i = 0; i < arr.length; i++)
{
var v = parseInt(arr[i], 10);
if (!isNaN(v))
safe_arr.push(v);
}
return safe_arr;
},
filename: function (naam) // geen 'lage' karakters en geen (back)slashes, *,%,<,>, '"', ':', ';' '?' and '|'
{