Browse Source

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

feature/rotating_product
Guillaume Bourgeois 6 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

@@ -133,7 +133,12 @@ class CommunicateController extends BackendController
$usersArray = [];
foreach ($users as $key => $user) {
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 {
unset($users[$key]);
}
@@ -148,30 +153,14 @@ class CommunicateController extends BackendController


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é.');
} 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]);
}

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

@@ -131,7 +131,7 @@ class DistributionController extends BackendController
$json['points_sale'] = $this->buildAjaxInfosResponsePointsSale($distribution);
$json['delivery_notes'] = $this->buildAjaxInfosResponseDeliveryNotes($date);
$json['order_create'] = $this->buildAjaxInfosResponseOrderCreate($distribution, $productsArray);
$json['users'] = $userModule->findUsers();
$json['users'] = $this->buildAjaxInfosResponseUsers();
$json['one_distribution_week_active'] = $distributionModule->isOneDistributionWeekActive($date);
$json['tiller_is_synchro'] = $this->buildAjaxInfosResponseTiller($producer, $date);
$json['tiller_is_authenticated'] = $this->getOrderModule()->getTillerManager()->isAuthenticated();
@@ -142,6 +142,15 @@ class DistributionController extends BackendController
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)
{
$producerModule = $this->getProducerModule();
@@ -362,8 +371,8 @@ class DistributionController extends BackendController
'mean_payment' => $payment->mean_payment,
'wording_mean_payment' => $paymentManager->getStrMeanPayment($payment),
'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),
'amount' => $paymentManager->getAmount($payment, Order::AMOUNT_TOTAL, true),
];
@@ -399,6 +408,7 @@ class DistributionController extends BackendController
$order->user->getAttributes(),
$arrayDatasUser
) : null,
'username_user' => (isset($order->user)) ? $userModule->getSolver()->getUsername($order->user) : '',
'pointSale' => $order->pointSale ? ['id' => $order->pointSale->id, 'name' => $order->pointSale->name] : null,
'productOrder' => $productOrderArray,
'paymentsArray' => $paymentArray,

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

@@ -1069,7 +1069,7 @@ class OrderController extends BackendController
foreach ($history as $creditHistory) {
$html .= '<tr>'
. '<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->isTypeDebit($creditHistory) ? '- ' . Price::getPriceWithTax($creditHistory->amount) : '') . '</td>'
. '<td>' . ($paymentManager->isTypeCredit($creditHistory) ? '+ ' . Price::getPriceWithTax($creditHistory->amount) : '') . '</td>'

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

@@ -86,6 +86,9 @@ class ReportController extends BackendController
$distributionModule = $this-> getDistributionModule();

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

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

@@ -205,9 +205,13 @@ class UserController extends BackendController

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();
$pointSaleModule = $this->getPointSaleModule();

$model = $this->findModel($id);
$previousMail = $model->email;
$userBelongToProducer = UserProducer::findOne(['id_user' => $id, 'id_producer' => GlobalParam::getCurrentProducerId()]);
@@ -518,7 +522,7 @@ class UserController extends BackendController
$dateTransaction
);

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

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

@@ -73,7 +73,7 @@ $this->setTitle('Accès') ;
</tr>
<?php foreach($usersAccessArray as $user): ?>
<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>
</tr>
<?php endforeach; ?>

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

@@ -334,8 +334,8 @@ $this->setPageTitle('Distributions') ;
Attention, ce jour de distribution n'est pas activé et vous avez quand même des commandes enregistrées.
</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>
CA TTC : <strong>{{ totalActivePointSale() }} €</strong> / Poids : <strong>{{ weightActivePointSale() }} kg</strong>
</div>
@@ -385,17 +385,7 @@ $this->setPageTitle('Distributions') ;
<td class="column-origin" v-html="order.labelOrigin"></td>
<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 : ''">
<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>
<span v-else class="user-without-account">{{ order.username }}</span>
<span v-if="order.comment && order.comment.length > 0" class="glyphicon glyphicon-comment"></span>
@@ -548,7 +538,7 @@ $this->setPageTitle('Distributions') ;
<modal v-if="showModalPayment && idOrderPayment == order.id" class="modal-payment" @close="showModalPayment = false">
<h3 slot="header">
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>
</h3>
<div slot="body">
@@ -679,12 +669,7 @@ $this->setPageTitle('Distributions') ;
<select class="form-control select2-order-form" v-model="order.id_user" @change="userChange">
<option value="0">--</option>
<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>
</select>
<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

@@ -59,7 +59,7 @@ $this->addBreadcrumb('Rapports') ;
<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 ))">
<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>
</ul>
</div>

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

@@ -43,11 +43,13 @@ use domain\Product\Product\Product;
use domain\Product\Product\ProductModule;
use domain\Subscription\Subscription\Subscription;
use domain\Subscription\Subscription\SubscriptionModule;
use domain\User\User\UserModule;
use yii\grid\GridView;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;

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

$this->setTitle('Abonnements') ;
$this->addBreadcrumb($this->getTitle()) ;
@@ -57,7 +59,6 @@ $subscriptionsArray = Subscription::searchAll() ;

?>
<div class="subscription-index">
<?= GridView::widget([
'filterModel' => $searchModel,
'dataProvider' => $dataProvider,
@@ -66,14 +67,14 @@ $subscriptionsArray = Subscription::searchAll() ;
'attribute' => 'username',
'label' => 'Utilisateur',
'format' => 'raw',
'value' => function($model) {
'value' => function($model) use ($userModule) {
if(strlen($model->username))
{
return Html::encode($model->username) ;
}
else {
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

@@ -172,8 +172,8 @@ $this->addBreadcrumb('Cagnotte') ;
],
[
'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

@@ -44,14 +44,16 @@ use domain\Order\OrderStatus\OrderStatus;
use domain\Producer\Producer\ProducerModule;
use domain\User\User\UserModule;
use domain\User\UserProducer\UserProducer;
use Faker\Factory;
use yii\grid\GridView;
use yii\helpers\Html;
use domain\User\UserGroup\UserGroupModule;

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

$this->setTitle('Utilisateurs');
$this->addBreadcrumb($this->getTitle());
@@ -84,7 +86,7 @@ $this->render('_menu_filter', [
'attribute' => 'username',
'label' => 'Nom',
'value' => function ($user) use ($userModule) {
return $userModule->getUsername($user);
return $userModule->getSolver()->getUsername($user);
}
],
[
@@ -105,20 +107,28 @@ $this->render('_menu_filter', [
'headerOptions' => ['class' => 'column-hide-on-mobile'],
'filterOptions' => ['class' => 'column-hide-on-mobile'],
'contentOptions' => ['class' => 'column-hide-on-mobile'],
'value' => function ($user) {
'value' => function ($user) use ($producerCurrent) {

$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;
}
],

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

@@ -97,7 +97,7 @@ $this->addBreadcrumb('Récapitulatif') ;
<strong>Téléphone</strong>
<span class="pull-right">
<span class="glyphicon glyphicon-phone"></span>
<?= $model->phone ?>
<?= $userModule->getSolver()->getPhone($model); ?>
</span>
</li>
<?php endif; ?>
@@ -106,7 +106,7 @@ $this->addBreadcrumb('Récapitulatif') ;
<strong>Email</strong>
<span class="pull-right">
<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>
</li>
<?php endif; ?>
@@ -114,7 +114,7 @@ $this->addBreadcrumb('Récapitulatif') ;
<li class="list-group-item list-group-item-address">
<strong>Adresse</strong>
<span class="pull-right">
<?= nl2br($model->address) ?>
<?= nl2br($userModule->getSolver()->getAddress($model)) ?>
</span>
<div class="clr"></div>
</li>

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

@@ -0,0 +1,42 @@
<?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

@@ -78,6 +78,9 @@ return [
}
},
'components' => [
'faker' => [
'class' => 'common\components\Faker'
],
'parameterBag' => [
'class' => 'common\components\ParameterBag'
],

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

@@ -18,6 +18,7 @@ use domain\Product\Product\Product;
use domain\Product\Product\ProductRepository;
use domain\Product\Product\ProductSolver;
use domain\User\User\UserRepository;
use domain\User\User\UserSolver;
use kartik\mpdf\Pdf;
use domain\_\AbstractGenerator;

@@ -35,6 +36,7 @@ class DistributionReportPdfGenerator extends AbstractGenerator implements Distri
protected ProductSolver $productSolver;
protected DocumentSolver $documentSolver;
protected UserRepository $userRepository;
protected UserSolver $userSolver;

public function loadDependencies(): void
{
@@ -48,6 +50,7 @@ class DistributionReportPdfGenerator extends AbstractGenerator implements Distri
$this->productSolver = $this->loadService(ProductSolver::class);
$this->documentSolver = $this->loadService(DocumentSolver::class);
$this->userRepository = $this->loadService(UserRepository::class);
$this->userSolver = $this->loadService(UserSolver::class);
}

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

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

@@ -127,11 +127,7 @@ class OrderSolver extends AbstractService implements SolverInterface
public function getOrderUsername(Order $order): string
{
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)) {
return Html::encode($order->username);
} else {

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

@@ -6,6 +6,7 @@ use common\helpers\MeanPayment;
use domain\Order\Order\Order;
use domain\_\AbstractService;
use domain\_\SolverInterface;
use domain\User\User\UserSolver;

class PaymentSolver extends AbstractService implements SolverInterface
{
@@ -130,15 +131,4 @@ class PaymentSolver extends AbstractService implements SolverInterface

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

@@ -671,5 +671,14 @@ class Producer extends ActiveRecordCommon
{
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

@@ -10,18 +10,6 @@ use yii\helpers\Html;

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
{
$address = '<div class="name">'.$producer->name . '</div>';

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

@@ -2,11 +2,15 @@

namespace domain\User\User;

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

class UserSolver extends AbstractService implements SolverInterface
{
@@ -79,15 +83,62 @@ class UserSolver extends AbstractService implements SolverInterface
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 {
$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)) {
@@ -99,14 +150,19 @@ class UserSolver extends AbstractService implements SolverInterface

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) {

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

@@ -72,7 +72,7 @@ $this->setMeta('description', 'Connectez-vous pour passer commande auprès du pr
<h2 class="panel-title">Connexion</h2>
</div>
<div class="panel-body">
<?php if(isset($producer) && $producerModule->isDemo($producer)) : ?>
<?php if(isset($producer) && $producer->isDemoAccount()) : ?>
<div class="alert alert-warning">
<p>Merci d'utiliser les identifiants suivants pour vous connecter à l'espace de démonstration :</p>
Identifiant : <strong>demo@souke.fr</strong><br>

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

@@ -85,7 +85,7 @@ $this->setPageTitle('Confirmation de commande');
<?php if($pointsSaleSharedWithPointSaleArray && count($pointsSaleSharedWithPointSaleArray)): ?>
<div class="alert alert-info">
<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 />
</h4>
<?php foreach($pointsSaleSharedWithPointSaleArray as $pointSaleSharedWithPointSale): ?>

Loading…
Cancel
Save