]> git.mxchange.org Git - jfinancials-war.git/commitdiff
Don't cherry-pick:
authorRoland Häder <roland@mxchange.org>
Sat, 31 Mar 2018 14:36:43 +0000 (16:36 +0200)
committerRoland Häder <roland@mxchange.org>
Sat, 31 Mar 2018 14:38:31 +0000 (16:38 +0200)
- added view-scoped backing bean for receipt lists which helps pagination +
  filter + sorting
- it is now the new receiptListController and no allReceipts() (method) but only
  allReceipts (bean property)
- addded missing i18n strings, removed no longer used

Signed-off-by: Roland Häder <roland@mxchange.org>
14 files changed:
src/java/org/mxchange/jfinancials/beans/financial/model/receipt/FinancialAdminReceiptWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/financial/model/receipt/FinancialsReceiptWebRequestBean.java
src/java/org/mxchange/jfinancials/beans/financial/model/receipt/FinancialsReceiptWebRequestController.java
src/java/org/mxchange/jfinancials/beans/financial/model/receipt/list/FinancialsReceiptListWebViewBean.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/financial/model/receipt/list/FinancialsReceiptListWebViewController.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/financial/model/receipt/user/FinancialsReceiptUserWebSessionBean.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/beans/financial/model/receipt/user/FinancialsReceiptUserWebSessionController.java [new file with mode: 0644]
src/java/org/mxchange/jfinancials/converter/financial/receipt/FinancialsReceiptConverter.java
src/java/org/mxchange/localization/project_de_DE.properties
src/java/org/mxchange/localization/project_en_US.properties
web/WEB-INF/templates/admin/financial/receipt_item/admin_form_financial_receipt_item.tpl
web/admin/financial/receipt/admin_receipt_list.xhtml
web/admin/financial/receipt_item/admin_receipt_item_list.xhtml
web/user/financials/login_financials_add_income.xhtml

index fa714108d22b7983d1425923a0b38cde3b4859e7..150cc03bae5dd68a808b19bb8198dd595d745fc5 100644 (file)
@@ -28,6 +28,7 @@ import javax.inject.Named;
 import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
 import org.mxchange.jcontactsbusiness.model.employee.Employable;
 import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.beans.financial.model.receipt.list.FinancialsReceiptListWebViewController;
 import org.mxchange.jfinancials.events.receipt.added.ObservableReceiptAddedEvent;
 import org.mxchange.jfinancials.events.receipt.added.ReceiptAddedEvent;
 import org.mxchange.jfinancials.exceptions.receipt.ReceiptAlreadyAddedException;
@@ -85,6 +86,12 @@ public class FinancialAdminReceiptWebRequestBean extends BaseFinancialsBean impl
         */
        private Date receiptIssued;
 
+       /**
+        * Receipt list controller
+        */
+       @Inject
+       private FinancialsReceiptListWebViewController receiptListController;
+
        /**
         * Receipt number (only numbers)
         */
@@ -152,7 +159,7 @@ public class FinancialAdminReceiptWebRequestBean extends BaseFinancialsBean impl
                final BillableReceipt receipt = this.createReceiptInstance();
 
                // Is the receipt already there?
-               if (this.receiptController.isReceiptAdded(receipt)) {
+               if (this.receiptListController.isReceiptAdded(receipt)) {
                        // Receipt has already been added
                        throw new FaceletException(MessageFormat.format("Receipt for receiptBranchOffice={0},receiptIssued={1},receiptNumber={2} has already been added.", this.getReceiptBranchOffice().getBranchId(), this.getReceiptIssued().toString(), this.getReceiptNumber())); //NOI18N
                }
index dd67e95fd09d6b113cbc7b5c920c6e15dcc186a0..f829942b675c4c909baf60440b725d6cd279a69f 100644 (file)
  */
 package org.mxchange.jfinancials.beans.financial.model.receipt;
 
-import fish.payara.cdi.jsr107.impl.NamedCache;
 import java.text.MessageFormat;
-import java.util.Comparator;
 import java.util.Date;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Objects;
-import javax.annotation.PostConstruct;
-import javax.cache.Cache;
 import javax.ejb.EJB;
 import javax.enterprise.context.RequestScoped;
 import javax.enterprise.event.Event;
-import javax.enterprise.event.Observes;
 import javax.enterprise.inject.Any;
 import javax.faces.view.facelets.FaceletException;
 import javax.inject.Inject;
@@ -37,16 +28,15 @@ import javax.inject.Named;
 import org.mxchange.jcontactsbusiness.model.branchoffice.BranchOffice;
 import org.mxchange.jcontactsbusiness.model.employee.Employable;
 import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.beans.financial.model.receipt.list.FinancialsReceiptListWebViewController;
 import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
 import org.mxchange.jfinancials.events.receipt.added.ObservableReceiptAddedEvent;
 import org.mxchange.jfinancials.events.receipt.added.ReceiptAddedEvent;
 import org.mxchange.jfinancials.exceptions.receipt.ReceiptAlreadyAddedException;
-import org.mxchange.jfinancials.exceptions.receipt.ReceiptNotFoundException;
 import org.mxchange.jfinancials.model.receipt.BillableReceipt;
 import org.mxchange.jfinancials.model.receipt.FinancialReceipt;
 import org.mxchange.jfinancials.model.receipt.FinancialReceiptSessionBeanRemote;
 import org.mxchange.jproduct.model.payment.PaymentType;
-import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
 
 /**
  * A general financial receipt bean (controller)
@@ -69,16 +59,6 @@ public class FinancialsReceiptWebRequestBean extends BaseFinancialsBean implemen
        @Any
        private Event<ObservableReceiptAddedEvent> addedReceiptEvent;
 
-       /**
-        * All receipts list
-        */
-       private final List<BillableReceipt> allReceipts;
-
-       /**
-        * Filtered receipts list
-        */
-       private List<BillableReceipt> filteredReceipts;
-
        /**
         * Bar-code number
         */
@@ -96,16 +76,15 @@ public class FinancialsReceiptWebRequestBean extends BaseFinancialsBean implemen
        private BranchOffice receiptBranchOffice;
 
        /**
-        * A list of all branch offices (globally)
+        * Date/time the receipt has been issued
         */
-       @Inject
-       @NamedCache (cacheName = "receiptCache")
-       private Cache<Long, BillableReceipt> receiptCache;
+       private Date receiptIssued;
 
        /**
-        * Date/time the receipt has been issued
+        * Receipt list controller
         */
-       private Date receiptIssued;
+       @Inject
+       private FinancialsReceiptListWebViewController receiptListController;
 
        /**
         * Receipt number (only numbers)
@@ -133,11 +112,6 @@ public class FinancialsReceiptWebRequestBean extends BaseFinancialsBean implemen
        @Inject
        private FinancialsUserLoginWebSessionController userLoginController;
 
-       /**
-        * User's receipts
-        */
-       private final List<BillableReceipt> userReceipts;
-
        /**
         * Constructor
         */
@@ -145,10 +119,6 @@ public class FinancialsReceiptWebRequestBean extends BaseFinancialsBean implemen
        public FinancialsReceiptWebRequestBean () {
                // Call super constructor
                super();
-
-               // Init lists
-               this.allReceipts = new LinkedList<>();
-               this.userReceipts = new LinkedList<>();
        }
 
        /**
@@ -183,7 +153,7 @@ public class FinancialsReceiptWebRequestBean extends BaseFinancialsBean implemen
                final BillableReceipt receipt = this.createReceiptInstance();
 
                // Is the receipt already there?
-               if (this.isReceiptAdded(receipt)) {
+               if (this.receiptListController.isReceiptAdded(receipt)) {
                        // Receipt has already been added
                        throw new FaceletException(MessageFormat.format("Receipt for receiptBranchOffice={0},receiptIssued={1},receiptNumber={2} has already been added.", this.getReceiptBranchOffice().getBranchId(), this.getReceiptIssued().toString(), this.getReceiptNumber())); //NOI18N
                }
@@ -210,120 +180,6 @@ public class FinancialsReceiptWebRequestBean extends BaseFinancialsBean implemen
                return "admin_list_receipts?faces-redirect=true"; //NOI18N
        }
 
-       /**
-        * Observes events being fired when a new receipt has been added
-        * <p>
-        * @param event Event being fired
-        */
-       public void afterAddedReceiptEvent (@Observes final ObservableReceiptAddedEvent event) {
-               // Validate parameter
-               if (null == event) {
-                       // Throw NPE
-                       throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getReceipt() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("event.receipt is null"); //NOI18N
-               } else if (event.getReceipt().getReceiptId() == null) {
-                       // Throw it again
-                       throw new NullPointerException("event.receipt.receiptId is null"); //NOI18N
-               } else if (event.getReceipt().getReceiptId() < 1) {
-                       // Throw IAE
-                       throw new IllegalArgumentException(MessageFormat.format("event.receipt.receiptId={0} is invalid", event.getReceipt().getReceiptId())); //NOI18N
-               }
-
-               // Add to cache and general list
-               this.receiptCache.put(event.getReceipt().getReceiptId(), event.getReceipt());
-               this.allReceipts.add(event.getReceipt());
-
-               // Is same user?
-               if (this.userLoginController.isUserLoggedIn() && Objects.equals(event.getReceipt().getReceiptUser(), this.userLoginController.getLoggedInUser())) {
-                       // Same user, then add it
-                       this.userReceipts.add(event.getReceipt());
-               }
-       }
-
-       /**
-        * Event observer for logged-in user
-        * <p>
-        * @param event Event instance
-        */
-       public void afterUserLoginEvent (@Observes final ObservableUserLoggedInEvent event) {
-               // event should not be null
-               if (null == event) {
-                       // Throw NPE
-                       throw new NullPointerException("event is null"); //NOI18N
-               } else if (event.getLoggedInUser() == null) {
-                       // Throw NPE again
-                       throw new NullPointerException("event.loggedInUser is null"); //NOI18N
-               } else if (event.getLoggedInUser().getUserId() == null) {
-                       // userId is null
-                       throw new NullPointerException("event.loggedInUser.userId is null"); //NOI18N
-               } else if (event.getLoggedInUser().getUserId() < 1) {
-                       // Not avalid id
-                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
-               }
-
-               // Fill cache with all found user's receipts
-               for (final BillableReceipt receipt : this.allReceipts) {
-                       // Is same user?
-                       if (Objects.equals(receipt.getReceiptUser(), event.getLoggedInUser())) {
-                               // Yes, then add it
-                               this.userReceipts.add(receipt);
-                       }
-               }
-       }
-
-       /**
-        * Returns all receipts
-        * <p>
-        * @return All receipts
-        */
-       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
-       public List<BillableReceipt> allReceipts () {
-               return this.allReceipts;
-       }
-
-       @Override
-       public BillableReceipt findReceiptById (final Long receiptId) throws ReceiptNotFoundException {
-               // Validate parameter
-               if (null == receiptId) {
-                       // Throw NPE
-                       throw new NullPointerException("receiptId is null"); //NOI18N
-               } else if (receiptId < 1) {
-                       // Throw IAE
-                       throw new IllegalArgumentException("receiptId=" + receiptId + " is invalid."); //NOI18N
-               } else if (!this.receiptCache.containsKey(receiptId)) {
-                       // Not found
-                       throw new ReceiptNotFoundException(receiptId);
-               }
-
-               // Get it from cache
-               final BillableReceipt receipt = this.receiptCache.get(receiptId);
-
-               // Return it
-               return receipt;
-       }
-
-       /**
-        * Getter for filtered receipts
-        * <p>
-        * @return Filtered receipts
-        */
-       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
-       public List<BillableReceipt> getFilteredReceipts () {
-               return this.filteredReceipts;
-       }
-
-       /**
-        * Setter for filtered receipts
-        * <p>
-        * @param filteredReceipts Filtered receipts
-        */
-       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
-       public void setFilteredReceipts (final List<BillableReceipt> filteredReceipts) {
-               this.filteredReceipts = filteredReceipts;
-       }
-
        /**
         * Getter for receipt's bar-code number
         * <p>
@@ -452,51 +308,6 @@ public class FinancialsReceiptWebRequestBean extends BaseFinancialsBean implemen
                this.receiptSellerEmployee = receiptSellerEmployee;
        }
 
-       @PostConstruct
-       public void initCache () {
-               // Is cache there?
-               if (!this.receiptCache.iterator().hasNext()) {
-                       // Get whole list
-                       final List<BillableReceipt> receipts = this.receiptBean.allReceipts();
-
-                       // Add all
-                       for (final BillableReceipt receipt : receipts) {
-                               // Add it to cache
-                               this.receiptCache.put(receipt.getReceiptId(), receipt);
-                       }
-               }
-
-               // Is the list empty, but filled cache?
-               if (this.allReceipts.isEmpty() && this.receiptCache.iterator().hasNext()) {
-                       // Get iterator
-                       final Iterator<Cache.Entry<Long, BillableReceipt>> iterator = this.receiptCache.iterator();
-
-                       // Build up list
-                       while (iterator.hasNext()) {
-                               // GEt next element
-                               final Cache.Entry<Long, BillableReceipt> next = iterator.next();
-
-                               // Add to list
-                               this.allReceipts.add(next.getValue());
-                       }
-
-                       // Sort list
-                       this.allReceipts.sort(new Comparator<BillableReceipt>() {
-                               @Override
-                               public int compare (final BillableReceipt o1, final BillableReceipt o2) {
-                                       return o1.getReceiptId() > o2.getReceiptId() ? 1 : o1.getReceiptId() < o2.getReceiptId() ? -1 : 0;
-                               }
-                       }
-                       );
-               }
-       }
-
-       @Override
-       public boolean isReceiptAdded (final BillableReceipt receipt) {
-               // Always trust the cache
-               return this.allReceipts.contains(receipt);
-       }
-
        /**
         * Clears this bean
         */
index 23a7205181c38294a6a3cebfaca94968cf24882c..9192bb1dd3d7961d68f0cf3dfda1ca88a14e040c 100644 (file)
@@ -17,8 +17,6 @@
 package org.mxchange.jfinancials.beans.financial.model.receipt;
 
 import java.io.Serializable;
-import org.mxchange.jfinancials.exceptions.receipt.ReceiptNotFoundException;
-import org.mxchange.jfinancials.model.receipt.BillableReceipt;
 
 /**
  * An administrative interface for financial receipt beans
@@ -27,26 +25,4 @@ import org.mxchange.jfinancials.model.receipt.BillableReceipt;
  */
 public interface FinancialsReceiptWebRequestController extends Serializable {
 
-       /**
-        * Returns a receipt instance (entity) for given primary key. If not found,
-        * a proper exception is thrown.
-        * <p>
-        * @param receiptId Receipt id (primary key)
-        * <p>
-        * @return Receipt entity matching to primary key
-        * <p>
-        * @throws ReceiptNotFoundException If a receipt with given primary key
-        * could not be found
-        */
-       BillableReceipt findReceiptById (final Long receiptId) throws ReceiptNotFoundException;
-
-       /**
-        * Checks if receipt has already been added to database
-        * <p>
-        * @param receipt Prepared receipt instance
-        * <p>
-        * @return Whether the receipt has already been added
-        */
-       boolean isReceiptAdded (final BillableReceipt receipt);
-
 }
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/model/receipt/list/FinancialsReceiptListWebViewBean.java b/src/java/org/mxchange/jfinancials/beans/financial/model/receipt/list/FinancialsReceiptListWebViewBean.java
new file mode 100644 (file)
index 0000000..65a4127
--- /dev/null
@@ -0,0 +1,227 @@
+/*
+ * Copyright (C) 2017, 2018 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.financial.model.receipt.list;
+
+import fish.payara.cdi.jsr107.impl.NamedCache;
+import java.text.MessageFormat;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+import javax.annotation.PostConstruct;
+import javax.cache.Cache;
+import javax.ejb.EJB;
+import javax.enterprise.event.Observes;
+import javax.faces.view.ViewScoped;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.events.receipt.added.ObservableReceiptAddedEvent;
+import org.mxchange.jfinancials.exceptions.receipt.ReceiptNotFoundException;
+import org.mxchange.jfinancials.model.receipt.BillableReceipt;
+import org.mxchange.jfinancials.model.receipt.FinancialReceiptSessionBeanRemote;
+
+/**
+ * A view-scoped bean for receipt lists
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("receiptListController")
+@ViewScoped
+public class FinancialsReceiptListWebViewBean extends BaseFinancialsBean implements FinancialsReceiptListWebViewController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 34_869_872_672_653L;
+
+       /**
+        * All receipts list
+        */
+       private final List<BillableReceipt> allReceipts;
+
+       /**
+        * Filtered receipts list
+        */
+       private List<BillableReceipt> filteredReceipts;
+
+       /**
+        * EJB for general financial receipt purposes
+        */
+       @EJB (lookup = "java:global/jfinancials-ejb/financialReceipt!org.mxchange.jfinancials.model.receipt.FinancialReceiptSessionBeanRemote")
+       private FinancialReceiptSessionBeanRemote receiptBean;
+
+       /**
+        * A list of all branch offices (globally)
+        */
+       @Inject
+       @NamedCache (cacheName = "receiptCache")
+       private transient Cache<Long, BillableReceipt> receiptCache;
+
+       /**
+        * Selected receipt
+        */
+       private BillableReceipt selectedReceipt;
+
+       /**
+        * Default constructor
+        */
+       public FinancialsReceiptListWebViewBean () {
+               // Call super constructor
+               super();
+
+               // Init lists
+               this.allReceipts = new LinkedList<>();
+       }
+
+       /**
+        * Observes events being fired when a new receipt has been added
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterAddedReceiptEvent (@Observes final ObservableReceiptAddedEvent event) {
+               // Validate parameter
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getReceipt() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.receipt is null"); //NOI18N
+               } else if (event.getReceipt().getReceiptId() == null) {
+                       // Throw it again
+                       throw new NullPointerException("event.receipt.receiptId is null"); //NOI18N
+               } else if (event.getReceipt().getReceiptId() < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("event.receipt.receiptId={0} is invalid", event.getReceipt().getReceiptId())); //NOI18N
+               }
+
+               // Add to cache and general list
+               this.receiptCache.put(event.getReceipt().getReceiptId(), event.getReceipt());
+               this.getAllReceipts().add(event.getReceipt());
+       }
+
+       @Override
+       public BillableReceipt findReceiptById (final Long receiptId) throws ReceiptNotFoundException {
+               // Validate parameter
+               if (null == receiptId) {
+                       // Throw NPE
+                       throw new NullPointerException("receiptId is null"); //NOI18N
+               } else if (receiptId < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException("receiptId=" + receiptId + " is invalid."); //NOI18N
+               } else if (!this.receiptCache.containsKey(receiptId)) {
+                       // Not found
+                       throw new ReceiptNotFoundException(receiptId);
+               }
+
+               // Get it from cache
+               final BillableReceipt receipt = this.receiptCache.get(receiptId);
+
+               // Return it
+               return receipt;
+       }
+
+       @Override
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<BillableReceipt> getAllReceipts () {
+               return this.allReceipts;
+       }
+
+       /**
+        * Getter for filtered receipts
+        * <p>
+        * @return Filtered receipts
+        */
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<BillableReceipt> getFilteredReceipts () {
+               return this.filteredReceipts;
+       }
+
+       /**
+        * Setter for filtered receipts
+        * <p>
+        * @param filteredReceipts Filtered receipts
+        */
+       @SuppressWarnings ("AssignmentToCollectionOrArrayFieldFromParameter")
+       public void setFilteredReceipts (final List<BillableReceipt> filteredReceipts) {
+               this.filteredReceipts = filteredReceipts;
+       }
+
+       /**
+        * Getter for selected receipt
+        * <P>
+        * @return Selected receipt
+        */
+       public BillableReceipt getSelectedReceipt () {
+               return this.selectedReceipt;
+       }
+
+       /**
+        * Setter for selected receipt
+        * <P>
+        * @param selectedReceipt Selected receipt
+        */
+       public void setSelectedReceipt (final BillableReceipt selectedReceipt) {
+               this.selectedReceipt = selectedReceipt;
+       }
+
+       @PostConstruct
+       public void initCache () {
+               // Is cache there?
+               if (!this.receiptCache.iterator().hasNext()) {
+                       // Get whole list
+                       final List<BillableReceipt> receipts = this.receiptBean.allReceipts();
+
+                       // Add all
+                       for (final BillableReceipt receipt : receipts) {
+                               // Add it to cache
+                               this.receiptCache.put(receipt.getReceiptId(), receipt);
+                       }
+               }
+
+               // Is the list empty, but filled cache?
+               if (this.getAllReceipts().isEmpty() && this.receiptCache.iterator().hasNext()) {
+                       // Get iterator
+                       final Iterator<Cache.Entry<Long, BillableReceipt>> iterator = this.receiptCache.iterator();
+
+                       // Build up list
+                       while (iterator.hasNext()) {
+                               // GEt next element
+                               final Cache.Entry<Long, BillableReceipt> next = iterator.next();
+
+                               // Add to list
+                               this.getAllReceipts().add(next.getValue());
+                       }
+
+                       // Sort list
+                       this.getAllReceipts().sort(new Comparator<BillableReceipt>() {
+                               @Override
+                               public int compare (final BillableReceipt o1, final BillableReceipt o2) {
+                                       return o1.getReceiptId() > o2.getReceiptId() ? 1 : o1.getReceiptId() < o2.getReceiptId() ? -1 : 0;
+                               }
+                       }
+                       );
+               }
+       }
+
+       @Override
+       public boolean isReceiptAdded (final BillableReceipt receipt) {
+               // Always trust the cache
+               return this.getAllReceipts().contains(receipt);
+       }
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/model/receipt/list/FinancialsReceiptListWebViewController.java b/src/java/org/mxchange/jfinancials/beans/financial/model/receipt/list/FinancialsReceiptListWebViewController.java
new file mode 100644 (file)
index 0000000..aed38e9
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2018 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.financial.model.receipt.list;
+
+import java.io.Serializable;
+import java.util.List;
+import org.mxchange.jfinancials.exceptions.receipt.ReceiptNotFoundException;
+import org.mxchange.jfinancials.model.receipt.BillableReceipt;
+
+/**
+ * An interface of receipt list backing beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsReceiptListWebViewController extends Serializable {
+
+       /**
+        * Returns a receipt instance (entity) for given primary key. If not found,
+        * a proper exception is thrown.
+        * <p>
+        * @param receiptId Receipt id (primary key)
+        * <p>
+        * @return Receipt entity matching to primary key
+        * <p>
+        * @throws ReceiptNotFoundException If a receipt with given primary key
+        * could not be found
+        */
+       BillableReceipt findReceiptById (final Long receiptId) throws ReceiptNotFoundException;
+
+       /**
+        * Checks if receipt has already been added to database
+        * <p>
+        * @param receipt Prepared receipt instance
+        * <p>
+        * @return Whether the receipt has already been added
+        */
+       boolean isReceiptAdded (final BillableReceipt receipt);
+
+       /**
+        * Returns all receipts
+        * <p>
+        * @return All receipts
+        */
+       public List<BillableReceipt> getAllReceipts ();
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/model/receipt/user/FinancialsReceiptUserWebSessionBean.java b/src/java/org/mxchange/jfinancials/beans/financial/model/receipt/user/FinancialsReceiptUserWebSessionBean.java
new file mode 100644 (file)
index 0000000..a0a00b1
--- /dev/null
@@ -0,0 +1,145 @@
+/*
+ * Copyright (C) 2017, 2018 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.financial.model.receipt.user;
+
+import java.text.MessageFormat;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Objects;
+import javax.enterprise.context.SessionScoped;
+import javax.enterprise.event.Observes;
+import javax.inject.Inject;
+import javax.inject.Named;
+import org.mxchange.jfinancials.beans.BaseFinancialsBean;
+import org.mxchange.jfinancials.beans.financial.model.receipt.list.FinancialsReceiptListWebViewController;
+import org.mxchange.jfinancials.beans.user.login.FinancialsUserLoginWebSessionController;
+import org.mxchange.jfinancials.events.receipt.added.ObservableReceiptAddedEvent;
+import org.mxchange.jfinancials.model.receipt.BillableReceipt;
+import org.mxchange.juserlogincore.events.login.ObservableUserLoggedInEvent;
+
+/**
+ * A view-scoped bean for receipt lists
+ * <p>
+ * @author Roland Haeder<roland@mxchange.org>
+ */
+@Named ("userReceiptController")
+@SessionScoped
+public class FinancialsReceiptUserWebSessionBean extends BaseFinancialsBean implements FinancialsReceiptUserWebSessionController {
+
+       /**
+        * Serial number
+        */
+       private static final long serialVersionUID = 34_869_872_672_654L;
+
+       /**
+        * Receipt list controller
+        */
+       @Inject
+       private FinancialsReceiptListWebViewController receiptListController;
+
+       /**
+        * User instance
+        */
+       @Inject
+       private FinancialsUserLoginWebSessionController userLoginController;
+
+       /**
+        * User's receipts
+        */
+       private final List<BillableReceipt> userReceipts;
+
+       /**
+        * Default constructor
+        */
+       public FinancialsReceiptUserWebSessionBean () {
+               // Call super constructor
+               super();
+
+               // Init lists
+               this.userReceipts = new LinkedList<>();
+       }
+
+       /**
+        * Observes events being fired when a new receipt has been added
+        * <p>
+        * @param event Event being fired
+        */
+       public void afterAddedReceiptEvent (@Observes final ObservableReceiptAddedEvent event) {
+               // Validate parameter
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getReceipt() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.receipt is null"); //NOI18N
+               } else if (event.getReceipt().getReceiptId() == null) {
+                       // Throw it again
+                       throw new NullPointerException("event.receipt.receiptId is null"); //NOI18N
+               } else if (event.getReceipt().getReceiptId() < 1) {
+                       // Throw IAE
+                       throw new IllegalArgumentException(MessageFormat.format("event.receipt.receiptId={0} is invalid", event.getReceipt().getReceiptId())); //NOI18N
+               }
+
+               // Is same user?
+               if (this.userLoginController.isUserLoggedIn() && Objects.equals(event.getReceipt().getReceiptUser(), this.userLoginController.getLoggedInUser())) {
+                       // Same user, then add it
+                       this.getUserReceipts().add(event.getReceipt());
+               }
+       }
+
+       /**
+        * Event observer for logged-in user
+        * <p>
+        * @param event Event instance
+        */
+       public void afterUserLoginEvent (@Observes final ObservableUserLoggedInEvent event) {
+               // event should not be null
+               if (null == event) {
+                       // Throw NPE
+                       throw new NullPointerException("event is null"); //NOI18N
+               } else if (event.getLoggedInUser() == null) {
+                       // Throw NPE again
+                       throw new NullPointerException("event.loggedInUser is null"); //NOI18N
+               } else if (event.getLoggedInUser().getUserId() == null) {
+                       // userId is null
+                       throw new NullPointerException("event.loggedInUser.userId is null"); //NOI18N
+               } else if (event.getLoggedInUser().getUserId() < 1) {
+                       // Not avalid id
+                       throw new IllegalArgumentException(MessageFormat.format("userId of user={0} is not valid: {1}", event.getLoggedInUser(), event.getLoggedInUser().getUserId())); //NOI18N
+               }
+
+               // Fill cache with all found user's receipts
+               for (final BillableReceipt receipt : this.receiptListController.getAllReceipts()) {
+                       // Is same user?
+                       if (Objects.equals(receipt.getReceiptUser(), event.getLoggedInUser())) {
+                               // Yes, then add it
+                               this.getUserReceipts().add(receipt);
+                       }
+               }
+       }
+
+       /**
+        * Getter for user's receipts
+        * <p>
+        * @return User's receipts
+        */
+       @SuppressWarnings ("ReturnOfCollectionOrArrayField")
+       public List<BillableReceipt> getUserReceipts () {
+               return this.userReceipts;
+       }
+
+}
diff --git a/src/java/org/mxchange/jfinancials/beans/financial/model/receipt/user/FinancialsReceiptUserWebSessionController.java b/src/java/org/mxchange/jfinancials/beans/financial/model/receipt/user/FinancialsReceiptUserWebSessionController.java
new file mode 100644 (file)
index 0000000..6c01e06
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2018 Free Software Foundation
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+package org.mxchange.jfinancials.beans.financial.model.receipt.user;
+
+import java.io.Serializable;
+
+/**
+ * An interface of user's receipt backing beans
+ * <p>
+ * @author Roland Häder<roland@mxchange.org>
+ */
+public interface FinancialsReceiptUserWebSessionController extends Serializable {
+
+}
index 08a3c41d9546c8f9e334e5bbc40206fe25626723..8a144c4062ec45cf4126d4ef2019c624dcf97267 100644 (file)
@@ -22,8 +22,8 @@ import javax.faces.context.FacesContext;
 import javax.faces.convert.Converter;
 import javax.faces.convert.ConverterException;
 import javax.faces.convert.FacesConverter;
-import org.mxchange.jfinancials.beans.financial.model.receipt.FinancialsReceiptWebRequestBean;
-import org.mxchange.jfinancials.beans.financial.model.receipt.FinancialsReceiptWebRequestController;
+import org.mxchange.jfinancials.beans.financial.model.receipt.list.FinancialsReceiptListWebViewBean;
+import org.mxchange.jfinancials.beans.financial.model.receipt.list.FinancialsReceiptListWebViewController;
 import org.mxchange.jfinancials.exceptions.receipt.ReceiptNotFoundException;
 import org.mxchange.jfinancials.model.receipt.BillableReceipt;
 
@@ -38,14 +38,14 @@ public class FinancialsReceiptConverter implements Converter<BillableReceipt> {
        /**
         * Receipt backing bean
         */
-       private static FinancialsReceiptWebRequestController RECEIPT_CONTROLLER;
+       private static FinancialsReceiptListWebViewController RECEIPT_LIST_CONTROLLER;
 
        @Override
        public BillableReceipt getAsObject (final FacesContext context, final UIComponent component, final String submittedValue) {
                // Is the instance there?
-               if (null == RECEIPT_CONTROLLER) {
+               if (null == RECEIPT_LIST_CONTROLLER) {
                        // Get bean from CDI directly
-                       RECEIPT_CONTROLLER = CDI.current().select(FinancialsReceiptWebRequestBean.class).get();
+                       RECEIPT_LIST_CONTROLLER = CDI.current().select(FinancialsReceiptListWebViewBean.class).get();
                }
 
                // Is the value null or empty?
@@ -65,7 +65,7 @@ public class FinancialsReceiptConverter implements Converter<BillableReceipt> {
                        final Long receiptId = Long.valueOf(submittedValue);
 
                        // Try to get user instance from it
-                       receipt = RECEIPT_CONTROLLER.findReceiptById(receiptId);
+                       receipt = RECEIPT_LIST_CONTROLLER.findReceiptById(receiptId);
                } catch (final NumberFormatException ex) {
                        // Throw again
                        throw new ConverterException(ex);
index bdd8238259ddf27fb825f14a1f914545f3504ec5..c74c277b8abda6b2a57dde2e6718e8c3c1cbb25d 100644 (file)
@@ -51,7 +51,6 @@ ADMIN_RECEIPT_ISSUE_DATE_REQUIRED=Bitte geben Sie das Ausstellungsdatum des Kass
 ADMIN_MENU_RECEIPTS_TITLE=Kassenbons & Eintraege
 ADMIN_LINK_LIST_RECEIPTS_TITLE=Listet alle registrierten Kassenbons/Rechnungen auf..
 ADMIN_LINK_LIST_RECEIPTS=Kassenbons/Rechnungen auflisten
-ADMIN_LIST_RECEIPTS_HEADER=Alle Kassenbons/Rechnungen auflisten
 ADMIN_RECEIPT_BASIC_LEGEND=Grunddaten des Kassenbons
 ADMIN_RECEIPT_BASIC_LEGEND_TITLE=Bitte geben Sie hier die Grunddaten des neuen Kassenbons ein.
 ENTER_RECEIPT_ISSUE_DATE=Ausstellungsdatum des Kassenbons eingeben:
@@ -303,3 +302,26 @@ CATEGORY_SHOW_IN_STATISTICS_TITLE=Ob diese Kategorie in Statistiken vorkommt.
 CATEGORY_PARENT_HEADER=Elternkategorie:
 CATEGORY_PARENT_TITLE=Elternkategorie dieser Kategorie.
 CATEGORY_HAS_NO_PARENT=Diese Kategorie hat keine Elternkategorie.
+ADMIN_SINGLE_RECEIPT_DETAILS_HEADER=Details zum einzelnen Kassenbon
+ADMIN_RECEIPT_DETAILS_HEADER=Details zur Kassenbon-Id {0}:
+#@TODO Please fix German umlauts!
+ADMIN_LINK_SHOW_RECEIPT_SELLER_EMPLOYEE_TITLE=Zeigt zugewiesenen Verkaeufer des Kassenbons an.
+#@TODO Please fix German umlauts!
+ADMIN_LINK_ASSIGN_RECEIPT_SELLER_EMPLOYEE_TITLE=Verkaeufer dem Kassenbon zuweisen.
+ADMIN_LINK_ASSIGN_RECEIPT_OWNER_USER_TITLE=Besitzenden Benutzer dem Kassenbon zuweisen.
+RECEIPT_NUMBER_TITLE=Nummer des Kassenbons.
+RECEIPT_ISSUED_TITLE=Wann dieser Kassenbon ausgestellt wurde.
+ASSIGNED_RECEIPT_BRANCH_OFFICE_TITLE=Zugewiesene Filiale zum Kassenbons:
+SELLER_HEADER=Verkaeufer:
+#@TODO Please fix German umlauts!
+ASSIGNED_RECEIPT_SELLER_TITLE=Zugewiesener Verkaeufer zum Kassenbon:
+#@TODO Please fix German umlauts!
+NO_SELLER_ASSIGNED_TO_RECEIPT=Kein Verkaeufer dem Kassenbon zugewiesen.
+ASSIGNED_RECEIPT_USER_TITLE=Zugewiesener Benutzer zum Kassenbon.
+NO_USER_ASSIGNED_TO_RECEIPT=Kein Benutzer dem Kassenbon zugewiesen.
+RECEIPT_ID_NUMBER_TITLE=Id-Nummer des Kassenbonus.
+RECEIPT_BARCODE_HEADER=Streifencode:
+RECEIPT_BARCODE_TITLE=Streifencode des Kassenbons.
+RECEIPT_SEQUENCE_NUMBER_HEADER=Durchlaufende Nummer:
+RECEIPT_SEQUENCE_NUMBER_TITLE=Durchlaufende Nummer des Kassenbons.
+RECEIPT_PAYMENT_TYPE_TITLE=Bezahlungsart des Kassenbons.
index 9c7b9ae1bdf68ac0e737175fde54061e9022ffc6..964894def99b5b1b0708f916702a50b1332d9059 100644 (file)
@@ -38,7 +38,6 @@ ADMIN_RECEIPT_ISSUE_DATE_REQUIRED=Please enter date of issue of receipt.
 ADMIN_MENU_RECEIPTS_TITLE=Receipts & Items
 ADMIN_LINK_LIST_RECEIPTS_TITLE=Lists all registered receipts.
 ADMIN_LINK_LIST_RECEIPTS=Receipts
-ADMIN_LIST_RECEIPTS_HEADER=List all receipts
 ADMIN_RECEIPT_BASIC_LEGEND=Basic data of receipt:
 ADMIN_RECEIPT_BASIC_LEGEND_TITLE=Please enter here basic data of the new receipt.
 ENTER_RECEIPT_ISSUE_DATE=Enter date of issue of receipt:
@@ -221,3 +220,22 @@ CATEGORY_SHOW_IN_STATISTICS_TITLE=Whether this category is shown in statistics.
 CATEGORY_PARENT_HEADER=Parent category:
 CATEGORY_PARENT_TITLE=Parent category of this category.
 CATEGORY_HAS_NO_PARENT=This category has no parent category.
+ADMIN_SINGLE_RECEIPT_DETAILS_HEADER=Details of a single receipt
+ADMIN_RECEIPT_DETAILS_HEADER=Details of receipt id {0}:
+ADMIN_LINK_SHOW_RECEIPT_SELLER_EMPLOYEE_TITLE=Shows assigned seller employee of receipt.
+ADMIN_LINK_ASSIGN_RECEIPT_SELLER_EMPLOYEE_TITLE=Assign seller to receipt.
+ADMIN_LINK_ASSIGN_RECEIPT_OWNER_USER_TITLE=Assign owning user to receipt.
+RECEIPT_NUMBER_TITLE=Number of receipt.
+RECEIPT_ISSUED_TITLE=When this receipt has been issued.
+ASSIGNED_RECEIPT_BRANCH_OFFICE_TITLE=Assigned branch office of receipt:
+SELLER_HEADER=Seller:
+ASSIGNED_RECEIPT_SELLER_TITLE=Assigned seller of receipt:
+NO_SELLER_ASSIGNED_TO_RECEIPT=No seller assigned to receipt.
+ASSIGNED_RECEIPT_USER_TITLE=Assigned user of receipt.
+NO_USER_ASSIGNED_TO_RECEIPT=No user assigned to receipt.
+RECEIPT_ID_NUMBER_TITLE=Id number of receipt.
+RECEIPT_BARCODE_HEADER=Barcode:
+RECEIPT_BARCODE_TITLE=Barcode of receipt.
+RECEIPT_SEQUENCE_NUMBER_HEADER=Sequence number:
+RECEIPT_SEQUENCE_NUMBER_TITLE=Sequence number of receipt.
+RECEIPT_PAYMENT_TYPE_TITLE=Payment type of receipt.
index 718bf5d00f97eb547c591c01af575a1d7bbea716..598c637e7495b037fbd0b78a52016b0f7726bba0 100644 (file)
                                >
                                <f:converter converterId="ReceiptConverter" />
                                <f:selectItem itemValue="#{null}" itemLabel="#{msg.PLEASE_SELECT}" noSelectionOption="true" itemDisabled="true" />
-                               <f:selectItems value="#{receiptController.allReceipts()}" var="receipt" itemValue="#{receipt}" itemLabel="#{beanHelper.renderReceipt(receipt)}" />
+                               <f:selectItems value="#{receiptListController.allReceipts}" var="receipt" itemValue="#{receipt}" itemLabel="#{beanHelper.renderReceipt(receipt)}" />
                        </p:selectOneMenu>
 
                        <p:outputLabel value="#{project.ADMIN_ENTER_GENERIC_PRODUCT_PRICE}" />
index 19e65f7b9390413b9cac4b5dbd236505c2e14503..f3ba86d726838d3154e0f69f6744d161ca065c0f 100644 (file)
        </ui:define>
 
        <ui:define name="content">
-               <h:form id="form-list-financial-receipt">
+               <h:form id="form-list-financial-receipts">
                        <p:dataTable
                                id="receiptList"
                                var="receipt"
-                               value="#{receiptController.allReceipts()}"
-                               filteredValue="#{receiptController.filteredReceipts}"
+                               value="#{receiptListController.allReceipts}"
                                tableStyleClass="table table-full"
-                               rows="10"
                                paginator="true"
                                paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
+                               filteredValue="#{receiptListController.filteredReceipts}"
+                               rows="10"
+                               rowKey="#{receipt.receiptId}"
                                reflow="true"
                                resizableColumns="true"
                                rowsPerPageTemplate="5,10,20,50,100"
                                summary="#{project.TABLE_SUMMARY_ADMIN_LIST_RECEIPTS}"
                                emptyMessage="#{project.ADMIN_EMPTY_LIST_RECEIPT}"
                                widgetVar="receiptList"
+                               selectionMode="single"
+                               selection="#{receiptListController.selectedReceipt}"
+                               skipChildren="true"
                                >
+
                                <f:facet name="header">
-                                       <p:panelGrid columns="2" columnClasses="ui-grid-col-10,ui-grid-col-2" layout="grid" styleClass="ui-noborder ui-transparent-widget">
-                                               <h:outputText value="#{project.ADMIN_LIST_RECEIPTS_HEADER}" />
+                                       <p:panelGrid columns="3" layout="grid" columnClasses="ui-grid-col-4,ui-grid-col-6,ui-grid-col-2">
+                                               <p:spacer />
 
-                                               <h:panelGroup>
+                                               <p:panelGrid columns="2" columnClasses="ui-grid-4,ui-grid-8" layout="grid" styleClass="table table-full ui-noborder">
+                                                       <p:outputLabel for="globalFilter" value="#{msg.SEARCH_ALL_FIELDS}" style="float: right" />
+                                                       <p:inputText id="globalFilter" onkeyup="PF('receiptList').filter()" placeholder="#{msg.ENTER_KEYWORD}"/>
+                                               </p:panelGrid>
+
+                                               <p:outputPanel>
+                                                       <p:spacer height="4" />
                                                        <p:commandButton id="toggler" type="button" value="#{msg.SELECT_SHOWN_COLUMNS}" styleClass="column-selector" />
                                                        <p:columnToggler datasource="receiptList" trigger="toggler" />
-                                               </h:panelGroup>
-                                       </p:panelGrid >
+                                               </p:outputPanel>
+                                       </p:panelGrid>
                                </f:facet>
 
+                               <p:ajax
+                                       event="rowSelect"
+                                       update=":master:form-list-financial-receipts:receipt-details"
+                                       oncomplete="PF('receiptDialog').show()"
+                                       />
+
                                <p:column headerText="#{msg.ID_NUMBER_HEADER}" sortBy="#{receipt.receiptId}" filterBy="#{receipt.receiptId}">
                                        <p:link outcome="admin_show_receipt" title="#{project.ADMIN_LINK_SHOW_RECEIPT_TITLE}" value="#{receipt.receiptId}">
                                                <f:param name="receiptId" value="#{receipt.receiptId}" />
@@ -64,7 +81,6 @@
                                                        title="#{msg.FILTER_BY_MULTIPLE_BRANCH_OFFICES_TITLE}"
                                                        >
                                                        <f:converter converterId="BranchOfficeConverter" />
-                                                       <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
                                                        <f:selectItems value="#{branchOfficeController.allBranchOffices()}" var="branchOffice" itemValue="#{branchOffice}" itemLabel="#{beanHelper.renderBranchOffice(branchOffice)}" />
                                                </p:selectCheckboxMenu>
                                        </f:facet>
                                                </p:selectCheckboxMenu>
                                        </f:facet>
 
-                                       <p:link outcome="admin_show_employee" title="#{msg.ADMIN_LINK_SHOW_RECEIPT_SELLER_EMPLOYEE_TITLE}" value="#{beanHelper.renderEmployee(receipt.receiptSellerEmployee)}" rendered="#{not empty receipt.receiptSellerEmployee}">
+                                       <p:link outcome="admin_show_employee" title="#{project.ADMIN_LINK_SHOW_RECEIPT_SELLER_EMPLOYEE_TITLE}" value="#{beanHelper.renderEmployee(receipt.receiptSellerEmployee)}" rendered="#{not empty receipt.receiptSellerEmployee}">
                                                <f:param name="userId" value="#{receipt.receiptSellerEmployee.employeeId}" />
                                        </p:link>
 
-                                       <p:link outcome="admin_assign_receipt_seller" title="#{msg.ADMIN_LINK_ASSIGN_RECEIPT_SELLER_EMPLOYEE_TITLE}" value="#{msg.ADMIN_LINK_ASSIGN}" rendered="#{empty receipt.receiptSellerEmployee}">
+                                       <p:link outcome="admin_assign_receipt_seller" title="#{project.ADMIN_LINK_ASSIGN_RECEIPT_SELLER_EMPLOYEE_TITLE}" value="#{msg.ADMIN_LINK_ASSIGN}" rendered="#{empty receipt.receiptSellerEmployee}">
                                                <f:param name="receiptId" value="#{receipt.receiptId}" />
                                        </p:link>
                                </p:column>
                                                </p:selectCheckboxMenu>
                                        </f:facet>
 
-                                       <p:link outcome="admin_show_user" title="#{msg.ADMIN_LINK_SHOW_RECEIPT_OWNER_USER_TITLE}" value="#{receipt.receiptUser.userId}" rendered="#{not empty receipt.receiptUser}">
+                                       <p:link outcome="admin_show_user" title="#{project.ADMIN_LINK_SHOW_RECEIPT_OWNER_USER_TITLE}" value="#{beanHelper.renderUser(receipt.receiptUser)}" rendered="#{not empty receipt.receiptUser}">
                                                <f:param name="userId" value="#{receipt.receiptUser.userId}" />
                                        </p:link>
 
-                                       <p:link outcome="admin_assign_receipt_user" title="#{msg.ADMIN_LINK_ASSIGN_RECEIPT_OWNER_USER_TITLE}" value="#{msg.ADMIN_LINK_ASSIGN}" rendered="#{empty receipt.receiptUser}">
+                                       <p:link outcome="admin_assign_receipt_user" title="#{project.ADMIN_LINK_ASSIGN_RECEIPT_OWNER_USER_TITLE}" value="#{msg.ADMIN_LINK_ASSIGN}" rendered="#{empty receipt.receiptUser}">
                                                <f:param name="receiptId" value="#{receipt.receiptId}" />
                                        </p:link>
                                </p:column>
                                        </h:outputText>
                                </p:column>
 
-                               <p:column headerText="#{msg.ADMIN_PAYMENT_TYPE}" sortBy="#{receipt.receiptPaymentType}" filterBy="#{receipt.receiptPaymentType}">
+                               <p:column headerText="#{msg.ADMIN_PAYMENT_TYPE}" sortBy="#{receipt.receiptPaymentType}" filterBy="#{receipt.receiptPaymentType}" filterMatchMode="in">
                                        <f:facet name="filter">
-                                               <p:selectOneMenu
+                                               <p:selectCheckboxMenu
                                                        filter="true"
                                                        filterMatchMode="contains"
                                                        label="#{msg.LABEL_PAYMENT_TYPES}"
+                                                       updateLabel="true"
                                                        onchange="PF('receiptList').filter()"
-                                                       title="#{msg.FILTER_BY_MULTIPLE_PAYMENT_TYPES_TITLE}"
                                                        >
                                                        <f:converter converterId="PaymentTypeConverter" />
-                                                       <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
                                                        <f:selectItems value="#{dataController.paymentTypes}" var="paymentType" itemValue="#{paymentType}" itemLabel="#{msg[paymentType.i18nKey]}" />
-                                               </p:selectOneMenu>
+                                               </p:selectCheckboxMenu>
                                        </f:facet>
 
                                        <h:outputText value="#{msg[receipt.receiptPaymentType.i18nKey]}" />
                                        <pl:outputReceiptAdminMiniLinks receipt="#{receipt}" />
                                </p:column>
                        </p:dataTable>
+
+                       <p:dialog
+                               dynamic="true"
+                               modal="true"
+                               resizable="false"
+                               header="#{project.ADMIN_SINGLE_RECEIPT_DETAILS_HEADER}"
+                               hideEffect="fade"
+                               showEffect="fade"
+                               widgetVar="receiptDialog"
+                               position="center,center"
+                               responsive="true"
+                               >
+                               <p:outputPanel id="receipt-details">
+                                       <p:panelGrid columns="2" rendered="#{not empty receiptListController.selectedReceipt}" columnClasses="label,value">
+                                               <f:facet name="header">
+                                                       <h:outputFormat value="#{project.ADMIN_RECEIPT_DETAILS_HEADER}">
+                                                               <f:param value="#{receiptListController.selectedReceipt.receiptId}" />
+                                                       </h:outputFormat>
+                                               </f:facet>
+
+                                               <p:outputLabel value="#{msg.ID_NUMBER_HEADER}" title="#{project.RECEIPT_ID_NUMBER_TITLE}" />
+                                               <h:outputText value="#{receiptListController.selectedReceipt.receiptId}" />
+
+                                               <p:outputLabel value="#{project.RECEIPT_NUMBER}" title="#{project.RECEIPT_NUMBER_TITLE}" />
+                                               <h:outputText value="#{receiptListController.selectedReceipt.receiptNumber}" />
+
+                                               <p:outputLabel value="#{project.RECEIPT_ISSUED}" title="#{project.RECEIPT_ISSUED_TITLE}" />
+                                               <h:outputText id="receiptIssued" value="#{receiptListController.selectedReceipt.receiptIssued.time}">
+                                                       <f:convertDateTime for="receiptIssued" type="both" timeStyle="short" dateStyle="short" />
+                                               </h:outputText>
+
+                                               <p:outputLabel value="#{msg.BRANCH_OFFICE}" title="#{project.ASSIGNED_RECEIPT_BRANCH_OFFICE_TITLE}" />
+                                               <p:link outcome="admin_show_branch_office" title="#{msg.ADMIN_LINK_SHOW_BRANCH_OFFICE_TITLE}" value="#{beanHelper.renderBranchOffice(receiptListController.selectedReceipt.receiptBranchOffice)}">
+                                                       <f:param name="branchId" value="#{receiptListController.selectedReceipt.receiptBranchOffice.branchId}" />
+                                               </p:link>
+
+                                               <p:outputLabel value="#{project.SELLER_HEADER}" title="#{project.ASSIGNED_RECEIPT_SELLER_TITLE}" />
+                                               <p:link outcome="admin_show_employee" title="#{project.ADMIN_LINK_SHOW_RECEIPT_SELLER_EMPLOYEE_TITLE}" value="#{beanHelper.renderEmployee(receiptListController.selectedReceipt.receiptSellerEmployee)}" rendered="#{not empty receiptListController.selectedReceipt.receiptSellerEmployee}">
+                                                       <f:param name="userId" value="#{receiptListController.selectedReceipt.receiptSellerEmployee.employeeId}" />
+                                               </p:link>
+                                               <h:outputText value="#{project.NO_SELLER_ASSIGNED_TO_RECEIPT}" rendered="#{empty receiptListController.selectedReceipt.receiptSellerEmployee}" />
+
+                                               <p:outputLabel value="#{msg.USER_HEADER}" title="#{project.ASSIGNED_RECEIPT_USER_TITLE}" />
+                                               <p:link outcome="admin_show_user" title="#{project.ADMIN_LINK_SHOW_RECEIPT_USER_EMPLOYEE_TITLE}" value="#{beanHelper.renderEmployee(receiptListController.selectedReceipt.receiptUser)}" rendered="#{not empty receiptListController.selectedReceipt.receiptUser}">
+                                                       <f:param name="userId" value="#{receiptListController.selectedReceipt.receiptUser.userId}" />
+                                               </p:link>
+                                               <h:outputText value="#{project.NO_USER_ASSIGNED_TO_RECEIPT}" rendered="#{empty receiptListController.selectedReceipt.receiptUser}" />
+
+                                               <p:outputLabel value="#{project.RECEIPT_BARCODE_HEADER}" title="#{project.RECEIPT_BARCODE_TITLE}" />
+                                               <h:outputText value="#{receiptListController.selectedReceipt.receiptBarCodeNumber}" />
+
+                                               <p:outputLabel value="#{project.RECEIPT_SEQUENCE_NUMBER_HEADER}" title="#{project.RECEIPT_SEQUENCE_NUMBER_TITLE}" />
+                                               <h:outputText value="#{receiptListController.selectedReceipt.receiptSequenceNumber}" />
+
+                                               <p:outputLabel value="#{msg.PAYMENT_TYPE}" title="#{project.RECEIPT_PAYMENT_TYPE_TITLE}" />
+                                               <h:outputText value="#{msg[receiptListController.selectedReceipt.receiptPaymentType.i18nKey]}" />
+                                       </p:panelGrid>
+                               </p:outputPanel>
+                       </p:dialog>
                </h:form>
 
                <h:form>
                                                type="submit"
                                                value="#{project.BUTTON_ADMIN_ADD_RECEIPT}"
                                                action="#{adminReceiptController.addReceipt()}"
-                                               update=":master:form-list-financial-receipt:receiptList"
+                                               update=":master:form-list-financial-receipts:receiptList"
                                                />
                                </p:panelGrid>
                        </p:panelGrid>
index 5fc51f1148bc7055abb24a197f712b41681ffe05..1f94db7ff237ae0b27ab2f78fb7fcff5189edc0f 100644 (file)
@@ -66,8 +66,7 @@
                                                        title="#{project.FILTER_BY_MULTIPLE_RECEIPTS_TITLE}"
                                                        >
                                                        <f:converter converterId="ReceiptConverter" />
-                                                       <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
-                                                       <f:selectItems value="#{receiptController.allReceipts()}" var="receipt" itemValue="#{receipt}" itemLabel="#{beanHelper.renderReceipt(receipt)}" />
+                                                       <f:selectItems value="#{receiptListController.allReceipts}" var="receipt" itemValue="#{receipt}" itemLabel="#{beanHelper.renderReceipt(receipt)}" />
                                                </p:selectCheckboxMenu>
                                        </f:facet>
 
@@ -87,7 +86,6 @@
                                                        title="#{project.FILTER_BY_MULTIPLE_ITEM_PRODUCTS_TITLE}"
                                                        >
                                                        <f:converter converterId="GenericProductConverter" />
-                                                       <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" />
                                                        <f:selectItems value="#{productListController.allProducts}" var="product" itemValue="#{product}" itemLabel="#{beanHelper.renderGenericProduct(product)}" />
                                                </p:selectCheckboxMenu>
                                        </f:facet>
index ef54df581fdf17322446be136370731d179f10a9..fde9c1f57081d83d85011d3c32599cde1702142e 100644 (file)
@@ -47,7 +47,6 @@
                                                        required="true"
                                                        requiredMessage="#{project.FIELD_FINANCIAL_INCOME_REQUIRED}"
                                                        >
-                                                       <f:selectItem itemValue="#{null}" itemLabel="#{msg.NONE_SELECTED}" noSelectionOption="true" />
                                                        <f:selectItems value="#{financialIncomeController.allIncomeIntervals()}" var="incomeInterval" itemValue="#{incomeInterval}" itemLabel="#{msg[incomeInterval.concat('_INTERVAL')]}" />
                                                </p:selectOneMenu>
                                        </div>