Browse Source

[Administration] Compte démo : cacher données personnelles

feature/rotating_product
Guillaume Bourgeois 5 months ago
parent
commit
d24bd599f0
22 changed files with 204 additions and 115 deletions
  1. +12
    -23
      backend/controllers/CommunicateController.php
  2. +13
    -3
      backend/controllers/DistributionController.php
  3. +1
    -1
      backend/controllers/OrderController.php
  4. +3
    -0
      backend/controllers/ReportController.php
  5. +6
    -2
      backend/controllers/UserController.php
  6. +1
    -1
      backend/views/access/index.php
  7. +5
    -20
      backend/views/distribution/index.php
  8. +1
    -1
      backend/views/report/index.php
  9. +4
    -3
      backend/views/subscription/index.php
  10. +2
    -2
      backend/views/user/credit.php
  11. +22
    -12
      backend/views/user/index.php
  12. +3
    -3
      backend/views/user/view.php
  13. +42
    -0
      common/components/Faker.php
  14. +3
    -0
      common/config/main.php
  15. +3
    -0
      domain/Distribution/Distribution/Export/DistributionReportPdfGenerator.php
  16. +1
    -5
      domain/Order/Order/OrderSolver.php
  17. +1
    -11
      domain/Payment/PaymentSolver.php
  18. +9
    -0
      domain/Producer/Producer/Producer.php
  19. +0
    -12
      domain/Producer/Producer/ProducerSolver.php
  20. +70
    -14
      domain/User/User/UserSolver.php
  21. +1
    -1
      frontend/views/site/producer.php
  22. +1
    -1
      producer/views/order/confirm.php

+ 12
- 23
backend/controllers/CommunicateController.php View File

$usersArray = []; $usersArray = [];
foreach ($users as $key => $user) { foreach ($users as $key => $user) {
if (isset($user['email']) && strlen($user['email']) > 0) { if (isset($user['email']) && strlen($user['email']) > 0) {
$usersArray[] = $user['email'];
if($this->getProducerCurrent()->isDemoAccount()) {
$usersArray[] = \Yii::$app->faker->email();
}
else {
$usersArray[] = $user['email'];
}
} else { } else {
unset($users[$key]); unset($users[$key]);
} }




if ($mailForm->load(\Yii::$app->request->post()) && $mailForm->validate()) { if ($mailForm->load(\Yii::$app->request->post()) && $mailForm->validate()) {
$mailForm->sendEmail($users);
$this->setFlash('success', 'Votre email a bien été envoyé.');


// @TODO : traiter les erreurs
/*if ($responseSendMail->success()) {
if($this->getProducerCurrent()->isDemoAccount()) {
$this->setFlash('error', "Fonctionnalité désactivée sur le compte de démo.");
}
else {
$mailForm->sendEmail($users);
$this->setFlash('success', 'Votre email a bien été envoyé.'); $this->setFlash('success', 'Votre email a bien été envoyé.');
} else {
$bodyResponseSendMail = $responseSendMail->getBody();
$emailsErrorArray = [];

if (isset($bodyResponseSendMail['Messages'])) {
foreach ($bodyResponseSendMail['Messages'] as $message) {
if ($message['Status'] != 'success') {
$emailsErrorArray[] = $message['Errors'][0]['ErrorMessage'];
}
}
}

$messageError = 'Un problème est survenu lors de l\'envoi de votre email.';
if (count($emailsErrorArray) > 0) {
$messageError .= '<br />Problème détecté : ' . implode(',', $emailsErrorArray);
}
$this->setFlash('error', $messageError);
}*/
}


return $this->redirect(['email', 'idPointSale' => $idPointSale]); return $this->redirect(['email', 'idPointSale' => $idPointSale]);
} }

+ 13
- 3
backend/controllers/DistributionController.php View File

$json['points_sale'] = $this->buildAjaxInfosResponsePointsSale($distribution); $json['points_sale'] = $this->buildAjaxInfosResponsePointsSale($distribution);
$json['delivery_notes'] = $this->buildAjaxInfosResponseDeliveryNotes($date); $json['delivery_notes'] = $this->buildAjaxInfosResponseDeliveryNotes($date);
$json['order_create'] = $this->buildAjaxInfosResponseOrderCreate($distribution, $productsArray); $json['order_create'] = $this->buildAjaxInfosResponseOrderCreate($distribution, $productsArray);
$json['users'] = $userModule->findUsers();
$json['users'] = $this->buildAjaxInfosResponseUsers();
$json['one_distribution_week_active'] = $distributionModule->isOneDistributionWeekActive($date); $json['one_distribution_week_active'] = $distributionModule->isOneDistributionWeekActive($date);
$json['tiller_is_synchro'] = $this->buildAjaxInfosResponseTiller($producer, $date); $json['tiller_is_synchro'] = $this->buildAjaxInfosResponseTiller($producer, $date);
$json['tiller_is_authenticated'] = $this->getOrderModule()->getTillerManager()->isAuthenticated(); $json['tiller_is_authenticated'] = $this->getOrderModule()->getTillerManager()->isAuthenticated();
return $json; return $json;
} }


public function buildAjaxInfosResponseUsers()
{
$usersArray = $this->getUserModule()->getRepository()->findUsers();
foreach($usersArray as $key => $user) {
$usersArray[$key]['username'] = $this->getUserModule()->getSolver()->getUsernameFromArray($user, true);
}
return $usersArray;
}

public function buildAjaxInfosResponseLeavePeriod(Producer $producer) public function buildAjaxInfosResponseLeavePeriod(Producer $producer)
{ {
$producerModule = $this->getProducerModule(); $producerModule = $this->getProducerModule();
'mean_payment' => $payment->mean_payment, 'mean_payment' => $payment->mean_payment,
'wording_mean_payment' => $paymentManager->getStrMeanPayment($payment), 'wording_mean_payment' => $paymentManager->getStrMeanPayment($payment),
'date' => date('d/m/Y H:i:s', strtotime($payment->date)), 'date' => date('d/m/Y H:i:s', strtotime($payment->date)),
'user' => $payment->getUserObject() ? $userModule->getUsername($payment->getUserObject()) : '',
'user_action' => $paymentManager->getStrUserAction($payment),
'user' => $payment->getUserObject() ? $userModule->getSolver()->getUsername($payment->getUserObject()) : '',
'user_action' => $userModule->getSolver()->getPaymentUsernameUserAction($payment),
'wording' => $paymentManager->getStrWording($payment, $order), 'wording' => $paymentManager->getStrWording($payment, $order),
'amount' => $paymentManager->getAmount($payment, Order::AMOUNT_TOTAL, true), 'amount' => $paymentManager->getAmount($payment, Order::AMOUNT_TOTAL, true),
]; ];
$order->user->getAttributes(), $order->user->getAttributes(),
$arrayDatasUser $arrayDatasUser
) : null, ) : null,
'username_user' => (isset($order->user)) ? $userModule->getSolver()->getUsername($order->user) : '',
'pointSale' => $order->pointSale ? ['id' => $order->pointSale->id, 'name' => $order->pointSale->name] : null, 'pointSale' => $order->pointSale ? ['id' => $order->pointSale->id, 'name' => $order->pointSale->name] : null,
'productOrder' => $productOrderArray, 'productOrder' => $productOrderArray,
'paymentsArray' => $paymentArray, 'paymentsArray' => $paymentArray,

+ 1
- 1
backend/controllers/OrderController.php View File

foreach ($history as $creditHistory) { foreach ($history as $creditHistory) {
$html .= '<tr>' $html .= '<tr>'
. '<td>' . date('d/m/Y H:i:s', strtotime($paymentManager->getDate($creditHistory))) . '</td>' . '<td>' . date('d/m/Y H:i:s', strtotime($paymentManager->getDate($creditHistory))) . '</td>'
. '<td>' . Html::encode($paymentManager->getStrUserAction($creditHistory)) . '</td>'
. '<td>' . Html::encode($this->getUserModule()->getSolver()->getPaymentUsernameUserAction($creditHistory)) . '</td>'
. '<td>' . $paymentManager->getStrWording($creditHistory) . '</td>' . '<td>' . $paymentManager->getStrWording($creditHistory) . '</td>'
. '<td>' . ($paymentManager->isTypeDebit($creditHistory) ? '- ' . Price::getPriceWithTax($creditHistory->amount) : '') . '</td>' . '<td>' . ($paymentManager->isTypeDebit($creditHistory) ? '- ' . Price::getPriceWithTax($creditHistory->amount) : '') . '</td>'
. '<td>' . ($paymentManager->isTypeCredit($creditHistory) ? '+ ' . Price::getPriceWithTax($creditHistory->amount) : '') . '</td>' . '<td>' . ($paymentManager->isTypeCredit($creditHistory) ? '+ ' . Price::getPriceWithTax($creditHistory->amount) : '') . '</td>'

+ 3
- 0
backend/controllers/ReportController.php View File

$distributionModule = $this-> getDistributionModule(); $distributionModule = $this-> getDistributionModule();


$usersArray = $userModule->findUsers(); $usersArray = $userModule->findUsers();
foreach($usersArray as $key => $user) {
$usersArray[$key]['username'] = $userModule->getSolver()->getUsernameFromArray($user, true);
}
$pointsSaleArray = $pointSaleModule->findPointSales(); $pointsSaleArray = $pointSaleModule->findPointSales();
$firstDistribution = $distributionModule->findOneFirstDistribution(); $firstDistribution = $distributionModule->findOneFirstDistribution();
$lastDistribution = $distributionModule->findOneLastDistribution(); $lastDistribution = $distributionModule->findOneLastDistribution();

+ 6
- 2
backend/controllers/UserController.php View File



public function actionUpdate($id) public function actionUpdate($id)
{ {
if($this->getProducerCurrent()->isDemoAccount()) {
$this->addFlash('error', "Fonctionnalité non disponible sur le compte de démo.");
return $this->redirect(['view', 'id' => $id]);
}

$userModule = $this->getUserModule(); $userModule = $this->getUserModule();
$pointSaleModule = $this->getPointSaleModule(); $pointSaleModule = $this->getPointSaleModule();

$model = $this->findModel($id); $model = $this->findModel($id);
$previousMail = $model->email; $previousMail = $model->email;
$userBelongToProducer = UserProducer::findOne(['id_user' => $id, 'id_producer' => GlobalParam::getCurrentProducerId()]); $userBelongToProducer = UserProducer::findOne(['id_user' => $id, 'id_producer' => GlobalParam::getCurrentProducerId()]);
$dateTransaction $dateTransaction
); );


if ($creditForm->send_mail) {
if ($creditForm->send_mail && !$this->getProducerCurrent()->isDemoAccount()) {
$paymentModule->getNotifier() $paymentModule->getNotifier()
->notifyUserCreditMovement( ->notifyUserCreditMovement(
$user, $user,

+ 1
- 1
backend/views/access/index.php View File

</tr> </tr>
<?php foreach($usersAccessArray as $user): ?> <?php foreach($usersAccessArray as $user): ?>
<tr> <tr>
<td><?= Html::encode($user->lastname.' '.$user->name) ?></td>
<td><?= Html::encode($userModule->getSolver()->getUsername($user)) ?></td>
<td><?= Html::a('<span class="glyphicon glyphicon-trash"></span>',['access/delete','idUser' => $user->id], ['class' => 'btn btn-default']); ?></td> <td><?= Html::a('<span class="glyphicon glyphicon-trash"></span>',['access/delete','idUser' => $user->id], ['class' => 'btn btn-default']); ?></td>
</tr> </tr>
<?php endforeach; ?> <?php endforeach; ?>

+ 5
- 20
backend/views/distribution/index.php View File

Attention, ce jour de distribution n'est pas activé et vous avez quand même des commandes enregistrées. Attention, ce jour de distribution n'est pas activé et vous avez quand même des commandes enregistrées.
</div> </div>


<div v-if="idActivePointSale > 0 && (totalActivePointSale() > 0 || weightActivePointSale() > 0)" class="point-sale-totals">
<div>
<div v-if="idActivePointSale > 0 && (totalActivePointSale() > 0 || weightActivePointSale() > 0 || pointSaleActive.producers_sharing_point_sale_as_string)" class="point-sale-totals">
<div v-if="totalActivePointSale() > 0 || weightActivePointSale() > 0">
<span class="title">Totaux</span> <span class="title">Totaux</span>
CA TTC : <strong>{{ totalActivePointSale() }} €</strong> / Poids : <strong>{{ weightActivePointSale() }} kg</strong> CA TTC : <strong>{{ totalActivePointSale() }} €</strong> / Poids : <strong>{{ weightActivePointSale() }} kg</strong>
</div> </div>
<td class="column-origin" v-html="order.labelOrigin"></td> <td class="column-origin" v-html="order.labelOrigin"></td>
<td class="column-user"> <td class="column-user">
<a v-if="order.user" :href="baseUrl+'/user/view?id='+order.id_user" target="_blank" :class="order.user.trust_alert ? 'user-trust-alert' : ''" :title="order.user.trust_alert ? order.user.trust_alert_comment : ''"> <a v-if="order.user" :href="baseUrl+'/user/view?id='+order.id_user" target="_blank" :class="order.user.trust_alert ? 'user-trust-alert' : ''" :title="order.user.trust_alert ? order.user.trust_alert_comment : ''">
<template v-if="order.user.name_legal_person && order.user.name_legal_person.length">
{{ order.user.name_legal_person }}
</template>
<template v-else>
{{ order.user.lastname+' '+order.user.name }}
</template>
<!--<span class="shortcuts btn-group" role="group">
<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>-->
{{ order.username_user }}
</a> </a>
<span v-else class="user-without-account">{{ order.username }}</span> <span v-else class="user-without-account">{{ order.username }}</span>
<span v-if="order.comment && order.comment.length > 0" class="glyphicon glyphicon-comment"></span> <span v-if="order.comment && order.comment.length > 0" class="glyphicon glyphicon-comment"></span>
<modal v-if="showModalPayment && idOrderPayment == order.id" class="modal-payment" @close="showModalPayment = false"> <modal v-if="showModalPayment && idOrderPayment == order.id" class="modal-payment" @close="showModalPayment = false">
<h3 slot="header"> <h3 slot="header">
Commande du <strong>{{ dateFormat }}</strong> &gt; Commande du <strong>{{ dateFormat }}</strong> &gt;
<strong><span v-if="order.user">{{ order.user.name +' '+order.user.lastname }}</span>
<strong><span v-if="order.user">{{ order.username_user }}</span>
<span v-else>{{ order.username }}</span></strong> <span v-else>{{ order.username }}</span></strong>
</h3> </h3>
<div slot="body"> <div slot="body">
<select class="form-control select2-order-form" v-model="order.id_user" @change="userChange"> <select class="form-control select2-order-form" v-model="order.id_user" @change="userChange">
<option value="0">--</option> <option value="0">--</option>
<option v-for="user in users" :value="user.id_user"> <option v-for="user in users" :value="user.id_user">
<template v-if="user.type == 'legal-person' && user.name_legal_person && user.name_legal_person.length">
{{ user.name_legal_person }} (personne morale)
</template>
<template v-else>
{{ user.lastname +' '+ user.name }}
</template>
{{ user.username }}
</option> </option>
</select> </select>
<input v-model="order.username" type="text" class="form-control" placeholder="Ou saisissez ici le nom de l'utilisateur" /> <input v-model="order.username" type="text" class="form-control" placeholder="Ou saisissez ici le nom de l'utilisateur" />

+ 1
- 1
backend/views/report/index.php View File

<ul id="list-users"> <ul id="list-users">
<li v-for="user in usersArray" v-if="!termSearchUser.length || (termSearchUser.length && (user.lastname.toLowerCase().indexOf(termSearchUser.toLowerCase()) != -1 || user.name.toLowerCase().indexOf(termSearchUser.toLowerCase()) != -1 ))"> <li v-for="user in usersArray" v-if="!termSearchUser.length || (termSearchUser.length && (user.lastname.toLowerCase().indexOf(termSearchUser.toLowerCase()) != -1 || user.name.toLowerCase().indexOf(termSearchUser.toLowerCase()) != -1 ))">
<input type="checkbox" :id="'user_'+user.user_id" v-model="user.checked" @change="reportChange()" /> <input type="checkbox" :id="'user_'+user.user_id" v-model="user.checked" @change="reportChange()" />
<label :for="'user_'+user.user_id" v-html="(user.name_legal_person && user.name_legal_person.length) ? user.name_legal_person : user.lastname+' '+user.name"></label>
<label :for="'user_'+user.user_id" v-html="user.username"></label>
</li> </li>
</ul> </ul>
</div> </div>

+ 4
- 3
backend/views/subscription/index.php View File

use domain\Product\Product\ProductModule; use domain\Product\Product\ProductModule;
use domain\Subscription\Subscription\Subscription; use domain\Subscription\Subscription\Subscription;
use domain\Subscription\Subscription\SubscriptionModule; use domain\Subscription\Subscription\SubscriptionModule;
use domain\User\User\UserModule;
use yii\grid\GridView; use yii\grid\GridView;
use yii\helpers\ArrayHelper; use yii\helpers\ArrayHelper;
use yii\helpers\Html; use yii\helpers\Html;


$subscriptionModule = SubscriptionModule::getInstance(); $subscriptionModule = SubscriptionModule::getInstance();
$userModule = UserModule::getInstance();


$this->setTitle('Abonnements') ; $this->setTitle('Abonnements') ;
$this->addBreadcrumb($this->getTitle()) ; $this->addBreadcrumb($this->getTitle()) ;


?> ?>
<div class="subscription-index"> <div class="subscription-index">
<?= GridView::widget([ <?= GridView::widget([
'filterModel' => $searchModel, 'filterModel' => $searchModel,
'dataProvider' => $dataProvider, 'dataProvider' => $dataProvider,
'attribute' => 'username', 'attribute' => 'username',
'label' => 'Utilisateur', 'label' => 'Utilisateur',
'format' => 'raw', 'format' => 'raw',
'value' => function($model) {
'value' => function($model) use ($userModule) {
if(strlen($model->username)) if(strlen($model->username))
{ {
return Html::encode($model->username) ; return Html::encode($model->username) ;
} }
else { else {
if(isset($model->user)) { if(isset($model->user)) {
return Html::encode($model->user->lastname.' '.$model->user->name) ;
return Html::encode($userModule->getSolver()->getUsername($model->user)) ;
} }
} }
} }

+ 2
- 2
backend/views/user/credit.php View File

], ],
[ [
'attribute' => 'id_user_action', 'attribute' => 'id_user_action',
'value' => function ($model) use ($paymentManager) {
return $paymentManager->getStrUserAction($model);
'value' => function ($model) use ($userModule) {
return $userModule->getSolver()->getPaymentUsernameUserAction($model);
} }
], ],
[ [

+ 22
- 12
backend/views/user/index.php View File

use domain\Producer\Producer\ProducerModule; use domain\Producer\Producer\ProducerModule;
use domain\User\User\UserModule; use domain\User\User\UserModule;
use domain\User\UserProducer\UserProducer; use domain\User\UserProducer\UserProducer;
use Faker\Factory;
use yii\grid\GridView; use yii\grid\GridView;
use yii\helpers\Html; use yii\helpers\Html;
use domain\User\UserGroup\UserGroupModule; use domain\User\UserGroup\UserGroupModule;


$userModule = UserModule::getInstance(); $userModule = UserModule::getInstance();
$producerModule = ProducerModule::getInstance(); $producerModule = ProducerModule::getInstance();
$userCurrent = GlobalParam::getCurrentUser();
$userGroupModule = UserGroupModule::getInstance(); $userGroupModule = UserGroupModule::getInstance();
$userCurrent = GlobalParam::getCurrentUser();
$producerCurrent = GlobalParam::getCurrentProducer();


$this->setTitle('Utilisateurs'); $this->setTitle('Utilisateurs');
$this->addBreadcrumb($this->getTitle()); $this->addBreadcrumb($this->getTitle());
'attribute' => 'username', 'attribute' => 'username',
'label' => 'Nom', 'label' => 'Nom',
'value' => function ($user) use ($userModule) { 'value' => function ($user) use ($userModule) {
return $userModule->getUsername($user);
return $userModule->getSolver()->getUsername($user);
} }
], ],
[ [
'headerOptions' => ['class' => 'column-hide-on-mobile'], 'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'], 'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'], 'contentOptions' => ['class' => 'column-hide-on-mobile'],
'value' => function ($user) {
'value' => function ($user) use ($producerCurrent) {

$html = ''; $html = '';
if (strlen($user['phone'])) {
$html .= $user['phone'];
if($producerCurrent->isDemoAccount()) {
$faker = Yii::$app->faker;
$html .= $faker->email().'<br />'.$faker->phoneNumber();
} }
if (strlen($user['phone']) && strlen($user['email'])) {
$html .= '<br />';
}
if (strlen($user['email'])) {
$html .= $user['email'];
if($user['problem_receiving_emails']) {
$html .= ' <span class="fa fa-life-ring"></span>';
else {
if (strlen($user['phone'])) {
$html .= $user['phone'];
}
if (strlen($user['phone']) && strlen($user['email'])) {
$html .= '<br />';
}
if (strlen($user['email'])) {
$html .= $user['email'];
if($user['problem_receiving_emails']) {
$html .= ' <span class="fa fa-life-ring"></span>';
}
} }
} }

return $html; return $html;
} }
], ],

+ 3
- 3
backend/views/user/view.php View File

<strong>Téléphone</strong> <strong>Téléphone</strong>
<span class="pull-right"> <span class="pull-right">
<span class="glyphicon glyphicon-phone"></span> <span class="glyphicon glyphicon-phone"></span>
<?= $model->phone ?>
<?= $userModule->getSolver()->getPhone($model); ?>
</span> </span>
</li> </li>
<?php endif; ?> <?php endif; ?>
<strong>Email</strong> <strong>Email</strong>
<span class="pull-right"> <span class="pull-right">
<span class="glyphicon glyphicon-envelope"></span> <span class="glyphicon glyphicon-envelope"></span>
<a href="mailto:<?= $model->email ?>"><?= $model->email ?></a>
<a href="mailto:<?= $userModule->getSolver()->getEmail($model) ?>"><?= $userModule->getSolver()->getEmail($model) ?></a>
</span> </span>
</li> </li>
<?php endif; ?> <?php endif; ?>
<li class="list-group-item list-group-item-address"> <li class="list-group-item list-group-item-address">
<strong>Adresse</strong> <strong>Adresse</strong>
<span class="pull-right"> <span class="pull-right">
<?= nl2br($model->address) ?>
<?= nl2br($userModule->getSolver()->getAddress($model)) ?>
</span> </span>
<div class="clr"></div> <div class="clr"></div>
</li> </li>

+ 42
- 0
common/components/Faker.php View File

<?php

namespace common\components;

use Faker\Factory;
use Faker\Generator;
use Faker\Provider\fr_FR\Address;
use Faker\Provider\fr_FR\Person;
use Faker\Provider\fr_FR\PhoneNumber;

class Faker
{
protected Generator $faker;

public function __construct()
{
$this->faker = Factory::create();
$this->faker->addProvider(new Person($this->faker));
$this->faker->addProvider(new PhoneNumber($this->faker));
$this->faker->addProvider(new Address($this->faker));
}

public function name(): string
{
return $this->faker->name;
}

public function email(): string
{
return $this->faker->email;
}

public function phoneNumber(): string
{
return $this->faker->mobileNumber;
}

public function address(): string
{
return $this->faker->address;
}
}

+ 3
- 0
common/config/main.php View File

} }
}, },
'components' => [ 'components' => [
'faker' => [
'class' => 'common\components\Faker'
],
'parameterBag' => [ 'parameterBag' => [
'class' => 'common\components\ParameterBag' 'class' => 'common\components\ParameterBag'
], ],

+ 3
- 0
domain/Distribution/Distribution/Export/DistributionReportPdfGenerator.php View File

use domain\Product\Product\ProductRepository; use domain\Product\Product\ProductRepository;
use domain\Product\Product\ProductSolver; use domain\Product\Product\ProductSolver;
use domain\User\User\UserRepository; use domain\User\User\UserRepository;
use domain\User\User\UserSolver;
use kartik\mpdf\Pdf; use kartik\mpdf\Pdf;
use domain\_\AbstractGenerator; use domain\_\AbstractGenerator;


protected ProductSolver $productSolver; protected ProductSolver $productSolver;
protected DocumentSolver $documentSolver; protected DocumentSolver $documentSolver;
protected UserRepository $userRepository; protected UserRepository $userRepository;
protected UserSolver $userSolver;


public function loadDependencies(): void public function loadDependencies(): void
{ {
$this->productSolver = $this->loadService(ProductSolver::class); $this->productSolver = $this->loadService(ProductSolver::class);
$this->documentSolver = $this->loadService(DocumentSolver::class); $this->documentSolver = $this->loadService(DocumentSolver::class);
$this->userRepository = $this->loadService(UserRepository::class); $this->userRepository = $this->loadService(UserRepository::class);
$this->userSolver = $this->loadService(UserSolver::class);
} }


public function generate(Distribution $distribution, bool $save = false) public function generate(Distribution $distribution, bool $save = false)

+ 1
- 5
domain/Order/Order/OrderSolver.php View File

public function getOrderUsername(Order $order): string public function getOrderUsername(Order $order): string
{ {
if (isset($order->user)) { if (isset($order->user)) {
if (isset($order->user->name_legal_person) && strlen($order->user->name_legal_person)) {
return Html::encode($order->user->name_legal_person);
} else {
return Html::encode($this->userSolver->getUsername($order->user));
}
return Html::encode($this->userSolver->getUsername($order->user));
} elseif (strlen($order->username)) { } elseif (strlen($order->username)) {
return Html::encode($order->username); return Html::encode($order->username);
} else { } else {

+ 1
- 11
domain/Payment/PaymentSolver.php View File

use domain\Order\Order\Order; use domain\Order\Order\Order;
use domain\_\AbstractService; use domain\_\AbstractService;
use domain\_\SolverInterface; use domain\_\SolverInterface;
use domain\User\User\UserSolver;


class PaymentSolver extends AbstractService implements SolverInterface class PaymentSolver extends AbstractService implements SolverInterface
{ {


return 'Type de paiement inconnu'; return 'Type de paiement inconnu';
} }

public function getStrUserAction(Payment $payment): string
{
$userAction = $payment->getUserActionObject();

if ($userAction) {
return $userAction->getName() . ' ' . $userAction->getlastname();
} else {
return 'Système';
}
}
} }

+ 9
- 0
domain/Producer/Producer/Producer.php View File

{ {
return self::$billingFrequencyArray; return self::$billingFrequencyArray;
} }

public function isDemoAccount(): bool
{
if (strpos($this->getName(), 'Démo') !== false) {
return true;
}

return false;
}
} }

+ 0
- 12
domain/Producer/Producer/ProducerSolver.php View File



class ProducerSolver extends AbstractService implements SolverInterface class ProducerSolver extends AbstractService implements SolverInterface
{ {
/**
* Retourne true si le compte est un compte de démo.
*/
public function isDemo(Producer $producer): bool
{
if (strpos($producer->name, 'Démo') !== false) {
return true;
}

return false;
}

public function getFullAddressAsHtml(Producer $producer): string public function getFullAddressAsHtml(Producer $producer): string
{ {
$address = '<div class="name">'.$producer->name . '</div>'; $address = '<div class="name">'.$producer->name . '</div>';

+ 70
- 14
domain/User/User/UserSolver.php View File



namespace domain\User\User; namespace domain\User\User;


use domain\Payment\Payment;
use domain\Producer\Producer\ProducerSolver;
use domain\User\UserGroup\UserGroup; use domain\User\UserGroup\UserGroup;
use domain\User\UserProducer\UserProducer; use domain\User\UserProducer\UserProducer;
use domain\User\UserUserGroup\UserUserGroup; use domain\User\UserUserGroup\UserUserGroup;
use domain\_\AbstractService; use domain\_\AbstractService;
use domain\_\SolverInterface; use domain\_\SolverInterface;
use Faker\Factory;
use yii\base\ErrorException;


class UserSolver extends AbstractService implements SolverInterface class UserSolver extends AbstractService implements SolverInterface
{ {
return $html; return $html;
} }


public function getUsername(User $user, $withType = false): string
// getStrUserAction
public function getPaymentUsernameUserAction(Payment $payment): string
{ {
if ($this->isTypeLegalPerson($user)
&& isset($user->name_legal_person)
&& strlen($user->name_legal_person)) {
$userAction = $payment->getUserActionObject();


$username = $user->name_legal_person;
if ($userAction) {
return $this->getUsername($userAction);
} else { } else {
$username = $user->lastname . ' ' . $user->name;
return 'Système';
}
}

public function getPhone(User $user)
{
if($this->getProducerContext() && $this->getProducerContext()->isDemoAccount()) {
return \Yii::$app->faker->phoneNumber();
}

return $user->phone;
}

public function getEmail(User $user)
{
if($this->getProducerContext() && $this->getProducerContext()->isDemoAccount()) {
return \Yii::$app->faker->email();
}

return $user->email;
}

public function getAddress(User $user): string
{
if($this->getProducerContext() && $this->getProducerContext()->isDemoAccount()) {
return \Yii::$app->faker->address();
}

return $user->address;
}

/**
* @throws ErrorException
*/
public function getUsername(User $user, $withType = false): string
{
if($this->getProducerContext() && $this->getProducerContext()->isDemoAccount()) {
$username = \Yii::$app->faker->name();
}
else {
if ($this->isTypeLegalPerson($user)
&& isset($user->name_legal_person)
&& strlen($user->name_legal_person)) {

$username = $user->name_legal_person;
} else {
$username = $user->lastname . ' ' . $user->name;
}
} }


if ($withType && $this->isTypeLegalPerson($user)) { if ($withType && $this->isTypeLegalPerson($user)) {


public function getUsernameFromArray(array $modelArray, $withType = false): string public function getUsernameFromArray(array $modelArray, $withType = false): string
{ {
$username = 'Nom indéfini';
if ($modelArray['type'] == User::TYPE_LEGAL_PERSON
&& isset($modelArray['name_legal_person'])
&& strlen($modelArray['name_legal_person'])) {
$username = $modelArray['name_legal_person'];
} elseif((isset($modelArray['lastname']) && $modelArray['lastname'])
|| (isset($modelArray['name']) && $modelArray['name'])) {
$username = $modelArray['lastname'] . ' ' . $modelArray['name'];
if($this->getProducerContext() && $this->getProducerContext()->isDemoAccount()) {
$username = \Yii::$app->faker->name();
}
else {
$username = 'Nom indéfini';
if ($modelArray['type'] == User::TYPE_LEGAL_PERSON
&& isset($modelArray['name_legal_person'])
&& strlen($modelArray['name_legal_person'])) {
$username = $modelArray['name_legal_person'];
} elseif((isset($modelArray['lastname']) && $modelArray['lastname'])
|| (isset($modelArray['name']) && $modelArray['name'])) {
$username = $modelArray['lastname'] . ' ' . $modelArray['name'];
}
} }


if ($withType && $modelArray['type'] == User::TYPE_LEGAL_PERSON) { if ($withType && $modelArray['type'] == User::TYPE_LEGAL_PERSON) {

+ 1
- 1
frontend/views/site/producer.php View File

<h2 class="panel-title">Connexion</h2> <h2 class="panel-title">Connexion</h2>
</div> </div>
<div class="panel-body"> <div class="panel-body">
<?php if(isset($producer) && $producerModule->isDemo($producer)) : ?>
<?php if(isset($producer) && $producer->isDemoAccount()) : ?>
<div class="alert alert-warning"> <div class="alert alert-warning">
<p>Merci d'utiliser les identifiants suivants pour vous connecter à l'espace de démonstration :</p> <p>Merci d'utiliser les identifiants suivants pour vous connecter à l'espace de démonstration :</p>
Identifiant : <strong>demo@souke.fr</strong><br> Identifiant : <strong>demo@souke.fr</strong><br>

+ 1
- 1
producer/views/order/confirm.php View File

<?php if($pointsSaleSharedWithPointSaleArray && count($pointsSaleSharedWithPointSaleArray)): ?> <?php if($pointsSaleSharedWithPointSaleArray && count($pointsSaleSharedWithPointSaleArray)): ?>
<div class="alert alert-info"> <div class="alert alert-info">
<h4 class="alert-heading"> <h4 class="alert-heading">
<i class="bi bi-share"></i>
<i class="bi bi-shop"></i>
Commander chez d'autres producteurs présents à cette distribution<br /> Commander chez d'autres producteurs présents à cette distribution<br />
</h4> </h4>
<?php foreach($pointsSaleSharedWithPointSaleArray as $pointSaleSharedWithPointSale): ?> <?php foreach($pointsSaleSharedWithPointSaleArray as $pointSaleSharedWithPointSale): ?>

Loading…
Cancel
Save