$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]); | ||||
} | } |
$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, |
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>' |
$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(); |
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, |
</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; ?> |
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> > | Commande du <strong>{{ dateFormat }}</strong> > | ||||
<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" /> |
<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> |
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)) ; | |||||
} | } | ||||
} | } | ||||
} | } |
], | ], | ||||
[ | [ | ||||
'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); | |||||
} | } | ||||
], | ], | ||||
[ | [ |
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; | ||||
} | } | ||||
], | ], |
<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> |
<?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; | |||||
} | |||||
} |
} | } | ||||
}, | }, | ||||
'components' => [ | 'components' => [ | ||||
'faker' => [ | |||||
'class' => 'common\components\Faker' | |||||
], | |||||
'parameterBag' => [ | 'parameterBag' => [ | ||||
'class' => 'common\components\ParameterBag' | 'class' => 'common\components\ParameterBag' | ||||
], | ], |
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) |
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 { |
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'; | |||||
} | |||||
} | |||||
} | } |
{ | { | ||||
return self::$billingFrequencyArray; | return self::$billingFrequencyArray; | ||||
} | } | ||||
public function isDemoAccount(): bool | |||||
{ | |||||
if (strpos($this->getName(), 'Démo') !== false) { | |||||
return true; | |||||
} | |||||
return false; | |||||
} | |||||
} | } | ||||
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>'; |
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) { |
<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> |
<?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): ?> |