Browse Source

[Administration] Distributions > commandes : mise en évidence "crédit obligatoire" de l'utilisateur #1246

feature/souke
Guillaume Bourgeois 1 year ago
parent
commit
0b1479c491
4 changed files with 24 additions and 20 deletions
  1. +1
    -0
      backend/controllers/DistributionController.php
  2. +3
    -7
      backend/views/distribution/index.php
  3. +7
    -13
      common/logic/User/User/Repository/UserRepository.php
  4. +13
    -0
      common/logic/User/User/Service/UserSolver.php

+ 1
- 0
backend/controllers/DistributionController.php View File

$arrayCreditUser = []; $arrayCreditUser = [];
if(isset($order->user)) { if(isset($order->user)) {
$arrayCreditUser['credit'] = $userManager->getCredit($order->user); $arrayCreditUser['credit'] = $userManager->getCredit($order->user);
$arrayCreditUser['credit_active'] = $userManager->getCreditActive($order->user);
} }


$oneProductUnactivated = false; $oneProductUnactivated = false;

+ 3
- 7
backend/views/distribution/index.php View File

{{ order.user.lastname+' '+order.user.name }} {{ order.user.lastname+' '+order.user.name }}
</template> </template>
<span class="shortcuts btn-group" role="group"> <span class="shortcuts btn-group" role="group">
<a class="btn btn-default btn-sm" :href="baseUrl+'/user/credit?id='+order.id_user" data-toggle="popover" data-trigger="hover" data-placement="bottom" :data-content="order.user.credit.toFixed(2)+' €'"><span class="glyphicon glyphicon-euro"></span></a>
<a :class="order.user.credit_active ? 'btn btn-success btn-sm' : 'btn btn-default btn-sm'" :href="baseUrl+'/user/credit?id='+order.id_user" data-toggle="popover" data-trigger="hover" data-placement="bottom" :data-content="order.user.credit.toFixed(2)+' €'"><span class="glyphicon glyphicon-euro"></span></a>
<a class="btn btn-default btn-sm" :href="baseUrl+'/user/update?id='+order.id_user" data-toggle="popover" data-trigger="hover" data-placement="bottom" data-content="Modifier"><span class="glyphicon glyphicon-user"></span></a> <a class="btn btn-default btn-sm" :href="baseUrl+'/user/update?id='+order.id_user" data-toggle="popover" data-trigger="hover" data-placement="bottom" data-content="Modifier"><span class="glyphicon glyphicon-user"></span></a>
<a class="btn btn-default btn-sm" :href="baseUrl+'/user/orders?id='+order.id_user" data-toggle="popover" data-trigger="hover" data-placement="bottom" data-content="Voir les commandes"><span class="glyphicon glyphicon-eye-open"></span></a> <a class="btn btn-default btn-sm" :href="baseUrl+'/user/orders?id='+order.id_user" data-toggle="popover" data-trigger="hover" data-placement="bottom" data-content="Voir les commandes"><span class="glyphicon glyphicon-eye-open"></span></a>
</span> </span>
<table class="table table-condensed table-bordered table-hover" v-if="order.paymentsArray && order.paymentsArray.length > 0"> <table class="table table-condensed table-bordered table-hover" v-if="order.paymentsArray && order.paymentsArray.length > 0">
<thead> <thead>
<tr> <tr>
<!--<td>Utilisateur</td>
<td>Action</td>
<td>Origine action</td>-->
<td>Date</td> <td>Date</td>
<td>Origine action</td>
<td>Type</td> <td>Type</td>
<td>Moyen</td> <td>Moyen</td>
<td>Montant</td> <td>Montant</td>
</thead> </thead>
<tbody> <tbody>
<tr v-for="payment in order.paymentsArray"> <tr v-for="payment in order.paymentsArray">
<!--<td>{{ payment.user }}</td>
<td v-html="payment.wording"></td>
<td>{{ payment.user_action }}</td>-->
<td>{{ payment.date }}</td> <td>{{ payment.date }}</td>
<td>{{ payment.user_action }}</td>
<td>{{ payment.wording_type }}</td> <td>{{ payment.wording_type }}</td>
<td>{{ payment.wording_mean_payment }}</td> <td>{{ payment.wording_mean_payment }}</td>
<td v-html="payment.amount"></td> <td v-html="payment.amount"></td>

+ 7
- 13
common/logic/User/User/Repository/UserRepository.php View File

*/ */
public function getCredit(User $user): float public function getCredit(User $user): float
{ {
// @TODO : optimisation à refactorer
$userProducer = null;
$producerId = $this->getProducerContextId();
foreach($user->userProducer as $userProducerRelation) {
if($userProducerRelation->id_producer == $producerId) {
$userProducer = $userProducerRelation;
}
}

if(!$userProducer) {
$userProducer = $this->userProducerRepository->findOneUserProducer($user);
}

$userProducer = $this->userSolver->getUserProducer($user);
return $userProducer ? $userProducer->credit : 0; return $userProducer ? $userProducer->credit : 0;
} }


public function getCreditActive(User $user): bool
{
$userProducer = $this->userSolver->getUserProducer($user);
return $userProducer ? $userProducer->credit_active : false;
}

/** /**
* Recherche des utilisateurs suivant les paramètres : id_etablissement, * Recherche des utilisateurs suivant les paramètres : id_etablissement,
* inactifs, id_point_vente, nom, prenom, email, telephone. * inactifs, id_point_vente, nom, prenom, email, telephone.

+ 13
- 0
common/logic/User/User/Service/UserSolver.php View File

use common\logic\SolverInterface; use common\logic\SolverInterface;
use common\logic\User\User\Model\User; use common\logic\User\User\Model\User;
use common\logic\User\UserGroup\Model\UserGroup; use common\logic\User\UserGroup\Model\UserGroup;
use common\logic\User\UserProducer\Model\UserProducer;
use common\logic\User\UserUserGroup\Model\UserUserGroup; use common\logic\User\UserUserGroup\Model\UserUserGroup;


class UserSolver extends AbstractService implements SolverInterface class UserSolver extends AbstractService implements SolverInterface
return false; return false;
} }


public function getUserProducer(User $user): ?UserProducer
{
$userProducer = null;
$producerId = $this->getProducerContextId();
foreach($user->userProducer as $userProducerRelation) {
if($userProducerRelation->id_producer == $producerId) {
$userProducer = $userProducerRelation;
}
}
return $userProducer;
}

} }

Loading…
Cancel
Save