<!--#include file="../inc/Secure.htm"-->
<%dim ThisKey
ThisKey = "w"
%>
<!--#include file="../inc/permission.htm"-->
<!--#include file="../inc/conn.htm"-->
<!--#include file="../inc/dbtools.htm"-->
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../CSS/main.css">
</HEAD>
<BODY BGCOLOR="#FFFFFF" leftmargin=20 topmargin=5>
<form name="SearchForm" method="post" action="">
<div align=center>
<table border=0 width="90%" bgcolor=#53A9FF cellspacing=1>
<tr bgcolor=#FFFFFF><td>
	<table border=0 width="100%" bgcolor=#FFFFFF cellspacing=1>
	<tr bgcolor=#FFFFFF>
	<td width="15%">复合检索：</td>
	<td width="30%">部  门：<%options "Department","tblDepartment","Name",Department%></td>
	<td width="40%">值班人：<input type="text" name="Title" class="input" size=20></td>
	<td></td>
	</tr>
	<tr bgcolor=#FFFFFF>
	<td width="15%"></td>
	<td width="30%">时间段：<input type="text" name="StartTime" class="input" size=10></td>
	<td width="40%">截止：<input type="text" name="EndTime" class="input" size=10>(yyyy-mm-dd)</td>
	<td><input type="submit" name="cmdUp" value="检  索" class="font9boldwhite"></td>
	</tr>
	</table>
</td></tr></table>
</div>
</form>
<div align=center>
<table border=0 width="90%"><tr><td>
<%
response.write "检索到的使用记录 共" & totalmessage & "条/" & totalpage & "页，每页"& maxmessage &"条"
if totalpage>0 then
	response.write "，第" & currentpage & "页　"
end if

if totalpage>1 then
	if currentpage>1 then%>
		<a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?Department=<%=Department%>&title=<%=title%>&page=<%=currentpage-1%>">上页</a>　　
		<%
	end if

	if currentpage+1<=totalpage then%>
		<a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?Department=<%=Department%>&title=<%=title%>&page=<%=currentpage+1%>">下页</a>
		<%
	end if
end if
%>
</td></tr></table></div>

<div align="center">
<table border=1 cellpadding=3 cellspacing=1 width="90%" bgcolor=#EEEEEE bordercolordark="#FFFFFF" bordercolorlight="#999999">
	<tr bgcolor=#CCCCCC><td colspan=4 align=center>
	<font color=red><b><%=gettableValue("tblDepartment","name","id",trim(msgarr(1,i)))%></b></font>
	<%if cdate(trim(msgarr(5,i)))>=now() then%>
		<font color=red><b><%=trim(msgarr(4,i))&"——"&trim(msgarr(5,i))%></b></font>
	<%else%>
		<b><%=trim(msgarr(4,i))&"——"&trim(msgarr(5,i))%></b>
	<%end if%>
	&nbsp;&nbsp;&nbsp;&nbsp;<a href="Watch_manage.htm?todo=delete&selectID=<%=trim(msgarr(0,i))%>" onclick="return CheckDelete();"><img src="../images/delete.gif" border=0></a>
	</td></tr>

	<tr>
	<td nowrap width="15%">值班人:</td>
	<td width="35%">
	<%if trim(msgarr(3,i))<>"" then%>
	<font color=red><%=trim(msgarr(3,i))%></font>
	<%end if%>
	&nbsp;</td>
	<td width="15%">值班部门:</td>
	<td width="35%">
	<%if trim(msgarr(1,i))<>"" then%>
	<%=GetTableValue("tblDepartment","Name","ID",trim(msgarr(1,i)))%>
	<%end if%>
	&nbsp;</td>
	
	</tr>

	<tr>
	<td width=60>安排人:</td>
	<td>
	<%if trim(msgarr(2,i))<>"" then%>
	<%=trim(msgarr(2,i))%>
	<%end if%>
	&nbsp;</td>
	<td nowrap width=60>填写时间:</td>
	<td>
	<%if trim(msgarr(6,i))<>"" then%>
	<%=trim(msgarr(6,i))%>
	<%end if%>
	&nbsp;</td>
	</tr>

	<!--tr>
	<td nowrap>值班主题:</td>
	<td colspan=3>
	<%if trim(msgarr(7,i))<>"" then%>
	<%=trim(msgarr(7,i))%>
	<%end if%>
	&nbsp;</td>
	</tr-->

	<tr>
	<td nowrap>值班内容说明：</td>
	<td colspan=3><%=replace(replace(server.htmlencode(trim(msgarr(8,i))&""),chr(13),"<br>")," ","&nbsp;")%>&nbsp;</td>
	</tr>
	<tr>
	<td nowrap>值班日记检查：</td>
	<td colspan=3>
	<%
	Department=trim(msgarr(1,i))
	WatchID=trim(msgarr(9,i))
	StartTime=trim(msgarr(4,i))
	EndTime=trim(msgarr(5,i))
	str=GetLog(trim(msgarr(0,i)),Department,WatchID,StartTime,EndTime)
	response.write str
	%>&nbsp;</td>
	</tr>
			
</table>
</div><BR></table>
</div> <BR>
<BR>

</BODY>
</HTML>
<script language=javascript>
function CheckDelete()
{
//	document.NewsForm.cmdDelete.value !=""
	return confirm("确实删除吗？");
}
</script>
<%
Function GetTableValue(TableName,Field,ValueField,Value)
	if TableName<>"" and Value<>"" then
		Set RsTmp = Server.Createobject("Adodb.recordset")
		strSql = "Select "& Field &" from "& TableName &" where "& ValueField &"='"& Value &"'"
		Rstmp.open strSql,oConn,1,1
		If not Rstmp.eof then
			GetTableValue=trim(Rstmp(Field))
		else
			GetTableValue=""
		end if
		Rstmp.close
		'set RsTmp = Nothing
	else
		GetTableValue=""
	end if
End Function

Function GetLog(ID,Department,WatchID,StartTime,EndTime)
	if isnumeric(Department) and isnumeric(WatchID) and isdate(StartTime) and isDate(EndTime) then
	set rstmp=Server.CreateObject("ADODB.RecordSet")
	sql="select count(*) as nCount from tblWatchLog where WriteID="& WatchID &" and DepartMent="& Department &" and Times>='"& StartTime &"' and Times<='"& EndTime &"'"
	rstmp.open sql,oConn
	if not rstmp.eof then
		nCount=trim(rstmp("nCount"))
		if nCount<>"0" then
			Getlog="<a href=ManageLog.htm?Department="&Department&"&ID="&ID&"&WriteId="&WatchID&">共检查到 <font color=red>"& nCount &"</font> 条值班日记！</a>"
		else
			Getlog="未填写值班日记！"
		end if
	else
		Getlog="未填写值班日记！"
	end if
	rstmp.close
	set rstmp=nothing
	else
		Getlog="出现错误！"
	end if
end Function

%>
<!--#include file="../inc/conn_close.htm"-->
<script language=javascript>
function CheckDelete()
{
	return confirm("确实删除吗？");
}
</script>