Files
Facilitor/APPL/SCF/scaffolding_m_edit.inc
Jos Groot Lipman 44304472b5 NYBU#30506 PDA rapportages via scaffolding
svn path=/Website/trunk/; revision=24399
2015-03-10 16:26:09 +00:00

97 lines
3.0 KiB
PHP

<% /*
$Revision$
$Id$
File: scaffolding_m_edit.asp
Description: show detailed information of a model
Parameters:
Context:
Note:
*/ %>
<%
function scaffolding_m_edit(model, scf_params)
{
FCLTHeader.Requires({ plugins: ["jQuery"],
js: ["jquery-ui.js", "jquery.timepicker-table.js"],
css: ["timePicker-table.css"]})
var transit = "";
if ("transit" in scf_params)
transit = "&" + scf_params.transit.name + "=" + safe.url(scf_params.transit.val);
var key = getQParamInt("id", -1);
if (key > 0)
{
user.auth_required_or_abort(model.REST_PUT);
var xxx_params = { filter: { id: key } };
var xxx_array = model.REST_GET(xxx_params);
if (!xxx_array.length)
shared.record_not_found();
var xxx_data = xxx_array[0];
}
else
{
user.auth_required_or_abort(model.REST_POST);
xxx_data = {};
}
if ("hook_pre_edit" in model)
model.hook_pre_edit(xxx_data);
var modal = (model.parent_key != null); // dan doen we een detailrecord altijd modal
%>
<html>
<head>
<% FCLTHeader.Generate(); %>
<script>
function scf_submit()
{
if (!validateForm("u2"))
return false;
$.post($("form[name=u2]")[0].getAttribute("action"), $("[name=u2]").serialize(), FcltCallbackClose, "json");
return true; // disable button
}
function scf_cancel()
{
FcltMgr.closeDetail(window, { cancel: true } );
}
</script>
</head>
<body id="<%=modal?"mod_scaffolding":"editbody"%>" <%=modal?"class='modal scaffolding'":""%>>
<%
var buttons = [ {title: L("lcl_submit"), action:"scf_submit()", icon: "opslaan.png", singlepress: true },
{title: L("lcl_cancel"), action:"scf_cancel()", icon: "undo.png" }];
if (!modal)
IFRAMER_HEADER(model.record_title, buttons);
%>
<div id="edit">
<form name="u2" method="post" action="<%=scf_params.this_fullpath%>?mode=save&id=<%=key%><%=transit%>" onsubmit="return false;">
<%
BLOCK_START("facInfo", xxx_data["name"] || model.record_title);
for (var fld in model.fields)
{
var field = model.fields[fld];
if (field.readonly || fld == "id")
scf_ROFIELDTR(field, fld, xxx_data[fld]);
else if (field.insertonly && key > 0)
scf_ROFIELDTR(field, fld, xxx_data[fld]);
else
scf_RWFIELDTR(field, fld, xxx_data[fld]);
}
BLOCK_END();
if (modal)
CreateButtons(buttons);
IFACE.FORM_END();
%>
</form>
</div>
</body>
</html>
<%
}
%>