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.

90 lines
3.2KB

  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. return Html::encode($model->user->nom.' '.$model->user->prenom) ;
  19. }
  20. ],
  21. [
  22. 'attribute' => 'id_point_vente',
  23. 'format' => 'raw',
  24. 'value' => function($model) {
  25. return Html::encode($model->pointVente->nom) ;
  26. }
  27. ],
  28. [
  29. 'attribute' => 'produits',
  30. 'format' => 'raw',
  31. 'value' => function($model) {
  32. $html = '' ;
  33. foreach($model->commandeAutoProduit as $commande_produit)
  34. {
  35. $html .= $commande_produit->quantite . ' x '.Html::encode($commande_produit->produit->nom).'<br />' ;
  36. }
  37. return $html ;
  38. }
  39. ],
  40. [
  41. 'attribute' => 'date_debut',
  42. 'value' => function($model) {
  43. return date('d/m/Y',strtotime($model->date_debut)) ;
  44. }
  45. ],
  46. [
  47. 'attribute' => 'date_fin',
  48. 'value' => function($model) {
  49. if($model->date_fin)
  50. return date('d/m/Y',strtotime($model->date_fin)) ;
  51. else
  52. return 'indéterminée' ;
  53. }
  54. ],
  55. [
  56. 'attribute' => 'periodicite_semaine',
  57. 'value' => function($model) {
  58. if($model->periodicite_semaine == 1)
  59. return 'Toutes les semaines' ;
  60. else
  61. return 'Toutes les '.$model->periodicite_semaine.' semaines' ;
  62. }
  63. ],
  64. [
  65. 'class' => 'yii\grid\ActionColumn',
  66. 'template' => '{update} {delete}',
  67. 'headerOptions' => ['class' => 'actions'],
  68. 'buttons' => [
  69. 'update' => function ($url, $model) {
  70. return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
  71. 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
  72. ]);
  73. },
  74. 'delete' => function ($url, $model) {
  75. return Html::a('<span class="glyphicon glyphicon-trash"></span> Suprimer', $url, [
  76. 'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
  77. ]);
  78. }
  79. ],
  80. ],
  81. ],
  82. ]); ?>
  83. </div>