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.

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