Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

107 lines
3.9KB

  1. <?php
  2. use yii\helpers\Html;
  3. use yii\grid\GridView;
  4. use common\models\PointVenteUser ;
  5. /* @var $this yii\web\View */
  6. /* @var $dataProvider yii\data\ActiveDataProvider */
  7. $this->title = 'Points de vente';
  8. $this->params['breadcrumbs'][] = $this->title;
  9. ?>
  10. <div class="point-vente-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. 'nom',
  16. 'localite',
  17. [
  18. 'attribute' => 'point_fabrication',
  19. 'format' => 'raw',
  20. 'value' => function($model) {
  21. if($model->point_fabrication)
  22. {
  23. return '<span class="label label-success">Oui</span>' ;
  24. }
  25. else {
  26. return '<span class="label label-danger">Non</span>' ;
  27. }
  28. }
  29. ],
  30. [
  31. 'label' => 'Livraison',
  32. 'value' => function($model) {
  33. $html = '' ;
  34. if($model->livraison_lundi) $html .= 'lundi, ' ;
  35. if($model->livraison_mardi) $html .= 'mardi, ' ;
  36. if($model->livraison_mercredi) $html .= 'mercredi, ' ;
  37. if($model->livraison_jeudi) $html .= 'jeudi, ' ;
  38. if($model->livraison_vendredi) $html .= 'vendredi, ' ;
  39. if($model->livraison_samedi) $html .= 'samedi, ' ;
  40. if($model->livraison_dimanche) $html .= 'dimanche, ' ;
  41. if(strlen($html))
  42. return substr ($html, 0, strlen($html)-2) ;
  43. else
  44. return '' ;
  45. }
  46. ],
  47. [
  48. 'attribute' => 'acces_restreint',
  49. 'format' => 'raw',
  50. 'value' => function($model) {
  51. $count = PointVenteUser::find()->where(['id_point_vente' => $model->id])->count();
  52. if($model->acces_restreint)
  53. {
  54. $html = '<span class="glyphicon glyphicon-lock"></span> ' ;
  55. if($count == 1)
  56. {
  57. $html .= '1 utilisateur' ;
  58. }
  59. else {
  60. $html .= $count.' utilisateurs' ;
  61. }
  62. return $html ;
  63. }
  64. else {
  65. return '' ;
  66. }
  67. }
  68. ],
  69. [
  70. 'attribute' => 'credit_pain',
  71. 'label' => 'Crédit pain',
  72. 'format' => 'raw',
  73. 'value' => function($model) {
  74. if($model->credit_pain)
  75. return '<span class="glyphicon glyphicon-euro"></span>' ;
  76. return '' ;
  77. }
  78. ],
  79. [
  80. 'class' => 'yii\grid\ActionColumn',
  81. 'template' => '{update} {delete}',
  82. 'headerOptions' => ['class' => 'actions'],
  83. 'buttons' => [
  84. 'update' => function ($url, $model) {
  85. return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
  86. 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
  87. ]);
  88. },
  89. 'delete' => function ($url, $model) {
  90. return Html::a('<span class="glyphicon glyphicon-trash"></span> Suprimer', $url, [
  91. 'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
  92. ]);
  93. }
  94. ],
  95. ],
  96. ],
  97. ]); ?>
  98. </div>