<html>
<head>
<title>Enquiry</title>
<meta http-equiv="Content-Type" content="text/html; charset=big5">
<link href="/assg3.css" rel="stylesheet" type="text/css">
</head>
<body>
  <h1 align="center" class="title">Insertion and Deletion Process</h1>
	<%
		String mode = (String)request.getAttribute("mode");
		if(mode.equals("add"))
		{
			String[] success = (String[])request.getAttribute("success");
			int successNum = Integer.parseInt((String)request.getAttribute("successNum"));
			String[] unsuccess = (String[])request.getAttribute("unsuccess");
			int unsuccessNum = Integer.parseInt((String)request.getAttribute("unsuccessNum"));

			if(successNum > 0 ||  unsuccessNum > 0)
			{
				out.println("<table width=100% border=1>");
				out.println("<tr><td><div align=center>Flight ID</td><td>");
				out.println("<div align=center>Date of departure</td>");
				out.println("<td><div align=center>Departure city</td><td><div align=center>Arrival city</td>");
				out.println("<td><div align=center>Departure time</td><td><div align=center>Arrival time</td>");
				out.println("<td><div align=center>Flight duration time</td><td><div align=center>Price</td>");
				out.println("<td><div align=center>State</td></tr>");
			}
			else
			{
				out.println("<div align=center> No Insertion required </div>");
			}
			for(int i = 0; i < successNum; i++)
			{
				out.println("<td><div align=center>"+success[i].substring(0,5)+"</td>");
				out.println("<td><div align=center>"+success[i].substring(5,13)+"</td>");
				out.println("<td><div align=center>"+success[i].substring(13,23)+"</td>");
				out.println("<td><div align=center>"+success[i].substring(23,33)+"</td>");
				out.println("<td><div align=center>"+success[i].substring(33,37)+"</td>");
				out.println("<td><div align=center>"+success[i].substring(37,41)+"</td>");
				out.println("<td><div align=center>"+success[i].substring(41,45)+"</td>");
				out.println("<td><div align=center>"+success[i].substring(45,50)+"</td>");
				out.println("<td><div align=center> success </td>");
				out.println("</tr>");    
			}
			for(int i = 0; i < unsuccessNum; i++)
			{
				out.println("<td><div align=center>"+unsuccess[i].substring(0,5)+"</td>");
				out.println("<td><div align=center>"+unsuccess[i].substring(5,13)+"</td>");
				out.println("<td><div align=center>"+unsuccess[i].substring(13,23)+"</td>");
				out.println("<td><div align=center>"+unsuccess[i].substring(23,33)+"</td>");
				out.println("<td><div align=center>"+unsuccess[i].substring(33,37)+"</td>");
				out.println("<td><div align=center>"+unsuccess[i].substring(37,41)+"</td>");
				out.println("<td><div align=center>"+unsuccess[i].substring(41,45)+"</td>");
				out.println("<td><div align=center>"+unsuccess[i].substring(45,50)+"</td>");
				out.println("<td><div align=center> unsuccess </td>");
				out.println("</tr>");    
			}
			out.println("</table>");
		}
		else if(mode.equals("remove"))
		{
			String[] success = (String[])request.getAttribute("success");
			int successNum = Integer.parseInt((String)request.getAttribute("successNum"));
			if(successNum > 0)
			{
				out.println("<table width=100% border=1>");
				out.println("<tr><td><div align=center>Flight ID</td><td>");
				out.println("<div align=center>Date of departure</td>");
				out.println("<td><div align=center>Departure city</td><td><div align=center>Arrival city</td>");
				out.println("<td><div align=center>Departure time</td><td><div align=center>Arrival time</td>");
				out.println("<td><div align=center>Flight duration time</td><td><div align=center>Price</td>");
				out.println("<td><div align=center>State</td></tr>");
			}
			else
			{
				out.println("<div align=center> No Deletion required </div>");
			}
			for(int i = 0; i < successNum; i++)
			{
				out.println("<tr><td><div align=center>"+success[i].substring(0,5)+"</td>");
				out.println("<td><div align=center>"+success[i].substring(5,13)+"</td>");
				out.println("<td><div align=center>"+success[i].substring(13,23)+"</td>");
				out.println("<td><div align=center>"+success[i].substring(23,33)+"</td>");
				out.println("<td><div align=center>"+success[i].substring(33,37)+"</td>");
				out.println("<td><div align=center>"+success[i].substring(37,41)+"</td>");
				out.println("<td><div align=center>"+success[i].substring(41,45)+"</td>");
				out.println("<td><div align=center>"+success[i].substring(45)+"</td>");
				out.println("<td><div align=center> success </td>");
				out.println("</tr>");    
			}
			out.println("</table>");
		}
		else
		{
				out.println("<div align=center> No Insertion required </div>");
				out.println("<div align=center> No Deletion required </div>");
		}			
	%>
	</div>
<h1 align="center" class="title">Travel Plan Corner</h1>

<form name="form1" method="post" action="/servlet/Controller?service=CornerService&target=/travelCorner.jsp">
  <div align="center">
    <p> 
<%
	  String[][] tpc = (String[][])request.getAttribute("tpc");
	  int tpcNum = Integer.parseInt((String)request.getAttribute("tpcNum"));
			if(tpcNum > 0)
			{
				out.println("<table width=100% border=1>");
				out.println("<tr><td></td>");
				out.println("<td><div align=center>Flight ID</td>");
				out.println("<td><div align=center>Date of departure</td>");
				out.println("<td><div align=center>Departure city</td><td><div align=center>Arrival city</td>");
				out.println("<td><div align=center>Departure time</td><td><div align=center>Arrival time</td>");
				out.println("<td><div align=center>Flight duration time</td><td><div align=center>Price</td>");
				out.println("<td><div align=center>State</td></tr>");
				for(int i = 0; i < tpcNum; i++)
				{
					out.println("<tr><td><div align=center><input type=checkbox name=checkbox value='"+tpc[i][0]+tpc[i][1]+tpc[i][2]+tpc[i][3]+tpc[i][4]+tpc[i][5]+tpc[i][6]+tpc[i][7]+"'></td>");
					out.println("<td><div align=center>"+tpc[i][0]+"</td>");
					out.println("<td><div align=center>"+tpc[i][1]+"</td>");
					out.println("<td><div align=center>"+tpc[i][2]+"</td>");
					out.println("<td><div align=center>"+tpc[i][3]+"</td>");
					out.println("<td><div align=center>"+tpc[i][4]+"</td>");
					out.println("<td><div align=center>"+tpc[i][5]+"</td>");
					out.println("<td><div align=center>"+tpc[i][6]+"</td>");
					out.println("<td><div align=center>"+tpc[i][7]+"</td>");
					out.println("<td><div align=center> tpc </td>");
					out.println("</tr>");    
				}
				out.println("</table>");
			}
			else
			{
				out.println("<div align=center> No Deletion required </div>");
			}
%>
      <input type="hidden" name="mode" value="remove">
      <input type="submit" name="Submit" value="Submit">
      <input type="reset" name="Submit2" value="Reset">
    </p>
<%
	String tPrice = (String)request.getAttribute("tPrice");
	String tTime = (String)request.getAttribute("tTime");
	out.println("<p>Total Price: $"+tPrice+"</p>");
	out.println("<p>Total Time: "+tTime+" minutes</p>");
%>
<p align="center" class="nav">| <a href="/enquiry.jsp">Enquiry page</a> 
  | <a href="/servlet/Controller?service=CornerService&target=/travelCorner.jsp&mode=none">Travel Plan Corner</a>
|</p>
  </div>
</form>
</body>
</html>
