76 lines
2.3 KiB
PHP
76 lines
2.3 KiB
PHP
<% /*
|
|
$Revision$
|
|
$Id$
|
|
|
|
File fac_reportx_import.asp
|
|
Description: Voor import van een rapport
|
|
Parameters:
|
|
Note:
|
|
*/ %>
|
|
<%
|
|
function scaffolding_import(model, scf_params)
|
|
{
|
|
var transit = scf_transit2url(scf_params);
|
|
%>
|
|
<html>
|
|
<head>
|
|
<% FCLTHeader.Generate() %>
|
|
<script>
|
|
// Als ik *zeker* wist dat API2 is ingericht zou ik POSTen naar /api2/reportsx.json
|
|
var url = "<%=scf_params.this_fullpath%>?mode=api2&format=json<%=transit%>";
|
|
|
|
function importCallback(json, textStatus)
|
|
{
|
|
if ("<%=model.record_name%>" in json)
|
|
{
|
|
var id = json["<%=model.record_name%>"].id;
|
|
FcltMgr.alert("Created {0} (key {1})".format("<%=model.record_title%>",id));
|
|
}
|
|
else
|
|
FcltMgr.alert("Strange, no '<%=model.record_name%>' in json?\n{0}".format(json.warning));
|
|
}
|
|
function scf_import()
|
|
{
|
|
var data = $("#importeer").val();
|
|
try {
|
|
var tester = JSON.parse($("#importeer").val());
|
|
} catch (e) {
|
|
FcltMgr.alert(e.description || e.message);
|
|
return;
|
|
}
|
|
|
|
$.ajax({
|
|
type: "POST",
|
|
url: url,
|
|
data: data,
|
|
contentType:"application/json; charset=utf-8",
|
|
success: importCallback,
|
|
dataType: "json",
|
|
"headers": { "X-CSRF-TOKEN" : RVT_token }
|
|
}).fail(function(xhr, status, error) {
|
|
// error handling
|
|
var data = JSON.parse(xhr.responseText);
|
|
FcltMgr.alert(data.error.message);
|
|
});
|
|
}
|
|
|
|
</script>
|
|
</head>
|
|
<body>
|
|
<%
|
|
var buttons = [];
|
|
buttons.push({title: L("lcl_scf_import"), action: "scf_import()", icon: "fa-upload"});
|
|
IFRAMER_HEADER(L("lcl_scf_import") + " " + model.record_title, buttons);
|
|
|
|
%>
|
|
<form method="post" action="../../api2/reportsx.json">
|
|
<% BLOCK_START("scf_import", model.record_title);
|
|
%>
|
|
<textarea id='importeer' style='width:800px;height:500px;'></textarea>
|
|
<% BLOCK_END();
|
|
%>
|
|
</form>
|
|
</body>
|
|
<%
|
|
}
|
|
%> |