<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
     <%@page import="java.util.List"%>
    <%@page import="model.CommentInfo"%>
    <%@page import="model.Emoticon"%>
    <html>
<%
List<CommentInfo> cminfo = (List<CommentInfo>) request.getAttribute("cminfo");
if (cminfo == null) { %>
<link rel=stylesheet href='images/AjaxForm.css' type=text/css>
<script type="text/javascript" src="js/SearchID2.js"></script>
<script type="text/javascript">document.getElementById("titleMod").innerHTML = "Comment";</script>
<div style="border:1px solid #cfcfcf;padding:20px 0px 20px 5px;background-color:#f3f3f3; width:440px ">
<p>
<form action="../AComment" method="post" onsubmit="return SearchID2(this)">
<input type="hidden" name="rep" value="view"/>
Nhập ID sản phẩm
<input name="id" id="id2" type="text" onkeypress="return numberonly(event);">
  <input type="submit" class="UniXT" value="Tìm kiếm">
</form>
</div>

<% } else {

String id = request.getParameter("id");
	int TrangHienTai = Integer.parseInt(request.getParameter("cmpage"));
	int TongSoTrang = (Integer)request.getAttribute("cmrecord");
%>    

<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/DelChoicedComment.js" type="text/javascript" charset="utf-8"></script>
<Script>
function delall(){
if(confirm('Bạn Thực Sự Muốn Xóa Toàn Bộ Nhận Xét Của Sản Phẩm Này ?'))
{return true;}
else {return false;}
}
function numberonly(event) {
	 var chCode = (event.charCode === undefined) ? event.keyCode : event.charCode;
	 if (chCode > 31 && (chCode < 48 || chCode > 57))
	 {return false;}
	 else { return true;}
	  }

document.title="Quản Lý Comment";
document.getElementById("titleMod").innerHTML = "Comment";
</script>
<style>
.comment_ui
{
background-color: #F5F5FF; border-bottom:1px ;clear:left;float:none;
overflow:hidden;margin-bottom:2px;padding:6px 4px 3px 6px;width:450px; 
}


</style>
<title>Comment Manage</title>
<style>

.comment_ui
{
background-color: #F5F5FF; border-bottom:1px ;clear:left;float:none;
overflow:hidden;margin-bottom:2px;padding:6px 4px 3px 6px;width:410px; 
}
</style>

</head>
<body>

<% if (TongSoTrang == 0) { %>
<div align="Center" style="border:1px solid #cfcfcf;padding:20px 10px 20px 10px;background-color:#f3f3f3; width:410px "><b>Chưa có bình luận nào với sản phẩm này</b></div>
<% } else { %>

<p>
<table 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">Nội dung bình luận (Sản phẩm #<%= id %>)</th>
		<th style="background: #E3E3E3">Xóa</th>
    </tr>
    <%for(int i  = cminfo.size()-1; i >=0 ; i--) { %>
        <tr align="center">
        <td><input class="UniXT" onclick = "return checkIsAll();" name= "idchoiced<%= cminfo.size() - i %>" id= "lxt<%= cminfo.size() - i %>" type="checkbox" value = "<%= cminfo.get(i).getId() %>"/></td>
            <td>
	<div align="left" class="comment_ui"> <i><font color="#828282"><%= cminfo.get(i).getDate() %> </font></i><b> <%= cminfo.get(i).getUser() %>:</b> <%= new Emoticon().EmoticonRe(cminfo.get(i).getContent()) %></div>		
			
			</td>
			<td><a href="../AComment?rep=DelCm&id=<%= cminfo.get(i).getId() %>&idpd=<%= cminfo.get(i).getIdpd() %>&cmpage=<%= TrangHienTai %>"><img border="0" src="images/discard.jpg" width="25" height="25" title="Xóa"></a></td>
        </tr>
        <%} %> 
		
<tr><td colspan="7" valign="baseline" align="center">
<Br>
<B>Trang</B> <% for (int t = 1; t <= TongSoTrang; t++){%>
       <a href="../AComment?rep=view&id=<%= id %>&cmpage=<%= t %>"><% if(TrangHienTai==t){ %></a><span style="background: #F5F5FF; border:0px ; font-size: 14px"><% } %> <%= t %></span><%} %>

</td>	</tr>

        <tr><td colspan="7" valign="baseline" align="right">
        <Br>
<form method="post" action="../AComment" onsubmit="return delall();">
<input type="hidden" name="rep" value="DelAllCm">
<input type="hidden" name="idpd" value="<%= id %>">
	<input onclick="return deleteIDChoiced('AComment', '<%= cminfo.get((cminfo.size()-1)).getIdpd() %>', '<%= 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>


       <% }} %>
</body>
</html>