Commit 17c6fbe9 by Tuomas Riihimäki

Shoppia

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