ソースを参照

自动复制课程

lizhen_gitee 9 ヶ月 前
コミット
610240c241

+ 2 - 1
application/admin/controller/Lessonslot.php

@@ -177,10 +177,11 @@ class Lessonslot extends Backend
      * 复制本周的课程表
      */
     public function copyweek(){
+        exit;
         $starttime = strtotime('this week Monday'); // 获取本周一的时间戳
         $endtime   = $starttime + 86400*7;
 
-        $list = Db::name('lesson_slot')->where('is_show',1)->where('starttime','BETWEEN',[$starttime,$endtime])->select();
+        $list = Db::name('lesson_slot')->where('is_show',1)->where('starttime','BETWEEN',[$starttime,$endtime])->order('starttime asc')->select();
         if(empty($list)){
             $this->error('本周还没有课程表');
         }

+ 1 - 1
application/admin/view/lessonslot/index.html

@@ -17,7 +17,7 @@
                 <div class="widget-body no-padding">
                     <div id="toolbar" class="toolbar">
                         <a href="javascript:;" class="btn btn-primary btn-refresh" title="{:__('Refresh')}" ><i class="fa fa-refresh"></i> </a>
-                        <a class="btn btn-info btn-copyweek" href="javascript:;"><i class="fa"></i> 复制本周的课程表</a>
+                        <!--<a class="btn btn-info btn-copyweek" href="javascript:;"><i class="fa"></i> 复制本周的课程表</a>-->
                         <a href="javascript:;" class="btn btn-success btn-add {:$auth->check('lessonslot/add')?'':'hide'}" title="{:__('Add')}" ><i class="fa fa-plus"></i> {:__('Add')}</a>
                         <!--<a href="javascript:;" class="btn btn-success btn-edit btn-disabled disabled {:$auth->check('lessonslot/edit')?'':'hide'}" title="{:__('Edit')}" ><i class="fa fa-pencil"></i> {:__('Edit')}</a>
                         <a href="javascript:;" class="btn btn-danger btn-del btn-disabled disabled {:$auth->check('lessonslot/del')?'':'hide'}" title="{:__('Delete')}" ><i class="fa fa-trash"></i> {:__('Delete')}</a>

+ 49 - 0
application/index/controller/Plantask.php

@@ -435,6 +435,55 @@ class Plantask extends Controller
         }
     }
 
+    /**
+     * 复制本周的课程表
+     */
+    public function auto_slot_copyweek(){
+
+        $week = date('w');
+
+        if($week != 1){
+            exit;
+        }
+
+        //先查找 下周有没有数据
+        $starttime = strtotime('this week Monday') + 86400*7;
+        $endtime   = $starttime + 86400*7;
+        $check = Db::name('lesson_slot')->where('starttime','BETWEEN',[$starttime,$endtime])->find();
+        if($check){
+            echo '下周有数据了';
+            exit;
+        }
+
+        echo '准备复制';
+        //拿上周,复制到下周
+
+        $starttime = strtotime('this week Monday') - 86400*7; // 获取本周一的时间戳
+        $endtime   = $starttime + 86400*7;
+
+        $list = Db::name('lesson_slot')->where('is_show',1)->where('starttime','BETWEEN',[$starttime,$endtime])->order('starttime asc')->select();
+        if(empty($list)){
+            echo 'empty';
+            exit;
+        }
+
+        foreach($list as $key => &$val){
+            unset($val['id']);
+            $val['starttime'] = $val['starttime'] + 86400*14;
+            $val['endtime']   = $val['endtime'] + 86400*14;
+            $val['status'] = 0;
+            $val['notice_status'] = 0;
+            $val['finishtime'] = 0;
+            $val['cancel_reason'] = '';
+            $val['cancel_time'] = 0;
+        }
+
+        Db::name('lesson_slot')->insertAll($list);
+        echo '复制完成';
+
+        //$this->success('已复制到下周');
+    }
+
 /////////////////////////////////////////下面都是工具方法////////////////////////////////////////////////
 
     public function whatapp($receive_mobile,$template,$code,$parameters){

+ 2 - 2
public/assets/js/backend/lessonslot.js

@@ -73,9 +73,9 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             Table.api.bindevent(table);
 
             // 复制本周的课程表
-            $(document).on("click", ".btn-copyweek", function () {
+            /*$(document).on("click", ".btn-copyweek", function () {
                 Fast.api.ajax('lessonslot/copyweek','复制本周的课程表');
-            });
+            });*/
         },
         add: function () {
             Controller.api.bindevent();

+ 0 - 1
public/assets/js/backend/video.js

@@ -21,7 +21,6 @@ define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefin
             table.bootstrapTable({
                 url: $.fn.bootstrapTable.defaults.extend.index_url,
                 pk: 'id',
-                sortName: 'weigh',
                 columns: [
                     [
                         {checkbox: true},