public function add_resume_save()
 {
     $userinfo = $_SESSION['userinfo'];
     if (empty($userinfo)) {
         setcookie("gourl", "/index.php?s=/Job/add_resume", time() + 3600, "/");
         echo json_encode(array("code" => "400", "msg" => "未登录"));
         die;
     }
     $uid = $userinfo['userid'];
     setcookie("gourl", "", time() - 1, "/");
     foreach ($_POST as $k => $v) {
         $_POST[$k] = I("post." . $k, '', 'htmlspecialchars');
     }
     if (empty($_POST['username']) || empty($_POST['mobile']) || empty($_POST['exper']) || empty($_POST['age']) || empty($_POST['email']) || empty($_POST['qqnum']) || empty($_POST['because']) || empty($_POST['personal']) || empty($_POST['edu']) || empty($_POST['zige'])) {
         echo json_encode(array("code" => "500", "msg" => "请完善简历信息"));
         die;
     }
     if (!is_numeric($_POST['age'])) {
         echo json_encode(array("code" => "500", "msg" => "请输入正确的年龄"));
         die;
     }
     $rule = "/^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+\$/";
     preg_match($rule, $_POST['email'], $result);
     if (!$result) {
         echo json_encode(array("code" => "500", "msg" => "请输入正确的邮箱"));
         die;
     }
     if (!is_numeric($_POST['qqnum'])) {
         echo json_encode(array("code" => "500", "msg" => "请输入正确的qq号码"));
         die;
     }
     $rule1 = "/^1[0-9]{10}\$/A";
     preg_match($rule1, $_POST['mobile'], $result1);
     if (!$result1) {
         echo json_encode(array("code" => "500", "msg" => "请输入正确的手机号码"));
         die;
     }
     if ($_POST['type']) {
         $data['type'] = $_POST['type'];
     } else {
         if ($_COOKIE['upload']) {
             $data['type'] = 5;
         }
     }
     $data['username'] = $_POST['username'];
     $data['sex'] = $_POST['sex'];
     $data['age'] = $_POST['age'];
     $data['state'] = $_POST['state'];
     $data['mobile'] = $_POST['mobile'];
     $data['email'] = $_POST['email'];
     $data['qqnum'] = $_POST['qqnum'];
     $data['because'] = $_POST['because'];
     $data['personal'] = $_POST['personal'];
     $data['keyword'] = $_POST['keyword'];
     $data['job_id'] = 0;
     $data['t_id'] = $uid;
     $data['keyid'] = getMillisecond();
     $data['audreason'] = 0;
     $data['posttime'] = time();
     $resumeOb = M("resume");
     $resumeOb->add($data);
     $iResumeid = $resumeOb->getLastInsID();
     //最后插入的简历id
     //echo $resumeOb -> getLastSql();
     if ($_POST['edu']) {
         $education = array();
         $education['keyid'] = $data['keyid'];
         $education['starttime'] = 0;
         $education['endtime'] = 0;
         $education['schoolname'] = 0;
         $education['profess'] = 0;
         $education['academic'] = 0;
         $education['checkinfo'] = true;
         $education['content'] = $_POST['edu'];
         M("education")->add($education);
     }
     if ($_POST['exper']) {
         $workexper = array();
         $workexper['keyid'] = $data['keyid'];
         $workexper['starttime'] = 0;
         $workexper['endtime'] = 0;
         $workexper['pname'] = 0;
         $workexper['salary'] = 0;
         $workexper['releaving'] = 0;
         $workexper['checkinfo'] = true;
         $workexper['intro'] = $_POST['exper'];
         M("workexper")->add($workexper);
     }
     if ($_POST['zige']) {
         $cercate = array();
         $cercate['keyid'] = $data['keyid'];
         $cercate['ceaname'] = 0;
         $cercate['zhengshu'] = $_POST['zige'];
         M("cercate")->add($cercate);
     }
     /*                 * **************【增加候选人】操作日志 begin************************* */
     $username = $userinfo['username'];
     $arNoticeInfo = getTNoticeInfo(0, $data['username']);
     $sLogtitle = $arNoticeInfo[0];
     $sLogContent = $arNoticeInfo[1];
     $arNotice = array("uid" => $uid, "username" => $username, "bt_id" => $iResumeid, "title" => $sLogtitle, "content" => $sLogContent, "created_at" => time(), "updated_at" => time());
     M("notice_log")->add($arNotice);
     /*                 * **************【增加候选人】操作日志 end************************* */
     if (!$_POST['type']) {
         //判断该简历有多少能匹配的职位
         $where = "title like '%" . $data['keyword'] . "%' and stj_job.employ>(select count(*) from stj_record where stj_record.j_id = stj_job.id and audstart=6) and checkinfo='true' and endtime>unix_timestamp(now()) and is_deleted=0";
         $jobCount = M("job")->where($where)->count();
         if ($jobCount > 0) {
             echo json_encode(array("code" => "300", "msg" => $jobCount . "," . $data['keyword']));
             die;
         } else {
             echo json_encode(array("code" => "200", "msg" => "增加成功"));
             die;
         }
     }
     echo json_encode(array("code" => "200", "msg" => $iResumeid));
     die;
 }
 public function record_save()
 {
     $data['j_id'] = $_POST['j_id'];
     $userinfo = $_COOKIE['userinfo'];
     if (empty($userinfo)) {
         setcookie("gourl", "/Home/Webchat/new_job");
         echo json_encode(array("code" => 400, "msg" => "未登录"));
         die;
     } else {
         setcookie("gourl", "");
         $userinfoArr = unserialize($userinfo);
     }
     $uid = $userinfoArr['userid'];
     $data['t_id'] = $uid;
     $data['bt_id'] = $_POST['bt_id'];
     $data['posttime'] = time();
     $data['audstartdate'] = $_POST['audstartdate'];
     $recordOb = M("record");
     $re = $recordOb->add($data);
     if ($re) {
         /************************【推荐候选人】操作日志 begin***************/
         $username = $userinfoArr['username'];
         $arResume = M("resume")->where("id=" . $data['bt_id'])->find();
         $sRecommended = $arResume['username'];
         //候选人名称
         $arJob = M("job")->where("id=" . $data['j_id'])->find();
         $sJobTitle = $arJob['title'];
         //职位名称
         if ($sJobTitle == '0') {
             $sJobTitle = getCascList($arJob['Jobcate'], "信息不明");
         }
         $arCompany = M("company")->where("id=" . $arJob['cpid'])->find();
         $sCompanyName = $arCompany['cpname'];
         //公司名称
         $arNotice = getTNoticeInfo(1, $sRecommended, $sCompanyName, $sJobTitle);
         $sLogtitle = $arNotice[0];
         $sLogContent = $arNotice[1];
         $bt_id = $data['bt_id'];
         //简历id
         $job_id = $data['j_id'];
         //职位id
         addNoticeLog($uid, $username, $bt_id, $job_id, $sLogtitle, $sLogContent);
         /************************【推荐候选人】操作日志 end***************/
         echo json_encode(array("code" => "200", "msg" => "保存成功"));
         die;
     } else {
         echo json_encode(array("code" => "500", "msg" => "保存失败"));
         die;
     }
 }
 public function add_resume_save()
 {
     $userinfo = unserialize($_COOKIE['userinfo']);
     if (empty($userinfo)) {
         setcookie("gourl", "/Home/Webchatnew/add_resume", time() + 3600, "/");
         echo json_encode(array("code" => "400", "msg" => "未登录"));
         die;
     }
     setcookie("gourl", "", time() - 1, "/");
     $uid = $userinfo['userid'];
     foreach ($_POST as $k => $v) {
         $_POST[$k] = I("post." . $k, '', 'htmlspecialchars');
     }
     if (empty($_POST['username']) || empty($_POST['mobile']) || empty($_POST['keyword']) || empty($_POST['exper']) || empty($_POST['because']) || empty($_POST['edu'])) {
         echo json_encode(array("code" => "500", "msg" => "请完善简历信息"));
         die;
     }
     $rule1 = "/^1[0-9]{10}\$/A";
     preg_match($rule1, $_POST['mobile'], $result1);
     if (!$result1) {
         echo json_encode(array("code" => "500", "msg" => "请输入正确的手机号码"));
         die;
     }
     $arAllResume = M("resume")->query("select *  from stj_resume where mobile='{$_POST['mobile']}' and isshow=1 ");
     if (!empty($arAllResume)) {
         echo json_encode("该候选人简历在系统中已存在");
         die;
     }
     $data['username'] = $_POST['username'];
     $data['sex'] = $_POST['sex'];
     $data['state'] = $_POST['state'];
     $data['mobile'] = $_POST['mobile'];
     $data['keyword'] = $_POST['keyword'];
     $data['because'] = $_POST['because'];
     $data['job_id'] = 0;
     $data['t_id'] = $uid;
     $data['keyid'] = getMillisecond();
     $data['audreason'] = 0;
     $data['posttime'] = time();
     $data['type'] = 5;
     $resumeOb = M("resume");
     $resumeOb->add($data);
     $iResumeid = $resumeOb->getLastInsID();
     //最后插入的简历id
     //echo $resumeOb -> getLastSql();
     if ($_POST['edu']) {
         $education = array();
         $education['keyid'] = $data['keyid'];
         $education['starttime'] = 0;
         $education['endtime'] = 0;
         $education['schoolname'] = 0;
         $education['profess'] = 0;
         $education['academic'] = 0;
         $education['checkinfo'] = true;
         $education['content'] = $_POST['edu'];
         M("education")->add($education);
     }
     if ($_POST['exper']) {
         $workexper = array();
         $workexper['keyid'] = $data['keyid'];
         $workexper['starttime'] = 0;
         $workexper['endtime'] = 0;
         $workexper['pname'] = 0;
         $workexper['salary'] = 0;
         $workexper['releaving'] = 0;
         $workexper['checkinfo'] = true;
         $workexper['intro'] = $_POST['exper'];
         M("workexper")->add($workexper);
     }
     /*                 * **************【增加候选人】操作日志 begin************************* */
     $username = $userinfo['username'];
     $arNoticeInfo = getTNoticeInfo(0, $data['username']);
     $sLogtitle = $arNoticeInfo[0];
     $sLogContent = $arNoticeInfo[1];
     $arNotice = array("uid" => $uid, "username" => $username, "bt_id" => $iResumeid, "title" => $sLogtitle, "content" => $sLogContent, "created_at" => time(), "updated_at" => time());
     M("notice_log")->add($arNotice);
     /*                 * **************【增加候选人】操作日志 end************************* */
     echo json_encode(array("code" => "200", "msg" => $iResumeid));
     die;
 }
 public function updateUserStatus()
 {
     $reasonid = $_POST['reasonid'];
     $data['audstart'] = $_POST['statused'];
     if (!empty($_POST['content'])) {
         $data['audreason'] = $_POST['content'];
     }
     if (!empty($_POST['candidate_time'])) {
         $data['real_audstart_time'] = $_POST['candidate_time'];
     }
     $data['audstarttime'] = time();
     $status = M("record")->where("id='{$reasonid}'")->save($data);
     $status = $_POST['statused'];
     $statusValue = getCascData("audstart", $status, "信息不明");
     //推荐info
     $recordinfo = M("record")->where("id='{$reasonid}'")->find();
     /*                 * *********************【推荐人/企业】【修改面试状态】操作日志  begin*********************************** */
     $resumeInfo = M("resume")->where("id=" . $recordinfo['bt_id'])->find();
     $arJobInfo = M("job")->where("id=" . $recordinfo['j_id'])->find();
     $arCompanyInfo = M("company")->where("id=" . $arJobInfo['cpid'])->find();
     if (!$arJobInfo['title']) {
         $arJobInfo['title'] = M("casclist")->where("id='{$arJobInfo['Jobcate']}'")->getField("cascname");
     }
     if ($data['audreason']) {
         $arTNoticeInfo = getTNoticeInfo(9, $resumeInfo['username'], $arCompanyInfo['cpname'], $arJobInfo['title'], "", $statusValue, $data['audreason']);
         $arCNoticeInfo = getCNoticeInfo(9, $arJobInfo['title'], $resumeInfo['username'], $statusValue, $data['audreason']);
     } else {
         $arTNoticeInfo = getTNoticeInfo(7, $resumeInfo['username'], $arCompanyInfo['cpname'], $arJobInfo['title'], "", $statusValue);
         $arCNoticeInfo = getCNoticeInfo(7, $arJobInfo['title'], $resumeInfo['username'], $statusValue);
     }
     $sLogtitle = $arTNoticeInfo[0];
     $sLogContent = $arTNoticeInfo[1];
     addNoticeLog($arCompanyInfo['id'], $arCompanyInfo['username'], $recordinfo['bt_id'], $recordinfo['j_id'], $sLogtitle, $sLogContent);
     $sLogtitle = $arCNoticeInfo[0];
     $sLogContent = $arCNoticeInfo[1];
     addNoticeLog($arCompanyInfo['id'], $arCompanyInfo['username'], $recordinfo['bt_id'], $recordinfo['j_id'], $sLogtitle, $sLogContent, 1, 2);
     /*                 * *********************【推荐人/企业】【修改面试状态】操作日志  end*********************************** */
     //////////////////////////分享职位送大礼/////////////////////////////////
     if (C("SHARE_JON_OPEN") === true) {
         //   $id = $_POST['rid'] = 499;
         //如果是活动1并且是已入职状态则查看是否已经为推荐人的来源用户赠送过
         $activiteID = C("SHARE_JOB_ID");
         if ($status == 6 && $activiteID == 2) {
             $activeInfo = M("active")->where("id='{$activiteID}' and status=1 and endtime>'" . date("Y-m-d H:i:s") . "'")->find();
             if ($activeInfo) {
                 $memberId = $recordinfo['t_id'];
                 $userInfo = M("member")->where("id=" . $memberId . " AND fromwhere='share'")->find();
                 if ($userInfo) {
                     //如果存在还没有赠送过并且有来源的username,则赠送给分享人金额
                     $userinfo = M("userinfo")->where("username='******' and fromusername !=''")->find();
                     if ($userinfo) {
                         $Recorduserinfo = M("userinfo")->where("username='******'")->find();
                         $accArr = M("account")->where("uid='{$Recorduserinfo['userid']}'")->find();
                         //查找推荐人之前的账户信息
                         $time = time();
                         if (empty($accArr)) {
                             //插入一条信息账户信息到account表中
                             $sql = "insert into   stj_account(uid,username,account,created_at,updated_at)  values({$Recorduserinfo['userid']},'{$Recorduserinfo['username']}'," . C('SHARE_JOB_RECORD_SUCCESS') . ",'{$time}','{$time}')";
                             M("account")->query($sql);
                             $newAccount = C('SHARE_JOB_RECORD_SUCCESS');
                             $account = 0;
                         } else {
                             //插入一条日志记录到account_balance中
                             $newAccount = $accArr['account'] + C('SHARE_JOB_RECORD_SUCCESS');
                             //更新账户表中的金额和更新时间
                             $sql = "update  stj_account  set account='{$newAccount}',updated_at='{$time}'  where id ={$accArr['id']}";
                             M("account")->query($sql);
                             $account = $accArr['account'];
                         }
                         $sql = "insert into  stj_account_blance(uid,username,last_account,account,incr,operat,`from`,comment,created_at,updated_at)  values({$Recorduserinfo[userid]},'{$Recorduserinfo[username]}',{$account},{$newAccount}," . C('SHARE_JOB_RECORD_SUCCESS') . ",'','shareMoney','分享职位成功入职。','{$time}','{$time}')";
                         M("account_blance")->query($sql);
                         //首次推荐修改状态
                         $sql = "update  stj_share  set num=`num`+1  where decrypturl ='{$userinfo['fromwhere']}'";
                         M("share")->query($sql);
                     }
                 }
             }
         }
         //如果是活动1并且是已入职状态并且此人是通过分享而来则赠送分享人奖励
         $activiteID = C("SHARE_JOB_ID");
         if ($status == 6 && $activiteID == 2) {
             $activeInfo = M("active")->where("id='{$activiteID}' and status=1 and endtime>'" . date("Y-m-d H:i:s") . "'")->find();
             if ($activeInfo) {
                 $jobInfo = M("job")->where("id='{$recordinfo['j_id']}'")->find();
                 $memberId = $jobInfo['cpid'];
                 $userInfo = M("company")->where("id=" . $memberId . " AND fromwhere='share'")->find();
                 if ($userInfo) {
                     //如果存在还没有赠送过并且有来源的username,则赠送给分享人金额
                     $userinfo = M("userinfo")->where("username='******' and fromusername !=''")->find();
                     if ($userinfo) {
                         $Recorduserinfo = M("userinfo")->where("username='******'")->find();
                         $accArr = M("account")->where("uid='{$Recorduserinfo['userid']}'")->find();
                         //查找推荐人之前的账户信息
                         $time = time();
                         if (empty($accArr)) {
                             //插入一条信息账户信息到account表中
                             $sql = "insert into   stj_account(uid,username,account,created_at,updated_at)  values({$Recorduserinfo['userid']},'{$Recorduserinfo['username']}'," . C('SHARE_JOB_COMPANY_SUCCESS') . ",'{$time}','{$time}')";
                             M("account")->query($sql);
                             $newAccount = C('SHARE_JOB_COMPANY_SUCCESS');
                             $account = 0;
                         } else {
                             //插入一条日志记录到account_balance中
                             $newAccount = $accArr['account'] + C('SHARE_JOB_COMPANY_SUCCESS');
                             //更新账户表中的金额和更新时间
                             $sql = "update  stj_account  set account='{$newAccount}',updated_at='{$time}'  where id ={$accArr['id']}";
                             M("account")->query($sql);
                             $account = $accArr['account'];
                         }
                         $sql = "insert into  stj_account_blance(uid,username,last_account,account,incr,operat,`from`,comment,created_at,updated_at)  values({$Recorduserinfo[userid]},'{$Recorduserinfo[username]}',{$account},{$newAccount}," . C('SHARE_JOB_COMPANY_SUCCESS') . ",'','shareMoney','分享职位企业成功入职。','{$time}','{$time}')";
                         M("account_blance")->query($sql);
                         //首次推荐修改状态
                         $sql = "update  stj_share  set num=`num`+1  where decrypturl ='{$userinfo['fromwhere']}'";
                         M("share")->query($sql);
                     }
                 }
             }
         }
     }
     ////////////////////////////////推广奖利送大礼////////////////////////////////////////////////////////
     if (C("SHARE_RECOMMENDSHARE_OPEN") === true && $status == 6) {
         $activiteID = C("SHARE_RECOMMENDSHARE_ID");
         if ($status == 6 && $activiteID == 4) {
             $activeInfo = M("active")->where("id='{$activiteID}' and status=1 and endtime>'" . date("Y-m-d H:i:s") . "'")->find();
             if ($activeInfo) {
                 $memberId = $recordinfo['t_id'];
                 $userInfo = M("member")->where("id=" . $memberId . " AND fromwhere='recommentshare'")->find();
                 if ($userInfo) {
                     //如果存在还没有赠送过并且有来源的username,则赠送给分享人金额
                     $userinfo = M("userinfo")->where("username='******' and fromusername !=''")->find();
                     if ($userinfo) {
                         $Recorduserinfo = M("userinfo")->where("username='******'")->find();
                         $accArr = M("account")->where("uid='{$Recorduserinfo['userid']}'")->find();
                         //查找推荐人之前的账户信息
                         $time = time();
                         if (empty($accArr)) {
                             //插入一条信息账户信息到account表中
                             $sql = "insert into   stj_account(uid,username,account,created_at,updated_at)  values({$Recorduserinfo['userid']},'{$Recorduserinfo['username']}'," . C('SHARE_RECOMMENDSHARE_RECORD_SUCCESS') . ",'{$time}','{$time}')";
                             M("account")->query($sql);
                             $newAccount = C('SHARE_RECOMMENDSHARE_RECORD_SUCCESS');
                             $account = 0;
                         } else {
                             //插入一条日志记录到account_balance中
                             $newAccount = $accArr['account'] + C('SHARE_RECOMMENDSHARE_RECORD_SUCCESS');
                             //更新账户表中的金额和更新时间
                             $sql = "update  stj_account  set account='{$newAccount}',updated_at='{$time}'  where id ={$accArr['id']}";
                             M("account")->query($sql);
                             $account = $accArr['account'];
                         }
                         $sql = "insert into  stj_account_blance(uid,username,last_account,account,incr,operat,`from`,comment,created_at,updated_at)  values({$Recorduserinfo[userid]},'{$Recorduserinfo[username]}',{$account},{$newAccount}," . C('SHARE_RECOMMENDSHARE_RECORD_SUCCESS') . ",'','recommendShare ','推广分享奖励。 。','{$time}','{$time}')";
                         M("account_blance")->query($sql);
                         //首次推荐修改状态
                         $sql = "update  stj_share  set num=`num`+1  where decrypturl ='{$userinfo['fromwhere']}'";
                         M("share")->query($sql);
                     }
                 }
             }
         }
         $activiteID = C("SHARE_RECOMMENDSHARE_ID");
         if ($status == 6 && $activiteID == 4) {
             $activeInfo = M("active")->where("id='{$activiteID}' and status=1 and endtime>'" . date("Y-m-d H:i:s") . "'")->find();
             if ($activeInfo) {
                 $jobInfo = M("job")->where("id='{$recordinfo['j_id']}'")->find();
                 $memberId = $jobInfo['cpid'];
                 $userInfo = M("company")->where("id=" . $memberId . " AND fromwhere='recommentshare'")->find();
                 if ($userInfo) {
                     //如果存在还没有赠送过并且有来源的username,则赠送给分享人金额
                     $userinfo = M("userinfo")->where("username='******' and fromusername !=''")->find();
                     if ($userinfo) {
                         $Recorduserinfo = M("userinfo")->where("username='******'")->find();
                         $accArr = M("account")->where("uid='{$Recorduserinfo['userid']}'")->find();
                         //查找推荐人之前的账户信息
                         $time = time();
                         if (empty($accArr)) {
                             //插入一条信息账户信息到account表中
                             $sql = "insert into   stj_account(uid,username,account,created_at,updated_at)  values({$Recorduserinfo['userid']},'{$Recorduserinfo['username']}'," . C('SHARE_RECOMMENDSHARE_COMPANY_SUCCESS') . ",'{$time}','{$time}')";
                             M("account")->query($sql);
                             $newAccount = C('SHARE_RECOMMENDSHARE_COMPANY_SUCCESS');
                             $account = 0;
                         } else {
                             //插入一条日志记录到account_balance中
                             $newAccount = $accArr['account'] + C('SHARE_RECOMMENDSHARE_COMPANY_SUCCESS');
                             //更新账户表中的金额和更新时间
                             $sql = "update  stj_account  set account='{$newAccount}',updated_at='{$time}'  where id ={$accArr['id']}";
                             M("account")->query($sql);
                             $account = $accArr['account'];
                         }
                         $sql = "insert into  stj_account_blance(uid,username,last_account,account,incr,operat,`from`,comment,created_at,updated_at)  values({$Recorduserinfo[userid]},'{$Recorduserinfo[username]}',{$account},{$newAccount}," . C('SHARE_RECOMMENDSHARE_COMPANY_SUCCESS') . ",'','recommendShare ','推广分享奖励。','{$time}','{$time}')";
                         M("account_blance")->query($sql);
                         //首次推荐修改状态
                         $sql = "update  stj_share  set num=`num`+1  where decrypturl ='{$userinfo['fromwhere']}'";
                         M("share")->query($sql);
                     }
                 }
             }
         }
     }
     // $recordInfo = M("record")->where("id='$reasonid'")->find();
     //  echo M("record")->getLastSql();
     echo json_encode("ok");
 }
 function RecommendTheCandidate3()
 {
     $username = $_SESSION['username'];
     $this->assign("first_class", 3);
     $this->assign("second_class", 5);
     //招聘信息ID
     $data['j_id'] = intval($_REQUEST["jobid"]);
     if (!is_array($_REQUEST['id']) && $_SESSION['recommend_jobid'] && $_SESSION['recommend_comid']) {
         //推荐人添加完简历直接过来
         $type = 3;
         $getid = array($_REQUEST['id']);
         unset($_SESSION['recommend_jobid']);
         unset($_SESSION['recommend_comid']);
     } else {
         $type = 0;
         $getid = $_REQUEST['id'];
         //获取选择的复选框的值
     }
     if (!$getid) {
         $this->error('未选择记录');
         //没选择就提示信息
         exit;
     }
     if ($data['j_id'] <= 0) {
         $this->error("参数错误");
         exit;
     }
     $userInfo = M('member')->where("username='******'")->find();
     if (empty($userInfo)) {
         $this->error("您长时间未操作,请登陆后重试");
         exit;
     }
     //招聘信息
     $jobInfos = M("job")->where("id='{$data['j_id']}'")->find();
     $cid = $jobInfos['cpid'];
     if (!$jobInfos['title']) {
         $jobInfos['title'] = M("casclist")->where("id='{$jobInfos['Jobcate']}'")->getField("cascname");
     }
     $this->assign("jobInfos", $jobInfos);
     //选择一个以上,就用,把值连接起来(1,2,3)这样
     $data['bt_id'] = $getid;
     $data['t_id'] = $userInfo['id'];
     /*                 * *********限制同一个候选人(电话号码相同的所有简历)已经推荐给该职位、限制同一个候选人已经推荐给该公司职位、限制同一个候选人已经推荐给3家公司******* */
     for ($j = 0; $j < count($data['bt_id']); $j++) {
         $where = "";
         //查看与该候选人电话号码相同的候选人的简历id
         $arAllResume = M("resume")->query("select s.id,s.mobile bt_mobile  from stj_resume r join stj_resume s  on r.id={$data['bt_id'][$j]} and s.mobile=r.mobile ");
         foreach ($arAllResume as $v) {
             $where .= " bt_id=" . $v['id'] . " OR";
         }
         $where = "(" . rtrim($where, "OR") . ")";
         //判断该候选人是否已经推荐给该职位
         //                        $isRecord = M("record")->where($where . " AND j_id='$jid' and (audstart=1 or audstart=3 or audstart=5 or audstart=6) and status !=1")->find();
         $isRecord = M("record")->where($where . " AND j_id='{$data['j_id']}'")->find();
         if ($isRecord) {
             $this->resumelist = $this->getRecordListByJob($userInfo['id'], $data['j_id']);
             $this->display("new_recorded_user");
             exit;
         } else {
             //判断该推荐人是否已经推荐给该企业的一个职位
             $isThisCompany = M("record")->query("select *  from stj_record where " . $where . " and j_id in (select id from stj_job where cpid = {$cid})  and (audstart=1 or audstart=3 or audstart=5 or audstart=6) and status !=1");
             //                                $isThisCompany = M("record")->query("select *  from stj_record where " . $where . " and j_id in (select id from stj_job where cpid = $cid)");
             if (!empty($isThisCompany)) {
                 $this->resumelist = $this->getRecordListByJob($userInfo['id'], $data['j_id']);
                 $this->display("new_recorded_user");
                 exit;
             } else {
                 //判断该职位是否已经推荐给3家企业
                 $isThreeCompany = M("record")->query("select * from stj_record  r join stj_job b on  r.j_id = b.id  and " . $where . "  and (audstart=1 or audstart=3 or audstart=5 or audstart=6) and status !=1 group by  b.cpid;");
                 //                                        $isThreeCompany = M("record")->query("select * from stj_record  r join stj_job b on  r.j_id = b.id  and " . $where . " group by  b.cpid;");
                 if (count($isThreeCompany) >= 3) {
                     $this->resumelist = $this->getRecordListByJob($userInfo['id'], $data['j_id']);
                     $this->display("new_recorded_user");
                     exit;
                 }
             }
         }
     }
     $arRecordCount = M("record")->where("j_id='{$data['j_id']}' and t_id='{$data['t_id']}'")->count();
     //如果此职位已经推荐过10个人,则不能再次推荐
     if ($arRecordCount > 10) {
         $this->resumelist = $this->getRecordListByJob($userInfo['id'], $data['j_id']);
         $this->display("new_recorded_user");
         exit;
     }
     $data['posttime'] = time();
     $sql = "INSERT INTO `stj_record` (`id`, `j_id`, `t_id`, `bt_id`, `audstart`, `audreason`, `sink`, `posttime`, `status`, `because`, `news_status`,`is_send`,`audstartdate`,type,j_title) VALUES ";
     $sqlvalue = "";
     for ($i = 0; $i < count($data['bt_id']); $i++) {
         //                        $isRecord = M("record")->where("j_id='$data[j_id]' and bt_id='" . $data[bt_id][$i] . "' and (audstart=1 or audstart=3 or audstart=5 or audstart=6) and status !=1")->find();
         $isRecord = M("record")->where("j_id='{$data['j_id']}' and bt_id='" . $data[bt_id][$i] . "'")->find();
         $resumeInfo = M("resume")->where("id='" . $data[bt_id][$i] . "'")->find();
         $this->assign("resumeInfo", $resumeInfo);
         if (!$isRecord && $resumeInfo) {
             $sqlvalue .= "(NULL, '" . $data['j_id'] . "', '" . $data['t_id'] . "', '" . $data['bt_id'][$i] . "', '1', '', '1', '" . $data['posttime'] . "', '0', NULL, '0',1,'{$_REQUEST['audstarttime']}','{$type}','{$jobInfos['title']}'),";
             /*                                 * *******************************【推荐候选人】操作日志 begin ************************** */
             $companyInfo = M("company")->where("id=" . $jobInfos['cpid'])->find();
             $arNoticeInfo = getTNoticeInfo(1, $resumeInfo['username'], $companyInfo['cpname'], $jobInfos['title']);
             $sLogtitle = $arNoticeInfo[0];
             $sLogContent = $arNoticeInfo[1];
             addNoticeLog($data['t_id'], $username, $data['bt_id'][$i], $data['j_id'], $sLogtitle, $sLogContent);
             /*                                 * *******************************【推荐候选人】操作日志 end ************************** */
         }
     }
     if ($sqlvalue) {
         $sqlvalue = rtrim($sqlvalue, ",");
         $add = mysql_query($sql . $sqlvalue);
         if ($add) {
             $this->resumelist = $this->getRecordListByJob($userInfo['id'], $data['j_id']);
             $this->display("new_recorded_user");
         } else {
             $this->display("RecommendTheCandidate");
         }
     } else {
         $this->resumelist = $this->getRecordListByJob($userInfo['id'], $data['j_id']);
         //    $this->display();
         $this->display("new_recorded_user");
     }
 }
 public function view_resume()
 {
     //推荐记录id
     $id = intval($_GET['id']) > 0 ? intval($_GET['id']) : 0;
     //招聘信息id
     $jid = intval($_GET['jid']) > 0 ? intval($_GET['jid']) : 0;
     //推荐人id
     $btid = intval($_GET['btid']) > 0 ? intval($_GET['btid']) : 0;
     if (empty($id) || empty($jid) || empty($btid)) {
         header("location:/");
         die;
     }
     $result = M("resume")->where("id={$btid}")->find();
     $arJobInfo = M("job")->where("id='{$jid}'")->find();
     if (!$arJobInfo['title']) {
         $arJobInfo['title'] = M("casclist")->where("id='{$arJobInfo['Jobcate']}'")->getField("cascname");
     }
     $arRecord = M("record")->where("id='{$id}'")->find();
     if ($arRecord['news_status'] == "0") {
         /*                         * ***************************【推荐人/企业】企业查看简历操作日志 begin************************** */
         $arCompanyInfo = M("company")->where("id={$arJobInfo['cpid']}")->find();
         $username = $this->username;
         $arTNoticeInfo = getTNoticeInfo(6, $resumeInfo['username'], $arCompanyInfo['cpname'], $arJobInfo['title']);
         $sLogtitle = $arTNoticeInfo[0];
         $sLogContent = $arTNoticeInfo[1];
         $arNotice = array("uid" => $arCompanyInfo['id'], "username" => $username, "bt_id" => $btid, "j_id" => $jid, "title" => $sLogtitle, "content" => $sLogContent, "created_at" => time(), "updated_at" => time());
         M("notice_log")->add($arNotice);
         $arCNoticeInfo = getCNoticeInfo(6, $arJobInfo['title'], $resumeInfo['username']);
         $sLogtitle = $arCNoticeInfo[0];
         $sLogContent = $arCNoticeInfo[1];
         $arNotice = array("uid" => $arCompanyInfo['id'], "username" => $username, "bt_id" => $btid, "j_id" => $jid, "title" => $sLogtitle, "content" => $sLogContent, "type" => 2, "created_at" => time(), "updated_at" => time());
         M("notice_log")->add($arNotice);
         /*                         * ***************************【推荐人/企业】企业查看简历操作日志 begin************************** */
         //修改新消息状态
         M("record")->query("UPDATE stj_record set news_status=1 where id='{$id}'");
     }
     $result['sexdata'] = $result['sex'] ? "女" : "男";
     $result['agedata'] = $result['age'] ? $result['age'] : "未填";
     //在职状态
     $result['statedata'] = M("cascadedata")->where("datagroup='zzstart' and datavalue='{$result['state']}'")->getField("dataname");
     //工作经历
     $result['experiencedata'] = M("workexper")->where("keyid='{$result['keyid']}'")->getField("intro");
     $result['experiencedata'] = $result['experiencedata'] ? $result['experiencedata'] : "无";
     //教育经历
     $result['educationdata'] = M("education")->where("keyid='{$result['keyid']}'")->getField("content");
     $result['educationdata'] = $result['educationdata'] ? $result['educationdata'] : "无";
     //资格证书
     $result['zige'] = M("cercate")->where("keyid='{$result['keyid']}'")->getField("zhengshu");
     $result['zige'] = $result['zige'] ? $result['zige'] : "无";
     //推荐理由
     $result['because'] = $result['because'] ? $result['because'] : "无";
     $lArr = array(array("name" => "回到首页", "url" => "/", "img" => "/Public/new-images/head-icon/m-icon1.png"), array("name" => "发布职位", "url" => "/index.php?s=/Company/send_job", "img" => "/Public/new-images/com-head-icon/send_job.png"), array("name" => "正在招聘", "url" => "/index.php?s=/Companyabout/recording", "img" => "/Public/new-images/com-head-icon/recording.png"), array("name" => "往期招聘", "url" => "/index.php?s=/Companyabout/recorded", "img" => "/Public/new-images/com-head-icon/recorded.png"));
     $this->assign("lArr", $lArr);
     $this->assign("header_title", "候选人简历");
     $this->assign("result", $result);
     $this->assign("select", "send_job");
     $this->display("Company/view_resume");
 }