Files
Facilitor/APPL/API2/model_buildings.inc
Jos Groot Lipman 07d4374194 FSN#38299 Flexkenmerken via de API kunnen bewerken: ook gebouw in ieder geval opvragen
svn path=/Website/trunk/; revision=33679
2017-05-03 21:25:35 +00:00

79 lines
3.7 KiB
PHP

<% /*
$Revision$
$Id$
File: model_buildings.inc
Description: Gebouwen model.
Parameters:
Context:
Notes:
*/
%>
<!-- #include file="../Shared/discxalg3d.inc"-->
<!-- #include file="./model_custom_fields.inc"-->
<!-- #include file="../mgt/mgt_tools.inc"-->
<!-- #include file="./model_alg_kenmerk.inc"-->
<%
function model_buildings()
{
this.table = "alg_gebouw";
this.primary = "alg_gebouw_key";
this.records_name = "buildings";
this.record_name = "building";
this.fields = {"id" : { dbs: "alg_gebouw_key", typ: "key", filter: "exact" },
"code" : { dbs: "alg_gebouw_code", typ: "varchar", filter: "like" },
"name" : { dbs: "alg_gebouw_naam", typ: "varchar", filter: "like" },
// is afgeleid gegeven { name: "description", dbs: "alg_gebouw_omschrijving", typ: "varchar"},
"visitable" : { dbs: "alg_gebouw_bez", typ: "check", filter: "exact"},
"location" : { dbs: "alg_locatie_key", typ: "key", foreign: "alg_locatie", filter: "exact"},
"buildingfunction": { dbs: "alg_srtgebouw_key",
typ: "key",
foreign: { tbl: "alg_srtgebouw",
key: "alg_srtgebouw_key",
desc: "alg_srtgebouw_omschrijving"
}
},
"remark" : { dbs: "alg_gebouw_opmerking", typ: "varchar" },
"openfrom" : { dbs: "alg_gebouw_beginuur", typ: "float", track: true, label: L("lcl_estate_gebouw_beginuur") },
"opento" : { dbs: "alg_gebouw_einduur", typ: "float", track: true, label: L("lcl_estate_gebouw_einduur") },
"workdays" : { dbs: "alg_gebouw_werkdagen", typ: "number" },
"email" : { dbs: "alg_gebouw_email", typ: "varchar" },
"coordinate_x": { dbs: "alg_gebouw_x", typ: "number"},
"coordinate_y": { dbs: "alg_gebouw_y", typ: "number"},
"deleted" : { dbs: "alg_gebouw_verwijder", typ: "datetime" }
},
this.includes = {
"custom_fields" : {
"model": new model_custom_fields(this, new model_alg_kenmerk("G", { internal: true }), { readman: true, readuse: true }),
"joinfield": "flexparentkey",
"enable_update": true
}
}
this.REST_GET = function _GET(params)
{
var urole = "fe"; // TODO: Moet echt niet ter zake doen
var autfunction = urole == "fe"? "WEB_ALGUSE" : "WEB_ALGMAN";
params.authparams = user.checkAutorisation(autfunction, null, null, true); // pessimistisch
// TODO: Add authorization
var query = api2.sqlfields(params, this);
query.wheres.push("alg_gebouw_verwijder IS NULL");
var wheres = api2.sqlfilter(params, this)
query.wheres = query.wheres.concat(wheres);
var sql = "SELECT " + query.selects.join(", ")
+ " FROM " + query.tables.join(", ")
+ " WHERE " + query.wheres.join(" AND " )
+ " ORDER BY alg_gebouw_code";
var json = api2.sql2json (params, sql, this);
return json;
}
}
%>