'status', 'name' => '审核状态', 'value' => array( 1 => '已审核', 3 => '未审核', 2 => '未通过', 4 => '已锁定' ) ); $this -> yunset('search_list', $search_list); } /** * 会员- 培训 - 培训师 * 2019-06-04 hjy */ public function index_action(){ $this->set_search(); $teWhereData = array(); $keywordStr = trim($_GET['keyword']); if(!empty($keywordStr)){ $teWhereData['name'] = array('like', $keywordStr); } //审核状态条件 if(!empty($_GET['status'])){ if ($_GET['status'] == 3){ $teWhereData['status'] = array('=', 0); $teWhereData['r_status'] = array('=', 1); }else if($_GET['status']==4){ $teWhereData['r_status'] = array('>', 1); }else{ $teWhereData['status'] = array('=', $_GET['status']); $teWhereData['r_status'] = array('=', 1); } } $urlarr = $_GET; $urlarr['page'] = "{{page}}"; $pageurl = Url($_GET['m'], $urlarr, 'admin'); //提取分页 $pageM = $this -> MODEL('page'); $pages = $pageM -> pageList('px_teacher', $teWhereData, $pageurl, $_GET['page']); //分页数大于0的情况下 执行列表查询 $List = array(); $pxM = $this -> MODEL('train'); if($pages['total'] > 0){ //limit order 只有在列表查询时才需要 if(!empty($_GET['order']) && !empty($_GET['t'])){ $teWhereData['orderby'] = $_GET['t'].','.$_GET['order']; }else{ $teWhereData['orderby'] = array('r_status,asc','status,asc', 'id,desc'); } $teWhereData['limit'] = $pages['limit']; $List = $pxM -> getTeaList($teWhereData); } if(!empty($List)){ $pxuid = array(); foreach($List as $lv){ $pxuid[] = $lv['uid']; } $bcWhereData = array('uid' => array('in', pylode(',',$pxuid))); //补充用户相关的信息 $pxField = '`uid`, `name` AS train_name'; $pxList = $pxM -> getList($bcWhereData, array('field' => $pxField)); $pxListIndex = array(); if(!empty($pxList)){ foreach ($pxList as $pxV) { $pxListIndex[$pxV['uid']] = $pxV; } } //补充进相关信息 foreach($List as $Lk => $Lv){ if(isset($pxListIndex[$Lv['uid']])){ $List[$Lk] = array_merge($List[$Lk], $pxListIndex[$Lv['uid']]); } } } $this -> yunset('rows', $List); $this -> yunset($this -> MODEL('cache') -> GetCache(array('city', 'hy', 'subject'))); $this -> yunset('get_type', $_GET); $this -> yuntpl(array('admin/admin_teacher')); } /** * 会员- 培训 - 培训师 * 审核信息 * 2019-06-05 hjy */ public function lockinfo_action(){ $pxM = $this -> MODEL('train'); $rows = $pxM -> getTeaInfo(array('id' => array('=', $_POST['id'])), array('field' => '`statusbody`')); echo $rows['statusbody'];die; } function teacherstatus_action() { if ($_POST) { $id = intval($_POST['tid']); $uid = intval($_POST['tuid']); $status = intval($_POST['r_status']); $statusbody = trim($_POST['statusbody']); $pxM = $this->MODEL('train'); $post = array( 'uid' => $uid, 'status' => $status==3 ? 2: 1 , 'statusbody' => $statusbody ); $return = $pxM -> statusTeacher($id, $post); $this -> ACT_layer_msg($return['msg'], $return['errcode'], $_SERVER['HTTP_REFERER'], 2, 1); } } /** * 会员- 培训 - 培训师 * 审核培训师 * 2019-06-05 hjy */ public function status_action(){ $postData = $this -> post_trim($_POST); $postData['id'] = trim($postData['id'], ','); if(empty($postData['id'])){ $this -> ACT_layer_msg('非法操作!', 9, $_SERVER['HTTP_REFERER']); } $pxM = $this -> MODEL('train'); $upData = array(); $upData['status'] = $postData['status']; $upData['statusbody'] = $postData['statusbody']; $upid = $pxM -> upTeaInfo(array('id' => array('in', $postData['id']),'r_status'=>1), $upData); $px_subj = $pxM -> getSubList(array('teachid' => array('in', $postData['id'],'r_status'=>1)), array('field' => '`uid`, `name`')); $TeaList = $pxM -> getTeaList(array('id' => array('in', $postData['id'],'r_status'=>1)), array('field' => '`uid`, `name`,`id`')); if(!empty($px_subj)){ if($postData['status'] != 1){ $pxM -> upSubInfo(array('teachid' => array('in', $postData['id'],'r_status'=>1), array('status' => $postData['status']))); } } if(!empty($TeaList)){ /* 消息前缀 */ $tagName = '培训师'; $sysmsgM = $this->MODEL('sysmsg'); foreach($TeaList as $v){ $uids[] = $v['uid']; /* 处理审核信息 */ if ($upData['status'] == 2){ $statusInfo = $tagName.':'.$v['name'].'审核未通过'; if($upData['statusbody']){ $statusInfo .= ' , 原因:'.$upData['statusbody']; } $msg[$v['uid']][] = $statusInfo; }elseif($upData['status'] == 1){ $msg[$v['uid']][] = $tagName.':'.$v['name'].'已审核通过'; } } $sysmsgM -> addInfo(array('uid'=> $uids,'usertype'=>4, 'content'=>$msg)); } if($upid){ $pxtecahwhere['id'] = array('in', $postData['id']); $pxtecahnum = $pxM->getPxTeacherNum($pxtecahwhere); if($pxtecahnum>1){ $pxtecahtwhere['id'] = array('in',$postData['id']); $pxtecahtwhere['r_status'] = 1; $pxtecahtnum = $pxM->getPxTeacherNum($pxtecahtwhere); $pxtecahwwhere['id'] = array('in',$postData['id']); $pxtecahwwhere['r_status'] = array('<>',1); $pxtecahwnum = $pxM->getPxTeacherNum($pxtecahwwhere); if($pxtecahwnum>0){ $msg='培训讲师批量审核成功'.$pxtecahtnum.'条,失败'.$pxtecahwnum.'条原因:培训账户未审核'; }else{ $msg='培训讲师批量审核成功(ID:'.$postData['id'].')'; } $this -> ACT_layer_msg($msg, 9, $_SERVER['HTTP_REFERER'], 2, 1); }else{ $pxwwhere['id'] = array('in',$postData['id']); $pxwwhere['r_status'] = array('<>',1); $pxtnum = $pxM->getPxTeacherNum($pxwwhere); if($pxtnum>0){ $this -> ACT_layer_msg('培训讲师审核(ID:'.$postData['id'].')失败,原因:培训账户未审核!', 8, $_SERVER['HTTP_REFERER']); }else{ $this -> ACT_layer_msg('培训讲师审核(ID:'.$postData['id'].')设置成功!', 9, $_SERVER['HTTP_REFERER'], 2, 1); } } }else{ $this->ACT_layer_msg('设置失败!', 8, $_SERVER['HTTP_REFERER']); } } /** * 会员- 培训 - 培训师 * 设置推荐 * 2019-06-05 hjy */ public function rec_action(){ $this->check_token(); $pxId = intval($_GET['id']); $pxRec = intval($_GET['rec']); $upData = array(); $upData['rec'] = $pxRec; $pxM = $this -> MODEL('train'); $whereData = array('id' => array('=', $pxId)); $info = $pxM -> getTeaInfo($whereData, array('field' => '`uid`, `name`')); if(empty($info)){ $this -> layer_msg('设置失败!', 8, 0, $_SERVER['HTTP_REFERER']); } $nid = $pxM -> upTeaInfo($whereData, $upData); $sysmsgM = $this -> MODEL('sysmsg'); if($nid && $pxRec == 1){ $sysmsgM -> addInfo(array('content' => '管理员设置:推荐培训师'.$info['name'],'usertype'=>4, 'uid' => $info['uid'])); }elseif($nid && $pxRec == 0){ $sysmsgM -> addInfo(array('content' => '管理员操作:取消培训师推荐'.$info['name'],'usertype'=>4, 'uid' => $info['uid'])); } $this -> MODEL('log') -> addAdminLog("培训师(ID:".$pxId.")推荐设置成功!"); echo $nid?1:0;die; } /** * 会员- 培训 - 培训师 * 修改培训师 * 2019-06-05 hjy */ public function add_action(){ $pxId = intval($_GET['id']); $pxM = $this -> MODEL('train'); if(!empty($pxId) && empty($_POST['update'])){ $row = $pxM -> getTeaInfo(array('id' => array('=', $pxId))); $this -> yunset("row", $row); $where['uid'] = $row['uid']; $trainfo = $pxM->getInfo($where,array('field'=>'`r_status`,`uid`')); $this -> yunset("trainfo", $trainfo); $this -> yunset($this -> MODEL('cache') -> GetCache(array('city', 'hy', 'subject'))); $this -> yuntpl(array('admin/admin_teacher_add')); } if(!empty($_POST['update'])){ $postData = $this -> post_trim($_POST); $id = intval($postData['id']); $teacher = $pxM -> getTeaInfo(array('id' => array('=', $id)), array('field' => '`pic`')); if(empty($teacher)){ $this->ACT_layer_msg('数据错误!', 8, 'index.php?m=teacher'); } unset($postData['id']); unset($postData['update']); $postData['file'] = $_FILES['file']; if($_POST['r_status']==1){ $postData['status'] = 1; }else{ $postData['status'] = 0; } $nid = $pxM -> upTeaInfo(array('id' => array('=', $id)), $postData); if($nid){ $this->ACT_layer_msg('更新成功!', 9, 'index.php?m=teacher'); }else{ $this->ACT_layer_msg('更新失败!', 8, 'index.php?m=teacher'); } } } /** * 会员- 培训 - 培训师 * 删除培训师 * 2019-06-05 hjy */ public function del_action(){ $del = $_GET['del']; $this -> check_token(); if(is_array($del)){ $layer_type = 1; $del = pylode(',', $del); }else{ $layer_type = 0; } if(empty($del)){ $this->layer_msg('请选择要删除的内容!', 8, 0, $_SERVER['HTTP_REFERER']); } $pxM = $this -> MODEL('train'); $list = $pxM -> getTeaList(array('id' => array('in', $del)), array('field' => '`uid`, `name`, `pic`')); if(!empty($list)){ $sysmsgM = $this -> MODEL('sysmsg'); $pxM -> delTea(array('id' => array('in', $del))); foreach($list as $v){ $sysmsgM -> addInfo(array('content' => '管理员操作:删除培训讲师《'.$v['name'].'》','usertype'=>4, 'uid' => $v['uid'])); } } $this->layer_msg('培训师(ID:'.$del.')删除成功!', 9, $layer_type, $_SERVER['HTTP_REFERER']); } /** * 会员- 培训 - 培训师 * 数据统计 * 2019-06-05 hjy */ public function teacherNum_action(){ $MsgNum = $this->MODEL('msgNum'); echo $MsgNum -> teacherNum(); } }