|
- <?php
-
-
-
- use domain\Feature\Feature\Feature;
- use domain\PointSale\UserPointSale\UserPointSale;
- use domain\Producer\Producer\Producer;
- use yii\grid\GridView;
- use yii\helpers\Html;
-
- $pointSaleModule = $this->getPointSaleModule();
- $sharedPointSaleModule = $this->getSharedPointSaleModule();
- $featureChecker = $this->getFeatureModule()->getChecker();
-
- $this->setTitle('Points de vente');
- $this->addBreadcrumb($this->getTitle());
- $this->addButton(
- [
- 'label' => 'Nouveau point de vente <span class="glyphicon glyphicon-plus"></span>',
- 'url' => 'point-sale/create',
- 'class' => 'btn btn-primary'
- ]
- );
-
- ?>
-
- <div class="point-sale-index">
- <?= GridView::widget([
- 'filterModel' => $searchModel,
- 'dataProvider' => $dataProvider,
- 'columns' => [
- [
- 'attribute' => 'name',
- 'label' => 'Nom',
- 'format' => 'raw',
- 'contentOptions' => ['class' => 'column-name'],
- 'value' => function ($model) use ($featureChecker, $sharedPointSaleModule) {
- $html = '';
- $html .= '<div class="name">';
- $html .= $model->name;
- if ($model->is_bread_box) {
- $html .= ' <span class="label label-default">Boîte à pain</span> ';
- }
- $html .= '</div>';
-
- if($featureChecker->isEnabled(Feature::ALIAS_SHARED_POINT_SALE)) {
- if($sharedPointSaleModule->getResolver()->countPointsSaleSharedWithPointSale($model)) {
- $html .= '<div class="shared-point-sale-producers"><small><span class="fa fa-share-alt"></span> ';
- $html .= $sharedPointSaleModule->getResolver()->getProducersSharingPointSaleAsString($model);
- $html .= '</small></div>';
- }
- }
-
- return $html;
- }
- ],
- [
- 'attribute' => 'locality',
- 'headerOptions' => ['class' => 'column-hide-on-mobile'],
- 'filterOptions' => ['class' => 'column-hide-on-mobile'],
- 'contentOptions' => ['class' => 'column-hide-on-mobile'],
- ],
- [
- 'attribute' => 'delivery',
- 'label' => 'Livraison',
- 'filter' => [
- 'monday' => 'Lundi',
- 'tuesday' => 'Mardi',
- 'wednesday' => 'Mercredi',
- 'thursday' => 'Jeudi',
- 'friday' => 'Vendredi',
- 'saturday' => 'Samedi',
- 'sunday' => 'Dimanche',
- ],
- 'value' => function ($model) use ($pointSaleModule) {
- return $pointSaleModule->getStrDeliveryDays($model);
- }
- ],
- [
- 'attribute' => 'access_type',
- 'label' => 'Accès',
- 'filter' => [
- 'open' => 'Ouvert',
- 'code' => 'Code',
- 'restricted_access' => 'Accès restreint'
- ],
- 'format' => 'raw',
- 'headerOptions' => ['class' => 'column-hide-on-mobile'],
- 'filterOptions' => ['class' => 'column-hide-on-mobile'],
- 'contentOptions' => ['class' => 'column-hide-on-mobile'],
- 'value' => function ($model) {
- $count = UserPointSale::find()->where(
- ['id_point_sale' => $model->id]
- )->count();
- $html = '';
- if ($model->restricted_access) {
- $html .= '<span class="glyphicon glyphicon-lock"></span> ';
- if ($count == 1) {
- $html .= '1 utilisateur';
- } else {
- $html .= $count . ' utilisateurs';
- }
- }
-
- if (strlen($model->code)) {
- if (strlen($html)) {
- $html .= '<br />';
- }
- $html .= 'Code : <strong>' . Html::encode(
- $model->code
- ) . '</strong>';
- }
-
- return $html;
- }
- ],
- [
- 'label' => 'Modes de paiement',
- 'format' => 'raw',
- 'headerOptions' => ['class' => 'column-hide-on-mobile'],
- 'filterOptions' => ['class' => 'column-hide-on-mobile'],
- 'contentOptions' => ['class' => 'column-hide-on-mobile column-payment-method'],
- 'value' => function ($model) {
- $html = '<ul>';
- if($model->payment_method_onsite) {
- $html .= '<li><i class="bi bi-wallet2"></i> Sur place</li>';
- }
- if ($model->payment_method_credit && isset(Producer::$creditFunctioningArray[$model->credit_functioning])) {
- $html .= '<li><i class="bi bi-piggy-bank"></i> Cagnotte ('. strtolower(Producer::$creditFunctioningArray[$model->credit_functioning]).')</li>';
- }
- if ($model->payment_method_online) {
- $html .= '<li><i class="bi bi-credit-card"></i> Paiement en ligne</li>';
- }
- $html .= '</ul>';
- return $html;
- }
- ],
- [
- 'attribute' => 'default',
- 'label' => 'Par défaut',
- 'format' => 'raw',
- 'headerOptions' => ['class' => 'column-hide-on-mobile'],
- 'filterOptions' => ['class' => 'column-hide-on-mobile'],
- 'contentOptions' => ['class' => 'td-default column-hide-on-mobile'],
- 'value' => function ($model) {
- if ($model->default) {
- return Html::a(
- '<span class="glyphicon glyphicon-star"></span>',
- ['point-sale/default', 'id' => $model->id],
- [
- 'title' => 'Point de vente par défaut',
- 'class' => 'btn btn-default'
- ]
- );
- } else {
- return Html::a(
- '<span class="glyphicon glyphicon-star-empty"></span>',
- ['point-sale/default', 'id' => $model->id],
- [
- 'title' => 'Point de vente par défaut',
- 'class' => 'btn btn-default'
- ]
- );
- }
- }
- ],
- [
-
- 'visible' => false,
- 'label' => 'Partages',
- 'format' => 'raw',
- 'headerOptions' => ['class' => 'column-hide-on-mobile'],
- 'filterOptions' => ['class' => 'column-hide-on-mobile'],
- 'contentOptions' => ['class' => 'td-shared-point-sale column-hide-on-mobile'],
- 'value' => function ($pointSale) use ($sharedPointSaleModule) {
- $countPointsSaleSharedWithPointSale = $sharedPointSaleModule->getResolver()->countPointsSaleSharedWithPointSale($pointSale);
- return '<a class="btn btn-'.($countPointsSaleSharedWithPointSale ? 'success' : 'default').'" href="'.Yii::$app->urlManager->createUrl(['shared-point-sale/index']).'" title="'.$sharedPointSaleModule->getResolver()->getProducersSharingPointSaleAsString($pointSale, null, '
').'">'.$countPointsSaleSharedWithPointSale.' <span class="fa fa-share-alt"></span></a>';
- }
- ],
- [
- 'class' => 'yii\grid\ActionColumn',
- 'template' => '{update} {delete}',
- 'headerOptions' => ['class' => 'column-actions'],
- 'contentOptions' => ['class' => 'column-actions'],
- 'buttons' => [
- 'update' => function ($url, $model) {
- return Html::a(
- '<span class="glyphicon glyphicon-pencil"></span>',
- $url,
- [
- 'title' => 'Modifier',
- 'class' => 'btn btn-default'
- ]
- );
- },
- 'delete' => function ($url, $model) {
- return Html::a(
- '<span class="glyphicon glyphicon-trash"></span>',
- $url,
- [
- 'title' => 'Supprimer',
- 'class' => 'btn btn-default'
- ]
- );
- }
- ],
- ],
- ],
- ]); ?>
- </div>
|