Files
Facilitor/APPL/Shared/srtprodselector.inc
2023-02-02 15:53:48 +00:00

103 lines
4.5 KiB
C++

<% /*
$Revision$
$Id$
File: srtprodselector.inc
Description: Algemene interface functie om een productsoort suggestbox te maken
Deze moet je kunnen includen en aanroepen.
parameters fieldName: veldnaam van het srtprodKey veld. Dit veld wordt gesubmit.
objectName: naam van het suggest object dat wordt aangemaakt.
params: object met meegegeven parameters.
*/ %>
<%
FCLTHeader.Requires({ plugins: ["suggest", "jQuery"], js: [] });
function FCLTsrtprodselector(fieldName, objectName, params)
{
if (typeof params=="undefined") params = {};
if (!(params.srtprodKey && params.srtprodKey > 0) && params.readonly && params.suppressEmpty) return;
var lwhenEmpty = (params.whenEmpty != null ? params.whenEmpty : (params.readonly ? L("lcl_select_readonly") : L("lcl_select_srtprod")));
var lsrtprodName = "";
var lextraInit = "";
if (params.srtprodKey && params.srtprodKey > 0)
{
sql = "SELECT bes_srtprod_key"
+ " , " + lcl.xsqla("bes_srtprod_omschrijving", "bes_srtprod_key")
+ " FROM bes_srtprod"
+ " WHERE bes_srtprod_key = " + params.srtprodKey;
var oRs = Oracle.Execute(sql);
if (!oRs.eof)
lsrtprodName = oRs("bes_srtprod_omschrijving").value;
else
params.srtprodKey = -1; // toch invalid
oRs.Close(); // close the recordset
}
// Bouw de url voor de srtprod query op
var functieQueryUrl = rooturl + "/appl/shared/suggest/suggestBesProd.asp?1=1"
+ (params.filtercode? "&filtcode=" + params.filtercode : "");
if (params.label)
{
%>
<tr <%=params.trclass?"class='"+params.trclass+"'":""%>>
<td class="label">
<label for="<%=fieldName%>_show"><%=params.label%></label>
</td>
<td>
<% } %>
<nobr>
<input id="<%=fieldName%>_show" class="fld<%=!params.readonly&&params.required? " required" : ""%>" value="<%=safe.htmlattr(lsrtprodName)%>" placeholder="<%=safe.htmlattr(lwhenEmpty)%>"
<%=params.readonly? " readonly tabindex=-1" : ""%>
<%=params.onChange && !params.readonly? " sgonChange='" + params.onChange + "'" : ""%>>
<input type="hidden" id="<%=fieldName%>" name="<%=fieldName%>" value="<%=params.srtprodKey%>">
<%
if (params.extraParamField)
{ /* het extra parameter veld wordt door suggest object gevuld */
%>
<input type="hidden" id="<%=params.extraParamField%>" name="<%=params.extraParamField%>" value="<%=safe.htmlattr(lextraInit)%>">
<% } %>
</nobr>
<%
if (params.label)
{
%>
</td>
</tr>
<% } %>
<%
if (!params.readonly)
{
if (params.urlAdd)
{
var urlAddTxt = "[";
for (var i = 0; i < params.urlAdd.length; i++)
{
urlAddTxt += (i > 0? ", " : "") + "{ urlParam: \"" + params.urlAdd[i].urlParam + "\", field: \"" + params.urlAdd[i].field + "\" }";
}
urlAddTxt += "]"
}
%>
<script type="text/javascript">
$(function()
{
<%=objectName%> = new Suggest({ objectName: "<%=objectName%>",
queryField: $("#<%=fieldName%>_show")[0],
queryUrl: "<%=functieQueryUrl%>",
initKey: <%=params.srtprodKey? params.srtprodKey : -1%>,
icon: "fa-cube",
keyField: $("#<%=fieldName%>")[0]
<%=params.urlAdd? ", urlAdd: " + urlAddTxt : ""%>
<%=params.extraParamField? ", extraParamField: $(\"" + "#" + params.extraParamField + "\")[0]" : ""%>
<%=params.extraParamField? ", initExtraParam: \"" + safe.jsstring("" + lextraInit) + "\"": ""%>
<%=params.isBad? ", isBad: true": ""%>
<%=params.readonly? ", fieldReadonly: true": ""%>
});
});
</script>
<% }
}
%>