62 lines
2.0 KiB
PHP
62 lines
2.0 KiB
PHP
<% /*
|
|
$Revision$
|
|
$Id$
|
|
|
|
File: model_locations.inc
|
|
|
|
Description: Locatie model.
|
|
Parameters:
|
|
Context:
|
|
|
|
Notes:
|
|
*/
|
|
|
|
%>
|
|
<!-- #include file="../Shared/discxalg3d.inc"-->
|
|
<%
|
|
model_locations =
|
|
{
|
|
table: "alg_locatie",
|
|
primary: "alg_locatie_key",
|
|
records_name: "locations",
|
|
record_name: "location",
|
|
fields: {"id" : { dbs: "alg_locatie_key", typ: "key", filter: "exact" },
|
|
"code" : { dbs: "alg_locatie_code", typ: "varchar", filter: "like" },
|
|
"name" : { dbs: "alg_locatie_omschrijving", typ: "varchar"},
|
|
"district" : { dbs: "alg_district_key", typ: "key", foreign: "alg_district"},
|
|
"coordinate_x" : { dbs: "alg_locatie_x", typ: "number"},
|
|
"coordinate_y" : { dbs: "alg_locatie_y", typ: "number"}
|
|
},
|
|
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, model_locations);
|
|
query.wheres.push("alg_locatie_verwijder IS NULL");
|
|
|
|
var wheres = api2.sqlfilter(params, model_locations)
|
|
query.wheres = query.wheres.concat(wheres);
|
|
|
|
var sql = "SELECT " + query.selects.join(", ")
|
|
+ " FROM " + query.tables.join(", ")
|
|
+ " WHERE " + query.wheres.join(" AND " )
|
|
+ " ORDER BY alg_locatie_code";
|
|
|
|
var json = api2.sql2json (params, sql, model_locations);
|
|
|
|
return json;
|
|
},
|
|
PUT: function (params) /* update location */
|
|
{
|
|
},
|
|
POST: function (params) /* new location */
|
|
{
|
|
},
|
|
DELETE: function (params) /* delete location */
|
|
{
|
|
}
|
|
}
|
|
%> |