|
- <?php
-
- use yii\helpers\Html;
- use yii\grid\GridView;
-
- /* @var $this yii\web\View */
- /* @var $dataProvider yii\data\ActiveDataProvider */
-
- $this->title = 'Commandes récurrentes';
- $this->params['breadcrumbs'][] = $this->title;
- ?>
- <div class="commande-auto-index">
-
- <h1><?= Html::encode($this->title) ?> <?= Html::a('Ajouter', ['create'], ['class' => 'btn btn-success']) ?></h1>
-
- <?= 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->nom.' '.$model->user->prenom) ;
- }
- }
- ],
- [
- 'attribute' => 'id_point_vente',
- 'format' => 'raw',
- 'value' => function($model) {
- return Html::encode($model->pointVente->nom) ;
- }
- ],
- [
- 'attribute' => 'produits',
- 'format' => 'raw',
- 'value' => function($model) {
- $html = '' ;
- foreach($model->commandeAutoProduit as $commande_produit)
- {
- $html .= $commande_produit->quantite . ' x '.Html::encode($commande_produit->produit->nom).'<br />' ;
- }
- return $html ;
- }
- ],
- [
- 'attribute' => 'date_debut',
- 'value' => function($model) {
- return date('d/m/Y',strtotime($model->date_debut)) ;
- }
- ],
- [
- 'attribute' => 'date_fin',
- 'value' => function($model) {
- if($model->date_fin)
- return date('d/m/Y',strtotime($model->date_fin)) ;
- else
- return 'indéterminée' ;
- }
- ],
- [
- 'attribute' => 'lundi',
- 'label' => 'Jours',
- 'value' => function($model) {
- $html = '' ;
- if($model->lundi)
- $html .= 'lundi, ' ;
- if($model->mardi)
- $html .= 'mardi, ' ;
- if($model->mercredi)
- $html .= 'mercredi, ' ;
- if($model->jeudi)
- $html .= 'jeudi, ' ;
- if($model->vendredi)
- $html .= 'vendredi, ' ;
- if($model->samedi)
- $html .= 'samedi, ' ;
- if($model->dimanche)
- $html .= 'dimanche, ' ;
-
- if(strlen($html))
- return substr ($html, 0, strlen($html) - 2) ;
- else
- return '' ;
- }
- ],
- [
- 'attribute' => 'periodicite_semaine',
- 'value' => function($model) {
- if($model->periodicite_semaine == 1)
- return 'Toutes les semaines' ;
- else
- return 'Toutes les '.$model->periodicite_semaine.' semaines' ;
- }
- ],
- [
- '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>
|