Procházet zdrojové kódy

[Administration] Utilisateurs > création : possibilité de choisir d'envoyer ou non l'email de bienvenue #1368

feature/souke
Guillaume Bourgeois před 1 rokem
rodič
revize
bd3a55c577
5 změnil soubory, kde provedl 55 přidání a 25 odebrání
  1. +3
    -2
      backend/controllers/UserController.php
  2. +3
    -0
      backend/views/user/_form.php
  3. +40
    -20
      backend/web/js/backend.js
  4. +4
    -1
      common/logic/User/User/Model/User.php
  5. +5
    -2
      common/logic/User/User/Service/UserBuilder.php

+ 3
- 2
backend/controllers/UserController.php Zobrazit soubor

@@ -148,7 +148,8 @@ class UserController extends BackendController
$model->phone,
$model->address,
$model->newsletter,
Password::generate()
Password::generate(),
$model->send_mail_welcome
);

$this->processLinkPointSale($model);
@@ -181,7 +182,7 @@ class UserController extends BackendController
if ($model->load(\Yii::$app->request->post()) && $model->save()) {

// on envoie le mail de bienvenue si le mail vient d'être défini
if (!strlen($previousMail) && strlen($model->email)) {
if (!strlen($previousMail) && strlen($model->email) && $model->send_mail_welcome) {
$password = Password::generate();
$userModule->setPassword($model, $password);
$model->username = $model->email;

+ 3
- 0
backend/views/user/_form.php Zobrazit soubor

@@ -68,6 +68,9 @@ $distributionModule = DistributionModule::getInstance();
<?= $form->field($model, 'name')->textInput() ?>
<?= $form->field($model, 'phone')->textInput() ?>
<?= $form->field($model, 'email')->textInput() ?>
<?php if(!$model->email): ?>
<?= $form->field($model, 'send_mail_welcome')->checkbox() ?>
<?php endif; ?>
<?= $form->field($model, 'address')->textarea() ?>

<?php if ($producerModule->getSolver()->getConfig('option_export_evoliz')): ?>

+ 40
- 20
backend/web/js/backend.js Zobrazit soubor

@@ -53,6 +53,7 @@ $(document).ready(function () {
opendistrib_dropdown_producers();
opendistrib_gridview_pagesize();
opendistrib_producers_admin();
opendistrib_user_form();
});

var UrlManager = {
@@ -65,8 +66,29 @@ var UrlManager = {
}
};

function opendistrib_user_form() {
var $fieldUserEmail = $('#app-user-form .field-user-email input');
var $fieldSendMailWelcome = $('#app-user-form .field-user-send_mail_welcome');

opendistrib_user_form_event($fieldUserEmail, $fieldSendMailWelcome);
$fieldUserEmail.keyup(function () {
opendistrib_user_form_event($fieldUserEmail, $fieldSendMailWelcome);
});
}

function opendistrib_user_form_event($fieldUserEmail, $fieldSendMailWelcome) {
var val = $fieldUserEmail.val();

if (val.length > 0) {
$fieldSendMailWelcome.show();
}
else {
$fieldSendMailWelcome.hide();
}
}

function opendistrib_producers_admin() {
$('.producer-admin-index .btn-alwaysdata, .producer-admin-index .btn-dolibarr').click(function() {
$('.producer-admin-index .btn-alwaysdata, .producer-admin-index .btn-dolibarr').click(function () {
var $button = $(this);
$button.attr('disabled', 'disabled');
axios.get($button.attr('href'), {})
@@ -79,47 +101,44 @@ function opendistrib_producers_admin() {
}

function opendistrib_gridview_pagesize() {
$('.gridview-pagesize select').change(function() {
$('.gridview-pagesize select').change(function () {
$(this).parent().parent().submit();
});
}

function opendistrib_dropdown_producers() {

$('.producer-menu .dropdown-toggle').click(function() {
$('.producer-menu .dropdown-toggle').click(function () {
$('.producer-menu .search-producer').focus();
});

$('.producer-menu .search-producer').keyup(function() {
$('.producer-menu .search-producer').keyup(function () {
var $alertNoResults = $('.producer-menu .li-alert-no-results');
var searchWords = $(this).val().toLowerCase();
var count = 0;

if(searchWords && searchWords.length > 0) {
$('.producer-menu li.producer').each(function() {
if($(this).find('a').text().toLowerCase().indexOf(searchWords) >= 0 || !searchWords) {
if (searchWords && searchWords.length > 0) {
$('.producer-menu li.producer').each(function () {
if ($(this).find('a').text().toLowerCase().indexOf(searchWords) >= 0 || !searchWords) {
$(this).show();
count ++;
}
else {
count++;
} else {
$(this).hide();
}
});

if(count) {
if (count) {
$alertNoResults.hide();
}
else {
} else {
$alertNoResults.show();
}
}
else {
} else {
$alertNoResults.hide();
$('.producer-menu li.producer').show();
}
});

$('#link-display-producers-offline').click(function() {
$('#link-display-producers-offline').click(function () {
$(this).hide();
$('.producer-menu .offline').show();
return false;
@@ -152,7 +171,7 @@ function opendistrib_menu_treeview() {
}

function opendistrib_product_index() {
$('body.product-index .toggle input').change(function() {
$('body.product-index .toggle input').change(function () {
var id = $(this).data('id');
var checked = $(this).prop('checked');
$.get(UrlManager.getBaseUrl() + 'product/ajax-toggle-status', {
@@ -207,7 +226,7 @@ function opendistrib_products_event_price_with_tax() {
taxRateSelected = 0;
}

if($('#product-price').length) {
if ($('#product-price').length) {
var price = $('#product-price').val().replace(',', '.');
if (price) {
$('#product-price-with-tax').val(getPriceWithTax(price, taxRateSelected));
@@ -276,7 +295,7 @@ function opendistrib_product_prices() {
opendistrib_product_prices_event_price_with_tax();
$('#productprice-price').change(opendistrib_product_prices_event_price_with_tax);
$('#productprice-price-with-tax').change(opendistrib_product_prices_event_price);
$('#reduction-increase-percent').change(function() {
$('#reduction-increase-percent').change(function () {
opendistrib_product_prices_event_reduction_increase();
});
}
@@ -305,6 +324,7 @@ function opendistrib_product_prices_event_price() {
opendistrib_product_prices_update_reduction_increase();
}
}

function opendistrib_product_prices_update_reduction_increase() {
var productPriceBase = $('#reduction-increase-percent').data('price-base');
var productPriceSpecific = $('#productprice-price').val().replace(',', '.');
@@ -315,7 +335,7 @@ function opendistrib_product_prices_update_reduction_increase() {
function opendistrib_product_prices_event_reduction_increase() {
var productPriceBase = $('#reduction-increase-percent').data('price-base');
var reductionIncreasePercent = $('#reduction-increase-percent').val();
if(reductionIncreasePercent) {
if (reductionIncreasePercent) {
var newPrice = productPriceBase + productPriceBase * (reductionIncreasePercent / 100);
$('#productprice-price').val(parseFloat(newPrice).toFixed(5));
opendistrib_product_prices_event_price_with_tax();

+ 4
- 1
common/logic/User/User/Model/User.php Zobrazit soubor

@@ -78,6 +78,7 @@ class User extends ActiveRecordCommon implements IdentityInterface
var $one_name;
var $product_price_percent;
var $newsletter;
var $send_mail_welcome;

/**
* @inheritdoc
@@ -105,7 +106,8 @@ class User extends ActiveRecordCommon implements IdentityInterface
return [
[['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'], 'boolean'],
'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'],
['lastname', 'verifyOneName', 'skipOnError' => false, 'skipOnEmpty' => false],
['email', 'email', 'message' => 'Cette adresse email n\'est pas valide'],
@@ -150,6 +152,7 @@ class User extends ActiveRecordCommon implements IdentityInterface
'evoliz_code' => 'Code client Evoliz',
'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"
];
}


+ 5
- 2
common/logic/User/User/Service/UserBuilder.php Zobrazit soubor

@@ -64,7 +64,8 @@ class UserBuilder extends AbstractBuilder
string $phone = null,
string $address = null,
bool $newsletter = true,
string $password = null
string $password = null,
bool $sendMailWelcome = true
): User
{
$userExist = null;
@@ -86,7 +87,9 @@ class UserBuilder extends AbstractBuilder
);
$this->create($user);

$this->userNotifier->sendMailWelcome($user, $password);
if($sendMailWelcome) {
$this->userNotifier->sendMailWelcome($user, $password);
}
}

$user->triggerEvent(

Načítá se…
Zrušit
Uložit