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

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

'//获取个人用户的登陆标记
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
'//获取和判断参数
Ncid     = Replace_Text(Request("ncid"))
'Response.Write Ncid
'Response.End()
If Ncid = "" Then
 Response.write "<script language=JavaScript>alert('您没有选择记录！');window.close();</script>"
 Response.End()
Elseif Instr(Ncid,",") <> 0 Then
 Response.write "<script language=JavaScript>alert('对不起！每次只能选择一个职位发送意向，请勿多选...');window.close();</script>"
 Response.End()
End if

'//判断在24小时内有否发送
SQL = "Select Ncid From [pH_Company_Inbox] Where Perid='"&Perid&"' And Jobid="&Ncid&" And DateDiff(n,AddDate,GetDate())<1440"
Set Rs = Conn.Execute(SQL)
If Not Rs.Eof Then
 Rs.Close
 Response.write "<table><tr><td>对不起！在24小时内不能重复发送求职意向到同一职位...</td></tr></table>"
 Response.End()
End if
Rs.Close

'//从数据库中获取个人用户的资料
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
'//获取职位名称和企业名称
SQL = "Select C.CompanyName,J.JobName,J.Comid From pH_Company_Base As C,pH_Job_Base As J Where C.Comid=J.Comid And J.Jobid="&Cstr(Ncid)
Set Rs = Conn.Execute(SQL)
If Rs.Eof Then
 Response.write "指定的企业或者职位不存在..."
 Response.End()
End if
CompanyName  = Rs(0) '企业名称
JobName      = Rs(1) '职位名称
Comid        = Rs(2)
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>&nbsp;</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>
                  <td width="100" height="25" align="right">收件企业：</td>
                  <td height="25"><%= CompanyName %></td>
                </tr>
                <tr bgcolor="f9f9f9"> 
                  <td width="100" height="25" align="right">职位名称：</td>
                  <td height="25"><%= JobName %></td>
                </tr>
                <tr>
                  <td width="100" height="25" align="right">信件标题：</td>
                  <td height="25"><input name="title" type="text" id="title" size="40" maxlength="50" value="求职--<%= JobName %>"></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="comid" value="<%= Comid %>">
        <input type="hidden" name="jobid" value="<%= Ncid %>">

		</td>
    </tr>
  </Form>
</table>
</body>
</html>
<% 
Sub Save_Submit() '保存数据 
 Perid         = Session("Person")(2)
 Jobid         = Replace_Text(Request.Form("Jobid"))
 Comid         = Replace_Text(Request.Form("Comid"))
 Title         = Replace_Text(Request.Form("Title"))
 Memo          = Replace_Text(Request.Form("Memo"))
 If Memo <> "" Then Memo = Replace(Memo,Chr(13),"<br>")
 '//判断在24小时内有否发送
SQL = "Select Ncid From [pH_Company_Inbox] Where Perid='"&Perid&"' And Jobid="&Jobid&" And DateDiff(n,AddDate,GetDate())<1440"
Set Rs = Conn.Execute(SQL)
If Not Rs.Eof Then
 Rs.Close
 Response.write "对不起！在24小时内不能重复发送求职意向到同一职位..."
 Response.End()
End if
Rs.Close
 
 '//保存数据到企业收件夹表
 SQL = "Insert Into [pH_Company_InBox] (Perid,Jobid,Comid,AddDate,Title,Memo,Flag) Values ('"&Perid&"',"&Jobid&",'"&Comid&"',GetDate(),'"&Title&"','"&Memo&"',0)"
 Conn.Execute(SQL)
 
 '//更新职位被求职的次数
 Conn.Execute("Update [pH_Job_Base] Set SendClicks=SendClicks+1 Where Jobid="&Cstr(Jobid))
 '//保存数据到个人发件夹表
 SQL = "Insert Into [pH_Person_OutBox] (Perid,Jobid,Comid,AddDate,Title,Memo) Values ('"&Perid&"',"&Jobid&",'"&Comid&"',GetDate(),'"&Title&"','"&Memo&"')"
 Conn.Execute(SQL)
 
 '//系统自动回复信件到个人收件夹
 Title = "您的简历已收到"
 Memo  = "尊敬的先生/女士：<br><br>您好！<br>您投递的简历我们已经收到，我们会尽快对您的简历进行评阅，进而决定对您的后续安排。<br>希望您继续关注我们！"
 SQL = "Insert Into [pH_Person_InBox] (Perid,Jobid,Comid,AddDate,Title,Memo,Flag) Values ('"&Perid&"',"&Jobid&",'"&Comid&"',GetDate(),'"&Title&"','"&Memo&"',0)"
 Conn.Execute(SQL)
 
 Response.write "<script language=JavaScript>alert('发送成功！');window.close();</script>"

End Sub

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