<%-- 
/**
  * Copyright (c) 2004 Red Hat, Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Lesser General Public
  * License as published by the Free Software Foundation; either
  * version 2.1 of the License, or any later version.
  *
  * This library is distributed in the hope that it will be useful,
  * but WITHOUT ANY WARRANTY; without even the implied warranty of
  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  * Lesser General Public License for more details.
  *
  * You should have received a copy of the GNU Lesser General Public
  * License along with this library; if not, write to the Free Software
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
  * USA
  *
  * Component of: Red Hat Application Server
  * 
  * Initial Developers: Aizaz Ahmed
  *                     Vivek Lakshmanan
  *                     Andrew Overholt
  *                     Matthew Wringe
  *
  */
--%>
<%@ page contentType="text/html"
         import="olstore.entity.UserLocal"
         import="olstore.entity.UserLocalHome"
         import="olstore.framework.EJBHomeFactory"
         import="java.util.Iterator"
         import="java.util.Collection"

%>

    <% request.setAttribute ( "page_title", "My Account" ); %>
    <jsp:include page="../nav/Header.jsp" />

    <!-- Content begins here -->
    <div id="form">

    <div class="formHeader"> Your Account Status </div><br />
        <div class="orderListView" style="background:#e0b080">
            <span class="label" style="text-align:center ; font-weight:bold"> Item </span>
            <span class="quantity" style="text-align:center ; font-weight:bold"> Qty</span>
            <span class="status" style="text-align:center ; font-weight:bold"> Status</span>
            <span class="date" style="text-align:center ; font-weight:bold"> Date Ordered </span>
            <span class="price" style="text-align:center ; font-weight:bold ; color:#000;"> Price</span>
            <div class="spacer" ></div>
        </div>
<%
    EJBHomeFactory factory=EJBHomeFactory.getInstance();
    UserLocalHome userHome = (UserLocalHome)factory.getLocalHome (EJBHomeFactory.USER);
    UserLocal user = userHome.findByUsername ( request.getRemoteUser() );

    String template = "OrderListView.jsp";

    Collection orders = user.getOrders ();
    
    if ( ! orders.isEmpty() ) {
        Iterator it = orders.iterator();
        while ( it.hasNext() ) {
            request.setAttribute ( "orderToDisplay", it.next() );
            request.setAttribute ( "template", template );
%>
            <jsp:include page="OrderListView.jsp" />
<%
        }
    } else {
%>
        <div class="error"> You have not placed any orders</div>
<%
    }
%>
    
    <!-- This is necessary to force the parent to expand and include floating divs -->
    <br style="clear:both">
</div>
    <jsp:include page="../nav/Footer.jsp" />
