|
@@ -206,11 +206,18 @@ class Lessonslot extends Backend
|
|
|
$coach_id = input('coach_id','');
|
|
|
$lesson_id = input('lesson_id','');
|
|
|
$danceroom_id = input('danceroom_id',0);
|
|
|
- $starttime = input('starttime',date('Y-m-d'),'strtotime');//默认看今天
|
|
|
- $endtime = input('endtime',date('Y-m-d 23:59:59'),'strtotime');
|
|
|
+ $bookstatus = input('bookstatus',0);
|
|
|
+ $starttime = input('starttime',0);//默认看今天
|
|
|
+ $endtime = input('endtime',0);
|
|
|
+
|
|
|
+ if(empty($starttime) || empty($endtime)){
|
|
|
+ $starttime = strtotime(date('Y-m-d'));
|
|
|
+
|
|
|
+ $endtime = $starttime + 86399;
|
|
|
+ }
|
|
|
|
|
|
if(!empty($coach_id)){
|
|
|
- $where['coach_id'] = ['IN',$coach_id];
|
|
|
+ $where['coach_ids'] = ['IN',$coach_id];
|
|
|
}
|
|
|
if(!empty($lesson_id)){
|
|
|
$where['lesson_id'] = ['IN',$lesson_id];
|
|
@@ -218,15 +225,69 @@ class Lessonslot extends Backend
|
|
|
if(!empty($danceroom_id)){
|
|
|
$where['danceroom_id'] = $danceroom_id;
|
|
|
}
|
|
|
- $where['starttime'] = ['BETWEEN',[$starttime,$endtime]];
|
|
|
+ //$where['starttime'] = ['BETWEEN',[$starttime,$endtime]];
|
|
|
|
|
|
+ $wherenew = '';
|
|
|
+ if(!empty($bookstatus)){
|
|
|
+ if($bookstatus == 1){
|
|
|
+ $wherenew = 'bookednum = 0';
|
|
|
+ }
|
|
|
+ if($bookstatus == 2){
|
|
|
+ $wherenew = 'bookednum != 0 and bookednum < num_max';
|
|
|
+ }
|
|
|
+ if($bookstatus == 3){
|
|
|
+ $wherenew = 'bookednum = num_max';
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ $field = [
|
|
|
+ 'slot.id','slot.starttime','slot.endtime','slot.num_max','slot.bookednum',
|
|
|
+ 'coach.nickname as Staff','coach.bgcolor',
|
|
|
+ 'lesson.name_en as title',
|
|
|
+ 'danceroom.name_en as Location',
|
|
|
+ ];
|
|
|
$list = Db::name('lesson_slot')->alias('slot')
|
|
|
+ ->join('coach','slot.coach_ids = coach.id','LEFT')
|
|
|
+ ->join('lesson','slot.lesson_id = lesson.id','LEFT')
|
|
|
+ ->join('danceroom','slot.danceroom_id = danceroom.id','LEFT')
|
|
|
+ ->field($field)
|
|
|
->where($where)
|
|
|
+ ->where($wherenew)
|
|
|
->order('id desc')
|
|
|
->select();
|
|
|
|
|
|
- return json($list);
|
|
|
+ if(!empty($list)){
|
|
|
+ foreach($list as $key => $val){
|
|
|
+ $val['start'] = date('Y-m-d H:i',$val['starttime']);
|
|
|
+ $val['end'] = date('Y-m-d H:i',$val['endtime']);
|
|
|
+
|
|
|
+ //无人约
|
|
|
+ $val['backgroundColor'] = '#ffffff';
|
|
|
+ $val['borderColor'] = $val['bgcolor'];
|
|
|
+ $val['textColor'] = '#333333';
|
|
|
+
|
|
|
+ //有人约
|
|
|
+ if($val['bookednum'] > 0){
|
|
|
+ $val['backgroundColor'] = $val['bgcolor'];
|
|
|
+ $val['borderColor'] = $val['bgcolor'];
|
|
|
+ $val['textColor'] = '#ffffff';
|
|
|
+ }
|
|
|
+
|
|
|
+ //详情
|
|
|
+ $val['extendedProps'] = [
|
|
|
+ 'Session' => $val['title'],
|
|
|
+ 'time' => date('D, M d Y, H:i',$val['starttime']).' - '.date('H:i',$val['endtime']),
|
|
|
+ 'Staff' => $val['Staff'],
|
|
|
+ 'Location' => $val['Location'],
|
|
|
+ 'Participar' => $val['bookednum'].'/'.$val['num_max'].' participants',
|
|
|
+ 'id' => $val['id'],
|
|
|
+ ];
|
|
|
+
|
|
|
+ $list[$key] = $val;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ $this->result($list,1,'success','json');
|
|
|
|
|
|
}
|
|
|
|