- <?php
-
-
-
- use yii\helpers\Html;
- use yii\grid\GridView;
- use common\models\User ;
- use common\models\Producer ;
-
- $this->setTitle('Producteurs') ;
- $this->addBreadcrumb($this->getTitle()) ;
-
- ?>
-
- <?= GridView::widget([
- 'dataProvider' => $dataProviderProducer,
- 'columns' => [
- 'name',
- [
- '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->city.' ('.$model->postcode.')') ;
- }
- ],
- [
- 'attribute' => 'Utilisateurs',
- 'format' => 'raw',
- 'value' => function($model) {
- if(!$model->userProducer || !count($model->userProducer))
- {
- return 'Aucun utilisateur' ;
- }
- else {
- $users = count($model->userProducer).' client' ;
- if(count($model->userProducer) > 1) {
- $users .= 's' ;
- }
- return $users ;
- }
-
- }
- ],
- [
- '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_PRODUCER)
- {
- return Html::encode($u->lastname.' '.$u->name)
- .'<br />'.Html::encode($u->email)
- .'<br />'.Html::encode($u->phone) ;
- }
- }
-
- }
- }
- ],
- [
- 'attribute' => 'active',
- 'format' => 'raw',
- 'value' => function($model) {
- $html = '' ;
- if($model->active) {
- $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' => 'Prix libre',
- 'label' => 'Prix libre',
- 'format' => 'raw',
- 'value' => function($model) {
- if(is_null($model->free_price)) {
- return '' ;
- }
- else {
- return $model->getFreePrice() ;
- }
-
- }
- ],
- [
- 'attribute' => 'Cours',
- 'label' => 'CA mois en cours',
- 'format' => 'raw',
- 'value' => function($model) {
- $turnover = $model->getTurnover(date('Y-m')) ;
- return 'CA : '.number_format($turnover,2).' €<br />' ;
- }
- ],
- ],
- ]); ?>
|