Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

79 lines
2.8KB

  1. <?php
  2. use yii\helpers\Html;
  3. use yii\grid\GridView;
  4. use common\helpers\Url ;
  5. /* @var $this yii\web\View */
  6. /* @var $dataProvider yii\data\ActiveDataProvider */
  7. $this->title = 'Produits';
  8. $this->params['breadcrumbs'][] = $this->title;
  9. ?>
  10. <div class="produit-index">
  11. <h1><?= Html::encode($this->title) ?> <?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-success']) ?></h1>
  12. <?= GridView::widget([
  13. 'dataProvider' => $dataProvider,
  14. 'columns' => [
  15. [
  16. 'attribute' => 'order',
  17. 'headerOptions' => ['class' => 'order'],
  18. 'format' => 'raw',
  19. 'value' => function($model) {
  20. return '<a class="btn-order btn btn-default" href="javascript:void(0);"><span class="glyphicon glyphicon-resize-vertical"></span></a>' ;
  21. }
  22. ],
  23. [
  24. 'attribute' => 'photo',
  25. 'format' => 'raw',
  26. 'headerOptions' => ['class' => 'td-photo'],
  27. 'value' => function($model) {
  28. if(strlen($model->photo)) {
  29. $url = Url::frontend() ;
  30. return '<img class="photo-produit" src="'.$url.'uploads/'.$model->photo.'" />' ;
  31. }
  32. return '' ;
  33. }
  34. ],
  35. 'nom',
  36. 'description',
  37. [
  38. 'attribute' => 'actif',
  39. 'headerOptions' => ['class' => 'actif'],
  40. 'contentOptions' => ['class' => 'center'],
  41. 'format' => 'raw',
  42. 'value' => function($model) {
  43. if($model->actif)
  44. {
  45. return '<span class="label label-success">oui</span>' ;
  46. }
  47. else {
  48. return '<span class="label label-danger">non</span>' ;
  49. }
  50. }
  51. ],
  52. [
  53. 'class' => 'yii\grid\ActionColumn',
  54. 'template' => '{update} {delete}',
  55. 'headerOptions' => ['class' => 'actions'],
  56. 'buttons' => [
  57. 'update' => function ($url, $model) {
  58. return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
  59. 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
  60. ]);
  61. },
  62. 'delete' => function ($url, $model) {
  63. return Html::a('<span class="glyphicon glyphicon-trash"></span> Suprimer', $url, [
  64. 'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
  65. ]);
  66. }
  67. ],
  68. ],
  69. ],
  70. ]); ?>
  71. </div>