示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Hotel::find()->notDeleted()->with('hotelData');
     //->allowed()
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'stars' => $this->stars, 'country_id' => $this->country_id, 'city_id' => $this->city_id, 'zip' => $this->zip, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by, 'deleted' => $this->deleted]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'phone', $this->phone])->andFilterWhere(['like', 'fax', $this->fax])->andFilterWhere(['like', 'address', $this->address]);
     return $dataProvider;
 }
 public function action_renderHotelOptions()
 {
     $response = '<option value="">' . Yii::t('general', 'Please select') . '</option>';
     if (Yii::$app->request->isAjax) {
         if (($withoutId = Yii::$app->request->post('withoutId')) && ($departmentId = Yii::$app->request->post('departmentId')) && ($checkIn = Yii::$app->request->post('checkIn')) && ($checkOut = Yii::$app->request->post('checkOut'))) {
             $rooModels = Hotel::getByParams($departmentId, $checkIn, $checkOut, $withoutId);
             $hotels = ArrayHelper::getColumn($rooModels, 'hotel');
             if (count($hotels)) {
                 foreach ($hotels as $hotel) {
                     $response .= '<option value="' . $hotel->id . '">' . $hotel->name . '</option>';
                 }
             }
         }
     }
     return $response;
 }
示例#3
0
<?php

use yii\helpers\Html;
use common\components\GridView;
use common\models\Hotel;
use common\models\RoomType;
use common\models\Registration;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\RoomSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Rooms');
?>
<div class="room-index">
    <?php 
$gridColumns = [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'hotel_id', 'value' => function ($data) {
    return $data->hotel->name;
}, 'filter' => Hotel::getMap()], ['attribute' => 'room_type_id', 'value' => function ($data) {
    return $data->roomType->name;
}, 'filter' => RoomType::getMap()], ['attribute' => 'date', 'format' => ['date', 'php:d-m-Y'], 'filterType' => GridView::FILTER_DATE, 'filterWidgetOptions' => ['pluginOptions' => ['autoclose' => true, 'format' => 'dd-mm-yyyy']], 'width' => '180px'], 'allotment', ['attribute' => 'booked', 'value' => function ($data) {
    $data->booked = $data->getBooked();
    return $data->booked;
}], ['attribute' => 'free', 'value' => function ($data) {
    return $data->allotment - $data->booked;
}], ['attribute' => 'price', 'value' => function ($data) {
    return Registration::generateRoomRate($data->price);
}, 'format' => 'raw']];
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => $gridColumns, 'responsive' => true, 'hover' => true, 'pjax' => true, 'resizableColumns' => false, 'toolbar' => [Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['index'], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => Yii::t('kvgrid', 'Reset Grid')]), '{export}', '{toggleData}'], 'toggleDataOptions' => ['default' => 'all'], 'panelBeforeTemplate' => '<div class="pull-right"><div class="btn-toolbar kv-grid-toolbar" role="toolbar"><span class="pager-mini">{pager}</span>{toolbar}</div></div>{before}<div class="clearfix"></div>', 'panelAfterTemplate' => '{after}<span class="pager-mini clearfix">{pager}</span>', 'panel' => ['type' => GridView::TYPE_PRIMARY, 'heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-user"></i>' . Html::encode($this->title) . '</h3>', 'footer' => false], 'exportConfig' => [GridView::EXCEL => [], GridView::CSV => ['config' => ['colDelimiter' => ';', 'rowDelimiter' => "\r\n"]], GridView::PDF => []]]);
?>

</div>
示例#4
0
<?php

use yii\helpers\Html;
use common\components\GridView;
use common\models\Registration;
use common\models\Hotel;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\RegistrationSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Registrations');
?>
<div class="registration-index">
    <?php 
$gridColumns = [['attribute' => 'status', 'value' => function ($data) {
    return isset($data->status) && array_key_exists($data->status, Registration::$reverseStatus) ? Registration::$reverseStatus[$data->status] : null;
}, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Registration::$statusNames + ['' => 'All']], 'headerOptions' => ['style' => 'min-width:115px;']], 'first_name', 'last_name', 'company', 'department', ['attribute' => 'hotel_id', 'value' => function ($data) {
    return isset($data->hotel) && $data->hotel ? $data->hotel->name : null;
}, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Hotel::getMap(), 'options' => ['prompt' => Yii::t('general', 'All')]], 'headerOptions' => ['style' => 'min-width:155px;']], ['attribute' => 'check_in', 'format' => ['date', 'php:d/m/Y'], 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Registration::getCheckIn(), 'options' => ['prompt' => Yii::t('general', 'All')]], 'headerOptions' => ['style' => 'min-width:115px;']], ['attribute' => 'check_out', 'format' => ['date', 'php:d/m/Y'], 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Registration::getCheckOut(), 'options' => ['prompt' => Yii::t('general', 'All')]], 'headerOptions' => ['style' => 'min-width:115px;']], ['attribute' => 'room_type_id', 'value' => function ($data) {
    return isset($data->roomType) && $data->roomType ? $data->roomType->name : null;
}, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => \common\models\RoomType::getMap(), 'options' => ['prompt' => Yii::t('general', 'All')]]], ['attribute' => 'room_rate', 'value' => function ($data) {
    return isset($data->room_rate) ? Registration::generateRoomRate($data->room_rate) : null;
}, 'format' => 'raw'], ['attribute' => 'updated_at', 'format' => ['date', 'php:h:i:s A d-m-Y']], 'd12', 'd13', 'd14', 'd15', 'd16'];
// Generate a bootstrap responsive striped table with row highlighted on hover
echo GridView::widget(['dataProvider' => $dataProvider, 'responsive' => true, 'hover' => true, 'columns' => $gridColumns, 'pjax' => true, 'resizableColumns' => false, 'toolbar' => [Html::a('<i class="glyphicon glyphicon-repeat"></i>', ['index'], ['data-pjax' => 0, 'class' => 'btn btn-default', 'title' => Yii::t('kvgrid', 'Reset Grid')]), '{export}', '{toggleData}'], 'toggleDataOptions' => ['default' => 'all'], 'panelBeforeTemplate' => '<div class="pull-right"><div class="btn-toolbar kv-grid-toolbar" role="toolbar"><span class="pager-mini">{pager}</span>{toolbar}</div></div>{before}<div class="clearfix"></div>', 'panelAfterTemplate' => '{after}<span class="pager-mini clearfix">{pager}</span>', 'panel' => ['type' => GridView::TYPE_PRIMARY, 'heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-list-alt"></i> Hotel Rooming List</h3>', 'footer' => false], 'exportConfig' => [GridView::EXCEL => [], GridView::CSV => ['config' => ['colDelimiter' => ';', 'rowDelimiter' => "\r\n"]], GridView::PDF => []]]);
?>

</div>
示例#5
0
 /**
  * Finds the Hotel model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Hotel the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Hotel::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }