|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147 |
- <?php
-
- use yii\helpers\Html;
- use yii\grid\GridView;
- use common\models\User ;
- use common\models\Etablissement ;
-
- $this->title = 'Boulangeries';
- $this->params['breadcrumbs'][] = 'Administration' ;
- $this->params['breadcrumbs'][] = $this->title;
-
- ?>
-
- <h1>Boulangeries</h1>
-
- <?= GridView::widget([
- 'dataProvider' => $datas_etablissements,
- 'columns' => [
- 'nom',
- [
- 'attribute' => 'date_creation',
- 'format' => 'raw',
- 'value' => function($model) {
- return date('d/m/Y', strtotime($model->date_creation)) ;
- }
- ],
- [
- 'attribute' => 'Lieu',
- 'format' => 'raw',
- 'value' => function($model) {
- return Html::encode($model->ville.' ('.$model->code_postal.')') ;
- }
- ],
- [
- 'attribute' => 'Clients',
- 'format' => 'raw',
- 'value' => function($model) {
- if(!$model->userEtablissement || !count($model->userEtablissement))
- {
- return 'Aucun client' ;
- }
- else {
- $clients = count($model->userEtablissement).' client' ;
- if(count($model->userEtablissement) > 1)
- $clients .= 's' ;
- return $clients ;
- }
-
- }
- ],
- [
- 'attribute' => 'Contact',
- 'format' => 'raw',
- 'value' => function($model) {
- if(!isset($model->user) || (isset($model->user) && count($model->user) == 0))
- {
- return 'Aucun contact' ;
- }
- else {
- foreach($model->user as $u)
- {
- if($u->status == User::STATUS_BOULANGER)
- {
- return Html::encode($u->prenom.' '.$u->nom)
- .'<br />'.Html::encode($u->email)
- .'<br />'.Html::encode($u->telephone) ;
- }
- }
-
- }
- }
- ],
- [
- 'attribute' => 'actif',
- 'format' => 'raw',
- 'value' => function($model) {
- $html = '' ;
- if($model->actif)
- $html .= '<span class="label label-success">En ligne</span>' ;
- else
- $html .= '<span class="label label-danger">Hors-ligne</span>' ;
-
- if(strlen($model->code))
- {
- $html .= ' <span class="glyphicon glyphicon-lock" data-toggle="tooltip" data-placement="bottom" data-original-title="'.Html::encode($model->code).'"></span>' ;
- }
-
- return $html ;
- }
- ],
- [
- 'attribute' => 'Gratuit',
- 'format' => 'raw',
- 'value' => function($model) {
- if($model->gratuit)
- return '<span class="label label-success">Compte gratuit</span>' ;
- else
- return '' ;
- }
- ],
- [
- 'attribute' => 'Facture',
- 'label' => 'Facture mois dernier',
- 'format' => 'raw',
- 'value' => function($model) {
-
- $periode = date('Y-m', strtotime('-1 month')) ;
- $ca = $model->getCA($periode) ;
-
- $html = '' ;
- $html .= 'CA : '.number_format($ca,2).' €<br />' ;
-
- $montant_facturer = $model->getMontantFacturer($periode, $ca) ;
- $facture = $model->getFacture($periode) ;
-
- if($facture)
- {
- $html .= '<span class="label label-success">Facturé</span> <strong>'.number_format($facture->montant_ht,2).' €</strong>' ;
- }
- else {
- if($montant_facturer == 0) {
- $html .= '<span class="label label-default">Gratuit</span>' ;
- }
- else {
- $html .= Html::a('Facturer <strong>'.$model->getMontantFacturer($periode, $ca, true).'</strong>', ['etablissement-admin/facturer','id_etablissement' => $model->id], ['class' => 'btn btn-default']) ;
- }
- }
-
- return $html ;
- }
- ],
- [
- 'attribute' => 'Cours',
- 'label' => 'Mois en cours',
- 'format' => 'raw',
- 'value' => function($model) {
-
- $ca = $model->getCA(date('Y-m')) ;
-
- $html = '' ;
- $html .= 'CA : '.number_format($ca,2).' €<br />' ;
-
- return $html ;
- }
- ],
- ],
- ]); ?>
|