Example #1
0
 public function actionIndex()
 {
     $today = new DateTime();
     //        todo Надо переделать время
     $dateBegin = time();
     $model = new Tour();
     $model->date_begin = $today->format('Y-m-d');
     $freeObj = Objreservation::find()->select('objreservation.*')->leftJoin('reservationinfo', 'objreservation.id = reservationinfo.objreservation_id')->where(['>=', 'reservationinfo.date_begin', time()])->groupBy('id')->limit(3)->all();
     $data = ArrayHelper::getColumn(Tag::find()->asArray()->all(), 'name');
     return $this->render('index', ['model' => $model, 'data' => $data, 'freeObj' => $freeObj, 'dateBegin' => $dateBegin]);
 }
Example #2
0
 public function actionIndex($sort = 'desc', $dateBegin = null)
 {
     if (Yii::$app->request->post('Tour')['date_begin']) {
         $dateBegin = Yii::$app->request->post('Tour')['date_begin'];
     }
     //        todo Надо переделать время
     $dateBegin = time();
     if ($sort == 'desc') {
         $query = Objreservation::find()->select('objreservation.*')->leftJoin('reservationinfo', 'objreservation.id = reservationinfo.objreservation_id')->where(['>=', 'reservationinfo.date_begin', $dateBegin])->groupBy('id')->addOrderBy(['price' => SORT_DESC]);
     } else {
         if ($sort == 'asc') {
             $query = Objreservation::find()->select('objreservation.*')->leftJoin('reservationinfo', 'objreservation.id = reservationinfo.objreservation_id')->where(['>=', 'reservationinfo.date_begin', $dateBegin])->groupBy('id')->addOrderBy(['price' => SORT_ASC]);
         }
     }
     $countQuery = clone $query;
     $pages = new Pagination(['totalCount' => $countQuery->count(), 'pageSize' => 4]);
     $models = $query->offset($pages->offset)->limit($pages->limit)->all();
     return $this->render('index', ['models' => $models, 'pages' => $pages, 'dateBegin' => $dateBegin, 'sort' => $sort]);
 }
Example #3
0
 public function getFreeRandomObjreservation()
 {
     $today = new DateTime();
     //        echo Yii::info($today->format('Y-m-d H:i:s'));
     //        ['reservationinfo.date_begin' => $today->format('Y-m-d H:i:s')]
     return $query = Objreservation::find()->select('objreservation.*')->leftJoin('reservationinfo', 'objreservation.id = reservationinfo.objreservation_id')->where(['>=', 'reservationinfo.date_begin', strtotime($today->getTimestamp())])->limit(3)->all();
 }