home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / JAVA Utilities / JProxy 1.1.0 / customers / product-list.jsp < prev    next >
Encoding:
Text File  |  2003-04-29  |  5.6 KB  |  187 lines

  1. <%@ page language="java" import="
  2.     java.util.*,
  3.     com.jproxy.site.ejbeans.interfaces.*,
  4.     com.jproxy.site.*"
  5. %>
  6.  
  7. <script language="JavaScript">
  8.   function luanch_browser(sPageURL)
  9.   {
  10.     window.open(sPageURL, null, "");
  11.   }
  12. </script>
  13.  
  14. <jsp:useBean id="ses" scope="session" class="com.jproxy.site.JSPSession"/>
  15. <%
  16. if (!ses.isLoggedIn())
  17. {
  18. %>
  19.   <jsp:forward page="login.jsp">
  20.   </jsp:forward>
  21. <%
  22. }
  23. ses.request(pageContext);
  24. ses.setNewHit(pageContext, "hits", "Product List", null);
  25. %>
  26.  
  27. <%
  28. String bgcolors[] = {"#F3F8FF", "#FFFFFF"};
  29.  
  30. String customerID = ses.getParameter("customer-id");
  31. if(customerID.trim().length()==0||ses.isAdmin())
  32.     customerID = ses.getLogin().getID();
  33.  
  34. Vector formulas = null;
  35. try{
  36.     formulas = ses.session.getSaleFormulas(customerID);
  37. }catch(Exception e)
  38. {
  39.     e.printStackTrace();
  40. }
  41.  
  42. %>
  43.   <!-- HEADER -->
  44.   <jsp:include page="header.jsp" flush="true">
  45.     <jsp:param name="pageId" value="product_list"/>
  46.   </jsp:include>
  47.  
  48. <!-- MAIN PANEL -->
  49. <%
  50. int totalPurchasedLicenses = 0;
  51. %>
  52. <br>
  53. This is a list of all available products. You may choose any of available actions
  54. against each product name and version. You may buy licenses for a product,
  55. review its release notes and if you have a valid support contract then you may
  56. be able to interact with our technical support engineers via private Forums.
  57. <p>
  58. Each purchased product version get its own private Forum. If you have a question
  59. or would like  to report a bug please choose the product name and version that your
  60. question relates to and follow the [Forum] link.
  61. Once in forum submit your questions there.
  62.  
  63. <p>
  64.  <table class="h8Verdana" border="0" cellpadding="2" cellspacing="2" width="100%">
  65.   <tr class="h8VerdanaBold" bgcolor="9c9cff">
  66.     <td>Product Name</td>
  67.     <td>Product Version</td>
  68.     <td>Release Date</td>
  69.     <td>Purchased<br>licenses</td>
  70.     <td>Action</td>
  71.   </tr>
  72. <%
  73. /*
  74. int productLastPurchaseID = 0;
  75. for(int i=0; i<formulas.size(); i++)
  76. {
  77.     IProduct product = (IProduct)products.elementAt(i);
  78.     String productID = product.getID();
  79.     Vector purchases = ses.session.findPurchases(customerID, productID);
  80.     if(purchases.size()>0)
  81.     {
  82.         productLastPurchaseID = i+1;
  83.         break;
  84.     }
  85. }
  86. */
  87. int nTotalProducts = 0;
  88. // for each "saleable" product for this customer
  89. for(int i=0; i<formulas.size(); i++)
  90. {
  91.   // get its sale formula interface
  92.   ISaleFormula saleFormula = (ISaleFormula)formulas.elementAt(i);
  93.  
  94.   if (!saleFormula.getType().equals("development"))
  95.     continue;
  96.  
  97.   nTotalProducts++;
  98.  
  99.   // get its product that this sale formula interface is bound to
  100.   IProduct product = (IProduct)ses.session.getProductById(saleFormula.getProductID());
  101.   String productID = product.getID();
  102.   String productName = product.getProductName();
  103.  
  104.   // calcaulate total license purchase for this product
  105.   Vector purchases = ses.session.findPurchases(customerID, productID);
  106.   int purchasedLicenses = 0;
  107.   for(int j=0; j<purchases.size(); j++)
  108.   {
  109.     IPurchase purchase = (IPurchase)purchases.elementAt(j);
  110.     int licenses = purchase.getNumberOfLicenses();
  111.     purchasedLicenses += licenses;
  112.     totalPurchasedLicenses += licenses;
  113.   }
  114. %>
  115.   <tr bgcolor="<%=bgcolors[i % 2]%>">
  116.     <td align="left">
  117.       <%=productName%>
  118.     </td>
  119.     <td align="left"><%=product.getProductVersion()%></td>
  120.     <%
  121.         java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(JSPRes.dateFormar);
  122.         String releaseDate = sdf.format(new Date(product.getReleaseDate()));
  123.     %>
  124.     <td align="left"><%=releaseDate%></td>
  125.     <td align="left">
  126.       <%=purchasedLicenses%>
  127.     <%
  128.     if(purchasedLicenses>0)
  129.     {
  130.     %>
  131.       <a class="h8Verdana" href="<%=JSPRes.path%>/main/customers/purchases-list.jsp?customer-id=<%=customerID%>&product-id=<%=productID%>"> [details] </a><br>
  132.     <%
  133.     }
  134.     %>
  135.     </td>
  136.     <td align="left">
  137.       <a class="h8Verdana" href="<%=JSPRes.path%>/main/customers/buy.jsp?productid=<%=productID%>&customer-id=<%=customerID%>&purchased-licenses=<%=purchasedLicenses%>"> [Buy] </a>
  138.     <%
  139.     ISaleFormula sf = (ISaleFormula)formulas.elementAt(0);
  140.     String upgradeProductID = sf.getProductID();
  141.     if(!upgradeProductID.equalsIgnoreCase(JSPRes.defaultTunnelLicenseID)&&purchasedLicenses>0)
  142.     {
  143.     %>
  144.       <br><a class="h8Verdana" href="<%=JSPRes.path%>/main/customers/buy.jsp?productid=<%=upgradeProductID%>&customer-id=<%=customerID%>&purchased-licenses=<%=purchasedLicenses%>&is-upgrade=true"> [Upgrade] </a>
  145.     <%
  146.     }
  147.     %>
  148.     <%
  149.         // if this guy has actually bought at least one license then let him have access to Forums
  150.         // TO DO: Disable editing capabilities, once the support contract is over
  151.     String permit = ses.getLogin().getPermit();
  152.     if(permit==null)
  153.         permit = "";
  154.     if(purchasedLicenses>0||permit.equalsIgnoreCase("admin")||permit.equalsIgnoreCase("forum"))
  155.     {
  156.     %>
  157.       <br><a class="h8Verdana" href="<%=JSPRes.path%>/main/mlist/topic.jsp?command=refresh&product-id=<%=productID%>"> [Forum] </a>
  158.     <%
  159.     }
  160.     %>
  161.       <br><a class="h8Verdana" target="_blank" href="../release-notes/<%=product.getReleaseNotes()%>"> [Notes] </a>
  162.     </td>
  163.   </tr>
  164. <%
  165. }
  166. %>
  167. </table>
  168. <p>
  169. <table class="h8Verdana" width="100%" border="0" bgcolor="#f3f8ff" cellpadding="1" cellspacing="0">
  170.   <tr>
  171.    <td>
  172.      <span class="h8Verdana">
  173.        You've a total of <span class="h8VerdanaBold"><%=nTotalProducts%></span>
  174.        products with total purchase of <span class="h8VerdanaBold"><%=totalPurchasedLicenses%></span>
  175.        licenses
  176.      </span>
  177.    </td>
  178.   </tr>
  179. </table>
  180. <p>
  181. If you want to get a combined view of all Forums, please follow this link:
  182. <a class="h8VerdanaBold" href="<%=JSPRes.path%>/main/mlist/topic.jsp?command=refresh"> [All Forums] </a>
  183.  
  184.  
  185. <!-- FOOTER -->
  186. <jsp:include page="footer.jsp" flush="true"/>
  187.