home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / JAVA Utilities / JProxy 1.1.0 / customers / BUY-OEM.JSP < prev    next >
Encoding:
Text File  |  2003-04-29  |  7.2 KB  |  186 lines

  1. <%@ page language="java" import="
  2.     java.util.*,
  3.     com.jproxy.site.mbeans.JMXInvocator,
  4.     com.jproxy.site.mbeans.config.*,
  5.     com.jproxy.site.ejbeans.interfaces.ISaleFormula,
  6.     com.jproxy.site.ejbeans.interfaces.IProduct,
  7.     com.jproxy.site.*"
  8. %>
  9.  
  10. <jsp:useBean id="buycustomers" scope="request" class="com.jproxy.site.customers.Buy"/>
  11. <%
  12. buycustomers.request(pageContext);
  13. buycustomers.ses.setNewHit(pageContext, "hits", "OEM Buy Page", null);
  14. %>
  15.  
  16. <%
  17. int licenses = 1;
  18. int purchasedLicenses = 0;
  19. String productName = "";
  20.  
  21. String productID = buycustomers.getParameter("productid").trim();
  22. if(buycustomers.getParameter("licenses").trim().length()>0)
  23.     licenses = new Integer(buycustomers.getParameter("licenses")).intValue();
  24. if(buycustomers.getParameter("purchased-licenses").trim().length()>0)
  25.     purchasedLicenses = new Integer(buycustomers.getParameter("purchased-licenses")).intValue();
  26.  
  27. // find out the number of licenses requested
  28. if (licenses <= 0)
  29.     licenses = 1;
  30.  
  31. if(productID.length()>0)
  32.     productName = buycustomers.product.getProductName();
  33. else
  34. {
  35. %>
  36.     <span class="h9Verdana">Failed to obtain Product Id!
  37.     Please report this error to <a class="h8VerdanaBold" href="mailto:postmaster@jproxy.com">postmaster@jproxy.com</a></span>
  38. <%
  39.     return;
  40. }
  41.  
  42. String customerName = buycustomers.customer.getCustomerName();
  43. String host = "http://"+request.getServerName()+":"+request.getServerPort();
  44.  
  45. boolean isDisabled = false;
  46. ISaleFormula formula = (ISaleFormula)buycustomers.getSaleFormulaByProductID(productID);
  47.  
  48. int firstLicensePrice = formula.getFirstLicense();
  49. int additionalLicensePrice = formula.getAdditionalLicense();
  50. if(purchasedLicenses>0)
  51.     firstLicensePrice = additionalLicensePrice;
  52.  
  53. int customerId = 0;
  54. int invoice = 0;
  55.  
  56. // calculate the TOTAL AMOUNT based on the number of licenses and the pricing model
  57. double lic_cost = firstLicensePrice * buycustomers.formula.getDiscount();
  58. lic_cost += (licenses-1) * additionalLicensePrice * buycustomers.formula.getDiscount();
  59. //double sup_cost = lic_cost * buycustomers.formula.getSupport() * support_licenses;
  60. double sup_cost = lic_cost * buycustomers.formula.getSupport();
  61.  
  62. if(request.getParameter("submit_recalculate")!=null)
  63. {
  64. }
  65. if(request.getParameter("submit_purchase")!=null && request.getParameter("error")==null)
  66. {
  67. %>
  68.     <jsp:forward page="purchase.jsp"/>
  69. <%
  70. }
  71. %>
  72.   <!-- HEADER -->
  73.   <jsp:include page="header.jsp" flush="true">
  74.     <jsp:param name="name" value="ePortal - Purchasing Licenses and Technical Support"/>
  75.     <jsp:param name="pageId" value="buy"/>
  76.   </jsp:include>
  77.  
  78. <!-- MAIN PANEL -->
  79. <%
  80. ConfigMBean mbean = (ConfigMBean)JMXInvocator.getMBean("JProxy:service=JProxyConfigMBean", ConfigMBean.class);
  81. //String productName = mbean.get("com.jproxy.proxy.name") + " " + mbean.get("com.jproxy.proxy.version");
  82. String invoiceStr = mbean.get("com.jproxy.commerce.invoice");
  83. try{
  84.     invoice = Integer.parseInt(invoiceStr);
  85. }
  86. catch(Exception e)
  87. {
  88.     invoice = 15;
  89. }
  90. %>
  91.  
  92.   <br>
  93.   You're about to purchase licenses for your <span class="h9VerdanaBold"><%=customerName%></span> customer.
  94.   <p>
  95.   Once the payment is made the new total of purchased licenses will be changed to include newly purchased licenses.
  96.   <p>
  97.   Please enter the number of licenses you would like to purchase and click <b>Recalcualte</b> to get the updated price
  98.   <p>
  99.   <br>
  100.     <table class="h9Verdana" cellpadding="5" width="100%" border="0">
  101.   <!-- Prolog -->
  102.           <tr>
  103.            <td>
  104.                   <table class="h9Verdana" border="0" bgcolor="9c9cff" cellpadding="1" cellspacing="0">
  105.                    <tr><td>
  106.                      <%=productName%>
  107.                    </td></tr>
  108.                    <tr><td>
  109.                        <form method="get" action="buy.jsp">
  110.                            <table class="h8Verdana" border="0" bgcolor="white" cellpadding="5" cellspacing="1" width="100%">
  111.                             <tr>
  112.                              <td align="left">
  113.                                     <br>
  114.                                     Quantity:
  115.                                     <input type="input" name="licenses" value="<%=licenses%>" size="3">
  116.                                     <INPUT TYPE=HIDDEN NAME="customer-id" VALUE="<%=buycustomers.customerID%>">
  117.                                      Licenses:
  118.                                      <input type="text" name="total" READONLY value="$<%=lic_cost%>" size="8">
  119.                                      Technical Support:
  120.                                      <input type="text" name="total" READONLY value="$<%=sup_cost%>" size="8">
  121.                                      Order Total:
  122.                                      <input type="text" name="total" READONLY value="$<%=(lic_cost + sup_cost)%>" size="8">
  123.                              </td>
  124.                             </tr>
  125.                             <tr>
  126.                              <td class="h8Verdana" align="right">
  127.                               <INPUT TYPE=SUBMIT NAME=submit_recalculate WIDTH="20" VALUE="Recalculate">
  128.                               <INPUT TYPE=HIDDEN NAME="productid" VALUE="<%=buycustomers.product.getID()%>">
  129.                               <INPUT TYPE=HIDDEN NAME="purchased-licenses" VALUE="<%=purchasedLicenses%>">
  130.                              </td>
  131.                             </tr>
  132.                           </table>
  133.                       </form>
  134.     <!-- begin separator -->
  135.                     </td></tr>
  136.                     <tr><td>
  137.     <!-- end separator -->
  138.                      <table class="h8Verdana" width="100%" border="0" bgcolor="white" cellpadding="5" cellspacing="0" >
  139.                           <tr>
  140.                            <td align="left">
  141.                              When you're ready to proceed to a secure payment form
  142.                              please press the <b>Purchase</b> button
  143.                            </td>
  144.                            <td align="right">
  145.                              <br>
  146.         <%
  147.         String headerHTML = "<font size=30 color=#6331CE>JProxy</font>";
  148.             headerHTML += "<font size=10 color=#9C00FF>.com</font>";
  149.         String footerHTML = "<font size=2><em>Copyright 2001-2002, JProxy</em></font>";
  150.         String description = "productName : "+productName;
  151.             description += "<br>Customer Name : "+customerName;
  152.             description += "<br>Licenses # : "+licenses+" ($"+lic_cost+")";
  153.             description += "<br>Technical support : $"+sup_cost;
  154.         %>
  155.                              <FORM METHOD=POST ACTION="https://secure.authorize.net/gateway/transact.dll">
  156.                     <INPUT TYPE=HIDDEN NAME="number_of_licenses" VALUE="<%=licenses%>">
  157.                     <INPUT TYPE=HIDDEN NAME="customer-id" VALUE="<%=buycustomers.customerID%>">
  158.                     <INPUT TYPE=HIDDEN NAME="productid" VALUE="<%=buycustomers.product.getID()%>">
  159.                     <INPUT TYPE=HIDDEN NAME="parent-id" VALUE="<%=buycustomers.ses.getLogin().getID()%>">
  160.                     <INPUT TYPE=HIDDEN NAME="x_amount" VALUE="<%=(lic_cost + sup_cost)%>">
  161.                     <INPUT TYPE=HIDDEN NAME="x_Version" VALUE="3.0">
  162.                     <INPUT TYPE=HIDDEN NAME="x_Login" VALUE="jproxyllc">
  163.                     <INPUT TYPE=HIDDEN NAME="x_Show_Form" VALUE="PAYMENT_FORM">
  164.                     <INPUT TYPE=HIDDEN NAME="x_Cust_ID" VALUE="<%=customerId%>">
  165.                     <INPUT TYPE=HIDDEN NAME="x_Invoice_Num" VALUE="<%=invoice%>">
  166.                     <INPUT TYPE=HIDDEN NAME="x_Description" VALUE="<%=description%>">
  167.                     <!-- INPUT TYPE=HIDDEN NAME="x_Logo_URL" VALUE="http://jproxy.com/main/resources/jproxy.gif" -->
  168.                     <INPUT TYPE=HIDDEN NAME="x_Header_HTML_Payment_Form" VALUE="<%=headerHTML%>">
  169.                     <INPUT TYPE=HIDDEN NAME="x_Footer_HTML_Payment_Form" VALUE="<%=footerHTML%>">
  170.                     <INPUT TYPE=HIDDEN NAME="x_Receipt_Link_Method" VALUE="GET">
  171.                     <INPUT TYPE=HIDDEN NAME="x_Receipt_Link_Text" VALUE="Click here to continue">
  172.                     <INPUT TYPE=HIDDEN NAME="x_Receipt_Link_URL" VALUE="<%=host%>/main/customers/purchase.jsp;jsessionid=<%=request.getSession().getId()%>">
  173.                     <INPUT TYPE=SUBMIT NAME=submit_purchase WIDTH="20" VALUE="Purchase">
  174.                              </FORM>
  175.                            </td>
  176.                           </tr>
  177.                      </table>
  178.                    </td></tr>
  179.                   </table>
  180.            </td>
  181.           </tr>
  182.     </table>
  183.  
  184. <!-- FOOTER -->
  185. <jsp:include page="footer.jsp" flush="true"/>
  186.