/** * 新增/编辑授课教师页面 * @param int $scht_schid 学校ID * @param int $ct_id 授课教师ID,若为0表新增,否则表编辑 */ public function editteacher($scht_schid = 0, $ct_id = 0) { if (!$scht_schid) { message('参数错误'); } $data = array(); $data['scht_schid'] = $scht_schid; Fn::ajax_call($this, 'setSchoolTeacher'); $ct_id = intval($ct_id); if ($ct_id) { $data['ct_info'] = CTeacherModel::CTeacherInfo($ct_id); if (empty($data['ct_info'])) { message('查询无记录', 'admin/school/teacherlist/' . $scht_schid); } } else { $data['ct_info'] = array('ct_id' => 0, 'ct_flag' => time()); } $data['subject_map'] = C('subject'); $data['grade_map'] = C('grades'); $v = CTeacherModel::CTeacherGradeIDPairs($ct_id); if (isset($v[$ct_id])) { $v = $v[$ct_id]; } else { $v = array(); } $data['cteacher_gradeid'] = $v; $v = CTeacherModel::CTeacherSubjectIDPairs($ct_id); if (isset($v[$ct_id])) { $v = $v[$ct_id]; } else { $v = array(); } $data['cteacher_subjectid'] = $v; // 模版 $this->load->view('school/editteacher', $data); }
/** * 下载资源 */ public function down_file() { /* 资源类型(1:pdf, 2:zip, 3:interview_pdf, 4:interview_zip) */ $type = $this->input->get('type'); if ($type == 1) { $target_id = $this->input->get('target_id'); $sql = "SELECT source_path FROM rd_convert2pdf \n WHERE target_id = '{$target_id}'"; $source_path = Fn::db()->fetchOne($sql); $filepath = C('html2pdf_path') . "/{$source_path}"; if (!file_exists($filepath)) { echo '文件不存在'; die; } $name = end(explode('/', $source_path)); $target_ids = explode('_', $target_id); if (count($target_ids) == 4 && in_array(end($target_ids), array(1, 2))) { if (end($target_ids) == 1) { $data = SchoolModel::schoolClassInfo($target_ids[1], 'schcls_name AS name'); } else { if (end($target_ids) == 2) { $data = CTeacherModel::CTeacherInfo($target_ids[1], 'ct_name as name'); } } $name = $data['name'] . '-' . $name; } else { $student = StudentModel::get_student($target_ids[1], 'last_name, first_name'); $name = $student['last_name'] . $student['first_name'] . '-' . $name; } Func::dumpFile('application/pdf', $filepath, $name); } else { if ($type == 2) { $source_path = urldecode($this->input->get('source_path')); $name = $this->input->get('name'); $filepath = realpath(dirname(APPPATH)) . "/cache/zip/report/" . $source_path; if (!file_exists($filepath)) { echo '文件不存在'; die; } Func::dumpFile('application/zip', $filepath, $name); } else { if ($type == 3) { $target_id = $this->input->get('target_id'); $data = explode('_', $target_id); $subject_id = end($data); $name = ($subject_id ? C("subject/{$subject_id}") : '总结') . "面试.pdf"; $source_path = "zeming/interview_report/" . $data[0] . "/" . $data[1] . "/{$name}"; $filepath = C('html2pdf_path') . "/{$source_path}"; if (!file_exists($filepath)) { echo '文件不存在'; die; } if (count($data) == 4) { if (end($data) == 1) { $name = SchoolModel::schoolClassInfo($data[1], 'schcls_name AS name'); } else { if (end($data) == 2) { $name = CTeacherModel::CTeacherInfo($data[1], 'ct_name as name'); } } $name = $name['name'] . '-' . $name; } else { $student = StudentModel::get_student($data[1], 'last_name, first_name'); $name = $student['last_name'] . $student['first_name'] . '-' . $name; } Func::dumpFile('application/pdf', $filepath, $name); } else { if ($type == 4) { $source_path = urldecode($this->input->get('source_path')); $name = $this->input->get('name'); $filepath = realpath(dirname(APPPATH)) . "/cache/zip/interview_report/" . $source_path; if (!file_exists($filepath)) { echo '文件不存在'; die; } Func::dumpFile('application/zip', $filepath, $name); /* header("Cache-Control: public"); header("Content-Description: File Transfer"); header('Content-disposition: attachment; filename='.$name); //文件名 header("Content-Type: application/zip"); //zip格式的 header("Content-Transfer-Encoding: binary"); //告诉浏览器,这是二进制文件 header('Content-Length: '. filesize($filepath)); //告诉浏览器,文件大小 @readfile($filepath); */ } else { echo '文件不存在!'; exit; } } } } }
/** * 新增/编辑授课教师页面 * @param int $ct_id 授课教师ID,若为0表新增,否则表编辑 */ public function setctinfo($ct_id) { Fn::ajax_call($this, 'setCT'); $ct_id = intval($ct_id); $data = array(); if ($ct_id) { $data['ct_info'] = CTeacherModel::CTeacherInfo($ct_id); if (empty($data['ct_info'])) { message('查询无记录', 'admin/cteacher/ctlist'); } } else { $data['ct_info'] = array('ct_id' => 0, 'ct_flag' => time()); } $data['subject_map'] = C('subject'); $data['grade_map'] = C('grades'); //$data['subject_map'][0] = '[全部学科]'; //$data['grade_map'][0] = '[全部年级]'; $v = CTeacherModel::CTeacherGradeIDPairs($ct_id); if (isset($v[$ct_id])) { $v = $v[$ct_id]; } else { $v = array(); } $data['cteacher_gradeid'] = $v; $v = CTeacherModel::CTeacherSubjectIDPairs($ct_id); if (isset($v[$ct_id])) { $v = $v[$ct_id]; } else { $v = array(); } $data['cteacher_subjectid'] = $v; if ($ct_id) { $sql = <<<EOT SELECT a.cc_id, a.tc_name, b.ti_name, b.cors_name FROM v_course_campus a LEFT JOIN v_course b on a.cc_corsid = b.cors_id WHERE a.cc_id IN ( SELECT cct_ccid FROM t_course_campus_teacher WHERE cct_ctid = {$ct_id}) EOT; $data['cteacher_cclist'] = Fn::db()->fetchAll($sql); } $this->load->view('cteacher/setctinfo', $data); }