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.
129 lines
5.2 KiB
129 lines
5.2 KiB
<?php
|
|
class Admin_ClassController 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 hotAction(){
|
|
$p = $_REQUEST;
|
|
$id = empty($p['id'])?Tool_Fnc::ajaxMsg('课程查询错误!'):$p['id'];
|
|
$hot = $p['hot'];
|
|
$updata['id'] = $id;
|
|
$updata['hot'] = $hot;
|
|
$CMD = new CurriculumModel;
|
|
if(!$CMD->save($updata)){
|
|
Tool_Fnc::ajaxMsg('操作失败');
|
|
}
|
|
Tool_Fnc::ajaxMsg('操作成功',1);
|
|
}
|
|
public function teacherAction(){
|
|
$p = $_REQUEST;
|
|
$class = $p['class'];
|
|
$TMO = new TeacherModel;
|
|
$teacher = $TMO->query("select * from teacher where class={$class} and status=1");
|
|
if(empty($teacher)){
|
|
Tool_Fnc::ajaxMsg('请先添加该课程教学讲师');
|
|
}
|
|
Tool_Fnc::ajaxMsg('查询成功',1,$teacher);
|
|
|
|
}
|
|
public function classsaveAction(){
|
|
$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'];
|
|
$money = empty($p['money'])?Tool_Fnc::ajaxMsg('请填写课程价格'):$p['money'];
|
|
$teacher = empty($p['teacher'])?Tool_Fnc::ajaxMsg('请选择教学老师'):$p['teacher'];
|
|
$discount_money = empty($p['discount_money'])?0:$p['discount_money'];
|
|
$real_money = $money-$discount_money;
|
|
$content = empty($p['content'])?Tool_Fnc::ajaxMsg('请填写教师介绍'):$p['content'];
|
|
$order = empty($p['order'])?0:$p['order'];
|
|
$CMD = new CurriculumModel;
|
|
if(!empty($id)){
|
|
$Data['id'] = $id;
|
|
}
|
|
$Data['class'] = $class;
|
|
$Data['title'] = $name;
|
|
$Data['img'] = $img;
|
|
$Data['money'] = $money;
|
|
$Data['teacher'] = $teacher;
|
|
$Data['discount_money'] = $discount_money;
|
|
$Data['real_money'] = $real_money;
|
|
$Data['content'] = $content;
|
|
$Data['order'] = $order;
|
|
$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'];
|
|
$offset = ($page-1)*$limit;
|
|
$CMD = new CurriculumModel;
|
|
$sql = "select * from curriculum where status=1";
|
|
$count = $CMD->query($sql);
|
|
$sql = "select teacher.name tname,class.title cname,curriculum.* from curriculum left join teacher on curriculum.teacher=teacher.id left join class on curriculum.class=class.id where curriculum.status=1 order by curriculum.order 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 orderlistAction(){
|
|
$p = $_REQUEST;
|
|
$page = $p['page'];
|
|
$limit = $p['limit'];
|
|
$offset = ($page-1)*$limit;
|
|
$CMD = new OrderModel;
|
|
$sql = "select * from `order`";
|
|
$count = $CMD->query($sql);
|
|
$sql = "select teacher.name AS tname,`order`.* from `order` left join teacher on `order`.teacher=teacher.id limit {$offset},{$limit} ";
|
|
$status = array('1'=>'未支付','2'=>'订单失败','3'=>'订单完成','4'=>'订单已退');
|
|
$data = $CMD->query($sql);
|
|
foreach ($data as $key => &$val){
|
|
$val['content'] = strip_tags($val['content']);
|
|
$val['status'] = $status[$val['status']];
|
|
}
|
|
$return['code'] = 0;
|
|
$return['count'] = count($count);
|
|
$return['data'] = $data;
|
|
$return['msg'] = "成功";
|
|
echo json_encode($return);die;
|
|
}
|
|
public function registerlistAction(){
|
|
$p = $_REQUEST;
|
|
$page = $p['page'];
|
|
$limit = $p['limit'];
|
|
$offset = ($page-1)*$limit;
|
|
$CMD = new OrderModel;
|
|
$sql = "select * from `appoint`";
|
|
$count = $CMD->query($sql);
|
|
$sql = "select curriculum.title AS cname,`appoint`.* from `appoint` left join curriculum on `appoint`.cid=curriculum.id 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;
|
|
}
|
|
}
|
|
|