setTitle('Abonnements') ; $this->addBreadcrumb($this->getTitle()) ; $this->addButton(['label' => '+', 'url' => 'subscription/create', 'class' => 'btn btn-success']) ; ?>
$searchModel, 'dataProvider' => $dataProvider, 'columns' => [ [ 'attribute' => 'username', 'label' => 'Utilisateur', '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' => 'product_name', 'label' => 'Produits', 'format' => 'raw', 'value' => function($model) { $html = '' ; foreach($model->productSubscription as $productSubscription) { if(isset($productSubscription->product)) { $html .= $productSubscription->quantity . ' x '.Html::encode($productSubscription->product->name).'
' ; } else { $html .= 'Produit non défini
' ; } } // aucun produit if(!count($model->productSubscription)) { $html .= ' Aucun produit' ; } return $html ; } ], [ 'attribute' => 'id_point_sale', 'label' => 'Point de vente', 'format' => 'raw', 'filter' => ArrayHelper::map(PointSale::find()->where(['id_producer' => Producer::getId()])->asArray()->all(), 'id', 'name'), 'value' => function($model) { return Html::encode($model->pointSale->name) ; } ], [ 'attribute' => 'date_begin', 'label' => 'Date de début', 'format' => 'raw', 'value' => function($model) { $html = date('d/m/Y',strtotime($model->date_begin)) ; return $html ; } ], [ 'attribute' => 'day', 'label' => 'Jours', 'format' => 'raw', 'filter' => [ 'monday' => 'Lundi', 'tuesday' => 'Mardi', 'wednesday' => 'Mercredi', 'thursday' => 'Jeudi', 'friday' => 'Vendredi', 'saterday' => 'Samedi', 'sunday' => 'Dimanche', ], 'contentOptions' => ['class' => 'text-small'], '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 ' Aucun jour' ; } } ], [ 'attribute' => 'week_frequency', 'filter' => [ 1 => 'Toutes les semaines', 2 => 'Toutes les 2 semaines', 3 => 'Toutes les 3 semaines', 4 => 'Tous les mois'], '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', 'label' => 'Paiement automatique', 'headerOptions' => ['class' => 'column-auto-payment'], 'contentOptions' => ['class' => 'column-auto-payment'], 'filter' => [0 => 'Non', 1 => 'Oui'], 'value' => function($model) { if($model->auto_payment) { return 'Oui' ; } else { return 'Non' ; } } ], [ 'class' => 'yii\grid\ActionColumn', 'template' => '{update} {delete}', 'headerOptions' => ['class' => 'column-actions'], 'contentOptions' => ['class' => 'column-actions'], 'buttons' => [ 'update' => function ($url, $model) { return Html::a('', $url, [ 'title' => Yii::t('app', 'Modifier'), 'class' => 'btn btn-default' ]); }, 'delete' => function ($url, $model) { return Html::a('', $url, [ 'title' => Yii::t('app', 'Supprimer'), 'class' => 'btn btn-default' ]); } ], ], ], ]); ?>