setTitle('Abonnements') ; $this->addBreadcrumb($this->getTitle()) ; $this->addButton(['label' => 'Nouvel abonnement ', 'url' => 'subscription/create', 'class' => 'btn btn-primary']) ; $subscriptionsArray = Subscription::searchAll() ; ?>
$searchModel, 'dataProvider' => $dataProvider, 'columns' => [ [ 'attribute' => 'username', 'label' => 'Utilisateur', 'format' => 'raw', 'value' => function($model) use ($userModule) { if(strlen($model->username)) { return Html::encode($model->username) ; } else { if(isset($model->user)) { return Html::encode($userModule->getSolver()->getUsername($model->user)) ; } } } ], [ 'attribute' => 'product_name', 'label' => 'Produits', 'format' => 'raw', 'headerOptions' => ['class' => 'column-hide-on-mobile'], 'filterOptions' => ['class' => 'column-hide-on-mobile'], 'contentOptions' => ['class' => 'column-hide-on-mobile'], 'value' => function($model) { $productModule = ProductModule::getInstance(); $html = '' ; foreach($model->productSubscription as $productSubscription) { if(isset($productSubscription->product)) { $html .= Html::encode($productSubscription->product->name).' ('.($productSubscription->quantity * Product::$unitsArray[$productSubscription->product->unit]['coefficient']).' '. $productModule->getSolver()->strUnit($productSubscription->product, 'wording_short').')
' ; } 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' => GlobalParam::getCurrentProducerId(), 'status' => StatusInterface::STATUS_ONLINE])->orderBy('is_bread_box ASC, name ASC')->asArray()->all(), 'id', 'name'), 'value' => function($model) { if($model->pointSale) { return Html::encode($model->pointSale->name) ; } return ''; } ], [ 'attribute' => 'date_begin', 'label' => 'Période', 'format' => 'raw', 'headerOptions' => ['class' => 'column-hide-on-mobile'], 'filterOptions' => ['class' => 'column-hide-on-mobile'], 'contentOptions' => ['class' => 'column-hide-on-mobile'], 'value' => function($model) use ($subscriptionModule) { return $subscriptionModule->getPeriodAsHtml($model); } ], [ 'attribute' => 'day', 'label' => 'Jours', 'format' => 'raw', 'filter' => [ 'monday' => 'Lundi', 'tuesday' => 'Mardi', 'wednesday' => 'Mercredi', 'thursday' => 'Jeudi', 'friday' => 'Vendredi', 'saturday' => 'Samedi', 'sunday' => 'Dimanche', ], 'headerOptions' => ['class' => 'column-hide-on-mobile'], 'filterOptions' => ['class' => 'column-hide-on-mobile'], 'contentOptions' => ['class' => 'text-small column-hide-on-mobile'], 'value' => function($model) use ($subscriptionModule) { return $subscriptionModule->getDaysAsHtml($model); } ], [ 'attribute' => 'week_frequency', 'filter' => [ 1 => 'Toutes les semaines', 2 => 'Toutes les 2 semaines', 3 => 'Toutes les 3 semaines', 4 => 'Tous les mois' ], 'headerOptions' => ['class' => 'column-hide-on-mobile'], 'filterOptions' => ['class' => 'column-hide-on-mobile'], 'contentOptions' => ['class' => 'column-hide-on-mobile'], 'value' => function($model) use ($subscriptionModule) { return $subscriptionModule->getSolver()->getWeekFrequencyAsString($model); } ], [ 'attribute' => 'auto_payment', 'format' => 'raw', 'label' => 'Débit automatique', 'headerOptions' => ['class' => 'column-auto-payment column-hide-on-mobile'], 'filterOptions' => ['class' => 'column-hide-on-mobile'], 'contentOptions' => ['class' => 'column-auto-payment column-hide-on-mobile'], 'filter' => [0 => 'Non', 1 => 'Oui'], 'value' => function($model) { if($model->auto_payment == Subscription::AUTO_PAYMENT_DEDUCTED) { return 'Déduit' ; } elseif($model->auto_payment == Subscription::AUTO_PAYMENT_YES) { 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' => 'Modifier', 'class' => 'btn btn-default' ]); }, 'delete' => function ($url, $model) { return Html::a('', $url, [ 'title' => 'Supprimer', 'class' => 'btn btn-default' ]); } ], ], ], ]); ?>