Commit 9e34a849 authored by xiabin's avatar xiabin

Merge remote-tracking branch 'origin/dev' into dev

parents dfb37eb4 c7181066
...@@ -78,10 +78,15 @@ class ClassesController extends Controller ...@@ -78,10 +78,15 @@ class ClassesController extends Controller
switch ($check) { switch ($check) {
case Classes::STATUS_OK: case Classes::STATUS_OK:
$class->status = $check; $class->status = $check;
if ($class->save() && $msg) { $class->reason = '';
$user->role = User::ROLE_TEACHER;
if ($class->update() && $user->update() && $msg) {
$template = Yii::$app->params['classes.check.msg.ok']; $template = Yii::$app->params['classes.check.msg.ok'];
$sms->send($user->telephone, str_replace('{className}', $class->name, $template)); $sms->send($user->telephone, str_replace('{className}', $class->name, $template));
} }
Utils::ajaxResponse(true); Utils::ajaxResponse(true);
break; break;
...@@ -93,7 +98,9 @@ class ClassesController extends Controller ...@@ -93,7 +98,9 @@ class ClassesController extends Controller
} }
$class->status = $check; $class->status = $check;
if ($class->save() && $msg) { $class->reason = $reason;
if ($class->update() && $msg) {
$template = Yii::$app->params['classes.check.msg.failed']; $template = Yii::$app->params['classes.check.msg.failed'];
$sms->send($user->telephone, str_replace(['{className}', '{reason}'], [$class->name, $reason], $template)); $sms->send($user->telephone, str_replace(['{className}', '{reason}'], [$class->name, $reason], $template));
} }
...@@ -109,7 +116,9 @@ class ClassesController extends Controller ...@@ -109,7 +116,9 @@ class ClassesController extends Controller
} }
$class->status = $check; $class->status = $check;
if ($class->save() && $msg) { $class->reason = $reason;
if ($class->update() && $msg) {
$template = Yii::$app->params['classes.check.msg.locked']; $template = Yii::$app->params['classes.check.msg.locked'];
$sms->send($user->telephone, str_replace(['{className}', '{reason}'], [$class->name, $reason], $template)); $sms->send($user->telephone, str_replace(['{className}', '{reason}'], [$class->name, $reason], $template));
} }
......
...@@ -122,6 +122,7 @@ class CourseController extends Controller ...@@ -122,6 +122,7 @@ class CourseController extends Controller
} }
$course->status = $check; $course->status = $check;
$course->reason = '';
$courseware->status = $check; $courseware->status = $check;
if ($course->save() && $courseware->save() && $msg) { if ($course->save() && $courseware->save() && $msg) {
...@@ -140,6 +141,7 @@ class CourseController extends Controller ...@@ -140,6 +141,7 @@ class CourseController extends Controller
} }
$course->status = $check; $course->status = $check;
$course->reason = $reason;
$courseware->status = Courseware::STATUS_FAILED; $courseware->status = Courseware::STATUS_FAILED;
if ($course->save() && $courseware->save() && $msg) { if ($course->save() && $courseware->save() && $msg) {
...@@ -158,6 +160,7 @@ class CourseController extends Controller ...@@ -158,6 +160,7 @@ class CourseController extends Controller
} }
$course->status = $check; $course->status = $check;
$course->reason = $reason;
$courseware->status = Courseware::STATUS_LOCKED; $courseware->status = Courseware::STATUS_LOCKED;
if ($course->save() && $courseware->save() && $msg) { if ($course->save() && $courseware->save() && $msg) {
......
...@@ -99,11 +99,11 @@ $this->title = "课堂管理"; ...@@ -99,11 +99,11 @@ $this->title = "课堂管理";
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
$("button.CLASS_CHECK").click(function() { $("button.CLASS_CHECK").click(function() {
accessAction(this, 1, '确定要通过该课堂申请吗?', true); accessAction(this, 1, '确定要通过该课堂申请吗?', "已通过该课堂申请。", true);
}); });
$("button.CLASS_REFUSE").click(function() { $("button.CLASS_REFUSE").click(function() {
refuseAction(this, 2, "请输入拒绝原因!", "已拒绝课堂申请!", true); refuseAction(this, 2, "请输入拒绝原因!", "已拒绝该课堂申请!", true);
}); });
$("button.CLASS_LOCK").click(function() { $("button.CLASS_LOCK").click(function() {
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
* @var $pagination \yii\data\Pagination * @var $pagination \yii\data\Pagination
* @var $qiniu \common\components\Qiniu * @var $qiniu \common\components\Qiniu
*/ */
use common\libs\Utils;
use common\models\Course; use common\models\Course;
use yii\helpers\Html; use yii\helpers\Html;
use yii\helpers\Url; use yii\helpers\Url;
...@@ -38,7 +39,6 @@ $qiniu = \Yii::$app->qiniu; ...@@ -38,7 +39,6 @@ $qiniu = \Yii::$app->qiniu;
<li<?php if ($status == Course::STATUS_LOCKED) {?> class="active"<?php } ?>><a href="<?=Url::to(['course/index', 'status'=>Course::STATUS_LOCKED])?>"><i class="fa fa-lock"></i> 已锁定</a></li> <li<?php if ($status == Course::STATUS_LOCKED) {?> class="active"<?php } ?>><a href="<?=Url::to(['course/index', 'status'=>Course::STATUS_LOCKED])?>"><i class="fa fa-lock"></i> 已锁定</a></li>
</ul> </ul>
</div> </div>
<!-- /.box-body -->
</div> </div>
<?php if ($count > 0) { ?> <?php if ($count > 0) { ?>
...@@ -49,11 +49,11 @@ $qiniu = \Yii::$app->qiniu; ...@@ -49,11 +49,11 @@ $qiniu = \Yii::$app->qiniu;
<tr role="row"> <tr role="row">
<th>课程ID</th> <th>课程ID</th>
<th colspan="2">视频</th> <th colspan="2">视频</th>
<th>时长/秒</th> <th>时长</th>
<th>文件大小</th> <th>文件大小</th>
<th>原始格式</th> <th>原始格式</th>
<th>价格/元</th> <th>价格/元</th>
<th>免费试看/分钟</th> <th>免费试看</th>
<th>ACTION</th> <th>ACTION</th>
</tr> </tr>
</thead> </thead>
...@@ -63,11 +63,11 @@ $qiniu = \Yii::$app->qiniu; ...@@ -63,11 +63,11 @@ $qiniu = \Yii::$app->qiniu;
<td class="sorting_1"><?=$course['id']?></td> <td class="sorting_1"><?=$course['id']?></td>
<td width="110"><a href="<?=$qiniu->getUrl('public', $course['preview_pic'])?>-m.preview" target="_blank"><img src="<?=$qiniu->getUrl('public', $course['preview_pic'])?>-s.preview" height="50"></a></td> <td width="110"><a href="<?=$qiniu->getUrl('public', $course['preview_pic'])?>-m.preview" target="_blank"><img src="<?=$qiniu->getUrl('public', $course['preview_pic'])?>-s.preview" height="50"></a></td>
<td><a href="#"><?=Html::encode($course['name'])?></a><span class="help-block"><?=date('Y-m-d H:i:s', $course['created_at'])?></span></td> <td><a href="#"><?=Html::encode($course['name'])?></a><span class="help-block"><?=date('Y-m-d H:i:s', $course['created_at'])?></span></td>
<td><?=$course['courseware']['time']?></td> <td><?=Utils::humanSeconds($course['courseware']['time'])?></td>
<td><?=$course['courseware']['size']?></td> <td><?=Utils::byteConvert($course['courseware']['size'])?></td>
<td><?=$course['courseware']['format']?></td> <td><?=$course['courseware']['format']?></td>
<td><?=$course['price']?></td> <td><?=$course['price']?></td>
<td><?=$course['free_time']?></td> <td><?=($course['free_time'] ? $course['free_time'].'分钟' : '-')?></td>
<td> <td>
<a class="btn btn-info btn-xs COURSE_DETAIL" href="<?=Url::to(['course/detail', 'id'=>$course['id']])?>" target="_blank"><i class="fa fa-info"></i> 详情</a> <a class="btn btn-info btn-xs COURSE_DETAIL" href="<?=Url::to(['course/detail', 'id'=>$course['id']])?>" target="_blank"><i class="fa fa-info"></i> 详情</a>
<?php if ($course['status'] == Course::STATUS_OK) { ?> <?php if ($course['status'] == Course::STATUS_OK) { ?>
......
...@@ -207,6 +207,45 @@ class Utils ...@@ -207,6 +207,45 @@ class Utils
return $count; return $count;
} }
/**
* 将字节数转换为可读文件大小
*
* @param int $bytes
* @return string
*/
public static function byteConvert($bytes)
{
if ($bytes == 0)
return "0.00 B";
$s = array('B', 'KB', 'MB', 'GB', 'TB', 'PB');
$e = floor(log($bytes, 1024));
return round($bytes/pow(1024, $e), 2).' '.$s[$e];
}
/**
* 将秒数转换为自然时间
*
* @param int
* @return string
*/
public static function humanSeconds($tl)
{
$units = ['年'=>31536000, '月'=>2628000, '天'=>86400, '小时'=>3600, '分钟'=>60, '秒'=>1];
$str = '';
foreach ($units as $un => $it) {
if ($tl >= $it) {
$floor = floor($tl / $it);
$tl = fmod($tl, $it);
$str .= $floor.$un;
}
}
return $str;
}
/** /**
* @param $rootElementName * @param $rootElementName
* @param $ar * @param $ar
......
...@@ -18,6 +18,7 @@ use yii\db\ActiveRecord; ...@@ -18,6 +18,7 @@ use yii\db\ActiveRecord;
* @property string $intro * @property string $intro
* @property string $desc * @property string $desc
* @property integer $status * @property integer $status
* @property string $reason
* @property integer $created_at * @property integer $created_at
* @property integer $updated_at * @property integer $updated_at
*/ */
...@@ -65,7 +66,7 @@ class Classes extends ActiveRecord ...@@ -65,7 +66,7 @@ class Classes extends ActiveRecord
return [ return [
[['user_id', 'name', 'intro'], 'required'], [['user_id', 'name', 'intro'], 'required'],
[['user_id', 'status'], 'integer'], [['user_id', 'status'], 'integer'],
[['intro', 'desc'], 'string'], [['intro', 'desc', 'reason'], 'string'],
[['name'], 'string', 'max' => 30], [['name'], 'string', 'max' => 30],
]; ];
} }
......
...@@ -22,6 +22,7 @@ use yii\redis\ActiveRecord; ...@@ -22,6 +22,7 @@ use yii\redis\ActiveRecord;
* @property string $preview_pic * @property string $preview_pic
* @property integer $recommend * @property integer $recommend
* @property integer $status * @property integer $status
* @property string $reason
* @property integer $play_count * @property integer $play_count
* @property integer $comment_count * @property integer $comment_count
* @property integer $favorite_count * @property integer $favorite_count
...@@ -85,7 +86,7 @@ class Course extends \yii\db\ActiveRecord ...@@ -85,7 +86,7 @@ class Course extends \yii\db\ActiveRecord
[['name', 'preview_pic'], 'required'], [['name', 'preview_pic'], 'required'],
['name', 'string', 'length' => [1, 60]], ['name', 'string', 'length' => [1, 60]],
[['user_id', 'class_id'], 'integer'], [['user_id', 'class_id'], 'integer'],
['intro', 'string'], [['intro', 'reason'], 'string'],
[['price'], 'number'], [['price'], 'number'],
['free_time', 'integer', 'min' => 0, 'max' => 15], ['free_time', 'integer', 'min' => 0, 'max' => 15],
['recommend', 'boolean'], ['recommend', 'boolean'],
......
...@@ -23,6 +23,7 @@ class m160927_115114_classes_init extends Migration ...@@ -23,6 +23,7 @@ class m160927_115114_classes_init extends Migration
'intro' => $this->text()->notNull(), 'intro' => $this->text()->notNull(),
'desc' => $this->text()->notNull()->comment('案例资源'), 'desc' => $this->text()->notNull()->comment('案例资源'),
'status' => $this->smallInteger()->notNull()->defaultValue(0)->comment('0 未审核 1 审核通过 2 审核不通过 3 锁定 '), 'status' => $this->smallInteger()->notNull()->defaultValue(0)->comment('0 未审核 1 审核通过 2 审核不通过 3 锁定 '),
'reason' => $this->string(128)->notNull()->comment('未审核通过时的原因'),
'created_at' => $this->integer()->notNull(), 'created_at' => $this->integer()->notNull(),
'updated_at' => $this->integer()->notNull(), 'updated_at' => $this->integer()->notNull(),
], $tableOptions); ], $tableOptions);
......
...@@ -22,8 +22,9 @@ class m160927_121107_course_init extends Migration ...@@ -22,8 +22,9 @@ class m160927_121107_course_init extends Migration
'price' => $this->decimal(6,2)->unsigned()->notNull()->defaultValue(0), 'price' => $this->decimal(6,2)->unsigned()->notNull()->defaultValue(0),
'free_time' => $this->integer(10)->notNull()->defaultValue(0), 'free_time' => $this->integer(10)->notNull()->defaultValue(0),
'intro' => $this->text()->notNull(), 'intro' => $this->text()->notNull(),
'preview_pic' => $this->string(255)->notNull(), 'preview_pic' => $this->string(200)->notNull(),
'recommend' => $this->smallInteger()->notNull()->defaultValue(0)->comment('0 表示推荐 1推荐'), 'recommend' => $this->smallInteger()->notNull()->defaultValue(0)->comment('0 表示推荐 1推荐'),
'reason' => $this->string(128)->notNull()->comment('未审核通过时的原因'),
'status' => $this->smallInteger()->notNull()->defaultValue(0)->comment('0 未审核 1 审核通过 2 审核不通过 3 锁定 '), 'status' => $this->smallInteger()->notNull()->defaultValue(0)->comment('0 未审核 1 审核通过 2 审核不通过 3 锁定 '),
'play_count' => $this->integer(10)->unsigned()->notNull()->defaultValue(0)->comment('播放次数'), 'play_count' => $this->integer(10)->unsigned()->notNull()->defaultValue(0)->comment('播放次数'),
'comment_count' => $this->integer(8)->unsigned()->notNull()->defaultValue(0)->comment('评论次数'), 'comment_count' => $this->integer(8)->unsigned()->notNull()->defaultValue(0)->comment('评论次数'),
......
...@@ -56,6 +56,9 @@ class ClassesFilter extends ActionFilter ...@@ -56,6 +56,9 @@ class ClassesFilter extends ActionFilter
case Classes::STATUS_LOCKED: case Classes::STATUS_LOCKED:
Utils::showWarn('课堂被锁定无法访问!'); Utils::showWarn('课堂被锁定无法访问!');
break; break;
case Classes::STATUS_FAILED:
Utils::showWarn('您提交的课堂资料未能通过审核!');
break;
default: default:
Utils::showWarn('您提交的课堂资料尚未通过审核,无法访问此页面!'); Utils::showWarn('您提交的课堂资料尚未通过审核,无法访问此页面!');
} }
......
...@@ -58,7 +58,7 @@ class MyCourseController extends \yii\web\Controller ...@@ -58,7 +58,7 @@ class MyCourseController extends \yii\web\Controller
public function actionIndex() public function actionIndex()
{ {
$list = Course::getCourseListsByClassId($this->classStatus['id'], null, 12, null); $list = Course::getCourseListsByClassId($this->classStatus['id'], null, 12, null);
return $this->render('index', ['list'=>$list['data'], 'pagination'=>$list['pagination']]); return $this->render('index', ['count'=>$list['count'], 'list'=>$list['data'], 'pagination'=>$list['pagination']]);
} }
/** /**
......
...@@ -26,6 +26,7 @@ $this->registerJs($js); ...@@ -26,6 +26,7 @@ $this->registerJs($js);
*/ */
$qiniu = \Yii::$app->qiniu; $qiniu = \Yii::$app->qiniu;
?> ?>
<?php if ($count > 0) { ?>
<div class="cls-list-box clearfix"> <div class="cls-list-box clearfix">
<?php foreach ($list as $course) { ?> <?php foreach ($list as $course) { ?>
<div class="col-md-4"> <div class="col-md-4">
...@@ -105,11 +106,11 @@ $qiniu = \Yii::$app->qiniu; ...@@ -105,11 +106,11 @@ $qiniu = \Yii::$app->qiniu;
</div> </div>
<?php } ?> <?php } ?>
</div> </div>
<div class="text-center"> <div class="text-center">
<?= LinkPager::widget(['pagination' => $pagination]) ?> <?= LinkPager::widget(['pagination' => $pagination]) ?>
</div> </div>
<?php } else { ?>
<div class="empty-data">您还没有添加课程!</div>
<?php } ?>
\ No newline at end of file
...@@ -37,6 +37,7 @@ AppAsset::addScript($this, '@web/assets/my_income.js'); ...@@ -37,6 +37,7 @@ AppAsset::addScript($this, '@web/assets/my_income.js');
</div> </div>
</div> </div>
<?php if ($count > 0) { ?>
<div class="con-md-12"> <div class="con-md-12">
<div class="table-responsive table-box"> <div class="table-responsive table-box">
<table class="table table-hover"> <table class="table table-hover">
...@@ -70,4 +71,6 @@ AppAsset::addScript($this, '@web/assets/my_income.js'); ...@@ -70,4 +71,6 @@ AppAsset::addScript($this, '@web/assets/my_income.js');
</div> </div>
</div> </div>
</div> </div>
<?php } else { ?>
<div class="empty-data" style="margin-top:80px;">您还没有卖出课程的记录!</div>
<?php } ?>
\ No newline at end of file
...@@ -26,6 +26,7 @@ $this->title = '我的会员'; ...@@ -26,6 +26,7 @@ $this->title = '我的会员';
</div> </div>
</div> </div>
<?php if ($count > 0) { ?>
<div class="con-md-12"> <div class="con-md-12">
<div class="table-responsive table-box"> <div class="table-responsive table-box">
<table class="table table-hover"> <table class="table table-hover">
...@@ -60,3 +61,6 @@ $this->title = '我的会员'; ...@@ -60,3 +61,6 @@ $this->title = '我的会员';
</div> </div>
</div> </div>
</div> </div>
<?php } else { ?>
<div class="empty-data" style="margin-top:80px;">您还没有会员!</div>
<?php } ?>
\ No newline at end of file
...@@ -14,8 +14,8 @@ AppAsset::addScript($this, '@web/assets/teacher_manager.js'); ...@@ -14,8 +14,8 @@ AppAsset::addScript($this, '@web/assets/teacher_manager.js');
<img src="<?=\common\models\User::getAvatarUrl($row['avatar'])?>"> <img src="<?=\common\models\User::getAvatarUrl($row['avatar'])?>">
<h3><?=$row['name']?></h3> <h3><?=$row['name']?></h3>
<p><?=$row['intro']?></p> <p><?=$row['intro']?></p>
<a class="edit" href="<?=\yii\helpers\Url::to(['teacher-manager/edit', 'id'=>$row['id']])?>"><i class="icon-mode_edit"></i></a> <a class="edit" href="<?=\yii\helpers\Url::to(['teacher-manager/edit', 'id'=>$row['id']])?>" title="编辑讲师信息"><i class="icon-mode_edit"></i></a>
<a href="javascript:;" class="delete"><i class="icon-trash"></i></a> <a href="javascript:;" class="delete" title="删除该讲师"><i class="icon-trash"></i></a>
</div> </div>
</div> </div>
<?php } ?> <?php } ?>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment