%@ include file="/header.jsp" %>
<%@ include file="/title.jsp" %>
<%@ include file="/utils.jsp" %>
<%= print_popup(session) %>

<% if ( usern.getUsern() == null ) { %>
Before you can order any online products, you must first
register or,
if you have already registered, please login.
<% } %>
Internet Specials
<%
PreparedStatement ps = null;
ResultSet rs = null;
Statement stmt1 = null;
ResultSet rs1 = null;
try {
stmt1 = con.createStatement();
rs1 = stmt1.executeQuery("select distinct prodid from item where onsale = 'Y' and pricesale is not null");
boolean noitems = true;
while ( rs1.next() ) {
noitems = false;
ps = con.prepareStatement("select ib.itemblock from itemblock ib,item where ib.itemblock=item.itemblock and item.prodid = ? and item.onsale='Y' and pricesale is not null and rownum < 2");
ps.setString(1,rs1.getString(1));
rs = ps.executeQuery();
boolean norows = true;
java.util.Vector itemblocksVector = new java.util.Vector();
while ( rs.next() ) {
itemblocksVector.add( rs.getString(1) );
}
rs.close();
ps.close();
String[] itemblocks = new String[ itemblocksVector.size() ];
int i2 = -1;
for (java.util.Enumeration e = itemblocksVector.elements() ; e.hasMoreElements() ;) {
i2++;
itemblocks[i2] = (String)e.nextElement();
}
for ( int i = 0 ; i < itemblocks.length ; i++ ) {
ItemblockBean itemblock = new ItemblockBean();
itemblock.findByPrimaryKey(con,itemblocks[i]);
%>
<%= itemblock.getTitle() %>
| <%= itemblock.getImagepath() %> |
<%= itemblock.getDescrip() %> |
<%
ItemBean[] items = itemblock.getItemBeans(con, new Where(), new Orderby("orderby"));
String color = null;
for ( int ii = 0 ; ii < items.length ; ii++ ) {
color = next_color(color);
String saleString = "";
double price = 0;
if ( usern.getUsern() != null ) {
double usern_price = 0;
double sale_price = 0;
usern_price = Double.valueOf( items[ii].getPrice( con , usern.getUsern() ) ).doubleValue();
if ( "Y".equals(items[ii].getOnsale()) && items[ii].getPricesale() != null ) {
sale_price = Double.valueOf( items[ii].getPricesale() ).doubleValue();
if ( sale_price < usern_price ) { price = sale_price; }
else { price = usern_price; }
}
else { price = usern_price; }
}
else {
if ( "Y".equals(items[ii].getOnsale()) && items[ii].getPricesale() != null ) {
saleString = "On sale from " + moneyFormatter.format( Double.valueOf( items[ii].getPrice() ).doubleValue() ) + " ";
price = Double.valueOf( items[ii].getPricesale() ).doubleValue();
}
else {
price = Double.valueOf( items[ii].getPrice() ).doubleValue();
}
}
%>
<% if ( "Y".equals( items[ii].getInstock() ) ) { %>
 |
<% } else { %>
<%= new MessagesBean(con,"out_of_stock").toString() %> |
<% } %>
<%
if ( ! (items[ii].getEfficientcytext() == null) ){
if ( items[ii].getEfficientcytext().length() > 0 ){ %>
<%
}
}
%>
<%= items[ii].getTitle() %> (<%= items[ii].getProdid() %>)
<% if ( items[ii].getDescrip() != null && ! "".equals( items[ii].getDescrip() ) ) { %>
<%= items[ii].getDescrip() %>
<% } %>
<% if ( "Y".equals(items[ii].getNewitem() ) ) { %>
* NEW *
<% } %>
|
<%= saleString %><%= moneyFormatter.format( price ) %> |
<%
}
%>
<%
}
}
if ( noitems ) {
%>No specials at this time, please try back later
<%
}
}
catch ( SQLException e ) {
throw new RuntimeException(e.getMessage());
}
finally {
try {
if ( rs != null ) { rs.close(); }
if ( ps != null ) { ps.close(); }
if ( rs1 != null ) { rs1.close(); }
if ( stmt1 != null ) { stmt1.close(); }
}
catch ( SQLException e ) {
throw new RuntimeException(e.getMessage());
}
}
%>
<%@ include file="/foot.jsp"%>
<%!
String next_color(String s) {
if ( "#6699CC".equals(s) ) {
return "#E3E5E8";
}
return "#6699CC";
}
%>