Browse Source

[Administration] Utilisateurs : alerte confiance

feature/souke
Guillaume Bourgeois 8 months ago
parent
commit
34e0bc135f
10 changed files with 166 additions and 55 deletions
  1. +10
    -5
      backend/controllers/DistributionController.php
  2. +9
    -0
      backend/controllers/UserController.php
  3. +1
    -1
      backend/views/distribution/index.php
  4. +21
    -0
      backend/views/user/_form.php
  5. +33
    -0
      backend/views/user/view.php
  6. +48
    -44
      backend/web/css/screen.css
  7. +4
    -0
      backend/web/sass/distribution/_index.scss
  8. +28
    -0
      console/migrations/m240320_092736_add_columns_user_trust_alert.php
  9. +7
    -3
      domain/User/User/User.php
  10. +5
    -2
      domain/User/UserProducer/UserProducer.php

+ 10
- 5
backend/controllers/DistributionController.php View File

@@ -316,6 +316,7 @@ class DistributionController extends BackendController
$orderModule = $this->getOrderModule();
$paymentManager = $this->getPaymentModule();
$productOrderModule = $this->getProductOrderModule();
$userProducerModule = $this->getUserProducerModule();

if ($ordersArray) {
foreach ($ordersArray as &$order) {
@@ -360,10 +361,14 @@ class DistributionController extends BackendController
];
}

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

$userProducer = $userProducerModule->getRepository()->findOneUserProducer($order->user);
$arrayDatasUser['trust_alert'] = $userProducer->trust_alert;
$arrayDatasUser['trust_alert_comment'] = $userProducer->trust_alert_comment;
}

$oneProductUnactivated = false;
@@ -384,7 +389,7 @@ class DistributionController extends BackendController
'amount_surplus' => Price::numberTwoDecimals($orderModule->getOrderAmount($order, Order::AMOUNT_SURPLUS)),
'user' => (isset($order->user)) ? array_merge(
$order->user->getAttributes(),
$arrayCreditUser
$arrayDatasUser
) : null,
'pointSale' => $order->pointSale ? ['id' => $order->pointSale->id, 'name' => $order->pointSale->name] : null,
'productOrder' => $productOrderArray,

+ 9
- 0
backend/controllers/UserController.php View File

@@ -207,6 +207,9 @@ class UserController extends BackendController
$userBelongToProducer = UserProducer::findOne(['id_user' => $id, 'id_producer' => GlobalParam::getCurrentProducerId()]);
if ($userBelongToProducer) {
$model->newsletter = $userBelongToProducer->newsletter;
$model->trust_alert = $userBelongToProducer->trust_alert;
$model->trust_alert_comment = $userBelongToProducer->trust_alert_comment;

if ($model->load(\Yii::$app->request->post()) && $model->save()) {

// on envoie le mail de bienvenue si le mail vient d'être défini
@@ -220,12 +223,18 @@ class UserController extends BackendController
$this->processLinkUserGroup($model);
//$this->processProductPricePercent($model);

// Newsletter
if ($model->newsletter) {
$userModule->getNewsletterManager()->subscribeUserNewsletter($model);
} else {
$userModule->getNewsletterManager()->unsubscribeUserNewsletter($model);
}

// Alerte confiance
$userBelongToProducer->trust_alert = $model->trust_alert;
$userBelongToProducer->trust_alert_comment = $model->trust_alert_comment;
$userBelongToProducer->save();

$this->setFlash('success', 'Utilisateur <strong>' . Html::encode($userModule->getUsername($model)) . '</strong> modifié.');
return $this->redirect(['view', 'id' => $model->id]);
}

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

@@ -386,7 +386,7 @@ $this->setPageTitle('Distributions') ;
<span class="label label-success" v-if="!order.date_update && !order.date_delete"><span class="glyphicon glyphicon-check"></span></span>
</td>
<td class="column-user">
<a :href="baseUrl+'/user/view?id='+order.id_user" target="_blank" v-if="order.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>

+ 21
- 0
backend/views/user/_form.php View File

@@ -165,6 +165,27 @@ $distributionModule = DistributionModule::getInstance();
</div>
</div>

<div class="panel panel-default panel-newsletter">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-exclamation-triangle"></i>
Alerte confiance
</h3>
</div>
<div class="panel-body">
<?= $form->field($model, 'trust_alert')->widget(Toggle::class,
[
'options' => [
'data-id' => $model->id,
'data-on' => 'Oui',
'data-off' => 'Non',
],
]
)->hint('Si activé, le nom du client sera mis en avant dans la liste des commandes'); ?>
<?= $form->field($model, 'trust_alert_comment')->textarea(['rows' => 7]); ?>
</div>
</div>

<?php if (
$distributionModule->getExportManager()->isEnabled(ExportManager::SHOPPING_CART_LABELS_PDF)
|| $producerModule->getSolver()->getConfig('option_export_evoliz')): ?>

+ 33
- 0
backend/views/user/view.php View File

@@ -39,11 +39,14 @@ termes.
use common\helpers\Price;
use domain\Order\Order\OrderModule;
use domain\User\User\UserModule;
use domain\User\UserProducer\UserProducerModule;
use yii\helpers\Html;
use yii\widgets\ActiveForm;

$orderModule = OrderModule::getInstance();
$userModule = UserModule::getInstance();
$userProducerModule = UserProducerModule::getInstance();
$userProducer = $userProducerModule->findOneUserProducer($model);
$username = Html::encode($userModule->getSolver()->getUsername($model));
$this->setTitle($username.' (#'.$model->id.')') ;
$this->addBreadcrumb(['label' => 'Utilisateurs', 'url' => ['index']]) ;
@@ -144,6 +147,36 @@ $this->addBreadcrumb('Récapitulatif') ;
</div>
</div>

<?php if($userProducer->trust_alert): ?>
<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">
<i class="fa fa-exclamation-triangle"></i>
Alerte confiance
</h3>
</div>
<div class="panel-body">
<ul class="list-group list-group-unbordered">
<li class="list-group-item">
<strong>Alerte confiance</strong>
<span class="pull-right">
<span class="label label-danger">Oui</span>
</span>
</li>
<?php if($userProducer->trust_alert_comment && strlen($userProducer->trust_alert_comment) > 0): ?>
<li class="list-group-item">
<strong>Commentaire</strong>
<span class="pull-right">
<?= nl2br($userProducer->trust_alert_comment) ?>
</span>
<div class="clr"></div>
</li>
<?php endif; ?>
</ul>
</div>
</div>
<?php endif; ?>

<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">

+ 48
- 44
backend/web/css/screen.css View File

@@ -2430,15 +2430,19 @@ termes.
color: gray;
font-style: italic;
}
/* line 286, ../sass/distribution/_index.scss */
/* line 285, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-user .user-trust-alert {
color: red;
}
/* line 290, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-delivery-note {
position: relative;
}
/* line 290, ../sass/distribution/_index.scss */
/* line 294, ../sass/distribution/_index.scss */
.distribution-index #orders table td.tiller {
width: 60px;
}
/* line 293, ../sass/distribution/_index.scss */
/* line 297, ../sass/distribution/_index.scss */
.distribution-index #orders table td.tiller label {
font-size: 12px;
cursor: pointer;
@@ -2446,88 +2450,88 @@ termes.
top: -2px;
font-weight: normal;
}
/* line 302, ../sass/distribution/_index.scss */
/* line 306, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions {
position: relative;
text-align: right;
}
/* line 306, ../sass/distribution/_index.scss */
/* line 310, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions .wrapper-button-dropdown {
display: inline-block;
}
/* line 310, ../sass/distribution/_index.scss */
/* line 314, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions .dropdown-menu {
left: -70px;
width: 227px;
}
/* line 315, ../sass/distribution/_index.scss */
/* line 319, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions .modal-form-order,
.distribution-index #orders table td.column-actions .modal-payment {
text-align: left;
}
/* line 320, ../sass/distribution/_index.scss */
/* line 324, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions .add-subscription {
position: relative;
}
/* line 323, ../sass/distribution/_index.scss */
/* line 327, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-actions .add-subscription .glyphicon-plus {
position: absolute;
top: 4px;
right: 4px;
font-size: 7px;
}
/* line 332, ../sass/distribution/_index.scss */
/* line 336, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-state-payment {
width: 133px;
}
/* line 338, ../sass/distribution/_index.scss */
/* line 342, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-credit a.positive {
color: green;
}
/* line 341, ../sass/distribution/_index.scss */
/* line 345, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-credit a.negative {
color: red;
}
/* line 347, ../sass/distribution/_index.scss */
/* line 351, ../sass/distribution/_index.scss */
.distribution-index #orders table .state-payment-mobile {
display: none;
}
/* line 351, ../sass/distribution/_index.scss */
/* line 355, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-payment {
position: relative;
}
/* line 354, ../sass/distribution/_index.scss */
/* line 358, ../sass/distribution/_index.scss */
.distribution-index #orders table td.column-payment div.btn-group {
width: 125px;
}
/* line 360, ../sass/distribution/_index.scss */
/* line 364, ../sass/distribution/_index.scss */
.distribution-index #orders table tr.view ul {
list-style-type: none;
margin-left: 0px;
padding-left: 15px;
}
/* line 370, ../sass/distribution/_index.scss */
/* line 374, ../sass/distribution/_index.scss */
.distribution-index #orders table tr.view .comment {
margin-top: 20px;
}
/* line 374, ../sass/distribution/_index.scss */
/* line 378, ../sass/distribution/_index.scss */
.distribution-index #orders table tr.view .delivery {
margin-top: 20px;
}
/* line 383, ../sass/distribution/_index.scss */
/* line 387, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container {
width: 100%;
padding: 0px;
}
/* line 387, ../sass/distribution/_index.scss */
/* line 391, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-body {
padding-right: 15px;
}
/* line 390, ../sass/distribution/_index.scss */
/* line 394, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-body table {
margin-bottom: 150px;
}
/* line 395, ../sass/distribution/_index.scss */
/* line 399, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-footer {
border-top-color: #f4f4f4;
position: fixed;
@@ -2539,64 +2543,64 @@ termes.
text-align: center;
border-top: solid 1px #e0e0e0;
}
/* line 407, ../sass/distribution/_index.scss */
/* line 411, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-footer .actions-form button {
float: none;
}
/* line 411, ../sass/distribution/_index.scss */
/* line 415, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .modal-container .modal-footer .actions-form div.right {
float: right;
}
/* line 418, ../sass/distribution/_index.scss */
/* line 422, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .btn-credit {
float: right;
}
/* line 424, ../sass/distribution/_index.scss */
/* line 428, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products .product-ordered td {
background-color: #e9e9e9;
}
/* line 428, ../sass/distribution/_index.scss */
/* line 432, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products .product-ordered input.input-quantity {
font-size: 16px;
font-weight: bold;
}
/* line 434, ../sass/distribution/_index.scss */
/* line 438, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price {
width: 150px;
}
/* line 437, ../sass/distribution/_index.scss */
/* line 441, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price input {
text-align: center;
}
/* line 441, ../sass/distribution/_index.scss */
/* line 445, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price .input-group-addon {
background-color: #eee;
}
/* line 445, ../sass/distribution/_index.scss */
/* line 449, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price .invoice-price {
margin-top: 8px;
}
/* line 447, ../sass/distribution/_index.scss */
/* line 451, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.price .invoice-price .label-invoice-price {
font-size: 11px;
font-weight: bold;
color: gray;
}
/* line 455, ../sass/distribution/_index.scss */
/* line 459, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity {
width: 165px;
}
/* line 458, ../sass/distribution/_index.scss */
/* line 462, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity input {
text-align: center;
color: black;
}
/* line 463, ../sass/distribution/_index.scss */
/* line 467, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity .form-control {
border-right: 0px none;
padding-right: 4px;
}
/* line 468, ../sass/distribution/_index.scss */
/* line 472, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity .input-group-addon {
padding: 5px;
padding-left: 0px;
@@ -2604,35 +2608,35 @@ termes.
border-left: 0px none;
border-right: 0px none;
}
/* line 477, ../sass/distribution/_index.scss */
/* line 481, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining {
text-align: right;
}
/* line 480, ../sass/distribution/_index.scss */
/* line 484, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining.quantity-remaining, .distribution-index .modal-form-order table.table-products td.quantity-remaining.infinite {
color: #00A65A;
}
/* line 484, ../sass/distribution/_index.scss */
/* line 488, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining.negative {
color: #DD4B39;
}
/* line 488, ../sass/distribution/_index.scss */
/* line 492, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order table.table-products td.quantity-remaining.infinite, .distribution-index .modal-form-order table.table-products td.quantity-remaining.empty {
font-size: 18px;
}
/* line 495, ../sass/distribution/_index.scss */
/* line 499, ../sass/distribution/_index.scss */
.distribution-index .modal-form-order .actions-form button {
margin-left: 15px;
}
/* line 503, ../sass/distribution/_index.scss */
/* line 507, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-icon {
width: 50px;
}
/* line 506, ../sass/distribution/_index.scss */
/* line 510, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-icon i {
font-size: 30px;
}
/* line 511, ../sass/distribution/_index.scss */
/* line 515, ../sass/distribution/_index.scss */
.distribution-index .modal-payment .info-box .info-box-content {
margin-left: 50px;
}

+ 4
- 0
backend/web/sass/distribution/_index.scss View File

@@ -281,6 +281,10 @@ termes.
color: gray;
font-style: italic;
}

.user-trust-alert {
color: red;
}
}

td.column-delivery-note {

+ 28
- 0
console/migrations/m240320_092736_add_columns_user_trust_alert.php View File

@@ -0,0 +1,28 @@
<?php

use yii\db\Migration;
use yii\db\Schema;

/**
* Class m240320_092736_add_columns_user_trust_alert
*/
class m240320_092736_add_columns_user_trust_alert extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('user_producer', 'trust_alert', Schema::TYPE_BOOLEAN);
$this->addColumn('user_producer', 'trust_alert_comment', Schema::TYPE_TEXT);
}

/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('user_producer', 'trust_alert');
$this->dropColumn('user_producer', 'trust_alert_comment');
}
}

+ 7
- 3
domain/User/User/User.php View File

@@ -78,6 +78,8 @@ class User extends ActiveRecordCommon implements IdentityInterface
var $product_price_percent;
var $newsletter;
var $send_mail_welcome;
var $trust_alert;
var $trust_alert_comment;

/**
* @inheritdoc
@@ -106,8 +108,8 @@ class User extends ActiveRecordCommon implements IdentityInterface
[['no_mail', 'mail_distribution_monday', 'mail_distribution_tuesday', 'mail_distribution_wednesday',
'mail_distribution_thursday', 'mail_distribution_friday', 'mail_distribution_saturday',
'mail_distribution_sunday', 'is_main_contact', 'newsletter', 'exclude_export_shopping_cart_labels',
'send_mail_welcome'], 'boolean'],
[['lastname', 'name', 'phone', 'address', 'type', 'name_legal_person', 'evoliz_code'], 'string'],
'send_mail_welcome', 'trust_alert'], 'boolean'],
[['lastname', 'name', 'phone', 'address', 'type', 'name_legal_person', 'evoliz_code', 'trust_alert_comment'], 'string'],
['lastname', 'verifyOneName', 'skipOnError' => false, 'skipOnEmpty' => false],
[['email', 'email_sending_invoicing_documents'], 'email', 'message' => 'Cette adresse email n\'est pas valide'],
['email', 'verifyEmail'],
@@ -152,7 +154,9 @@ class User extends ActiveRecordCommon implements IdentityInterface
'newsletter' => "Inscrit au bulletin d'information",
'exclude_export_shopping_cart_labels' => "Exclure de l'export d'étiquettes",
'send_mail_welcome' => "Envoyer un email de bienvenue",
'email_sending_invoicing_documents' => 'Email facturation'
'email_sending_invoicing_documents' => 'Email facturation',
'trust_alert' => 'Alerte confiance',
'trust_alert_comment' => 'Commentaire',
];
}


+ 5
- 2
domain/User/UserProducer/UserProducer.php View File

@@ -63,8 +63,9 @@ class UserProducer extends ActiveRecordCommon
return [
[['id_user', 'id_producer'], 'required'],
[['id_user', 'id_producer', 'product_price_percent'], 'integer'],
[['active', 'bookmark', 'credit_active', 'newsletter'], 'boolean'],
[['active', 'bookmark', 'credit_active', 'newsletter', 'trust_alert'], 'boolean'],
[['credit', 'product_price_percent'], 'double'],
[['trust_alert_comment'], 'string']
];
}

@@ -79,7 +80,9 @@ class UserProducer extends ActiveRecordCommon
'active' => 'Actif',
'bookmark' => 'Favoris',
'credit_active' => 'Crédit',
'product_price_percent' => 'Prix produits : pourcentage'
'product_price_percent' => 'Prix produits : pourcentage',
'trust_alert' => 'Alert confiance',
'trust_alert_comment' => 'Commentaire',
];
}


Loading…
Cancel
Save