浏览代码

[Administration] Utilisateurs > import : gestion de l'email de bienvenue et groupes

feature/souke
Guillaume Bourgeois 1年前
父节点
当前提交
93968e5845
共有 6 个文件被更改,包括 33 次插入21 次删除
  1. +5
    -2
      backend/controllers/UserImportController.php
  2. +4
    -1
      backend/forms/UserImportUploadForm.php
  3. +12
    -10
      backend/views/distribution/index.php
  4. +1
    -0
      backend/views/user-import/index.php
  5. +7
    -5
      backend/web/js/backend.js
  6. +4
    -3
      common/logic/User/User/Service/UserBulkImporter.php

+ 5
- 2
backend/controllers/UserImportController.php 查看文件

@@ -68,11 +68,14 @@ class UserImportController extends BackendController
public function actionIndex()
{
$model = new UserImportUploadForm();
if (\Yii::$app->request->isPost) {
if ($model->load(\Yii::$app->request->post())) {
$model->file = UploadedFile::getInstance($model, 'file');
if($model->file && $model->validate()) {
try {
$this->getUserModule()->getBulkImporter()->import($model->file->tempName);
$this->getUserModule()->getBulkImporter()->import(
$model->file->tempName,
(bool) $model->send_mail_welcome
);
$this->setFlash('success', "Fichier importé.");
}
catch(ErrorException $exception) {

+ 4
- 1
backend/forms/UserImportUploadForm.php 查看文件

@@ -11,6 +11,7 @@ class UserImportUploadForm extends Model
* @var UploadedFile file attribute
*/
public $file;
public $send_mail_welcome;

/**
* @return array the validation rules.
@@ -19,13 +20,15 @@ class UserImportUploadForm extends Model
{
return [
[['file'], 'file', 'skipOnEmpty' => false, 'mimeTypes' => 'text/csv, text/plain'],
[['send_mail_welcome'], 'boolean']
];
}

public function attributeLabels()
{
return [
'file' => "Fichier d'import (CSV)"
'file' => "Fichier d'import (CSV)",
'send_mail_welcome' => "Envoyer un email de bienvenue aux utilisateurs importés"
];
}
}

+ 12
- 10
backend/views/distribution/index.php 查看文件

@@ -396,17 +396,19 @@ $this->setPageTitle('Distributions') ;
</div>
</td>
<td class="column-state-payment">
<a href="javascript:void(0);" @click="orderPaymentModalClick" :data-id-order="order.id">
<order-state-payment :order="order" :producer="producer"></order-state-payment>
</a>
<span class="glyphicon glyphicon-time" title="Débit automatique du crédit la veille de la distribution" v-if="order.amount != 0 && order.isCreditAutoPayment && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span>
<template v-if="!order.date_delete">
<a href="javascript:void(0);" @click="orderPaymentModalClick" :data-id-order="order.id">
<order-state-payment :order="order" :producer="producer"></order-state-payment>
</a>
<span class="glyphicon glyphicon-time" title="Débit automatique du crédit la veille de la distribution" v-if="order.amount != 0 && order.isCreditAutoPayment && (order.amount_paid == 0 || order.amount_paid < order.amount)"></span>

<div v-if="order.amount_paid > 0 && order.amount_paid < order.amount">
<span class="glyphicon glyphicon-alert"></span> Reste à payer
</div>
<div v-if="order.amount_paid > order.amount">
<span class="glyphicon glyphicon-alert"></span> Surplus à rembourser
</div>
<div v-if="order.amount_paid > 0 && order.amount_paid < order.amount">
<span class="glyphicon glyphicon-alert"></span> Reste à payer
</div>
<div v-if="order.amount_paid > order.amount">
<span class="glyphicon glyphicon-alert"></span> Surplus à rembourser
</div>
</template>
</td>
<td class="column-credit" v-if="!idActivePointSale || (pointSaleActive && pointSaleActive.credit == 1)">
<template v-if="order.isCreditContext">

+ 1
- 0
backend/views/user-import/index.php 查看文件

@@ -56,6 +56,7 @@ $this->addBreadcrumb($this->getTitle());
]); ?>

<?= $form->field($model, 'file')->fileInput() ?>
<?= $form->field($model, 'send_mail_welcome')->checkbox() ?>

<div class="form-group">
<?= Html::submitButton('Envoyer', ['class' => 'btn btn-primary']) ?>

+ 7
- 5
backend/web/js/backend.js 查看文件

@@ -67,13 +67,15 @@ 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');
if($('#app-user-form').length) {
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);
});
$fieldUserEmail.keyup(function () {
opendistrib_user_form_event($fieldUserEmail, $fieldSendMailWelcome);
});
}
}

function opendistrib_user_form_event($fieldUserEmail, $fieldSendMailWelcome) {

+ 4
- 3
common/logic/User/User/Service/UserBulkImporter.php 查看文件

@@ -30,7 +30,7 @@ class UserBulkImporter extends AbstractManager
/**
* @throws ErrorException
*/
public function import(string $fileName): void
public function import(string $fileName, bool $sendMailWelcome = true): void
{
$usersArray = $this->loadCsv($fileName);

@@ -44,7 +44,8 @@ class UserBulkImporter extends AbstractManager
$userData[self::PHONE],
$userData[self::ADDRESS],
$userData[self::NEWSLETTER],
Password::generate()
Password::generate(),
$sendMailWelcome
);
}
}
@@ -53,7 +54,7 @@ class UserBulkImporter extends AbstractManager
{
$usersArray = CSV::csv2array($fileName);

if(count($usersArray) && count($usersArray[0]) != 6) {
if(count($usersArray) && count($usersArray[0]) != 8) {
throw new ErrorException("Le fichier n'a pas le bon nombre de colonnes.
Veuillez vous baser sur le fichier d'exemple téléchargeable ci-dessous.");
}

正在加载...
取消
保存