Files
Facilitor/APPL/API2/model_bes_discipline.inc
2023-05-02 14:34:20 +00:00

166 lines
5.4 KiB
PHP

<% /*
$Revision$
$Id$
File: model_bes_discipline.inc
Description: Vanuit CodeCharge gegenereerd model voor bes_discipline
Context:
Notes: intern hebben we een apart model voor _bes_disc_params
Naar de buitenwereld presenteren we het als één model
*/
%>
<!-- #include file="../api2/model_bes_disc_params.inc" -->
<!-- #include file="../api2/model_bes_srtgroep.inc" -->
<!-- #include file="../mgt/mgt.inc"-->
<%
function model_bes_discipline(disc_key, params)
{
// Eén model voor de buitenwereld
api2.merge_disc_params_model(this, _model_bes_discipline);
this.hook_pre_edit = function(obj, fld, scf_params)
{
var proturl = protectQS.create("../shared/BijlagenForm.asp?module=BESD" + (mode == "show"? "&reado=1" : ""));
%>
<script>
var proturl_bijlage = "<%=proturl%>";
</script>
<%
}
this.REST_GET = generic_REST_GET(_model_bes_discipline, // Let op: de originele _model_bes_discipline
{ "GET": {
wheres: [ "ins_tab_discipline.ins_discipline_module = 'BES'"
]
}
}
);
this.hook_post_post = function (params, obj, key)
{
var org_disc_key = getQParamInt("id", -1);
var clone_auth = getQParamInt("clone_auth", 0) == 1;
if (clone_auth)
{ // Ook de autorisatie van de oude discipline kopieren
mgt.clone_authorization(key, org_disc_key);
}
}
this.REST_POST = generic_REST_POST(_model_bes_discipline);
this.REST_PUT = generic_REST_PUT(_model_bes_discipline);
this.REST_DELETE = generic_REST_DELETE(this, {});
}
_model_bes_discipline = // Internal only
{
"records_name": "orderdisciplines",
"record_name": "orderdiscipline",
"table": "ins_tab_discipline",
"audit": { "childtable": "bes_disc_params" }, // Parameters voor fac_audit.
"primary": "ins_discipline_key",
"soft_delete": "ins_discipline_verwijder",
"autfunction": "WEB_BESMSU",
"record_title": L("bes_discipline"),
"records_title": L("bes_discipline_m"),
"fields": {
"id": {
"dbs": "ins_discipline_key",
"label": L("lcl_key"),
"typ": "key",
"required": true,
"seq": "ins_s_ins_discipline_key"
},
"module": {
"dbs": "ins_discipline_module",
"label": L("ins_discipline_module"),
"typ": "varchar",
"defaultvalue": "BES",
"hidden_fld": true
},
"name": {
"dbs": "ins_discipline_omschrijving",
"label": L("ins_discipline_omschrijving"),
"typ": "varchar",
"filter": "like",
"translate": true,
"required": true
},
"costtype": {
"dbs": "prs_kostensoort_key",
"label": L("prs_kostensoort_key"),
"typ": "key",
"foreign": "prs_kostensoort",
"LOVinit": "",
"showtransit": true
},
"costcentremandatory": {
"dbs": "ins_discipline_kpnverplicht",
"label": L("ins_discipline_kpnverplicht"),
"typ": "key",
"LOV": buildKpnVerplichtList(),
"required": true
},
"remark": {
"dbs": "ins_discipline_opmerking",
"label": L("ins_discipline_opmerking"),
"typ": "memo",
"translate": true
},
"satisfactionpercentage": {
"dbs": "ins_discipline_ktopercentage",
"label": L("ins_discipline_ktopercentage"),
"typ": "number"
},
"satisfactionthreshold": {
"dbs": "ins_discipline_ktodrempel",
"label": L("ins_discipline_ktodrempel"),
"typ": "number"
},
"symbolname": {
"dbs": "ins_discipline_image",
"typ": "symbol",
"module": "BESD",
"label": L("lcl_bes_symbol_name")
},
"externnr": {
"dbs": "ins_discipline_externnr",
"typ": "varchar",
"label": L("extern_nr")
},
"externsyncdate": {
"dbs": "ins_discipline_externsyncdate",
"typ": "datetime",
"label": L("extern_syncdate"),
"readonly": !user.has("WEB_FACTAB")
}
/* Velden van BES_DISC_PARAMS komen er dynamisch bij */
},
"disc_params": {
model: model_bes_disc_params,
joinfield: "orderdiscipline"
}
// problematisch omdat disc_params ook een orderdisciplines heeft
// bovendien verwarrend bij punchout
//"includes": {
// "articlegroups" : {
// "model": new model_bes_srtgroep(),
// "joinfield": "orderdisciplines",
// "enable_update": true,
// "required": true
// }
// }
}
function buildKpnVerplichtList()
{
return "0;" + L("mgt_discipline_kpnverplicht_0")
+ ";1;" + L("mgt_discipline_kpnverplicht_1")
+ ";2;" + L("mgt_discipline_kpnverplicht_2");
}
%>