Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

101 lines
3.5KB

  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. return $model->strJoursLivraison() ;
  34. }
  35. ],
  36. [
  37. 'attribute' => 'acces_restreint',
  38. 'format' => 'raw',
  39. 'value' => function($model) {
  40. $count = PointVenteUser::find()->where(['id_point_vente' => $model->id])->count();
  41. $html = '' ;
  42. if($model->acces_restreint)
  43. {
  44. $html .= '<span class="glyphicon glyphicon-lock"></span> ' ;
  45. if($count == 1)
  46. {
  47. $html .= '1 utilisateur' ;
  48. }
  49. else {
  50. $html .= $count.' utilisateurs' ;
  51. }
  52. }
  53. if(strlen($model->code))
  54. {
  55. if(strlen($html)) $html .= '<br />' ;
  56. $html .= 'Code : <strong>'.Html::encode($model->code).'</strong>' ;
  57. }
  58. return $html ;
  59. }
  60. ],
  61. [
  62. 'attribute' => 'credit_pain',
  63. 'label' => 'Crédit pain',
  64. 'format' => 'raw',
  65. 'value' => function($model) {
  66. if($model->credit_pain)
  67. return '<span class="glyphicon glyphicon-euro"></span>' ;
  68. return '' ;
  69. }
  70. ],
  71. [
  72. 'class' => 'yii\grid\ActionColumn',
  73. 'template' => '{update} {delete}',
  74. 'headerOptions' => ['class' => 'actions'],
  75. 'buttons' => [
  76. 'update' => function ($url, $model) {
  77. return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
  78. 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
  79. ]);
  80. },
  81. 'delete' => function ($url, $model) {
  82. return Html::a('<span class="glyphicon glyphicon-trash"></span> Suprimer', $url, [
  83. 'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
  84. ]);
  85. }
  86. ],
  87. ],
  88. ],
  89. ]); ?>
  90. </div>