|
@@ -54,11 +54,21 @@ class Lessonslot extends Backend
|
|
|
}
|
|
|
list($where, $sort, $order, $offset, $limit) = $this->buildparams();
|
|
|
|
|
|
+ //按周翻页
|
|
|
+ $week_current = input('week_current','');
|
|
|
+ if($week_current !== ''){
|
|
|
+ $starttime = strtotime('this week Monday') + (86400*7*$week_current);
|
|
|
+ $endtime = $starttime + (86400*7);
|
|
|
+ $where = ['lessonslot.starttime'=>['between',[$starttime,$endtime]]];
|
|
|
+ $limit = 9999;
|
|
|
+ }
|
|
|
+
|
|
|
$list = $this->model
|
|
|
->with(['coach','lesson','danceroom'])
|
|
|
->where($where)
|
|
|
// ->order($sort, $order)
|
|
|
->order('lessonslot.starttime desc,lessonslot.id desc')
|
|
|
+// ->select(false);echo $list;exit;
|
|
|
->paginate($limit);
|
|
|
|
|
|
foreach ($list as $row) {
|
|
@@ -68,7 +78,26 @@ class Lessonslot extends Backend
|
|
|
$row->getRelation('danceroom')->visible(['name','name_en']);
|
|
|
}
|
|
|
|
|
|
- $result = array("total" => $list->total(), "rows" => $list->items());
|
|
|
+ $items = $list->items();
|
|
|
+ foreach($items as $key => $val){
|
|
|
+ $items[$key]['week'] = date('l',$val['starttime']);
|
|
|
+ }
|
|
|
+
|
|
|
+ //上-周,本周,下-周
|
|
|
+ if(empty($week_current)){$week_current = 0;}
|
|
|
+ $this_week = 'lessonslot/index/week_current/0';
|
|
|
+
|
|
|
+ $last_week = 'lessonslot/index/week_current/'.($week_current-1);
|
|
|
+
|
|
|
+ $next_week = 'lessonslot/index/week_current/'.($week_current+1);
|
|
|
+
|
|
|
+ $extend = [
|
|
|
+ 'this_week'=>$this_week,
|
|
|
+ 'last_week'=>$last_week,
|
|
|
+ 'next_week'=>$next_week,
|
|
|
+ ];
|
|
|
+
|
|
|
+ $result = array("total" => $list->total(), "rows" => $items,'extend'=>$extend);
|
|
|
|
|
|
return json($result);
|
|
|
}
|
|
@@ -589,9 +618,12 @@ class Lessonslot extends Backend
|
|
|
//课程新增
|
|
|
public function slot_add(){
|
|
|
$field = ['starttime','hours','num_min','num_max','waitnum_max','coach_ids','lesson_id','danceroom_id','address','remark','address_en','remark_en','is_show'];
|
|
|
- $require = ['starttime','hours','num_min','num_max','waitnum_max','coach_ids','lesson_id','danceroom_id','is_show'];
|
|
|
- $data = request_post_hub($field,$require);
|
|
|
+// $require = ['starttime','hours','num_min','num_max','waitnum_max','coach_ids','lesson_id','danceroom_id','is_show'];
|
|
|
+ $data = request_post_hub($field/*,$require*/);
|
|
|
|
|
|
+ if(empty($data['starttime'])){
|
|
|
+ $data['starttime'] = time();
|
|
|
+ }
|
|
|
$data['endtime'] = $data['starttime'] + ($data['hours'] * 3600);
|
|
|
|
|
|
$id = Db::name('lesson_slot')->insertGetId($data);
|