<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Food Planet - Food Items</title>
    </head>
    <body>

    <h1>Food Planet - Food Items</h1>
<c:choose>
	<c:when test="${not empty requestScope.list}">
		<table width="100%" border="1" cellspacing="1" cellpadding="2">
			<tr>
                            <td style="background-color:silver;width:40px"></td>
                            <td style="background-color:silver;"><b>Item</b></td>
                            <td style="background-color:silver;">&nbsp;</td>
			</tr>
			<c:forEach var="c" items="${requestScope.list}">
                        <tr>
                            <td>
                                ${c.id}
                            </td>
                            <td valign="top">
                                <span style="font-size:12pt;font-weight:bold;color:blue">${c.name}</span><br/>
                                ${c.description}
                                <br/>
                                <b>Price: ${c.price}</b>
                                <br/>
                                [Available: ${c.quantityStocked}]
                                <c:choose>
                                    <c:when test="${c.quantityStocked gt 0}">
                                        <button id="btnUpStock" onclick="location.href='upstock.do?id=${c.id}&catid=${param.catid}';">Purchase</button>
                                    </c:when>
                                    <c:otherwise>
                                        <button id="btnUpStock" disabled="true">Purchase</button>
                                    </c:otherwise>
                                </c:choose>
                            </td>
                            <td>
                                <img src="../images/products/${c.imgFile}" style="height:120px"/>
                            </td>
                        </tr>
                        
			</c:forEach>
		</table>
	</c:when>
        <c:otherwise>
            <tr><td><h3>No Food Items Found!</h3></td></tr>
        </c:otherwise>
</c:choose>

<br/>
<fieldset>
    <button id="btnReturnCat" onclick="location.href='../category/list.do';">&lt;&lt; Categories</button>
    <button id="btnShowAll" onclick="location.href='list.do';">&lt;&lt; Show All Products</button>
</fieldset>

    </body>
</html>
