<?php
/*
 * $Author ：PHPYUN开发团队
 *
 * 官网: http://www.phpyun.com
 *
 * 版权所有 2009-2021 宿迁鑫潮信息技术有限公司，并保留所有权利。
 *
 * 软件声明：未经授权前提下，不得用于商业运营、二次开发以及任何形式的再次发布。
 */
class resume_controller extends wxapp_controller
{
    //邀请面试页面相关信息
    function inviteMsg_action()
    {

        $member             =   $this->yzToken((int)$_POST['comid'],$_POST['token']);

        if($_POST['rewardid']){
            $packM          =   $this -> MODEL('pack');
            $reward         =   $packM -> getPackInfo(array('comid'=>$member['uid'],'id'=>(int)$_POST['rewardid']));

            $ruid           =   $reward['uid'];

        }else{
            $ruid           =   (int)$_POST['ruid'];
        }

        $resumeM            =   $this -> MODEL('resume');
        $user_resume        =   $resumeM -> getResumeInfo(array('uid' => $ruid, 'r_status' => 1), array('field' => '`def_job`'));
        $userrows           =   $resumeM -> getInfoByEid(array('eid' => $user_resume['def_job'], 'uid' => $member['uid'], 'usertype' => $member['usertype']));

        $user               =   array();
        $user['name']       =   $userrows['m_status']==1 ? $userrows['name'] : $userrows['username_n'];
        $user['uid']        =   $userrows['uid'];
        $user['photo']      =   $userrows['photo'];
        $user['sex']        =   $userrows['sex'];
        $user['user_exp']   =   $userrows['user_exp'];
        $user['useredu']    =   $userrows['useredu'];
        $user['age']        =   $userrows['age']?$userrows['age']:'';

        $expect             =   $resumeM -> getExpect(array('uid' => $ruid, 'defaults' => 1), array('field' => '`id`, `job_classid`', 'needCache' => 1));
        $user['id']         =   $expect['id'];
        $user['jobname']    =   @implode('、', $expect['jobnameArr']);



        $jobM     =  $this -> MODEL('job');

        //公司旗下职位信息（包含职位联系方式）
        $rows     =  $jobM -> getList(array('uid' => $member['uid'], 'status' => 0, 'state' => 1, 'r_status' => 1, 'limit'=>50), array('link'=>'yes', 'field' => '`id`, `name`, `is_link`'));

        $joblist  =  $rows['list'];

        if(!empty($reward)){

           foreach ($joblist as $key => $value) {
               $joblist[$key]['content']       = '';
               $joblist[$key]['intertime']     = '';
                if($reward['jobid'] == $value['id']){

                    $data['jobnameIndex'] = $key;
                    break;
                }
            }
        }
        foreach ($joblist as $key => $value) {
            $joblist[$key]['content']    =  '';
            $joblist[$key]['intertime']  =  '';
        }

        $data['joblist']    =   $joblist;
        $data['user']       =   $user;

        //邀请模板
        $yqmbM  =   $this->MODEL('yqmb');
        $ymlist =   $yqmbM  ->getList(array('uid'=>$member['uid'],'status'=>1));
        $ymData =   array();
        $ykey   =   0;
        $ymData[$ykey]['name']          = '请选择';
        $ymData[$ykey]['id']            = '';
        $ymData[$ykey]['link_man']      = '';
        $ymData[$ykey]['link_mobile']   = '';
        $ymData[$ykey]['content']       = '';
        $ymData[$ykey]['intertime']     = '';
        $ymData[$ykey]['address']       = '';

        foreach($ymlist as $yk=>$yv){

            $ykey++;
            $ymData[$ykey]['id']            = $yv['id'];
            $ymData[$ykey]['name']          = $yv['name'];
            $ymData[$ykey]['link_man']      = $yv['linkman'];
            $ymData[$ykey]['link_moblie']   = $yv['linktel'];
            $ymData[$ykey]['content']       = $yv['content'];
            $ymData[$ykey]['intertime']     = $yv['intertime'];
            $ymData[$ykey]['address']       = $yv['address'];

        }
        $data['ymlist'] = $ymData;

        $this->render_json(0,'',$data);
    }
    //邀请面试判断是否满足条件
    function invite_action()
    {
        $member =   $this->yzToken($_POST['fid'],$_POST['token']);

        $companyM   =   $this->MODEL('company');
        $result     =   $companyM->comVipDayActionCheck('interview',$member['uid']);

        if($result['status'] == '-1'){
            $error  =   2;
            $msg    =   strip_tags($result['msg']);

        }else{

            $comtcM            =   $this->MODEL('comtc');
            $data['uid']       =   $member['uid'];
            $data['username']  =   $member['username'];
            $data['usertype']  =   $member['usertype'];
            $data['ruid']      =   $_POST['ruid'];
            $data['show_job']  =   $_POST['show_job'];


            $return     =   $comtcM->invite_resume($data);

            $error      =   $return['status'];
            $msg        =   strip_tags($return['msg']);

        }
		$return['iosfk']	=	$this->config['sy_iospay'] ;
        $this->render_json($error,$msg, $return);
    }
    //执行邀请面试保存数据
    function invitesave_action(){
	    if(!empty($_POST['source']) && $_POST['source'] == 'wap'){
            $_POST['fid'] = $this->uid;
            $_POST['usertype'] = $this->usertype;
        }
        $member		=  $this->yzToken($_POST['fid'],$_POST['token']);
		$jobM       =   $this -> MODEL('job');

		$_POST      =   $this -> post_trim($_POST);
		$_POST['port']	=	$this->plat == 'mini' ? '3' : '4';
		$fidArr     =   array(
		    'fuid'      =>  $member['uid'],
		    'fusername' =>  $member['username'],
		    'fusertype' =>  $member['usertype']
		);


        if(!empty($_POST['longitude']) && !empty($_POST['latitude'])){
            $bd09 = $this->Convert_GCJ02_To_BD09($_POST['longitude'], $_POST['latitude']);
            $_POST['longitude'] = $bd09['lng'];
            $_POST['latitude'] = $bd09['lat'];
        }

		$return     =   $jobM -> addYqmsInfo(array_merge($fidArr, $_POST));

		$this->render_json($return['status'], strip_tags($return['msg']), $return);
    }
}
?>