/** * 添加学生 第 4 步提交处理. * * @access public * @return void * @author Liuping <*****@*****.**> */ public function addStep4Action() { // 校验一级中介是否有权限添加学生 if (!AgentAuth::checkTopAgentOfStu()) { $this->error('No permission'); } // 当前操作, 参见第 1 步中说明. $operFlag = intval(I('post.oper', 1)); $studentId = intval(I('post.currStudent', 0)); // 学生 id if (empty($studentId)) { $this->error('Invalid parameters'); } // 实例化模型 $model = new MemberStuModel(); $stuInfo = $model->fetchStuInfo($studentId); if (empty($stuInfo)) { $this->error('Invalid parameters'); } // 对学生做权限验证 $res = AgentAuth::checkStu($studentId, [AgentAuth::WRITE]); if (9 !== $res['status']) { $this->error('No permission'); } // 验证成功规则能过, 验证是否有添加学生的权限 // 校验一级中介是否有权限添加学生 if (!AgentAuth::checkTopAgentOfStu($stuInfo['uid'])) { $this->error('No permission'); } $post = I('post.'); $files = $_FILES; // js 上传无效时, PHP做上传兼容处理, 仅在为空时才处理 /* foreach($post as $k => & $v) { if(empty($v)) { $_f = isset($files[$k]) ? $files[$k] : []; if(empty($_f)) { // 没有上传文件 $v = ''; } else { $info = $this->procStuAttaUploadFile([$_f]); if(0 === $info['status']) { // 上传失败 $v = ''; } else { // 上传成功 $v = $info['data']['src']; } } } } unset($v); */ // 设置并补齐默认数据 if (empty($post['id'])) { $post['create_time'] = time(); } $uid = $stuInfo['uid']; $ano = ''; $post['uid'] = $uid; $post['fuid'] = $stuInfo['fuid']; $post['partid'] = $stuInfo['partid']; $post['s_id'] = $studentId; $post['a_no'] = $ano; // 执行验证 // 若有上传学位证, 必须有毕业证附近 $attDegreeCert = $post['degree_certificate']; if (!empty($attDegreeCert)) { $attDiploma = $post['diploma']; if (empty($attDiploma)) { $this->error('Please upload graduation certificate'); } } // 必填项验证 $res = $model->validate($model->uploadInfoRules)->create($post); if (!$res) { $this->error($model->getError()); } // 验证通过 $res = $model->procUploadInfo($post, $uid, $studentId, $ano); // 处理成功跳转到 lists 列表页面 if ($res) { // 写入完整标志 $res1 = $model->switchCompleteStatus($studentId, 1); if ($res1) { // 更新区域 id $model->updateStuArea($studentId); // 写入系统日志 $_mark = session('username') . '在' . date('Y-m-d H:i:s') . ', 添加了一个学生, 学生姓名: ' . $stuInfo['first_name'] . $stuInfo['family_name']; if (1 === $operFlag) { // 写入新增日志 system_log($_mark, $model->getTableName(), $studentId, 'a', $stuInfo, NULL, 1); } //$this->success('Successful!', U('noApplyStudentlist')); $this->success('Successful!', U('studentDetail', ['id' => $studentId])); } else { $this->error('Action failed'); } } else { $this->error('Action failed'); } }