瀏覽代碼

[Administration] Utilisateurs > récapitulatif : ajout abonnements

feature/rotating_product
Guillaume Bourgeois 6 月之前
父節點
當前提交
af3216fbec
共有 7 個檔案被更改,包括 73 行新增15 行删除
  1. +0
    -1
      backend/controllers/SubscriptionController.php
  2. +2
    -1
      backend/controllers/UserController.php
  3. +2
    -8
      backend/views/subscription/index.php
  4. +51
    -2
      backend/views/user/view.php
  5. +7
    -2
      domain/Subscription/Subscription/SubscriptionRepository.php
  6. +1
    -1
      domain/Subscription/Subscription/SubscriptionSearch.php
  7. +10
    -0
      domain/Subscription/Subscription/SubscriptionSolver.php

+ 0
- 1
backend/controllers/SubscriptionController.php 查看文件

@@ -155,7 +155,6 @@ class SubscriptionController extends BackendController
$productSubscriptionModule = $this->getProductSubscriptionModule();
$productModule = $this->getProductModule();
$distributionModule = $this-> getDistributionModule();
$orderModule = $this->getOrderModule();

$model = new SubscriptionForm;
$model->isAdmin = true;

+ 2
- 1
backend/controllers/UserController.php 查看文件

@@ -193,7 +193,8 @@ class UserController extends BackendController

return $this->render('view', [
'model' => $model,
'pointSaleBillingArray' => $pointSaleModule->findByBillingUser($model)
'pointSaleBillingArray' => $pointSaleModule->findByBillingUser($model),
'subscriptionsArray' => $this->getSubscriptionModule()->getRepository()->findSubscriptionsByUser($model)
]);
}


+ 2
- 8
backend/views/subscription/index.php 查看文件

@@ -160,14 +160,8 @@ $subscriptionsArray = Subscription::searchAll() ;
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'value' => function($model) {
if($model->week_frequency == 1) {
return 'Toutes les semaines' ;
}
else {
return 'Toutes les '.$model->week_frequency.' semaines' ;
}
'value' => function($model) use ($subscriptionModule) {
return $subscriptionModule->getSolver()->getWeekFrequencyAsString($model);
}
],
[

+ 51
- 2
backend/views/user/view.php 查看文件

@@ -39,6 +39,7 @@ termes.
use common\helpers\GlobalParam;
use common\helpers\Price;
use domain\Order\Order\OrderModule;
use domain\Subscription\Subscription\SubscriptionModule;
use domain\User\User\UserModule;
use domain\User\UserProducer\UserProducerModule;
use yii\helpers\Html;
@@ -48,8 +49,10 @@ $userCurrent = GlobalParam::getCurrentUser();
$orderModule = OrderModule::getInstance();
$userModule = UserModule::getInstance();
$userProducerModule = UserProducerModule::getInstance();
$subscriptionModule = SubscriptionModule::getInstance();
$userProducer = $userProducerModule->findOneUserProducer($model);
$username = Html::encode($userModule->getSolver()->getUsername($model));
$producer = GlobalParam::getCurrentProducer();
$this->setTitle($username.' (#'.$model->id.')') ;
$this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]) ;
$this->addBreadcrumb(['label' => $username]) ;
@@ -141,7 +144,9 @@ $this->addBreadcrumb('Récapitulatif') ;
<strong>Points de vente</strong>
<span class="pull-right">
<?php foreach($model->userPointSale as $userPointSale): ?>
<span class="label label-default"><?= $userPointSale->pointSale->name; ?></span>
<?php if($userPointSale->pointSale->id_producer == $producer->id): ?>
<span class="label label-default"><?= $userPointSale->pointSale->name; ?></span>
<?php endif; ?>
<?php endforeach; ?>
</span>
</li>
@@ -298,7 +303,6 @@ $this->addBreadcrumb('Récapitulatif') ;
</h3>
</div>
<div class="panel-body">

<?php $countOrders = $orderModule->getRepository()->countOrdersByUser($model); ?>
<?php if($countOrders): ?>
<ul class="list-group list-group-unbordered">
@@ -323,6 +327,51 @@ $this->addBreadcrumb('Récapitulatif') ;
</div>
</div>

<?php $hasSubscription = $subscriptionsArray && count($subscriptionsArray); ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<i class="glyphicon glyphicon-repeat"></i>
Abonnements
<?php if($hasSubscription): ?>
<a class="btn btn-default btn-xs" href="<?= Yii::$app->urlManager->createUrl(['subscription/index','SubscriptionSearch[id_user]' => $model->id]) ?>">
<span class="glyphicon glyphicon-eye-open"></span>
Voir
</a>
<?php else: ?>
<a class="btn btn-default btn-xs" href="<?= Yii::$app->urlManager->createUrl(['subscription/create']) ?>">
<span class="glyphicon glyphicon-plus"></span>
Créer
</a>
<?php endif; ?>
</h3>
</div>
<div class="panel-body">
<?php if($hasSubscription): ?>
<ul class="list-group list-group-unbordered">
<?php foreach($subscriptionsArray as $subscription): ?>
<li class="list-group-item">
<span class="pull-right">
<?= $subscriptionModule->getSolver()->getProductsListAsHtml($subscription) ?>
</span>

<strong><?= $subscriptionModule->getSolver()->getDaysAsHtml($subscription) ?></strong>
(<?= strtolower($subscriptionModule->getSolver()->getWeekFrequencyAsString($subscription)) ?>)<br />
<?= Html::encode($subscription->pointSale->name); ?><br />
<?= $subscriptionModule->getSolver()->getPeriodAsHtml($subscription) ?>

<div class="clr"></div>
</li>
<?php endforeach; ?>
</ul>
<?php else: ?>
<div class="alert alert-info">
Aucun abonnement
</div>
<?php endif; ?>
</div>
</div>

<?php if(isset($pointSaleBillingArray) && $pointSaleBillingArray && count($pointSaleBillingArray) > 0): ?>
<div class="panel panel-default">
<div class="panel-heading">

+ 7
- 2
domain/Subscription/Subscription/SubscriptionRepository.php 查看文件

@@ -58,11 +58,16 @@ class SubscriptionRepository extends AbstractRepository
return $subscriptionReturnArray;
}

public function countSubscriptionsByUser(User $user)
public function findSubscriptionsByUser(User $user)
{
return $this->createDefaultQuery()
->filterByUser($user)
->count();
->find();
}

public function countSubscriptionsByUser(User $user)
{
return count($this->findSubscriptionsByUser($user));
}

public function findSubscriptionsLatestAdded()

+ 1
- 1
domain/Subscription/Subscription/SubscriptionSearch.php 查看文件

@@ -49,7 +49,7 @@ class SubscriptionSearch extends Subscription
public function rules()
{
return [
[['id_point_sale', 'week_frequency'], 'integer'],
[['id_user', 'id_point_sale', 'week_frequency'], 'integer'],
[['auto_payment'], 'boolean'],
[['date_begin', 'username','product_name', 'day'], 'safe'],
];

+ 10
- 0
domain/Subscription/Subscription/SubscriptionSolver.php 查看文件

@@ -148,4 +148,14 @@ class SubscriptionSolver extends AbstractService implements SolverInterface
return '<span class="glyphicon glyphicon-warning-sign"></span> Aucun jour' ;
}
}

public function getWeekFrequencyAsString(Subscription $subscription): string
{
if($subscription->week_frequency == 1) {
return 'Toutes les semaines' ;
}
else {
return 'Toutes les '.$subscription->week_frequency.' semaines' ;
}
}
}

Loading…
取消
儲存