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.

122 lines
4.4KB

  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 = 'Commandes automatiques';
  7. $this->params['breadcrumbs'][] = $this->title;
  8. ?>
  9. <div class="commande-auto-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' => 'id_user',
  16. 'format' => 'raw',
  17. 'value' => function($model) {
  18. if(strlen($model->username))
  19. {
  20. return Html::encode($model->username) ;
  21. }
  22. else {
  23. return Html::encode($model->user->nom.' '.$model->user->prenom) ;
  24. }
  25. }
  26. ],
  27. [
  28. 'attribute' => 'id_point_vente',
  29. 'format' => 'raw',
  30. 'value' => function($model) {
  31. return Html::encode($model->pointVente->nom) ;
  32. }
  33. ],
  34. [
  35. 'attribute' => 'produits',
  36. 'format' => 'raw',
  37. 'value' => function($model) {
  38. $html = '' ;
  39. foreach($model->commandeAutoProduit as $commande_produit)
  40. {
  41. $html .= $commande_produit->quantite . ' x '.Html::encode($commande_produit->produit->nom).'<br />' ;
  42. }
  43. return $html ;
  44. }
  45. ],
  46. [
  47. 'attribute' => 'date_debut',
  48. 'value' => function($model) {
  49. return date('d/m/Y',strtotime($model->date_debut)) ;
  50. }
  51. ],
  52. [
  53. 'attribute' => 'date_fin',
  54. 'value' => function($model) {
  55. if($model->date_fin)
  56. return date('d/m/Y',strtotime($model->date_fin)) ;
  57. else
  58. return 'indéterminée' ;
  59. }
  60. ],
  61. [
  62. 'attribute' => 'lundi',
  63. 'label' => 'Jours',
  64. 'value' => function($model) {
  65. $html = '' ;
  66. if($model->lundi)
  67. $html .= 'lundi, ' ;
  68. if($model->mardi)
  69. $html .= 'mardi, ' ;
  70. if($model->mercredi)
  71. $html .= 'mercredi, ' ;
  72. if($model->jeudi)
  73. $html .= 'jeudi, ' ;
  74. if($model->vendredi)
  75. $html .= 'vendredi, ' ;
  76. if($model->samedi)
  77. $html .= 'samedi, ' ;
  78. if($model->dimanche)
  79. $html .= 'dimanche, ' ;
  80. if(strlen($html))
  81. return substr ($html, 0, strlen($html) - 2) ;
  82. else
  83. return '' ;
  84. }
  85. ],
  86. [
  87. 'attribute' => 'periodicite_semaine',
  88. 'value' => function($model) {
  89. if($model->periodicite_semaine == 1)
  90. return 'Toutes les semaines' ;
  91. else
  92. return 'Toutes les '.$model->periodicite_semaine.' semaines' ;
  93. }
  94. ],
  95. [
  96. 'class' => 'yii\grid\ActionColumn',
  97. 'template' => '{update} {delete}',
  98. 'headerOptions' => ['class' => 'actions'],
  99. 'buttons' => [
  100. 'update' => function ($url, $model) {
  101. return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
  102. 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
  103. ]);
  104. },
  105. 'delete' => function ($url, $model) {
  106. return Html::a('<span class="glyphicon glyphicon-trash"></span> Suprimer', $url, [
  107. 'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
  108. ]);
  109. }
  110. ],
  111. ],
  112. ],
  113. ]); ?>
  114. </div>