|
- <?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 ;
- }
- ],
- ],
- ]); ?>
|