Переглянути джерело

[Administration] Utilisateurs : email facturation

feature/souke
Guillaume Bourgeois 8 місяці тому
джерело
коміт
bf82ab6d34
5 змінених файлів з 49 додано та 3 видалено
  1. +4
    -0
      backend/views/user/_form.php
  2. +26
    -0
      console/migrations/m240314_093700_add_column_user_email_invoicing.php
  3. +4
    -1
      domain/Document/Document/DocumentManager.php
  4. +3
    -2
      domain/User/User/User.php
  5. +12
    -0
      domain/User/User/UserSolver.php

+ 4
- 0
backend/views/user/_form.php Переглянути файл

@@ -81,6 +81,10 @@ $distributionModule = DistributionModule::getInstance();
<?= $form->field($model, 'send_mail_welcome')->checkbox() ?>
<?php endif; ?>
<?= $form->field($model, 'address')->textarea() ?>
<?= $form->field($model, 'email_sending_invoicing_documents')
->textInput()
->hint("Utilisé pour l'envoi des documents (devis, bons de livraisons et factures)")
?>
</div>
</div>


+ 26
- 0
console/migrations/m240314_093700_add_column_user_email_invoicing.php Переглянути файл

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

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

/**
* Class m240314_093700_add_column_user_email_invoicing
*/
class m240314_093700_add_column_user_email_invoicing extends Migration
{
/**
* {@inheritdoc}
*/
public function safeUp()
{
$this->addColumn('user', 'email_sending_invoicing_documents', Schema::TYPE_STRING);
}

/**
* {@inheritdoc}
*/
public function safeDown()
{
$this->dropColumn('user', 'email_sending_invoicing_documents');
}
}

+ 4
- 1
domain/Document/Document/DocumentManager.php Переглянути файл

@@ -3,12 +3,14 @@
namespace domain\Document\Document;

use domain\Producer\Producer\ProducerSolver;
use domain\User\User\UserSolver;
use kartik\mpdf\Pdf;
use domain\_\AbstractManager;
use yii\base\ErrorException;

class DocumentManager extends AbstractManager
{
protected UserSolver $userSolver;
protected DocumentSolver $documentSolver;
protected DocumentBuilder $documentBuilder;
protected ProducerSolver $producerSolver;
@@ -16,6 +18,7 @@ class DocumentManager extends AbstractManager

public function loadDependencies(): void
{
$this->userSolver = $this->loadService(UserSolver::class);
$this->documentSolver = $this->loadService(DocumentSolver::class);
$this->documentBuilder = $this->loadService(DocumentBuilder::class);
$this->producerSolver = $this->loadService(ProducerSolver::class);
@@ -124,7 +127,7 @@ class DocumentManager extends AbstractManager
], [
'document' => $document
])
->setTo($document->user->email)
->setTo($this->userSolver->getEmailSendingInvoicingDocuments($document->user))
->setFrom([$this->producerSolver->getEmailOpendistrib($producer) => $producer->name])
->setSubject('[' . $producer->name . '] ' . $subjectEmail);


+ 3
- 2
domain/User/User/User.php Переглянути файл

@@ -109,7 +109,7 @@ class User extends ActiveRecordCommon implements IdentityInterface
'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'],
[['email', 'email_sending_invoicing_documents'], 'email', 'message' => 'Cette adresse email n\'est pas valide'],
['email', 'verifyEmail'],
['status', 'default', 'value' => self::STATUS_ACTIVE],
['status', 'in', 'range' => [self::STATUS_ACTIVE, self::STATUS_DELETED, self::STATUS_ADMIN, self::STATUS_PRODUCER]],
@@ -151,7 +151,8 @@ 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"
'send_mail_welcome' => "Envoyer un email de bienvenue",
'email_sending_invoicing_documents' => 'Email facturation'
];
}


+ 12
- 0
domain/User/User/UserSolver.php Переглянути файл

@@ -278,4 +278,16 @@ class UserSolver extends AbstractService implements SolverInterface
return $userProducer;
}

public function getEmailSendingInvoicingDocuments(User $user): ?string
{
if($user->email_sending_invoicing_documents && strlen($user->email_sending_invoicing_documents) > 0) {
return $user->email_sending_invoicing_documents;
}

if($user->email && strlen($user->email) > 0) {
return $user->email;
}

return null;
}
}

Завантаження…
Відмінити
Зберегти