Files
Facilitor/APPL/API2/model_custom_fields.inc
Jos Groot Lipman d562b8e229 FSN#33339 API2 ook bijlagen ondersteunen
svn path=/Website/trunk/; revision=25676
2015-07-22 10:07:59 +00:00

86 lines
2.8 KiB
PHP

<% /*
$Revision$
$Id$
File: model_custom_fields.inc
Description: Flexkenmerken model
Parameters:
Context:
Notes:
*/
%>
<!-- #include file="../Shared/kenmerk_common.inc" -->
<!-- #include file="../Shared/resultset_flex.inc"-->
<!-- #include file="../Shared/flexfiles.inc"-->
<%
function model_custom_fields(flexModule, flexId, flexParams)
{
flexParams = flexParams || {};
this.module = flexModule;
this.table = "flex";
this.primary = "flexparentkey";
this.records_name = "custom_fields";
this.record_name = "custom_field";
// this.records_title = L("lcl_orders");
// this.record_title = L("lcl_opdr_info");
var theSqlFlex = getSqlFlex(flexModule, flexId, flexParams);
this.tablesql = "(" + theSqlFlex + ") flex"
this.fields =
{ "id": { dbs: "kenmerk_key", typ: "key" },
"pid": { dbs: "flexparentkey", typ: "key" },
"value": { dbs: "waarde", typ: "varchar" },
"type": { dbs: "kenmerktype", typ: "varchar" },
"sequence": { dbs: "volgnummer", typ: "number" },
"label": { dbs: "omschrijving", typ: "varchar" }
};
// Deze functie wordt na de GET aangeroepen. De bijlagen zijn zo afwijkend
// dat ik dat niet fatsoenlijk in 'fields' verwerkt kreeg
this.post_get = function (record)
{
if (record.type == 'F' || record.type == 'M')
{
var flexparam = flexProps(flexModule, record.pid, String(record.id), flexParams.pNiveau, { getFiles: true });
record.attachments = [];
for (var f in flexparam.files)
{
var file = flexparam.files[f];
record.attachments.push({ name: file.name,
date: file.date,
size: file.size,
temp_url: file.api2url,
digest: file.digest })
};
}
}
}
function set_custom_field(jsondata, kenmerk_key, val)
{
for (var i=0; i< jsondata.custom_fields.length; i++)
{
if (jsondata.custom_fields[i].id == kenmerk_key)
{
jsondata.custom_fields[i].value = val;
return; // direct klaar
}
}
}
function get_custom_field(jsondata, kenmerk_key)
{
for (var i=0; i< jsondata.custom_fields.length; i++)
{
if (jsondata.custom_fields[i].id == kenmerk_key)
{
return jsondata.custom_fields[i].value; // direct klaar
}
}
return null;
}
%>