Authored by wuxiao

配置时区

修改房间预告时间的编辑
@@ -158,16 +158,17 @@ class Room extends \yii\db\ActiveRecord @@ -158,16 +158,17 @@ class Room extends \yii\db\ActiveRecord
158 if (empty($data['app'])){ 158 if (empty($data['app'])){
159 throw new \Exception('未选择业务线'); 159 throw new \Exception('未选择业务线');
160 } 160 }
  161 + if (!empty($data['starting_time'])){
  162 + $data['starting_time'] = (int)strtotime($data['starting_time']);
  163 + if ($data['starting_time'] <= time()){
  164 + throw new \Exception('预告开始时间不能早于当前时间');
  165 + }
  166 + }
161 167
162 $data['room_id'] = $this->bornRoomId(); 168 $data['room_id'] = $this->bornRoomId();
163 sort($data['app']); 169 sort($data['app']);
164 $data['app'] = implode(',', $data['app']); 170 $data['app'] = implode(',', $data['app']);
165 171
166 - $data['starting_time'] = $data['starting_time'] ? strtotime($data['starting_time']) : 0;  
167 - if ( ($data['starting_time']>0) && ($data['starting_time'] <= time())){  
168 - $data['starting_time'] = 0;  
169 - }  
170 -  
171 if ($data['best'] > 0){ 172 if ($data['best'] > 0){
172 $count = $this->find()->where(['!=','best','0'])->count(); 173 $count = $this->find()->where(['!=','best','0'])->count();
173 if ($count >= 2){ 174 if ($count >= 2){
@@ -218,15 +219,16 @@ class Room extends \yii\db\ActiveRecord @@ -218,15 +219,16 @@ class Room extends \yii\db\ActiveRecord
218 if (empty($data['app'])){ 219 if (empty($data['app'])){
219 throw new \Exception('未选择业务线'); 220 throw new \Exception('未选择业务线');
220 } 221 }
  222 + if (!empty($data['starting_time'])){
  223 + $data['starting_time'] = (int)strtotime($data['starting_time']);
  224 + if ($data['starting_time'] <= time()){
  225 + throw new \Exception('预告开始时间不能早于当前时间');
  226 + }
  227 + }
221 228
222 @sort($data['app']); 229 @sort($data['app']);
223 $data['app'] = implode(',', $data['app']); 230 $data['app'] = implode(',', $data['app']);
224 231
225 - $data['starting_time'] = $data['starting_time'] ? strtotime($data['starting_time']) : 0;  
226 - if ( ($data['starting_time']>0) && ($data['starting_time'] <= time())){  
227 - $data['starting_time'] = 0;  
228 - }  
229 -  
230 if ($data['best'] > 0){ 232 if ($data['best'] > 0){
231 $count = $this->find()->where(['and',['!=','best','0'],['!=','id',$this->id]])->count(); 233 $count = $this->find()->where(['and',['!=','best','0'],['!=','id',$this->id]])->count();
232 if ($count >= 2){ 234 if ($count >= 2){
@@ -62,7 +62,7 @@ $this->registerJs($this->blocks['javascript'],View::POS_END) @@ -62,7 +62,7 @@ $this->registerJs($this->blocks['javascript'],View::POS_END)
62 <div class="form-group"> 62 <div class="form-group">
63 <label class="col-sm-3 control-label">预告开始时间: </label> 63 <label class="col-sm-3 control-label">预告开始时间: </label>
64 <div class="col-sm-5"> 64 <div class="col-sm-5">
65 - <input type="text" name="starting_time" class="form-control" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss',minDate:'%y-%M-%d %H:%m:%s'})" value="<?=$model->starting_time ? date('Y-m-d H:i:s',$model->starting_time) : ''?>"> 65 + <input type="text" name="starting_time" class="form-control" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'})" value="<?=$model->starting_time ? date('Y-m-d H:i:s',$model->starting_time) : ''?>">
66 </div> 66 </div>
67 </div> 67 </div>
68 68
@@ -44,5 +44,12 @@ return [ @@ -44,5 +44,12 @@ return [
44 ], 44 ],
45 ], 45 ],
46 ], 46 ],
  47 + /**
  48 + * 默认路由
  49 + */
47 'defaultRoute'=>'index/index', 50 'defaultRoute'=>'index/index',
  51 + /*
  52 + * 时区
  53 + */
  54 + 'timeZone' => 'Asia/Shanghai',
48 ]; 55 ];