示例#1
0
 /**
  * 中介添加的学生详情页面.
  * 
  * @access public
  * @param integer $id 学生id
  * @return void
  * @author Liuping <*****@*****.**>
  */
 public function studentDetail($id)
 {
     $lang = 'en-us';
     // 语系
     // 学生 id
     $studentId = intval($id);
     // 没有 学生 id
     if (empty($studentId)) {
         $this->error('Invalid parameters');
     }
     // 实例化模型
     $modelStu = new MemberStuModel();
     // 学生基本信息
     $stuInfo = $modelStu->fetchStuInfo($studentId);
     if (empty($stuInfo)) {
         $this->error('Invalid parameters');
     }
     // 对学生做权限验证
     $res = AgentAuth::checkStu($studentId, [AgentAuth::READ]);
     if (9 !== $res['status']) {
         $this->error('No permission');
     }
     // 中介资料信息.
     $agentInfo = $this->fetchAgentInfo($stuInfo['uid']);
     if (empty($agentInfo)) {
         $this->error('Invalid parameters');
     }
     // 当前用户允许同一学生允许添加的最大申请数量, -1 无限制
     $allowApplyNum = session('allowApplyNum');
     $modelAppStatus = new ApplyStatusModel();
     // 获取学生已有申请的全部年份
     $stuAllYears = $modelAppStatus->fetchStuApplyYears($studentId);
     $_tmp_years = [];
     foreach ($stuAllYears as $row) {
         $_tmp_years[] = intval($row['year']);
     }
     // 将已有申请的年份排序
     sort($_tmp_years);
     // 当前允许申请的年份
     $allowAppYears = getApplyForYears();
     // 没有已申请的年份, 取当前可申请的年份中的第 1 个, 否则最后一个申请的年份
     $_show_year = empty($_tmp_years) ? $allowAppYears[0] : end($_tmp_years);
     $showYears = $allowAppYears;
     // 显示的全部年份
     // 合并已有申请的年份和当前可申请的年份
     if (!empty($_tmp_years)) {
         $showYears = array_merge($_tmp_years, $allowAppYears);
     }
     $showYears = array_unique($showYears);
     // 去重
     sort($showYears);
     // 排序全部的可申请年份
     $_tmp_key = array_search($_show_year, $showYears);
     // 用这个索引控制 js 中的默认显示第几页
     // 所有年份对应的申请信息, 以年份为 key
     $lists = [];
     // 循环获取对应年份的申请信息
     foreach ($showYears as $year) {
         $lists[$year] = $modelAppStatus->fetchStuApplyInfo($year, $studentId, $lang);
     }
     // 语言信息.
     $engCertInfo = $modelStu->fetchEngCertInfo($stuInfo['id'], '');
     // 教育背景信息
     $eduBackInfo = $modelStu->fetchEduBackInfo($stuInfo['id'], '');
     $sortTopEduInfo = $modelStu->sortEduForModArea($eduBackInfo);
     $eduBackInfo1 = isset($eduBackInfo[0]) ? $eduBackInfo[0] : [];
     $eduBackInfo2 = isset($eduBackInfo[1]) ? $eduBackInfo[1] : [];
     $eduBackInfo3 = isset($eduBackInfo[2]) ? $eduBackInfo[2] : [];
     unset($eduBackInfo);
     // 上传信息.
     $uploadInfo = $modelStu->fetchUploadInfo($stuInfo['id'], '');
     // 推荐人信息
     $refInfo = $modelStu->fetchRefereesInfo($stuInfo['id'], '');
     $refInfo1 = isset($refInfo[0]) ? $refInfo[0] : [];
     $refInfo2 = isset($refInfo[1]) ? $refInfo[1] : [];
     unset($refInfo);
     $yearArr = array();
     if (date('m') > 8) {
         $yearArr[] = date('Y', strtotime('+1year', strtotime(date('Y'))));
         $yearArr[] = date('Y', strtotime('+2year', strtotime(date('Y'))));
     } else {
         $yearArr[] = date('Y');
         $yearArr[] = date('Y', strtotime('+1year', strtotime(date('Y'))));
     }
     $statusModel = M('apply_status');
     foreach ($yearArr as $k => $v) {
         $num = $statusModel->where("invalid=0 and o_status=1 and s_no={$studentId} and year={$v} and isOfferAccept=1 and (needMargin=2 or marginStatus=1)")->count();
         if ($num > 0) {
             $num = $statusModel->where("invalid=0 and o_status>1 and s_no={$studentId} and year={$v}")->count();
             if ($num != 0) {
                 unset($yearArr[$k]);
             }
         } else {
             unset($yearArr[$k]);
         }
     }
     $this->assign('yearArr', $yearArr);
     $this->assign('sortTopEduInfo', $sortTopEduInfo);
     $this->assign('progTypes', $modelAppStatus->fetchApplyProgTypeData($lang));
     // 学科类型, 硕士, 硕士预科
     $this->assign('allowAppYears', $allowAppYears);
     // 当前可以申请的年份
     $this->assign('lists', $lists);
     // 当前学生全部的申请信息
     $this->assign('showYears', $showYears);
     // 显示全部的年份
     $this->assign('allowApplyNum', $allowApplyNum);
     // 当前用户同一学生允许添加的最大申请数量
     $this->assign('controlPage', $_tmp_key + 1);
     // 控制默认显示的第几页
     $this->assign('refInfo1', $refInfo1);
     $this->assign('refInfo2', $refInfo2);
     $this->assign('uploadInfo', $uploadInfo);
     $this->assign('engCertInfo', $engCertInfo);
     $this->assign('eduBackInfo3', $eduBackInfo3);
     $this->assign('eduBackInfo2', $eduBackInfo2);
     $this->assign('eduBackInfo1', $eduBackInfo1);
     $this->assign('agentInfo', $agentInfo);
     $this->assign('stuInfo', $stuInfo);
     $this->display();
 }
示例#2
0
 /**
  * 提交申请第 2 步处理.
  * 
  * @access public
  * @return void
  * @author Liuping <*****@*****.**>
  */
 public function appSubmit2Action()
 {
     // 校验一级中介是否有权限添加申请
     if (!AgentAuth::checkTopAgentOfApply()) {
         $this->error('No permission');
     }
     // 申请 id
     $appStatusId = intval(I('post.appStatus', ''));
     if (empty($appStatusId)) {
         $this->error('Parameters error', U('Student/noApplyStudentList'));
     }
     $modelAppStatus = new ApplyStatusModel();
     $appStatusInfo = $modelAppStatus->find($appStatusId);
     if (NULL === $appStatusInfo || FALSE === $appStatusInfo) {
         $appStatusInfo = [];
     }
     if (empty($appStatusInfo)) {
         $this->error('Parameters error', U('Student/noApplyStudentList'));
     }
     // 操作类型 1 : 添加, 2 : 编辑
     $operFlag = intval(I('post.oper', 1));
     // 根据操作类型, 设置不同的权限
     $authRule = [];
     if (1 === $operFlag) {
         $authRule[] = AgentAuth::ADD;
     } else {
         $authRule[] = AgentAuth::WRITE;
     }
     $modelStu = new MemberStuModel();
     // 验证权限
     $res = AgentAuth::checkStu($appStatusInfo['s_no'], $authRule);
     if ($res['status'] !== 9) {
         $this->error('No permission');
     }
     // 检查是否已超过允许添加的条数
     $res = $modelAppStatus->checkApplyNum($appStatusInfo['year'], $appStatusInfo['s_no']);
     if ($res) {
         // 超过申请次数跳转到中介未申请学生列表
         $msg = 'The application amount of ' . $appStatusInfo['year'] . 'entry for this student has run out.';
         $this->error($msg, U('Student/noApplyStudentList'));
     }
     // 开始组装新添加的数据
     $uid = $appStatusInfo['uid'];
     $fuid = $appStatusInfo['fuid'];
     $partid = $appStatusInfo['partid'];
     $stuId = $appStatusInfo['s_no'];
     $ano = $appStatusInfo['a_no'];
     // 中介的联系信息
     $agentLinkInfo = $modelAppStatus->fetchAgentInfo($uid);
     // 获取该学生的所有个人信息
     // 学生个人详细信息
     $perInfo = $modelStu->fetchPerInfo($stuId, $ano);
     if (empty($perInfo)) {
         // 新增
         $perInfo = $modelStu->fetchPerInfo($stuId, '');
         $perInfo['id'] = '';
         $perInfo['uid'] = $uid;
         $perInfo['fuid'] = $fuid;
         $perInfo['partid'] = $partid;
         $perInfo['s_id'] = $stuId;
         $perInfo['a_no'] = $ano;
         $perInfo['create_time'] = time();
         // 将联系电话和邮箱修改成中介的
         //$perInfo['contact_number'] = $agentLinkInfo['telephone'];
         $perInfo['email_address'] = $agentLinkInfo['email'];
     }
     // 学生个人其它信息
     $perOtherInfo = $modelStu->fetchPerOtherInfo($stuId, $ano);
     if (empty($perOtherInfo)) {
         $perOtherInfo = $modelStu->fetchPerOtherInfo($stuId, '');
         $perOtherInfo['id'] = '';
         $perOtherInfo['uid'] = $uid;
         $perOtherInfo['fuid'] = $fuid;
         $perOtherInfo['partid'] = $partid;
         $perOtherInfo['s_id'] = $stuId;
         $perOtherInfo['a_no'] = $ano;
         $perOtherInfo['create_time'] = time();
     }
     // 学生教育背景信息
     $eduBackInfo = $modelStu->fetchEduBackInfo($stuId, $ano);
     if (empty($eduBackInfo)) {
         $eduBackInfo = $modelStu->fetchEduBackInfo($stuId, '');
         foreach ($eduBackInfo as &$row) {
             $row['id'] = '';
             $row['uid'] = $uid;
             $row['fuid'] = $fuid;
             $row['partid'] = $partid;
             $row['s_id'] = $stuId;
             $row['a_no'] = $ano;
             $row['create_time'] = time();
         }
         unset($row);
     }
     // 语言证书信息
     $engCertInfo = $modelStu->fetchEngCertInfo($stuId, $ano);
     if (empty($engCertInfo)) {
         $engCertInfo = $modelStu->fetchEngCertInfo($stuId, '');
         $engCertInfo['id'] = '';
         $engCertInfo['uid'] = $uid;
         $engCertInfo['fuid'] = $fuid;
         $engCertInfo['partid'] = $partid;
         $engCertInfo['s_id'] = $stuId;
         $engCertInfo['a_no'] = $ano;
         $engCertInfo['create_time'] = time();
     }
     // 工作经验
     $workExpInfo = $modelStu->fetchWorkExpInfo($stuId, $ano);
     if (empty($workExpInfo)) {
         $workExpInfo = $modelStu->fetchWorkExpInfo($stuId, '');
         if (!empty($workExpInfo)) {
             foreach ($workExpInfo as &$row) {
                 $row['id'] = '';
                 $row['uid'] = $uid;
                 $row['fuid'] = $fuid;
                 $row['partid'] = $partid;
                 $row['s_id'] = $stuId;
                 $row['a_no'] = $ano;
                 $row['create_time'] = time();
             }
             unset($row);
         }
     }
     // 推荐人信息
     $refereeInfo = $modelStu->fetchRefereesInfo($stuId, $ano);
     if (empty($refereeInfo)) {
         $refereeInfo = $modelStu->fetchRefereesInfo($stuId, '');
         foreach ($refereeInfo as &$row) {
             $row['id'] = '';
             $row['uid'] = $uid;
             $row['fuid'] = $fuid;
             $row['partid'] = $partid;
             $row['s_id'] = $stuId;
             $row['a_no'] = $ano;
             $row['create_time'] = time();
         }
         unset($row);
     }
     // 上传信息
     $uploadInfo = $modelStu->fetchUploadInfo($stuId, $ano);
     if (empty($uploadInfo)) {
         $uploadInfo = $modelStu->fetchUploadInfo($stuId, '');
         $uploadInfo['id'] = '';
         $uploadInfo['uid'] = $uid;
         $uploadInfo['fuid'] = $fuid;
         $uploadInfo['partid'] = $partid;
         $uploadInfo['s_id'] = $stuId;
         $uploadInfo['a_no'] = $ano;
         $uploadInfo['create_time'] = time();
     }
     // 开启事务
     $modelStu->startTrans();
     $res = $modelStu->procPerInfo($perInfo, $uid, $stuId, $ano);
     $res1 = $modelStu->procPerOtherInfo($perOtherInfo, $uid, $stuId, $ano);
     $res2 = $modelStu->procEduBackInfo($eduBackInfo, $uid, $stuId, $ano);
     $res3 = $modelStu->procEngLangCertInfo($engCertInfo, $uid, $stuId, $ano);
     $res4 = $modelStu->procWorkExpInfo($workExpInfo, $uid, $stuId, $ano);
     $res5 = $modelStu->procRefereeInfo($refereeInfo, $uid, $stuId, $ano);
     $res6 = $modelStu->procUploadInfo($uploadInfo, $uid, $stuId, $ano);
     if ($res && $res1 && $res2 && $res3 && $res4 && $res5 && $res6) {
         $modelStu->commit();
     } else {
         $modelStu->rollback();
         $this->error('Action failed!');
     }
     $url = 'appSubmit3';
     $this->redirect('addTrans', [$this->jumpUrl => $url, $this->jumpInfo => $appStatusId, 'oper' => $operFlag]);
 }