187 lines
6.4 KiB
PHP
187 lines
6.4 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];
|
|
|
|
// Defaults vanuit url maken we readonly
|
|
// Vooral bij includes wordt hier ook de parent_key verwijzing gezet
|
|
var filter = shared.qs2json()
|
|
for (var fld in model.fields)
|
|
{
|
|
var field = model.fields[fld];
|
|
if (fld in filter)
|
|
model.fields[fld].readonly = true;
|
|
}
|
|
|
|
}
|
|
else
|
|
{
|
|
user.auth_required_or_abort(model.REST_POST);
|
|
xxx_data = {};
|
|
// Defaults vanuit url invullen
|
|
// Bij includes wordt hier ook de parent_key verwijzing gezet
|
|
var filter = scf_params.filter || shared.qs2json()
|
|
for (var fld in model.fields)
|
|
{
|
|
var field = model.fields[fld];
|
|
if (fld in filter)
|
|
{
|
|
xxx_data[fld] = filter[fld];
|
|
if (field.foreign)
|
|
{
|
|
xxx_data[fld] = { id: filter[fld], name: "<< TODO Foreign name >>" };
|
|
}
|
|
field.readonly = true;
|
|
}
|
|
else
|
|
xxx_data[fld] = field.defaultvalue;
|
|
}
|
|
}
|
|
if ("hook_pre_edit" in model)
|
|
model.hook_pre_edit(xxx_data, model.fields);
|
|
|
|
var modal = model.edit.modal; // 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 } );
|
|
}
|
|
window.lastinputid = null;
|
|
$(function () {
|
|
$("input,textarea").on("focus", function () {
|
|
window.lastinputid = this.id;
|
|
sethint();
|
|
});
|
|
});
|
|
|
|
window.hints = {};
|
|
function sethint()
|
|
{
|
|
if ($("#hinter").is(':visible'))
|
|
{
|
|
if (window.lastinputid)
|
|
{
|
|
if (window.lastinputid in window.hints)
|
|
$("#hinter div#hinttitle").text (window.hints[window.lastinputid]);
|
|
else
|
|
{
|
|
$.getJSON("../shared/load_hint.asp?model=<%=model.table%>&fld=" + escape(window.lastinputid),
|
|
function (data, textStatus)
|
|
{
|
|
if (data && data.hint)
|
|
{
|
|
window.hints[window.lastinputid] = data.hint;
|
|
}
|
|
else
|
|
window.hints[window.lastinputid] = "No info found";
|
|
$("#hinter div#hinttitle").text (window.hints[window.lastinputid]);
|
|
}
|
|
);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function scf_enablehint()
|
|
{
|
|
$("#hinter").dialog({ title: L("lcl_hint")});
|
|
sethint();
|
|
}
|
|
jQuery(function()
|
|
{
|
|
$('textarea').resize(function () { FcltMgr.resized(window) });
|
|
$('textarea').autogrow();
|
|
});
|
|
</script>
|
|
</head>
|
|
<body id="<%=modal?"mod_scaffolding":"editbody"%>" <%=modal?"class='modal scaffolding'":""%>>
|
|
<div id="hinter" style='display:none'>Hint!
|
|
<div id='hinttitle'></div>
|
|
</div>
|
|
<%
|
|
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 (model.hashints)
|
|
buttons.splice(0, 0, {title: L("lcl_hint"), action:"scf_enablehint()", icon: "lightbulb.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;">
|
|
<%
|
|
// Eerst de hidden velden.
|
|
for (var fld in model.fields)
|
|
{
|
|
var field = model.fields[fld];
|
|
if (field.hidden_fld)
|
|
scf_RWHIDDENTR(fld, xxx_data[fld]);
|
|
}
|
|
|
|
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 if (!field.hidden_fld)
|
|
scf_RWFIELDTR(model, fld, xxx_data[fld], key);
|
|
}
|
|
BLOCK_END();
|
|
if (modal)
|
|
CreateButtons(buttons);
|
|
IFACE.FORM_END();
|
|
%>
|
|
</form>
|
|
</div>
|
|
</body>
|
|
</html>
|
|
<%
|
|
}
|
|
%> |