<!--#INCLUDE FILE="../HXINCLUDE/HXINCLUDEHEAD.ASP"-->
<!--#include file ="../HXINCLUDE/SelectDate.asp"-->
<%if WS_S.MemberPriv("WS_PublicAffairsOfficeEdit")<>1 or WS_S.MemberPriv("WS_PublicAffairsOfficeDel")<>1 then  response.Write "<script>alert('对不起,您的权限不够!');window.close();</script>":response.end
ColumnName="":Tablename="HX_Office":Tablename1="HX_OfficeUseed"
 passorlost=request("passorlost")
 WS_USID=request("WS_USID")
 WS_OFID=request("WS_OFID")
 action=request("action")
if action="View" then '查看分情况
 Orderby=" where WS_OFID="&WS_OFID
 set rs=WS_S.HX_SetRSD(ColumnName,Tablename,Orderby)
 if rs.recordcount<=0 then
    response.write "<script>alert('非法操作');window.close();</script>"
    response.end 
 end if
 msg="查看分发情况"
else'申请使用
 if WS_OFID="" or isnull(WS_OFID) or (WS_OFID<>"" and not isnumeric(WS_OFID)) then
 	response.write "<script>alert('非法操作');window.close();</script>"
    response.end  
 end if
if passorlost="pass" then
  conn.execute("update HX_OfficeUseed set WS_OfficeUseed=True where WS_USID="&WS_USID)
  response.Redirect "OfficeUseed.asp?action=View&WS_USID="&WS_USID&"&WS_OFID="&WS_OFID
  response.end
elseif passorlost="lost" then
  conn.execute("update HX_OfficeUseed set WS_OfficeUseed=False where WS_USID="&WS_USID)
  response.Redirect "OfficeUseed.asp?action=View&WS_USID="&WS_USID&"&WS_OFID="&WS_OFID
  response.end
end if
 Orderby=" where WS_OFID="&WS_OFID
 set rs=WS_S.HX_SetRSD(ColumnName,Tablename,Orderby)
 if rs.recordcount<=0 then
    response.write "<script>alert('非法操作');window.close();</script>"
    response.end 
 end if
 if action="replysave" then
   OfficeReplyNum=request("WS_OfficeReplyNum")
   OfficeReplyDate=request("WS_OfficeReplyDate")
   if not isdate(OfficeReplyDate) then
     OfficeReplyDate=date
   end if  
   OfficeReplyComment=request("WS_OfficeReplyComment")
   if isnumeric(OfficeReplyNum) and cint(OfficeReplyNum)<=rs("WS_OfficeNum") then
     conn.execute("insert into HX_OfficeUseed(WS_OFID,WS_OfficeReplyUserid,WS_OfficeReplyNum,WS_OfficeReplyDate,WS_OfficeReplyComment) values("&WS_OFID&","&LOGINUid&","&cint(OfficeReplyNum)&",#"&OfficeReplyDate&"#,'"&OfficeReplyComment&"')")
     response.write "<script>alert('申领成功，请等待发放！');window.opener.location.reload();window.close();</script>"
     response.end 
   else
     HX_GoBack "申领失败：申领数不能大于库存数！",""
   end if
 end if
 msg="申请使用" 
end if 
response.Write "<head><meta http-equiv='Content-Type' content='text/html; charset=gb2312'><title>"&msg&"</title><link rel=stylesheet type=text/css href='../HXinclude/HX_Css.css'><script src='../HXinclude/HX_Function.js'></script></head><body topmargin='20' leftmargin='0' bottommargin='0'><table width='596'  border='0' cellspacing='1' cellpadding='0' align=center bgcolor='#613c25'><tr><td colspan='2' bgcolor=FFFBE8><table width='100%'  border='0' cellspacing='0' cellpadding='0'><tr><td height='25' background='../hximages/titleline.gif'><font class='fontmenu'>"&msg&"</font></td></tr></table>"
select case action
	case "View"
	Orderby=" where WS_OFID="&WS_OFID	
    set prs=WS_S.HX_SetRSD(ColumnName,Tablename1,Orderby)
    if prs.recordcount<=0 then
      response.write "<script>alert('非法操作');window.close();</script>"
      response.end 
   end if  
	response.Write "<table width='100%'  border='0' cellspacing='1' cellpadding='2'><tr bgcolor=BF9B73><td colspan='4'>&nbsp;<font color=FFFBE8>分发情况</font></td></tr><tr bgcolor=FFFBE8><td colspan='4'><table width='100%'  border='0' cellspacing='1' cellpadding='3'><tr bgcolor=D0DDEF><td width='9%'><div align='center'>序 号</div></td><td width='20%'><div align='center'>申请人</div></td><td width='15%'><div align='center'>申请/发放数目</div></td><td width='19%'><div align='center'>申请/发放时间</div></td><td width='13%'><div align='center'>是否发放</div></td><td width='24%'><div align='center'>用 途</div></td></tr>"
  if prs.recordcount>0 then
    do until prs.eof
     response.Write "<tr bgcolor=FFFBE8 onmouseover=javascript:this.bgColor='#F9F8F2' onmouseout=javascript:this.bgColor='#FFFBE8'><td><div align='center'>"&prs("WS_USID")&"</div></td><td><div align='left'>"
	if prs("WS_OfficeReplyUserid")>0 then
	  Call WS_S.HX_OutUserInfo(prs("WS_OfficeReplyUserid"))
	  response.write "<a style='cursor:hand;' onclick=openwin(700,550,'../HXManpowerResource/userinfolook.asp?WS_Uid="&prs("WS_OfficeReplyUserid")&"') title='查看"&OutName&"的资料'>"&Outdepartment&OutAppointment&OutName&"</a>"
	end if
	response.Write "</div></td><td><div align='center'>"&prs("WS_OfficeReplyNum")&"&nbsp;"&prs("WS_OfficeMeasurement")&"</div></td><td><div align='center'>"&WS_S.Format_Time(prs("WS_OfficeReplyDate"),5)&"</div></td><td><div align='center'>"
  if rs("WS_OfficeManageID")=cint(loginuid) then
	 if prs("WS_OfficeUseed")=True then
	   response.write "<a href='?passorlost=lost&WS_USID="&prs("WS_USID")&"&WS_OFID="&prs("WS_OFID")&"' title='点击取消发放'><font color=red>已发放</font></a>"
     else
	  response.write "<a href='?passorlost=pass&WS_USID="&prs("WS_USID")&"&WS_OFID="&prs("WS_OFID")&"' title='点击发放'><font color=blue>未发放</font></a>"
	 end if
  else
	 if prs("WS_OfficeUseed")=True then
	   response.write "<font color=red>已发放</font>"
     else
	  response.write "<font color=blue>未发放</font>"
	 end if
  end if
	response.Write "</div></td><td><div align='left'>"&prs("WS_OfficeReplyComment")&"</div></td></tr>"
    prs.movenext
	loop
  end if
  response.Write "</table></td></tr><tr bgcolor=BF9B73><td colspan='4' class=td4>&nbsp;<font color=FFFBE8>办公用品信息</font></td></tr><tr bgcolor=FFFBE8><td width='13%'><div align='right'>名　　称：</div></td><td colspan='3'>"&rs("WS_OfficeName")&"<font color=red>&nbsp; </font></td></tr><tr bgcolor='FFFBE8'><td><div align='right'>单　　价：</div></td><td colspan='3'>"&rs("WS_OfficeUnitPrice")&" 元</td></tr><tr bgcolor='FFFBE8'><td><div align='right'>数　　量：</div></td><td width='31%'>共 "&rs("WS_OfficeNum")&"&nbsp;"&rs("WS_OfficeMeasurement")&"</td><td width='15%'><div align='right'>单　　位：</div></td><td width='41%'>"&rs("WS_OfficeMeasurement")&"</td></tr><tr bgcolor='FFFBE8'><td><div align='right'>保 管 员：</div></td><td>"
	OfficeManageID=rs("WS_OfficeManageID")
	if OfficeManageID>0 then
	  Call WS_S.HX_OutUserInfo(OfficeManageID)
	  response.write "<a style='cursor:hand;' onclick=openwin(700,550,'../HXManpowerResource/userinfolook.asp?WS_Uid="&OfficeManageID&"') title='查看"&OutName&"的资料'>"&Outdepartment&OutAppointment&OutName&"</a>"
	end if
	response.Write " </td><td><div align='right'>购 买 人：</div></td><td>"
		OfficeBuyID=rs("WS_OfficeBuyID")
		if OfficeBuyID>0 then
	  Call WS_S.HX_OutUserInfo(OfficeBuyID)
	  response.write "<a style='cursor:hand;' onclick=openwin(700,550,'../HXManpowerResource/userinfolook.asp?WS_Uid="&OfficeBuyIDD&"') title='查看"&OutName&"的资料'>"&Outdepartment&OutAppointment&OutName&"</a>"
	end if
	response.Write "</td></tr><tr bgcolor='FFFBE8'><td><div align='right'>购买时间：</div></td><td>"&WS_S.Format_Time(rs("WS_OfficeBuydate"),5)&"</td><td><div align='right'>入库时间：</div></td><td>"&WS_S.Format_Time(rs("WS_OfficeAddDate"),5)&"</td></tr><tr bgcolor='FFFBE8'><td height='135' valign='top'><div align='right'>备　　注：</div></td><td colspan='3' valign='top'>"&rs("WS_OfficeContent")&"</td></tr><tr bgcolor='FFFBE8'><td>&nbsp;</td><td colspan='3' align=right><input type='reset' name='Submit2' value=' 打 印 ' onclick='window.print();'> <input type='button' name='Submit3' value=' 关 闭 ' onclick='window.close();'></td></tr></table>"
	case else
	  response.Write "<table width='100%'  border='0' cellspacing='1' cellpadding='2'><tr bgcolor=BF9B73><td colspan='4'>&nbsp;<font color=FFFBE8>申领 "&rs("WS_OfficeName")&"</font></td></tr><tr bgcolor=FFFBE8><td colspan='4'><table width='100%'  border='0' cellspacing='1' cellpadding='3' bgcolor=D0DDEF><form action='?action=replysave&WS_OFID="&WS_OFID&"' method='post' name='form1'><tr bgcolor='#FFFBE8'><td width='24%'><div align='right'>申 领 人：</div></td><td width='76%'>"&loginusername&"<div align='right'></div></td></tr><tr bgcolor='#FFFBE8'><td><div align='right'>申领数目：</div></td>"
    msg=""
    num=conn.execute("select count(WS_OfficeReplyNum) as ReplyNum from HX_OfficeUseed where WS_OFID="&rs("WS_OFID"))(0)
	if num>0 then
	  num1=conn.execute("select count(WS_OfficeReplyNum) as ReplyNum from HX_OfficeUseed where WS_OfficeUseed=True and WS_OFID="&rs("WS_OFID"))(0)
      if num1>0 then  
	    msg=msg&num1&rs("WS_OfficeMeasurement")&"已发放;"
	  end if
	    num2=conn.execute("select count(WS_OfficeReplyNum) as ReplyNum from HX_OfficeUseed where WS_OfficeUseed=False and WS_OFID="&rs("WS_OFID"))(0)
	    if num2>0 then
		  msg=msg&num2&rs("WS_OfficeMeasurement")&"被申领;"
	    end if
	end if
	msg=msg&"有"&(rs("WS_OfficeNum")-num)&rs("WS_OfficeMeasurement")&"可以申领！"
		response.Write "<td><input name='WS_OfficeReplyNum' type='text' value='"&(rs("WS_OfficeNum")-num)&"' size='10' maxlength='4' style='ime-mode:disabled' onKeyPress='event.returnValue=IsDigit();'><font color=red>"&msg&"</font></td></tr><tr bgcolor='#FFFBE8'><td><div align='right'>申请时间：</div></td><td><input name='WS_OfficeReplyDate' type='text' value='"&date&"' size='20' maxlength='40' readonly> <input name='button' type='button' class='bdlogin' onClick=""popUpcalendar(this, form1.WS_OfficeReplyDate, 'yyyy-mm-dd')"" value='选择' title='点击选择申领时间'></td></tr><tr bgcolor='#FFFBE8'><td valign=top><div align='right'>用　　途：</div></td><td><textarea name='WS_OfficeReplyComment' cols='50' rows='2' class='bgline'></textarea></td></tr><tr bgcolor='#FFFBE8'><td></td><td><input type='submit' name='Submit' value=' 申 领 '></td></tr></form></table></td></tr><tr bgcolor=BF9B73><td colspan='4' class=td4>&nbsp;<font color=FFFBE8>办公用品信息</font></td></tr><tr bgcolor=FFFBE8><td width='13%'><div align='right'>名　　称：</div></td><td colspan='3'>"&rs("WS_OfficeName")&"<font color=red>&nbsp; </font></td></tr><tr bgcolor='FFFBE8'><td><div align='right'>单　　价：</div></td><td colspan='3'>"&rs("WS_OfficeUnitPrice")&"        元</td></tr><tr bgcolor='FFFBE8'><td><div align='right'>数　　量：</div></td><td width='31%'>共 "&rs("WS_OfficeNum")&"&nbsp;"&rs("WS_OfficeMeasurement")&"</td><td width='15%'><div align='right'>单　　位：</div></td><td width='41%'>"&rs("WS_OfficeMeasurement")&"</td></tr><tr bgcolor='FFFBE8'><td><div align='right'>保 管 员：</div></td><td>"
		OfficeManageID=rs("WS_OfficeManageID")
		if OfficeManageID>0 then
	  Call WS_S.HX_OutUserInfo(OfficeManageID)
	  response.write "<a style='cursor:hand;' onclick=openwin(700,550,'../HXManpowerResource/userinfolook.asp?WS_Uid="&OfficeManageID&"') title='查看"&OutName&"的资料'>"&Outdepartment&OutAppointment&OutName&"</a>"
	end if
	response.Write "</td><td><div align='right'>购 买 人：</div></td><td>"
	OfficeManageID=rs("WS_OfficeManageID")
	if OfficeManageID>0 then
	  Call WS_S.HX_OutUserInfo(OfficeBuyID)
	  response.write "<a style='cursor:hand;' onclick=openwin(700,550,'../HXManpowerResource/userinfolook.asp?WS_Uid="&OfficeManageID&"') title='查看"&OutName&"的资料'>"&Outdepartment&OutAppointment&OutName&"</a>"
	end if
	 response.write "</td></tr><tr bgcolor='FFFBE8'><td><div align='right'>购买时间：</div></td><td>"&WS_S.Format_Time(rs("WS_OfficeBuydate"),5)&"<td><div align='right'>入库时间：</div></td><td>"&WS_S.Format_Time(rs("WS_OfficeAddDate"),5)&"</td></tr><tr bgcolor='FFFBE8'><td height='92' valign='top'><div align='right'>备　　注：</div></td><td colspan='3' valign='top'>"&rs("WS_OfficeContent")&"</td></tr><tr bgcolor='FFFBE8'><td>&nbsp;</td><td colspan='3' align=right><input type='reset' name='Submit2' value=' 打 印 ' onclick='window.print();'> <input type='button' name='Submit3' value=' 关 闭 ' onclick='window.close();'></td></tr></table>"
	end select
	 response.write "</td></tr></table>"
%>