<%@ page language="java" %>
<!DOCTYPE HTML PUBLIC "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<title>Coffee Order</title>
</head>
<body bgcolor="#FFFFFF">



  <!--webbot bot="SaveResults" U-File="C:\340\_private\form_results.txt"
  S-Format="TEXT/CSV" S-Label-Fields="TRUE" -->
<%@ page import="JavaBeans.*"%>
<%@ page import="java.util.*"%>

<jsp:useBean id='customer_interface' scope='session' class='JavaBeans.Customer_Interface'/>

<jsp:useBean id='customer_data' scope='session' class='JavaBeans.Customer_Data'/>
<jsp:setProperty name='customer_data' property="*"/>

<jsp:useBean id='creditcard_data' scope='session' class='JavaBeans.CreditCard_Data'/>
<jsp:setProperty name='creditcard_data' property="*"/>

<jsp:useBean id='address_data' scope='session' class='JavaBeans.Address_Data'/>
<jsp:setProperty name='address_data' property="*"/>

<jsp:useBean id='coffeepreference_data' scope='session' class='JavaBeans.CoffeePreference_Data'/>
<jsp:setProperty name='coffeepreference_data' property="*"/>


<% customer_data = customer_interface.getCustomer();
address_data = customer_interface.getAddress();
if(!(request.getParameter("action").equals("Order")))
coffeepreference_data = customer_data.getPreference();
%>
<% if(request.getParameter("action").equals("Order")){
customer_data.setPreference(coffeepreference_data);
customer_interface.processRequest(request.getParameter("action"),customer_data,creditcard_data, address_data, coffeepreference_data);
}
%>
<%if(request.getParameter("action").equals("Update Account")){
customer_interface.processRequest(request.getParameter("action"),customer_data,creditcard_data, address_data, coffeepreference_data);
}
%>
 
<form method=POST action="order.jsp">
<table align="center" border="0" cellpadding="0" cellspacing="0">
	<tr>
		<td><p align="center"><img src="CoffeeBanner.gif"></p>
		</td>
	</tr>
	<tr>
		<td bgcolor=#F0F8FF><br><font face="Geneva, Arial, Helvetica, sans-serif"><p align="center"><font size="-1" face="Geneva, Arial, Helvetica, sans-serif">
		<p align="center"><font  size = "-1"><i><b>Welcome <%out.print(customer_data.getFirstName());%>.</b></i></font></p>
		<p align="center"><font  size = "-1"><i>Use this screen to order coffee, update your profile or increase your available balance.</i></font></p>
		<!--Please feel free to order a coffee, update your details or increase your remaining balance.<br><br></p-->
			</font>
		</td>
	</tr>
	<tr>
		<td align=left><font face="Geneva, Arial, Helvetica, sans-serif">
			<table align="center" border="0" cellpadding="0" cellspacing="0" width=100%>
				<td bgcolor=#ADD8E6><font face="Geneva, Arial, Helvetica, sans-serif" type="bold" size="-1">
				
					<!--% out.println("coffee description: " + coffee_data.getDescription());%-->
					<p align="center"><font  size = "-1"><i>Select the Coffee Preference and click order to place your order</i></font></p>
					<p align ="center">
				  <br><font face="Verdana" size="-1"><b>Flavour: </b><select size="1" name="description">
			      <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDescription().equals("Caffe Latte - small $2.80")) out.print("selected");}%>>Caffe Latte - small $2.80</option>
				  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDescription().equals("Caffe Latte - medium $3.30")) out.print("selected");}%>>Caffe Latte - medium $3.30</option>
				  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDescription().equals("Caffe Latte - large $3.60")) out.print("selected");}%>>Caffe Latte - large $3.60</option>
				  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDescription().equals("Cappuccino - small $2.50")) out.print("selected");}%>>Cappuccino - small $2.50</option>
				  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDescription().equals("Cappuccino - medium $3.50")) out.print("selected");}%>>Cappuccino - medium $3.50</option>
				  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDescription().equals("Cappuccino - large $4.50")) out.print("selected");}%>>Cappuccino - large $4.50</option>
				  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDescription().equals("Espresso - small $2.50")) out.print("selected");}%>>Espresso - small $2.50</option>
				  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDescription().equals("Espresso - medium $3.50")) out.print("selected");}%>>Espresso - medium $3.50</option>
				  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDescription().equals("Espresso - large $4.50")) out.print("selected");}%>>Espresso - large $4.50</option>
				  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDescription().equals("Iced Cafe Latte - small $2.50")) out.print("selected");}%>>Iced Cafe Latte - small $2.50</option>
			  	  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDescription().equals("Iced Cafe Latte - medium $3.50")) out.print("selected");}%>>Iced Cafe Latte - medium $3.50</option>
				  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDescription().equals("Iced Cafe Latte - large $4.50")) out.print("selected");}%>>Iced Cafe Latte - large $4.50</option>
				  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDescription().equals("Mocha - small $2.50")) out.print("selected");}%>>Mocha - small $2.50</option>
			  	  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDescription().equals("Mocha - medium $3.50")) out.print("selected");}%>>Mocha - medium $3.50</option>
				  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDescription().equals("Mocha - large $4.50")) out.print("selected");}%>>Mocha - large $4.50</option>
						</select>
					<font face="Verdana" size="-1"><b>Quantity: </b><select size="1" name="quantity">
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getQuantity().equals("1")) out.print("selected");}%>>1</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getQuantity().equals("2")) out.print("selected");}%>>2</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getQuantity().equals("3")) out.print("selected");}%>>3</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getQuantity().equals("4")) out.print("selected");}%>>4</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getQuantity().equals("5")) out.print("selected");}%>>5</option>
					</select>
					</p>
					<p align="center"><font size="-1" face="Geneva, Arial, Helvetica, sans-serif" color = "000000">
					<b>Time coffee required: <select size="1" name="deliveryHour">
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryHour().equals("07")) out.print("selected");}%>>07</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryHour().equals("08")) out.print("selected");}%>>08</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryHour().equals("09")) out.print("selected");}%>>09</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryHour().equals("10")) out.print("selected");}%>>10</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryHour().equals("11")) out.print("selected");}%>>11</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryHour().equals("12")) out.print("selected");}%>>12</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryHour().equals("13")) out.print("selected");}%>>13</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryHour().equals("14")) out.print("selected");}%>>14</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryHour().equals("15")) out.print("selected");}%>>15</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryHour().equals("16")) out.print("selected");}%>>16</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryHour().equals("17")) out.print("selected");}%>>17</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryHour().equals("18")) out.print("selected");}%>>18</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryHour().equals("19")) out.print("selected");}%>>19</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryHour().equals("20")) out.print("selected");}%>>20</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryHour().equals("21")) out.print("selected");}%>>21</option>
					</select><select size="1" name="deliveryMinute">
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryMinute().equals("00")) out.print("selected");}%>>00</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryMinute().equals("05")) out.print("selected");}%>>05</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryMinute().equals("10")) out.print("selected");}%>>10</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryMinute().equals("15")) out.print("selected");}%>>15</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryMinute().equals("20")) out.print("selected");}%>>20</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryMinute().equals("25")) out.print("selected");}%>>25</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryMinute().equals("30")) out.print("selected");}%>>30</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryMinute().equals("35")) out.print("selected");}%>>35</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryMinute().equals("40")) out.print("selected");}%>>40</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryMinute().equals("45")) out.print("selected");}%>>45</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryMinute().equals("50")) out.print("selected");}%>>50</option>
					  <option <% if(coffeepreference_data!=null){if(coffeepreference_data.getDeliveryMinute().equals("55")) out.print("selected");}%>>55</option>
					</select></p>
										
					<p align="center"><font size="-1" face="Geneva, Arial, Helvetica, sans-serif" color = "FF0000">
					
					<b>
					
					<%if(request.getParameter("action").equals("Order")){
					out.println( customer_interface.getMessage());
					}
					%></b></p>
					<p align="center">
						<font color="000000" size = "-1"><i><b>Your account BALANCE: $<%java.text.DecimalFormat df = new java.text.DecimalFormat("0.00");out.print(df.format(customer_data.getAccount()));%>
						</b></i></font>
					</p>
					<p align ="center" ><input type="submit" value="Order" name="action"></p>
					</form>					
				</td>				
			</table>
		</td>
	</tr>
	
	<tr><td bgcolor ="F0F8FF"><font face="Geneva, Arial, Helvetica, sans-serif"><p align="center"><font size="-1" face="Geneva, Arial, Helvetica, sans-serif">
		<br><p align="center"><font  size = "+1"></font></p></td>
	</tr>
	<tr>
		<td>
		<table align="center" border="0" cellpadding="0" cellspacing="0" width=100%>
			<td width="50%" bgcolor=#D3D3D3>
					<form type=POST action="customerUpdate.jsp">
  					<p align="center"><font size = "+1"></font></p>
  					<p align="center"><i>Click below to update your details</i></p>
  					
  					<br>
  					<br>
  					<br>
  					<p align="center"><input type="submit" value="Update User Profile" name="action"></p>
					</form>
				</td>
			<td  width="50%" bgcolor=#D3D3D3>
					<form method=POST action="order.jsp">
					  <p align="center"><font size = "+1"></font></p>
					  <p align="center"><i>This will be added to your remaining balance</i></p>
					  <p align="center">$ <input type="text" name="preBillingAmount" maxlength="3" size=16 value=<%= customer_data.getPreBillingAmount() != null ? "'"+customer_data.getPreBillingAmount()+"'" : "" %>></p>
					  <p align="center"><input type="submit" value="Update Account" name="action"></p>
					  <p align="center"><font size="-1" face="Geneva, Arial, Helvetica, sans-serif" color = "FF0000">
					  <b><%if(request.getParameter("action").equals("Update Account")){
					out.println( customer_interface.getMessage());
					}
					%></b></p>
					  
					</form>	
					
			</td>
		</table>
		</td>
	</tr>
	<tr>
		<td bgcolor=#F0F8FF><br><font face="Geneva, Arial, Helvetica, sans-serif"><p align="center"><font size="-1" face="Geneva, Arial, Helvetica, sans-serif">
		<p align="center"><font  size = "-1"><i><b>NOTE: All transactions are in NZ dollars.</b></i></font></p>
		<!--Please feel free to order a coffee, update your details or increase your remaining balance.<br><br></p-->
		</font>
		</td>
	</tr>
	<tr>
		<td bgcolor=#F0F8FF>
		<form method ="POST" action="coffeelogout.jsp">
		<p align="center"><input type="submit" value="Logout" name="action"></p>
		</form>
		</td>
	</tr>
</table>

</body>
</html>