Commit 1ac3c7b1 by Tuomas Riihimäki

merge from newui

1 parent 0af7b2aa
/* General css, use for non-layout purposes for general elements */
/* userlistview popup */
.userdata_popup {
position: absolute;
border: 1px solid black;
background: white;
border-radius: 3px;
display: none;
position: absolute;
border: 1px solid black;
background: white;
border-radius: 3px;
display: none;
width: 300px;
height: 150px;
}
/* general class for hoverable usage */
.hoverable {
}
.hidden {
display: none;
}
#webcamcontainer {
}
#shopItems {
}
.ui-panel-title {
text-overflow: clip;
}
.shopItem {
float: left;
width: 72px;
height: 72px;
background: burlywood;
border: 1px solid black;
margin: 2px;
}
a.shopItem {
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
......@@ -20,41 +20,103 @@
<h:form id="shoppingcartform">
<h:panelGrid columns="2">
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['shop.accountBalance']}" />
<h:outputText value="#{productShopView.accountBalance}">
<f:convertNumber />
</h:outputText>
<h:panelGroup>
<div id="shopItems">
<ui:repeat value="#{productShopView.shoppingcart}" var="cart">
<h:commandLink styleClass="shopItem"
action="#{productShopView.addOne}">
<f:ajax render="@form" />
<h:outputLabel value="#{i18n['shop.totalPrice']}" />
<h:outputText value="#{productShopView.totalPrice}">
<f:convertNumber />
</h:outputText>
<div>
#{cart.product.name}<br />
<h:outputText value="#{cart.product.price}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>eur
</div>
</h:commandLink>
</ui:repeat>
</div>
</h:panelGroup>
<h:outputLabel value="#{i18n['shop.cash']}" />
<h:inputText value="#{productShopView.cash}">
<f:ajax render="@form" event="valueChange" />
<f:convertNumber />
</h:inputText>
</h:panelGrid>
<h:panelGroup>
<h:outputLabel value="#{i18n['shop.readBarcode']}" />
<h:outputLabel value="#{i18n['shop.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['shop.readBarcode']}">
<f:ajax render="@form" onevent="barcodeReadEvent" execute="@form" />
</h:commandButton>
<br />
<p:dataTable id="prods" value="#{productShopView.boughtItems}"
var="prods">
</h:panelGroup>
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['shop.count']}" />
</f:facet>
<h:outputText value="#{prods.count}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['shop.product']}" />
</f:facet>
<h:outputText value="#{prods.getProduct().name}" />
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['shop.price']}" />
</f:facet>
<h:outputText value="#{prods.getProduct().price}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['shop.actions']}" />
</f:facet>
<h:commandButton action="#{productShopView.removeBought()}"
value="Poista" />
</p:column>
</p:dataTable>
<div style="font-weight: bold;">
<h:outputText value="#{i18n['shop.totalPrice']}" />
<span class="shoptotal"> <h:outputText value="#{productShopView.totalPrice}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText></span>
</div>
<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()" />
<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()" />
<br />
<h:outputLabel value="#{i18n['shop.accountBalance']}" />
<h:outputText value=" #{productShopView.accountCredits}">
<f:convertNumber />
</h:outputText>
<br/>
<h:commandButton action="#{productShopView.buyCash()}" value="#{i18n['shop.buyCash']}" />
<h:commandButton action="#{productShopView.buyCredit()}" onclick="return confirm('#{i18n['shop.confirmCreditBuy']}');" value="#{i18n['shop.buyCredit']}" />
</h:panelGroup>
</h:panelGrid>
<h:outputText value="#{i18n['product.shopInstant']}" />
<h:selectBooleanCheckbox value="#{productShopView.payInstant}">
<f:ajax render="@form" execute="@form" />
</h:selectBooleanCheckbox>
<products:shop commitaction="#{productShopView.commitShoppingCart()}" items="#{productShopView.shoppingcart}" commitValue="#{i18n['productshop.commit']}" />
<h:outputScript library="primefaces" name="jquery/jquery.js" />
</h:form>
<script>
var blipSnd = new Audio(
......@@ -62,12 +124,17 @@
$(function() {
$("#shoppingcartform\\:barcode").focus();
});
});
function blip() {
blipSnd.play();
}
function calc() {
$("#returnval").val($(".inputval").val() - $(".shoptotal").text().replace(",","."));
}
function barcodeReadEvent(data) {
if (data.status == "success") {
$("#shoppingcartform\\:barcode").focus();
......
......@@ -119,9 +119,9 @@ placegroupview.toptext = \
poll.edit = edit
product.providedRole = Tuote m\u00E4\u00E4ritt\u00E4\u00E4 roolin
product.returnProductEdit = Palaa tuotteeseen:
product.saved = Tuote tallennettu
product.providedRole = Tuote tarjoaa roolin
product.returnProductEdit = Palaa tuotteeseen:
product.saved = Tuote tallennettu
productshop.minusOne = -1
productshop.minusTen = -10
......
......@@ -454,6 +454,8 @@ productShopView.readBarcode = Read barcode
products.save = Save
productsShopView.readBarcode = Read
productshop.billCreated = Bill created
productshop.commit = Buy
productshop.limits = Available
......@@ -515,11 +517,21 @@ salespoint.noSalesPoints = Amount
sendPicture.header = S
shop.accountBalance = Account balance
shop.cash = Cash deposit
shop.readBarcode = Read barcode
shop.totalPrice = Price of products
shop.user = Selling to
shop.accountBalance = Credits
shop.actions = Actions
shop.barcode = Barcode
shop.buyCash = Buy by Cash
shop.buyCredit = Buy Credit
shop.calcsubtotal = Calc Subtotal
shop.cash = Cash
shop.cashback = Cashback
shop.confirmCreditBuy = Are You sure ?
shop.count = Q
shop.price = price
shop.product = Product
shop.readBarcode = Read
shop.totalPrice = Total
shop.user = Selling to
sidebar.bill.list = My bills
sidebar.bill.listAll = All bills
......
......@@ -442,6 +442,8 @@ productShopView.readBarcode = Lue viivakoodi
products.save = Tallenna
productsShopView.readBarcode = Lue
productshop.billCreated = Lasku luotu
productshop.commit = Osta
productshop.limits = Vapaana
......@@ -500,11 +502,21 @@ salespoint.noSalesPoints = M\u00E4\u00E4r\u00E4
sendPicture.header = L\u00E4het\u00E4 kuva
shop.accountBalance = Tilin saldo
shop.cash = K\u00E4teispano
shop.readBarcode = Lue viivakoodi
shop.totalPrice = Tuotteiden hinta
shop.user = Myyd\u00E4\u00E4n
shop.accountBalance = Credits
shop.actions = Hallinta
shop.barcode = Viivakoodi
shop.buyCash = K\u00E4teismaksu
shop.buyCredit = Credit
shop.calcsubtotal = Laske v\u00E4lisumma
shop.cash = K\u00E4teinen
shop.cashback = Takaisin
shop.confirmCreditBuy = Varmastikko ?
shop.count = Lkm
shop.price = Hinta
shop.product = Tuote
shop.readBarcode = Lue
shop.totalPrice = Yhteens\u00E4
shop.user = Myyd\u00E4\u00E4n
sidebar.bill.list = Omat laskut
sidebar.bill.listAll = Kaikki laskut
......
......@@ -161,6 +161,15 @@ public class ProductShopView extends GenericCDIView {
getTotalPrice(), ret });
return ret;
}
public BigDecimal getAccountCredits() {
BigDecimal ret = user.getAccountBalance();
ret = ret.add(getCash());
logger.info("User accountbalance {}, cash{}, total {}. retBalance {}",
new Object[] { user.getAccountBalance(), getCash(),
getTotalPrice(), ret });
return ret;
}
public BigDecimal getTotalPrice() {
BigDecimal ret = BigDecimal.ZERO;
......@@ -197,6 +206,21 @@ public class ProductShopView extends GenericCDIView {
}
public String buyCash() {
cash = getTotalPrice();
logger.info("buying cash {}", cash);
commitShoppingCart();
return null;
}
public String buyCredit() {
setCash(BigDecimal.ZERO);
commitShoppingCart();
return null;
}
public String commitShoppingCart() {
EventUser retuser = null;
for (ProductShopItem shopitem : shoppingcart) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!