= GridView::widget([
'dataProvider' => $dataProviderFeatures,
'columns' => [
[
'attribute' => 'position',
'headerOptions' => ['class' => 'position'],
'format' => 'raw',
'filter' => '',
'value' => function ($model) {
return '
';
}
],
'name',
[
'attribute' => 'status',
'headerOptions' => ['class' => 'status column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'center column-hide-on-mobile'],
'format' => 'raw',
'filter' => [0 => 'Désactivée', 1 => 'Activée'],
'value' => function ($model) {
return Toggle::widget(
[
'name' => 'active',
'checked' => $model->status,
'options' => [
'data-id' => $model->id,
'data-on' => 'Activée',
'data-off' => 'Désactivée',
],
]
);
}
],
[
'attribute' => 'producers',
'label' => 'Producteurs',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'format' => 'raw',
'value' => function ($model) {
$html = '';
foreach($model->featureProducers as $featureProducer) {
if(!is_null($featureProducer->status)) {
$html .= feature_status_producer($featureProducer->producer->name, $featureProducer->status);
}
}
return $html;
}
],
[
'attribute' => 'only_for_selected_producers',
'label' => "Producteurs sélectionnés",
'headerOptions' => ['class' => 'only-for-selected-producers column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'only-for-selected-producers column-hide-on-mobile'],
'format' => 'raw',
'value' => function ($model) {
return '
'
.($model->only_for_selected_producers ? 'Oui' : 'Non') .'';
}
],
[
'attribute' => 'is_paid_feature',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'format' => 'raw',
'value' => function ($model) {
return '
'
.($model->is_paid_feature ? 'Oui' : 'Non') .'';
}
],
[
'attribute' => 'price',
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'format' => 'raw',
'value' => function ($model) {
if($model->is_paid_feature && $model->price) {
return Price::format($model->price, 0);
}
return '';
}
],
[
'class' => 'yii\grid\ActionColumn',
'template' => '{toggle_status_feature_producer} {update}',
'headerOptions' => ['class' => 'column-actions'],
'contentOptions' => ['class' => 'column-actions'],
'buttons' => [
'toggle_status_feature_producer' => function ($url, $model) use ($producerCurrent) {
return '
';
},
'update' => function ($url, $model) {
return Html::a('
', $url, [
'title' => 'Modifier', 'class' => 'btn btn-default'
]);
},
],
],
]
]);
?>
'.Html::encode($producerName).' ';
}
?>