Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

82 lines
3.0KB

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