選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

113 行
4.2KB

  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. $html = '' ;
  53. if($model->acces_restreint)
  54. {
  55. $html .= '<span class="glyphicon glyphicon-lock"></span> ' ;
  56. if($count == 1)
  57. {
  58. $html .= '1 utilisateur' ;
  59. }
  60. else {
  61. $html .= $count.' utilisateurs' ;
  62. }
  63. }
  64. if(strlen($model->code))
  65. {
  66. if(strlen($html)) $html .= '<br />' ;
  67. $html .= 'Code : <strong>'.Html::encode($model->code).'</strong>' ;
  68. }
  69. return $html ;
  70. }
  71. ],
  72. [
  73. 'attribute' => 'credit_pain',
  74. 'label' => 'Crédit pain',
  75. 'format' => 'raw',
  76. 'value' => function($model) {
  77. if($model->credit_pain)
  78. return '<span class="glyphicon glyphicon-euro"></span>' ;
  79. return '' ;
  80. }
  81. ],
  82. [
  83. 'class' => 'yii\grid\ActionColumn',
  84. 'template' => '{update} {delete}',
  85. 'headerOptions' => ['class' => 'actions'],
  86. 'buttons' => [
  87. 'update' => function ($url, $model) {
  88. return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
  89. 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
  90. ]);
  91. },
  92. 'delete' => function ($url, $model) {
  93. return Html::a('<span class="glyphicon glyphicon-trash"></span> Suprimer', $url, [
  94. 'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
  95. ]);
  96. }
  97. ],
  98. ],
  99. ],
  100. ]); ?>
  101. </div>