foodwave summary

1 parent dc64db73
......@@ -4,10 +4,9 @@
*/
package fi.insomnia.bortal.model;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
import javax.persistence.Column;
import javax.persistence.Entity;
......@@ -152,9 +151,26 @@ public class FoodWave extends GenericEntity {
return true;
}
public List<Product> getOrderedProducts() {
List<Product> retlist = new ArrayList<Product>();
if (getAccountEvents() != null) {
for (AccountEvent ae : getAccountEvents()) {
if (!retlist.contains(ae.getProduct())) {
retlist.add(ae.getProduct());
}
}
}
return retlist;
}
public List<BillLine> getBillLines() {
return billLines;
}
public Integer getMaximumFoods() {
return maximumFoods;
}
......@@ -176,6 +192,7 @@ public class FoodWave extends GenericEntity {
return retval;
}
public void setMaximumFoods(Integer maximumFoods) {
this.maximumFoods = maximumFoods;
}
......
......@@ -84,6 +84,7 @@ public class FoodWaveTemplate extends GenericEntity {
return products;
}
/**
* @param products
* the products to set
......
......@@ -46,7 +46,7 @@
<div id="actionlog">
<h:form id="refresh">
<p:poll interval="1" update="actionlogtable" />
<p:dataTable styleClass="bordertable" id="actionlogtable" value="#{actionLogMessageView.messages}" var="message" paginator="true" rows="10" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}">
<p:dataTable2styleClass="bordertable" id="actionlogtable" value="#{actionLogMessageView.messages}" var="message" paginator="true" rows="30" paginatorTemplate="{CurrentPageReport} {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}" rowsPerPageTemplate="10,20,30,50,100">
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['actionlog.time']}" />
......
......@@ -137,6 +137,14 @@
</p:dataTable>
</h:form>
<br />
<br />
<br />
<br />
<foodwave:summary foodwaveProductSummaries="#{foodWaveView.productSummaries}" foodwave="#{foodWaveView.selectedFoodWave}"/>
</ui:define>
......
package fi.insomnia.bortal.web.cdiview.shop;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.TreeSet;
......@@ -12,6 +14,8 @@ import javax.faces.model.ListDataModel;
import javax.inject.Inject;
import javax.inject.Named;
import com.sun.xml.rpc.processor.schema.UnimplementedFeatureException;
import fi.insomnia.bortal.beans.AccountEventBeanLocal;
import fi.insomnia.bortal.beans.BillBeanLocal;
import fi.insomnia.bortal.beans.EventBeanLocal;
......@@ -27,6 +31,7 @@ import fi.insomnia.bortal.model.FoodWaveTemplate;
import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.model.ProductFlag;
import fi.insomnia.bortal.web.cdiview.GenericCDIView;
import fi.insomnia.bortal.web.helpers.FoodwaveProductSummary;
@Named
@ConversationScoped
......@@ -138,6 +143,23 @@ public class FoodWaveView extends GenericCDIView {
}
}
public List<FoodwaveProductSummary> getProductSummaries() {
System.out.println("..asdfasdf");
HashMap<Product, FoodwaveProductSummary> pmap = new HashMap<Product, FoodwaveProductSummary>();
for(AccountEvent ae : getSelectedFoodWave().getAccountEvents()) {
if(!pmap.containsKey(ae.getProduct())) {
pmap.put(ae.getProduct(), new FoodwaveProductSummary(ae.getProduct(), new BigDecimal(0), new BigDecimal(0)));
}
System.out.println("..");
pmap.get(ae.getProduct()).add(ae);
}
System.out.println("::"+pmap.values().size());
return new ArrayList<FoodwaveProductSummary>(pmap.values());
}
private void createNewProductSkeleton() {
TreeSet<ProductFlag> ts = new TreeSet<ProductFlag>();
ts.add(ProductFlag.PREPAID_INSTANT_CREATE);
......@@ -199,7 +221,7 @@ public class FoodWaveView extends GenericCDIView {
public void initFoodWaveOrderList() {
if (super.requirePermissions(ShopPermission.MANAGE_FOODWAVES) && selectedFoodWave == null) {
System.out.println("Testiä");
selectedFoodWave = foodWaveBean.findFoodwave(foodWaveId);
this.setAccountEventLines(new ListDataModel<AccountEvent>(selectedFoodWave.getAccountEvents()));
......@@ -242,6 +264,7 @@ public class FoodWaveView extends GenericCDIView {
}
public FoodWave getSelectedFoodWave() {
System.out.println("APOFKASFASFASFASFASFASFASFASFASFKJIOJIO");
return selectedFoodWave;
}
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!