Browse Source

[Administration] Utilisateurs : email facturation

feature/souke
Guillaume Bourgeois 8 months ago
parent
commit
bf82ab6d34
5 changed files with 49 additions and 3 deletions
  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 View File

<?= $form->field($model, 'send_mail_welcome')->checkbox() ?> <?= $form->field($model, 'send_mail_welcome')->checkbox() ?>
<?php endif; ?> <?php endif; ?>
<?= $form->field($model, 'address')->textarea() ?> <?= $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>
</div> </div>



+ 26
- 0
console/migrations/m240314_093700_add_column_user_email_invoicing.php View File

<?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 View File

namespace domain\Document\Document; namespace domain\Document\Document;


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


class DocumentManager extends AbstractManager class DocumentManager extends AbstractManager
{ {
protected UserSolver $userSolver;
protected DocumentSolver $documentSolver; protected DocumentSolver $documentSolver;
protected DocumentBuilder $documentBuilder; protected DocumentBuilder $documentBuilder;
protected ProducerSolver $producerSolver; protected ProducerSolver $producerSolver;


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



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

'send_mail_welcome'], 'boolean'], 'send_mail_welcome'], 'boolean'],
[['lastname', 'name', 'phone', 'address', 'type', 'name_legal_person', 'evoliz_code'], 'string'], [['lastname', 'name', 'phone', 'address', 'type', 'name_legal_person', 'evoliz_code'], 'string'],
['lastname', 'verifyOneName', 'skipOnError' => false, 'skipOnEmpty' => false], ['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'], ['email', 'verifyEmail'],
['status', 'default', 'value' => self::STATUS_ACTIVE], ['status', 'default', 'value' => self::STATUS_ACTIVE],
['status', 'in', 'range' => [self::STATUS_ACTIVE, self::STATUS_DELETED, self::STATUS_ADMIN, self::STATUS_PRODUCER]], ['status', 'in', 'range' => [self::STATUS_ACTIVE, self::STATUS_DELETED, self::STATUS_ADMIN, self::STATUS_PRODUCER]],
'evoliz_code' => 'Code client Evoliz', 'evoliz_code' => 'Code client Evoliz',
'newsletter' => "Inscrit au bulletin d'information", 'newsletter' => "Inscrit au bulletin d'information",
'exclude_export_shopping_cart_labels' => "Exclure de l'export d'étiquettes", '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 View File

return $userProducer; 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;
}
} }

Loading…
Cancel
Save