コード例 #1
0
ファイル: school.php プロジェクト: Vincent-Shen/origin
 /**
  * 新增/编辑授课教师页面
  * @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);
 }
コード例 #2
0
ファイル: report.php プロジェクト: Vincent-Shen/origin
 /**
  * 下载资源
  */
 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;
                 }
             }
         }
     }
 }
コード例 #3
0
ファイル: cteacher.php プロジェクト: Vincent-Shen/origin
 /**
  * 编辑授课教师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;
 }