@@ -346,6 +346,7 @@ class DistributionController extends BackendController | |||
$arrayCreditUser = []; | |||
if(isset($order->user)) { | |||
$arrayCreditUser['credit'] = $userManager->getCredit($order->user); | |||
$arrayCreditUser['credit_active'] = $userManager->getCreditActive($order->user); | |||
} | |||
$oneProductUnactivated = false; |
@@ -367,7 +367,7 @@ $this->setPageTitle('Distributions') ; | |||
{{ order.user.lastname+' '+order.user.name }} | |||
</template> | |||
<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/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> | |||
@@ -572,10 +572,8 @@ $this->setPageTitle('Distributions') ; | |||
<table class="table table-condensed table-bordered table-hover" v-if="order.paymentsArray && order.paymentsArray.length > 0"> | |||
<thead> | |||
<tr> | |||
<!--<td>Utilisateur</td> | |||
<td>Action</td> | |||
<td>Origine action</td>--> | |||
<td>Date</td> | |||
<td>Origine action</td> | |||
<td>Type</td> | |||
<td>Moyen</td> | |||
<td>Montant</td> | |||
@@ -583,10 +581,8 @@ $this->setPageTitle('Distributions') ; | |||
</thead> | |||
<tbody> | |||
<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.user_action }}</td> | |||
<td>{{ payment.wording_type }}</td> | |||
<td>{{ payment.wording_mean_payment }}</td> | |||
<td v-html="payment.amount"></td> |
@@ -69,22 +69,16 @@ class UserRepository extends AbstractRepository | |||
*/ | |||
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; | |||
} | |||
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, | |||
* inactifs, id_point_vente, nom, prenom, email, telephone. |
@@ -6,6 +6,7 @@ use common\logic\AbstractService; | |||
use common\logic\SolverInterface; | |||
use common\logic\User\User\Model\User; | |||
use common\logic\User\UserGroup\Model\UserGroup; | |||
use common\logic\User\UserProducer\Model\UserProducer; | |||
use common\logic\User\UserUserGroup\Model\UserUserGroup; | |||
class UserSolver extends AbstractService implements SolverInterface | |||
@@ -231,4 +232,16 @@ class UserSolver extends AbstractService implements SolverInterface | |||
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; | |||
} | |||
} |