diff --git a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/CustomSearchController.java b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/CustomSearchController.java index c55f868..3e0b31a 100644 --- a/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/CustomSearchController.java +++ b/office-alexander-logistics-app/src/main/java/com/alexanderlogistics/CustomSearchController.java @@ -24,15 +24,22 @@ package com.alexanderlogistics; import java.io.Serializable; +import java.io.UnsupportedEncodingException; +import java.net.URLEncoder; import java.text.DecimalFormat; import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; +import java.util.logging.Logger; import javax.enterprise.context.ConversationScoped; import javax.enterprise.event.Observes; +import javax.inject.Inject; import javax.inject.Named; +import org.imixs.marty.team.TeamController; +import org.imixs.workflow.ItemCollection; +import org.imixs.workflow.office.views.SearchController; import org.imixs.workflow.office.views.SearchEvent; /** @@ -49,20 +56,19 @@ public class CustomSearchController implements Serializable { private static final long serialVersionUID = 1L; + private static Logger logger = Logger.getLogger(CustomSearchController.class.getName()); + + @Inject + SearchController searchController; + + @Inject + TeamController teamController; + /** - * Erweitere Query - * - * _amount_brutto_from, _amount_brutto_to + * Diese Suche schränkt immer auf Archive und Rechnugnscontrolling ein!! * * @param searchEvent - * - **/ - - /* - * Aktuell ist es nicht möglich nach Long oder Double zu suchen. Hierzu muss die - * LuceneUpdate Funktion in Imixs-Workflow verändert werden */ - public void onSearchEvent(@Observes SearchEvent searchEvent) { String query = searchEvent.getQuery(); @@ -76,48 +82,58 @@ public class CustomSearchController implements Serializable { String invoiceNumber = searchEvent.getSearchFilter().getItemValueString("invoice.number"); + query += " (type:\"workitemarchive\") "; + // process ref= Rechnugnscontorling Prozess + ItemCollection process = teamController.getProcessByName("Rechnungscontrolling"); + if (process == null) { + process = teamController.getProcessByName("Invoice Controlling"); + } + if (process != null) { + query += " AND ($uniqueidref:\"" + process.getUniqueID() + "\") "; + } + // invoice.total if (invoiceTotal != 0) { // format form and to with at least one digit DecimalFormat decimalFormat = new DecimalFormat("#.00"); - query += " (invoice.total:" + decimalFormat.format(invoiceTotal) + ")"; + query += " AND (invoice.total:" + decimalFormat.format(invoiceTotal) + ")"; } // invoice.date if (invoiceDate != null) { - query += " (invoice.date:" + CustomSearchController.getRangeDay(invoiceDate) + ")"; + query += " AND (invoice.date:" + CustomSearchController.getRangeDay(invoiceDate) + ")"; } // invoice.duedate if (dueDate != null) { - query += " (invoice.duedate:" + CustomSearchController.getRangeDay(dueDate) + ")"; + query += " AND (invoice.duedate:" + CustomSearchController.getRangeDay(dueDate) + ")"; } // invoice.closingdate if (closingDate != null) { - query += " ($lasteventdate:" + CustomSearchController.getRangeMonth(closingDate) + ")"; + query += " AND ($lasteventdate:" + CustomSearchController.getRangeMonth(closingDate) + ")"; } if (invoiceNumber != null && !invoiceNumber.isEmpty()) { - query += " (invoice.number:" + invoiceNumber + ")"; + query += " AND (invoice.number:" + invoiceNumber + ")"; } // Rechnungsart if (invoiceType != null && !"0".equals(invoiceType)) { if ("1".equals(invoiceType)) { - query += " ($workflowgroup:\"Rechnungseingang\" AND NOT payment.type:credit)"; + query += " AND ($workflowgroup:\"Rechnungseingang\" AND NOT payment.type:credit)"; } if ("2".equals(invoiceType)) { - query += " ($workflowgroup:Sachrechnung)"; + query += " AND ($workflowgroup:Sachrechnung)"; } if ("3".equals(invoiceType)) { - query += " (($workflowgroup:Rechnungseingang) AND (payment.type:credit))"; + query += " AND (($workflowgroup:Rechnungseingang) AND (payment.type:credit))"; } if ("4".equals(invoiceType)) { - query += " ($workflowgroup:\"Gutschrift Abgleich\")"; + query += " AND ($workflowgroup:\"Gutschrift Abgleich\")"; } } @@ -125,26 +141,57 @@ public class CustomSearchController implements Serializable { if (cdtrNumber != null && !cdtrNumber.isEmpty()) { cdtrNumber = cdtrNumber.trim().toUpperCase(); if (!cdtrNumber.startsWith("K") && !cdtrNumber.startsWith("D")) { - query += " (cdtr.number:K" + cdtrNumber + " OR dbtr.number:" + cdtrNumber + ")"; + query += " AND (cdtr.number:K" + cdtrNumber + " OR dbtr.number:" + cdtrNumber + ")"; } else { if (cdtrNumber.startsWith("K")) { // suche nach Kreditor (Eingangsrechnung) - query += " (cdtr.number:" + cdtrNumber + ")"; + query += " AND (cdtr.number:" + cdtrNumber + ")"; } else { // suche nach Debitor (Ausgangsrechnung) if (cdtrNumber.startsWith("D")) { cdtrNumber = cdtrNumber.substring(1); } - query += " (dbtr.number:" + cdtrNumber + ")"; + query += " AND (dbtr.number:" + cdtrNumber + ")"; } } } + logger.info(query); // Udpate query searchEvent.setQuery(query); } + /** + * Sonder AGL Lösung um im Archiv zu bleiben. + * + */ + public String refreshAGLArchive() { + String phrase = searchController.getSearchFilter().getItemValueString("phrase"); + + searchController.getSearchFilter().setItemValue("Type", "workitemarchive"); + try { + phrase = URLEncoder.encode(phrase, "UTF-8"); + } catch (UnsupportedEncodingException e) { + logger.severe("unable to encode search phrase!"); + e.printStackTrace(); + } + String action = "/pages/workitems/agl_archive.xhtml?faces-redirect=true&phrase=" + phrase; + searchController.setPageIndex(0); + return action; + } + + /** + * This method reset the search filter and the search pageIndex and creates a + * new bookmarkable search link to the worklist including the current search + * phrase. + * + */ + public String resetSearch() { + searchController.reset(); + return refreshAGLArchive(); + } + private static String getRangeDay(Date dueDate) { // Setze die Uhrzeit auf Mitternacht (00:00) Calendar startCalendar = Calendar.getInstance(); diff --git a/office-alexander-logistics-app/src/main/webapp/pages/workitems/agl_archive.xhtml b/office-alexander-logistics-app/src/main/webapp/pages/workitems/agl_archive.xhtml new file mode 100644 index 0000000..255c99c --- /dev/null +++ b/office-alexander-logistics-app/src/main/webapp/pages/workitems/agl_archive.xhtml @@ -0,0 +1,149 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Rechnungscontrolling - Archiv + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #{message.total_result} #{searchresultCount} + #{message.serach_hits} + + + + + + + + + + + + #{message.empty_worklist} + + + + + + + + + #{message.search_error_title} + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/office-alexander-logistics-app/src/main/webapp/pages/workitems/worklist_search_custom.xhtml b/office-alexander-logistics-app/src/main/webapp/pages/workitems/agl_archive_filter.xhtml similarity index 100% rename from office-alexander-logistics-app/src/main/webapp/pages/workitems/worklist_search_custom.xhtml rename to office-alexander-logistics-app/src/main/webapp/pages/workitems/agl_archive_filter.xhtml diff --git a/office-alexander-logistics-app/src/main/webapp/pages/workitems/xxxxworklist_search_custom.xhtml b/office-alexander-logistics-app/src/main/webapp/pages/workitems/xxxxworklist_search_custom.xhtml new file mode 100644 index 0000000..2fb3918 --- /dev/null +++ b/office-alexander-logistics-app/src/main/webapp/pages/workitems/xxxxworklist_search_custom.xhtml @@ -0,0 +1,87 @@ + + + + + + + #{custom.invoiceamount}: + + + + + + + + + #{custom.invoicedate}: + + + + + + + + #{custom.invoiceduedate}: + + + + + + + + + + #{custom.closingdate}: + + + + + + + + + #{custom.creditor_number}: + + + + + + + + + #{custom.invoicenumber}: + + + + + + + + + + + + Rechnungsart: + + + + + + + + + + + + + + + + + + + \ No newline at end of file
+ +