office-alexander-logistics/office-alexander-logistics-app/src/main/deprecated/cargsoft-debitor-search.xhtml

84 lines
No EOL
3.3 KiB
HTML

<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:h="http://xmlns.jcp.org/jsf/html" xmlns:c="http://xmlns.jcp.org/jsp/jstl/core"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets" xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
xmlns:marty="http://xmlns.jcp.org/jsf/composite/marty" xmlns:i="http://xmlns.jcp.org/jsf/composite/imixs">
<!-- Cargosoft Search integration
This subform is loaded by the form_basic.xhtml page.
The subform provides a jsf commandScript which calls the cargosoftController.searchCreditor method in the backend.
The script below inits a autocompletion feature for the input field.
See imixs-office.autocompletion.js
See also:
https://stackoverflow.com/questions/16588327/how-to-invoke-a-jsf-managed-bean-on-a-html-dom-event-using-native-javascript
https://dzone.com/articles/execute-a-jsf-ajax-request-by-just-a-function-call
https://www.w3schools.com/howto/howto_js_autocomplete.asp
-->
<h:commandScript name="cargosoftDbtrSearch" action="#{cargosoftController.searchDebitor()}"
render="autocomplete-resultlist-cargosoft" onevent="autocompleteShowResult" />
<h:commandScript name="updateDbtrNumber" action="#{opListController.updateDbtrNumber()}"
render="#{opListContainer.clientId}" onevent="ajaxUpdateInvoiceSelection" />
<script type="text/javascript">
/*<![CDATA[*/
// init ml input fields...
$(document).ready(function () {
// add autocomplete feature to dbtr.number...
var creditorField = $("input[data-item='dbtr.number']");
$(creditorField).each(function () {
$(this).addClass("imixs-ml");
// set callback function...
autocompleteInitInput(this, cargosoftDbtrSearch, 'autocomplete-resultlist-cargosoft', selectDbtrCallback);
});
// add cargsoft label if available
var dbtrName = "#{workflowController.workitem.item['dbtr.name']}";
// append span with dbtr.name....
creditorField.after("<span id='dbtr-name-id' class='small'>" + dbtrName + "</p>");
});
// Hier bekommen wir die JSON Struktur mit allen daten.
// diese Daten werden auf die einzelnen Felder verteilt.
function selectDbtrCallback(selection) {
const dbtrData = JSON.parse(selection);
// fill data into the fields....
var inputElement = $("input[data-item='dbtr.number']");
inputElement.val(dbtrData.no);
// remove old dbtr.name
$('#dbtr-name-id').remove();
// append span with dbtr.name....
inputElement.after("<span id='dbtr-name-id' class='small'>" + dbtrData.name + "</p>");
var inputElementDbtrName = $("input[id$='dbtr_name']");
if (inputElementDbtrName) {
inputElementDbtrName.val(dbtrData.name);
}
// check if we have a mail...
if (dbtrData.mail) {
var inputElementMail = $("input[data-item='dbtr.mail'],textarea[data-item='dbtr.mail']");
if (inputElementMail) {
inputElementMail.val(dbtrData.mail);
}
}
// finally we do a trick and trigger the commandScript updateDbtrNumber which
// refreshes the op section
updateDbtrNumber({ dbtrNumber: dbtrData.no });
}
/*]]>*/
</script>
<!-- Hier speichern das von Kreditor vorgeschlagene zahlungsziel -->
<h:inputHidden id="dbtr_creditperiod" value="#{workflowController.workitem.item['dbtr.creditperiod']}" />
<h:inputHidden id="dbtr_name" value="#{workflowController.workitem.item['dbtr.name']}" />
</ui:composition>