Files
Facilitor/APPL/SCF/scaffolding_edit.inc
Jos Groot Lipman 4cba87ca58 FSN#32295 scf-schermen moeten eigen class-id's krijgen
svn path=/Website/trunk/; revision=24956
2015-04-22 12:32:30 +00:00

105 lines
3.3 KiB
PHP

<% /*
$Revision$
$Id$
File: scaffolding_edit.asp
Description: show detailed information of a usrrapx
Parameters: usrxxx_key (usrrapx id)
Context:
Note:
*/ %>
<%
function scaffolding_edit(model, scf_params)
{
FCLTHeader.Requires({ plugins: ["jQuery"],
js: ["jquery-ui.js", "jquery.timepicker-table.js"],
css: ["timePicker-table.css"]})
if (scf_params.edit && "requires" in scf_params.edit)
FCLTHeader.Requires(scf_params.edit.requires);
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 } );
}
jQuery(function()
{
$('textarea').resize(function () { FcltMgr.resized(window) });
$('textarea').autogrow();
});
</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("scf_info", xxx_data["name"] || model.record_title);
for (var fld in model.fields)
{
var field = model.fields[fld];
if (field.readonly || fld == "id")
scf_ROFIELDTR(model, fld, xxx_data[fld]);
else if (field.insertonly && key > 0)
scf_ROFIELDTR(model, fld, xxx_data[fld]);
else
scf_RWFIELDTR(model, fld, xxx_data[fld], key);
}
BLOCK_END();
if (modal)
CreateButtons(buttons);
IFACE.FORM_END();
%>
</form>
</div>
</body>
</html>
<%
}
%>