<%--
  % This Javer Server Page is part of the iX JSP tutorial.
  % The user can choose a pizza plus some additional 
  % ingredients
 --%>


<%-- Setting up an error page --%>
<%@ page errorPage="/jspTutorial/errorpage.jsp" %>
<%@ taglib uri="/ixtaglib" prefix="jsptut" %>


<%-- import needed java classes --%>	 
<%@ page import="java.util.*" %>
<%@ page import="java.text.*" %>
<%@ page import="de.ix.jspTutorial.model.Customer" %>
<%@ page import="de.ix.jspTutorial.model.Pizza" %>
<%@ page import="de.ix.jspTutorial.model.PizzaList" %>
<%@ page import="de.ix.jspTutorial.model.Ingredient" %>
<%@ page import="de.ix.jspTutorial.model.IngredientList" %>


<%-- initialize pizza list --%>
<jsp:useBean
     id="pizzaList"
     class="de.ix.jspTutorial.model.PizzaList"
	 scope="session"
   >

   <%
     pizzaList.readList(application);
   %>
 </jsp:useBean>


<%-- initialize ingredient list --%>
<jsp:useBean
     id="ingredientList"
     class="de.ix.jspTutorial.model.IngredientList"
	 scope="session"
   >

   <%
     ingredientList.readList(application);
   %>
 </jsp:useBean>

<jsp:useBean
     id    = "pizzaModelManager"
     class = "de.ix.jspTutorial.controller.ModelManager"
     scope = "session"
   />

<% Customer customer = pizzaModelManager.getCustomer();
   if(customer == null)
      throw new ServletException("No Customer") ;
   pageContext.setAttribute("Customer",customer) ;
%>
 
<HTML>
<HEAD>
	<TITLE>PIZZA SERVICE ONLINE - CHOICE</TITLE>
</HEAD>

<BODY BGCOLOR="#FFFFFF" LINK="#406E6E" ALINK="#406E6E" VLINK="#406E6E">
<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
<TR VALIGN="top">
	<TD WIDTH="115"><A HREF="index.jsp"><IMG SRC="logo.gif" WIDTH="115" HEIGHT="115" ALT="" BORDER="0"></A></TD>
	<TD WIDTH="50">&nbsp;</TD>
	<TD WIDTH="500"><FONT FACE="Arial,Helvetica" SIZE="2">
		
	<FONT SIZE="5" COLOR="#406E6E"><B><I>Pizza ausw&auml;hlen</I></B></FONT><BR>	
	
	<BR>
	<FONT SIZE="2">
	Hallo <jsp:getProperty name="Customer" property="firstname" /> <jsp:getProperty name="Customer" property="lastname" /> <BR>
	<BR> 
	bitte w&auml;hlen Sie aus unserem reichhaltigen Angebot eine Pizza und gewünschte Beilagen aus.<BR>
	<BR>
	
	<!-- <FORM ACTION="order.jsp" METHOD="post"> -->
	
	<FORM ACTION="PizzaServiceFC.jsp" METHOD="post">
	<INPUT NAME="doAction" TYPE="hidden" VALUE="choice">		
	
	<FONT COLOR="#406E6E"><B><I>Grundpizza:</I></B></FONT><BR>
	<BR>
	
	<!-- Table for choice of pizza -->
	<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
	<TR BGCOLOR="#406E6E">
		<TD WIDTH="150"><FONT FACE="Arial,Helvetica" SIZE="2" COLOR="#FFFFFF">&nbsp;Name</TD>
		<TD WIDTH="150"><FONT FACE="Arial,Helvetica" SIZE="2" COLOR="#FFFFFF">&nbsp;Größe</TD>
		<TD WIDTH="100"><FONT FACE="Arial,Helvetica" SIZE="2" COLOR="#FFFFFF">&nbsp;Preis</TD>
		<TD WIDTH="75"><FONT FACE="Arial,Helvetica" SIZE="2" COLOR="#FFFFFF">&nbsp;</TD>		
	</TR>
	
		
 <jsptut:foreach item="Pizza"  list="<%= pizzaList.getPizzas() %>" >
 <%     
     Pizza pizza = (Pizza)pageContext.findAttribute("Pizza"); 
  %>
		<TR>
			<TD><FONT FACE="Arial,Helvetica" SIZE="2">&nbsp;<jsp:getProperty name="Pizza" property="name" /></TD>
			<TD><FONT FACE="Arial,Helvetica" SIZE="2">&nbsp;<jsp:getProperty name="Pizza" property="size" /></TD>
			<TD><FONT FACE="Arial,Helvetica" SIZE="2">&nbsp;DM&nbsp;<jsptut:currency value="<%=pizza.getBasePrice()%>"/></TD>
			<TD><FONT FACE="Arial,Helvetica" SIZE="2"><INPUT NAME="ID_PIZZA" TYPE="radio" VALUE="<jsp:getProperty name="Pizza" property="id" />"></TD>
		</TR>
	</jsptut:foreach>
	
	
	</TABLE>
	<BR>
	<BR>
	<FONT COLOR="#406E6E"><B><I>Zutaten:</I></B></FONT><BR>
	<BR>
	<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
	<TR VALIGN="top">
		<TD>
			<!-- Table for choice of ingrediens -->	

 			<TABLE BORDER="0" CELLPADDING="0" CELLSPACING="0">
			
			<TR BGCOLOR="#406E6E">
				<TD WIDTH="150"><FONT FACE="Arial,Helvetica" SIZE="2" COLOR="#FFFFFF">&nbsp;Name</TD>
				<TD WIDTH="100"><FONT FACE="Arial,Helvetica" SIZE="2" COLOR="#FFFFFF">&nbsp;Preis</TD>
				<TD WIDTH="50"><FONT FACE="Arial,Helvetica" SIZE="2" COLOR="#FFFFFF">&nbsp;</TD>		
			</TR>
			
<jsptut:foreach item="Ingredient"  list="<%= ingredientList.getIngredients() %>" >
    <%  
    Ingredient ingredient = (Ingredient)pageContext.findAttribute("Ingredient") ;
    %>
				<TR>
					<TD><FONT FACE="Arial,Helvetica" SIZE="2">&nbsp;<jsp:getProperty name="Ingredient" property="name"/></TD>
					<TD><FONT FACE="Arial,Helvetica" SIZE="2">&nbsp;DM&nbsp;<jsptut:currency value="<%=ingredient.getPrice()%>"/></TD>
					<TD><FONT FACE="Arial,Helvetica" SIZE="2"><INPUT NAME="ID_INGREDIENTS" TYPE="checkbox" VALUE="<jsp:getProperty name="Ingredient" property="id"/>"></TD>	
				</TR>
 </jsptut:foreach>
				
			</TR>		
			</TABLE>		
			<BR>
			<BR>
			<INPUT TYPE="submit" VALUE="Weiter &gt;&gt;">
		</TD>
		<TD WIDTH="25">&nbsp;</TD>
		<TD><IMG SRC="pizza.jpg" WIDTH="152" HEIGHT="141" ALT="Pizza" BORDER="0"></TD>		
	</TR>
	</TABLE>
	</FORM>
	<%@ include file="/jspTutorial/includes/copyright.html"%>
	</FONT></TD>
</TR>
</TABLE>
</BODY>
</HTML>