101 lines
2.9 KiB
PHP
101 lines
2.9 KiB
PHP
<% /*
|
|
$Revision$
|
|
$Id$
|
|
|
|
File: model_prs_afdeling.inc
|
|
|
|
Description: Afdelingen model.
|
|
Parameters:
|
|
Context:
|
|
|
|
Notes:
|
|
*/
|
|
%>
|
|
<!-- #include file="../prs/prs.inc" -->
|
|
<!-- #include file="./model_custom_fields.inc"-->
|
|
<!-- #include file="../mgt/mgt_tools.inc"-->
|
|
<!-- #include file="./model_prs_kenmerk.inc"-->
|
|
<%
|
|
|
|
function model_prs_afdeling()
|
|
{
|
|
this.table = "prs_afdeling";
|
|
this.primary = "prs_afdeling_key";
|
|
this.records_name = "companies";
|
|
this.record_name = "company";
|
|
|
|
|
|
this.fields = {
|
|
"id": {
|
|
"dbs": "prs_afdeling_key",
|
|
"typ": "key"
|
|
},
|
|
"name": {
|
|
"dbs": "prs_afdeling_naam",
|
|
"typ": "varchar"
|
|
},
|
|
"description": {
|
|
"dbs": "prs_afdeling_omschrijving",
|
|
"typ": "varchar"
|
|
},
|
|
"company": {
|
|
"dbs": "prs_afdeling_key",
|
|
"label": L("lcl_prs_company"),
|
|
"typ": "key",
|
|
"foreign": "prs_afdeling"
|
|
},
|
|
"parent": {
|
|
"dbs": "prs_afdeling_parentkey",
|
|
"label": L("lcl_prs_organisatie"),
|
|
"typ": "key",
|
|
"foreign": "prs_afdeling"
|
|
},
|
|
"costcentre": {
|
|
"dbs": "prs_kostenplaats_key",
|
|
"label": L("prs_kostenplaats_key"),
|
|
"typ": "key",
|
|
"foreign": {
|
|
"tbl": "prs_kostenplaats",
|
|
"key": "prs_kostenplaats_key",
|
|
"desc": "prs_kostenplaats_nr"
|
|
},
|
|
"multiedit": true
|
|
}
|
|
};
|
|
|
|
this.includes = {
|
|
"custom_fields" : {
|
|
"model": new model_custom_fields(this, new model_prs_kenmerk("A", { internal: true }), { readman: true, readuse: true, pNiveau: "A" }),
|
|
"joinfield": "flexparentkey",
|
|
"enable_update": true
|
|
}
|
|
};
|
|
|
|
this.REST_GET = function _GET(params)
|
|
{
|
|
var autfunction = "WEB_RELMAN";
|
|
params.authparams = user.checkAutorisation(autfunction, null, null, true); // pessimistisch
|
|
|
|
// TODO: Add authorization
|
|
var query = api2.sqlfields(params, this);
|
|
query.wheres.push("prs_afdeling_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 prs_afdeling_naam";
|
|
|
|
var json = api2.sql2json (params, sql, this);
|
|
|
|
return json;
|
|
};
|
|
|
|
// (even) nog geen updates
|
|
//this.REST_POST = generic_REST_POST(this);
|
|
//this.REST_PUT = generic_REST_PUT(this);
|
|
//this.REST_DELETE = generic_REST_DELETE(this);
|
|
}
|
|
%> |