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"
<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:interface>
</composite:interface>
<composite:implementation>
<composite:implementation>
<h:form id="shoppingcartform">
<h:form id="shoppingcartform">
<h:panelGrid columns="2" style="width:100%;" columnClasses="shopProductbuttons,topalign">
<h:panelGroup>
......@@ -97,24 +92,24 @@
</div>
<h:panelGrid columns="2" >
<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>
<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"/>
<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 />
<h:outputText value="#{productShopView.balanceAfterTransaction}">
<f:convertNumber minFractionDigits="2" maxFractionDigits="2" />
</h:outputText>
</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:panelGrid>
......@@ -136,11 +131,11 @@
}
function calc() {
$("#returnval").val($("#inputval").val() - $(".inputval").text().replace(",","."));
$("#returnval").val(
$("#inputval").val()
- $(".inputval").text().replace(",", "."));
}
function barcodeReadEvent(data) {
if (data.status == "success") {
$("[id$=shoppingcartform\\:barcode]").focus();
......@@ -149,6 +144,6 @@
</script>
</composite:implementation>
</composite:implementation>
</html>
......@@ -827,6 +827,7 @@ 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
......@@ -842,6 +843,7 @@ 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
......
......@@ -810,6 +810,7 @@ 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
......@@ -824,6 +825,7 @@ 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
......
......@@ -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!