Commit 17c6fbe9 by Tuomas Riihimäki

Shoppia

1 parent 68ddd2bb
...@@ -7,9 +7,10 @@ public enum LanEventPropertyKey { ...@@ -7,9 +7,10 @@ public enum LanEventPropertyKey {
PORTAL_EMAIL_ADDRESS(Type.TEXT, "intra@streamparty.org"), PORTAL_EMAIL_ADDRESS(Type.TEXT, "intra@streamparty.org"),
PORTAL_EMAIL_NAME(Type.TEXT, "Streamparty intranet"), PORTAL_EMAIL_NAME(Type.TEXT, "Streamparty intranet"),
ADMIN_MAIL(Type.TEXT, "intra@streamparty.org"), ADMIN_MAIL(Type.TEXT, "intra@streamparty.org"),
EVENT_LAYOUT(Type.TEXT, "template1"), ; EVENT_LAYOUT(Type.TEXT, "template1"),
SHOP_DEFAULT_CASH(Type.BOOL, null), ;
private enum Type { private enum Type {
TEXT, DATE, DATA TEXT, DATE, DATA, BOOL
}; };
private final String defaultvalue; private final String defaultvalue;
...@@ -27,6 +28,10 @@ public enum LanEventPropertyKey { ...@@ -27,6 +28,10 @@ public enum LanEventPropertyKey {
return Type.DATA.equals(type); return Type.DATA.equals(type);
} }
public boolean isBoolean() {
return Type.DATA.equals(type);
}
private LanEventPropertyKey(Type t, String def) private LanEventPropertyKey(Type t, String def)
{ {
this.type = t; this.type = t;
......
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
</ui:fragment> </ui:fragment>
<div id="left"> <div id="left">
<ui:insert name="title" /> <ui:insert name="title" />
<h:messages globalOnly="true" /> <p:messages />
<ui:repeat var="cont1" value="#{menuView.getPagecontent('top')}"> <ui:repeat var="cont1" value="#{menuView.getPagecontent('top')}">
<h:outputText value="#{cont1.content}" escape="false" /> <h:outputText value="#{cont1.content}" escape="false" />
</ui:repeat> </ui:repeat>
......
...@@ -8,7 +8,8 @@ ...@@ -8,7 +8,8 @@
<composite:interface> <composite:interface>
<composite:attribute name="creating" required="false" default="false" /> <composite:attribute name="creating" required="false" default="false" />
<composite:attribute name="admincreate" required="false" />
<composite:attribute name="commitvalue" required="true" /> <composite:attribute name="commitvalue" required="true" />
<composite:attribute name="commitaction" required="true" method-signature="java.lang.String action()" /> <composite:attribute name="commitaction" required="true" method-signature="java.lang.String action()" />
</composite:interface> </composite:interface>
...@@ -65,14 +66,12 @@ ...@@ -65,14 +66,12 @@
<p:password validator="#{userValidator.password}" rendered="#{cc.attrs.creating}" id="password" value="#{userView.password}" /> <p:password validator="#{userValidator.password}" rendered="#{cc.attrs.creating}" id="password" value="#{userView.password}" />
<p:message rendered="#{cc.attrs.creating}" for="password" />
<br /> <br />
<p:outputLabel rendered="#{cc.attrs.creating}" value="#{i18n['user.passwordcheck']}" for="passwordcheck" /> <p:outputLabel rendered="#{cc.attrs.creating}" value="#{i18n['user.passwordcheck']}" for="passwordcheck" />
<br /> <br />
<p:password validator="#{userValidator.password}" rendered="#{cc.attrs.creating}" id="passwordcheck" value="#{userView.passwordcheck}" /> <p:password validator="#{userValidator.password}" rendered="#{cc.attrs.creating}" id="passwordcheck" value="#{userView.passwordcheck}" />
<p:message rendered="#{cc.attrs.creating}" for="passwordcheck" />
<br /> <br />
</h:panelGroup> </h:panelGroup>
...@@ -120,7 +119,7 @@ ...@@ -120,7 +119,7 @@
</table> </table>
<p:commandButton rendered="#{cc.attrs.creating or userView.canSave}" id="commitbtn" action="#{cc.attrs.commitaction}" value="#{cc.attrs.commitvalue}" /> <p:commandButton ajax="false" rendered="#{cc.attrs.creating or userView.canSave}" id="commitbtn" action="#{cc.attrs.commitaction}" value="#{cc.attrs.commitvalue}" />
</h:panelGroup> </h:panelGroup>
......
...@@ -87,17 +87,17 @@ ...@@ -87,17 +87,17 @@
<div style="font-weight: bold;"> <div style="font-weight: bold;">
<h:outputText value="#{i18n['shop.cartPrice']}" /> <h:outputText value="#{i18n['shop.cartPrice']}" />
<h:outputText styleClass="shoptotal" value="#{productShopView.cartPrice}"> <h:outputText id="shoptotal" value="#{productShopView.cartPrice}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" /> <f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText> </h:outputText>
<br /> <br />
<h:outputLabel value="#{i18n['shop.currentBalance']}" /> <h:outputLabel value="#{i18n['shop.currentBalance']}" />
<h:outputText styleClass="shoptotal" value="#{productShopView.accountCredits}"> <h:outputText id="currentbalance" value="#{productShopView.accountCredits}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" /> <f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText> </h:outputText>
<br /> <br />
<h:outputLabel value="#{i18n['shop.transactionTotal']}" /> <h:outputLabel value="#{i18n['shop.transactionTotal']}" />
<h:outputText styleClass="shoptotal" value="#{productShopView.transactionTotal}"> <h:outputText id="transactiontotal" value="#{productShopView.transactionTotal}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" /> <f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText> </h:outputText>
</div> </div>
...@@ -105,18 +105,16 @@ ...@@ -105,18 +105,16 @@
<br /> <br />
<br /> <br />
<h:outputLabel value="#{i18n['shop.cash']}" /> <h:outputLabel value="#{i18n['shop.cash']}" />
<!-- <h:inputText styleClass="inputval" size="5" onblur="calc()" value="#{productShopView.cash}"> <h:inputText styleClass="inputval" size="5" value="#{productShopView.cash}">
<f:ajax render="@form" event="valueChange" /> <f:ajax render="@form" event="valueChange" listener="#{productShopView.cashChanged}" />
</h:inputText> --> </h:inputText>
<input type="text" class="inputval" value="" size="5" onblur="calc()" />
<br /> <br />
<h:outputLabel value="#{i18n['shop.cashback']}" /> <h:outputLabel value="#{i18n['shop.cashback']}" />
<input id="returnval" type="text" size="5" value="0" /> <input id="returnval" type="text" size="5" value="0" disabled="disabled"/>
<input type="button" value="#{i18n['shop.calcsubtotal']}" onclick="calc()" />
<br /> <br />
<h:outputLabel value="#{i18n['shop.']}" /> <h:outputLabel value="#{i18n['shop.']}" />
<h:outputText value=" #{productShopView.accountBalance}"> <h:outputText value=" #{productShopView.balanceAfterTransaction}">
<f:convertNumber /> <f:convertNumber />
</h:outputText> </h:outputText>
...@@ -145,7 +143,7 @@ ...@@ -145,7 +143,7 @@
} }
function calc() { function calc() {
$("#returnval").val($(".inputval").val() - $(".shoptotal").text().replace(",",".")); $("#returnval").val($("#inputval").val() - $("#shoppingcartform\\:totaltransaction").text().replace(",","."));
} }
function barcodeReadEvent(data) { function barcodeReadEvent(data) {
......
...@@ -22,6 +22,8 @@ import fi.insomnia.bortal.beans.ProductBeanLocal; ...@@ -22,6 +22,8 @@ import fi.insomnia.bortal.beans.ProductBeanLocal;
import fi.insomnia.bortal.enums.apps.ShopPermission; import fi.insomnia.bortal.enums.apps.ShopPermission;
import fi.insomnia.bortal.model.Bill; import fi.insomnia.bortal.model.Bill;
import fi.insomnia.bortal.model.EventUser; import fi.insomnia.bortal.model.EventUser;
import fi.insomnia.bortal.model.LanEventProperty;
import fi.insomnia.bortal.model.LanEventPropertyKey;
import fi.insomnia.bortal.model.Product; import fi.insomnia.bortal.model.Product;
import fi.insomnia.bortal.web.annotations.SelectedUser; import fi.insomnia.bortal.web.annotations.SelectedUser;
import fi.insomnia.bortal.web.cdiview.GenericCDIView; import fi.insomnia.bortal.web.cdiview.GenericCDIView;
...@@ -46,11 +48,16 @@ public class ProductShopView extends GenericCDIView { ...@@ -46,11 +48,16 @@ public class ProductShopView extends GenericCDIView {
@EJB @EJB
private transient EventBeanLocal eventbean; private transient EventBeanLocal eventbean;
public void cashChanged()
{
payInstant = false;
}
@Inject @Inject
@SelectedUser @SelectedUser
private EventUser user; private EventUser user;
private boolean payInstant; private boolean payInstant = true;
private BigDecimal cash = BigDecimal.ZERO; private BigDecimal cash = BigDecimal.ZERO;
private String barcode; private String barcode;
...@@ -65,6 +72,7 @@ public class ProductShopView extends GenericCDIView { ...@@ -65,6 +72,7 @@ public class ProductShopView extends GenericCDIView {
private boolean blip = false; private boolean blip = false;
private ListDataModel<ProductShopItem> boughtItems; private ListDataModel<ProductShopItem> boughtItems;
@EJB
public void initBillView() { public void initBillView() {
if (requirePermissions(ShopPermission.LIST_USERPRODUCTS) if (requirePermissions(ShopPermission.LIST_USERPRODUCTS)
&& shoppingcart == null) { && shoppingcart == null) {
...@@ -80,12 +88,16 @@ public class ProductShopView extends GenericCDIView { ...@@ -80,12 +88,16 @@ public class ProductShopView extends GenericCDIView {
public void initShopView() { public void initShopView() {
if (requirePermissions(ShopPermission.SHOP_TO_OTHERS) if (requirePermissions(ShopPermission.SHOP_TO_OTHERS) && shoppingcart == null) {
&& shoppingcart == null) { shoppingcart = new ListDataModel<ProductShopItem>(ProductShopItem.productGTList(productBean.findForStaffshop()));
shoppingcart = new ListDataModel<ProductShopItem>(
ProductShopItem.productList(productBean.findForStaffshop()));
updateCartLimits(null); updateCartLimits(null);
logger.debug("Initialized shoppingcart to {}", shoppingcart);
LanEventProperty cashdefault = eventbean.getProperty(LanEventPropertyKey.SHOP_DEFAULT_CASH);
if (cashdefault == null || cashdefault.isBooleanValue())
{
payInstant = true;
}
this.beginConversation(); this.beginConversation();
} }
} }
...@@ -117,12 +129,11 @@ public class ProductShopView extends GenericCDIView { ...@@ -117,12 +129,11 @@ public class ProductShopView extends GenericCDIView {
public void updateCartLimits(ProductShopItem item) { public void updateCartLimits(ProductShopItem item) {
if (boughtItems == null) { if (boughtItems == null) {
boughtItems = new ListDataModel<ProductShopItem>( boughtItems = new ListDataModel<ProductShopItem>(new ArrayList<ProductShopItem>());
new ArrayList<ProductShopItem>());
} }
List<ProductShopItem> listdata = (List<ProductShopItem>) boughtItems @SuppressWarnings("unchecked")
.getWrappedData(); List<ProductShopItem> listdata = (List<ProductShopItem>) boughtItems.getWrappedData();
if (item != null && !listdata.contains(item)) { if (item != null && !listdata.contains(item)) {
listdata.add(item); listdata.add(item);
...@@ -330,6 +341,9 @@ public class ProductShopView extends GenericCDIView { ...@@ -330,6 +341,9 @@ public class ProductShopView extends GenericCDIView {
} }
public void setCash(BigDecimal cash) { public void setCash(BigDecimal cash) {
if (cash == null) {
payInstant = true;
}
this.cash = cash; this.cash = cash;
} }
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!