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