Commit e999a1c9 by Tuomas Riihimäki

Random fixes..

1 parent 22894aca
...@@ -58,16 +58,15 @@ ...@@ -58,16 +58,15 @@
<f:param name="eventid" value="#{event.id}" /> <f:param name="eventid" value="#{event.id}" />
</h:link> </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}" /> <f:param name="userid" value="#{event.printedCard.user.user.id}" />
</h:link> </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']}"> <h:link rendered="#{empty event.printedCard}" outcome="/shop/assocToUser" value="#{i18n['readerevent.associateToUser']}">
<f:param name="eventid" value="#{event.id}" /> <f:param name="eventid" value="#{event.id}" />
</h:link> --> </h:link>
</h:column> </h:column>
</h:dataTable> </h:dataTable>
......
<?xml version='1.0' encoding='UTF-8' ?> <?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> "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" <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: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:ui="http://java.sun.com/jsf/facelets" xmlns:c="http://java.sun.com/jsp/jstl/core" xmlns:reader="http://java.sun.com/jsf/composite/cditools/reader" xmlns:p="http://primefaces.org/ui">
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:interface> <composite:implementation>
</composite:interface>
<composite:implementation> <h:form id="shoppingcartform">
<h:form id="shoppingcartform">
<h:panelGrid columns="2" style="width:100%;" columnClasses="shopProductbuttons,topalign"> <h:panelGrid columns="2" style="width:100%;" columnClasses="shopProductbuttons,topalign">
<h:panelGroup> <h:panelGroup>
...@@ -97,24 +92,24 @@ ...@@ -97,24 +92,24 @@
</div> </div>
<h:panelGrid columns="2" > <h:panelGrid columns="2">
<h:outputLabel value="#{i18n['shop.toAccountValue']}" /> <h:outputLabel value="#{i18n['shop.toAccountValue']}" />
<h:inputText styleClass="inputval" size="5" value="#{productShopView.cash}"> <h:inputText styleClass="inputval" size="5" value="#{productShopView.cash}">
<f:ajax render="@form" event="valueChange" listener="#{productShopView.cashChanged}" /> <f:ajax render="@form" event="valueChange" listener="#{productShopView.cashChanged}" />
</h:inputText> </h:inputText>
</h:panelGrid>
<h:outputLabel value="#{i18n['shop.cashGiven']}" /> <p:commandButton update="@form" action="#{productShopView.buyByCredit()}" value="#{i18n['shop.buyByCredit']}" />
<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:panelGrid columns="2" style="background-color: #{productShopView.balanceAfterTransaction lt 0?'lightcoral':'lightgreen'}">
<h:outputLabel value="#{i18n['shop.afterBalance']}" /> <h:outputLabel value="#{i18n['shop.afterBalance']}" />
<h:outputText value=" #{productShopView.balanceAfterTransaction}"> <h:outputText value="#{productShopView.balanceAfterTransaction}">
<f:convertNumber /> <f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText> </h:outputText>
</h:panelGrid> </h:panelGrid>
<h:commandButton action="#{productShopView.commitShoppingCart()}" value="#{i18n['shop.buy']}" />
<p:commandButton ajax="false" action="#{productShopView.commitShoppingCart()}" value="#{i18n['shop.buy']}" />
</h:panelGroup> </h:panelGroup>
</h:panelGrid> </h:panelGrid>
...@@ -136,11 +131,11 @@ ...@@ -136,11 +131,11 @@
} }
function calc() { function calc() {
$("#returnval").val($("#inputval").val() - $(".inputval").text().replace(",",".")); $("#returnval").val(
$("#inputval").val()
- $(".inputval").text().replace(",", "."));
} }
function barcodeReadEvent(data) { function barcodeReadEvent(data) {
if (data.status == "success") { if (data.status == "success") {
$("[id$=shoppingcartform\\:barcode]").focus(); $("[id$=shoppingcartform\\:barcode]").focus();
...@@ -149,6 +144,6 @@ ...@@ -149,6 +144,6 @@
</script> </script>
</composite:implementation> </composite:implementation>
</html> </html>
...@@ -827,6 +827,7 @@ shop.actions = Actions ...@@ -827,6 +827,7 @@ shop.actions = Actions
shop.afterBalance = Balance after action shop.afterBalance = Balance after action
shop.barcode = Barcode shop.barcode = Barcode
shop.buy = Buy shop.buy = Buy
shop.buyByCredit = Buy by credit
shop.buyCash = Buy by Cash shop.buyCash = Buy by Cash
shop.buyCredit = Buy Credit shop.buyCredit = Buy Credit
shop.calcsubtotal = Calc Subtotal shop.calcsubtotal = Calc Subtotal
...@@ -842,6 +843,7 @@ shop.price = price ...@@ -842,6 +843,7 @@ shop.price = price
shop.product = Product shop.product = Product
shop.readBarcode = Read shop.readBarcode = Read
shop.shop = Shop shop.shop = Shop
shop.shoppingcartCommitted = Products bought
shop.totalPrice = Total shop.totalPrice = Total
shop.transactionTotal = Transaction total shop.transactionTotal = Transaction total
shop.user = Selling to shop.user = Selling to
......
...@@ -810,6 +810,7 @@ shop.actions = Hallinta ...@@ -810,6 +810,7 @@ shop.actions = Hallinta
shop.afterBalance = Saldo tapahtuman j\u00E4lkeen shop.afterBalance = Saldo tapahtuman j\u00E4lkeen
shop.barcode = Viivakoodi shop.barcode = Viivakoodi
shop.buy = Osta shop.buy = Osta
shop.buyByCredit = Maksa krediiteill\u00E4.
shop.buyCash = K\u00E4teismaksu shop.buyCash = K\u00E4teismaksu
shop.buyCredit = Credit shop.buyCredit = Credit
shop.calcsubtotal = Laske v\u00E4lisumma shop.calcsubtotal = Laske v\u00E4lisumma
...@@ -824,6 +825,7 @@ shop.currentBalance = T\u00E4m\u00E4nhetkinen saldo ...@@ -824,6 +825,7 @@ shop.currentBalance = T\u00E4m\u00E4nhetkinen saldo
shop.price = Hinta shop.price = Hinta
shop.product = Tuote shop.product = Tuote
shop.readBarcode = Lue shop.readBarcode = Lue
shop.shoppingcartCommitted = Tuotteet ostettu
shop.toAccountValue = Tilille shop.toAccountValue = Tilille
shop.totalPrice = Yhteens\u00E4 shop.totalPrice = Yhteens\u00E4
shop.transactionTotal = Tapahtuma yhteens\u00E4 shop.transactionTotal = Tapahtuma yhteens\u00E4
......
...@@ -132,7 +132,6 @@ public class FoodWaveFoodView extends GenericCDIView { ...@@ -132,7 +132,6 @@ public class FoodWaveFoodView extends GenericCDIView {
* @return * @return
*/ */
public Bill createBillFromShoppingcart() { public Bill createBillFromShoppingcart() {
logger.warn("Committing shoppingcart for user {}, userid {}", userview.getSelectedUser().getWholeName());
Bill bill = new Bill(eventBean.getCurrentEvent(), userview.getSelectedUser()); Bill bill = new Bill(eventBean.getCurrentEvent(), userview.getSelectedUser());
bill.setOurReference(eventBean.getCurrentEvent().getName()); bill.setOurReference(eventBean.getCurrentEvent().getName());
...@@ -141,11 +140,11 @@ public class FoodWaveFoodView extends GenericCDIView { ...@@ -141,11 +140,11 @@ public class FoodWaveFoodView extends GenericCDIView {
bill.addProduct(shopitem.getProduct(), shopitem.getCount(), getFoodWave()); bill.addProduct(shopitem.getProduct(), shopitem.getCount(), getFoodWave());
} }
} }
logger.warn("Committing shoppingcart for user {}. Cart prize: {}", userview.getSelectedUser().getWholeName(), bill.getTotalPrice());
billBean.createBill(bill); billBean.createBill(bill);
// TODO: do this the right way
// TODO: do this right way
eventBean.flushCache(); eventBean.flushCache();
return bill; return bill;
......
...@@ -84,6 +84,13 @@ public class ProductShopView extends GenericCDIView { ...@@ -84,6 +84,13 @@ public class ProductShopView extends GenericCDIView {
private boolean allowStatistics = true; private boolean allowStatistics = true;
private String otherInfo; private String otherInfo;
public String buyByCredit()
{
cash = BigDecimal.ZERO;
payInstant = false;
return null;
}
public void initBillView() { public void initBillView() {
if (requirePermissions(ShopPermission.LIST_USERPRODUCTS) if (requirePermissions(ShopPermission.LIST_USERPRODUCTS)
&& shoppingcart == null) { && shoppingcart == null) {
...@@ -136,8 +143,7 @@ public class ProductShopView extends GenericCDIView { ...@@ -136,8 +143,7 @@ public class ProductShopView extends GenericCDIView {
updateCartLimits(null); updateCartLimits(null);
LanEventProperty cashdefault = eventbean.getProperty(LanEventPropertyKey.SHOP_DEFAULT_CASH); LanEventProperty cashdefault = eventbean.getProperty(LanEventPropertyKey.SHOP_DEFAULT_CASH);
if (cashdefault == null || cashdefault.isBooleanValue()) if (cashdefault == null || cashdefault.isBooleanValue()) {
{
payInstant = true; payInstant = true;
} }
...@@ -292,7 +298,7 @@ public class ProductShopView extends GenericCDIView { ...@@ -292,7 +298,7 @@ public class ProductShopView extends GenericCDIView {
addFaceMessage("productshop.billCreated"); addFaceMessage("productshop.billCreated");
cash = BigDecimal.ZERO; cash = BigDecimal.ZERO;
shoppingcart = null; shoppingcart = null;
billEditView.setBill(bill); boughtItems = null;
return "showCreatedBill"; return "showCreatedBill";
...@@ -314,21 +320,21 @@ public class ProductShopView extends GenericCDIView { ...@@ -314,21 +320,21 @@ 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(), retuser = productBean.createAccountEvent(shopitem.getProduct(), shopitem.getCount(), user).getUser();
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) retuser = productBean.createAccountEvent(credProd, cash, user).getUser();
.getUser();
} }
if (retuser != null) { if (retuser != null) {
user = retuser; user = retuser;
} }
shoppingcart = null; shoppingcart = null;
boughtItems = null;
cash = BigDecimal.ZERO; cash = BigDecimal.ZERO;
super.addFaceMessage("shop.shoppingcartCommitted");
return null; return null;
} }
......
...@@ -94,7 +94,12 @@ public class LayoutView { ...@@ -94,7 +94,12 @@ public class LayoutView {
} }
public String getPagepath() { 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(); HttpServletRequest req = (HttpServletRequest) context.getExternalContext().getRequest();
String[] splitted = req.getServletPath().split("\\."); String[] splitted = req.getServletPath().split("\\.");
if (splitted.length > 0) { 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!