|
@@ -0,0 +1,807 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+/**
|
|
|
+ * Created by PhpStorm.
|
|
|
+ * User: Ellisran
|
|
|
+ * Date: 2016/9/21
|
|
|
+ * Time: 16:05
|
|
|
+ */
|
|
|
+class AdminController extends DooController {
|
|
|
+
|
|
|
+ public $data;
|
|
|
+// public $appKey = '';
|
|
|
+// public $AppSecret = '';
|
|
|
+
|
|
|
+ function __construct() {
|
|
|
+ $this->data['rootUrl'] = Doo::conf()->APP_URL;
|
|
|
+ include ('./protected/controller/BaseController.php');
|
|
|
+ $this->base = new BaseController ();
|
|
|
+ $this->base->admin_init();
|
|
|
+// require_once (Doo::conf()->SITE_PATH . '/protected/class/video.php');
|
|
|
+// $video = new video ( );
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户登出
|
|
|
+ */
|
|
|
+ function admin_exit() {
|
|
|
+
|
|
|
+ setcookie ( "auth_main", "", time () + 3600 * 24, "/", COOKIE_WEB_SITE );
|
|
|
+
|
|
|
+ $this->render ( "admin-login", $this->data, TRUE);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 用户管理
|
|
|
+ */
|
|
|
+ public function userlist(){
|
|
|
+ Doo::loadModel('user');
|
|
|
+ Doo::loadModel('classuser');
|
|
|
+ $user = new User();
|
|
|
+ $class_user = new Classuser();
|
|
|
+ $totalArchive = $user->count();
|
|
|
+ if(isset($this->params['status'])){
|
|
|
+ $pager = new DooPager(Doo::conf()->APP_URL . "m/userlist/status/".$this->params['status']."/page", $totalArchive, 20, 10);
|
|
|
+ }else{
|
|
|
+ $pager = new DooPager(Doo::conf()->APP_URL . "m/userlist/page", $totalArchive, 20, 10);
|
|
|
+ }
|
|
|
+ if (isset($this->params['pindex']))
|
|
|
+ $pager->paginate(intval($this->params['pindex']));
|
|
|
+ else
|
|
|
+ $pager->paginate(1);
|
|
|
+ if ($pager->limit != ' -20,20')
|
|
|
+ if(isset($this->params['status'])){
|
|
|
+ $this->data['userlist'] = $user->getResultbysort($this->params['status'],$pager->limit);
|
|
|
+ $this->data['status'] = $this->params['status'];
|
|
|
+ }else{
|
|
|
+ $this->data['userlist'] = $user->getAllRow($pager->limit);
|
|
|
+ }
|
|
|
+ if(isset($this->data['userlist']) && !empty($this->data['userlist'])){
|
|
|
+ foreach($this->data['userlist'] as $k => $v){
|
|
|
+ $cnum = $class_user->getNumbyuserid($v['userid']);
|
|
|
+ $this->data['userlist'][$k]['cnum'] = $cnum;
|
|
|
+ $this->data['userlist'][$k]['allprice'] = $class_user->getAllpricebyid($v['userid']);
|
|
|
+ $idcard = strlen($v['idcard'])==15?substr_replace($v['idcard'],"******",2,6):(strlen($v['idcard'])==18?substr_replace($v['idcard'],"*********",3,9):"身份证位数不正常!");
|
|
|
+ $this->data['userlist'][$k]['idcard'] = $idcard;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $this->data['pager'] = $pager->output;
|
|
|
+ $this->data['user'] = TRUE;
|
|
|
+ $this->render ( "admin-userlist", $this->data, TRUE);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 搜索用户
|
|
|
+ */
|
|
|
+ public function userSearch(){
|
|
|
+ if(isset($_POST['search']) && !empty($_POST['search'])){
|
|
|
+ Doo::loadModel('user');
|
|
|
+ $user = new User();
|
|
|
+ if(is_numeric(trim($_POST['search'])) && strlen(trim($_POST['search'])) == 6){
|
|
|
+ $result = $user->getUserMsgbyidcard(trim($_POST['search']));
|
|
|
+ }else{
|
|
|
+ $result = $user->getUserMsgbySearch(trim($_POST['search']));
|
|
|
+ }
|
|
|
+ if(!empty($result)) {
|
|
|
+ $this->data['userinfo'] = $result;
|
|
|
+ Doo::loadModel('classuser');
|
|
|
+ $class_user = new Classuser();
|
|
|
+ $classlist = $class_user->getclassbyuserid($result['userid']);
|
|
|
+ if(!empty($classlist)){
|
|
|
+ $this->data['classlist'] = $classlist;
|
|
|
+ Doo::loadModel('ktclass');
|
|
|
+ $ktclass = new Ktclass();
|
|
|
+ foreach($classlist as $k => $v){
|
|
|
+ $bum = $class_user->getNumbyClassid($v['classid']);
|
|
|
+ $this->data['classlist'][$k]['bnum'] = $bum;
|
|
|
+ $classinfo = $ktclass->getRowbyId($v['classid']);
|
|
|
+ $hadbuy = $class_user->gethasbyuserandclass($result['userid'],$v['classid']);
|
|
|
+ $this->data['classlist'][$k]['user_progress'] = $this->getPersonProgress($classinfo,$hadbuy);
|
|
|
+ $this->data['classlist'][$k]['classname'] = $classinfo['classname'];
|
|
|
+ $this->data['classlist'][$k]['cnum'] = $classinfo['classnum'];
|
|
|
+ $this->data['classlist'][$k]['totalnum'] = sprintf('%.2f',$classinfo['classnum']*$classinfo['classtime']/60);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $this->data['search'] = $_POST['search'];
|
|
|
+ }
|
|
|
+ $this->render('admin-usersearch', $this->data, TRUE);
|
|
|
+ }else{
|
|
|
+ return '/m/userlist';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 继续教育管理
|
|
|
+ */
|
|
|
+ public function classlist(){
|
|
|
+ Doo::loadModel('ktclass');
|
|
|
+ Doo::loadModel('classuser');
|
|
|
+ Doo::loadHelper('DooPager');
|
|
|
+ $ktclass = new Ktclass();
|
|
|
+ $class_user = new Classuser();
|
|
|
+ $totalArchive = $ktclass->count();
|
|
|
+ $pager = new DooPager(Doo::conf()->APP_URL . "m/classlist/page", $totalArchive, 8, 10);
|
|
|
+ if (isset($this->params['pindex']))
|
|
|
+ $pager->paginate(intval($this->params['pindex']));
|
|
|
+ else
|
|
|
+ $pager->paginate(1);
|
|
|
+ if ($pager->limit != ' -8,8')
|
|
|
+ $this->data['classlist'] = $ktclass->getclasslist($pager->limit);
|
|
|
+ foreach($this->data['classlist'] as $k => $v){
|
|
|
+ $bum = $class_user->getNumbyClassid($v['classid']);
|
|
|
+ $this->data['classlist'][$k]['bnum'] = $bum;
|
|
|
+
|
|
|
+ }
|
|
|
+ $this->data['pager'] = $pager->output;
|
|
|
+ $this->data['jiaoyu'] = TRUE;
|
|
|
+ $this->render ( "admin-classlist", $this->data, TRUE);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 课程进度
|
|
|
+ */
|
|
|
+ public function tracklist(){
|
|
|
+ Doo::loadModel('ktclass');
|
|
|
+ Doo::loadModel('classuser');
|
|
|
+ Doo::loadHelper('DooPager');
|
|
|
+ $ktclass = new Ktclass();
|
|
|
+ $class_user = new Classuser();
|
|
|
+ $totalArchive = $ktclass->count(array('where' => 'ishow=1'));
|
|
|
+ $pager = new DooPager(Doo::conf()->APP_URL . "m/tracklist/page", $totalArchive, 8, 10);
|
|
|
+ if (isset($this->params['pindex']))
|
|
|
+ $pager->paginate(intval($this->params['pindex']));
|
|
|
+ else
|
|
|
+ $pager->paginate(1);
|
|
|
+ if ($pager->limit != ' -8,8')
|
|
|
+ $this->data['classlist'] = $ktclass->getclasslistbyshow($pager->limit);
|
|
|
+ foreach($this->data['classlist'] as $k => $v){
|
|
|
+ $bum = $class_user->getNumbyClassid($v['classid']);
|
|
|
+ $this->data['classlist'][$k]['bnum'] = $bum;
|
|
|
+ $this->data['classlist'][$k]['totalnum'] = sprintf('%.2f',$v['classnum']*$v['classtime']/60);
|
|
|
+ $this->data['classlist'][$k]['class_progress'] = $this->getClassProgress($v['classid'],$this->data['classlist'][$k]['totalnum'],$bum);
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->data['pager'] = $pager->output;
|
|
|
+ $this->data['kecheng'] = TRUE;
|
|
|
+ $this->render ( "admin-classtracklist", $this->data, TRUE);
|
|
|
+ }
|
|
|
+
|
|
|
+ public function trackInfo(){
|
|
|
+ Doo::loadModel('ktclass');
|
|
|
+ Doo::loadModel('user');
|
|
|
+ Doo::loadModel('classuser');
|
|
|
+ Doo::loadHelper('DooPager');
|
|
|
+ $ktclass = new Ktclass();
|
|
|
+ $class_user = new Classuser();
|
|
|
+ $user = new User();
|
|
|
+ $class = $ktclass->getRowbyId($this->params['classid']);
|
|
|
+ $this->data['totalnum'] = sprintf("%.2f", $class['classnum']*$class['classtime']/60);
|
|
|
+ $this->data['classname'] = $ktclass->getnamebyId($this->params['classid'])['classname'];
|
|
|
+ $this->data['classid'] = $this->params['classid'];
|
|
|
+ $totalArchive = $class_user->getNumbyClassid($this->params['classid']);
|
|
|
+ if(isset($this->params['sort'])){
|
|
|
+ $pager = new DooPager(Doo::conf()->APP_URL . "m/trackinfo/".$this->params['classid']."/sort/".$this->params['sort']."/page", $totalArchive, 20, 10);
|
|
|
+ }else{
|
|
|
+ $pager = new DooPager(Doo::conf()->APP_URL . "m/trackinfo/".$this->params['classid']."/page", $totalArchive, 20, 10);
|
|
|
+ }
|
|
|
+ if (isset($this->params['pindex']))
|
|
|
+ $pager->paginate(intval($this->params['pindex']));
|
|
|
+ else
|
|
|
+ $pager->paginate(1);
|
|
|
+ if ($pager->limit != ' -20,20'){
|
|
|
+ if(isset($this->params['sort'])){
|
|
|
+ $this->data['userlist'] = $class_user->getuserlist2($this->params['classid'],$pager->limit,$this->params['sort']);
|
|
|
+ $this->data['sort'] = $this->params['sort'];
|
|
|
+ }else{
|
|
|
+ $this->data['userlist'] = $class_user->getuserlist($this->params['classid'],$pager->limit);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(isset($this->data['userlist'])){
|
|
|
+ foreach($this->data['userlist'] as $k => $v){
|
|
|
+ $this->data['userlist'][$k]['username'] = $user->getNamebyId($v['userid'])['username'];
|
|
|
+ $hadbuy = $class_user->gethasbyuserandclass($v['userid'],$this->params['classid']);
|
|
|
+ $this->data['userlist'][$k]['user_progress'] = $this->getPersonProgress($class,$hadbuy);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $this->data['pager'] = $pager->output;
|
|
|
+ $this->render('admin-classtrack', $this->data, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ //进度课程搜索
|
|
|
+ public function trackSearch(){
|
|
|
+ if(isset($_POST['search']) && !empty($_POST['search'])){
|
|
|
+ Doo::loadModel('ktclass');
|
|
|
+ Doo::loadModel('classuser');
|
|
|
+ $ktclass = new Ktclass();
|
|
|
+ $class_user = new Classuser();
|
|
|
+ $this->data['classlist'] = $ktclass->getclassbySearch($_POST['search']);
|
|
|
+ if(!empty($this->data['classlist'])){
|
|
|
+ foreach($this->data['classlist'] as $k => $v){
|
|
|
+ $bum = $class_user->getNumbyClassid($v['classid']);
|
|
|
+ $this->data['classlist'][$k]['bnum'] = $bum;
|
|
|
+ $this->data['classlist'][$k]['totalnum'] = $v['classnum']*($v['classtime']/60);
|
|
|
+ $this->data['classlist'][$k]['class_progress'] = $this->getClassProgress($v['classid'],$this->data['classlist'][$k]['totalnum'],$bum);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ $this->data['searchResult'] = $_POST['search'];
|
|
|
+ }
|
|
|
+ $this->data['kecheng'] = TRUE;
|
|
|
+ $this->render ( "admin-classtracklist", $this->data, TRUE);
|
|
|
+ }else{
|
|
|
+ return '/m/tracklist';
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 订单列表
|
|
|
+ */
|
|
|
+ public function orderlist(){
|
|
|
+ Doo::loadModel('order');
|
|
|
+ Doo::loadHelper('DooPager');
|
|
|
+ $ktorder = new Order();
|
|
|
+ if(isset($this->params['search']) && !empty($this->params['search']) && !isset($this->params['status'])){
|
|
|
+ $search = urldecode(trim($this->params['search']));
|
|
|
+ $totalArchive = $ktorder->count(array('where' => 'trade_sn=? or username=? or useremail=? or mobile=? or classname=?', 'param' => array($search,$search,$search,$search,$search), 'asArray' => TRUE));
|
|
|
+ $pager = new DooPager(Doo::conf()->APP_URL . "m/orderinfo/result/".$search."/page", $totalArchive, 20, 10);
|
|
|
+ if (isset($this->params['pindex']))
|
|
|
+ $pager->paginate(intval($this->params['pindex']));
|
|
|
+ else
|
|
|
+ $pager->paginate(1);
|
|
|
+ if ($pager->limit != ' -20,20')
|
|
|
+ $this->data['orderlist'] = $ktorder->getorderlistbySearch($search, $pager->limit);
|
|
|
+ $this->data['search'] = $search;
|
|
|
+ }elseif(isset($this->params['search']) && !empty($this->params['search']) && isset($this->params['status']) && !empty($this->params['status'])){
|
|
|
+ $search = urldecode(trim($this->params['search']));
|
|
|
+ $totalArchive = $ktorder->count(array('where' => '(trade_sn=? or username=? or useremail=? or mobile=? or classname=?) and status=?', 'param' => array($search,$search,$search,$search,$search,$this->params['status']), 'asArray' => TRUE));
|
|
|
+
|
|
|
+ $pager = new DooPager(Doo::conf()->APP_URL . "m/orderinfo/status/".$this->params['status']."/result/".$search."/page", $totalArchive, 20, 10);
|
|
|
+ if (isset($this->params['pindex']))
|
|
|
+ $pager->paginate(intval($this->params['pindex']));
|
|
|
+ else
|
|
|
+ $pager->paginate(1);
|
|
|
+ if ($pager->limit != ' -20,20')
|
|
|
+ $this->data['orderlist'] = $ktorder->getorderlistbySearch($search, $pager->limit, $this->params['status']);
|
|
|
+ $this->data['search'] = $search;
|
|
|
+ $this->data['status'] = $this->params['status'];
|
|
|
+ }elseif(isset($this->params['status']) && !empty($this->params['status']) && !isset($this->params['search'])){
|
|
|
+ $totalArchive = $ktorder->count(array('where' => 'status='.$this->params['status'], 'asArray' => TRUE));
|
|
|
+ $pager = new DooPager(Doo::conf()->APP_URL . "m/orderlist/status/".$this->params['status']."/page", $totalArchive, 20, 10);
|
|
|
+ if (isset($this->params['pindex']))
|
|
|
+ $pager->paginate(intval($this->params['pindex']));
|
|
|
+ else
|
|
|
+ $pager->paginate(1);
|
|
|
+ if ($pager->limit != ' -20,20')
|
|
|
+ $this->data['orderlist'] = $ktorder->getorderlist($pager->limit,$this->params['status']);
|
|
|
+ $this->data['status'] = $this->params['status'];
|
|
|
+ }else{
|
|
|
+ $totalArchive = $ktorder->count();
|
|
|
+ $pager = new DooPager(Doo::conf()->APP_URL . "m/orderlist/page", $totalArchive, 20, 10);
|
|
|
+ if (isset($this->params['pindex']))
|
|
|
+ $pager->paginate(intval($this->params['pindex']));
|
|
|
+ else
|
|
|
+ $pager->paginate(1);
|
|
|
+ if ($pager->limit != ' -20,20')
|
|
|
+ $this->data['orderlist'] = $ktorder->getorderlist($pager->limit);
|
|
|
+ }
|
|
|
+ if(isset($this->data['orderlist'])){
|
|
|
+ foreach($this->data['orderlist'] as $k => $v){
|
|
|
+ $this->data['orderlist'][$k]['createtime'] = date('Y-m-d H:i',$v['createtime']);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $this->data['pager'] = $pager->output;
|
|
|
+ $this->data['order'] = TRUE;
|
|
|
+ $this->render ( "admin-orderlist", $this->data, TRUE);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发票列表
|
|
|
+ */
|
|
|
+ public function receiptlist(){
|
|
|
+ $this->data['order'] = TRUE;
|
|
|
+ $this->render ( "admin-receiptlist", $this->data, TRUE);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public function upload(){
|
|
|
+ $this->render('upload', $this->data, TRUE);
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加或编辑课程
|
|
|
+ public function editClass(){
|
|
|
+ if(isset($this->params['classid'])){
|
|
|
+ Doo::loadModel('ktclass');
|
|
|
+ $ktclass = new Ktclass();
|
|
|
+ $this->data['classinfo'] = $ktclass->getRowbyId($this->params['classid']);
|
|
|
+ $this->data['classinfo']['stoptime'] = date("Y-m-d",$this->data['classinfo']['stoptime']);
|
|
|
+ $this->data['edit'] = true;
|
|
|
+ }
|
|
|
+ $this->data['jiaoyu'] = TRUE;
|
|
|
+ $this->render('admin-editclass', $this->data, true);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //添加和编辑课程
|
|
|
+ public function do_class(){
|
|
|
+
|
|
|
+ if(empty($_POST['classname'])){
|
|
|
+ exit('课程名不能为空');
|
|
|
+ }
|
|
|
+
|
|
|
+ if(empty($_POST['price'])){
|
|
|
+ exit('价格不能为空');
|
|
|
+ }
|
|
|
+
|
|
|
+ if(empty($_POST['totalnum'])){
|
|
|
+ exit('总课时不能为空');
|
|
|
+ }
|
|
|
+
|
|
|
+ if(empty($_POST['classtime'])){
|
|
|
+ exit('课程时长不能为空');
|
|
|
+ }
|
|
|
+
|
|
|
+ if(empty($_POST['stoptime'])){
|
|
|
+ exit('截止日期不能为空');
|
|
|
+ }
|
|
|
+
|
|
|
+ if(empty($_POST['desc'])){
|
|
|
+ exit('简介不能为空');
|
|
|
+ }
|
|
|
+
|
|
|
+ $price = $_POST['price'];
|
|
|
+ $name = $_POST['classname'];
|
|
|
+ $totalnum = $_POST['totalnum'];
|
|
|
+ $classtime = $_POST['classtime'];
|
|
|
+ $stop = strtotime($_POST['stoptime']);
|
|
|
+ $desc = $_POST['desc'];
|
|
|
+ if(!empty($_POST['createtime'])){
|
|
|
+ $createTime = $_POST['createtime'];
|
|
|
+ }else{
|
|
|
+ $createTime = time();
|
|
|
+ }
|
|
|
+ var_dump($stop);
|
|
|
+
|
|
|
+ $avatar = '';
|
|
|
+ if(!empty($_FILES["avatar"]['name'])){
|
|
|
+ if ((($_FILES["avatar"]["type"] == "image/gif")
|
|
|
+ || ($_FILES["avatar"]["type"] == "image/jpeg")
|
|
|
+ || ($_FILES["avatar"]["type"] == "image/pjpeg")
|
|
|
+ || ($_FILES["avatar"]["type"] == "image/png"))
|
|
|
+ && ($_FILES["avatar"]["size"] < 1048576))
|
|
|
+ {
|
|
|
+ if ($_FILES["avatar"]["error"] > 0) {
|
|
|
+ echo "Return Code: " . $_FILES["avatar"]["error"];
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ include (DOO::conf()->SITE_PATH . 'protected/plugin/io.han.php');
|
|
|
+ $this->IoHandler = new IoHandler();
|
|
|
+
|
|
|
+ $filedir = $createTime;
|
|
|
+
|
|
|
+ //调用定义物理路径
|
|
|
+ $t=DOO::conf()->SITE_PATH."avatar/".$filedir;
|
|
|
+// $t='/opt/www/wenku/report/'.$filedir."/thumb";
|
|
|
+ $this->IoHandler->MakeDir($t);
|
|
|
+
|
|
|
+ $upload_dir = $t."/".$createTime.".png";
|
|
|
+ $k=move_uploaded_file($_FILES["avatar"]["tmp_name"], $upload_dir);
|
|
|
+ if($k) {
|
|
|
+ $avatar = 'avatar/'.$createTime.'/'.$createTime.".png";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ echo '预览图片文件过大或格式不对';
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }elseif(empty($_FILES["avatar"]['name']) && empty($_POST['hadavatar'])){
|
|
|
+ exit('请上传预览图');
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ Doo::loadModel('ktclass');
|
|
|
+ $ktclass = new Ktclass();
|
|
|
+ if(isset($_POST['classid']) && !empty($_POST['classid'])){
|
|
|
+ $ktclass->classid = $_POST['classid'];
|
|
|
+ $ktclass->classname = $name;
|
|
|
+ $ktclass->price = $price;
|
|
|
+ $ktclass->classnum = $totalnum;
|
|
|
+ $ktclass->classtime = $classtime;
|
|
|
+ $ktclass->stoptime = $stop;
|
|
|
+ $ktclass->description = $desc;
|
|
|
+ $ktclass->update();
|
|
|
+ }else{
|
|
|
+ $ktclass->classname = $name;
|
|
|
+ $ktclass->price = $price;
|
|
|
+ $ktclass->classnum = $totalnum;
|
|
|
+ $ktclass->classtime = $classtime;
|
|
|
+ $ktclass->stoptime = $stop;
|
|
|
+ $ktclass->description = $desc;
|
|
|
+ $ktclass->createtime = $createTime;
|
|
|
+ $ktclass->avatar = $avatar;
|
|
|
+ $ktclass->ishow = 0;
|
|
|
+ $ktclass->insert();
|
|
|
+ }
|
|
|
+ return '/m/classlist';
|
|
|
+ }
|
|
|
+
|
|
|
+ //发布课程
|
|
|
+ public function showOnline(){
|
|
|
+ if(isset($_POST['classid']) && !empty($_POST['classid'])){
|
|
|
+ Doo::loadModel('ktclass');
|
|
|
+ $ktclass = new Ktclass();
|
|
|
+ $ktclass->classid = $_POST['classid'];
|
|
|
+ $ktclass->ishow = 1;
|
|
|
+ $result = $ktclass->update();
|
|
|
+ if($result){
|
|
|
+ echo '1';
|
|
|
+ exit();
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ echo '0';
|
|
|
+ exit();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //课程详情页
|
|
|
+ public function classInfo(){
|
|
|
+ Doo::loadModel('ktclass');
|
|
|
+ Doo::loadModel('classuser');
|
|
|
+ Doo::loadModel('kttype');
|
|
|
+ $ktclass = new Ktclass();
|
|
|
+ $ktype = new Kttype();
|
|
|
+ $class_user = new Classuser();
|
|
|
+
|
|
|
+ $this->data['kttype'] = $ktype->getTypebyClassid($this->params['classid']);
|
|
|
+ foreach($this->data['kttype'] as $k => $v){
|
|
|
+ Doo::loadModel('ktsection');
|
|
|
+ $ktsection = new Ktsection();
|
|
|
+ $section = $ktsection->getSecbyTypeid($v['typeid']);
|
|
|
+ $this->data['kttype'][$k]['section'] = $section;
|
|
|
+ foreach($section as $sk => $sv){
|
|
|
+ Doo::loadModel('ktvideo');
|
|
|
+ $ktvideo = new Ktvideo();
|
|
|
+ $video = $ktvideo->getVideobySec($sv['seid']);
|
|
|
+ $this->data['kttype'][$k]['section'][$sk]['video'] = $video;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->data['bnum'] = $class_user->getNumbyClassid($this->params['classid']);
|
|
|
+ $this->data['classinfo'] = $ktclass->getRowbyId($this->params['classid']);
|
|
|
+ $this->data['jiaoyu'] = TRUE;
|
|
|
+ $this->render('admin-classinfo', $this->data, true);
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加课程里的章
|
|
|
+ public function addType(){
|
|
|
+// require_once (Doo::conf()->SITE_PATH . '/protected/class/video.php');
|
|
|
+// $video = new video ( );
|
|
|
+ $typeprefix = $_POST['typeprefix'];
|
|
|
+ $typeName = $_POST['typename'];
|
|
|
+ $classid = $_POST['classid'];
|
|
|
+ if($typeprefix == '' || $typeName == ''){
|
|
|
+ exit('请输入章号或章名!');
|
|
|
+ }
|
|
|
+// $data = $video->videoTypeCreate($typeName);
|
|
|
+// if($data['code'] == '200'){
|
|
|
+// $video_type_id = $data['ret']['typeId'];
|
|
|
+// }else{
|
|
|
+// exit('网易视频云 - 创建分类失败,请联系管理员');
|
|
|
+// }
|
|
|
+ Doo::loadModel('kttype');
|
|
|
+ $kttype = new Kttype();
|
|
|
+ $kttype->typeprefix = $typeprefix;
|
|
|
+ $kttype->typename = $typeName;
|
|
|
+// $kttype->video_typeid = $video_type_id;
|
|
|
+ $kttype->createtime = time();
|
|
|
+ $kttype->classid = $classid;
|
|
|
+ $kttype->insert();
|
|
|
+
|
|
|
+ return '/m/classinfo/'.$classid;
|
|
|
+ }
|
|
|
+
|
|
|
+ //编辑章
|
|
|
+ public function ExitType(){
|
|
|
+// require_once (Doo::conf()->SITE_PATH . '/protected/class/video.php');
|
|
|
+// $video = new video ( );
|
|
|
+ $typeprefix = $_POST['exprefix'];
|
|
|
+ $typeName = $_POST['typename'];
|
|
|
+ $classid = $_POST['classid'];
|
|
|
+ $typeid = $_POST['typeid'];
|
|
|
+// $wytypeid = $_POST['wytypeid'];
|
|
|
+ if($typeprefix == '' || $typeName == ''){
|
|
|
+ exit('请输入章号或章名!');
|
|
|
+ }
|
|
|
+
|
|
|
+// $data = $video->videoTypeUpdate($wytypeid, $typeName);
|
|
|
+// if($data['code'] == '200'){
|
|
|
+ Doo::loadModel('kttype');
|
|
|
+ $kttype = new Kttype();
|
|
|
+ $kttype->typeprefix = $typeprefix;
|
|
|
+ $kttype->typename = $typeName;
|
|
|
+ $kttype->typeid = $typeid;
|
|
|
+ $kttype->update();
|
|
|
+// }else{
|
|
|
+// exit('网易视频云 - 修改分类失败,请联系管理员');
|
|
|
+// }
|
|
|
+
|
|
|
+ return '/m/classinfo/'.$classid;
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除章
|
|
|
+ public function deleteType(){
|
|
|
+// require_once (Doo::conf()->SITE_PATH . '/protected/class/video.php');
|
|
|
+// $video = new video ( );
|
|
|
+ $classid = $this->params['classid'];
|
|
|
+ $typeid = $this->params['typeid'];
|
|
|
+ Doo::loadModel('kttype');
|
|
|
+ $kttype = new Kttype();
|
|
|
+// $wytype = $kttype->getwyidBytypeid($typeid);
|
|
|
+// $data = $video->videoTypeDelete($wytype['video_typeid']);
|
|
|
+// if($data['code'] == '200'){
|
|
|
+ $kttype->typeid = $typeid;
|
|
|
+ $kttype->delete();
|
|
|
+ Doo::loadModel('ktsection');
|
|
|
+ $ktsection = new Ktsection();
|
|
|
+ $section = $ktsection->getSecbyTypeid($typeid);
|
|
|
+ foreach($section as $k => $v){
|
|
|
+ $ktsection->seid = $v['seid'];
|
|
|
+ $ktsection->delete();
|
|
|
+ }
|
|
|
+// }else{
|
|
|
+// exit('网易视频云 - 删除分类失败,请联系管理员');
|
|
|
+// }
|
|
|
+ return '/m/classinfo/'.$classid;
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加章里的节
|
|
|
+ public function addSection(){
|
|
|
+ $seprefix = $_POST['seprefix'];
|
|
|
+ $seName = $_POST['sename'];
|
|
|
+ $typeid = $_POST['typeid'];
|
|
|
+ $classid = $_POST['classid'];
|
|
|
+ if($seprefix == '' || $seName == ''){
|
|
|
+ exit('请输入节号或节名!');
|
|
|
+ }
|
|
|
+ Doo::loadModel('ktsection');
|
|
|
+ $ktsection = new Ktsection();
|
|
|
+ $ktsection->seprefix = $seprefix;
|
|
|
+ $ktsection->sename = $seName;
|
|
|
+ $ktsection->createtime = time();
|
|
|
+ $ktsection->typeid = $typeid;
|
|
|
+ $ktsection->insert();
|
|
|
+
|
|
|
+ return '/m/classinfo/'.$classid;
|
|
|
+ }
|
|
|
+
|
|
|
+ public function exitSection(){
|
|
|
+ $seprefix = $_POST['seprefix'];
|
|
|
+ $seName = $_POST['sename'];
|
|
|
+ $ishow = $_POST['sectionshow'];
|
|
|
+ $seid = $_POST['seid'];
|
|
|
+ $classid = $_POST['classid'];
|
|
|
+ if($seprefix == '' || $seName == ''){
|
|
|
+ exit('请输入节号或节名!');
|
|
|
+ }
|
|
|
+ Doo::loadModel('ktsection');
|
|
|
+ $ktsection = new Ktsection();
|
|
|
+ $ktsection->seprefix = $seprefix;
|
|
|
+ $ktsection->sename = $seName;
|
|
|
+ $ktsection->ishow = $ishow;
|
|
|
+ $ktsection->seid = $seid;
|
|
|
+ $ktsection->update();
|
|
|
+
|
|
|
+ return '/m/classinfo/'.$classid;
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除节
|
|
|
+ public function deleteSection(){
|
|
|
+ $seid = $this->params['seid'];
|
|
|
+ $classid = $this->params['classid'];
|
|
|
+ Doo::loadModel('ktsection');
|
|
|
+ $ktsection = new Ktsection();
|
|
|
+ $ktsection->seid = $seid;
|
|
|
+ $ktsection->delete();
|
|
|
+ return '/m/classinfo/'.$classid;
|
|
|
+ }
|
|
|
+
|
|
|
+ //添加视频
|
|
|
+ public function addVideo(){
|
|
|
+ if(isset($_POST['videomsg']) && !empty($_POST['videomsg'])){
|
|
|
+ $videodata = $_POST['videomsg'];
|
|
|
+ require_once (Doo::conf()->SITE_PATH . '/protected/class/video.php');
|
|
|
+ $video = new video ( );
|
|
|
+ $result = $video->videoGet($videodata['wyvideoid']);
|
|
|
+ if($result['code'] == 200){
|
|
|
+ Doo::loadModel('ktvideo');
|
|
|
+ $ktvideo = new Ktvideo();
|
|
|
+ $ktvideo->videoname = basename($videodata['fileName'],".".substr(strrchr($videodata['fileName'], '.'), 1));//不带后缀的视频名
|
|
|
+ $ktvideo->objectname = $videodata['objectname'];
|
|
|
+ $ktvideo->wy_video_id = $videodata['wyvideoid'];
|
|
|
+ $ktvideo->classid = $videodata['classid'];
|
|
|
+ $ktvideo->typeid = $videodata['typeid'];
|
|
|
+ $ktvideo->seid = $videodata['seid'];
|
|
|
+ $ktvideo->type_video_id = 27143;
|
|
|
+ $ktvideo->file_time = $result['ret']['duration'];
|
|
|
+ $ktvideo->file_ext = $videodata['ext'];
|
|
|
+ $ktvideo->file_size = $videodata['size'];
|
|
|
+ $ktvideo->isshow = 0;
|
|
|
+ $ktvideo->addtime = time();
|
|
|
+ $res = $ktvideo->insert();
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ echo 0;
|
|
|
+ exit();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //修改视频
|
|
|
+ public function updateVideo(){
|
|
|
+ if(isset($_POST['videoId']) && !empty($_POST['videoId'])){
|
|
|
+ $videoid = $_POST['videoId'];
|
|
|
+ Doo::loadModel('ktvideo');
|
|
|
+ $ktvideo = new Ktvideo();
|
|
|
+ $wyvideo = $ktvideo->getvideobyid($videoid);
|
|
|
+ if(!empty($wyvideo)){
|
|
|
+ $ktvideo->videoid = $_POST['videoId'];
|
|
|
+ $ktvideo->videoname = $_POST['videoName'];
|
|
|
+ $ktvideo->isshow = $_POST['isshow'];
|
|
|
+ $ktvideo->update();
|
|
|
+
|
|
|
+ $section = $ktvideo->getsecbyid($_POST['videoId']);
|
|
|
+ $num = $ktvideo->count(array('where' => 'seid='.$section['seid'],'asArray'));
|
|
|
+ if($num == 1){
|
|
|
+ Doo::loadModel('ktsection');
|
|
|
+ $ktsection = new Ktsection();
|
|
|
+ if($_POST['isshow'] == 1){
|
|
|
+ $ktsection->ishow = 1;
|
|
|
+ }else{
|
|
|
+ $ktsection->ishow = 0;
|
|
|
+ }
|
|
|
+ $ktsection->seid = $section['seid'];
|
|
|
+ $ktsection->update();
|
|
|
+ }
|
|
|
+
|
|
|
+ require_once (Doo::conf()->SITE_PATH . '/protected/class/video.php');
|
|
|
+ $video = new video ( );
|
|
|
+ $result = $video->videoEdit($wyvideo['wy_video_id'],$_POST['videoName'].'.'.$wyvideo['file_ext'],$wyvideo['type_video_id']);
|
|
|
+ if($result['code'] == 200){
|
|
|
+ return '/m/classinfo/'.$_POST['classid'];
|
|
|
+ }else{
|
|
|
+ return '/m/classinfo/'.$_POST['classid'];
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return '/m/classinfo/'.$_POST['classid'];
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ return '/m/classinfo/'.$_POST['classid'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //发布视频
|
|
|
+ public function showVideo(){
|
|
|
+ $videoid = $this->params['videoid'];
|
|
|
+ $classid = $this->params['classid'];
|
|
|
+ Doo::loadModel('ktvideo');
|
|
|
+ $ktvideo = new Ktvideo();
|
|
|
+ $section = $ktvideo->getsecbyid($videoid);
|
|
|
+ $num = $ktvideo->count(array('where' => 'seid='.$section['seid'],'asArray'));
|
|
|
+ if($num == 1){
|
|
|
+ Doo::loadModel('ktsection');
|
|
|
+ $ktsection = new Ktsection();
|
|
|
+ $ktsection->ishow = 1;
|
|
|
+ $ktsection->seid = $section['seid'];
|
|
|
+ $ktsection->update();
|
|
|
+ }
|
|
|
+
|
|
|
+ $ktvideo->videoid = $videoid;
|
|
|
+ $ktvideo->isshow = 1;
|
|
|
+ $ktvideo->update();
|
|
|
+ return '/m/classinfo/'.$classid;
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断视频是否可以发布
|
|
|
+ public function isShowVideo(){
|
|
|
+ require_once (Doo::conf()->SITE_PATH . '/protected/class/video.php');
|
|
|
+ $video = new video ( );
|
|
|
+ $result = $video->videoGet($_GET['video']);
|
|
|
+ if($result['code'] == 200) {
|
|
|
+ if(empty($result['ret']['shdMp4Url'])){
|
|
|
+ echo '0';
|
|
|
+ exit;
|
|
|
+ }else{
|
|
|
+ echo '1';
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ echo '0';
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //删除视频
|
|
|
+ public function delVideo(){
|
|
|
+ $videoid = $this->params['videoid'];
|
|
|
+ $classid = $this->params['classid'];
|
|
|
+ Doo::loadModel('ktvideo');
|
|
|
+ $ktvideo = new Ktvideo();
|
|
|
+ $result = $ktvideo->getvideobyid($videoid);
|
|
|
+ if(!empty($result)) {
|
|
|
+ require_once(Doo::conf()->SITE_PATH . '/protected/class/video.php');
|
|
|
+ $video = new video ( );
|
|
|
+ $delvideo = $video->videoDetele($result['wy_video_id']);
|
|
|
+ $ktvideo->videoid = $videoid;
|
|
|
+ $ktvideo->delete();
|
|
|
+ }
|
|
|
+ return '/m/classinfo/'.$classid;
|
|
|
+ }
|
|
|
+
|
|
|
+ //播放转码后视频
|
|
|
+ public function playVideo(){
|
|
|
+ require_once (Doo::conf()->SITE_PATH . '/protected/class/video.php');
|
|
|
+ $video = new video ( );
|
|
|
+ if(isset($_GET['video'])){
|
|
|
+ $result = $video->videoGet($_GET['video']);
|
|
|
+ if($result['code'] == 200){
|
|
|
+ $play_url = !empty($result['ret']['shdMp4Url']) ? $result['ret']['shdMp4Url'] : '';
|
|
|
+ $play_type = substr(strrchr($play_url, '.'), 1);
|
|
|
+ if ($play_type == 'mp4'){
|
|
|
+ $type = 'video/mp4';
|
|
|
+ }else {
|
|
|
+ echo json_encode(array( 'code' => 400));
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+ echo json_encode(array( 'code' => 200, 'url' => $play_url, 'type' => $type));
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+ echo json_encode(array( 'code' => 400));
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+ echo json_encode(array( 'code' => 400));
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取个人的学习进度
|
|
|
+ private function getPersonProgress($class,$classuser){
|
|
|
+ $totalss = $class['classnum']*$class['classtime']*60; //课程总秒数
|
|
|
+ $userss = $classuser['seetime']; //已完成的秒数
|
|
|
+
|
|
|
+ $nodonehh = sprintf('%.2f',($totalss-$userss)/3600); //未完成的小时数
|
|
|
+ $donehh = sprintf('%.2f',$classuser['seetime']/3600); //已完成的小时数
|
|
|
+ $doneclassnum = intval($userss/($class['classtime']*60)); //已完成的课时数,取整
|
|
|
+ if($doneclassnum<10 && $doneclassnum != 0){
|
|
|
+ $doneclassnum = '0'.$doneclassnum;
|
|
|
+ }
|
|
|
+ $progress = sprintf('%.2f',$userss/$totalss) *100; //已完成占总课程的百分比showVideo
|
|
|
+ $noprogress = 100-$progress; //未完成占总课程的百分比
|
|
|
+ return array('progress' => $progress, 'noprogress' => $noprogress, 'donehh' => $donehh, 'doneclassnum' => $doneclassnum, 'nodonehh' => $nodonehh);
|
|
|
+ }
|
|
|
+
|
|
|
+ //获取课程的平均进度
|
|
|
+ private function getClassProgress($classid,$totalnum,$bnum){
|
|
|
+ if($bnum != 0){
|
|
|
+ Doo::loadModel('classuser');
|
|
|
+ $classuser = new Classuser();
|
|
|
+ $classtrack = $classuser->gettimebyClassid($classid);
|
|
|
+ $doness = 0;
|
|
|
+ foreach($classtrack as $k => $v){
|
|
|
+ $doness += $v['seetime']; //已完成的总秒数
|
|
|
+ }
|
|
|
+ $donehh = sprintf('%.2f',sprintf('%.2f',$doness/3600)/$bnum); //已完成的平均小时数
|
|
|
+ $nodonehh = $totalnum-$donehh; //未完成的小时数
|
|
|
+ $progress = sprintf('%.2f',$donehh/$totalnum) *100; //已完成占总课程的百分比
|
|
|
+ $noprogress = 100-$progress; //未完成占总课程的百分比
|
|
|
+ }else{
|
|
|
+ $progress = 0;
|
|
|
+ $noprogress = 100;
|
|
|
+ $donehh = 0;
|
|
|
+ $nodonehh = $totalnum;
|
|
|
+ }
|
|
|
+ return array('progress' => $progress, 'noprogress' => $noprogress, 'donehh' => $donehh, 'nodonehh' => $nodonehh);
|
|
|
+ }
|
|
|
+
|
|
|
+}
|