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.

147 line
4.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 = 'Boulangeries';
  7. $this->params['breadcrumbs'][] = 'Administration' ;
  8. $this->params['breadcrumbs'][] = $this->title;
  9. ?>
  10. <h1>Boulangeries</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' => 'Facture',
  94. 'label' => 'Facture mois dernier',
  95. 'format' => 'raw',
  96. 'value' => function($model) {
  97. $periode = date('Y-m', strtotime('-1 month')) ;
  98. $ca = $model->getCA($periode) ;
  99. $html = '' ;
  100. $html .= 'CA : '.number_format($ca,2).' €<br />' ;
  101. $montant_facturer = $model->getMontantFacturer($periode, $ca) ;
  102. $facture = $model->getFacture($periode) ;
  103. if($facture)
  104. {
  105. $html .= '<span class="label label-success">Facturé</span> <strong>'.number_format($facture->montant_ht,2).' €</strong>' ;
  106. }
  107. else {
  108. if($montant_facturer == 0) {
  109. $html .= '<span class="label label-default">Gratuit</span>' ;
  110. }
  111. else {
  112. $html .= Html::a('Facturer <strong>'.$model->getMontantFacturer($periode, $ca, true).'</strong>', ['etablissement-admin/facturer','id_etablissement' => $model->id], ['class' => 'btn btn-default']) ;
  113. }
  114. }
  115. return $html ;
  116. }
  117. ],
  118. [
  119. 'attribute' => 'Cours',
  120. 'label' => 'Mois en cours',
  121. 'format' => 'raw',
  122. 'value' => function($model) {
  123. $ca = $model->getCA(date('Y-m')) ;
  124. $html = '' ;
  125. $html .= 'CA : '.number_format($ca,2).' €<br />' ;
  126. return $html ;
  127. }
  128. ],
  129. ],
  130. ]); ?>