<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>

    <%@page import="model.ThongTinSanPham"%>
    <%@page import="java.util.List"%>
<%@page import="model.SanPham"%>
<% 
List<ThongTinSanPham> product = (List<ThongTinSanPham>) request.getAttribute("sanpham");
if(product==null) { %><% } else { 
int TrangHienTai = Integer.parseInt(request.getParameter("page"));
int TongSoTrang = (Integer)request.getAttribute("TongSoTrang");
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel=stylesheet href='images/style.css' type=text/css>
<link rel="stylesheet" type="text/css" href="highslide/highslide.css" />
<script type="text/javascript" src="highslide/highslide-with-html.js"></script>
<script src="js/CheckChoice.js" type="text/javascript" charset="utf-8"></script>
<script src="js/DelChoicedPdSo.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript">
	hs.graphicsDir = 'highslide/graphics/';
	hs.outlineType = 'rounded-white';
	hs.showCredits = false;
	hs.wrapperClassName = 'draggable-header';
</script>
<Script>
function delall(){
if(confirm('Bạn Thực Sự Muốn Xóa Toàn Bộ Sản Phẩm Này ?'))
{return true;}
else {return false;}
}
document.title="Sản Phẩm Đã Hết Hàng"; 
document.getElementById("titleMod").innerHTML = "SP Hết Hàng";
</script>
<title>Sam Pham Het Hang</title>
</head>
<body>
<% if (product.size() == 0){ %><div align="Center" style="border:1px solid #cfcfcf;padding:20px 10px 20px 10px;background-color:#f3f3f3; width:320px "><b>Chưa có sản phẩm nào hết hàng</b></div><p><br><br><%} else { %>
<br>
<center>
<p>
<table class="tablext" border="1" cellspacing="0" style="border-collapse: collapse" bordercolor="silver" cellpadding="3">
    <tr>
    	<th style="background: #E3E3E3"><input class="UniXT" id ="checkAll" onclick = "return checkHow();" type="checkbox" /></th>
        <th style="background: #E3E3E3">STT</th>
		<th style="background: #E3E3E3">ID</th>
        <th style="background: #E3E3E3">Tên Sản Phẩm</th>
		<th style="background: #E3E3E3">Thể Loại</th>
        <th style="background: #E3E3E3">Giá (vnđ)</th>
        <th style="background: #E3E3E3">Trạng Thái</th>
        <th style="background: #E3E3E3">Chỉnh Sửa</th>
        <th style="background: #E3E3E3">Xóa</th>
    </tr>  
<% for(int i  = product.size()-1; i >=0 ; i--) { %>
        <tr align="center">
         <td><input class="UniXT" onclick = "return checkIsAll();" name= "idchoiced<%= product.size() - i %>" id= "lxt<%= product.size() - i %>" type="checkbox" value = "<%= product.get(i).getId() %>"/></td>
            <td><%= product.size()- i %></td>
			<td># <%= product.get(i).getId() %></td>
            <td><div>
<a href="#" onclick="return hs.htmlExpand(this, {headingText: '<%= product.get(i).getName() %>' })"><%= product.get(i).getName() %></a>
<div class="highslide-maincontent">
<% if (product.get(i).getImage().substring(0,4).equals("http")) { %>
<img src="<%= product.get(i).getImage() %>" width="170" height="180" title="<%= product.get(i).getImage() %>"> <% } else { %>
<img src="../<%= product.get(i).getImage() %>" width="170" height="180" title="<%= product.get(i).getImage()%>">
<% } %>
	</div>
		</div>
</td>
			<td><%= product.get(i).getCategory() %></td>
            <td><%= Math.round(product.get(i).getPrice()) %></td>
            <td>       
            <% String TrangThaiSP = product.get(i).getStatus(); if (TrangThaiSP == null){TrangThaiSP = "HetHang";} 
            if (TrangThaiSP.equals("ConHang")){TrangThaiSP = "Còn hàng";} else {TrangThaiSP = "Hết hàng";}
            %>   
       <%= TrangThaiSP %>
            </td>
			<td><a href="../ProductController?rep=editpdso&page=<%= TrangHienTai %>&id=<%= product.get(i).getId()%>"><img border="0" src="images/edit.png" width="25" height="25" title="Chỉnh Sửa"></a></td>
			<td><a href="../ProductController?rep=delidso&page=<%= TrangHienTai %>&id=<%= product.get(i).getId()%>"><img border="0" src="images/discard.jpg" width="25" height="25" title="Xóa"></a></td>
        </tr>  
        <% } %>       
             
        <tr><td colspan="9" valign="baseline" align="right">
        <Br>
<form method="post" action="../ProductController" onsubmit="return delall();">
<input type="hidden" name="rep" value="delallpdso" title="Xóa Toàn Bộ">
	<input onclick="return deleteIDChoiced('ProductController', '<%= TrangHienTai %>');" class ="UniXT" type="button" value = "Xóa chọn"/>
	<input type="submit" class="UniXT" value="Xóa toàn bộ"/>
	</form></td></tr>
                    
    </table>  
    <br><p>
<B>Trang</B> <% for (int t = 1; t <= TongSoTrang; t++){%>
       <a href="../ProductController?rep=showpdso&page=<%= t %>"><% if(TrangHienTai==t){ %></a><span style="padding: 5px 5px 5px 5px; background: #F5F5FF; border:0px ; font-size: 14px"><% } %> <%= t %></span>
       <%}}}%> 
<br>
</Center>
<br>
</body></html>