addCondition('create_time>=:create_time'); $criteria->params[':create_time'] = strtotime($start_time); } if(empty($_page)) { $_page = 1; } if($end_time) { $criteria->addCondition('create_time<=:end_time'); $criteria->params[':end_time'] = strtotime($end_time); } if($mode<0){ $criteria->addCondition('mode=:mode'); $criteria->params[':mode'] = 0; } if($mode>0){ $criteria->addInCondition('mode',array(1,2)); } $criteria->order = "create_time desc"; $count = SNotificationModel::model()->count($criteria); $pager = new CPagination($count,10); $criteria->limit=$pager->getLimit(); $criteria->offset=$pager->getOffset(); $notification_data = SNotificationModel::model()->findAll($criteria); $data = array(); $data['page'] = $pager; $data['start_time'] = $start_time; $data['end_time'] = $end_time; $data['_page'] = $_page; $data['page_total'] = $count; $data['mode'] = $mode; $data['list'] = $notification_data; $this->render("index",$data); } public function actionDel() { $n_id = Req::post('n_id'); if($n_id) { $n_ids = explode(',',$n_id); $criteria = new CDbCriteria(); $criteria->addInCondition('id',$n_ids); SNotificationModel::model()->deleteAll($criteria); echo json_encode(array('status'=>1));exit; } echo json_encode(array('status'=>0));exit; } public function actionAjax_exam_info() { $data = array(); $exam_group_id = Req::post('exam_group_id'); $n_id = Req::post('n_id'); $mode = Req::post('mode'); $teacher_data = array(); $class_data = array(); $class_name = array(); $teacher_ids = array(); $subject_id = 3; //更新已读 if($n_id) { SNotificationModel::model()->updateAll(array('status'=>1,'update_time'=>time()),'id=:id',array(':id'=>$n_id)); } if($mode>1){ $notification = SNotificationModel::model()->find('id=:id',array(':id'=>$n_id)); if($notification) { $data['mode'] = 2; $data['title'] = $notification->title; $data['create_time'] = date('Y-m-d',$notification->create_time); $data['alarm_level'] = $notification->alarm_level; $data['alarm_description'] = $notification->alarm_description; $data['school_name'] = $this->schoolInfo['school_name']; echo json_encode($data);exit; } } //获取本校所有老师信息 $teachers = Teacher::model()->findAll(); if($teachers){ foreach ($teachers as $v) { $teacher_data[$v->teacher_id] = $v->teacher_name; } } //获取本学期班级信息 $classes = ClassModel::model()->findAll('semester_id=:semester_id',array(':semester_id'=>$this->semesterId)); if($classes) { foreach ($classes as $v) { $class_data[$v->class_id] = $v->class_name; } } //获取本次考试信息 $exam_group = ExamGroup::model()->find('exam_group_id=:exam_group_id',array(':exam_group_id'=>$exam_group_id)); if($exam_group) { $data['mark_type'] = $exam_group->mark_type; if(isset($teacher_data[$exam_group->teacher_id])) { $data['teacher_name'] = $teacher_data[$exam_group->teacher_id]; } } //获取考试名称 $exam = Exam::model()->find('exam_group_id=:exam_group_id',array(':exam_group_id'=>$exam_group_id)); if($exam) { $data['exam_name'] = $exam->name; $data['exam_time'] = date('Y-m-d',$exam->create_time); $data['subject_id'] = $exam->subject_id; $subject_id = $exam->subject_id; } //获取通知信息 $notification = SNotificationModel::model()->find('id=:id',array(':id'=>$n_id)); if($notification) { $class_ids = explode(',',$notification->classids); foreach ($class_ids as $v) { if(isset($class_data[$v])) { $class_name[] = $class_data[$v]; } } $teacher_name=array(); if($exam_group&& isset($exam_group->mark_type)&&$exam_group->mark_type==4) { $criteria1 = new CDbCriteria(); $criteria1->addInCondition('class_id',$class_ids); $teacher_class = TeacherToClass::model()->findAll($criteria1); if($teacher_class) { if(in_array($subject_id,$this->mathSubjectId)){ $subject_id = 3; } foreach ($teacher_class as $v) { $teacher_ids[$v->teacher_id] = $v->teacher_id; } // $criteria = new CDbCriteria(); $criteria->addInCondition('teacher_id',$teacher_ids); $criteria->addCondition('subjects=:subjects'); $criteria->params[':subjects'] = $subject_id; $teacher_ids = Teacher::model()->findAll($criteria); if($teacher_ids){ foreach ($teacher_ids as $val){ $teacher_name[]=$val->teacher_name; } } } $data['teacher_name'] = join(',',$teacher_name); } $data['class_name'] = join(',',$class_name); $data['mode'] = 1; $count = SNotificationModel::model()->count('status=:status',array(':status'=>0)); $data['count'] = $count; } echo json_encode($data);exit; } //2021新版客户端通知 public function actionList(){ $title = Req::get("title"); $_page = Req::get("page"); $criteria = new CDbCriteria(); if(empty($_page)) { $_page = 1; } if($title){ $criteria->addCondition("title like :title"); $criteria->params[':title'] = '%'.$title.'%'; } if(!isset(Yii::app()->session['testFlag']) || (Yii::app()->session['testFlag']!=1)){ $criteria->addCondition("status =2"); } $criteria->order = "create_time desc"; $count = ClientNotifyModel::model()->count($criteria); $pager = new CPagination($count,10); $criteria->limit=$pager->getLimit(); $criteria->offset=$pager->getOffset(); $notification_data = ClientNotifyModel::model()->findAll($criteria); $data = array(); $data['page'] = $pager; $data['_page'] = $_page; $data['page_total'] = $count; $data['title'] = $title; $data['list'] = $notification_data; $this->render("list",$data); } public function actionPush(){ $id = Req::post("id"); $result=array(); $result['status']=0; if(!$id){ $result['msg']='id不能为空'; exit(json_encode($result)); } $criteria = new CDbCriteria(); $criteria->addCondition('id=:id'); $criteria->params[':id'] = $id; $rs = ClientNotifyModel::model()->updateAll(array('status'=>2,'update_time'=>time()),$criteria); if($rs){ $result['status']=1; } exit(json_encode($result)); } public function actionDeleteNo(){ $id = Req::post('id'); $result['status']=0; $criteria = new CDbCriteria(); $criteria->addCondition('id=:id'); $criteria->params[':id'] = $id; //ClientNotifyModel::model()->deleteAll($criteria); $rs = ClientNotifyModel::model()->updateAll(array('status'=>0,'update_time'=>time()),$criteria); if($rs){ $result['status']=1; } exit(json_encode($result)); } public function actionEdit(){ if (Yii::app()->request->getIsPostRequest()){ $title=Req::post('title'); $content=Req::post('content'); $eid=Req::post('eid'); $files=Req::post('files'); $time=time(); if($eid){ $criteria = new CDbCriteria(); $criteria->addCondition('id=:id'); $criteria->params[':id'] = $eid; $rs = ClientNotifyModel::model()->updateAll(array('title'=>$title,'content'=>$content,'update_time'=>time(),'file_list'=>$files),$criteria); if($rs){ Yii::app()->jump->error('保存成功',Yii::app()->createUrl('notification/list')); }else{ Yii::app()->jump->error('保存失败',Yii::app()->createUrl('notification/edit')); } }else{ $notifyModel=new ClientNotifyModel(); $notifyModel->title=$title; $notifyModel->content=$content; $notifyModel->create_time=$time; $notifyModel->status=1; $notifyModel->update_time=$time; $notifyModel->file_list=$files; if($notifyModel->save()){ Yii::app()->jump->error('保存成功',Yii::app()->createUrl('notification/list')); }else{ Yii::app()->jump->error('保存失败',Yii::app()->createUrl('notification/edit')); } } } $id=Req::get('id'); $data=array(); if($id){ $rs=ClientNotifyModel::model()->find("id=:id",array(":id"=>$id)); $files=json_decode(str_replace(""",'"',$rs['file_list']),true); $data=array( 'title'=>$rs['title'], 'content'=>$rs['content'], 'id'=>$rs['id'], 'file_list'=>$files ); } $this->render("edit",$data); } public function actionAjaxGetData(){ $id=Req::post('id'); $result['status']=0; if(!$id){ exit(json_encode($result)); } $data=ClientNotifyModel::model()->find("id=:id",array(":id"=>$id)); $files=json_decode(str_replace(""",'"',$data['file_list']),true); $html=''; if($files){ $html='
附件
'; foreach ($files as $file){ $html.=''.$file['file_name'].'
'; } $html.='注:通知发布一个月后,文档将不支持下载,请及时下载所需文档!
'; $html.='附件
'; foreach ($files as $file){ $html.=''.$file['file_name'].'
'; } $html.='注:通知发布一个月后,文档将不支持下载,请及时下载所需文档!
'; $html.='