<?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>
<?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>