<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="java.util.List"%>    
<%@page import="admin.model.BillMods"%>
<%@page import="model.BillInfo"%>
<%
List<BillInfo> bill = (List<BillInfo>) request.getAttribute("bills");
if(bill==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>
<script src="js/CheckChoice.js" type="text/javascript" charset="utf-8"></script>
<script src="js/DelChoiced.js" type="text/javascript" charset="utf-8"></script>
<title>Hoa Don Khach Hang</title>
<Script>
function delall(){
if(confirm('Bạn Thực Sự Muốn Xóa Toàn Bộ Hóa Đơn ?'))
{return true;}
else {return false;}
}
function changeSTT(){
	if(confirm('Bạn Muốn Thay Trạng Thái Hóa Đơn?'))
	{return true;}
	else {return false;}
	}
function del(){
	if(confirm('Bạn Thực Sự Muốn Xóa Hóa Đơn Này ?'))
	{return true;}
	else {return false;}
	}
document.title="Hóa Đơn Khách Hàng";
document.getElementById("titleMod").innerHTML = "Hóa Đơn";
</script>
</head>
<body>
<center>
<% if (bill.size() == 0){ %><div align="Center" style="border:1px solid #cfcfcf;padding:20px 10px 20px 10px;background-color:#f3f3f3; width:320px "><b>Chưa có hóa đơn nào</b></div><p><br><br><%} else { %>
<br>
<jsp:include page="userinfo.jsp"></jsp:include> 

<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">Thời Gian</th>
		<th style="background: #E3E3E3">Khách Hàng</th>
		<th style="background: #E3E3E3">Mã Sản Phẩm</th>
		<th style="background: #E3E3E3">Credit Card</th>
        <th style="background: #E3E3E3">Tổng Cộng</th>
        <th style="background: #E3E3E3">Trạng Thái</th>
        <th style="background: #E3E3E3">Xóa</th>
    </tr>   
<% for(int i  = bill.size()-1; i >=0 ; i--) {%>
    <tr align="center">
    		<td><input class="UniXT" onclick = "return checkIsAll();" name= "idchoiced<%= bill.size() - i %>" id= "lxt<%= bill.size() - i %>" type="checkbox" value = "<%= bill.get(i).getId() %>"/></td>
            <td><%= bill.size() - i %></td>
            <td><%= bill.get(i).getDate() %></td>
			<td><a href="../Bill?rep=view&page=<%= TrangHienTai %>&userinfo=<%= bill.get(i).getUser() %>" title="Xem Thông Tin"><%= bill.get(i).getUser() %></a></td>
			<td><textarea class="UniXT" rows="1" cols="15"><%= bill.get(i).getIdproduct()%></textarea></td>
			<td><textarea class="UniXT" rows="1" cols="15"><%= bill.get(i).getPayinfo() %></textarea></td>
            <td><%= Math.round(bill.get(i).getTotal()) %></td>
            <td>
  <% if (bill.get(i).getStatus().equals("ok")) { %><a onclick = "return changeSTT();" href="../Bill?rep=status&id=<%= bill.get(i).getId() %>&stt=wait&page=<%= TrangHienTai %>"> <div style="width: 45px; background: #7DB378; cursor: pointer;" title="Thay đổi trạng thái ?">&nbsp;</div></a>
  <% } else { %> <a onclick = "return changeSTT();" href="../Bill?rep=status&id=<%= bill.get(i).getId() %>&stt=ok&page=<%= TrangHienTai %>"> <div style="width: 45px; background: #C2C2C2; cursor: pointer;" title="Thay đổi trạng thái ?">&nbsp;</div></a> <% } %>
            </td>
            <td><a onclick = "return del();" href="../Bill?rep=delid&id=<%= bill.get(i).getId() %>&page=<%= TrangHienTai %>"><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="../Bill" onsubmit="return delall();">
<input type="hidden" name="rep" value="delall">
	<input onclick="return deleteIDChoiced('Bill', '<%= 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>
<span style="width: 40px; background: #7DB378">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> Đã thanh toán
<span style="width: 40px; background: #C2C2C2">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span> Đang xác nhận               

<Br><br><p>

<B>Trang</B> <% for (int t = 1; t <= TongSoTrang; t++){%>
       <a href="../Bill?rep=view&page=<%= t %>"><% if(TrangHienTai==t){ %></a><span style="padding: 5px 5px 5px 5px;background: #F5F5FF; border:0px ; font-size: 14px"><% } %> <%= t %></span> <% } %><br><br>
</center>
</body>
<% }} %>
</html>