60 lines
1.9 KiB
PHP
60 lines
1.9 KiB
PHP
<% /*
|
|
$Revision$
|
|
$Id$
|
|
|
|
File: model_districts.inc
|
|
|
|
Description: District model.
|
|
Parameters:
|
|
Context:
|
|
|
|
Notes:
|
|
*/
|
|
|
|
%>
|
|
<!-- #include file="../Shared/discxalg3d.inc"-->
|
|
<%
|
|
model_districts =
|
|
{
|
|
table: "alg_district",
|
|
primary: "alg_district_key",
|
|
records_name: "districts",
|
|
record_name: "district",
|
|
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", comment: "reference to Region"}
|
|
},
|
|
list: { columns: ["id", "name"] },
|
|
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_districts);
|
|
query.wheres.push("alg_district_verwijder IS NULL");
|
|
|
|
var wheres = api2.sqlfilter(params, model_districts)
|
|
query.wheres = query.wheres.concat(wheres);
|
|
|
|
var sql = "SELECT " + query.selects.join(", ")
|
|
+ " FROM " + query.tables.join(", ")
|
|
+ " WHERE " + query.wheres.join(" AND " )
|
|
+ " ORDER BY alg_district_key, alg_district_omschrijving";
|
|
|
|
var json = api2.sql2json (params, sql, model_districts);
|
|
|
|
return json;
|
|
},
|
|
PUT: function (params) /* update district */
|
|
{
|
|
},
|
|
POST: function (params) /* new district */
|
|
{
|
|
},
|
|
DELETE: function (params) /* delete district */
|
|
{
|
|
}
|
|
}
|
|
%> |