|
- <?php
-
-
-
- use yii\helpers\Html;
- use yii\grid\GridView;
-
-
- $this->setTitle('Abonnements') ;
- $this->addBreadcrumb($this->getTitle()) ;
- $this->addButton(['label' => '+', 'url' => 'subscription/create', 'class' => 'btn btn-success']) ;
-
- ?>
- <div class="subscription-index">
-
- <?= GridView::widget([
- 'dataProvider' => $dataProvider,
- 'columns' => [
- [
- 'attribute' => 'id_user',
- 'format' => 'raw',
- 'value' => function($model) {
- if(strlen($model->username))
- {
- return Html::encode($model->username) ;
- }
- else {
- if(isset($model->user)) {
- return Html::encode($model->user->lastname.' '.$model->user->name) ;
- }
- }
- }
- ],
- [
- 'attribute' => 'id_point_sale',
- 'format' => 'raw',
- 'value' => function($model) {
- return Html::encode($model->pointSale->name) ;
- }
- ],
- [
- 'attribute' => 'products',
- 'format' => 'raw',
- 'value' => function($model) {
- $html = '' ;
- foreach($model->productSubscription as $productSubscription)
- {
- if(isset($productSubscription->product)) {
- $html .= $productSubscription->quantity . ' x '.Html::encode($productSubscription->product->name).'<br />' ;
- }
- else {
- $html .= 'Produit non défini<br />' ;
- }
- }
-
-
- if(!count($model->productSubscription))
- {
- $html .= '<span class="glyphicon glyphicon-warning-sign"></span> Aucun produit' ;
- }
-
- return $html ;
- }
- ],
- [
- 'attribute' => 'date_begin',
- 'value' => function($model) {
- return date('d/m/Y',strtotime($model->date_begin)) ;
- }
- ],
- [
- 'attribute' => 'date_end',
- 'value' => function($model) {
- if($model->date_end)
- return date('d/m/Y',strtotime($model->date_end)) ;
- else
- return 'indéterminée' ;
- }
- ],
- [
- 'attribute' => 'monday',
- 'label' => 'Jours',
- 'format' => 'raw',
- 'value' => function($model) {
- $html = '' ;
- if($model->monday)
- $html .= 'lundi, ' ;
- if($model->tuesday)
- $html .= 'mardi, ' ;
- if($model->wednesday)
- $html .= 'mercredi, ' ;
- if($model->thursday)
- $html .= 'jeudi, ' ;
- if($model->friday)
- $html .= 'vendredi, ' ;
- if($model->saturday)
- $html .= 'samedi, ' ;
- if($model->sunday)
- $html .= 'dimanche, ' ;
-
- if(strlen($html))
- return substr ($html, 0, strlen($html) - 2) ;
- else
- return '<span class="glyphicon glyphicon-warning-sign"></span> Aucun jour' ;
- }
- ],
- [
- 'attribute' => 'week_frequency',
- 'value' => function($model) {
- if($model->week_frequency == 1)
- return 'Toutes les semaines' ;
- else
- return 'Toutes les '.$model->week_frequency.' semaines' ;
- }
- ],
- [
- 'attribute' => 'auto_payment',
- 'format' => 'raw',
- 'value' => function($model) {
- if($model->auto_payment)
- return '<span class="label label-success">Oui</span>' ;
- else
- return '<span class="label label-danger">Non</span>' ;
- }
- ],
- [
- 'class' => 'yii\grid\ActionColumn',
- 'template' => '{update} {delete}',
- 'headerOptions' => ['class' => 'actions'],
- 'buttons' => [
- 'update' => function ($url, $model) {
- return Html::a('<span class="glyphicon glyphicon-pencil"></span> Modifier', $url, [
- 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default'
- ]);
- },
- 'delete' => function ($url, $model) {
- return Html::a('<span class="glyphicon glyphicon-trash"></span> Suprimer', $url, [
- 'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default'
- ]);
- }
- ],
- ],
- ],
- ]); ?>
- </div>
|