<%@ include file="globalPaths.jsp" %><%@ include file="globalDefinitions.jsp" %><% Connection connection = null; Statement statement = null; ResultSet resultSet = null; String query = ""; int discount=0; double price=0.0; String printartwork = null; printartwork = request.getParameter("printartwork"); String artwork=request.getParameter("artwork"); if (((artwork==null)||(artwork.equals("")))&&((printartwork==null)||(printartwork.equals("")))) { sendRedirect(globalErrorPage + "?"+"errorDescription=" + URLencode("Missing artwork or printartwork")); return; } try { connection = openConnection(); statement = connection.createStatement(); query = "SELECT price,discount FROM galleryArtwork WHERE id=" + quoteString(artwork); resultSet = statement.executeQuery(query); if (resultSet.next()) { price = resultSet.getDouble("price"); discount = resultSet.getInt("discount"); resultSet.close(); } else { resultSet.close(); sendRedirect(globalErrorPage + "?"+"errorDescription=" + URLencode("RecordSet is empty. May be an artwork was not found")); return; } } catch(Exception e) { errorLog(e, query); sendRedirect(globalErrorPage + "?errorDescription=" + URLEncoder.encode(e.getMessage() + ".")); return; } finally { if (resultSet != null) resultSet.close(); if (connection != null && !connection.isClosed()) connection.close(); } if (request.getParameter("submit")!=null) { String offer=request.getParameter("offer"); if (!"".equals(offer.trim())) { try { offer=offer.trim()+" "; while (offer.startsWith("$")) { offer=offer.substring(offer.indexOf("$")+1); } offer=" "+offer.trim(); while (offer.endsWith("$")) { offer=offer.substring(0,offer.length()-1); } offer=offer.trim(); offer=substituteTokens(offer,",",""); double doffer=Double.parseDouble(offer); doffer=Math.round(doffer*100)/100.0; if (doffer>=price*(1.00-discount/100.00)) { Vector cart=new Vector(); cart.addElement(artwork); Vector offeredprice=new Vector(); offeredprice.addElement(new Double(doffer)); session.putValue("offereditems",cart); session.putValue("offeredprices",offeredprice); sendRedirect("norder02ship.jsp?artwork="+artwork+"&printartwork="+printartwork); return; } } catch (Exception e) { sendRedirect(globalErrorPage + "?"+"errorDescription=" + URLencode("Please enter correct price." )); return; } } else { sendRedirect(globalErrorPage + "?"+"errorDescription=" + URLencode("Please enter correct price." )); return; } } %> Customer's offer <%@ include file="inc/head.txt" %> <%@ include file="inc/top.txt" %>
 
 

<% if (request.getParameter("submit")==null) { %>

The initial price of this artwork is: <%=formatPrice(price)%>.

Enter your price:

This artist indicated that they would be willing to negotiate the price of this artwork. In the process of making an offer you will be asked to submit information in a similar way to an online order.

Notes:
1. This is not an online order.
2. The artist may decline or ignore your offer.
3. You are not obligated to buy this artwork once the artist has agreed to your offer. <% } else { String offer=request.getParameter("offer"); try { offer=offer.trim()+" "; while (offer.startsWith("$")) { offer=offer.substring(offer.indexOf("$")+1); } offer=" "+offer.trim(); while (offer.endsWith("$")) { offer=offer.substring(0,offer.length()-1); } offer=offer.trim(); offer=substituteTokens(offer,",",""); double doffer=Double.parseDouble(offer); doffer=Math.round(doffer*100)/100.0; if ( ("".equals(offer.trim()) )||(doffer The offered amount is outside of the limits discounted for this artwork, set by the artist. Sorry we will not be able to present your offer to the artist.

     
<% } } catch(Exception e) { sendRedirect(globalErrorPage + "?"+"errorDescription=" + URLencode("Bad price format")); return; } } %>




 
<%@ include file="inc/bottom.txt" %> <%@ include file="globalFinally.jsp" %>