Commit bbdc6a79 by Petri Jarvisalo

aloitettu uutta kauppaui:ta

1 parent f0a14147
...@@ -185,7 +185,7 @@ public class MenuNavigation extends GenericEntity implements Comparable<MenuNavi ...@@ -185,7 +185,7 @@ public class MenuNavigation extends GenericEntity implements Comparable<MenuNavi
// used only for initialization function... // used only for initialization function...
public MenuNavigation addPage(Menuitem item, IAppPermission permission) { public MenuNavigation addPage(Menuitem item, IAppPermission permission) {
int childSort = 100; int childSort = 100;
if (children == null) { if (children == null || children.size() == 0) {
children = new ArrayList<MenuNavigation>(); children = new ArrayList<MenuNavigation>();
} else { } else {
childSort = children.get(children.size() - 1).getSort() + 10; childSort = children.get(children.size() - 1).getSort() + 10;
......
/* General css, use for non-layout purposes for general elements */ /* General css, use for non-layout purposes for general elements */
/* userlistview popup */ /* userlistview popup */
.userdata_popup { .userdata_popup {
position: absolute; position: absolute;
border: 1px solid black; border: 1px solid black;
background: white; background: white;
border-radius: 3px; border-radius: 3px;
display: none; display: none;
width: 300px; width: 300px;
height: 150px; height: 150px;
} }
/* general class for hoverable usage */ /* general class for hoverable usage */
.hoverable { .hoverable {
} }
.hidden { .hidden {
display: none; display: none;
} }
#webcamcontainer { #webcamcontainer {
} }
#shopItems {} #shopItems {
}
.ui-panel-title { .ui-panel-title {
text-overflow: clip; text-overflow: clip;
} }
.shopItem { .shopItem {
position: relative; float: left;
width: 72px; width: 72px;
height: 72px; height: 72px;
float:left; background: burlywood;
border: 1px solid black;
margin: 2px; margin: 2px;
} }
.shopItem:hover { a.shopItem {
background: #ddd; color: black !important;
}
a.shopItem div {
position: absolute;
height: 72px;
width: 72px;
text-align: center;
/* Firefox */
display: -moz-box;
-moz-box-orient: horizontal;
-moz-box-pack: center;
-moz-box-align: center;
/* Safari and Chrome */
display: -webkit-box;
-webkit-box-orient: horizontal;
-webkit-box-pack: center;
-webkit-box-align: center;
/* W3C */
display: box;
box-orient: horizontal;
box-pack: center;
box-align: center;
clip: rect(0, 72px, 72px, 0);
} }
}
a.shopItem:hover {
background: darkgoldenrod;
}
a.shopItem:active {
background: red;
}
\ No newline at end of file
<!DOCTYPE html <!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" <html xmlns="http://www.w3.org/1999/xhtml"
xmlns:products="http://java.sun.com/jsf/composite/cditools/products" xmlns:p="http://primefaces.org/ui" xmlns:users="http://java.sun.com/jsf/composite/cditools/user" xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:products="http://java.sun.com/jsf/composite/cditools/products"
xmlns:p="http://primefaces.org/ui"
xmlns:users="http://java.sun.com/jsf/composite/cditools/user"
xmlns:c="http://java.sun.com/jsp/jstl/core"> xmlns:c="http://java.sun.com/jsp/jstl/core">
<h:body> <h:body>
<ui:composition template="/layout/#{sessionHandler.layout}/template.xhtml"> <ui:composition
template="/layout/#{sessionHandler.layout}/template.xhtml">
<f:metadata> <f:metadata>
<f:viewParam name="userid" value="#{userView.userid}" /> <f:viewParam name="userid" value="#{userView.userid}" />
<f:event type="preRenderView" listener="#{userView.initView}" /> <f:event type="preRenderView" listener="#{userView.initView}" />
<f:event type="preRenderView" listener="#{productShopView.initShopView}" /> <f:event type="preRenderView"
listener="#{productShopView.initShopView}" />
</f:metadata> </f:metadata>
<ui:define name="title"> <ui:define name="title">
...@@ -24,13 +31,13 @@ ...@@ -24,13 +31,13 @@
<h:panelGroup> <h:panelGroup>
<div id="shopItems"> <div id="shopItems">
<ui:repeat value="#{productShopView.shoppingcart}" var="cart"> <ui:repeat value="#{productShopView.shoppingcart}" var="cart">
<h:commandLink action="#{productShopView.addOne}"> <h:commandLink styleClass="shopItem"
<f:ajax render="@form" /> action="#{productShopView.addOne}">
<p:panel header="#{cart.product.name}" styleClass="shopItem"> <f:ajax render="@form" />
<p:panelGrid>
#{cart.product.price()} <div>
</p:panelGrid> #{cart.product.name}<br /> #{cart.product.price}
</p:panel> </div>
</h:commandLink> </h:commandLink>
</ui:repeat> </ui:repeat>
</div> </div>
...@@ -38,9 +45,50 @@ ...@@ -38,9 +45,50 @@
</h:panelGroup> </h:panelGroup>
<h:panelGroup> <h:panelGroup>
<p:dataTable id="prods" value="#{productShopView.boughtItems}"
var="prods">
<p:column>
<f:facet name="header">
<h:link value="#{i18n['user.nick']}" includeViewParams="true">
</h:link>
</f:facet>
<h:outputText value="#{prods.count}" />
</p:column>
<p:column>
<f:facet name="header">
<h:link value="#{i18n['user.nick']}" includeViewParams="true">
</h:link>
</f:facet>
<h:outputText value="#{prods.getProduct().name}" />
</p:column>
<p:column>
<f:facet name="header">
<h:link value="#{i18n['user.nick']}" includeViewParams="true">
</h:link>
</f:facet>
<h:outputText value="#{prods.getProduct().price}" />
</p:column>
<p:column>
<f:facet name="header">
<h:link value="#{i18n['user.nick']}" includeViewParams="true">
</h:link>
</f:facet>
<h:commandButton action="#{productShopView.removeBought()}" value="Poista"/>
</p:column>
</p:dataTable>
<h:outputLabel value="#{i18n['shop.readBarcode']}" /> <h:outputLabel value="#{i18n['shop.readBarcode']}" />
<h:inputText id="barcode" value="#{productShopView.barcode}" /> <h:inputText id="barcode" value="#{productShopView.barcode}" />
<h:commandButton action="#{productShopView.readBarcode}" onclick="blip(); return true;" value="#{i18n['productShopView.readBarcode']}"> <h:commandButton action="#{productShopView.readBarcode}"
onclick="blip(); return true;"
value="#{i18n['productShopView.readBarcode']}">
<f:ajax render="@form" onevent="barcodeReadEvent" execute="@form" /> <f:ajax render="@form" onevent="barcodeReadEvent" execute="@form" />
</h:commandButton> </h:commandButton>
...@@ -65,8 +113,8 @@ ...@@ -65,8 +113,8 @@
</h:panelGrid> </h:panelGrid>
<h:outputText value="#{i18n['product.shopInstant']}" /> <h:outputText value="#{i18n['product.shopInstant']}" />
<h:selectBooleanCheckbox value="#{productShopView.payInstant}"> <h:selectBooleanCheckbox value="#{productShopView.payInstant}">
<f:ajax render="@form" execute="@form" /> <f:ajax render="@form" execute="@form" />
...@@ -74,7 +122,8 @@ ...@@ -74,7 +122,8 @@
<h:outputScript library="primefaces" name="jquery/jquery.js" /> <h:outputScript library="primefaces" name="jquery/jquery.js" />
<div style="margin-top: 5px;"> <div style="margin-top: 5px;">
<h:commandButton action="#{cc.attrs.commitaction}" id="commitbutton-top" value="#{cc.attrs.commitValue}" /> <h:commandButton action="#{cc.attrs.commitaction}"
id="commitbutton-top" value="#{cc.attrs.commitValue}" />
</div> </div>
...@@ -86,7 +135,8 @@ ...@@ -86,7 +135,8 @@
</h:outputText> </h:outputText>
</div> </div>
<h:commandButton action="#{cc.attrs.commitaction}" id="commitbutton-botton" value="#{cc.attrs.commitValue}" /> <h:commandButton action="#{cc.attrs.commitaction}"
id="commitbutton-botton" value="#{cc.attrs.commitValue}" />
</h:form> </h:form>
......
...@@ -64,14 +64,17 @@ public class SessionHandler { ...@@ -64,14 +64,17 @@ public class SessionHandler {
public String getLayout() { public String getLayout() {
// TODO: layout selection code missing!! // TODO: layout selection code missing!!
// return "stream1"; template = "template1";
return template;
/*
if (template == null) { if (template == null) {
template = eventbean.getPropertyString(LanEventPropertyKey.EVENT_LAYOUT); template = eventbean.getPropertyString(LanEventPropertyKey.EVENT_LAYOUT);
} }
if (template == null) { if (template == null) {
template = "template1"; template = "template1";
} }
return template; return template; */
} }
// public boolean hasPermission(String target, String permission) { // public boolean hasPermission(String target, String permission) {
......
package fi.insomnia.bortal.web.cdiview.shop; package fi.insomnia.bortal.web.cdiview.shop;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Map; import java.util.Map;
import javax.ejb.EJB; import javax.ejb.EJB;
...@@ -61,6 +63,7 @@ public class ProductShopView extends GenericCDIView { ...@@ -61,6 +63,7 @@ public class ProductShopView extends GenericCDIView {
private BillEditView billEditView; private BillEditView billEditView;
private boolean hasLimits = false; private boolean hasLimits = false;
private boolean blip = false; private boolean blip = false;
private ListDataModel<ProductShopItem> boughtItems;
public void initBillView() { public void initBillView() {
if (requirePermissions(ShopPermission.LIST_USERPRODUCTS) if (requirePermissions(ShopPermission.LIST_USERPRODUCTS)
...@@ -91,34 +94,41 @@ public class ProductShopView extends GenericCDIView { ...@@ -91,34 +94,41 @@ public class ProductShopView extends GenericCDIView {
public String add(Integer count) { public String add(Integer count) {
ProductShopItem item = shoppingcart.getRowData(); ProductShopItem item = shoppingcart.getRowData();
item.setCount(item.getCount().add(BigDecimal.valueOf(count))); item.setCount(item.getCount().add(BigDecimal.valueOf(count)));
updateCartLimits(item); updateCartLimits(item);
return null; return null;
} }
public String addOne() public String addOne() {
{
return add(1); return add(1);
} }
public String addMinusOne() public String addMinusOne() {
{
return add(-1); return add(-1);
} }
public String addTen() public String addTen() {
{
return add(10); return add(10);
} }
public String addMinusTen() public String addMinusTen() {
{
return add(-10); return add(-10);
} }
public void updateCartLimits(ProductShopItem item) { public void updateCartLimits(ProductShopItem item) {
if (boughtItems == null) {
boughtItems = new ListDataModel<ProductShopItem>(
new ArrayList<ProductShopItem>());
}
List<ProductShopItem> listdata = (List<ProductShopItem>) boughtItems
.getWrappedData();
if (item != null && !listdata.contains(item)) {
listdata.add(item);
}
Map<Integer, BigDecimal> prodCounts = new HashMap<Integer, BigDecimal>(); Map<Integer, BigDecimal> prodCounts = new HashMap<Integer, BigDecimal>();
for (ProductShopItem sc : shoppingcart) { for (ProductShopItem sc : shoppingcart) {
prodCounts.put(sc.getProduct().getId(), sc.getCount()); prodCounts.put(sc.getProduct().getId(), sc.getCount());
...@@ -128,11 +138,9 @@ public class ProductShopView extends GenericCDIView { ...@@ -128,11 +138,9 @@ public class ProductShopView extends GenericCDIView {
prodCounts, user); prodCounts, user);
// Update the updated cart first // Update the updated cart first
if (item != null) if (item != null) {
{
BigDecimal l = limits.get(item.getProduct().getId()); BigDecimal l = limits.get(item.getProduct().getId());
if (item.updateLimit(l)) if (item.updateLimit(l)) {
{
updateCartLimits(null); updateCartLimits(null);
return; return;
} }
...@@ -145,9 +153,29 @@ public class ProductShopView extends GenericCDIView { ...@@ -145,9 +153,29 @@ public class ProductShopView extends GenericCDIView {
} }
n.updateLimit(l); n.updateLimit(l);
} }
} }
public String removeBought() {
ProductShopItem row = boughtItems.getRowData();
row.setCount(row.getCount().subtract(BigDecimal.ONE));
updateCartLimits(row);
return null;
}
// public ListDataModel<ProductShopItem> getProducts() {
// List<ProductShopItem> prods = new ArrayList<ProductShopItem>();
// for (ProductShopItem sc : shoppingcart) {
// if (sc.getCount() != null && sc.getCount().compareTo(BigDecimal.ONE) !=
// -1) {
// prods.add(sc);
// }
// }
// return prods;
//
// }
public void updateAllCartLimits() { public void updateAllCartLimits() {
updateCartLimits(null); updateCartLimits(null);
} }
...@@ -201,13 +229,15 @@ public class ProductShopView extends GenericCDIView { ...@@ -201,13 +229,15 @@ public class ProductShopView extends GenericCDIView {
EventUser retuser = null; EventUser retuser = null;
for (ProductShopItem shopitem : shoppingcart) { for (ProductShopItem shopitem : shoppingcart) {
if (shopitem.getCount().compareTo(BigDecimal.ZERO) > 0) { if (shopitem.getCount().compareTo(BigDecimal.ZERO) > 0) {
retuser = productBean.createAccountEvent(shopitem.getProduct(), shopitem.getCount(), user).getUser(); retuser = productBean.createAccountEvent(shopitem.getProduct(),
shopitem.getCount(), user).getUser();
} }
} }
if (cash != null && cash.compareTo(BigDecimal.ZERO) != 0) { if (cash != null && cash.compareTo(BigDecimal.ZERO) != 0) {
Product credProd = productBean.findCreditProduct(); Product credProd = productBean.findCreditProduct();
retuser = productBean.createAccountEvent(credProd, cash, user).getUser(); retuser = productBean.createAccountEvent(credProd, cash, user)
.getUser();
} }
if (user != null) { if (user != null) {
user = retuser; user = retuser;
...@@ -316,4 +346,12 @@ public class ProductShopView extends GenericCDIView { ...@@ -316,4 +346,12 @@ public class ProductShopView extends GenericCDIView {
this.blip = blip; this.blip = blip;
} }
public ListDataModel<ProductShopItem> getBoughtItems() {
return boughtItems;
}
public void setBoughtItems(ListDataModel<ProductShopItem> boughtItems) {
this.boughtItems = boughtItems;
}
} }
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!