/* "wrAuctionConfirmPage(out)"
 * generated after auction confirmed and placed.
 * just confirmation , nothing else
 *===============================================================================
 * "wrSellFormPage(out, String categoryname, vector featurename, vector featuretype)"
 * format of page:
 * feature name: text area
 *   "             "
 * it contains login/password form also.
 * fo reach field check whether the value entered matches with the type of the field
 * Submit Button: goto servlet "PlaceAuctionServlet" and http request = "post"
 * also encode category name in URL : ?categoty=******
 *===============================================================================
 * "wrLoginErrorPage(out)"
 * (generate error page : no buttons.)
 * same as "genSellFormPage" with one line written above it : "Invalid login"
*/

import Configure;
import java.util.*;
import java.io.*;
import java.lang.*;

public class AuctionHtmlPageWriter
{ 
	 private AuctionHtmlGen hg;
	 private JScriptGen jg;

	 
	 AuctionHtmlPageWriter() 
	 {
		  hg = new AuctionHtmlGen();
		  jg = new JScriptGen();
	 }
	 
	 public void wrAuctionConfirmPage(PrintWriter out)
	 {  
		  hg.addHtmlHeader(out, "Auction Status", "#fffff");
		  hg.addGeneralMsg(out, " Congratulations! The Auction Has Been Placed Successfully..", "blue", "10");
		  hg.addHtmlFooter(out);
	 }


	 public void wrReviveAuctionPage(PrintWriter out, int prodID)
	 {

	   String url = Configure.SERVLET_SERVER +":"+ Configure.SERVLET_PORT +"/"+ Configure.SERVLET_PATH +"/"+ "AuctionRevivalServlet?productID=" + prodID;

	   System.out.println("url in auctiohtmlpagewrite/wrsearchpage url= " + url);


	   String line="";
	   line += "<html>\n";
	   line += "<head>\n";
	   line += "<title>Auctio Revival Page</title>\n";
	   line += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n";
	   line += "</head>\n";
	   line += "\n";
	   line += "<body bgcolor=\"white\">\n";
	   line += "<font color=\"red\"><b>Revive Auction</b></font>\n";


	   line += "<FORM ACTION=\"" + url + "\" METHOD=POST>\n";
	   line += "\n";
	   //line += "<table>\n";
	   line += "<tr> \n";
	   line += "<td>Auctions Closing Before </td>\n";
	   line += "<td>\n";
	   line += "<select name=\"day\">\n";
	   line += "<option value=\"01\"><b>01</b></option>\n";
	   line += "<option value=\"02\"><b>02</b></option>\n";
	   line += "<option value=\"03\"><b>03</b></option>\n";
	   line += "<option value=\"04\"><b>04</b></option>\n";
	   line += "<option value=\"05\"><b>05</b></option>\n";
	   line += "<option value=\"06\"><b>06</b></option>\n";
	   line += "<option value=\"07\"><b>07</b></option>\n";
	   line += "<option value=\"08\"><b>08</b></option>\n";
	   line += "<option value=\"09\"><b>09</b></option>\n";
	   line += "<option value=\"10\"><b>10</b></option>\n";
	   line += "<option value=\"11\"><b>11</b></option>\n";
	   line += "<option value=\"12\"><b>12</b></option>\n";
	   line += "<option value=\"13\"><b>13</b></option>\n";
	   line += "<option value=\"14\"><b>14</b></option>\n";
	   line += "<option value=\"15\"><b>15</b></option>\n";
	   line += "<option value=\"16\"><b>16</b></option>\n";
	   line += "<option value=\"17\"><b>17</b></option>\n";
	   line += "<option value=\"18\"><b>18</b></option>\n";
	   line += "<option value=\"19\"><b>19</b></option>\n";
	   line += "<option value=\"20\"><b>20</b></option>\n";
	   line += "<option value=\"21\"><b>21</b></option>\n";
	   line += "<option value=\"22\"><b>22</b></option>\n";
	   line += "<option value=\"23\"><b>23</b></option>\n";
	   line += "<option value=\"2\"><b>24</b></option>\n";
	   line += "<option value=\"25\"><b>25</b></option>\n";
	   line += "<option value=\"26\"><b>26</b></option>\n";
	   line += "<option value=\"27\"><b>27</b></option>\n";
	   line += "<option value=\"28\"><b>28</b></option>\n";
	   line += "<option value=\"29\"><b>29</b></option>\n";
	   line += "<option value=\"30\"><b>30</b></option>\n";
	   line += "<option value=\"31\"><b>31</b></option>\n";
	   line += "</select>\n";

	   line += "<select name=\"month\">\n";
	   line += "<option value=\"1\">Jan </option>\n";
	   line += "<option value=\"2\">Feb </option>\n";
	   line += "<option value=\"3\">Mar </option>\n";
	   line += "<option value=\"4\">Apr </option>\n";
	   line += "<option value=\"5\">May </option>\n";
	   line += "<option value=\"6\">Jun </option>\n";
	   line += "<option value=\"7\">Jul </option>\n";
	   line += "<option value=\"8\">Aug </option>\n";
	   line += "<option value=\"9\">Sep </option>\n";
	   line += "<option value=\"10\">Oct </option>\n";
	   line += "<option value=\"11\">Nov </option>\n";
	   line += "<option value=\"12\">Dec </option>\n";
	   line += "</select>\n";

	   line += "<select name=\"year\">\n";
	   line += "<option value=\"2000\">2000 </option>\n";
	   line += "<option value=\"2001\">2001 </option>\n";
	   line += "<option value=\"2002\">2002 </option>\n";
	   line += "</select>\n";
	   line += "</td>\n";
	   line += "<td><input type=\"submit\" name= \"submit3\" value=\"submit\"></td>";
	   line += "</tr>\n";
	   line += "</table>\n";
	   line += "</form>\n";
	   line += "</body>\n";
	   line += "</html>\n";

	   out.println(line);

	 }

	 public void wrSellFormPage(PrintWriter out, String category, Vector fname, Vector ftype)
	 {
	   Vector lp = new Vector();
	   lp.addElement("Login");
	   lp.addElement("Password");


	   String url = Configure.SERVLET_SERVER +":"+ Configure.SERVLET_PORT +"/"+ Configure.SERVLET_PATH +"/"+ "PlaceAuctionServlet?category=" + category.replace(' ', '+');
	   //url = "http://144.16.111.4:5033/servlet/PlaceAuctionServlet?" + category;
	   hg.addHtmlHeader(out, "Product Details", "#fffff");	
	   jg.addJScriptHeader(out);
	   jg.addValidateFn(out, fname, ftype);
	   jg.addJScriptFooter(out);
	   hg.addFormHeader(out, url, "post");
	   hg.addFormTable(out, fname, ftype, 1, "<tr><th><font color=\"blue\">Property</font></th><th><font color=\"blue\">Value</font></th></tr>");
	   hg.addFormTable(out, lp, ftype, 1 , "<hr><font size=4 color=\"teal\">Please Enter Login password</font>");
	   hg.addFormFooter(out, true);
	   hg.addHtmlFooter(out);
	 }



	 /*old working fn.
	  * --------------
	  * 
	  public void wrSellFormPage(PrintWriter out, String category, Vector fname, Vector ftype)
	  {
	  Vector lp = new Vector();
	  lp.addElement("Login");
	  lp.addElement("Password");


	  String url = Configure.SERVLET_SERVER +":"+ Configure.SERVLET_PORT +"/"+ Configure.SERVLET_PATH +"/"+ "PlaceAuctionServlet?category=" + category.replace(' ', '+');
	 //url = "http://144.16.111.4:5033/servlet/PlaceAuctionServlet?" + category;
	 hg.addHtmlHeader(out, "Product Details", "white");	
	 jg.addJScriptHeader(out);
	 jg.addValidateFn(out, fname, ftype);
	 jg.addJScriptFooter(out);
	 hg.addFormHeader(out, url, "post");
	 hg.addFormTable(out, fname, ftype, 3);
	 hg.addFormTable(out, lp, ftype, 4);
	 hg.addFormFooter(out);
	 hg.addHtmlFooter(out);
	 }
	  */


	 //writes directly the search option page.
	 public void wrSearchPage(PrintWriter out)
	 {
	   String line ="";

	   String url = Configure.SERVLET_SERVER +":"+ Configure.SERVLET_PORT +"/"+ Configure.SERVLET_PATH +"/"+ "SearchServlet";

	   System.out.println("url in auctiohtmlpagewrite/wrsearchpage url= " + url);

	   line += "<html>\n";
	   line += "<head>\n";
	   line += "<title>Search Page</title>\n";
	   line += "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">\n";
	   line += "</head>\n";
	   line += "\n";
	   line += "<body bgcolor=\"#fffff\">\n";
	   
	   line += "<font color=\"red\"><b>GENERAL SEARCH</b></font>\n";

	   line += "<FORM ACTION=\"" + url + "\" METHOD=POST>\n";
	   line += "\n";
	   line += "<table>\n";
	   line += "<tr> \n";
	   line += "<td>Auctions Having Category Name</td>\n";
	   line += "<td><input name=\"productName\" size=\"20\" maxlength=\"20\"></td>\n";
	   line += "<td><input type=\"submit\" name= \"submit1\" value=\"submit\"></td>\n";
	   line += "</tr>\n";
	   //line += "</table>\n";
	   line += "</form>\n";

	   line += "<FORM ACTION=\"" + url + "\" METHOD=POST>\n";
	   line += "\n";
	   //line += "<table>\n";
	   line += "<tr> \n";
	   line += "<td>Auctions Having Bid Value Less Than</td>\n";
	   line += "<td><input name=\"bidValue\" size=\"20\" maxlength=\"20\"></td>\n";
	   line += "<td><input type=\"submit\" name= \"submit2\" value=\"submit\"></td>\n";
	   line += "</tr>\n";
	   //line += "</table>\n";
	   line += "</form>\n";


	   //line += "\n";
	   //line += "<tr><td></td><td></td></tr>\n";
	   //line += "\n";

	   //line += "<tr> \n";
	   //line += "<td>Auctions With Reserve Price Less than</td>\n";
	   //line += "<td> \n";
	   //line += "<b> \n";
	   //line += "<input name=\"reservePrice\" size=\"20\" maxlength=\"20\">\n";
	   //line += "</b>\n";
	   //line += "</td>\n";
	   //line += "</tr>\n";

	   //line += "\n";
	   //line += "<tr><td></td><td></td></tr>\n";
	   //line += "\n";

	   //line += "<tr> \n";
	   line += "<FORM ACTION=\"" + url + "\" METHOD=POST>\n";
	   line += "\n";
	   //line += "<table>\n";
	   line += "<tr> \n";
	   line += "<td>Auctions Closing Before </td>\n";
	   line += "<td>\n";
	   line += "<select name=\"day\">\n";
	   line += "<option value=\"01\"><b>01</b></option>\n";
	   line += "<option value=\"02\"><b>02</b></option>\n";
	   line += "<option value=\"03\"><b>03</b></option>\n";
	   line += "<option value=\"04\"><b>04</b></option>\n";
	   line += "<option value=\"05\"><b>05</b></option>\n";
	   line += "<option value=\"06\"><b>06</b></option>\n";
	   line += "<option value=\"07\"><b>07</b></option>\n";
	   line += "<option value=\"08\"><b>08</b></option>\n";
	   line += "<option value=\"09\"><b>09</b></option>\n";
	   line += "<option value=\"10\"><b>10</b></option>\n";
	   line += "<option value=\"11\"><b>11</b></option>\n";
	   line += "<option value=\"12\"><b>12</b></option>\n";
	   line += "<option value=\"13\"><b>13</b></option>\n";
	   line += "<option value=\"14\"><b>14</b></option>\n";
	   line += "<option value=\"15\"><b>15</b></option>\n";
	   line += "<option value=\"16\"><b>16</b></option>\n";
	   line += "<option value=\"17\"><b>17</b></option>\n";
	   line += "<option value=\"18\"><b>18</b></option>\n";
	   line += "<option value=\"19\"><b>19</b></option>\n";
	   line += "<option value=\"20\"><b>20</b></option>\n";
	   line += "<option value=\"21\"><b>21</b></option>\n";
	   line += "<option value=\"22\"><b>22</b></option>\n";
	   line += "<option value=\"23\"><b>23</b></option>\n";
	   line += "<option value=\"2\"><b>24</b></option>\n";
	   line += "<option value=\"25\"><b>25</b></option>\n";
	   line += "<option value=\"26\"><b>26</b></option>\n";
	   line += "<option value=\"27\"><b>27</b></option>\n";
	   line += "<option value=\"28\"><b>28</b></option>\n";
	   line += "<option value=\"29\"><b>29</b></option>\n";
	   line += "<option value=\"30\"><b>30</b></option>\n";
	   line += "<option value=\"31\"><b>31</b></option>\n";
	   line += "</select>\n";

	   line += "<select name=\"month\">\n";
	   line += "<option value=\"1\">Jan </option>\n";
	   line += "<option value=\"2\">Feb </option>\n";
	   line += "<option value=\"3\">Mar </option>\n";
	   line += "<option value=\"4\">Apr </option>\n";
	   line += "<option value=\"5\">May </option>\n";
	   line += "<option value=\"6\">Jun </option>\n";
	   line += "<option value=\"7\">Jul </option>\n";
	   line += "<option value=\"8\">Aug </option>\n";
	   line += "<option value=\"9\">Sep </option>\n";
	   line += "<option value=\"10\">Oct </option>\n";
	   line += "<option value=\"11\">Nov </option>\n";
	   line += "<option value=\"12\">Dec </option>\n";
	   line += "</select>\n";

	   line += "<select name=\"year\">\n";
	   line += "<option value=\"2000\">2000 </option>\n";
	   line += "<option value=\"2001\">2001 </option>\n";
	   line += "<option value=\"2002\">2002 </option>\n";
	   line += "</select>\n";
	   line += "</td>\n";
	   line += "<td><input type=\"submit\" name= \"submit3\" value=\"submit\"></td>";
	   line += "</tr>\n";
	   line += "</table>\n";
	   line += "</form>\n";

	   line += "\n";

	   /*
	   line += "<hr>";
	   line += "<font color=\"red\"><b>CUSTOMIZED SEARCH</b></font>\n";

	   line += "<FORM ACTION=\"" + url + "\" METHOD=POST>\n";
	   line += "<table>\n";
	   line += "<tr> \n";
	   line += "<td>Product </td>\n";

	   line += "<td> \n";
	   //line += "<b> \n";
	   line += "<input name=\"specProduct\" size=\"20\" maxlength=\"20\">\n";
	   //line += "</b>\n";
	   //
	   line += "</td>\n";
	   line += "<td><input type=\"submit\" name=\"submit4\" value=\"submit\"></td>";
	   line += "</tr>\n";
	   line += "</table>\n";
	   line += "</form>\n";
	   line += "\n";
	  */
	   
	   line += "\n";
	   line += "</body>\n";
	   line += "</html>\n";

	   ProdHtmlGen.linksToPages(out);
	   out.println(line);
	 }



	 public void wrLoginErrorPage(PrintWriter out)
	 {  
	   hg.addHtmlHeader(out, "Error", "#fffff");
	   hg.addGeneralMsg(out, "Incorrect Login!", "red", "10");
	   hg.addHtmlFooter(out);
	 }
}








