session["role"] = 2; echo ''; } } // 首页 public function actionIndex(){ $getClass = array(); $printList = array(); $notifyList = array(); if (Yii::app()->session['coachInfo']['leader'] == 1) { // 教练组长 /*+++++++++++ 获取当前学期所有班级 +++++++++++*/ $getClass = ClassModel::model()->findAll('semester_id=:sid',array(':sid'=>Yii::app()->session['session_semester_id'])); /*+++++++++++ 获取所有打印任务 +++++++++++*/ // 获取当前学期班级并组装 $class_array= ClassModel::model()->findAll('semester_id='.Yii::app()->session['session_semester_id']); $ccArray = array(); $ccName = array(); foreach ($class_array as $cc=>$ca) { array_push($ccArray, $ca->class_id); $ccName[$ca->class_id] = $ca->class_name; } $ExamModel = Exam::model(); $ClassModel = ClassModel::model(); $resultList = ClassExamPrinter::model()->getPrintList(); foreach ($resultList as $k=>$v) { if (in_array($v->class_id, $ccArray)) { $printList[$k] = $v->attributes; $printList[$k]['class_name'] = @$ccName[$v->class_id]; $pname = @$ExamModel->getExamName($v->exam_id); // 周周练名称 if ($v->type == 1) { $printList[$k]['print_name']= $pname.'"错题本"打印任务!'; } elseif ($v->type == 2) { $printList[$k]['print_name']= $pname.'"提分册"打印任务!'; } else { $printList[$k]['print_name']= $pname.'打印任务!'; } } } /*+++++++++++ 获取所有动态消息 +++++++++++ */ $teacher = Teacher::model(); $getNotify = NotifyModel::model()->getNotifyList(Yii::app()->session['session_semester_id']); foreach ($getNotify as $key=>$val) { $notifyList[$key] = $val->attributes; $notifyList[$key]['teacher_name'] = $teacher->getTeacherName($val->teacher_id); } } else { // 教员 /*+++++++++++ 获取当前教员所管理班级 +++++++++++*/ $getClass = ClassModel::model()->getClassArray(Yii::app()->session['session_semester_id'],Yii::app()->session['coachInfo']['coach_id']); /*+++++++++++ 获取当前教员打印任务 +++++++++++*/ // 获取教员管理的班级 $coachClass = $this->schoolManager->getCoachClassesRelations($this->coachId, "OBJ"); // 获取当前学期班级 $class_array= ClassModel::model()->findAll('semester_id='.Yii::app()->session['session_semester_id']); if (!empty($coachClass) && !empty($class_array)) { // 获取当前教师当前学期管理的班级 $cidArray = array(); foreach ($class_array as $t){ foreach ($coachClass as $tt) { if ($t->class_id == $tt->class_id) { array_push($cidArray, $tt->class_id); } continue; } } // 是否找到班级 if (!empty($cidArray)) { $ExamModel = Exam::model(); $ClassModel = ClassModel::model(); $resultList = ClassExamPrinter::model()->getPrintList(); foreach ($resultList as $k=>$v) { $pn = 0; if (in_array($v->class_id, $cidArray)) { $printList[$pn] = $v->attributes; $printList[$pn]['class_name'] = @$ClassModel->getClassName($v->class_id); $pname = @$ExamModel->getExamName($v->exam_id); // 周周练名称 if ($v->type == 1) { $printList[$pn]['print_name']= $pname.'"错题本"打印任务!'; } elseif ($v->type == 2) { $printList[$pn]['print_name']= $pname.'"提分册"打印任务!'; } else { $printList[$pn]['print_name']= $pname.'打印任务!'; } } ++$pn; continue; } /*+++++++++++ (当存在教员直接班级时)获取当前教员动态信息 +++++++++++*/ // 获取当前学期教师对应班级集合 $tidArray = array(); $getRelation = TeacherToClass::model()->findAll('semester_id='.Yii::app()->session['session_semester_id']); if (!empty($getRelation)) { foreach ($getRelation as $rl) { if (in_array($rl->class_id,$cidArray)) { array_push($tidArray, $rl->teacher_id); } } } if (!empty($tidArray)) { $teacher = Teacher::model(); $getNotify = NotifyModel::model()->getNotifyList(Yii::app()->session['session_semester_id']); foreach ($getNotify as $key=>$val) { $i = 0; if (in_array($val->teacher_id,$tidArray)){ $notifyList[$i] = $val->attributes; $notifyList[$i]['teacher_name'] = $teacher->getTeacherName($val->teacher_id); } ++$i; continue; } //dump($notifyList);die; } } } } //dump($examList); $data = array(); $data['classList'] = $getClass; $data['printList'] = $printList; $data['notifyList'] = $notifyList; $this->render('index',$data); } // ajax获取教师打印任务等 public function actionGettask(){ $criteria = new CDbCriteria; $criteria->select = 'exam_id,teacher_id,name,type,status'; $criteria->condition= 'status !=1'; $criteria->limit = 20; $criteria->order = 'exam_id DESC'; $getLsit = Exam::model()->findAll($criteria); $teacher = Teacher::model(); $ClassModel = ClassModel::model(); $examList = array(); foreach ($getLsit as $key=>$val) { //$examList[$key] = $val->attributes; if ($val->type == 1) { $typeName = '周周练'; } $examList[$key]['name'] = $val->name; $examList[$key]['type_name'] = $typeName; $examList[$key]['teacher_name'] = $teacher->getTeacherName($val->teacher_id); $examList[$key]['class_name'] = $ClassModel->getClassName($this->schoolManager->getExamClassId($val->exam_id)); } echo json_encode($examList);exit; } // ajax获取动态信息 public function actionGetnotify(){ $criteria = new CDbCriteria; $criteria->condition= 'semester_id=:sid and is_hide=0'; $criteria->params=array(':sid'=>Yii::app()->session['session_semester_id']); $criteria->limit = 20; $criteria->order = 'id DESC'; $getNotify = NotifyModel::model()->findAll($criteria); $notifyList = array(); $teacher = Teacher::model(); foreach ($getNotify as $key=>$val) { $notifyList[$key] = $val->attributes; $notifyList[$key]['teacher_name'] = $teacher->getTeacherName($val->teacher_id); } echo json_encode($notifyList);exit; } // 选着学期操作 public function actionSelect(){ if (isset($_POST['smid']) && !empty($_POST['smid'])) { $json = array(); $smid = safe_replace($_POST['smid']); $findInfo = Semester::model()->find('semester_id=:smid',array(':smid'=>$smid)); if (empty($findInfo)) { $json['flag'] = false; echo json_encode($json);die; } // 重新设置学期session if($this->schoolManager->changeSemester($findInfo->semester_id)){ Yii::app()->session['session_semester_id'] = $findInfo->semester_id; Yii::app()->session['session_semester_name'] = $findInfo->semester_name; if ($findInfo->status == 1){ unset(Yii::app()->session['session_semester_state']); } else { //Yii::app()->session['session_semester_state'] = 12; } } $json['flag'] = true; $json['findInfo'] = $findInfo->semester_name; echo json_encode($json);die; } $data = array(); $data['semesterId'] = Yii::app()->session['session_semester_id']; $data['allSemester']= Semester::model()->findAll(); $this->renderPartial('select',$data); } public function actionShowTips(){ if($tips = Yii::app()->cache->get("coach_".Yii::app()->session->sessionID."_tips")){ $this->render("tips", array("tips" => $tips)); //Yii::app()->cache->delete("tips"); }else { $tips = array( 'title' => '失效', 'result' => '内容失效!', 'content' => '内容失效!', 'url' => Yii::app()->createUrl('classes/index') ); $this->render("tips", array("tips" => $tips)); } } public function actionShowTipss(){ if($tips = Yii::app()->cache->get("coach_".Yii::app()->session->sessionID."_tipss")){ $this->render("tipss", array("tips" => $tips)); //Yii::app()->cache->delete("tips"); }else { $tips = array( 'title' => '失效', 'result' => '内容失效!', 'content' => '内容失效!', 'url' => Yii::app()->createUrl('record/index') ); $this->render("tips", array("tips" => $tips)); } } }