]> git.mxchange.org Git - pizzaservice-war.git/blob - web/index.jsp
Continued with project:
[pizzaservice-war.git] / web / index.jsp
1 <%-- 
2         Document   : index
3         Created on : 04.08.2015, 10:33:10
4         Author     : Roland Haeder
5 --%>
6
7 <%--<%@page errorPage="errorHandler.jsp" %>--%>
8 <%@page import="java.util.Map"%>
9 <%@page import="java.util.Iterator"%>
10 <%@page import="org.mxchange.pizzaapplication.application.PizzaApplication"%>
11 <%@page import="org.mxchange.pizzaapplication.beans.PizzaBean"%>
12 <%@page import="org.mxchange.pizzaapplication.product.Product"%>
13 <%@page import="org.mxchange.pizzaapplication.basket.Basket"%>
14 <%@page import="org.mxchange.pizzaapplication.item.basket.BasketItem"%>
15 <%@page import="org.mxchange.pizzaapplication.item.AddableBasketItem"%>
16 <%@page contentType="text/html" pageEncoding="UTF-8"%>
17 <%@taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
18 <%@taglib prefix="basket" uri="http://mxchange.org/pizza-service/tags/basket" %>
19 <jsp:useBean id="controller" scope="session" class="org.mxchange.pizzaapplication.beans.PizzaServiceBean" type="org.mxchange.pizzaapplication.beans.PizzaBean" />
20
21 <jsp:setProperty name="controller" property="application" value="${pageContext.servletContext}" />
22 <jsp:setProperty name="controller" property="basket" value="${basket}" />
23 <%controller.init();%>
24
25 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
26 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="de" lang="de">
27         <head>
28                 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
29                 <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" type="text/css"/>
30                 <title>Pizza-Service - Willkommen</title>
31         </head>
32
33         <body>
34                 <div id="header"> 
35                         <div id="title">
36                                 <h1>Pizza-Service - Willkommen</h1>
37                         </div>
38                 </div>
39
40                 <jsp:include page="/static/guest/guest_menu.jsp" flush="false" />
41
42                 <div id="content_outer">
43                         <div id="content_title">
44                                 <h2>Folgendes kann bestellt werden:</h2>
45                         </div>
46
47                         <div id="content">
48                                 <basket:mini_basket basket="${basket}" />
49
50                                 <table class="table">
51                                         <tr>
52                                                 <th class="table_header_column">
53                                                         Bestellen?
54                                                 </th>
55                                                 <th class="table_header_column">
56                                                         Anzahl:
57                                                 </th>
58                                                 <th class="table_header_column">
59                                                         Produkt:
60                                                 </th>
61                                                 <th class="table_header_column">
62                                                         Einzelpreis:
63                                                 </th>
64                                         </tr>
65                                 </table>
66
67                                 <%
68                                 // Get Iterator
69                                 Iterator<Product> iterator = controller.getAvailableProducts();
70
71                                 // "Walk" through all products and unmark them as ordered
72                                 while (iterator.hasNext()) {
73                                         // Get product instance
74                                         Product product = iterator.next();
75
76                                         // Debug message
77                                         product.getLogger().debug("product.itemId=" + product.getItemId());
78
79                                         // Create an item instance form this product
80                                         AddableBasketItem item = controller.getBasket().getItem(product);
81
82                                         // Debug message
83                                         product.getLogger().debug("item=" + item);
84
85                                         // Has it been already added to the basket?
86                                         if (item != null) {
87                                                 // Some nice output ...
88                                                 %>
89                                 <table class="table">
90                                         <tbody>
91                                                         <tr>
92                                                                 <td class="table_data_column">
93                                                                         <a href="<%=request.getContextPath()%>/basket.jsp" title="Zum Warenkorb">Warenkorb</a>
94                                                                 </td>
95                                                                 <td class="table_data_column">
96                                                                         <%=item.getAmount()%>
97                                                                 </td>
98                                                                 <td class="table_data_column">
99                                                                         <%=product.getTitle()%>
100                                                                 </td>
101                                                                 <td class="table_data_column" align="right">
102                                                                         <fmt:formatNumber type="currency"><%=product.getPrice()%></fmt:formatNumber>
103                                                                 </td>
104                                                         </tr>
105                                         </tbody>
106                                 </table>
107                                                 <%
108                                                 // Then skip this item
109                                                 continue;
110                                         }
111                                         %>
112                                 <form action="<%=request.getContextPath()%>/form_handler/add_item.jsp" accept-charset="utf-8" id="form" method="post">
113                                 <table class="table">
114                                         <tbody>
115                                                         <tr>
116                                                                 <td class="table_data_column">
117                                                                         <input class="submit" type="submit" name="add" value="Hinzuf&uuml;gen" />
118                                                                         <input class="input" type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_ID%>" value="<%=product.getItemId()%>" />
119                                                                         <input class="input" type="hidden" name="<%=PizzaApplication.HTTP_PARAM_ITEM_TYPE%>" value="Product" />
120                                                                 </td>
121                                                                 <td class="table_data_column">
122                                                                         <input class="input" type="text" name="<%=PizzaApplication.HTTP_PARAM_AMOUNT%>" size="3" maxlength="20" />
123                                                                 </td>
124                                                                 <td class="table_data_column">
125                                                                         <%=product.getTitle()%>
126                                                                 </td>
127                                                                 <td class="table_data_column" align="right">
128                                                                         <fmt:formatNumber type="currency"><%=product.getPrice()%></fmt:formatNumber>
129                                                                 </td>
130                                                         </tr>
131                                         </tbody>
132                                 </table>
133                                 </form>
134                                 <%
135                         }
136                         %>
137                         </div>
138                 </div>
139
140                 <jsp:include page="/static/guest/guest_footer.jsp" flush="false" />
141         </body>
142 </html>