Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

123 lines
4.5KB

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