Пример #1
0
 /**
  * 根据交易号修改交易记录
  * @param   string  $tr_id  交易号
  * @param   array   $param  map<string, variant>类型的新记录
  *                          int     $param['tr_money']  择明通宝余额
  *                          int     $param['tr_cash']   充值金额
  *                          int     $param['tr_trade_amount']   交易金额
  *                          string  $param['tr_comment'] 交易说明
  *                          int     $param['tr_flag']   交易状态
  * @return  boolean  true|false
  */
 public static function setTransactionRecordByTrNo($tr_no, $param)
 {
     if (!$tr_no) {
         return false;
     }
     $param = Func::param_copy($param, 'tr_money', 'tr_cash', 'tr_trade_amount', 'tr_comment', 'tr_flag', 'tr_finishtime');
     return Fn::db()->update('t_transaction_record', $param, 'tr_no = ?', array($tr_no));
 }
Пример #2
0
 /**
  * 设置评估规则生成html的状态
  */
 public static function setConvert2pdfStatus($param)
 {
     $param = Func::param_copy($param, 'rule_id', 'html_status', 'is_success', 'status', 'num');
     if (!Validate::isInt($param['rule_id']) || $param['rule_id'] <= 0) {
         throw new Exception('请指定评估规则!');
     }
     return Fn::db()->update('rd_convert2pdf', $param, "rule_id = " . $param['rule_id']);
 }
Пример #3
0
 /**
  * 新增/编辑校区AJAX方法
  * @param   array   $param  map<string,variant>类型参数
  *                  int     tc_id   ID,若为0表新增
  *                  int     tc_tiid 所属培训机构ID
  *                  string  tc_name 名称
  *                  int     tc_flag 状态,-1已删 0禁用 1启用 大于1待审
  *                  int     tc_environ  环境指数
  *                  int     tc_provid   地址省
  *                  int     tc_cityid   地址市
  *                  int     tc_areaid   地址区县
  *                  string  tc_ctcaddr  联系地址
  *                  string  tc_ctcperson    联系人
  *                  string  tc_ctcphone     联系电话
  */
 public function setTCFunc($param)
 {
     $resp = new AjaxResponse();
     $param = Func::param_copy($param, 'tc_id', 'tc_name', 'tc_tiid', 'tc_flag', 'tc_environ', 'tc_provid', 'tc_cityid', 'tc_areaid', 'tc_ctcaddr', 'tc_ctcperson', 'tc_ctcphone');
     if ($param['tc_name'] == '') {
         $resp->alert('培训校区名称不可为空');
         return $resp;
     }
     if (!Validate::isInt($param['tc_provid']) || $param['tc_provid'] < 1) {
         $resp->alert('请选择校区所在省');
         return $resp;
     }
     if ($param['tc_ctcaddr'] == '') {
         $resp->alert('请填写联系地址');
         return $resp;
     }
     if ($param['tc_ctcperson'] == '') {
         $param['tc_ctcperson'] = NULL;
     }
     if ($param['tc_ctcphone'] == '') {
         $resp->alert('请填写联系电话');
         return $resp;
     }
     if (!Validate::isInt($param['tc_environ'])) {
         $reps->alert('请填写环境指数');
         return $resp;
     }
     try {
         if ($param['tc_id']) {
             unset($param['tc_tiid']);
             TrainingInstitutionModel::setTrainingCampus($param);
             admin_log('edit', 'trainingcampus', "tc_id: " . $param['tc_id']);
         } else {
             $param['tc_id'] = TrainingInstitutionModel::addTrainingCampus($param);
             admin_log('add', 'trainingcampus', "tc_id: " . $param['tc_id']);
         }
         $resp->redirect('/admin/traininginstitution/tcinfo/' . $param['tc_id']);
     } catch (Exception $e) {
         $resp->alert($e->getMessage());
     }
     return $resp;
 }
Пример #4
0
 /**
  * 修改教师
  * @param   array   map<string, variant>类型的参数
  *                  int         ct_id
  *                  string      ct_name 
  *                  string      ct_contact
  *                  int         ct_flag
  *                  string      ct_memo
  *                  list<int>   gradeid_list
  *                  list<int>   subjectid_list
  *                  list<int>   cct_ccid_list
  * @return  int     若成功返回非0,若失败返回0
  */
 public static function setCTeacher(array $param)
 {
     $param = Func::param_copy($param, 'ct_id', 'ct_name', 'ct_contact', 'ct_flag', 'gradeid_list', 'subjectid_list', 'cct_ccid_list', 'ct_memo');
     if (!isset($param['ct_id']) || !Validate::isInt($param['ct_id'])) {
         throw new Exception('教师ID不正确');
     }
     if (count($param) == 1) {
         throw new Exception('没有任何要修改的内容');
     }
     if (isset($param['ct_name']) && !Validate::isStringLength($param['ct_name'], 1, 30)) {
         throw new Exception('教师名称不能为空且长度最多30个字符');
     }
     if (isset($param['ct_flag']) && !Validate::isInt($param['ct_flag'])) {
         throw new Exception('教师状态标志必须为整数');
     }
     if (isset($param['ct_contact'])) {
         if ($param['ct_contact'] == '') {
             $param['ct_contact'] = NULL;
         } else {
             if (!Validate::isStringLength($param['ct_contact'], 1, 255)) {
                 throw new Exception('教师联系方式最多255个字符');
             }
         }
     }
     if (isset($param['ct_memo'])) {
         if ($param['ct_memo'] == '') {
             $param['ct_memo'] = NULL;
         }
     }
     $gradeid_list = NULL;
     if (isset($param['gradeid_list'])) {
         if (!is_array($param['gradeid_list'])) {
             throw new Exception('年级参数类型不正确');
         }
         $param['gradeid_list'] = array_values($param['gradeid_list']);
         $param['gradeid_list'] = array_unique($param['gradeid_list']);
         foreach ($param['gradeid_list'] as $v) {
             if (!Validate::isInt($v)) {
                 throw new Exception('年级ID必须为整数');
             }
         }
         $gradeid_list = $param['gradeid_list'];
         unset($param['gradeid_list']);
         if (empty($gradeid_list)) {
             throw new Exception('年级ID必须填写');
         }
     }
     $subjectid_list = NULL;
     if (isset($param['subjectid_list'])) {
         if (!is_array($param['subjectid_list'])) {
             throw new Exception('学科参数类型不正确');
         }
         $param['subjectid_list'] = array_values($param['subjectid_list']);
         $param['subjectid_list'] = array_unique($param['subjectid_list']);
         foreach ($param['subjectid_list'] as $v) {
             if (!Validate::isInt($v)) {
                 throw new Exception('学科ID必须为整数');
             }
         }
         $subjectid_list = $param['subjectid_list'];
         unset($param['subjectid_list']);
         if (empty($subjectid_list)) {
             throw new Exception('学科ID必须填写');
         }
     }
     $ccid_list = NULL;
     if (isset($param['cct_ccid_list'])) {
         if (!is_array($param['cct_ccid_list'])) {
             throw new Exception('课程参数类型不正确');
         }
         $param['cct_ccid_list'] = array_values($param['cct_ccid_list']);
         $param['cct_ccid_list'] = array_unique($param['cct_ccid_list']);
         foreach ($param['cct_ccid_list'] as $v) {
             if (!Validate::isInt($v)) {
                 throw new Exception('课程ID必须为整数');
             }
         }
         $ccid_list = $param['cct_ccid_list'];
         unset($param['cct_ccid_list']);
     }
     $ct_id = $param['ct_id'];
     unset($param['ct_id']);
     $db = Fn::db();
     $bOk = false;
     if ($db->beginTransaction()) {
         $db->update('t_cteacher', $param, "ct_id = {$ct_id}");
         if (is_array($gradeid_list)) {
             $db->delete('t_cteacher_gradeid', 'ctg_ctid = ' . $ct_id);
             foreach ($gradeid_list as $v) {
                 $db->insert('t_cteacher_gradeid', array('ctg_ctid' => $ct_id, 'ctg_gradeid' => $v));
             }
         }
         if (is_array($subjectid_list)) {
             $db->delete('t_cteacher_subjectid', 'cts_ctid = ' . $ct_id);
             foreach ($subjectid_list as $v) {
                 $db->insert('t_cteacher_subjectid', array('cts_ctid' => $ct_id, 'cts_subjectid' => $v));
             }
         }
         if (is_array($ccid_list)) {
             $db->delete('t_course_campus_teacher', 'cct_ctid = ' . $ct_id);
             foreach ($ccid_list as $v) {
                 $db->insert('t_course_campus_teacher', array('cct_ctid' => $ct_id, 'cct_ccid' => $v));
             }
         }
         $bOk = $db->commit();
         if (!$bOk) {
             $db->rollBack();
         }
     }
     return $bOk ? 1 : 0;
 }
Пример #5
0
    public function baseFetchCTeacherListFunc($param)
    {
        $resp = new AjaxResponse();
        $param = Func::param_copy($param, 'grade_id', 'cteacher_name', 'cors_id');
        $grade_id = $param['grade_id'];
        unset($param['grade_id']);
        if (empty($param['cors_id'])) {
            $resp->alert('请选择培训课程');
            return $resp;
        }
        if (empty($param['cteacher_name'])) {
            unset($param['cteacher_name']);
        }
        try {
            $cors_id = $param['cors_id'];
            $sql = <<<EOT
SELECT ct_id, ct_name FROM v_course_campus_teacher WHERE cct_ccid IN (
    SELECT cc_id FROM t_course_campus WHERE cc_corsid = {$cors_id}
)
EOT;
            $ct_map = Fn::db()->fetchPairs($sql);
            if (!empty($ct_map)) {
                $ct_id_list = array_keys($ct_map);
                $ct_id_str = implode(',', $ct_id_list);
                $sql = <<<EOT
SELECT DISTINCT ctg_ctid FROM t_cteacher_gradeid 
WHERE ctg_ctid IN ({$ct_id_str}) AND (ctg_gradeid = 0 OR ctg_gradeid = {$grade_id})
EOT;
                $ct_id2 = Fn::db()->fetchCol($sql);
                $ct_list = array();
                foreach ($ct_map as $k => $v) {
                    if (in_array($k, $ct_id2)) {
                        $ct_list[] = array('ct_id' => $k, 'ct_name' => $v);
                    }
                }
                $resp->call('fnSetCTeacherListDiv', $ct_list);
            } else {
                $resp->call('fnSetCTeacherListDiv', array());
            }
        } catch (Exception $e) {
            $resp->alert($e->getMessage());
        }
        return $resp;
    }
Пример #6
0
 /**
  * 编辑职业,成功返回非0,失败返回0
  * $param为array,则为map<string, variant>,参数如下:
  *          int     profession_id       职业id
  *          string  profession_name     职业名称
  *          int     profession_emerging 新兴职业(0-否 1-是)
  *          string  profession_explain  职业说明
  * @return  mixed
  */
 public static function setProfession($param)
 {
     $param = Func::param_copy($param, 'profession_id', 'profession_name', 'profession_emerging', 'profession_explain');
     if (!Validate::isNotEmpty($param['profession_name'])) {
         throw new Exception('职业名称不能为空!');
     }
     $db = Fn::db();
     $sql = "SELECT profession_id FROM t_profession\n                WHERE profession_name = ? AND profession_id <> ?";
     if ($db->fetchOne($sql, array($param['profession_name'], $param['profession_id']))) {
         throw new Exception('职业名称已存在!');
     }
     $param['profession_updatetime'] = time();
     return $db->update('t_profession', $param, 'profession_id = ?', array($param['profession_id']));
 }
Пример #7
0
 /**
  * 编辑授课教师AJAX方法
  * @param   array   $param  map<stirng,variant>类型的参数
  *                  int     ct_id   教师ID,若为0表新增
  *                  string  ct_name 名称
  *                  string  ctc_contact 联系方式
  *                  string  subject_id_str  形如1,3,4样式的学科ID列表
  *                  string  grade_id_str    形如1,3,4样式的年级ID列表
  *                  int     ct_flag     状态,-1已删,0禁用,1启用,大于1待审
  */
 public function setCTFunc($param)
 {
     $resp = new AjaxResponse();
     $param = Func::param_copy($param, 'ct_id', 'ct_name', 'ct_contact', 'subject_id_str', 'grade_id_str', 'ct_flag', 'cct_ccid_str', 'ct_memo');
     if (!Validate::isInt($param['ct_id']) || $param['ct_id'] < 0) {
         $reps->alert('教师ID不正确');
         return $resp;
     }
     if ($param['ct_name'] == '') {
         $resp->alert('教师名称不正确');
         return $resp;
     }
     if ($param['ct_contact'] == '') {
         $param['ct_contact'] = NULL;
     }
     if (!Validate::isJoinedIntStr($param['grade_id_str'])) {
         $resp->alert('所选年级不正确');
         return $resp;
     }
     if (!Validate::isJoinedIntStr($param['subject_id_str'])) {
         $resp->alert('所选学科不正确');
         return $resp;
     }
     if ($param['cct_ccid_str'] == '') {
         $param['cct_ccid_list'] = array();
     } else {
         if (!Validate::isJoinedIntStr($param['cct_ccid_str'])) {
             $resp->alert('所选课程不正确');
             return $resp;
         } else {
             $param['cct_ccid_list'] = explode(',', $param['cct_ccid_str']);
         }
     }
     $param['subjectid_list'] = array_unique(explode(',', $param['subject_id_str']));
     $param['gradeid_list'] = array_unique(explode(',', $param['grade_id_str']));
     if (count($param['gradeid_list']) == count(C('grades'))) {
         $param['gradeid_list'] = array(0);
     }
     try {
         if ($param['ct_id']) {
             CTeacherModel::setCTeacher($param);
             admin_log('edit', 'cteacher', "ct_id: " . $param['ct_id']);
         } else {
             $param['ct_id'] = CTeacherModel::addCTeacher($param);
             admin_log('add', 'cteacher', "ct_id: " . $param['ct_id']);
         }
         $resp->redirect('/admin/cteacher/ctinfo/' . $param['ct_id']);
     } catch (Exception $e) {
         $resp->alert($e->getMessage());
     }
     return $resp;
 }
Пример #8
0
 public function saveexamrelatequestion()
 {
     $param = Func::param_copy($_POST, 'erq_examid', 'erq_paperid', 'erq_zmoss_examid', 'erq_relate_data');
     if (!Validate::isInt($param['erq_examid']) || $param['erq_examid'] <= 0 || !Validate::isInt($param['erq_zmoss_examid']) || $param['erq_zmoss_examid'] <= 0) {
         message('请确认考试学科对应关系!');
     }
     if (!Validate::isInt($param['erq_paperid']) || $param['erq_paperid'] <= 0) {
         message('测评考试学科试卷不可为空!');
     }
     $erq_relate_data = $param['erq_relate_data'];
     if ($erq_relate_data != array_filter($param['erq_relate_data']) || count($erq_relate_data) != count(array_unique($erq_relate_data))) {
         message('试题对应关系只能是一对一且不可为空!');
     }
     $param['erq_relate_data'] = json_encode($param['erq_relate_data']);
     try {
         $message = "试题对应关系设置";
         if (ZmossModel::setExamRelateQuestion($param)) {
             admin_log('set', 'exam_relate_question', $param['erq_examid']);
             $message .= "成功!";
         } else {
             $message .= "失败!";
         }
     } catch (Exception $e) {
         $message = $e->getMessage();
     }
     message($message, '/admin/zmoss/setexamrelatequestion/' . $param['erq_examid'] . '/' . $param['erq_zmoss_examid'] . '/?er_paperid=' . $param['erq_paperid']);
 }
Пример #9
0
 /**
  * 编辑授课教师AJAX方法
  * @param   array   $param  map<stirng,variant>类型的参数
  *                  int     scht_schid  学校id
  *                  int     ct_id   教师ID,若为0表新增
  *                  string  ct_name 名称
  *                  string  subject_id_str  形如1,3,4样式的学科ID列表
  *                  string  grade_id_str    形如1,3,4样式的年级ID列表
  *                  int     ct_flag     状态,-1已删,0禁用,1启用,大于1待审
  */
 public function setSchoolTeacherFunc($param)
 {
     $resp = new AjaxResponse();
     if (!$this->check_power_new('school_editteacher', false)) {
         $resp->alert('您没有权限执行该功能');
         return $resp;
     }
     $param = Func::param_copy($param, 'scht_schid', 'ct_id', 'ct_name', 'ct_contact', 'subject_id_str', 'grade_id_str', 'ct_flag', 'cct_ccid_str', 'ct_memo');
     if (!Validate::isInt($param['scht_schid']) || $param['scht_schid'] <= 0) {
         $resp->alert('教师所属学校不正确');
         return $resp;
     }
     if (!Validate::isInt($param['ct_id']) || $param['ct_id'] < 0) {
         $resp->alert('教师ID不正确');
         return $resp;
     }
     if ($param['ct_name'] == '') {
         $resp->alert('教师名称不正确');
         return $resp;
     }
     if (!Validate::isJoinedIntStr($param['grade_id_str'])) {
         $resp->alert('所选年级不正确');
         return $resp;
     }
     if (!Validate::isJoinedIntStr($param['subject_id_str'])) {
         $resp->alert('所选学科不正确');
         return $resp;
     }
     $param['subjectid_list'] = array_unique(explode(',', $param['subject_id_str']));
     $param['gradeid_list'] = array_unique(explode(',', $param['grade_id_str']));
     if (count($param['gradeid_list']) == count(C('grades'))) {
         $param['gradeid_list'] = array(0);
     }
     try {
         if ($param['ct_id']) {
             SchoolModel::setSchoolTeacher($param);
             admin_log('edit', 'school_teacher', "ct_id: " . $param['ct_id']);
         } else {
             $param['ct_id'] = SchoolModel::addSchoolTeacher($param);
             admin_log('add', 'school_teacher', "ct_id: " . $param['ct_id']);
         }
         $resp->redirect('/admin/school/teacherlist/' . $param['scht_schid']);
     } catch (Exception $e) {
         $resp->alert($e->getMessage());
     }
     return $resp;
 }
Пример #10
0
    public static function studentAjaxLogin($param, $bPasswordEnc = false, $bValidateOnly = false)
    {
        $resp = new AjaxResponse();
        $param = Func::param_copy($param, 'ticket', 'password');
        if (empty($param['ticket']) || empty($param['password'])) {
            $resp->alert('帐号或密码不能为空!');
            return $resp;
        }
        $where = array();
        $bind = array();
        if (is_email($param['ticket'])) {
            $where[] = 'email = ?';
            $bind[] = $param['ticket'];
        } else {
            if (is_idcard($param['ticket'])) {
                $where[] = 'idcard = ?';
                $bind[] = $param['ticket'];
            } else {
                //message('请输入合法的登陆帐号');
                $where[] = 'exam_ticket = ? OR external_account = ?';
                $bind[] = $param['ticket'];
                $bind[] = $param['ticket'];
            }
        }
        $where[] = 'password = ?';
        if ($bPasswordEnc) {
            $bind[] = $param['password'];
        } else {
            $bind[] = my_md5($param['password']);
        }
        $sql_where = implode(') AND (', $where);
        $sql = <<<EOT
SELECT uid, email, first_name, last_name, idcard, exam_ticket, 
    CONCAT(last_name, first_name) AS fullname,
    external_account, maprule, grade_id, sex, birthday, picture, mobile,
    is_check, last_login, last_ip, email_validate, status, is_delete, addtime,
    account, account_status
FROM rd_student WHERE ({$sql_where})
EOT;
        $user = Fn::db()->fetchRow($sql, $bind);
        if ($user) {
            $uid = $user['uid'];
            if (trim($user['picture'])) {
                $user['avatar_url'] = __IMG_ROOT_URL__ . $user['picture'];
            } else {
                $user['avatar_url'] = __IMG_ROOT_URL__ . 'zeming/exam/head.gif';
            }
            $resp->exdata = $user;
            if (!$bValidateOnly) {
                $sess = Fn::sess();
                if ($sess->userdata('uid') == $uid) {
                    // 当前登录用户已经是请求登录用户,不需要再登录了
                    $resp->refresh();
                } else {
                    $data = array();
                    $data['last_login'] = time();
                    $data['last_ip'] = Func::get_client_ip();
                    Fn::db()->update('rd_student', $data, 'uid = ' . $uid);
                    $sess->set_userdata(array('uid' => $uid, 'uinfo' => $user));
                    $sql = "SELECT * FROM rd_student_ranking WHERE uid = {$uid}";
                    $score_ranks = Fn::db()->fetchRow($sql);
                    if (!$score_ranks && $user['grade_id'] == 6) {
                        // 在basic页面会自动判断是否填写完全学生成绩并进行提示跳转
                        $resp->redirect(site_url('student/profile/basic'));
                    } else {
                        $resp->refresh();
                    }
                }
            }
        } else {
            $resp->alert('帐号或密码不正确!');
        }
        return $resp;
    }
Пример #11
0
    /** 可用产品考试考场学科试卷列表
         * 
    SELECT 
        p.p_id, p.p_name, p.exam_pid,  p.p_status, p.p_price, p.p_notice, 
        p.p_price_pushcourse, p.p_prefixinfo,
        pc.pc_id, pc.pc_name, pc.pc_memo,
        e.exam_id, e.exam_name, e.exam_isfree, e.grade_id, e.class_id, 
        e.introduce AS exam_intro, e.student_notice AS exam_notice, 
        e.status AS exam_status,
        ep.place_id, ep.place_name, ep.address AS place_address, ep.ip AS place_ip,
        ep.start_time AS place_start_time, ep.end_time AS place_end_time, 
        eps.subject_id, esp.id AS esp_id, esp.exam_id AS esp_exam_id, esp.paper_id,
        pt.pt_id, pt.pt_status,pt.pt_money, pt.pt_money_in, pt.pt_type, pt.pt_memo, 
        pt.pt_log, cp.cp_addtime
    FROM rd_product p
    LEFT JOIN rd_product_category pc ON p.pc_id = pc.pc_id
    LEFT JOIN rd_exam e ON p.exam_pid = e.exam_id
    LEFT JOIN rd_exam_place ep ON p.exam_pid = ep.exam_pid
    LEFT JOIN rd_exam_place_subject eps ON p.exam_pid = eps.exam_pid 
        AND ep.place_id = eps.place_id 
    LEFT JOIN rd_exam_subject_paper esp ON eps.exam_pid = esp.exam_pid 
        AND eps.exam_id = esp.exam_id AND eps.subject_id = esp.subject_id
    LEFT JOIN rd_exam_paper epaper ON esp.paper_id = epaper.paper_id 
        AND esp.exam_id = epaper.exam_id
    LEFT JOIN rd_production_transaction pt ON p.exam_pid = pt.exam_pid 
        AND ep.place_id = pt.place_id AND pt.uid = 87
    LEFT JOIN rd_exam_place_student epstu ON ep.place_id = epstu.place_id 
        AND epstu.uid = 87
    LEFT JOIN t_course_push cp ON p.exam_pid = cp.cp_exampid 
        AND ep.place_id = cp.cp_examplaceid AND cp.cp_stuuid = 87
    WHERE p.pc_id = 12  -- 分类
    -- AND p.p_status = 1  -- 产品状态
    -- AND e.status = 1 -- 考试状态
    -- AND ((e.exam_isfree = 0 AND ep.start_time > unix_timestamp() )  
            OR e.exam_isfree = 1) -- 考试时间限制
    AND eps.subject_id IS NOT NULL -- 考场已分配学科 
    AND eps.subject_id = 2 -- 学科
    AND e.grade_id = 5 -- 年级
    AND esp.id IS NOT NULL -- 学科试卷以分配存
    AND epaper.paper_id IS NOT NULL -- 试卷存在
    
    
         * @param   string  $field = NULL       表示查询字段
         * @param   array   $cond_param = NULL  表示查询字段及值
         * @param   int     $page = NULL        为NULL表示查询所有不分页
         * @param   int     $perpage = NULL     为NULL表示取默认值或系统配置值
         * @return  array   list<map<string, variant>>类型数据
         */
    public static function productExamPlaceSubjectPaperList($field = NULL, array $cond_param = NULL, $page = NULL, $perpage = NULL)
    {
        $where = array();
        $bind = array();
        $where[] = 'subject_id IS NOT NULL';
        $where[] = 'esp_id IS NOT NULL';
        $where[] = 'paper_id IS NOT NULL';
        $table = 'v_product_exam_place_subject_paper a';
        if ($cond_param) {
            $cond_param = Func::param_copy($cond_param, 'pc_id', 'p_status', 'exam_status', 'subject_id', 'grade_id', 'exam_isfree', 'place_available', 'stu_uid');
            if (isset($cond_param['pc_id']) && Validate::isInt($cond_param['pc_id'])) {
                $where[] = 'a.pc_id = ' . $cond_param['pc_id'];
            }
            if (isset($cond_param['p_status']) && Validate::isInt($cond_param['p_status'])) {
                $where[] = 'a.p_status = ' . $cond_param['p_status'];
            }
            if (isset($cond_param['exam_status']) && Validate::isInt($cond_param['exam_status'])) {
                $where[] = 'a.exam_status = ' . $cond_param['exam_status'];
            }
            if (isset($cond_param['place_available']) && Validate::isInt($cond_param['place_available']) && $cond_param['place_available']) {
                $time = time();
                if (isset($cond_param['exam_isfree']) && Validate::isInt($cond_param['exam_isfree'])) {
                    if ($cond_param['exam_isfree'] == 0) {
                        $where[] = <<<EOT
(a.exam_isfree = 0 AND a.place_start_time > {$time})
EOT;
                    } else {
                        if ($cond_param['exam_isfree'] == 1) {
                            $where[] = 'a.exam_isfree = 1';
                        } else {
                            $where[] = 'a.exam_isfree = ' . $cond_param['exam_isfree'];
                        }
                    }
                } else {
                    $where[] = <<<EOT
(a.exam_isfree = 0 AND a.place_start_time > {$time}) OR a.exam_isfree = 1
EOT;
                }
            } else {
                if (isset($cond_param['exam_isfree']) && Validate::isInt($cond_param['exam_isfree'])) {
                    $where[] = 'a.exam_isfree = ' . $cond_param['exam_isfree'];
                }
            }
            if (isset($cond_param['subject_id']) && Validate::isInt($cond_param['subject_id'])) {
                $where[] = 'a.subject_id = ' . $cond_param['subject_id'];
            }
            if (isset($cond_param['grade_id']) && Validate::isInt($cond_param['grade_id'])) {
                $where[] = 'a.grade_id = ' . $cond_param['grade_id'];
            }
            if (isset($cond_param['stu_uid']) && Validate::isInt($cond_param['stu_uid'])) {
                $a_arr = explode(',', 'p_id,p_name,exam_pid,p_status,' . 'p_price,p_notice,p_price_pushcourse,p_prefixinfo,' . 'pc_id,pc_name,pc_memo,exam_id,exam_name,exam_isfree,' . 'grade_id,class_id,exam_intro,exam_notice,exam_status,' . 'place_id,place_name,place_address,place_ip,' . 'place_start_time,place_end_time,subject_id,' . 'esp_id,esp_exam_id,esp_paper_id,paper_id,class_name');
                $b_arr = explode(',', 'epstu_uid,cp_addtime');
                if (is_null($field) || trim($field) == '*') {
                    $field = <<<EOT
a.*, epstu.uid AS epstu_uid, cp.cp_addtime
EOT;
                } else {
                    if ($field == 'COUNT(*) AS cnt') {
                    } else {
                        $field_arr = explode(',', $field);
                        $field_arr_new = array();
                        foreach ($field_arr as $v) {
                            $v = strtolower(trim($v));
                            if ($v == '' || $v == '*') {
                                continue;
                            }
                            if (in_array($v, $b_arr)) {
                                $field_arr_new[] = 'b.' . $v;
                            } else {
                                if (in_array($v, $a_arr)) {
                                    $field_arr_new[] = 'a.' . $v;
                                }
                            }
                        }
                        if (empty($field_arr_new)) {
                            $field = <<<EOT
a.*, epstu.uid AS epstu_uid, cp.cp_addtime
EOT;
                        } else {
                            $field = str_replace(array('b.epstu_uid', 'b.cp_'), array('epstu.uid AS epstu_uid', 'cp.cp_'), implode(',', $field_arr_new));
                        }
                    }
                }
                $uid = $cond_param['stu_uid'];
                $table = <<<EOT
v_product_exam_place_subject_paper a
LEFT JOIN rd_exam_place_student epstu ON a.place_id = epstu.place_id AND epstu.uid = {$uid}
LEFT JOIN t_course_push cp ON a.exam_pid = cp.cp_exampid AND a.place_id = cp.cp_examplaceid AND cp.cp_stuuid = {$uid}
EOT;
            }
            if (isset($cond_param['order_by'])) {
                $order_by = $cond_param['order_by'];
            }
        } else {
            $order_by = NULL;
        }
        return Fn::db()->fetchList($table, $field, $where, $bind, $order_by, $page, $perpage);
    }
Пример #12
0
 /**
  * 编辑四维学科
  * @param   array   map<string,variant>类型的学科思维信息参数 
  *          int     subd_subjectid      学科四维ID
  *          string  subd_value          学科四维赋值
  *          string  subd_professionid   学科关联职业
  * @return  boolean 若成功则返回TRUE,否则返回0
  **/
 public static function setSubjectDimension($param)
 {
     $param = Func::param_copy($param, 'subd_subjectid', 'subd_value', 'subd_professionid');
     if (!Validate::isInt($param['subd_subjectid']) || $param['subd_subjectid'] <= 0) {
         throw new Exception('请选择学科');
     }
     if (count($param['subd_value']) != 4 || max($param['subd_value']) > 7 || min($param['subd_value']) < -7) {
         throw new Exception('学科四维赋值不合法');
     }
     if (!$param['subd_professionid']) {
         throw new Exception('请选择关联职业');
     }
     $param['subd_value'] = implode(',', $param['subd_value']);
     $param['subd_professionid'] = json_encode($param['subd_professionid']);
     return Fn::db()->update('t_subject_dimension', $param, 'subd_subjectid = ?', array($param['subd_subjectid']));
 }
Пример #13
0
 /**
  * 编辑职业兴趣/职业能力倾向,成功返回非0,失败返回0
  * $param为array,则为map<string, variant>,参数如下:
  *          int     pr_id           职业兴趣/职业能力倾向id
  *          int     pr_subjectid    学科id
  *          int     pr_knowledgeid  知识点id
  *          string  pr_explain      说明
  *          string  pr_professionid 关联职业(JSON字符串)
  * @return  mixed
  */
 public static function setProfessionRelated($param)
 {
     $param = Func::param_copy($param, 'pr_id', 'pr_explain', 'pr_professionid');
     if (empty($param['pr_professionid'])) {
         throw new Exception('关联职业不能为空');
     }
     $db = Fn::db();
     $param['pr_professionid'] = json_encode($param['pr_professionid']);
     $param['pr_updatetime'] = time();
     return $db->update('t_profession_related', $param, 'pr_id = ?', array($param['pr_id']));
 }
Пример #14
0
 /** 课程推送列表
  * @param   string  $field = NULL       表示查询字段
  * @param   array   $cond_param = NULL  表示查询字段及值
  * @param   int     $page = NULL        为NULL表示查询所有不分页
  * @param   int     $perpage = NULL     为NULL表示取默认值或系统配置值
  * @return  array   list<map<string, variant>>类型数据
  */
 public static function coursePushList($field = NULL, array $cond_param = NULL, $page = NULL, $perpage = NULL)
 {
     $where = array();
     $bind = array();
     if ($cond_param) {
         if (isset($cond_param['order_by'])) {
             $order_by = $cond_param['order_by'];
         }
         $cond_param = Func::param_copy($cond_param, 'cp_exampid', 'cp_stuuid');
         /*
                     if (isset($cond_param['province']) 
            && is_numeric($cond_param['province'])
            && $cond_param['province'] > 0)
                     {
            $where[] = 'province = ' . $cond_param['province'];
                     }
                     if (isset($cond_param['city'])
            && is_numeric($cond_param['city'])
            && $cond_param['city'] > 0)
                     {
            $where[] = 'city = ' . $cond_param['city'];
                     }
                     if (isset($cond_param['area'])
            && is_numeric($cond_param['area'])
            && $cond_param['area'] > 0)
                     {
            $where[] = 'area = ' . $cond_param['area'];
                     }
                     if (isset($cond_param['grade_period'])
            && is_array($cond_param['grade_period']))
                     {
            foreach ($cond_param['grade_period'] as $period)
            {
                $period = intval($period);
                $where[] = "grade_period LIKE '%$period%'";
            }
                     }
                     if (isset($cond_param['keyword']))
                     {
            $where[] = 'school_name LIKE ?';
            $bind[] = '%' . $cond_param['keyword'] . '%';
                     }
         */
         if (isset($cond_param['cp_exampid']) && Validate::isInt($cond_param['cp_exampid'])) {
             $where[] = 'cp_exampid = ?';
             $bind[] = $cond_param['cp_exampid'];
         }
         if (isset($cond_param['cp_stuuid']) && Validate::isInt($cond_param['cp_stuuid'])) {
             $where[] = 'cp_stuuid = ?';
             $bind[] = $cond_param['cp_stuuid'];
         }
     } else {
         $order_by = NULL;
     }
     return Fn::db()->fetchList('v_course_push', $field, $where, $bind, $order_by, $page, $perpage);
 }
Пример #15
0
 /**
  * 修改考场信息
  */
 public function setExamPlace($param)
 {
     $param = Func::param_copy($param, 'place_id', 'exam_pid', 'place_name', 'school_id', 'place_schclsid', 'address', 'ip', 'start_time', 'end_time', 'exam_time_custom');
     if ((!$param['place_id'] || !Validate::isInt($param['place_id'])) && (!$param['exam_pid'] || !Validate::isInt($param['exam_pid']))) {
         return false;
     }
     $where = '';
     $where_bind = array();
     if ($param['place_id']) {
         unset($param['exam_pid']);
         $where = "place_id = ?";
         $where_bind[] = $param['place_id'];
     } else {
         unset($param['place_id']);
         $where = "exam_pid = ?";
         $where_bind[] = $param['exam_pid'];
     }
     return Fn::db()->update('rd_exam_place', $param, $where, $where_bind);
 }
Пример #16
0
 /**
  * 新增/编辑授课教师来源AJAX方法
  * @param   int     $ctf_id     旧ID,若为0表新增,否则表编辑
  * @param   array   $param      map<string,varaint>类型的新属性
  *                  int     ctf_id      新ID
  *                  string  ctf_name    新名称  
  */
 public function setCTFFunc($ctf_id, $param)
 {
     $resp = new AjaxResponse();
     $param = Func::param_copy($param, 'ctf_id', 'ctf_name');
     if ($ctf_id) {
         if (!$this->check_power_new('course_setctfinfo', false)) {
             $resp->alert('您没有权限执行该功能');
             return $resp;
         }
     } else {
         if (!$this->check_power_new('course_addctfinfo', false)) {
             $resp->alert('您没有权限执行该功能');
             return $resp;
         }
     }
     if (!Validate::isInt($param['ctf_id'])) {
         $resp->alert('培训课程授课教师来源ID必须为整数');
         return $resp;
     }
     if ($param['ctf_name'] == '') {
         $resp->alert('培训课程授课教师来源名称不可为空');
         return $resp;
     }
     try {
         if ($ctf_id) {
             CourseModel::setCourseTeachfrom($ctf_id, $param);
             admin_log('edit', '', "授课教师来源 ctf_id: " . $param['ctf_id']);
         } else {
             CourseModel::addCourseTeachfrom($param);
             admin_log('add', '', "授课教师来源 ctf_id: " . $param['ctf_id']);
         }
         $resp->call('location.reload');
     } catch (Exception $e) {
         $resp->alert($e->getMessage());
     }
     return $resp;
 }
Пример #17
0
 /**
  * 编辑学习风格属性,成功返回非0,失败返回0
  * $param为array,则为map<string, variant>,参数如下:
  *          int     lsattr_learnstyleid 学习风格id
  *          int     lsattr_value        学习风格属性id(1-正向 2-负向)
  *          string  lsattr_name     学习风格
  *          string  lsattr_define   学习风格定义
  *          string  lsattr_advice   学习风格建议
  * @return  bool    true|false
  *
  */
 public static function setLearnStyleAttribute($param)
 {
     $param = Func::param_copy($param, 'lsattr_learnstyleid', 'lsattr_value', 'lsattr_name', 'lsattr_define', 'lsattr_advice');
     if (!Validate::isInt($param['lsattr_learnstyleid']) || $param['lsattr_learnstyleid'] <= 0 || !in_array($param['lsattr_value'], array(1, 2))) {
         return false;
     }
     if (!Validate::isNotEmpty($param['lsattr_name'])) {
         throw new Exception('学习风格不能为空!');
     }
     $db = Fn::db();
     $sql = "SELECT lsattr_name FROM t_learn_style_attribute\n                WHERE lsattr_name = ? AND lsattr_learnstyleid <> ? \n                AND lsattr_value <> ?";
     if ($db->fetchOne($sql, array($param['lsattr_name'], $param['lsattr_learnstyleid'], $param['lsattr_value']))) {
         throw new Exception('学习风格已经存在!');
     }
     $bind = array($param['lsattr_learnstyleid'], $param['lsattr_value']);
     unset($param['lsattr_learnstyleid']);
     unset($param['lsattr_value']);
     $param['lsattr_updatetime'] = time();
     return $db->update('t_learn_style_attribute', $param, 'lsattr_learnstyleid = ? AND lsattr_value = ?', $bind);
 }
Пример #18
0
 /**
  * 修改培训校区(所属机构不可修改)
  * @param   array   map<string, variant>类型的参数
  *                  int         tc_id
  *                  string      tc_name
  *                  int         tc_flag
  *                  int         tc_provid
  *                  int         tc_cityid
  *                  int         tc_areaid
  *                  string      tc_ctcaddr
  *                  string      tc_ctcphone
  *                  string      tc_ctcperson
  *                  int         tc_environ
  * @return  int     若成功返回非0,若失败返回0
  */
 public static function setTrainingCampus(array $param)
 {
     $param = Func::param_copy($param, 'tc_id', 'tc_name', 'tc_flag', 'tc_provid', 'tc_cityid', 'tc_areaid', 'tc_ctcaddr', 'tc_ctcphone', 'tc_ctcperson', 'tc_environ');
     if (!isset($param['tc_id']) || !Validate::isInt($param['tc_id'])) {
         throw new Exception('培训校区ID不正确');
     }
     if (count($param) == 1) {
         throw new Exception('没有任何要修改的内容');
     }
     if (isset($param['tc_name']) && !Validate::isStringLength($param['tc_name'], 1, 60)) {
         throw new Exception('培训校区名称不能为空且长度最多60个字符');
     }
     if (isset($param['tc_flag']) && !Validate::isInt($param['tc_flag'])) {
         throw new Exception('培训校区状态标志必须为整数');
     }
     if (isset($param['tc_provid']) && !Validate::isInt($param['tc_provid']) || isset($param['tc_cityid']) && !Validate::isInt($param['tc_cityid']) || isset($param['tc_areaid']) && !Validate::isInt($param['tc_areaid'])) {
         throw new Exception('培训校区所在地区ID必须为整数');
     }
     if (isset($param['tc_ctcaddr']) && !Validate::isStringLength($param['tc_ctcaddr'], 1, 255)) {
         throw new Exception('培训校区联系地址长度最多为255个字符');
     }
     if (isset($param['tc_ctcperson'])) {
         if ($param['tc_ctcperson'] == '') {
             $param['tc_ctcperson'] = NULL;
         } else {
             if (!Validate::isStringLength($param['tc_ctcperson'], 1, 60)) {
                 throw new Exception('培训校区联系人姓名最多60个字符');
             }
         }
     }
     if (isset($param['tc_ctc_phone']) && !Validate::isStringLength($param['tc_ctcphone'], 1, 120)) {
         throw new Exception('培训校区联系电话长度最多为255个字符');
     }
     if (isset($param['tc_environ']) && !Validate::isInt($param['tc_environ'])) {
         throw new Exception('培训校区环境指数必须为整数');
     }
     $tc_id = $param['tc_id'];
     unset($param['tc_id']);
     $db = Fn::db();
     $v = $db->update('t_training_campus', $param, 'tc_id = ' . $tc_id);
     return $v ? 1 : 0;
 }
Пример #19
0
 /**
  * 设置考试试题对应关系
  * 若$param为array,则为map<string, variant>,参数如下:
  *          int     erq_examid   测评考试id
  *          int     erq_paperid   测评考试试卷id
  *          int     er_zmoss_examid 阅卷考试id
  *          string  erq_relate_data 试题对应关系
  * @return  bool    true|false
  */
 public static function setExamRelateQuestion($param)
 {
     $param = Func::param_copy($param, 'erq_examid', 'erq_paperid', 'erq_zmoss_examid', 'erq_relate_data');
     if (!Validate::isInt($param['erq_examid']) || $param['erq_examid'] <= 0 || !Validate::isInt($param['erq_zmoss_examid']) || $param['erq_zmoss_examid'] <= 0) {
         message('请确认考试学科对应关系!');
     }
     if (!Validate::isInt($param['erq_paperid']) || $param['erq_paperid'] <= 0) {
         throw new Exception('测评考试学科试卷不可为空!');
     }
     if (!Validate::isNotEmpty($param['erq_relate_data'])) {
         throw new Exception('试题对应关系不可为空!');
     }
     $param['erq_adminid'] = Fn::sess()->userdata('admin_id');
     $param['erq_addtime'] = time();
     return Fn::db()->replace('t_exam_relate_question', $param);
 }
Пример #20
0
 /**
  * 添加教师学生对应关系
  * $param参数如下
  *          int     tstu_ctid       教师id
  *          int     tstu_stuid      学生id
  *          int     tstu_exampid    考试期次
  *          int     tstu_examid     考试id    
  *          int     tstu_subjectid  学科id
  * @return  bool    true|false
  */
 public static function addTeacherStudent($param)
 {
     $param = Func::param_copy($param, 'tstu_ctid', 'tstu_stuid', 'tstu_exampid', 'tstu_examid', 'tstu_subjectid');
     if (!Validate::isNotEmpty($param['tstu_ctid']) || !Validate::isInt($param['tstu_ctid'])) {
         throw new Exception('学生关联的教师不能为空');
     }
     if (!Validate::isNotEmpty($param['tstu_stuid']) || !Validate::isInt($param['tstu_stuid'])) {
         throw new Exception('教师关联学生的不能为空');
     }
     if (!Validate::isNotEmpty($param['tstu_exampid']) || !Validate::isInt($param['tstu_exampid'])) {
         throw new Exception('考试期次的不能为空');
     }
     if (!Validate::isNotEmpty($param['tstu_subjectid']) || !Validate::isInt($param['tstu_subjectid'])) {
         throw new Exception('教师授课的学科不能为空');
     }
     $param['tstu_addtime'] = time();
     Fn::db()->replace('t_teacher_student', $param);
     return Fn::db()->lastInsertId('t_teacher_student', 'tstu_id');
 }