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.

127 line
3.9KB

  1. <?php
  2. use yii\helpers\Html;
  3. use yii\grid\GridView;
  4. use common\models\User ;
  5. use common\models\Etablissement ;
  6. $this->title = 'Producteurs';
  7. $this->params['breadcrumbs'][] = 'Administration' ;
  8. $this->params['breadcrumbs'][] = $this->title;
  9. ?>
  10. <h1>Producteurs</h1>
  11. <?= GridView::widget([
  12. 'dataProvider' => $datas_etablissements,
  13. 'columns' => [
  14. 'nom',
  15. [
  16. 'attribute' => 'date_creation',
  17. 'format' => 'raw',
  18. 'value' => function($model) {
  19. return date('d/m/Y', strtotime($model->date_creation)) ;
  20. }
  21. ],
  22. [
  23. 'attribute' => 'Lieu',
  24. 'format' => 'raw',
  25. 'value' => function($model) {
  26. return Html::encode($model->ville.' ('.$model->code_postal.')') ;
  27. }
  28. ],
  29. [
  30. 'attribute' => 'Clients',
  31. 'format' => 'raw',
  32. 'value' => function($model) {
  33. if(!$model->userEtablissement || !count($model->userEtablissement))
  34. {
  35. return 'Aucun client' ;
  36. }
  37. else {
  38. $clients = count($model->userEtablissement).' client' ;
  39. if(count($model->userEtablissement) > 1)
  40. $clients .= 's' ;
  41. return $clients ;
  42. }
  43. }
  44. ],
  45. [
  46. 'attribute' => 'Contact',
  47. 'format' => 'raw',
  48. 'value' => function($model) {
  49. if(!isset($model->user) || (isset($model->user) && count($model->user) == 0))
  50. {
  51. return 'Aucun contact' ;
  52. }
  53. else {
  54. foreach($model->user as $u)
  55. {
  56. if($u->status == User::STATUS_BOULANGER)
  57. {
  58. return Html::encode($u->prenom.' '.$u->nom)
  59. .'<br />'.Html::encode($u->email)
  60. .'<br />'.Html::encode($u->telephone) ;
  61. }
  62. }
  63. }
  64. }
  65. ],
  66. [
  67. 'attribute' => 'actif',
  68. 'format' => 'raw',
  69. 'value' => function($model) {
  70. $html = '' ;
  71. if($model->actif)
  72. $html .= '<span class="label label-success">En ligne</span>' ;
  73. else
  74. $html .= '<span class="label label-danger">Hors-ligne</span>' ;
  75. if(strlen($model->code))
  76. {
  77. $html .= ' <span class="glyphicon glyphicon-lock" data-toggle="tooltip" data-placement="bottom" data-original-title="'.Html::encode($model->code).'"></span>' ;
  78. }
  79. return $html ;
  80. }
  81. ],
  82. [
  83. 'attribute' => 'Gratuit',
  84. 'format' => 'raw',
  85. 'value' => function($model) {
  86. if($model->gratuit)
  87. return '<span class="label label-success">Compte gratuit</span>' ;
  88. else
  89. return '' ;
  90. }
  91. ],
  92. [
  93. 'attribute' => 'Prix libre',
  94. 'label' => 'Prix libre',
  95. 'format' => 'raw',
  96. 'value' => function($model) {
  97. if(is_null($model->prix_libre))
  98. return '' ;
  99. else
  100. return $model->getPrixLibre() ;
  101. }
  102. ],
  103. [
  104. 'attribute' => 'Cours',
  105. 'label' => 'CA mois en cours',
  106. 'format' => 'raw',
  107. 'value' => function($model) {
  108. $ca = $model->getCA(date('Y-m')) ;
  109. $html = '' ;
  110. $html .= 'CA : '.number_format($ca,2).' €<br />' ;
  111. return $html ;
  112. }
  113. ],
  114. ],
  115. ]); ?>