示例#1
0
    /**
     * 额外材料提交处理.
     * 
     * @access public
     * @return void
     * @author Liuping <*****@*****.**>
     */
    public function extraFilesAction()
    {
        $extraId = intval(I('post.extraStatus', ''));
        // 额外材料主键ID
        if (empty($extraId)) {
            $this->error('Invalid parameters');
        }
        // 实例化额外信息
        $modelExtra = M('member_upload_extra');
        $extraInfo = $modelExtra->find($extraId);
        if (NULL === $extraInfo || FALSE === $extraInfo) {
            $this->error('Invalid parameters');
        }
        $stuId = $extraInfo['s_id'];
        // 学生 id
        $ano = $extraInfo['a_no'];
        // 申请编号
        $postExtraDetail = I('post.detail', '');
        if (empty($postExtraDetail)) {
            $this->error('Please provide valid files');
        }
        // 去掉为空的数据
        $data = [];
        $_detailSrcs = isset($postExtraDetail['src']) ? $postExtraDetail['src'] : [];
        $_detailIds = isset($postExtraDetail['id']) ? $postExtraDetail['id'] : [];
        foreach ($_detailSrcs as $k => $v) {
            if (!empty($v)) {
                $data[] = ['id' => $_detailIds[$k], 'src' => $v];
            }
        }
        if (empty($data)) {
            $this->error('Please provide valid files');
        }
        $uid = session('uid');
        // 组装数据
        foreach ($data as &$row) {
            $row['fid'] = $extraId;
            $row['uid'] = $uid;
            $row['a_no'] = $ano;
            $_id = $row['id'];
            if (empty($_id)) {
                $row['reason'] = '';
                $row['create_time'] = date('Y-m-d H:i:s', time());
                $row['update_time'] = date('Y-m-d H:i:s', time());
                $row['is_del'] = 0;
            } else {
                $row['update_time'] = date('Y-m-d H:i:s', time());
            }
        }
        unset($row);
        $allowExtraNum = 5;
        // 同一个申请额外材料允许的最多条数
        $data = array_slice($data, 0, $allowExtraNum);
        $modelExtra->startTrans();
        // 开启事务
        $res = $this->procExtraDetailInfo($data);
        // 更新状态为已完成上传
        $res1 = $modelExtra->where('id=:id')->bind(':id', $extraId)->save(['is_complete' => 1]);
        if (FALSE !== $res1) {
            $res1 = TRUE;
        }
        // 写入日志
        $modelStu = new MemberStuModel();
        $aoInfo = $modelStu->fetchAoInfo($stuId);
        // 获取AO信息
        $modelAppStatus = new ApplyStatusModel();
        // 获取申请信息
        $appStatusInfo = $modelAppStatus->where('s_no=:sno AND a_no=:ano')->bind([':sno' => $stuId, ':ano' => $ano])->find();
        $strFullName = '';
        if (!empty($appStatusInfo)) {
            $strFullName = $appStatusInfo['first_name'] . ' ' . $appStatusInfo['family_name'];
        }
        $res2 = TRUE;
        $res3 = TRUE;
        $_cont = '用户提交了额外材料';
        $_cont1 = 'Your extra files have been received, application status changes to "Assessing by university"';
        if (!empty($aoInfo) && !empty($appStatusInfo)) {
            $res2 = $modelStu->writeLog($aoInfo['ao_uid'], $appStatusInfo['uid'], $ano, 1, date('Y-m-d H:i:s') . ', ' . $_cont);
            $res3 = $modelStu->writeApplyLog($aoInfo['ao_uid'], $appStatusInfo['uid'], $ano, 1, $_cont1);
        }
        // 更新额外材料标志位
        $res4 = $modelAppStatus->switchExtraFilesStatus($appStatusInfo['id'], 2);
        $res5 = $modelAppStatus->switchApplyStatus($appStatusInfo['id'], 5);
        // 评估中
        if ($res && $res1 && $res2 && $res3 && $res4 && $res5) {
            $modelExtra->commit();
            // 提交事务
            // 都成功, 给 AO 发送邮件
            if (!empty($aoInfo) && !empty($appStatusInfo)) {
                $resubmitTime = date('Y-m-d H:i:s', time());
                $emailTitle = $strFullName . ' ' . $_cont;
                $emailContent = <<<MAIL
学生姓名: {$strFullName}.
提交时间: {$resubmitTime}.
描述: {$_cont}.
MAIL;
                // 发送邮件
                MemberStuModel::sendEmail($aoInfo['ao_user_email'], $emailTitle, $emailContent);
            }
            $this->success('Successful!', U('studentDetail', ['id' => $stuId]));
        } else {
            $modelExtra->rollback();
            $this->error('Action failed');
        }
    }
示例#2
0
    /**
     * 提交申请第 3 步处理.
     * 
     * @access public
     * @return void
     * @author Liuping <*****@*****.**>
     */
    public function appSubmit3Action()
    {
        // 校验一级中介是否有权限添加申请
        if (!AgentAuth::checkTopAgentOfApply()) {
            $this->error('No permission');
        }
        // 申请 id
        $appStatusId = intval(I('post.appStatus', ''));
        // 陈述内容
        $stateContent = I('post.stateText', '');
        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');
        }
        // 申请状态
        $applyStatus = intval($appStatusInfo['a_status']);
        // 若申请状态为材料出错(a_status : 2), 就不验证是否超过允许添加的条数和不更新申请数量
        $res = FALSE;
        // 默认为未超过申请条数
        if (2 !== $applyStatus) {
            // 检查是否已超过允许添加的条数
            $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'];
        // 个人陈述
        $perStateInfo = $modelStu->fetchPerStateInfo($stuId, $ano);
        if (empty($perStateInfo)) {
            // 新增
            $perStateInfo = $modelStu->fetchPerStateInfo($stuId, '');
            $perStateInfo['id'] = '';
            $perStateInfo['uid'] = $uid;
            $perStateInfo['fuid'] = $fuid;
            $perStateInfo['partid'] = $partid;
            $perStateInfo['s_id'] = $stuId;
            $perStateInfo['a_no'] = $ano;
            $perStateInfo['create_time'] = time();
        }
        // 陈述内容
        $perStateInfo['content'] = $stateContent;
        // 执行验证规则
        $res = $modelStu->validate($modelStu->perStateRules)->create($perStateInfo);
        if (!$res) {
            $this->error($modelStu->getError());
        }
        $modelStu->startTrans();
        // 开启事务
        $res = $modelStu->procPerStateInfo($perStateInfo, $uid, $stuId, $ano);
        $res1 = $modelAppStatus->switchCompleteStatus($appStatusId, 1, time());
        $stuFullName = $appStatusInfo['first_name'] . ' ' . $appStatusInfo['family_name'];
        // 若申请状态为材料出错(a_status : 2), 就不验证是否超过允许添加的条数和不更新申请数量
        $res2 = TRUE;
        // 默认为更新数量成功
        if (2 !== $applyStatus) {
            $res2 = $modelAppStatus->updateApplyNum($appStatusInfo['year'], $stuId, $stuFullName);
        }
        $aoInfo = $modelStu->fetchAoInfo($stuId);
        $res3 = $modelAppStatus->switchApplyStatus($appStatusId, 1);
        // 更新状态为 审核中.
        $res4 = TRUE;
        $res5 = TRUE;
        $res6 = TRUE;
        $_cont = '用户重新提交了申请';
        $_cont1 = 'Application has been resubmitted, application status changes to"Verifying by ApplicationUK"';
        if (!empty($aoInfo) && 2 === $applyStatus) {
            // 有跟进AO且状态是材料出错, 就记录日志
            $res4 = $modelStu->writeLog($aoInfo['ao_uid'], $uid, $ano, 1, date('Y-m-d H:i:s') . ', ' . $_cont);
            $res5 = $modelStu->writeApplyLog($aoInfo['ao_uid'], $uid, $ano, 1, $_cont1);
        }
        // 新申请记录新申请日志.
        if (0 === $applyStatus) {
            $_cont1 = 'Your application has been submitted and now under verification, application status changes to "Verifing by ApplicationUK"';
            $res6 = $modelStu->writeApplyLog(empty($aoInfo) ? 0 : $aoInfo['ao_uid'], $uid, $ano, 1, $_cont1);
        }
        if ($res && $res1 && $res2 && $res3 && $res4 && $res5 && $res6) {
            $modelStu->commit();
            if (!empty($aoInfo) && 2 === $applyStatus) {
                // 材料出错重新提交, 给 AO 发邮件
                $resubmitTime = date('Y-m-d H:i:s', time());
                $emailTitle = $stuFullName . ' ' . $_cont;
                $emailContent = <<<MAIL
学生姓名: {$stuFullName}.
提交时间: {$resubmitTime}.
描述: {$_cont}.
MAIL;
                // 发送邮件
                MemberStuModel::sendEmail($aoInfo['ao_user_email'], $emailTitle, $emailContent);
            } elseif (!empty($aoInfo)) {
                // 新添加/修改申请时要发邮件
                $_cont = '提交了新的申请';
                $resubmitTime = date('Y-m-d H:i:s', time());
                $emailTitle = $stuFullName . ' ' . $_cont;
                $emailContent = <<<MAIL
学生姓名: {$stuFullName}.
提交时间: {$resubmitTime}.
描述: {$_cont}.
MAIL;
                // 发送邮件
                MemberStuModel::sendEmail($aoInfo['ao_user_email'], $emailTitle, $emailContent);
            }
            // 写入系统日志
            $_mark = session('username') . '在' . date('Y-m-d H:i:s') . ', 添加了一个申请资料, 申请编号 : ' . $ano . ', 学生姓名 : ' . $appStatusInfo['first_name'] . $appStatusInfo['family_name'];
            if (1 === $operFlag) {
                // 写入新增日志
                system_log($_mark, $modelAppStatus->getTableName(), $ano, 'a', $appStatusInfo, NULL, 1);
            }
            // 成功跳转到已申请列表.
            //$this->success('Successful!', U('Student/studentList'));
            $this->success('Successful!', U('Student/studentDetail', ['id' => $stuId]));
        } else {
            $modelStu->rollback();
            $this->error('Action failed');
        }
    }
示例#3
0
 private function sentMailToUser1($anoArr)
 {
     $MemberStuModel = new MemberStuModel();
     $list = M('apply_status')->alias('a')->field('a.first_name,b.name us,c.name mj,a.complate_time')->join('LEFT JOIN __UNIVERSITYLANG__ b ON a.us_id=b.fid and b.lang=\'en-US\'
                 LEFT JOIN __UNIVERSITY_MAJORLANG__ c ON a.mj_id=c.fid and c.lang=\'en-US\'')->where(array('a_no' => array('in', $anoArr)))->select();
     $userMail = M('user')->where(array('id' => session('uid')))->getField('email');
     $this->assign('list', $list);
     $html = $this->fetch('emailTemplate1');
     //生成邮件内容
     $emailTitle = "Application Received";
     $MemberStuModel->sendEmail($userMail, $emailTitle, $html);
 }
示例#4
0
 /**
  * @给用户发邮件通知
  * @Author: 段涛
  * @param $a_no
  * @FunctionName: sentMailToUser
  */
 protected function sentMailToUser($ano)
 {
     $MemberStuModel = new MemberStuModel();
     $appStatus = M('apply_status')->field('first_name,us_id,mj_id')->where(array('a_no' => $ano))->find();
     //获取学校信息
     $universityName = M('universitylang')->where(array('fid' => $appStatus['us_id'], 'lang' => 'en-US'))->getField('name');
     $majorName = M('university_majorlang')->where(array('fid' => $appStatus['mj_id'], 'lang' => 'en-US'))->getField('name');
     $userMail = M('user')->where(array('id' => session('uid')))->getField('email');
     //生成邮件内容
     $emailTitle = "Application for {$universityName}   {$majorName}";
     $emailContent = file_get_contents('./Application/Home/View/default/Member/emailTemplate.html');
     $array = ['{$universityName}' => $universityName, '{$majorName}' => $majorName, '{$FirstName}' => ucwords($appStatus['first_name'])];
     foreach ($array as $k => $rs) {
         $emailContent = str_replace($k, $rs, $emailContent);
     }
     //                    echo $emailContent;
     $MemberStuModel->sendEmail($userMail, $emailTitle, $emailContent);
 }