291 lines
10 KiB
PHP
291 lines
10 KiB
PHP
<% /*
|
|
$Revision$
|
|
$Id$
|
|
|
|
File: model_fac_srtnotificatie.inc
|
|
|
|
Description: Vanuit CodeCharge gegenereerd model voor fac_srtnotificatie
|
|
|
|
Context:
|
|
|
|
Notes:
|
|
*/
|
|
%>
|
|
<%
|
|
|
|
function model_fac_srtnotificatie(cust)
|
|
{
|
|
this.records_name = "notificationtypes";
|
|
this.record_name = "notificationtype";
|
|
this.table = "fac_srtnotificatie";
|
|
this.primary = "fac_srtnotificatie_key";
|
|
this.autfunction = "WEB_PRSSYS";
|
|
this.record_title = L("fac_srtnotificatie");
|
|
this.records_title = L("fac_srtnotificatie_m");
|
|
|
|
this.fields = {
|
|
"id": {
|
|
"dbs": "fac_srtnotificatie_key",
|
|
"label": L("lcl_key"),
|
|
"typ": "key",
|
|
"required": true,
|
|
"seq": "fac_s_fac_srtnotificatie_key",
|
|
"filter": "exact"
|
|
},
|
|
"name": {
|
|
"dbs": "fac_srtnotificatie_code",
|
|
"label": L("fac_srtnotificatie_code"),
|
|
"typ": "varchar",
|
|
"readonly": true
|
|
},
|
|
"description": {
|
|
"dbs": "fac_srtnotificatie_oms",
|
|
"label": L("fac_srtnotificatie_oms"),
|
|
"typ": "memo",
|
|
"translate": true,
|
|
"islcl": true,
|
|
"filter": "like"
|
|
},
|
|
"xmlnode": {
|
|
"dbs": "fac_srtnotificatie_xmlnode",
|
|
"label": L("fac_srtnotificatie_xmlnode"),
|
|
"typ": "varchar",
|
|
"readonly": true,
|
|
"LOV": fill_srtnotificatie_LOV(),
|
|
"emptyoption": null
|
|
},
|
|
"notificationurl": {
|
|
"dbs": "fac_srtnotificatie_url",
|
|
"label": L("fac_srtnotificatie_url"),
|
|
"typ": "varchar",
|
|
"readonly": true
|
|
},
|
|
"group": {
|
|
"dbs": "fac_srtnotificatie_groep",
|
|
"label": L("fac_srtnotificatie_groep"),
|
|
"typ": "varchar",
|
|
"readonly": true
|
|
},
|
|
"notificationmode": {
|
|
"dbs": "fac_srtnotificatie_mode",
|
|
"label": "",
|
|
"typ": "number",
|
|
"bits": [
|
|
{
|
|
"name": "",
|
|
"label": "",
|
|
"typ": "check",
|
|
"mask": 63,
|
|
"radios": [
|
|
{
|
|
"name": "portal_statusinfo",
|
|
"label": L("fac_srtnotificatie_portal_statusinfo"),
|
|
"mask": 1
|
|
},
|
|
{
|
|
"name": "send_email",
|
|
"label": L("fac_srtnotificatie_send_email"),
|
|
"mask": 2
|
|
},
|
|
{
|
|
"name": "send_sms",
|
|
"label": L("fac_srtnotificatie_send_sms"),
|
|
"mask": 4
|
|
},
|
|
{
|
|
"name": "portal_popup",
|
|
"label": L("fac_srtnotificatie_portal_popup"),
|
|
"mask": 8
|
|
},
|
|
{
|
|
"name": "stylesheet",
|
|
"label": L("fac_srtnotificatie_stylesheet"),
|
|
"mask": 16
|
|
},
|
|
{
|
|
"name": "app_push",
|
|
"label": L("fac_srtnotificatie_pushapp"),
|
|
"mask": 32
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
"attachment": {
|
|
"dbs": "fac_srtnotificatie_srtkm_key",
|
|
"label": L("fac_srtnotificatie_srtkenmerk"),
|
|
"typ": "key",
|
|
"foreign": {
|
|
"tbl": "(" + xxx_srtkenmerk_sql() + ")",
|
|
"key": "srtkenmerk_key",
|
|
"desc": "omschrijving"
|
|
},
|
|
"defaultvalue": null
|
|
},
|
|
"usermode": {
|
|
"dbs": "fac_srtnotificatie_usermode",
|
|
"label": L("fac_srtnotificatie_usermode"),
|
|
"typ": "check0",
|
|
"listfunction": fnshowusermode,
|
|
"multiedit": true
|
|
},
|
|
"mailbuilding": {
|
|
"dbs": "fac_srtnotificatie_gebouw",
|
|
"label": L("fac_srtnotificatie_gebouw"),
|
|
"typ": "check0",
|
|
"listfunction": fnshowmailbuilding,
|
|
"multiedit": true
|
|
},
|
|
"delay": {
|
|
"dbs": "fac_srtnotificatie_delay",
|
|
"label": L("fac_srtnotificatie_delay"),
|
|
"typ": "number",
|
|
"required": true,
|
|
"defaultvalue": "0",
|
|
"multiedit": true
|
|
},
|
|
"modestatus": {
|
|
"dbs": "notimode.status",
|
|
"label": L("fac_srtnotificatie_status"),
|
|
"typ": "varchar",
|
|
"hidden_fld": true
|
|
},
|
|
"modeemail": {
|
|
"dbs": "notimode.email",
|
|
"label": L("fac_srtnotificatie_mail"),
|
|
"typ": "varchar",
|
|
"hidden_fld": true
|
|
},
|
|
"modesms": {
|
|
"dbs": "notimode.sms",
|
|
"label": L("fac_srtnotificatie_sms"),
|
|
"typ": "varchar",
|
|
"hidden_fld": true
|
|
},
|
|
"modealert": {
|
|
"dbs": "notimode.portal",
|
|
"label": L("fac_srtnotificatie_alert"),
|
|
"typ": "varchar",
|
|
"hidden_fld": true
|
|
},
|
|
"modeapp": {
|
|
"dbs": "notimode.apppush",
|
|
"label": L("fac_srtnotificatie_app"),
|
|
"typ": "varchar",
|
|
"hidden_fld": true
|
|
}
|
|
};
|
|
|
|
if (!S("puo_smsaccount"))
|
|
this.fields.notificationmode.bits[0].radios.splice(2, 1);
|
|
|
|
var ext_sql = "(SELECT fac_srtnotificatie_key"
|
|
+ " , DECODE(BITAND(fac_srtnotificatie_mode, 1), 1,"+ safe.qL("lcl_on") +", '') status"
|
|
+ " , DECODE(BITAND(fac_srtnotificatie_mode, 2), 2,"+ safe.qL("lcl_on") +", '') email"
|
|
+ " , DECODE(BITAND(fac_srtnotificatie_mode, 4), 4,"+ safe.qL("lcl_on") +", '') sms"
|
|
+ " , DECODE(BITAND(fac_srtnotificatie_mode, 8), 8,"+ safe.qL("lcl_on") +", '') portal"
|
|
+ " , DECODE(BITAND(fac_srtnotificatie_mode, 32),32,"+ safe.qL("lcl_on") +", '') apppush"
|
|
+ " FROM fac_srtnotificatie) notimode ";
|
|
|
|
var get_param = {
|
|
"GET": {
|
|
"tables": [ext_sql],
|
|
"wheres": ["fac_srtnotificatie.fac_srtnotificatie_key = notimode.fac_srtnotificatie_key"]
|
|
}
|
|
};
|
|
|
|
function fill_srtnotificatie_LOV()
|
|
{
|
|
var xmlnodeLOV = "";
|
|
var sql = "SELECT distinct fac_srtnotificatie_xmlnode"
|
|
+ " , NVL(fac_srtnotificatie_xmlnode,'<empty>') xmlnode_lov"
|
|
+ " FROM fac_srtnotificatie"
|
|
+ " ORDER BY 1 NULLS FIRST";
|
|
var oRs = Oracle.Execute(sql);
|
|
while (!oRs.eof)
|
|
{
|
|
var xmlnode = oRs("fac_srtnotificatie_xmlnode").Value;
|
|
xmlnodeLOV += (xmlnodeLOV?";":"") + xmlnode + ";" + oRs("xmlnode_lov").Value;
|
|
oRs.moveNext();
|
|
}
|
|
oRs.Close();
|
|
return xmlnodeLOV;
|
|
}
|
|
|
|
function xxx_srtkenmerk_sql()
|
|
{
|
|
var sql = "(select sk.mld_srtkenmerk_key srtkenmerk_key"
|
|
+ " , sk.mld_srtkenmerk_omschrijving || ' (' || sk.mld_srtkenmerk_key || ')' omschrijving"
|
|
+ " from mld_srtkenmerk sk"
|
|
+ " where sk.mld_srtkenmerk_verwijder is null"
|
|
+ " and sk.mld_srtkenmerk_kenmerktype in ('M', 'F')" // -- 'E', 'X')
|
|
+ " order by sk.mld_srtkenmerk_omschrijving)"
|
|
return sql;
|
|
}
|
|
|
|
if (cust==1 && user.has("WEB_FACTAB"))
|
|
{
|
|
// Een gebruiker met WEB_FACTAB-rechten mag meer velden wijzigen...
|
|
this.fields.name.label = "CUST";
|
|
this.fields.name.readonly = false;
|
|
this.fields.name.required = true;
|
|
if (mode == "edit")
|
|
this.fields.name.len = 2; // Maximale lengte van de code = 6, maar er wordt CUST voor gezet (zie: hook_pre_post).
|
|
this.fields.xmlnode.readonly = false;
|
|
this.fields.xmlnode.required = true;
|
|
this.fields.description.required = true;
|
|
this.fields.notificationurl.readonly = false;
|
|
this.fields.group.readonly = false;
|
|
|
|
get_param.GET.wheres.push("UPPER(SUBSTR(fac_srtnotificatie_code, 1, 4)) = 'CUST' ");
|
|
this.REST_POST = generic_REST_POST(this); // ... ook toevoegen...
|
|
this.REST_DELETE = generic_REST_DELETE(this); // en verwijderen.
|
|
}
|
|
|
|
this.REST_GET = generic_REST_GET(this, get_param);
|
|
this.REST_PUT = generic_REST_PUT(this);
|
|
|
|
|
|
this.hook_pre_edit = function(obj, fld)
|
|
{
|
|
// Voorlopig mag alleen voor meldingen en opdrachten het vinkje 'E-mail sturen naar gebouw'
|
|
// gezet worden
|
|
if (iscust == 1 || !inArray(obj.name.substring(0,3), ["MLD", "ORD"]))
|
|
fld.mailbuilding.readonly = true;
|
|
|
|
if (inArray(obj.name, ["MLDAFM", "MLDAFR", "MLDUPD"]))
|
|
{
|
|
fld.attachment.foreign.tbl = xxx_srtkenmerk_sql();
|
|
}
|
|
else
|
|
{
|
|
delete fld.attachment;
|
|
}
|
|
|
|
if (iscust == 1 && obj.id != -1)
|
|
obj.name = obj.name.substring(4,7); // De "CUST" ervoor weg halen.
|
|
}
|
|
|
|
this.hook_pre_put = function(params, obj, key)
|
|
{
|
|
if (iscust == 1)
|
|
obj.name = "CUST" + obj.name.toUpperCase(); // De "CUST" er weer voor zetten.
|
|
}
|
|
|
|
this.hook_pre_post = function(params, obj)
|
|
{
|
|
// Wordt alleen gebruikt bij toevoegen, dus met url-param &cust=1.
|
|
obj.name = "CUST" + obj.name.toUpperCase(); // Dus altijd hoofdletters, en beginnen met "CUST".
|
|
}
|
|
|
|
function fnshowusermode(oRs)
|
|
{
|
|
return (oRs.Fields("usermode").Value == 1 ? L("lcl_Yes") : "");
|
|
}
|
|
|
|
function fnshowmailbuilding(oRs)
|
|
{
|
|
return (oRs.Fields("mail_building").Value == 1 ? L("lcl_Yes") : "");
|
|
}
|
|
}
|
|
%> |