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

index.php 5.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  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. // aucun produit
  45. if(!count($model->commandeAutoProduit))
  46. {
  47. $html .= '<span class="glyphicon glyphicon-warning-sign"></span> Aucun produit' ;
  48. }
  49. return $html ;
  50. }
  51. ],
  52. [
  53. 'attribute' => 'date_debut',
  54. 'value' => function($model) {
  55. return date('d/m/Y',strtotime($model->date_debut)) ;
  56. }
  57. ],
  58. [
  59. 'attribute' => 'date_fin',
  60. 'value' => function($model) {
  61. if($model->date_fin)
  62. return date('d/m/Y',strtotime($model->date_fin)) ;
  63. else
  64. return 'indéterminée' ;
  65. }
  66. ],
  67. [
  68. 'attribute' => 'lundi',
  69. 'label' => 'Jours',
  70. 'format' => 'raw',
  71. 'value' => function($model) {
  72. $html = '' ;
  73. if($model->lundi)
  74. $html .= 'lundi, ' ;
  75. if($model->mardi)
  76. $html .= 'mardi, ' ;
  77. if($model->mercredi)
  78. $html .= 'mercredi, ' ;
  79. if($model->jeudi)
  80. $html .= 'jeudi, ' ;
  81. if($model->vendredi)
  82. $html .= 'vendredi, ' ;
  83. if($model->samedi)
  84. $html .= 'samedi, ' ;
  85. if($model->dimanche)
  86. $html .= 'dimanche, ' ;
  87. if(strlen($html))
  88. return substr ($html, 0, strlen($html) - 2) ;
  89. else
  90. return '<span class="glyphicon glyphicon-warning-sign"></span> Aucun jour' ;
  91. }
  92. ],
  93. [
  94. 'attribute' => 'periodicite_semaine',
  95. 'value' => function($model) {
  96. if($model->periodicite_semaine == 1)
  97. return 'Toutes les semaines' ;
  98. else
  99. return 'Toutes les '.$model->periodicite_semaine.' semaines' ;
  100. }
  101. ],
  102. [
  103. 'attribute' => 'paiement_automatique',
  104. 'format' => 'raw',
  105. 'value' => function($model) {
  106. if($model->paiement_automatique)
  107. return '<span class="label label-success">Oui</span>' ;
  108. else
  109. return '<span class="label label-danger">Non</span>' ;
  110. }
  111. ],
  112. [
  113. 'class' => 'yii\grid\ActionColumn',
  114. 'template' => '{update} {delete}',
  115. 'headerOptions' => ['class' => 'actions'],
  116. 'buttons' => [
  117. 'update' => function ($url, $model) {
  118. return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
  119. 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
  120. ]);
  121. },
  122. 'delete' => function ($url, $model) {
  123. return Html::a('<span class="glyphicon glyphicon-trash"></span> Suprimer', $url, [
  124. 'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
  125. ]);
  126. }
  127. ],
  128. ],
  129. ],
  130. ]); ?>
  131. </div>