Commit e999a1c9 by Tuomas Riihimäki

Random fixes..

1 parent 22894aca
......@@ -58,16 +58,15 @@
<f:param name="eventid" value="#{event.id}" />
</h:link>
<!--
<h: link rendered="#{!empty event.printedCard} AND !empty cc.attrs.linkoutcome" outcome="/shop/shopToUser" value="#{i18n['readerevent.shopToUser']}">
<h:link rendered="#{!empty event.printedCard }" outcome="/shop/shopToUser" value="#{i18n['readerevent.shopToUser']}">
<f:param name="userid" value="#{event.printedCard.user.user.id}" />
</h:link>
<h:commandButton action="#{cc.attrs.commitaction}" id="commitbutton-botton" value="#{cc.attrs.commitValue}" />
<h:link rendered="#{empty event.printedCard}" outcome="/shop/assocToUser" value="#{i18n['readerevent.associateToUser']}">
<f:param name="eventid" value="#{event.id}" />
</h:link> -->
</h:link>
</h:column>
</h:dataTable>
......
<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core" xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core"
xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader"
xmlns:p="http://primefaces.org/ui"
>
<composite:interface>
</composite:interface>
<composite:implementation>
<h:form id="shoppingcartform">
<h:panelGrid columns="2" style="width:100%;" columnClasses="shopProductbuttons,topalign">
<h:panelGroup>
<div id="shopItems">
<ui:repeat value="#{productShopView.shoppingcart}" var="cart">
<h:commandLink styleClass="shopItem" action="#{productShopView.addOne}">
<f:ajax render="@form" />
<div>
#{cart.product.name}<br />
<h:outputText value="#{cart.product.price}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>
</div>
</h:commandLink>
</ui:repeat>
</div>
</h:panelGroup>
<h:panelGroup>
<reader:barcode selectaction="#{productShopView.readBarcode}" selectvalue="#{i18n['shop.readBarcode']}" />
<br />
<p:dataTable id="prods" value="#{productShopView.boughtItems}" var="prods">
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['shop.count']}" />
</f:facet>
<p:inplace>
<p:inputText value="#{prods.count}" size="4">
<f:ajax event="valueChange" render="@form" />
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</p:inputText>
</p:inplace>
</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}">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:composite="http://java.sun.com/jsf/composite"
xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:tools="http://java.sun.com/jsf/composite/tools"
xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader" xmlns:p="http://primefaces.org/ui">
<composite:interface>
</composite:interface>
<composite:implementation>
<h:form id="shoppingcartform">
<h:panelGrid columns="2" style="width:100%;" columnClasses="shopProductbuttons,topalign">
<h:panelGroup>
<div id="shopItems">
<ui:repeat value="#{productShopView.shoppingcart}" var="cart">
<h:commandLink styleClass="shopItem" action="#{productShopView.addOne}">
<f:ajax render="@form" />
<div>
#{cart.product.name}<br />
<h:outputText value="#{cart.product.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>
<p:commandButton action="#{productShopView.removeBought()}" update="@form" value="Poista" />
</p:column>
</p:dataTable>
<div style="font-weight: bold;">
<h:outputText value="#{i18n['shop.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 id="currentbalance" value="#{productShopView.accountCredits}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>
<br />
<h:outputLabel value="#{i18n['shop.transactionTotal']}" />
<h:outputText id="transactiontotal" value="#{productShopView.transactionTotal}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>
</div>
<h:panelGrid columns="2" >
<h:outputLabel value="#{i18n['shop.toAccountValue']}" />
<h:inputText styleClass="inputval" size="5" value="#{productShopView.cash}">
<f:ajax render="@form" event="valueChange" listener="#{productShopView.cashChanged}" />
</h:inputText>
<h:outputLabel value="#{i18n['shop.cashGiven']}" />
<input id="returnval" type="text" size="5" value="0" disabled="disabled"/>
<h:outputLabel value="#{i18n['shop.cashBack']}" />
<input id="returnval" type="text" size="5" value="0" disabled="disabled"/>
<h:outputLabel value="#{i18n['shop.afterBalance']}" />
<h:outputText value=" #{productShopView.balanceAfterTransaction}">
<f:convertNumber />
</div>
</h:commandLink>
</ui:repeat>
</div>
</h:panelGroup>
<h:panelGroup>
<reader:barcode selectaction="#{productShopView.readBarcode}" selectvalue="#{i18n['shop.readBarcode']}" />
<br />
<p:dataTable id="prods" value="#{productShopView.boughtItems}" var="prods">
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['shop.count']}" />
</f:facet>
<p:inplace>
<p:inputText value="#{prods.count}" size="4">
<f:ajax event="valueChange" render="@form" />
<f:convertNumber minFractionDigits="0" maxFractionDigits="2" />
</p:inputText>
</p:inplace>
</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>
</h:panelGrid>
<h:commandButton action="#{productShopView.commitShoppingCart()}" value="#{i18n['shop.buy']}" />
</h:panelGroup>
</p:column>
<p:column>
<f:facet name="header">
<h:outputText value="#{i18n['shop.actions']}" />
</f:facet>
<p:commandButton action="#{productShopView.removeBought()}" update="@form" value="Poista" />
</p:column>
</p:dataTable>
<div style="font-weight: bold;">
<h:outputText value="#{i18n['shop.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 id="currentbalance" value="#{productShopView.accountCredits}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>
<br />
<h:outputLabel value="#{i18n['shop.transactionTotal']}" />
<h:outputText id="transactiontotal" value="#{productShopView.transactionTotal}">
<f:convertNumber maxFractionDigits="2" minFractionDigits="2" />
</h:outputText>
</div>
<h:panelGrid columns="2">
<h:outputLabel value="#{i18n['shop.toAccountValue']}" />
<h:inputText styleClass="inputval" size="5" value="#{productShopView.cash}">
<f:ajax render="@form" event="valueChange" listener="#{productShopView.cashChanged}" />
</h:inputText>
</h:panelGrid>
<p:commandButton update="@form" action="#{productShopView.buyByCredit()}" value="#{i18n['shop.buyByCredit']}" />
<h:panelGrid columns="2" style="background-color: #{productShopView.balanceAfterTransaction lt 0?'lightcoral':'lightgreen'}">
<h:outputLabel value="#{i18n['shop.afterBalance']}" />
<h:outputText value="#{productShopView.balanceAfterTransaction}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText>
</h:panelGrid>
<h:outputScript library="primefaces" name="jquery/jquery.js" />
<p:commandButton ajax="false" action="#{productShopView.commitShoppingCart()}" value="#{i18n['shop.buy']}" />
</h:panelGroup>
</h:panelGrid>
<h:outputScript library="primefaces" name="jquery/jquery.js" />
</h:form>
<script>
var blipSnd = new Audio(
"#{request.contextPath}/resources/media/blip.mp3")
</h:form>
<script>
var blipSnd = new Audio(
"#{request.contextPath}/resources/media/blip.mp3")
$(function() {
$("#shoppingcartform\\:barcode").focus();
$(function() {
$("#shoppingcartform\\:barcode").focus();
});
});
function blip() {
blipSnd.play();
}
function blip() {
blipSnd.play();
}
function calc() {
$("#returnval").val($("#inputval").val() - $(".inputval").text().replace(",","."));
}
function calc() {
$("#returnval").val(
$("#inputval").val()
- $(".inputval").text().replace(",", "."));
}
function barcodeReadEvent(data) {
if (data.status == "success") {
$("[id$=shoppingcartform\\:barcode]").focus();
}
}
</script>
function barcodeReadEvent(data) {
if (data.status == "success") {
$("[id$=shoppingcartform\\:barcode]").focus();
}
}
</script>
</composite:implementation>
</composite:implementation>
</html>
......@@ -822,29 +822,31 @@ salespoint.noSalesPoints = Amount
sendPicture.header = S
shop.accountBalance = Credits
shop.actions = Actions
shop.afterBalance = Balance after action
shop.barcode = Barcode
shop.buy = Buy
shop.buyCash = Buy by Cash
shop.buyCredit = Buy Credit
shop.calcsubtotal = Calc Subtotal
shop.cartPrice = Cart price
shop.cash = Cash
shop.cashBack = Back
shop.cashGiven = Cash given
shop.cashback = Cashback
shop.confirmCreditBuy = Are You sure ?
shop.count = Q
shop.currentBalance = Current balance
shop.price = price
shop.product = Product
shop.readBarcode = Read
shop.shop = Shop
shop.totalPrice = Total
shop.transactionTotal = Transaction total
shop.user = Selling to
shop.accountBalance = Credits
shop.actions = Actions
shop.afterBalance = Balance after action
shop.barcode = Barcode
shop.buy = Buy
shop.buyByCredit = Buy by credit
shop.buyCash = Buy by Cash
shop.buyCredit = Buy Credit
shop.calcsubtotal = Calc Subtotal
shop.cartPrice = Cart price
shop.cash = Cash
shop.cashBack = Back
shop.cashGiven = Cash given
shop.cashback = Cashback
shop.confirmCreditBuy = Are You sure ?
shop.count = Q
shop.currentBalance = Current balance
shop.price = price
shop.product = Product
shop.readBarcode = Read
shop.shop = Shop
shop.shoppingcartCommitted = Products bought
shop.totalPrice = Total
shop.transactionTotal = Transaction total
shop.user = Selling to
sidebar.bill.list = My bills
sidebar.bill.listAll = All bills
......
......@@ -805,29 +805,31 @@ salespoint.noSalesPoints = M\u00E4\u00E4r\u00E4
sendPicture.header = L\u00E4het\u00E4 kuva
shop.accountBalance = Credits
shop.actions = Hallinta
shop.afterBalance = Saldo tapahtuman j\u00E4lkeen
shop.barcode = Viivakoodi
shop.buy = Osta
shop.buyCash = K\u00E4teismaksu
shop.buyCredit = Credit
shop.calcsubtotal = Laske v\u00E4lisumma
shop.cartPrice = Korin hinta
shop.cash = K\u00E4teinen
shop.cashBack = Vaihtoraha palautettu
shop.cashGiven = K\u00E4teist\u00E4 saatu
shop.cashback = Takaisin
shop.confirmCreditBuy = Varmastikko ?
shop.count = Lkm
shop.currentBalance = T\u00E4m\u00E4nhetkinen saldo
shop.price = Hinta
shop.product = Tuote
shop.readBarcode = Lue
shop.toAccountValue = Tilille
shop.totalPrice = Yhteens\u00E4
shop.transactionTotal = Tapahtuma yhteens\u00E4
shop.user = Myyd\u00E4\u00E4n
shop.accountBalance = Credits
shop.actions = Hallinta
shop.afterBalance = Saldo tapahtuman j\u00E4lkeen
shop.barcode = Viivakoodi
shop.buy = Osta
shop.buyByCredit = Maksa krediiteill\u00E4.
shop.buyCash = K\u00E4teismaksu
shop.buyCredit = Credit
shop.calcsubtotal = Laske v\u00E4lisumma
shop.cartPrice = Korin hinta
shop.cash = K\u00E4teinen
shop.cashBack = Vaihtoraha palautettu
shop.cashGiven = K\u00E4teist\u00E4 saatu
shop.cashback = Takaisin
shop.confirmCreditBuy = Varmastikko ?
shop.count = Lkm
shop.currentBalance = T\u00E4m\u00E4nhetkinen saldo
shop.price = Hinta
shop.product = Tuote
shop.readBarcode = Lue
shop.shoppingcartCommitted = Tuotteet ostettu
shop.toAccountValue = Tilille
shop.totalPrice = Yhteens\u00E4
shop.transactionTotal = Tapahtuma yhteens\u00E4
shop.user = Myyd\u00E4\u00E4n
sidebar.bill.list = Omat laskut
sidebar.bill.listAll = Kaikki laskut
......
......@@ -132,7 +132,6 @@ public class FoodWaveFoodView extends GenericCDIView {
* @return
*/
public Bill createBillFromShoppingcart() {
logger.warn("Committing shoppingcart for user {}, userid {}", userview.getSelectedUser().getWholeName());
Bill bill = new Bill(eventBean.getCurrentEvent(), userview.getSelectedUser());
bill.setOurReference(eventBean.getCurrentEvent().getName());
......@@ -141,11 +140,11 @@ public class FoodWaveFoodView extends GenericCDIView {
bill.addProduct(shopitem.getProduct(), shopitem.getCount(), getFoodWave());
}
}
logger.warn("Committing shoppingcart for user {}. Cart prize: {}", userview.getSelectedUser().getWholeName(), bill.getTotalPrice());
billBean.createBill(bill);
// TODO: do this right way
// TODO: do this the right way
eventBean.flushCache();
return bill;
......
......@@ -84,6 +84,13 @@ public class ProductShopView extends GenericCDIView {
private boolean allowStatistics = true;
private String otherInfo;
public String buyByCredit()
{
cash = BigDecimal.ZERO;
payInstant = false;
return null;
}
public void initBillView() {
if (requirePermissions(ShopPermission.LIST_USERPRODUCTS)
&& shoppingcart == null) {
......@@ -136,8 +143,7 @@ public class ProductShopView extends GenericCDIView {
updateCartLimits(null);
LanEventProperty cashdefault = eventbean.getProperty(LanEventPropertyKey.SHOP_DEFAULT_CASH);
if (cashdefault == null || cashdefault.isBooleanValue())
{
if (cashdefault == null || cashdefault.isBooleanValue()) {
payInstant = true;
}
......@@ -292,7 +298,7 @@ public class ProductShopView extends GenericCDIView {
addFaceMessage("productshop.billCreated");
cash = BigDecimal.ZERO;
shoppingcart = null;
billEditView.setBill(bill);
boughtItems = null;
return "showCreatedBill";
......@@ -314,21 +320,21 @@ public class ProductShopView extends GenericCDIView {
EventUser retuser = null;
for (ProductShopItem shopitem : shoppingcart) {
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) {
Product credProd = productBean.findCreditProduct();
retuser = productBean.createAccountEvent(credProd, cash, user)
.getUser();
retuser = productBean.createAccountEvent(credProd, cash, user).getUser();
}
if (retuser != null) {
user = retuser;
}
shoppingcart = null;
boughtItems = null;
cash = BigDecimal.ZERO;
super.addFaceMessage("shop.shoppingcartCommitted");
return null;
}
......
......@@ -94,7 +94,12 @@ public class LayoutView {
}
public String getPagepath() {
if (pagename == null) {
if (pagename == null &&
context != null &&
context.getExternalContext() != null &&
context.getExternalContext().getRequest() != null &&
context.getExternalContext().getRequest() instanceof HttpServletRequest) {
HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest();
String[] splitted = req.getServletPath().split("\\.");
if (splitted.length > 0) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!