Example #1
0
<!--<div class="row">-->
<!--        --><?php 
//$form = ActiveForm::begin([
//            'options' => ['enctype' => 'multipart/form-data'],
//        ]);
?>
<!--        --><?//= $form->field($model, 'excel')->fileInput(); ?>
<!--        --><?//= Html::submitButton('Import file'); ?>
<!--        --><?php 
//$form->end();
?>
<!--</div>-->

<div class="invoice-index">

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'responsive' => true, 'hover' => true, 'pjax' => false, 'columns' => [['class' => 'kartik\\grid\\SerialColumn'], ['class' => 'kartik\\grid\\ActionColumn', 'template' => '{view}', 'header' => '<span class="glyphicon glyphicon-info-sign"></span>'], ['attribute' => 'registration_id', 'label' => 'Firstname', 'filter' => false, 'value' => function ($data) {
    return Html::a($data->registration->first_name, Yii::$app->getUrlManager()->createUrl(['/registration/view', 'id' => $data->registration_id]));
}, 'format' => 'raw', 'enableSorting' => false], ['attribute' => 'registration_id', 'label' => 'Lastname', 'filter' => false, 'value' => function ($data) {
    return Html::a($data->registration->last_name, Yii::$app->getUrlManager()->createUrl(['/registration/view', 'id' => $data->registration_id]));
}, 'format' => 'raw', 'enableSorting' => false], ['attribute' => 'created_at', 'label' => 'Invoice date', 'filter' => false, 'format' => ['date', 'php:d-m-Y']], ['attribute' => 'invoice', 'format' => 'raw', 'filter' => false, 'value' => function ($data) {
    return Html::a($data->invoice, \yii\helpers\Url::to('/statics/pdfs/' . $data->invoice), ['target' => '_blank']);
}], ['attribute' => 'deleted', 'label' => 'Status', 'value' => function ($data) {
    return array_key_exists($data->deleted, Invoice::$reverseStatus) ? Invoice::$reverseStatus[$data->deleted] : null;
}, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Invoice::$nameStatus + ['' => 'All']]], ['attribute' => 'amount', 'filter' => false, 'value' => function ($data) {
    return $data->amount . ' &#8364';
}, 'format' => 'raw'], ['attribute' => 'created_at', 'filter' => false, 'format' => ['date', 'php:d.m.Y H:i:s']]], '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">{pager}</span>', 'panel' => ['type' => GridView::TYPE_PRIMARY, 'heading' => '<h3 class="panel-title"><i class="glyphicon glyphicon-credit-card"></i> Invoice</h3>', 'footer' => false], 'exportConfig' => [GridView::EXCEL => [], GridView::CSV => ['config' => ['colDelimiter' => ';', 'rowDelimiter' => "\r\n"]], GridView::PDF => []]]);
?>

</div>
Example #2
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>
Example #3
0
$this->registerJsFile('@web/js/grid/main.js', ['depends' => ['yii\\web\\JqueryAsset']]);
?>
<div class="registration-index">
    <?php 
$gridColumns = [['class' => '\\kartik\\grid\\SerialColumn'], ['class' => '\\kartik\\grid\\ActionColumn', 'template' => '{view} {update} {cancel} {delete}', 'buttons' => ['cancel' => function ($key, $model) {
    $customUrl = Yii::$app->getUrlManager()->createUrl(['registration/cancel-admin', 'id' => $model->id]);
    return Html::a('<span class="glyphicon glyphicon-ban-circle"></span>', $customUrl, ['title' => Yii::t('app', 'Cancel'), 'data-pjax' => '0', 'confirm' => Yii::t('app', 'Do you really want cancel registration?')]);
}, 'delete' => function ($key, $model) {
    $customUrl = Yii::$app->getUrlManager()->createUrl(['registration/delete-admin', 'id' => $model->id]);
    return Html::a('<span class="glyphicon glyphicon-trash"></span>', $customUrl, ['title' => Yii::t('app', 'Delete'), 'data-pjax' => '0', 'confirm' => Yii::t('app', 'Do you really want delete registration?')]);
}], 'header' => '<span class="glyphicon glyphicon-info-sign"></span>', 'headerOptions' => ['style' => 'min-width:50px;']], ['attribute' => 'status', 'value' => function ($data) {
    return 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;']], 'code', ['attribute' => 'title', 'value' => function ($data) {
    return Yii::t('general', $data->title);
}, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Registration::getTitles(), 'options' => ['prompt' => Yii::t('general', 'All')]], 'width' => '250px'], 'first_name', 'last_name', 'company', 'department', 'street', 'zip', 'city', ['attribute' => 'country_id', 'value' => function ($data) {
    return $data->country ? $data->country->name : null;
}, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Country::getMap(), 'options' => ['prompt' => Yii::t('general', 'All')]], 'headerOptions' => ['style' => 'min-width:150px;']], 'email:email', 'phone', ['attribute' => 'department_id', 'value' => function ($data) {
    return $data->departmentRel ? $data->departmentRel->name : null;
}, 'filterType' => GridView::FILTER_SELECT2, 'filterWidgetOptions' => ['data' => Department::getMap(), 'options' => ['prompt' => Yii::t('general', 'All')]], 'width' => '250px'], ['attribute' => 'hotel_id', 'value' => function ($data) {
    return $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 $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 Registration::generateRoomRate($data->room_rate);
}, 'format' => 'raw'], ['attribute' => 'special_request', 'hidden' => true], ['attribute' => 'updated_at', 'format' => ['date', 'php:h:i:s A d-m-Y']], ['attribute' => 'id', 'hiddenFromExport' => true, 'headerOptions' => ['style' => 'min-width:80px;']]];
// Generate a bootstrap responsive striped table with row highlighted on hover
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, '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-user"></i> Registrations</h3>', 'before' => Html::a('<i class="glyphicon glyphicon-list-alt"></i> Hotel Rooming List', ['hotel-rooming'], ['class' => 'btn btn-primary']), 'footer' => false], 'exportConfig' => [GridView::EXCEL => [], GridView::CSV => ['config' => ['colDelimiter' => ';', 'rowDelimiter' => "\r\n"]], GridView::PDF => []], 'beforeHeader' => [['columns' => [['options' => ['colspan' => 3]], ['content' => 'Personal Data', 'options' => ['colspan' => 12, 'class' => 'text-center warning']], ['content' => 'Hotel Information', 'options' => ['colspan' => 6, 'class' => 'text-center warning']]], 'options' => ['class' => 'skip-export']]]]);
?>

</div>