Example #1
0
 /**
  * @param $id
  * @return $this|array
  */
 public function actionUpdate($id)
 {
     $app = Yii::$app;
     $request = $app->request;
     $response = $app->response;
     /* @var $model HotelRecord */
     $model = HotelRecord::findOne($id);
     $model->setScenario('update');
     if ($model->load($request->post())) {
         if ($request->isAjax) {
             $response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($model);
         }
         if ($model->save()) {
             return $response->redirect(['hotel/index']);
         }
     }
     return $this->render('update', ['model' => $model]);
 }
Example #2
0
<?php

/* @var $model \app\models\country\CountryRecord */
use app\models\hotel\HotelRecord;
use app\models\country\CountryRecord;
use yii\bootstrap\ActiveForm;
$form = ActiveForm::begin(['layout' => 'horizontal']);
echo $form->field($model, 'name');
echo $form->field($model, 'description')->textarea(['cols' => 2, 'rows' => 3]);
echo $form->field($model, 'type')->dropDownList(HotelRecord::types());
echo $form->field($model, 'stars')->dropDownList(HotelRecord::stars());
echo $form->field($model, 'country_id')->dropDownList(CountryRecord::getCountries());
?>

    <div class="clearfix form-actions">
        <div class="col-md-offset-3 col-md-9">
            <?php 
echo \yii\bootstrap\Html::submitButton('Применить', ['class' => 'btn btn-success']);
?>
        </div>
    </div>

<?php 
ActiveForm::end();
Example #3
0
<?php

use app\models\tour\TourRecord;
use app\models\hotel\HotelRecord;
use yii\bootstrap\ActiveForm;
use app\widgets\DateTimePicker;
$form = ActiveForm::begin(['layout' => 'horizontal']);
echo $form->field($model, 'name');
echo $form->field($model, 'hotel_id')->dropDownList(HotelRecord::getHotels());
echo $form->field($model, 'children')->dropDownList(TourRecord::children());
echo $form->field($model, 'adults')->dropDownList(TourRecord::adults());
$clientOptions = ['format' => 'DD.MM.YYYY HH:mm:ss'];
$clientOptions['minDate'] = new \yii\web\JsExpression('moment().format("MM.DD.YYYY")');
$options = ['placeholder' => 'дд.мм.гггг ЧЧ:ММ'];
if ($model->isNewRecord) {
    $options['value'] = Yii::$app->formatter->datetimeFormat;
    $clientOptions['minDate'] = new \yii\web\JsExpression('moment().format("MM.DD.YYYY")');
}
echo $form->field($model, 'flyAt')->widget(DateTimePicker::className(), ['options' => $options, 'language' => 'ru', 'clientOptions' => $clientOptions]);
?>

    <div class="clearfix form-actions">
        <div class="col-md-offset-3 col-md-9">
            <?php 
echo \yii\bootstrap\Html::submitButton('Применить', ['class' => 'btn btn-success']);
?>
        </div>
    </div>

<?php 
ActiveForm::end();
Example #4
0
 /**
  * @return array
  */
 public static function stars()
 {
     return HotelRecord::stars();
 }
Example #5
0
    <?php 
$form = \yii\widgets\ActiveForm::begin(['method' => 'GET']);
?>
    <div class="form-group">

        <?php 
echo $form->field($hotelFilterForm, 'country_id')->dropDownList(CountryRecord::getCountries())->label(false);
?>
        <?php 
echo $form->field($search, 'hotel_id')->dropDownList(HotelRecord::getHotels())->label(false);
?>
        <?php 
echo $form->field($hotelFilterForm, 'stars')->dropDownList(HotelRecord::stars())->label(false);
?>
        <?php 
echo $form->field($hotelFilterForm, 'type')->dropDownList(HotelRecord::types())->label(false);
?>
        <?php 
echo $form->field($search, 'adults')->dropDownList(TourRecord::adults())->label(false);
?>
        <?php 
echo $form->field($search, 'children')->dropDownList(TourRecord::children())->label(false);
?>

        <div class="form-group">
            <div class="input-group">
                <?php 
echo \yii\helpers\Html::submitButton('Применить', array('class' => 'btn btn-warning', 'style' => 'margin-bottom: 9px'));
?>
            </div>
        </div>
Example #6
0
 /**
  * @param array $options
  * @param array $params
  * @return ActiveDataProvider
  */
 public function getFilterDataProvider($options = [], $params = [])
 {
     $query = static::find();
     $provider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 6]]);
     $hotelAlias = HotelRecord::tableName();
     if (!($this->load($params) && $this->validate())) {
         return $provider;
     }
     $query->children($this->children)->adults($this->adults)->hotel($this->hotel_id)->andFilterWhere(['=', $hotelAlias . '.country_id', $options['country_id']])->andFilterWhere(['=', $hotelAlias . '.stars', $options['stars']])->andFilterWhere(['=', $hotelAlias . '.type', $options['type']])->from([$hotelAlias, self::tableName()])->orderBy(self::tableName() . '.created_at DESC');
     return $provider;
 }