|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081 |
- <?php
-
- use yii\helpers\Html;
- use yii\grid\GridView;
-
- /* @var $this yii\web\View */
- /* @var $dataProvider yii\data\ActiveDataProvider */
-
- $this->title = 'Produits';
- $this->params['breadcrumbs'][] = $this->title;
- ?>
- <div class="produit-index">
-
- <h1><?= Html::encode($this->title) ?> <?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-success']) ?></h1>
-
- <?= GridView::widget([
- 'dataProvider' => $dataProvider,
- 'columns' => [
- [
- 'attribute' => 'order',
- 'headerOptions' => ['class' => 'order'],
- 'format' => 'raw',
- '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'],
- 'value' => function($model) {
- if(strlen($model->photo)) {
- if(Yii::$app->getRequest()->serverName == 'localhost')
- $url = '../../frontend/web/' ;
- else
- $url = 'http://www.laboiteapain.net/' ;
-
- return '<img class="photo-produit" src="'.$url.'uploads/'.$model->photo.'" />' ;
- }
- return '' ;
- }
- ],
- 'nom',
- 'description',
- [
- 'attribute' => 'actif',
- 'headerOptions' => ['class' => 'actif'],
- 'contentOptions' => ['class' => 'center'],
- 'format' => 'raw',
- 'value' => function($model) {
- if($model->actif)
- {
- 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' => 'actions'],
- 'buttons' => [
- 'update' => function ($url, $model) {
- return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
- 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
- ]);
- },
- 'delete' => function ($url, $model) {
- return Html::a('<span class="glyphicon glyphicon-trash"></span> Suprimer', $url, [
- 'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
- ]);
- }
- ],
- ],
- ],
- ]); ?>
-
- </div>
|