Beispiel #1
0
 /**
  * 下载学生成绩单
  */
 public function down_transcript($rule_id = 0)
 {
     $rule_id = intval($rule_id);
     $rule_id && ($rule = EvaluateRuleModel::get_evaluate_rule($rule_id));
     if (empty($rule)) {
         message('不存在该评估规则');
     }
     $place_id = (int) $this->input->get('place_id');
     if ($rule['place_id'] > 0) {
         $place_id = $rule['place_id'];
     }
     if ($place_id > 0) {
         $save_file = realpath(dirname(APPPATH)) . "/cache/transcript/" . $place_id . '.zip';
         if (!file_exists($save_file)) {
             $dir_name = realpath(dirname(APPPATH)) . "/cache/transcript/" . $place_id;
             if (!is_dir($dir_name)) {
                 @mkdir($dir_name, 0777, true);
             }
             $pdf_dir = C('html2pdf_path') . '/zeming/report/';
             $pdf_ready = false;
             $ulist = ExamPlaceModel::placeStudentInfoList($place_id);
             foreach ($ulist as $uid => $item) {
                 $dir = $pdf_dir . "{$rule_id}/transcript_{$uid}";
                 if (!is_dir($dir)) {
                     continue;
                 }
                 $pdf_ready = true;
                 $student_name = $item['last_name'] . $item['first_name'];
                 $student_name .= '_' . (trim($item['external_account']) ? trim($item['external_account']) : trim($item['exam_ticket']));
                 $f = @dir($dir);
                 if ($f) {
                     while (false !== ($entry = $f->read())) {
                         if ($entry != '.' && $entry != '..') {
                             @copy($dir . '/' . $entry, $dir_name . '/' . $student_name . '_' . $entry);
                         }
                     }
                 }
             }
             if ($pdf_ready) {
                 require_once APPPATH . 'libraries/Pclzip.php';
                 $archive = new PclZip($save_file);
                 //将文件进行压缩
                 $archive->create($dir_name, PCLZIP_OPT_REMOVE_PATH, realpath(dirname(APPPATH)) . "/cache/transcript");
                 $this->rm_dir($dir_name);
             } else {
                 message('学生成绩报告单PDF文件还未生成,无法下载!', '/admin/report/down_transcript/' . $rule_id);
             }
         }
         if (file_exists($save_file)) {
             $exam_name = ExamModel::get_exam($rule['exam_pid'], 'exam_name');
             $place = ExamPlaceModel::get_place($place_id, 'place_name,place_schclsid');
             $name = $place['place_name'];
             if ($place['place_schclsid']) {
                 $name = SchoolModel::schoolClassInfo($place['place_schclsid'], 'schcls_name');
             }
             $subject_name = '';
             if ($rule['subject_id'] > 0) {
                 $subject_name = $this->_subject_name($rule['exam_pid'], $rule['subject_id']);
             }
             $filename = $exam_name . $name . $subject_name . '成绩报告单';
             Func::dumpFile('application/zip', $save_file, $filename . '.zip');
         }
     }
     $data['rule'] = $rule;
     $cond_param = array('exam_pid' => $rule['exam_pid']);
     if ($rule['place_id'] > 0) {
         $cond_param['place_id'] = $rule['place_id'];
     }
     $data['places'] = ExamPlaceModel::get_exam_place_list($cond_param, 1, time(), null, 'place_id, place_name');
     $this->load->view('report/down_transcript', $data);
 }
Beispiel #2
0
 /**
  * 保存新增/编辑班级数据
  */
 public function updateclass()
 {
     $schcls_schid = Fn::getParam('schcls_schid');
     $schcls_id = Fn::getParam('schcls_id');
     if (!$schcls_schid && !$schcls_id) {
         message('参数错误');
     }
     $schcls_name = Fn::getParam('schcls_name');
     if (!$schcls_name) {
         message('班级名称不能为空');
     }
     $param = array();
     $param['schcls_name'] = trim($schcls_name);
     try {
         //编辑
         if ($schcls_id) {
             $class = SchoolModel::schoolClassInfo($schcls_id);
             if (!$class) {
                 message('班级不存在');
             }
             $schcls_schid = $class['schcls_schid'];
             $param['schcls_id'] = $schcls_id;
             $result = SchoolModel::setSchoolClass($param);
             if ($result) {
                 admin_log('edit', 'school_class', $schcls_id);
             }
         } else {
             $param['schcls_schid'] = $schcls_schid;
             $result = SchoolModel::addSchoolClass($param);
             if ($result) {
                 admin_log('edit', 'school_class', $result);
             }
         }
         message($result ? '操作成功' : '操作失败', '/admin/school/classlist/' . $schcls_schid);
     } catch (Exception $e) {
         message($e->getMessage());
     }
 }