<%@ page 
language="java"
contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"
%>
<%-- tpl:insert page="/jsptemplate.htpl" --%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
<HEAD>
<META http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<META name="GENERATOR" content="IBM WebSphere Studio">
<%-- tpl:put name="headarea" --%>
	<TITLE>The ICOM5016 Dummy CDStore</TITLE>
<%-- /tpl:put --%>
</HEAD>
<BODY>


<TABLE>
	<TBODY>
		<TR>
			<TD height="110" width="773">
			<TABLE width="80%" height="88">
				<TBODY>
					<TR>
						<TD height="65" width="249"><IMG border="0"
							src="/icom5016/images/cd_logo.jpeg" width="248" height="165"></TD>
						<TD height="65" width="462">
						<TABLE height="151">
							<TBODY>
								<TR>
									<TD height="87" width="324">
									<H2>The ICOM5016 Dummy CDStore</H2>
									</TD>
								</TR>
								<TR>
									<TD height="58" width="324">

									<TABLE width="100%">
										<TBODY>
											<TR>
												<TD width="110"><A href="/icom5016/index.jsp">Home</A></TD>
												<TD width="145"><A href="/icom5016/servlet/ShowCartServlet">View
												Cart</A></TD>
												<TD width="132"><%= edu.uprm.ece.icom5016.util.LogInChecker.getLoginLink(request) %></TD>
											</TR>
										</TBODY>
									</TABLE>
									</TD>
								</TR>
							</TBODY>
						</TABLE>
						</TD>
					</TR>
				</TBODY>
			</TABLE>
			</TD>
		</TR>
		<TR>
			<TD height="470" width="773">
			<TABLE width="771">
				<TBODY>
					<TR>
						<TD height="456" width="178">
						<TABLE height="425">
							<TBODY>
								<TR>
									<TD height="291" width="198">
									<FORM action="/icom5016/servlet/SearchServlet">
									<INPUT type="text" name="search_box" size="20"
										value="type your search"> 
									<INPUT type="submit" name="search" value="Search"><BR>
									<INPUT type="radio" name="search_buttons" value="artist">Artist<BR>
									<INPUT type="radio" name="search_buttons" value="album">Album<BR>
									<INPUT type="radio" name="search_buttons" value="genre">Genre<BR>
									<INPUT type="radio" name="search_buttons" value="all" checked>All</FORM>
									</TD>
								</TR>
								<TR>
									<TD height="128" width="198"></TD>
								</TR>
							</TBODY>
						</TABLE>
						</TD>
						<TD height="456" width="587"><%-- tpl:put name="Modifiy this " --%>
						<H1>You are about to buy this items</H1><BR>
						<%-- jsp:useBean id="cart" type="edu.uprm.ece.icom5016.bean.ShoppingCart" scope="session"/v --%>
						<%-- jsp:getProperty name="cart" property="items"/ --%>
						<%@ page import="edu.uprm.ece.icom5016.bean.ShoppingCart" %>
						<%@ page import="java.math.BigDecimal, edu.uprm.ece.icom5016.util.CartInspector" %>
						<%@ page import="edu.uprm.ece.icom5016.bean.ItemOrdered, edu.uprm.ece.icom5016.bean.CatalogItem" %>
						<%@ page import="edu.uprm.ece.icom5016.bean.Customer" %>
						<%-- @ page import="javax.servlet.RequestDispatcher" --%> 
						<%-- Check if the user is logged--%>
						<%--
						Customer c = (Customer) session.getAttribute("customer");
						if(c == null){
							request.setAttribute("checkout", "checkout");
						%>
							<jsp:forward page="/login.jsp" />
						<%	
						}
						--%>
						<%
						ShoppingCart cart = (ShoppingCart) session.getAttribute("cart");
						CartInspector inspector = new CartInspector(cart);
						BigDecimal current_total = inspector.getGran_total();
						BigDecimal shipping = new BigDecimal(100.00);
						ItemOrdered[] items = inspector.getItems();
						%>
							<TABLE width="100%" border="0">
								<TBODY>
							<% 
							for(int i=0; i<items.length; i++){
								 ItemOrdered item = items[i];
								 CatalogItem citem = item.getItem();
								 String img = citem.getImage();
								 String name = citem.getName();
								 String price = citem.getPrice().toString();
								 String qty = Integer.toString(item.getNumItems());
								 String total = item.getTotal().toString();
							%>
									<TR>
										<TD> <img border ="0" src= <%= img %> width = "118" height = "112"> </TD>
										<TD width="329">
											<TABLE border="0">
												<TBODY>
													<TR>
														<TD width="316"> Name = <%= name %></TD>
													</TR>
													<TR>
														<TD width="316"> Description = <%= price %> </TD>
													</TR>
													<TR>
														<TD width="316"> Price = <%= price %></TD>
													</TR>
													<TR>
														<TD width="316"> Qty = <%= qty %></TD>
													</TR>
													<TR>
														<TD width="316"> Total =  <%= total %></TD>
													</TR>
											
												<TBODY>
											</TABLE>
										</TD>
									</TR>
							<% } %>
									<TR>
									<TD>Sub Total = $<%= current_total %></TD>
									</TR>
									<TR>
									<TD>Shipping and Handling = $<%= shipping %></TD>
									</TR>
									<TR>
									<TD>Grand Total = $<%= current_total.add(shipping)%></TD>
									</TR>
								</TBODY>
							</TABLE>
						<FORM action="/icom5016/servlet/PlaceOrderServlet">
						<INPUT type="submit" name="place" value="Place Order">
						</FORM>
						<FORM action="/icom5016/index.jsp">
						<INPUT type="submit" name="continue" value="Continue Shopping">
						</FORM>
						<%-- /tpl:put --%></TD>
					</TR>
				</TBODY>
			</TABLE>
			</TD>
		</TR>
	</TBODY>
</TABLE>
</BODY>
</HTML>
<%-- /tpl:insert --%>