+confirmation and thank-you
This commit is contained in:
parent
a53cccc52e
commit
0f763413e9
@ -2,6 +2,7 @@ package de.hsel.itech.jsf;
|
|||||||
|
|
||||||
import de.hsel.itech.db.Database;
|
import de.hsel.itech.db.Database;
|
||||||
import de.hsel.itech.db.pojo.Book;
|
import de.hsel.itech.db.pojo.Book;
|
||||||
|
import de.hsel.itech.db.pojo.OrderItem;
|
||||||
import de.hsel.itech.db.pojo.ShoppingCartItem;
|
import de.hsel.itech.db.pojo.ShoppingCartItem;
|
||||||
import de.hsel.itech.db.pojo.User;
|
import de.hsel.itech.db.pojo.User;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -57,19 +58,37 @@ public class CartBean {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
public void setItems(List<ShoppingCartItem> list) {
|
public void setItems(List<ShoppingCartItem> list) {
|
||||||
|
|
||||||
|
}*/
|
||||||
|
|
||||||
|
public String buy(){
|
||||||
|
ArrayList<OrderItem> orderList = new ArrayList<>();
|
||||||
|
for(ShoppingCartItem item : getItems()){
|
||||||
|
orderList.add(new OrderItem(item.getArticle(),item.getCount()));
|
||||||
|
}
|
||||||
|
//Database.getInstance().order().insert(new Order(getUser(),orderList, new Date(234235235),sum(),null,null));
|
||||||
|
for(ShoppingCartItem item : getItems()) {
|
||||||
|
Database.getInstance().shoppingCart().delete(item);
|
||||||
|
}
|
||||||
|
return "thanks.jsp";
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getItemCount(){
|
public int getItemCount(){
|
||||||
return getItems().size();
|
return getItems().size();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSum(){
|
public long sum(){
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
for(ShoppingCartItem item : getItems()){
|
for(ShoppingCartItem item : getItems()){
|
||||||
sum += item.getCount() * item.getArticle().getPrice();
|
sum += item.getCount() * item.getArticle().getPrice();
|
||||||
}
|
}
|
||||||
|
return sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getSum(){
|
||||||
|
long sum = sum();
|
||||||
String res = "";
|
String res = "";
|
||||||
res += sum / 100;
|
res += sum / 100;
|
||||||
res += ",";
|
res += ",";
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
|
|
||||||
<div class="m-row">
|
<div class="m-row">
|
||||||
<div class="m-col-t-4 m-push-t-4 m-button m-success">
|
<div class="m-col-t-4 m-push-t-4 m-button m-success">
|
||||||
<a href="#">Jetzt Kaufen</a>
|
<a href="confirmation.jsf">Jetzt Kaufen</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
67
src/main/webapp/confirmation.xhtml
Normal file
67
src/main/webapp/confirmation.xhtml
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
<?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://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||||
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
<f:view>
|
||||||
|
<ui:composition template="template.xhtml">
|
||||||
|
<ui:define name="content">
|
||||||
|
<div class="m-row">
|
||||||
|
<h1 class="m-text-center">Bestellbestätigung</h1>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="m-row">
|
||||||
|
<div class="m-col-t-3 m-block">
|
||||||
|
<h4>Addresse:</h4>
|
||||||
|
Max Mustermann<br/>
|
||||||
|
Musterstraße 42<br/>
|
||||||
|
12345 Musterstadt
|
||||||
|
</div>
|
||||||
|
<div class="m-col-t-4 m-block m-push-t-5">
|
||||||
|
<h4>Konto</h4>
|
||||||
|
IBAN: 12345••••••••••••••••••••••••111<br/>
|
||||||
|
Inhaber: Max Mustermann<br/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<ui:repeat value="#{cartBean.items}" var="item">
|
||||||
|
|
||||||
|
|
||||||
|
<div class="m-row m-block">
|
||||||
|
<div class="m-col-t-4">
|
||||||
|
<img src="https://source.unsplash.com/#{item.article.image}/100x100" class="m-image" alt="Buchcover"/>
|
||||||
|
</div>
|
||||||
|
<div class="m-col-t-4">
|
||||||
|
<h3>#{item.article.title}</h3>
|
||||||
|
</div>
|
||||||
|
<div class="m-col-t-4">
|
||||||
|
<h4 class="m-text-right">#{item.count} x #{item.article.priceString}€</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ui:repeat>
|
||||||
|
|
||||||
|
|
||||||
|
<h:panelGroup type="block" styleClass="m-row">
|
||||||
|
<div class="m-col-t-5 m-push-t-7">
|
||||||
|
<h1 class="m-text-right">Summe: #{cartBean.sum}€</h1>
|
||||||
|
</div>
|
||||||
|
</h:panelGroup>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="m-row">
|
||||||
|
<div class="m-col-t-3 m-push-t-3 m-button m-danger">
|
||||||
|
<a href="cart.jsf">Abbrechen</a>
|
||||||
|
</div>
|
||||||
|
<div class="m-col-t-3 m-push-t-3 m-button m-success">
|
||||||
|
<h:form>
|
||||||
|
<h:commandLink action="#{cartBean.buy}">Bestätigen</h:commandLink>
|
||||||
|
</h:form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</ui:define>
|
||||||
|
</ui:composition>
|
||||||
|
</f:view>
|
||||||
|
</html>
|
21
src/main/webapp/thanks.xhtml
Normal file
21
src/main/webapp/thanks.xhtml
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
<?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://xmlns.jcp.org/jsf/html"
|
||||||
|
xmlns:ui="http://xmlns.jcp.org/jsf/facelets"
|
||||||
|
xmlns:f="http://xmlns.jcp.org/jsf/core">
|
||||||
|
<f:view>
|
||||||
|
<ui:composition template="template.xhtml">
|
||||||
|
<ui:define name="content">
|
||||||
|
<div class="m-container">
|
||||||
|
<div class="m-row">
|
||||||
|
<h2 class="m-col-t-5 m-push-t-4">
|
||||||
|
Vielen Dank für Ihren Einkauf!
|
||||||
|
</h2>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</ui:define>
|
||||||
|
</ui:composition>
|
||||||
|
</f:view>
|
||||||
|
</html>
|
Loading…
Reference in New Issue
Block a user