You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
100 lines
4.1 KiB
100 lines
4.1 KiB
<?php
|
|
class Admin_TeacherController extends Ctrl_Admin{
|
|
public function indexAction(){
|
|
$CMO = new ClasssModel;
|
|
$class = $CMO->query('select * from class where type=1 and status=1');
|
|
$this->assign('class',$class);
|
|
//权限判断跳转
|
|
/*$tMsg = '';
|
|
switch($_SESSION['admin']['roles']){
|
|
case 5:$tMsg = '/admin_purchases/';break;
|
|
case 8:$tMsg = '/admin_overseer/';break;
|
|
case 10:$tMsg = '/admin_wages/';break;
|
|
default:$tMsg = '/admin_senior/';break;
|
|
}*/
|
|
}
|
|
public function classsaveAction(){
|
|
$p = $_REQUEST;
|
|
$content = empty($p['content'])?Tool_Fnc::ajaxMsg('请填写类别介绍'):$p['content'];
|
|
$title = empty($p['title'])?Tool_Fnc::ajaxMsg('请填写类别名称'):$p['title'];
|
|
$type = empty($p['type'])?Tool_Fnc::ajaxMsg('请填写公司介绍'):$p['type'];
|
|
$CMD = new ClasssModel;
|
|
if(!empty($id)){
|
|
$Data['id'] = $id;
|
|
}
|
|
$Data['type'] = $type;
|
|
$Data['title'] = $title;
|
|
$Data['content'] = $content;
|
|
$Data['created'] = date('Y-m-d h:i:s',time());
|
|
$Data['status'] = 1;
|
|
if(!$CMD->save($Data)){
|
|
Tool_Fnc::ajaxMsg('操作失败');
|
|
}
|
|
Tool_Fnc::ajaxMsg('操作成功',1);
|
|
}
|
|
public function classlistAction(){
|
|
$p = $_REQUEST;
|
|
$page = $p['page'];
|
|
$limit = $p['limit'];
|
|
$type = $p['type'];
|
|
$offset = ($page-1)*$limit;
|
|
$CMD = new ClasssModel;
|
|
$sql = "select * from class where type={$type} and status=1";
|
|
$count = $CMD->query($sql);
|
|
$sql = "select * from class where type={$type} and status=1 order by id desc limit {$offset},{$limit} ";
|
|
$data = $CMD->query($sql);
|
|
foreach ($data as $key => &$val){
|
|
$val['content'] = strip_tags($val['content']);
|
|
}
|
|
$return['code'] = 0;
|
|
$return['count'] = count($count);
|
|
$return['data'] = $data;
|
|
$return['msg'] = "成功";
|
|
echo json_encode($return);die;
|
|
}
|
|
public function teachersaveAction(){
|
|
$p = $_REQUEST;
|
|
$class = empty($p['class'])?Tool_Fnc::ajaxMsg('请选择教学板块'):$p['class'];
|
|
$name = empty($p['title'])?Tool_Fnc::ajaxMsg('请填写教师姓名'):$p['title'];
|
|
$img = empty($p['img'])?Tool_Fnc::ajaxMsg('请上传教师图片'):$p['img'];
|
|
$classtime = empty($p['classtime'])?Tool_Fnc::ajaxMsg('请选择上课时间'):$p['classtime'];
|
|
$experienced = empty($p['experienced'])?Tool_Fnc::ajaxMsg('请填写经历'):$p['experienced'];
|
|
$content = empty($p['content'])?Tool_Fnc::ajaxMsg('请填写教师介绍'):$p['content'];
|
|
$CMD = new TeacherModel;
|
|
if(!empty($id)){
|
|
$Data['id'] = $id;
|
|
}
|
|
$Data['class'] = $class;
|
|
$Data['name'] = $name;
|
|
$Data['img'] = $img;
|
|
$Data['classtime'] = $classtime;
|
|
$Data['experienced'] = $experienced;
|
|
$Data['content'] = $content;
|
|
$Data['created'] = date('Y-m-d h:i:s',time());
|
|
$Data['status'] = 1;
|
|
if(!$CMD->save($Data)){
|
|
Tool_Fnc::ajaxMsg('操作失败');
|
|
}
|
|
Tool_Fnc::ajaxMsg('操作成功',1);
|
|
}
|
|
public function teacherlistAction(){
|
|
$p = $_REQUEST;
|
|
$page = $p['page'];
|
|
$limit = $p['limit'];
|
|
$type = $p['type'];
|
|
$offset = ($page-1)*$limit;
|
|
$CMD = new TeacherModel;
|
|
$sql = "select class.title,teacher.* from teacher left join class on teacher.class=class.id where teacher.status=1";
|
|
$count = $CMD->query($sql);
|
|
$sql = "select class.title,teacher.* from teacher left join class on teacher.class=class.id where teacher.status=1 order by teacher.id desc limit {$offset},{$limit} ";
|
|
$data = $CMD->query($sql);
|
|
foreach ($data as $key => &$val){
|
|
$val['content'] = strip_tags($val['content']);
|
|
}
|
|
$return['code'] = 0;
|
|
$return['count'] = count($count);
|
|
$return['data'] = $data;
|
|
$return['msg'] = "成功";
|
|
echo json_encode($return);die;
|
|
}
|
|
}
|
|
|