<?php use app\modules\admin\models\OrderSearch; use app\modules\checkout\models\Order; use app\widgets\EntityDropDown; use yii\bootstrap\Nav; use yii\data\ActiveDataProvider; use yii\grid\GridView; use yii\helpers\Url; /** * @var OrderSearch $searchModel * @var ActiveDataProvider $dataProvider */ $this->title = Yii::t('app', 'Orders'); echo Nav::widget(['encodeLabels' => false, 'items' => [['label' => Yii::t('app', 'Create'), 'url' => Url::to(['/admin/order/create']), 'active' => true]], 'options' => ['class' => 'nav-pills']]); echo GridView::widget(['filterModel' => $searchModel, 'dataProvider' => $dataProvider, 'columns' => [['attribute' => 'id', 'filter' => false], ['attribute' => 'name', 'format' => 'text'], ['attribute' => 'address', 'format' => 'text'], ['attribute' => 'phone', 'format' => 'text'], ['attribute' => 'country_id', 'format' => 'text'], ['attribute' => 'status', 'filter' => EntityDropDown::widget(['model' => $searchModel, 'attribute' => 'status', 'items' => [Yii::t('app', 'New'), Yii::t('app', 'Closed'), Yii::t('app', 'Canceled')]]), 'value' => function ($order) { /** @var Order $order */ return $order->getStatusText(); }], ['attribute' => 'created_at', 'format' => 'datetime'], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]);
use app\models\Product; use app\modules\admin\models\CommentSearch; use app\modules\user\models\User; use app\widgets\EntityDropDown; use app\widgets\Rating; use yii\bootstrap\Html; use yii\data\ActiveDataProvider; use yii\helpers\ArrayHelper; use yii\web\View; /** * @var CommentSearch $searchModel * @var ActiveDataProvider $dataProvider * @var View $this */ $this->title = Yii::t('app', 'Comments'); ?> <?php echo \yii\grid\GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['attribute' => 'product_id', 'filter' => false, 'format' => 'text'], ['label' => Yii::t('app', 'Product name'), 'filter' => false, 'format' => 'html', 'value' => function ($comment) { /** @var Product $product */ $product = Product::findOne($comment->product_id); return Html::a($product->name, ['/admin/product/update', 'id' => $product->id]); }], ['attribute' => 'user_id', 'format' => 'html', 'filter' => EntityDropDown::widget(['model' => $searchModel, 'attribute' => 'user_id', 'items' => ArrayHelper::map(User::find()->all(), 'id', 'name')]), 'value' => function ($comment) { return User::findOne($comment->user_id)->name; }], ['attribute' => 'body', 'format' => 'text', 'value' => function ($comment) { return \yii\helpers\StringHelper::truncateWords($comment->body, 10); }], 'created_at:datetime', ['attribute' => 'rating', 'format' => 'raw', 'filter' => false, 'value' => function ($comment) { return Rating::widget(['readonly' => true, 'name' => "rating[{$comment->id}]", 'value' => $comment->rating]); }], ['attribute' => 'status', 'format' => 'html', 'filter' => EntityDropDown::widget(['model' => $searchModel, 'attribute' => 'user_id', 'items' => [Yii::t('app', 'Inactive'), Yii::t('app', 'Active')]]), 'value' => function ($comment) { return $comment->status == Comment::STATUS_ACTIVE ? Yii::t('app', 'Active') : Yii::t('app', 'Inactive'); }], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]);
<?php use app\models\Category; use app\modules\admin\models\ProductSearch; use app\widgets\BackLink; use app\widgets\EntityDropDown; use yii\bootstrap\Nav; use yii\data\ActiveDataProvider; use yii\grid\GridView; use yii\helpers\Url; /** * @var ProductSearch $searchModel * @var ActiveDataProvider $dataProvider * @var Category $category */ $this->title = Yii::t('app', 'Products'); echo Nav::widget(['encodeLabels' => false, 'items' => [['label' => BackLink::widget(['title' => Yii::t('app', 'Categories'), 'textOnly' => true]), 'url' => Url::to(['/admin/category/list', 'node' => $category->id])], ['label' => $category->name, 'url' => Url::to(), 'active' => true], ['label' => Yii::t('app', 'Create'), 'url' => Url::to(['/admin/product/create', 'node' => $category->id])]], 'options' => ['class' => 'nav-pills']]); echo GridView::widget(['filterModel' => $searchModel, 'dataProvider' => $dataProvider, 'columns' => [['attribute' => 'id', 'filter' => false], 'slug', ['attribute' => 'name', 'format' => 'text'], ['attribute' => 'status', 'filter' => EntityDropDown::widget(['model' => $searchModel, 'attribute' => 'status', 'items' => [Yii::t('app', 'No'), Yii::t('app', 'Yes')]]), 'value' => function ($data) { return $data->status ? Yii::t('app', 'Yes') : Yii::t('app', 'No'); }], 'price', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]);
<?php use app\modules\admin\models\PageSearch; use app\modules\user\models\User; use app\widgets\EntityDropDown; use yii\bootstrap\Nav; use yii\data\ActiveDataProvider; use yii\grid\GridView; use yii\helpers\ArrayHelper; use yii\helpers\Url; /** * @var PageSearch $searchModel * @var ActiveDataProvider $dataProvider */ $this->title = Yii::t('app', 'News items'); echo Nav::widget(['encodeLabels' => false, 'items' => [['label' => Yii::t('app', 'Create'), 'url' => Url::to(['create']), 'active' => true]], 'options' => ['class' => 'nav-pills']]); echo GridView::widget(['filterModel' => $searchModel, 'dataProvider' => $dataProvider, 'columns' => [['attribute' => 'id', 'filter' => false], 'slug', ['attribute' => 'name', 'format' => 'text'], ['attribute' => 'author_id', 'format' => 'html', 'filter' => EntityDropDown::widget(['model' => $searchModel, 'attribute' => 'author_id', 'items' => ArrayHelper::map(User::find()->all(), 'id', 'name')]), 'value' => function ($newsItem) { return User::findOne($newsItem->author_id)->name; }], ['attribute' => 'status', 'filter' => EntityDropDown::widget(['model' => $searchModel, 'attribute' => 'status', 'items' => [Yii::t('app', 'No'), Yii::t('app', 'Yes')]]), 'value' => function ($data) { return $data->status ? Yii::t('app', 'Yes') : Yii::t('app', 'No'); }], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete}']]]);