public function setexamrelate($er_exampid = 0) { $er_exampid = intval($er_exampid); if ($er_exampid > 0) { $exam = ExamModel::get_exam($er_exampid); if ($exam['exam_ticket_maprule'] < 1) { message('该考试不是外部纸质考试,无法对应考试关系!'); } if ($exam['exam_pid'] > 0) { redirect('/admin/zmoss/setexamrelate/' . $exam['exam_pid']); exit; } $data['exam'] = $exam; $data['examrelate'] = ZmossModel::examRelateInfo($er_exampid); $data['examrelatelist'] = ZmossModel::examRelateZmossExamList($er_exampid); $examlist2 = ExamModel::get_exam_list(array('exam_pid' => $er_exampid), null, null, 'subject_id ASC'); } else { $cond_param = array('er_exampid' => 0); $list = ZmossModel::examRelatelist($cond_param, 1, time()); $examplist = array_keys($list); $examlist = ExamModel::get_exam_list_all(array('exam_pid' => 0, 'exam_ticket_maprule >' => '0')); $examlist2 = array(); if ($examlist) { $exam_pid = array(); foreach ($examlist as $k => $item) { if (in_array($item['exam_id'], $examplist)) { unset($examlist[$k]); continue; } $exam_pid[] = $item['exam_id']; } $list = ExamModel::get_exam_list(array('exam_pid' => $exam_pid), null, null, 'subject_id ASC'); foreach ($list as $item) { $examlist2[$item['exam_pid']][] = $item; } unset($list); } } $where = "exam_pid = 0"; $er_zmoss_examid = ZmossModel::examRelateZmossExamList(); if ($er_exampid > 0) { unset($er_zmoss_examid[$er_exampid]); } if ($er_zmoss_examid) { $where .= " AND exam_id NOT IN (" . implode(',', $er_zmoss_examid) . ")"; } $zmossexamlist = ZmossModel::examlist("*", $where); $zmossexamlist2 = array(); if ($zmossexamlist) { $list = ZmossModel::examlist("*", array('exam_pid' => implode(',', array_keys($zmossexamlist)))); foreach ($list as $item) { $zmossexamlist2[$item['exam_pid']][] = $item; } unset($list); } $data['examlist'] = $examlist; $data['examlist2'] = $examlist2; $data['zmossexamlist'] = $zmossexamlist; $data['zmossexamlist2'] = $zmossexamlist2; $data['subject'] = C('subject'); // 模版 $this->load->view('zmoss/setexamrelate', $data); }
/** * 获取考试期次列表 * * @param number $exam_id * @return void */ public function ajax_get_exams($exam_pid = 0) { $exams = ExamModel::get_exam_list(array('exam_pid' => '0', 'status' => array('1', '2')), false, false, null, 'exam_id, exam_name'); $output = array(); $output[] = '<option value="0">--请选择考试期次--</option>'; foreach ($exams as $exam) { $t_exam_pid = $exam['exam_id']; $exam_name = $exam['exam_name']; $output[] = "<option value='{$t_exam_pid}'" . ($exam_pid == $t_exam_pid ? 'selected="selected"' : '') . ">{$exam_name}</option>"; } echo implode('', $output); die; }