<!--#include file="../Include/Class_Conn.asp" -->
<!--#include file="../Public/Person_Cookies.asp" -->
<!--#include file="../Include/Class_Main.asp" -->
<% 
Dim Ncid,Action
Dim Rs,SQL
Dim Perid,UserName


'//获取个人用户的登陆标记
If IsArray(Session("Person")) Then
 Perid = Session("Person")(2)
 UserName = Session("Person")(0)
Else
 Session.Abandon() 
 Response.write "<script>alert('-登录后才能进行该操作！-');window.close();</script>"
 Response.End()
End if

Action = Request.QueryString("action")
If Action = "save" Then Call Save_Submit() '保存数据 

Jobid = Request("JobId")
If Jobid = "" Then
 Response.write "<script>alert('-您没有选择记录！-');window.close();</script>"
 Response.End()
End if
Jobid = Split(Jobid,",")

'//从数据库中获取个人用户的资料
SQL = "Select JobContent,RealName,Edus,Age,WorkWillClass1,AreaWill1 From [pH_Person_Info] Where Perid='"&Perid&"'"
Set Rs = Conn.Execute(SQL)
If Rs("JobContent") <> "" And Rs("RealName") <> "" And Rs("WorkWillClass1") <> "" And Rs("AreaWill1") <> "" Then
 JobContent = Rs(0) '求职信
 If JobContent <> "" Then JobContent = Replace(JobContent,"<br>",Chr(13)) 
Else
 Response.write "<table><tr><td>对不起！请先填写简历，再发送求职意向...</td></tr></table>"
 Response.End()
End if
Rs.Close

 %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<LINK href="../Css/Css.css" type=text/css rel=stylesheet>
<title><%= Cls_WebName %> -- 简历中心 -- 发送求职意向</title>
</head>
<body>
<table width="500" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td height="5"></td>
  </tr>
</table>
<table width="470" border="0" align="center" cellpadding="0" cellspacing="0">
  <Form action="?action=save" method="post" name="theForm">
    <tr> 
      <td><table width="100%" border="0" cellpadding="2" cellspacing="1" bgcolor="eeeeee">
          <tr>
            <td bgcolor="#FFFFFF"><table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="eeeeee">
                <tr>
                  <td height="25" bgcolor="f9f9f9"> &nbsp;<img src="../Images/icon.gif" width="11" height="11" align="absmiddle"> 
                    <strong>发送求职意向</strong></td>
                </tr>
              </table>
              <table width="100%" border="0" cellspacing="1" cellpadding="0">
                <tr>
                  <td height="2"></td>
                </tr>
              </table>
              <table width="100%" border="0" cellspacing="1" cellpadding="0">
                <tr bgcolor="#f9f9f9"> 
                  <td width="100" height="25" align="right">职位名称：</td>
                  <td height="25"> 
                    <table width="100%" border="0" cellspacing="0" cellpadding="0">
				  <% 
				  For i = 0 to Ubound(Jobid)
				  Set Re = Conn.Execute("Select JobName From [pH_Job_Base] Where Jobid="&Trim(Jobid(i)))
				  Jobname = ""
				  If Not Re.Eof Then JobName = Re(0)
				  Re.Close
				   %>
                      <tr>
                        <td height="25">&middot;<%= Jobname %></td>
                      </tr>
				  <% 
				  Next
				  %>  
                    </table></td>
                </tr>
                <tr bgcolor="#f9f9f9"> 
                  <td width="100" height="25" align="right">信件标题：</td>
                  <td height="25"> 
                    <input name="title" type="text" id="title" size="40" maxlength="50" value="求职信"></td>
                </tr>
                <tr bgcolor="#f9f9f9"> 
                  <td width="100" height="25" align="right">内 容：</td>
                  <td height="25"> 
                    <textarea name="memo" cols="40" rows="8" id="memo"><%= JobContent %></textarea></td>
                </tr>
              </table></td>
          </tr>
        </table></td>
    </tr>
    <tr>
      <td height="40" align="center"> 
        <input type="submit" name="Submit" value="发 送" style="height:30px;">
        <input type="button" name="Submit2" value="取消" style="height:30px;" onClick="window.close();">
        <input type="hidden" name="jobid" value="<%= Request("Jobid") %>">

		</td>
    </tr>
  </Form>
</table>
</body>
</html>
<% 
Sub Save_Submit() '保存数据 
 Perid         = Session("Person")(2)
 Jobid        = Replace_Text(Request.Form("Jobid"))
 Title         = Replace_Text(Request.Form("Title"))
 Memo          = Replace_Text(Request.Form("Memo"))
 If Memo <> "" Then Memo = Replace(Memo,Chr(13),"<br>")
 Jobid = Split(Jobid,",")

For i = 0 To UBound(Jobid)
Param = Trim(Jobid(i))

'//判断在24小时内有否发送
SQL = "Select Ncid From [pH_Company_Inbox] Where Perid='"&Perid&"' And Jobid="&Param&" And DateDiff(n,AddDate,GetDate())<1440"
Set Rs = Conn.Execute(SQL)
If Rs.Eof Then '//24小时内不能重复发送
 '//获取comid
 Set Re = Conn.Execute("Select Comid From [pH_Job_Base] Where Jobid="&Param)
 If Not Re.Eof Then Comid = Re(0)
 Re.Close
 '//保存数据到企业收件夹表
 SQL = "Insert Into [pH_Company_InBox] (Perid,Jobid,Comid,AddDate,Title,Memo,Flag) Values ('"&Perid&"',"&Param&",'"&Comid&"',GetDate(),'"&Title&"','"&Memo&"',0)"
 Conn.Execute(SQL)
 
 '//更新职位被求职的次数
 Conn.Execute("Update [pH_Job_Base] Set SendClicks=SendClicks+1 Where Jobid="&Cstr(Param))
 '//保存数据到个人发件夹表
 SQL = "Insert Into [pH_Person_OutBox] (Perid,Jobid,Comid,AddDate,Title,Memo) Values ('"&Perid&"',"&Param&",'"&Comid&"',GetDate(),'"&Title&"','"&Memo&"')"
 Conn.Execute(SQL)
 
 '//系统自动回复信件到个人收件夹
 Title2 = "您的简历已收到"
 Memo2  = "尊敬的先生/女士：<br><br>您好！<br>您投递的简历我们已经收到，我们会尽快对您的简历进行评阅，进而决定对您的后续安排。<br>希望您继续关注我们！"
 SQL = "Insert Into [pH_Person_InBox] (Perid,Jobid,Comid,AddDate,Title,Memo,Flag) Values ('"&Perid&"',"&Param&",'"&Comid&"',GetDate(),'"&Title2&"','"&Memo2&"',0)"
 Conn.Execute(SQL)
End if
Rs.Close

Next

Response.write "<script language=JavaScript>alert('发送成功！');window.close();</script>"

End Sub

'//关闭数据库连接
CloseDB
 %>
