findAll("parent_id=1"); if(!$page) $page=1; $where = array(); $condition=array(); if($schoolName){ $where[]= " school_name like '%".$schoolName."%' "; $condition['school_name']=$schoolName; }else{ if ($provinceId) { $where[]= " province_id='{$provinceId}'"; $condition['province_id']=$provinceId; } if ($cityId) { $where[]= " city_id='{$cityId}'"; $condition['city_id']=$cityId; } if ($areaId) { $where[]= " area_id='{$areaId}'"; $condition['area_id']=$areaId; } } //读取学校开关 $setting=AssistSetting::model()->getAssistSetting(); if($setting){ $acceptSchoolOpen=$setting['accept_school_open']; }else{ $acceptSchoolOpen=0; } $schoolIds=array(); if($where){ $schoolIds=BusinessSchool::model()->getSchoolIdByCondition($where); if(!$schoolIds){ $data=array( 'pages' => array(), 'dataList' => array(), 'province'=>$provinceList, 'acceptSchoolOpen'=>$acceptSchoolOpen, 'condition' =>$condition, ); // debug($data); return $this->render('list', $data); } } $AList=new AWhiteList(); // 任务列表 $totalCount = $AList->countSchool($schoolIds); $pageLimit=10; $pages['page']=$page; $pages['totalPage']=ceil($totalCount/$pageLimit); $pages['total']=$totalCount; //$pages = new Pagination(['totalCount' => $totalCount, 'pageSize' => 10]); //$dataList=ATask::model()->find(implode(' and ',$where),$param)->offset($pages->offset)->limit($pages->limit)->asArray()->all(); $dataList=$AList->getList($schoolIds,$page,$pageLimit); if($dataList){ foreach ($dataList as $key => $val){ //读取省市区 $schoolInfo=BusinessSchool::model()->find('school_id=:sid',array(':sid'=>$val['school_id'])); if($schoolInfo){ $province=BusinessRegion::model()->findByPk($schoolInfo->province_id); $city=BusinessRegion::model()->findByPk($schoolInfo->city_id); $area=BusinessRegion::model()->findByPk($schoolInfo->area_id); if(isset($province->region_name)){ $dataList[$key]['province']=$province->region_name; }else{ $dataList[$key]['province']=''; } if(isset($city->region_name)){ $dataList[$key]['city']=$city->region_name; }else{ $dataList[$key]['city']=''; } if(isset($area->region_name)){ $dataList[$key]['area']=$area->region_name; }else{ $dataList[$key]['area']=''; } } //读取学管 $coachInfo=BusinessCoach::model()->find("school_id=:sid",array(':sid'=>$val['school_id'])); if($coachInfo){ $dataList[$key]['coach']=$coachInfo->real_name.'-'.$coachInfo->telephone; }else{ $dataList[$key]['coach']='-'; } } } $data=array( 'pages' => $pages, 'dataList' => $dataList, 'province'=>$provinceList, 'acceptSchoolOpen'=>$acceptSchoolOpen, 'condition' =>$condition, ); return $this->render('list', $data); } public function actionSearchSchool(){ $provinceId = (int)Req::post('province_id'); $cityId = (int)Req::post('city_id'); $areaId = (int)Req::post('area_id'); $schoolName = Req::post('school_name'); $page = (int)Req::post('page'); if(!$page) $page=1; $where = array(); if ($schoolName) { $where[]= " school_name like '%".$schoolName."%' "; }else{ if ($provinceId) { $where[]= " province_id='{$provinceId}'"; } if ($cityId) { $where[]= " city_id='{$cityId}'"; } if ($areaId) { $where[]= " area_id='{$areaId}'"; } } $whiteList=new AWhiteList(); $schoolIds=$whiteList->getAllSchoolIds(); // if($schoolIds){ // $where[]= " school_id not in(".implode(',',$schoolIds).")"; // } $where[]="client<>2 and status=0 "; $AList=new BusinessSchool(); // 学校列表 $totalCount = $AList->countSchool($where); $pageLimit=6; $pages['page']=$page; $pages['totalPage']=ceil($totalCount/$pageLimit); $pages['total']=$totalCount; $dataList=$AList->getList($where,$page,$pageLimit); $html=''; if($dataList){ $i=($page-1)*6+1; foreach ($dataList as $key => $val){ $province=BusinessRegion::model()->findByPk($val['province_id']); $city=BusinessRegion::model()->findByPk($val['city_id']); $area=BusinessRegion::model()->findByPk($val['area_id']); $html.=''; $html.=''.$i.''; $html.=''.$val['school_name'].''; if(isset($province->region_name)){ $html.=''.$province->region_name.''; }else{ $html.=''; } if(isset($city->region_name)){ $html.=''.$city->region_name.''; }else{ $html.=''; } if(isset($area->region_name)){ $html.=''.$area->region_name.''; }else{ $html.=''; } if(in_array($val['school_id'],$schoolIds)){ $html.='添加'; }else{ $html.='添加'; } $html.=''; $i++; } } $pageHtml=' "; $pageHtml.=" 共:".$totalCount."条"; $data=array( 'pages'=>$pageHtml, 'list'=>$html ); $return['status']=1; $return['msg']='读取'; $return['data']=$data; exit(json_encode($return)); } public function actionGetRegion(){ $parentId=(int)Req::post('parent_id'); $province=BusinessRegion::model()->findAll("parent_id=:pid",array(':pid'=>$parentId)); $html=''; if($province){ foreach ($province as $val){ $html.=''; } } $return['status']=1; $return['msg']='读取'; $return['data']=$html; exit(json_encode($return)); } //学校发送开启关闭 public function actionSwitch(){ $value=(int)Req::post('value'); $return['status']=0; $data=array( 'accept_school_open'=>$value, ); $rs=AssistSetting::model()->updateAssistSchoolSetting($data); if($rs){ $return['status']=1; $return['msg']='设置成功'; exit(json_encode($return)); }else{ $return['msg']='设置失败'; exit(json_encode($return)); } } //添加学校白名单 public function actionAddWhiteList(){ $school_id=(int)Req::post('school_id'); $school_name=Req::post('school_name'); $AList=new AWhiteList(); if($AList->addSchool($school_id,$school_name)){ $return['status']=1; $return['msg']='设置成功'; exit(json_encode($return)); }else{ $return['status']=0; $return['msg']='设置失败'; exit(json_encode($return)); } } //移除学校名单 public function actionRemove(){ $school_id=(int)Req::post('school_id'); if(!$school_id) { $return['status']=0; $return['msg']='学校id不能为空'; exit(json_encode($return)); } $AList=new AWhiteList(); if($AList->deleteAll('school_id=:sid',array(':sid'=>$school_id))){ $return['status']=1; $return['msg']='移除成功'; exit(json_encode($return)); }else{ $return['status']=0; $return['msg']='移除失败'; exit(json_encode($return)); } } }