public function remove($pr_id) { if (!$pr_id && ($pr_id = $this->input->get('pr_ids'))) { $pr_id = implode(',', $pr_id); } if (!Validate::isJoinedIntStr($pr_id)) { message('请选择需要删除的职业能力倾向'); } if (ProfessionRelatedModel::removeProfessionRelated($pr_id)) { admin_log('delete', 'vocational_aptitude', $pr_id); message('删除成功', '/admin/vocational_aptitude/index'); } else { message('删除失败', '/admin/vocational_aptitude/index'); } }
public function remove($learnstyle_id) { if (!$learnstyle_id && ($learnstyle_id = $this->input->get('learnstyle_ids'))) { $learnstyle_id = implode(',', $learnstyle_id); } if (!Validate::isJoinedIntStr($learnstyle_id)) { message('请选择需要删除的内化过程'); } if (LearnStyleModel::removeLearnStyle($learnstyle_id)) { admin_log('delete', 'learn_style', $learnstyle_id); message('删除成功', '/admin/learn_style/index'); } else { message('删除失败', '/admin/learn_style/index'); } }
public function remove($profession_id) { if (!$profession_id && ($profession_id = $this->input->get('profession_ids'))) { $profession_id = implode(',', $profession_id); } if (!Validate::isJoinedIntStr($profession_id)) { message('请选择需要删除的职业'); } if (ProfessionModel::removeProfession($profession_id)) { admin_log('delete', 'profession', $profession_id); message('删除成功', '/admin/profession/index'); } else { message('删除失败', '/admin/profession/index'); } }
/** * 获取模板列表 * @param array $param * @param int $page * @param int $perpage * @return void */ public static function get_evaluate_template_list($param = array(), $page = null, $perpage = null) { $sql = "SELECT * FROM rd_evaluate_template"; $where = array(); $bind = array(); if ($param) { if (isset($param['template_type'])) { if (Validate::isInt($param['template_type'])) { $where[] = "template_type = " . intval($param['template_type']); } else { if (Validate::isJoinedIntStr($param['template_type'])) { $where[] = "template_type IN ( " . $param['template_type'] . ")"; } } } if (!empty($param['template_name'])) { $where[] = "template_name LIKE ?"; $bind[] = '%' . $param['template_name'] . '%'; } if (!empty($param['template_subjectid'])) { $template_subjectid = $param['template_subjectid']; if (is_array($template_subjectid)) { $template_subjectid = implode(',', $template_subjectid); } $where[] = "template_subjectid LIKE '%,{$template_subjectid},%'"; } } if ($where) { $sql .= " WHERE " . implode(' AND ', $where); } $sql .= " ORDER BY template_id DESC"; if ($page && $perpage) { $start = ($page - 1) * $perpage; $sql .= " LIMIT {$perpage} OFFSET {$start}"; } return Fn::db()->fetchAll($sql, $bind); }
/** * 获取教师关联学科 对象, 查v_cteacher_subjectid视图 * @param string $ct_id_str 形如1,3,4样式的教师ID字符串 * @return array map<int, map<int, map<string, varaint>>> * $arr[cts_ctid][cts_subjectid] = * */ public static function CTeacherSubjectIDPairs($ct_id_str) { if (!Validate::isJoinedIntStr($ct_id_str)) { throw new Exception('教师ID列表应为形如1,2,3样式的ID列表字符串'); } $sql = <<<EOT SELECT * FROM v_cteacher_subjectid WHERE cts_ctid IN ({$ct_id_str}) ORDER BY cts_ctid, cts_subjectid EOT; $rows = Fn::db()->fetchAll($sql); $arr = array(); foreach ($rows as $v) { if (!isset($arr[$v['cts_ctid']])) { $arr[$v['cts_ctid']] = array(); } $arr[$v['cts_ctid']][$v['cts_subjectid']] = $v; } unset($rows); return $arr; }
/** * 删除培训校区,若tc_flag > -1则为假删,否则为真删(已使用过的不可真删) * @param string $tc_id_str 形似1,2,3样式的ID列表 * @return int 成功执行则返回非,否则返回0 */ public static function removeTrainingCampus($tc_id_str) { if (!Validate::isJoinedIntStr($tc_id_str)) { throw new Exception('培训校区ID列表格式不正确,' . '应为英文逗号分隔开的ID字符串'); } $db = Fn::db(); $sql = <<<EOT SELECT tc_id FROM t_training_campus WHERE tc_flag = -1 AND tc_id IN ({$tc_id_str}) EOT; $rm_tc_ids = $db->fetchCol($sql); // 需要真删的ID if (!empty($rm_tc_ids)) { $rm_tc_str = implode(',', $rm_tc_ids); $sql = <<<EOT SELECT DISTINCT cc_tcid FROM t_course_campus WHERE cc_tcid IN ({$rm_tc_str}) EOT; $nrm_tc_ids = $db->fetchCol($sql); // 不可真删的ID $rm_tc_ids = array_diff($rm_tc_ids, $nrm_tc_ids); } $bOk = false; if ($db->beginTransaction()) { if (!empty($rm_tc_ids)) { $rm_tc_str = implode(',', $rm_tc_ids); // 可真删的ID $sql = <<<EOT SELECT tc_id, tc_tiid FROM t_training_campus WHERE tc_id IN ({$rm_tc_str}) EOT; $rows = $db->fetchAll($sql); $db->delete('t_training_campus', "tc_id IN ({$rm_tc_str})"); foreach ($rows as $row) { $ti_id = $row['tc_tiid']; $sql = <<<EOT UPDATE t_training_institution SET ti_campusnum = ti_campusnum - 1 WHERE ti_id = {$ti_id} EOT; $db->exec($sql); } } $db->update('t_training_campus', array('tc_flag' => -1), "tc_id IN ({$tc_id_str})"); $bOk = $db->commit(); if (!$bOk) { $db->rollBack(); } } return $bOk ? 1 : 0; }
/** * 删除教师,若ct_flag > -1则为假删,否则为真删(已使用过的不可真删) * @param string $ct_id_str 形似1,2,3样式的ID列表 * @return int 成功执行则返回非0,否则返回0 */ public static function removeSchoolTeacher($ct_id_str) { if (!Validate::isJoinedIntStr($ct_id_str)) { throw new Exception('教师ID列表格式不正确,' . '应为英文逗号分隔开的ID字符串'); } $db = Fn::db(); $sql = <<<EOT SELECT ct_id FROM t_cteacher WHERE ct_flag = -1 AND ct_id IN ({$ct_id_str}) EOT; $rm_ct_ids = $db->fetchCol($sql); // 需要真删的ID if (!empty($rm_ct_ids)) { } $bOk = false; if ($db->beginTransaction()) { if (!empty($rm_ct_ids)) { $rm_ct_str = implode(',', $rm_ct_ids); // 可真删的ID $db->delete('t_cteacher_gradeid', "ctg_ctid IN ({$rm_ct_str})"); $db->delete('t_cteacher_subjectid', "cts_ctid IN ({$rm_ct_str})"); $db->delete('t_cteacher_school', "scht_ctid IN ({$rm_ct_str})"); $db->delete('t_cteacher', "ct_id IN ({$rm_ct_str})"); } $db->update('t_cteacher', array('ct_flag' => -1), "ct_id IN ({$ct_id_str})"); $bOk = $db->commit(); if (!$bOk) { $db->rollBack(); } } return $bOk ? 1 : 0; }
/** * 获取$profession_id所指定的职业信息,返回结果集 * @param mixed $profession_id * @param array map<string, variant> */ public static function professionInfo($profession_id) { if (!$profession_id) { return array(); } if (Validate::isInt($profession_id)) { $sql = "SELECT * FROM t_profession\n WHERE profession_id = ?"; return Fn::db()->fetchRow($sql, array($profession_id)); } else { if (Validate::isJoinedIntStr($profession_id)) { $sql = "SELECT * FROM t_profession\n WHERE profession_id IN ({$profession_id})"; return Fn::db()->fetchAssoc($sql); } else { return array(); } } }
/** * 选择培训机构校区列表 * @param int $ti_id = NULL 培训机构ID,若为NULL表示查询所有,否则 * 表示只查询该机构ID所指校区 * @param int multisel GET参数,若为1表多选,否则表单选 */ public function seltclist($ti_id = NULL) { $param = array(); $ti_id = intval($ti_id); if ($ti_id) { $ti_info = TrainingInstitutionModel::trainingInstitutionInfo($ti_id); if ($ti_info) { $param['tc_tiid'] = $ti_id; } } else { $ti_info = array(); } if (isset($_GET['page'])) { $page = intval($_GET['page']); if ($page < 1) { $page = 1; } } else { $page = 1; } $param['order_by'] = 'tc_tiid, tc_provid, tc_cityid, tc_areaid, tc_id'; $tc_id = Fn::getParam('tc_id'); if (Validate::isJoinedIntStr($tc_id)) { $param['tc_id'] = $tc_id; } $data = array(); $data['ti_info'] = $ti_info; $data['tc_list'] = TrainingInstitutionModel::trainingCampusList('*', $param, $page); $data['tc_list_count'] = TrainingInstitutionModel::trainingCampusListCount($param); $this->load->view('traininginstitution/seltclist', $data); }
/** * 删除四维学科 * @param array map<string,variant>类型的学科思维信息参数 * int subd_subjectid 学科四维ID * @return boolean 若成功则返回TRUE,否则返回0 **/ public static function removeSubjectDimension($subd_subjectid) { if (Validate::isInt($subd_subjectid)) { return Fn::db()->delete('t_subject_dimension', "subd_subjectid = {$subd_subjectid}"); } else { if (Validate::isJoinedIntStr($subd_subjectid)) { return Fn::db()->delete('t_subject_dimension', "subd_subjectid IN ({$subd_subjectid})"); } else { return false; } } }
/** * 删除职业兴趣/职业能力倾向 * @param int $pr_id_str * @return bool true|false */ public static function removeProfessionRelated($pr_id_str) { if (!Validate::isJoinedIntStr($pr_id_str)) { return false; } $db = Fn::db(); $sql = "DELETE FROM t_profession_related WHERE pr_flag = '-1' \n AND pr_id IN ({$pr_id_str})"; $db->exec($sql); $sql = "UPDATE t_profession_related SET pr_flag = '-1'\n WHERE pr_id IN ({$pr_id_str})"; $db->exec($sql); return true; }
/** * 获取课程校区关联老师 对象, 查v_course_campus_teacher视图 * @param string $cc_id_str 形如1,3,4样式的课程ID字符串 * @return array map<int, map<int, map<string, varaint>>> * $arr[cct_ccid][cct_ctid] = * */ public static function courseCampusTeacherPairs($cc_id_str) { if (!Validate::isJoinedIntStr($cc_id_str)) { throw new Exception('课程校区ID列表应为形如1,2,3样式的ID列表字符串'); } $sql = <<<EOT SELECT * FROM v_course_campus_teacher WHERE cct_ccid IN ({$cc_id_str}) ORDER BY cct_ccid,cct_ctid EOT; $rows = Fn::db()->fetchAll($sql); $arr = array(); foreach ($rows as $v) { if (!isset($arr[$v['cct_ccid']])) { $arr[$v['cct_ccid']] = array(); } $arr[$v['cct_ccid']][$v['cct_ctid']] = $v; } unset($rows); return $arr; }
/** * 按学科ID,父ID的二级知识点列表 * @param int 学科ID * @param int 上级ID * @return array */ public static function get_knowledge_children_list($subject_id = 0, $pid = 0) { if (!$subject_id || !Validate::isInt($subject_id) && !Validate::isJoinedIntStr($subject_id)) { return false; } $sql = "SELECT * FROM rd_knowledge WHERE "; if (Validate::isInt($subject_id)) { $sql .= " subject_id = {$subject_id}"; } else { if (Validate::isJoinedIntStr($subject_id)) { $sql .= " subject_id IN ({$subject_id})"; } } if ($pid > 0) { $sql .= " AND pid = {$pid}"; } else { $sql .= " AND pid > 0"; } return Fn::db()->fetchAssoc($sql); }
/** * 编辑授课教师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; }
/** * 测试报名 * @param int $exam 期次id * @param int $place 场次id, 多个ID用英文逗号分隔开 * @param int $p_id 产品id * @return json 成功/失败 */ public function place_in() { $exam = intval($this->input->post('exam')); $place = $this->input->post('place'); $uid = $this->session->userdata('uid'); $p_id = intval($this->input->post('p_id')); $force = intval($this->input->post('force')); $b_pushcourse = intval($this->input->post('b_pushcourse')); if (!Validate::isJoinedIntStr($place)) { output_json(CODE_ERROR, '报名失败,考场不正确'); } // 检查是否存在该学生 $account = StudentModel::get_student($uid, 'account,account_status'); if (!count($account['account'])) { output_json(CODE_ERROR, '报名失败,不存在该学生.'); } else { if ($account['account_status']) { output_json(CODE_ERROR, '报名失败,学生帐号已被冻结'); } } if (CommonModel::get_product_trans($p_id, $uid, $place, $exam)) { output_json(CODE_ERROR, '报名失败,已报名该产品'); } $res = CommonModel::get_product_list($p_id); if (!$res) { output_json(CODE_ERROR, '报名失败,产品不存在'); } else { $price = $b_pushcourse ? $res['p_price_pushcourse'] : $res['p_price']; $pc_id = $res['pc_id']; } $account = $account['account']; $account1 = $account - $price; if ($account1 < 0) { output_json(CODE_ERROR, '帐号余额不足'); } $inserts = array(); $error = array(); $code = CODE_ERROR; $place_id_arr = array_unique(explode(',', $place)); $place_id_arr2 = array(); foreach ($place_id_arr as $place_id) { if ($place_id) { $query = $this->db->select('p.*,e.exam_name,e.exam_id,e.exam_pid,e.grade_id')->from('exam_place p')->join('exam e', 'p.exam_pid=e.exam_id')->where(array('p.place_id' => $place_id))->get(); $place = $query->row_array(); } else { continue; } if (empty($place)) { $error[] = "考场[{$place_id}]信息不存在"; //output_json(CODE_ERROR, '考场信息不存在'); continue; } $ids = $uid; // 控制考场只能在未开始考试操作 $no_start = ExamPlaceModel::place_is_no_start($place_id); if (!$no_start) { $error[] = "考场[{$place_id}]正确考试或已结束,无法报名"; continue; //output_json(CODE_ERROR, '该考场正在考试或已结束,无法做此操作'); } // $ids = my_intval($ids); // $school_id = (int)$this -> input ->post('school_id'); // 该考场所考到的学科 $subject_ids = array(); $query = $this->db->select('subject_id')->from('exam_place_subject')->where(array('place_id' => $place['place_id']))->get(); $subjects = $query->result_array(); $subject_ids = array(); foreach ($subjects as $subject) { $subject_ids[] = $subject['subject_id']; } $subject_ids = count($subject_ids) ? implode(',', $subject_ids) : '""'; $place['start_time'] = $place['start_time'] + 1; $place['end_time'] = $place['end_time'] - 1; if ($force == 0) { $sql = "SELECT count(u.uid) FROM rd_student u\n WHERE u.grade_id={$place['grade_id']} AND u.is_delete=0 AND u.uid ={$ids}"; $query = Fn::db()->fetchOne($sql); if ($query == 0) { $error[] = "考场[{$place_id}]您的年级不符合要求"; $code = -2; continue; //output_json('-2', '你的年级不符合要求'); } } $not_exists_sql = <<<EOT SELECT uid FROM rd_exam_place_student ps, rd_exam_place p, rd_exam e WHERE e.exam_isfree = 0 AND ps.place_id = p.place_id AND p.place_index = {$place['place_index']} AND ps.uid = u.uid AND p.exam_pid = e.exam_id AND ( ( (p.start_time >= {$place['start_time']} AND p.start_time <= {$place['end_time']} ) OR ( p.end_time >= {$place['start_time']} AND p.end_time <= {$place['end_time']} ) OR ( p.start_time <= {$place['start_time']} AND p.end_time >= {$place['end_time']} ) ) OR p.place_id IN ( SELECT DISTINCT(place_id) FROM rd_exam_place_subject eps WHERE eps.subject_id IN ({$subject_ids}) AND eps.exam_pid = {$place['exam_id']} ) ) EOT; $sql = <<<EOT SELECT u.uid FROM rd_student u WHERE u.is_delete = 0 AND u.uid = {$ids} AND NOT EXISTS({$not_exists_sql}) EOT; $tmp_inserts = array(); $query = $this->db->query($sql); foreach ($query->result_array() as $row) { $vrow = array('place_id' => $place_id, 'uid' => $row['uid']); $tmp_inserts[] = $vrow; $inserts[] = $vrow; } if (empty($tmp_inserts)) { $error[] = "考场[{$place_id}]时间段内您已经参加了相同时间段其它考试"; continue; //output_json(CODE_ERROR, '你已经参加相同时间段其他考试'); } $place_id_arr2[] = $place_id; } if (!empty($error) || empty($inserts)) { output_json($code, "报名失败\n" . implode("\n", $error)); } $vc = C('virtual_currency'); $pt_log = $account . $vc['name'] . '--' . $account1 . $vc['name']; $txt_account = -$price; $db = Fn::db(); $flag = false; if ($db->beginTransaction()) { foreach ($inserts as $val) { $db->replace('rd_exam_place_student', $val); } $param = array('tr_uid' => $uid, 'tr_type' => 3, 'tr_pid' => $p_id, 'tr_flag' => 1, 'tr_money' => $account1, 'tr_trade_amount' => $txt_account, 'tr_comment' => $pt_log); $number = TransactionRecordModel::addTransactionRecord($param); if ($b_pushcourse) { $now = date('Y-m-d H:i:s'); foreach ($place_id_arr2 as $place_id) { $db->insert('t_course_push', array('cp_stuuid' => $uid, 'cp_exampid' => $exam, 'cp_examplaceid' => $place_id, 'cp_addtime' => $now)); } } $sql = <<<EOT UPDATE rd_student SET account = account - {$price} WHERE uid = {$uid} EOT; $db->exec($sql); $flag = $db->commit(); if (!$flag) { $db->rollBack(); $error[] = "考场[{$place_id}]报名失败"; } } if (!$flag) { output_json(CODE_ERROR, "报名失败\n" . implode("\n", $error)); } else { output_json(CODE_SUCCESS, '报名成功.'); } }
public function remove_subject_dimension($subd_subjectid) { if (!Validate::isJoinedIntStr($subd_subjectid)) { message('请选择需要删除的学科四维'); } if (SubjectModel::removeSubjectDimension($subd_subjectid)) { admin_log('delete', 'subject_dimension', $subd_subjectid); message('删除成功', '/admin/subject/subject_dimension_list'); } else { message('删除失败', '/admin/subject/subject_dimension_list'); } }
/** * 删除计划任务中指定的评估规则 */ public static function removeCronTaskReport($rule_id) { if (!Validate::isJoinedIntStr($rule_id)) { throw new Exception('请指定评估规则!'); } $bOk = false; $db = Fn::db(); if ($db->beginTransaction()) { $db->delete('rd_convert2pdf', "rule_id IN ({$rule_id})"); $db->delete('rd_cron_task_report', "rule_id IN ({$rule_id})"); $db->delete('rd_evaluate_student_stat', "rule_id IN ({$rule_id})"); $bOk = $db->commit(); if (!$bOk) { $db->rollBack(); } } return $bOk; }
/** * 编辑授课教师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; }
/** * 删除职业 * @param int $profession_id_str * @return bool true|false */ public static function removeLearnStyle($learnstyle_id_str) { if (!Validate::isJoinedIntStr($learnstyle_id_str)) { return false; } $db = Fn::db(); $sql = "DELETE FROM t_learn_style WHERE learnstyle_flag = '-1' \n AND learnstyle_id IN ({$learnstyle_id_str})"; $db->exec($sql); $sql = "UPDATE t_learn_style SET learnstyle_flag = '-1'\n WHERE learnstyle_id IN ({$learnstyle_id_str})"; $db->exec($sql); $sql = "DELETE FROM t_learn_style_attribute \n WHERE lsattr_learnstyleid NOT IN \n (\n SELECT learnstyle_id FROM t_learn_style\n )"; $db->exec($sql); return true; }
/** * 新增课程及编辑课程方法 * 新增时只添加主表t_course;编辑时同时编辑子表t_course_开头的子表 * @param array $param map<string, variant>类型的参数 * int cors_id 课程ID,若为0则表新增;否则表编辑 * string cors_name 课程名称 * int cors_tiid 课程所属培训机构.编辑时不可修改 * int cors_cmid 授课模式,编辑时不可修改 * int cors_stunumtype 授课班级类型 * int cors_flag 状态,-1已删 0禁用 1启用 大于1表待审 * string cors_url 网址 * string grade_id_str 形如1,2,3样式的年级ID列表,0表所有年级 * string subject_id_str 形如1,2,3样式的学科ID列表,0表所有学科 * string class_id_str 形如1,2,3样式的考试类型ID列表 * map<int,int> kid_knprocid_pairs 知识点列表,键为知识点ID,值为 * 认知类型 * string cors_memo 备注 * list<map<string, variant>> cc_list 课程校区子表数据 * int cc_id 课程校区子表ID,若为0表示新增 * int cc_corsid 所属课程ID * int cc_tcid 若为空则表示为一对一课程;否则表示 * 班级授课所属的校区ID * int cc_ctfid 教师来源ID * string cc_classtime 上课时间 * date cc_begindate 开课日期 * date cc_enddate 结束日期 * int cc_startanytime 是否随时开课,一对一时该值方可 * 为1(此时cc_begindate、cc_enddate * 为空),否则必须为0 * int cc_hours 课时 * double cc_price 课程费用 * int cc_provid 上课地址省 * int cc_cityid 上课地址市 * int cc_areaid 上课地址区 * string cc_addr 上课地址明细 * string cc_ctcperson 联系人 * string cc_ctcphone 联系电话 */ public function setCorsFunc($param) { $resp = new AjaxResponse(); $cors_id = $param['cors_id'] = intval($param['cors_id']); $param = Func::param_copy($param, 'cors_id', 'cors_name', 'cors_tiid', 'cors_cmid', 'cors_stunumtype', 'cors_flag', 'cors_url', 'grade_id_str', 'subject_id_str', 'class_id_str', 'kid_knprocid_pairs', 'cors_memo', 'cc_list', 'kid_all'); if ($param['cors_id'] == 0) { unset($param['cors_id']); unset($param['cc_list']); unset($param['cors_memo']); if (!isset($param['kid_knprocid_pairs'])) { $param['kid_knprocid_pairs'] = array(); } } else { if ($param['cors_memo'] == '') { $param['cors_memo'] = NULL; } } if (isset($param['kid_knprocid_pairs'])) { if ($param['kid_all'] == '1') { $param['kid_knprocid_pairs'] = array(0 => 0); } } else { if ($param['kid_all'] == '1') { $param['kid_knprocid_pairs'] = array(0 => 0); } } unset($param['kid_all']); if ($param['cors_name'] == '') { $resp->alert('课程名称不可为空'); return $resp; } if (!Validate::isInt($param['cors_tiid'])) { $resp->alert('所属培训机构不可为空'); return $resp; } if (!Validate::isInt($param['cors_cmid']) || $param['cors_cmid'] < 1) { $resp->alert('授课模式必须选择'); return $resp; } if (!Validate::isInt($param['cors_stunumtype']) || $param['cors_stunumtype'] < 1) { $resp->alert('班级类型必须选择'); return $resp; } if ($param['cors_cmid'] == 1 && $param['cors_stunumtype'] != 1 || $param['cors_cmid'] != 1 && $param['cors_stunumtype'] == 1) { $resp->alert('授课模式和班级类型不匹配'); return $resp; } if (!Validate::isInt($param['cors_flag'])) { $resp->alert('状态标志必须选择'); return $resp; } if ($param['cors_url'] == '') { $param['cors_url'] = NULL; } if (!Validate::isJoinedIntStr($param['grade_id_str'])) { $resp->alert('年级必须选择'); return $resp; } if (!Validate::isJoinedIntStr($param['subject_id_str'])) { $resp->alert('学科必须选择'); return $resp; } if (isset($param['class_id_str']) && $param['class_id_str'] != '' && !Validate::isJoinedIntStr($param['subject_id_str'])) { $resp->alert('考试类型不正确'); return $resp; } $param['gradeid_list'] = explode(',', $param['grade_id_str']); $param['subjectid_list'] = explode(',', $param['subject_id_str']); if (isset($param['class_id_str']) && $param['class_id_str'] != '') { $param['classid_list'] = explode(',', $param['class_id_str']); } if ($cors_id) { // 编辑功能 $campus_num = count($param['cc_list']); if ($campus_num < 1) { $resp->alert('请至少添加一个校区'); return $resp; } $err = NULL; $tcid_arr = array(); for ($i = 0; $i < $campus_num; $i++) { $param['cc_list'][$i] = Func::param_copy($param['cc_list'][$i], 'cc_id', 'cc_corsid', 'cc_tcid', 'cc_ctfid', 'cc_classtime', 'cc_begindate', 'cc_enddate', 'cc_startanytime', 'cc_hours', 'cc_price', 'cc_provid', 'cc_cityid', 'cc_areaid', 'cc_addr', 'cc_ctcperson', 'cc_ctcphone', 'cct_ctid_str'); $param['cc_list'][$i]['cc_corsid'] = $cors_id; $err_pre = ''; if ($param['cors_cmid'] != 1) { $err_pre = '第' . ($i + 1) . '个校区'; if (!Validate::isInt($param['cc_list'][$i]['cc_tcid'])) { $err = $err_pre . '没有选择具体的培训校区'; break; } $param['cc_list'][$i]['cc_tcid'] = intval($param['cc_list'][$i]['cc_tcid']); if ($param['cc_list'][$i]['cc_tcid']) { $tcid_arr[] = intval($param['cc_list'][$i]['cc_tcid']); } } else { $err_pre = '第' . ($i + 1) . '个校区'; if ($param['cc_list'][$i]['cc_tcid'] == '') { $param['cc_list'][$i]['cc_tcid'] = NULL; } else { if (!Validate::isInt($param['cc_list'][$i]['cc_tcid'])) { $err = $err_pre . '没有选择具体的培训校区'; break; } $param['cc_list'][$i]['cc_tcid'] = intval($param['cc_list'][$i]['cc_tcid']); if ($param['cc_list'][$i]['cc_tcid']) { $tcid_arr[] = intval($param['cc_list'][$i]['cc_tcid']); } } } if (!isset($param['cc_list'][$i]['cct_ctid_str'])) { $param['cc_list'][$i]['cct_ctid_str'] = ''; } /* if ($param['cc_list'][$i]['cct_ctid_str'] == '') { $err = $err_pre . '请添加授课教师'; break; } */ if (strlen($param['cc_list'][$i]['cct_ctid_str']) > 0) { if (!Validate::isJoinedIntStr($param['cc_list'][$i]['cct_ctid_str'])) { $err = $err_pre . '请添加正确的授课教师'; break; } $param['cc_list'][$i]['teacherid_list'] = explode(',', $param['cc_list'][$i]['cct_ctid_str']); } else { $param['cc_list'][$i]['teacherid_list'] = array(); } unset($param['cc_list'][$i]['cct_ctid_str']); if (!Validate::isInt($param['cc_list'][$i]['cc_ctfid'])) { $err = $err_pre . '请选择教师来源'; break; } if ($param['cc_list'][$i]['cc_classtime'] == '') { $err = $err_pre . '请填写课程时间'; break; } if ($param['cc_list'][$i]['cc_startanytime'] == '1') { $param['cc_list'][$i]['cc_startanytime'] = 1; } else { $param['cc_list'][$i]['cc_startanytime'] = 0; if ($param['cc_list'][$i]['cc_begindate'] == '') { $err = $err_pre . '请填写课程周期开课日期'; break; } if (!Validate::isDate($param['cc_list'][$i]['cc_begindate'])) { $err = $err_pre . '请填写正确的课程周期开课日期'; break; } if ($param['cc_list'][$i]['cc_enddate'] == '') { $err = $err_pre . '请填写课程周期结束日期'; break; } if (!Validate::isDate($param['cc_list'][$i]['cc_enddate'])) { $err = $err_pre . '请填写正确的课程周期结束日期'; break; } if (strcmp($param['cc_list'][$i]['cc_enddate'], $param['cc_list'][$i]['cc_begindate']) < 0) { $err = $err_pre . '课程结束日期应大于开始日期'; break; } } if (!Validate::isInt($param['cc_list'][$i]['cc_hours'])) { $err = $err_pre . '请填写课时'; break; } if (!is_numeric($param['cc_list'][$i]['cc_price'])) { $err = $err_pre . '请填写课程收费'; break; } if ($param['cc_list'][$i]['cc_provid'] == '0') { $err = $err_pre . '请选择上课地址所在省市区'; break; } if ($param['cc_list'][$i]['cc_addr'] == '') { $err = $err_pre . '请填写上课地址'; break; } } if ($err) { $resp->alert($err); return $resp; } if (count($tcid_arr) > 0) { if (count($tcid_arr) != count(array_unique($tcid_arr))) { $resp->alert('校区列表中有相同的机构校区,请检查'); return $resp; } } } try { if ($cors_id) { $db = Fn::db(); $cc_id_arr = array(); $rows = CourseModel::courseCampusList("cc_id", array('cc_corsid' => $cors_id)); if ($rows) { foreach ($rows as $row) { $cc_id_arr[] = intval($row['cc_id']); } } $bOk = false; if (!$db->beginTransaction()) { throw new Exception('启动存储过程失败'); } $set_cc_id_arr = array(); try { CourseModel::setCourse($param, false); foreach ($param['cc_list'] as $row) { $row['cc_id'] = intval($row['cc_id']); if ($row['cc_id']) { CourseModel::setCourseCampus($row, false); $set_cc_id_arr[] = $row['cc_id']; } else { CourseModel::addCourseCampus($row, false); } } $remove_cc_id_arr = array_diff($cc_id_arr, $set_cc_id_arr); if ($remove_cc_id_arr) { CourseModel::removeCourseCampus(implode(',', $remove_cc_id_arr), false); } $bOk = $db->commit(); if (!$bOk) { $db->rollBack(); } } catch (Exception $e) { $db->rollBack(); throw $e; } if ($bOk) { admin_log('edit', 'course', "cors_id: {$cors_id}"); $resp->redirect(site_url('admin/course/corsinfo/' . $cors_id)); } else { $resp->alert('执行存储过程失败'); } } else { // 新增 $cors_id = CourseModel::addCourse($param); admin_log('add', 'course', "cors_id: {$cors_id}"); $resp->redirect(site_url('admin/course/setcorsinfo/' . $cors_id)); } } catch (Exception $e2) { $resp->alert($e2->getMessage()); } return $resp; }
public static function examRelatelistCount($cond_param = null) { $bind = array(); $where = array(); if (is_string($cond_param)) { $where[] = $cond_param; } else { if (is_array($cond_param)) { if (Validate::isInt($cond_param['er_exampid'])) { $where[] = 'er_exampid = ?'; $bind[] = $cond_param['er_exampid']; } else { if (Validate::isJoinedIntStr($cond_param['er_exampid'])) { $where[] = 'er_exampid IN (' . $cond_param['er_exampid'] . ')'; } } } } $sql = "SELECT COUNT(*) FROM t_exam_relate"; if (!empty($where)) { $sql .= ' WHERE (' . implode(') AND (', $where) . ')'; } return Fn::db()->fetchOne($sql, $bind); }
/** * 选择试题 * * @return void **/ public function select_question($paper_id = 0) { /* 查询条件 */ $where = array(); $param = array(); /* 过滤题组子题目,在题组页面管理 */ $where[] = "q.parent_id=0"; /* 未禁用试题 */ $where[] = "q.is_delete<>1"; /* 纸质考试试题 */ //$where[] = "q.test_way IN (1, 2, 3)"; /* 录入人员 只能查看自己录入的题目 管理员可以看到所有题目 */ $admin_id = $this->session->userdata('admin_id'); if (!$admin_id) { message('获取管理员数据失败,请从新登陆后重试!'); } //$where[] = "q.admin_id='{$admin_id}'"; //限制只能查看自己创建的试题 if (!$this->is_super_user() && !CpUserModel::is_action_type_all('question', 'r') && !CpUserModel::is_action_type_subject('question', 'r') && CpUserModel::is_action_type_self('question', 'r')) { $where[] = "q.admin_id='{$admin_id}'"; } else { $where[] = "q.admin_id>0"; } //限制只能查看所属学科 $c_subject_id = array(); if (!$this->is_super_user() && !CpUserModel::is_action_type_all('question', 'r') && CpUserModel::is_action_type_subject('question', 'r')) { $c_subject_id = rtrim($this->session->userdata('subject_id'), ','); if ($c_subject_id != '') { $c_subject_id = explode(',', $c_subject_id); $c_subject_id = array_values(array_filter($c_subject_id)); $c_subject_id = implode(',', $c_subject_id); $where[] = "q.subject_id in({$c_subject_id})"; } } //限制只能查看所属年级 $c_grade_id = array(); if (!$this->is_super_user() && !$this->is_all_grade_user()) { $c_grade_id = rtrim($this->session->userdata('grade_id'), ','); if ($c_grade_id != '') { $c_grade_id = explode(',', $c_grade_id); $c_grade_id = array_values(array_filter($c_grade_id)); $c_grade_id = implode(',', $c_grade_id); $where_3 = " grade_id in({$c_grade_id})"; } else { $where_3 = '1=1'; } } else { $where_3 = '1=1'; } //限制只能查看所属类型 $c_class_id = array(); if (!$this->is_super_user() && !$this->is_all_q_type_user()) { $c_q_type_id = rtrim($this->session->userdata('q_type_id'), ','); if ($c_q_type_id != '') { $c_q_type_id = explode(',', $c_q_type_id); $c_q_type_id = array_values(array_filter($c_q_type_id)); $c_class_id = $c_q_type_id; $c_q_type_id = implode(',', $c_q_type_id); $where_4 = " class_id in ({$c_q_type_id})"; } else { $where_4 = '1=1'; } } else { $where_4 = '1=1'; } if ($where_3 != '1=1' || $where_4 != '1=1') { $where[] = "q.ques_id IN (SELECT DISTINCT ques_id FROM rd_relate_class WHERE {$where_3} AND {$where_4}) "; } if ($paper_id) { $paper = ExamPaperModel::get_paper_by_id($paper_id); $where[] = "q.subject_id = {$paper['subject_id']}"; $param[] = "subject_id={$paper['subject_id']}"; $data['subject_id'] = $paper['subject_id']; if ($paper['exam_id']) { $exam = ExamModel::get_exam($paper['exam_id'], 'grade_id, class_id'); list($grade_id, $class_id) = array_values($exam); $where[] = "q.start_grade <= {$grade_id} AND q.end_grade >= {$grade_id}"; $param[] = "grade_id={$grade_id}"; $data['grade_id'] = $exam['grade_id']; $where[] = "q.class_id LIKE '%,{$class_id},%'"; $param[] = "class_id={$class_id}"; $data['class_id'] = $exam['class_id']; } } else { if ($subject_id = $this->input->get('subject_id')) { $where[] = "q.subject_id = {$subject_id}"; $param[] = "subject_id={$subject_id}"; } if ($grade_id = $this->input->get('grade_id')) { $where[] = "q.start_grade <= {$grade_id} AND q.end_grade >= {$grade_id}"; $param[] = "grade_id={$grade_id}"; } if ($class_id = $this->input->get('class_id')) { $where[] = "q.class_id LIKE '%,{$class_id},%'"; $param[] = "class_id={$class_id}"; } } $type = $this->input->get('type'); if (strlen($type) > 0 && $type >= 0) { $type = intval($type); $where[] = "q.type = {$type}"; $param[] = "type={$type}"; } if ($is_original = $this->input->get('is_original')) { $where[] = "q.is_original = {$is_original}"; $param[] = "is_original={$is_original}"; } if (Validate::isJoinedIntStr($this->input->get('ques_id'))) { $search_quesid = $this->input->get('ques_id'); $where[] = "q.ques_id IN ({$search_quesid})"; $param[] = "ques_id={$search_quesid}"; } if ($remark = $this->input->get('remark')) { $where[] = "q.remark LIKE '%{$remark}%'"; $param[] = "remark={$remark}"; } $where = $where ? ' WHERE ' . implode(' AND ', $where) : ' 1 '; /* 统计数量 */ $nums = QuestionModel::get_question_nums($where); $total = $nums['total']; /* 读取数据 */ $size = 15; $page = $this->input->get('page') ? intval($this->input->get('page')) : 1; $offset = ($page - 1) * $size; $list = array(); /* 学科 */ $qtypes = C('q_type'); /* 试题类型 */ $subjects = C('subject'); if ($total) { $sql = "SELECT q.*,a.admin_user,a.realname FROM {pre}question q\n LEFT JOIN {pre}admin a ON a.admin_id=q.admin_id\n {$where} ORDER BY q.ques_id DESC LIMIT {$offset},{$size}"; $res = $this->db->query($sql); foreach ($res->result_array() as $row) { $row['title'] = strip_tags($row['title']); $row['qtype'] = isset($qtypes[$row['type']]) ? $qtypes[$row['type']] : ''; $row['subject_name'] = isset($subjects[$row['subject_id']]) ? $subjects[$row['subject_id']] : ''; $row['addtime'] = date('Y-m-d H:i', $row['addtime']); $list[] = $row; } } $data['list'] =& $list; $data['q_class'] = $this->db->get_where('question_class')->result_array(); $data['c_subject_id'] = $c_subject_id ? explode(',', $c_subject_id) : array(); $data['c_class_id'] = $c_class_id; $data['c_grade_id'] = $c_grade_id ? explode(',', $c_grade_id) : array(); $data['search_data'] = $_GET; /* 分页 */ $purl = site_url('admin/paper_diy/select_question/' . ($param ? '?' . implode('&', $param) : '')); $data['pagination'] = multipage($total, $size, $page, $purl, '', $nums['relate_num']); /* 模版 */ $this->load->view('paper_diy/question_list', $data); }