Пример #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();
 }