title = 'Boulangeries';
$this->params['breadcrumbs'][] = 'Administration' ;
$this->params['breadcrumbs'][] = $this->title;
?>
Boulangeries
= 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)
.'
'.Html::encode($u->email)
.'
'.Html::encode($u->telephone) ;
}
}
}
}
],
[
'attribute' => 'actif',
'format' => 'raw',
'value' => function($model) {
$html = '' ;
if($model->actif)
$html .= 'En ligne' ;
else
$html .= 'Hors-ligne' ;
if(strlen($model->code))
{
$html .= ' ' ;
}
return $html ;
}
],
[
'attribute' => 'Gratuit',
'format' => 'raw',
'value' => function($model) {
if($model->gratuit)
return 'Compte gratuit' ;
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).' €
' ;
$montant_facturer = $model->getMontantFacturer($periode, $ca) ;
$facture = $model->getFacture($periode) ;
if($facture)
{
$html .= 'Facturé '.number_format($facture->montant_ht,2).' €' ;
}
else {
if($montant_facturer == 0) {
$html .= 'Gratuit' ;
}
else {
$html .= Html::a('Facturer '.$model->getMontantFacturer($periode, $ca, true).'', ['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).' €
' ;
return $html ;
}
],
],
]); ?>