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