You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.php 3.0KB

8 jaren geleden
8 jaren geleden
8 jaren geleden
8 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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>