<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
 <%@ page import="cn.sendsms.jdsmsserver.web.*" %>
 <%@ page import="cn.sendsms.jdsmsserver.*"%>
<%
response.setHeader("Cache-Control","no-store");
response.setHeader("Pragrma","no-cache");
response.setDateHeader("Expires",0);
%>
<%
User user=(User)session.getAttribute("user");
%>
<!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><%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_List")%></title>
<link href="css.css" type="text/css" rel="stylesheet">
<script type="text/javascript">
function next(){
	var index = document.getElementById('pageIndex').selectedIndex;
	var pageIndex = document.getElementById('pageIndex').options[index].value;
	++pageIndex;
	window.location.href="/smsAction?action=unsentRecord&pageIndex="+pageIndex;	
}
function pre(){
	var index = document.getElementById('pageIndex').selectedIndex;
	
	var pageIndex = document.getElementById('pageIndex').options[index].value;
	--pageIndex;
	
	window.location.href="/smsAction?action=unsentRecord&pageIndex="+pageIndex;	
}
function turn(){
	var index = document.getElementById('pageIndex').selectedIndex;
	var pageIndex = document.getElementById('pageIndex').options[index].value;
	window.location.href="/smsAction?action=unsentRecord&pageIndex="+pageIndex;	
}
function selectAll(option){
	var checked=option.checked;
	 var uMsgTable=document.getElementById('uMsgTable');
	   var len=uMsgTable.rows.length;
	   if(len<=2){
		   alert('<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_chose_nothing")%>');
		   return;
	   }
	   for(var i=1;i<len-1;i++){
		   uMsgTable.rows[i].cells[0].childNodes[0].checked=checked;
	   }
}
function delStopMsg(){
   var uMsgTable=document.getElementById('uMsgTable');
   var len=uMsgTable.rows.length;
   var isSelected=false;
   var msgId;
   var msgIdArray=new Array();
   if(len<=2){
	   alert('<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_have_nothing")%>');
	   return;
   }
   var k=0;
   for(var i=1;i<len-1;i++){
	   if(uMsgTable.rows[i].cells[0].childNodes[0].checked){
		   msgIdArray[k++]=uMsgTable.rows[i].cells[0].childNodes[0].value;
		   isSelected=true;
	   }
   }
   if(!isSelected){
	   alert('<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_chose_record_to_delete")%>');
	   return;
   }
   if (window.confirm('<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_make_sure_to_delete")%>')) {
		//window.location.href="/smsAction?action=cancelWaitMsg";
		with (document.getElementById("uMsgForm")) {
			action="smsAction?action=deleteCanceledMsg";
			method="post";
			submit();
		}
   }
}

function delAllCancelledMsg(){
	   if (window.confirm('<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_make_sure_to_delete")%>')) {
			//window.location.href="/smsAction?action=cancelWaitMsg";
			with (document.getElementById("uMsgForm")) {
				action="smsAction?action=deleteAllCanceledMessage";
				method="post";
				submit();
			}
	   }
}

function cancellAllWaitMsg(){
	   if (window.confirm('<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_make_sure_to_cancel_all")%>')) {
			//window.location.href="/smsAction?action=cancelWaitMsg";
			with (document.getElementById("uMsgForm")) {
				action="smsAction?action=cancelAllWaitMsg";
				method="post";
				submit();
			}
	   }
}

function cancelUMsg(){
   var uMsgTable=document.getElementById('uMsgTable');
   var len=uMsgTable.rows.length;
   var isSelected=false;
   var msgId;
   var msgIdArray=new Array();
   if(len<=2){
	   alert('<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_have_nothing")%>');
	   return;
   }
   var k=0;
   for(var i=1;i<len-1;i++){
	   if(uMsgTable.rows[i].cells[0].childNodes[0].checked){
		   msgIdArray[k++]=uMsgTable.rows[i].cells[0].childNodes[0].value;
		   isSelected=true;
	   }
   }
   if(!isSelected){
	   alert('<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_chose_record_to_cancel")%>');
	   return;
   }
   if (window.confirm('<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_make_sure_to_cancel")%>')) {
		with (document.getElementById("uMsgForm")) {
			action="smsAction?action=cancelWaitMsg";
			method="post";
			submit();
		}
   }
}
<%
	    if("admin".equals(user.getUserId())){
%>
	   function cancelmsg(){
	   window.location.href="/smsAction?action=cancelWaitMsg";	
}
      function deletemsg(){
	  window.location.href="/smsAction?action=deleteCanceledMsg";	
}
<%
	 }
%>
function cancelmsg(){
	window.location.href="/smsAction?action=cancelWaitMsg";	
}
function deletemsg(){
	window.location.href="/smsAction?action=deleteCanceledMsg";	
}
</script>
<style type="text/css">
	.input_foot_bt{
		display: inline-block;
		background: #fcfcfc;
		border:1px solid #141415;
		padding:0px 4px;
		border-radius: 4px;
		margin-left:0px;
		vertical-align: middle;
		height:30px !important;
	}
	.input_foot_bt:hover{
		border:1px solid #34a2c0;
	}
	.input_foot_bt_ico1,.input_foot_bt_ico2,.input_foot_bt_ico3,.input_foot_bt_ico4{margin-top:1px;}
	.input_foot_bt .input_foot_bt_ico1{
		float:left;
		display: inline-block;
		width:28px;
		height: 28px;
		background: url(w_img/delete.png);
	}
	.input_foot_bt .input_foot_bt_ico2{
		float:left;
		display: inline-block;
		width:28px;
		height: 28px;
		background: url(w_img/close.png);
	}
	.input_foot_bt .input_foot_bt_ico3{
		float:left;
		display: inline-block;
		width:28px;
		height: 28px;
		background: url(w_img/closeall.png);
	}
	.input_foot_bt .input_foot_bt_ico4{
		float:left;
		display: inline-block;
		width:28px;
		height: 28px;
		background: url(w_img/deleteall.png);
	}
	.input_foot_bt input{
		border:none;
		outline: none;
		float:left;
		margin-left:0px;
		line-height: 28px;
		background: #fff;
		font-size:10px;
	}
	#table table tr td{
		/*border:2px solid #f00;*/
	}
	.wscroll::-webkit-scrollbar{
		width:8px;
	}
	.wscroll::-webkit-scrollbar-track{
		background-color: red;
		background:#ececec;
		-webkit-border-radius: 2em;
		-moz-border-radius: 2em;
		border-radius: 2em;
	}
	tr:hover td{
		background:#ececec !important;
	}
	tr:first-child:hover td{
		background:#dfe9ed !important;
	}
</style>
</head>
<body>
<div id="top"><span><img src="img/tu1.jpg"></span><%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_List")%></div>
<div id="center">
<form id="uMsgForm" name="uMsgForm">
<div id="table">
<table cellpadding="0" cellspacing="1" border="0" width="100%" id="uMsgTable">

					<tr align="center">
						<th width="1%"><input type="checkbox" name="choose"
							onclick="selectAll(this)"></th>
						<th width="6%">ID</th>
						<th width="11%"><%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault)
					.getString("settings.pending_message_status")%></th>
						<th width="13%"><%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault)
					.getString("settings.pending_message_submit_time")%></th>
						<th width="50%"><%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault)
					.getString("settings.pending_message_content")%></th>
						<th><%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault)
					.getString("settings.pending_message_destination")%></th>
						<th width="6%"><%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault)
					.getString("settings.pending_message_port")%></th>
						<th width="6%"><%=ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault)
					.getString("settings.pending_message_type")%></th>
					</tr>
					<%
	Page page1 = (Page)request.getAttribute("page");
	if(page1==null)page1 = new Page();
	for(int i = 0;i<page1.getData().size();i++){
		OutMessage msg =(OutMessage) page1.getData().get(i);
%>
<tr align="center">
<td align="center"><input type="checkbox" name="selectFlag"  value="<%=msg.getId()%>"></td>
<td><%=msg.getId() %></td>
<td><%
switch(msg.getStatus()){
case 'U':
	out.print(ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_waiting"));
	break;
case 'Q':
	out.print(ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_sending"));
	break;
case 'Z':
	out.print(ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_stop"));
	break;
}
%></td>
<td style="white-space:nowrap;"><%=msg.getCreateTime() %></td>
<td align="left"><span class="wscroll" style="display: inline-block;height:50px;overflow: hidden;overflow-y: auto;">
<%
	String strContent = msg.getContent();
	strContent = strContent.replaceAll("<", "&lt;");
	strContent = strContent.replaceAll(">", "&gt;");
	out.print(strContent);
%>
<%if(msg.getWap_url()!=null)out.print(msg.getWap_url()); %></span>
</td>
<td>
<%
if(msg.getName().trim().equals("")){
	out.print(msg.getRecipient());
}else{
	out.print(msg.getName()+"("+msg.getRecipient()+")");
}
%>
</td>
<td align="center"><%=msg.getGateway_id().trim() %></td>
<td><%
switch(msg.getType()){
case 'O':
	out.print(ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_normal"));
	break;
case 'W':
	out.print("WAP");
	break;
}
%></td>
</tr>
<%} %>

<tr style="border:none;">
<td colspan="5" align="left" style="background:#ececec;border-radius:10px 0px 0px 10px;border-right:none;padding-top:5px;padding-bottom: 5px;">
		<input type="checkbox"  class="input_nomargin_bt" style="margin-top:8px;" name="choose" onclick="selectAll(this)">
		<div class="input_foot_bt">
			<i class="input_foot_bt_ico2"></i>
			<input type="button"  value="<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_cancel")%>" onclick="cancelUMsg()" >
		</div>
		<div class="input_foot_bt">
			<i class="input_foot_bt_ico1"></i>
			<input type="button"  value="<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_delete")%>" onclick="delStopMsg()" >
		</div>
		<div class="input_foot_bt">
			<i class="input_foot_bt_ico3"></i>
			<input type="button"  value="<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_cancel_all")%>" onclick="cancellAllWaitMsg()" >
		</div>
		<div class="input_foot_bt">
			<i class="input_foot_bt_ico4"></i>
			<input type="button"  value="<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_delete_all")%>" onclick="delAllCancelledMsg()" >
		</div>
		
	<!-- <input type="button" class="input_nomargin_bt" style="height:30px;text-align: center;"  value="<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_cancel")%>" onclick="cancelUMsg()" >
	<input type="button" class="input_nomargin_bt" value="<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_delete")%>" onclick="delStopMsg()">  
	<input type="button" class="input_nomargin_bt"  value="<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_cancel_all")%>" onclick="cancellAllWaitMsg()" >
	<input type="button" class="input_nomargin_bt" value="<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_delete_all")%>" onclick="delAllCancelledMsg()"> -->
</td>
<td colspan="3" align="right" style="background:#ececec;border-radius:0px 10px 10px 0px;padding:5px 0px;padding-right:5px; ">
<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_records")%><%=page1.getTotalNum() %><%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_pages")%><%=page1.getPageNum()%><%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_records_page")%><%=page1.getPageSize() %>
<input type="button" <%if(page1.getPageIndex()==1)out.print("disabled"); %> value="<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_previous_page")%>" onclick="pre()"><input type="button" value="<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_next_page")%>" <%if(page1.getPageIndex()>=page1.getPageNum())out.print("disabled"); %> onclick="next()">
<%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_page1")%><select id="pageIndex" name="pageIndex" onchange="turn()">
<%
for(int i=0;i<page1.getPageNum();i++){
%>
<option value="<%=i+1 %>" <%if(page1.getPageIndex()==i+1)out.print("selected"); %>> <%=i+1 %></option>
<%} %>
</select><%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_page2")%>
</td>
</tr>

</table></div>
</form>
<div style="margin-top:15px;"><%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_tips")%> </div>
<div><%= ResourceManager.getInstance().getBykey(ResourceManager.getInstance().m_sDefault).getString("settings.pending_message_tips1")%> </div>
</div>
<%if(request.getAttribute("message")!=null) {%>
<script type="text/javascript">
alert('<%=request.getAttribute("message")%>');
</script>
<% }%>
<%
if(request.getAttribute("global_info")!=null&&request.getAttribute("global_info")!=""){	
%>

<script type="text/javascript">
alert('<%=request.getAttribute("global_info")%>');
</script>

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