|
- <?php
-
-
-
- use yii\helpers\Html;
- use yii\grid\GridView;
- use common\helpers\Url ;
-
- $this->setTitle('Produits') ;
- $this->addBreadcrumb($this->getTitle()) ;
- $this->addButton(['label' => '+', 'url' => 'product/create', 'class' => 'btn btn-primary']) ;
-
- ?>
-
- <div class="product-index">
- <?= GridView::widget([
- 'filterModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- 'columns' => [
- [
- 'attribute' => 'order',
- 'headerOptions' => ['class' => 'order'],
- 'format' => 'raw',
- 'filter' => '',
- 'value' => function($model) {
- return '<a class="btn-order btn btn-default" href="javascript:void(0);"><span class="glyphicon glyphicon-resize-vertical"></span></a>' ;
- }
- ],
- [
- 'attribute' => 'photo',
- 'format' => 'raw',
- 'headerOptions' => ['class' => 'td-photo'],
- 'filter' => '',
- 'value' => function($model) {
- if(strlen($model->photo)) {
- $url = Yii::$app->urlManagerProducer->getHostInfo().'/'.Yii::$app->urlManagerProducer->baseUrl ;
- return '<img class="photo-product" src="'.$url.'/uploads/'.$model->photo.'" />' ;
- }
- return '' ;
- }
- ],
- 'name',
- 'description',
- [
- 'attribute' => 'active',
- 'headerOptions' => ['class' => 'active'],
- 'contentOptions' => ['class' => 'center'],
- 'format' => 'raw',
- 'filter' => [0 => 'Non', 1 => 'Oui'],
- 'value' => function($model) {
- if($model->active)
- {
- return '<span class="label label-success">oui</span>' ;
- }
- else {
- return '<span class="label label-danger">non</span>' ;
- }
- }
- ],
-
- [
- 'class' => 'yii\grid\ActionColumn',
- 'template' => '{update} {delete}',
- 'headerOptions' => ['class' => 'column-actions'],
- 'contentOptions' => ['class' => 'column-actions'],
- 'buttons' => [
- 'update' => function ($url, $model) {
- return Html::a('<span class="glyphicon glyphicon-pencil"></span>', $url, [
- 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
- ]);
- },
- 'delete' => function ($url, $model) {
- return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, [
- 'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
- ]);
- }
- ],
- ],
- ],
- ]); ?>
- </div>
|