Merge branch 'hytha/features/add-email-sender-to-cc-on-attestation' into staging
This commit is contained in:
commit
478bde8831
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
namespace OCA\Gestion\Controller;
|
||||
|
||||
use OCP\IConfig;
|
||||
use OCP\IRequest;
|
||||
use OCP\DB\Exception;
|
||||
use OCP\Mail\IMailer;
|
||||
@ -22,11 +23,14 @@ class InvoiceController extends Controller
|
||||
private $storage;
|
||||
private $mailerService;
|
||||
|
||||
private $config;
|
||||
|
||||
|
||||
public function __construct(
|
||||
$UserId,
|
||||
$AppName,
|
||||
IRequest $request,
|
||||
IConfig $config,
|
||||
Bdd $bdd,
|
||||
InvoicePdfService $invoicePdfService,
|
||||
IRootFolder $rootFolder,
|
||||
@ -41,6 +45,7 @@ class InvoiceController extends Controller
|
||||
$this->mailer = $mailer;
|
||||
$this->gestionRepository = $bdd;
|
||||
$this->mailerService = $mailerService;
|
||||
$this->config = $config;
|
||||
|
||||
try{
|
||||
$this->storage = $rootFolder->getUserFolder($this->currentUserIdNextcloud);
|
||||
@ -93,6 +98,12 @@ class InvoiceController extends Controller
|
||||
$factureContent = $factureGeneratedResponse["content"];
|
||||
$factureDate = DateHelpers::convertInvoiceDateToMonthAndYearOnly($facture['date_paiement']);
|
||||
try {
|
||||
$senderEmailAddress = $this->config->getSystemValue('mail_from_address') ?? null;
|
||||
$senderEmailDomain = $this->config->getSystemValue('mail_domain') ?? null;
|
||||
$senderEmail = null;
|
||||
if($senderEmailAddress && $senderEmailDomain){
|
||||
$senderEmail = $senderEmailAddress.'@'.$senderEmailDomain;
|
||||
}
|
||||
$message = $this->mailer->createMessage();
|
||||
$message->setTo(recipients: [$email => "Facture"]);
|
||||
$content = $this->mailer->createAttachment($factureContent, "Facture.pdf", "application/pdf");
|
||||
@ -106,6 +117,9 @@ class InvoiceController extends Controller
|
||||
"<p> Vous trouverez en pièce jointe la facture des soins de « " . $factureDate . " » .</p>".
|
||||
$signature
|
||||
);
|
||||
if($senderEmail != null){
|
||||
$message->setCc([$senderEmail]);
|
||||
}
|
||||
$this->mailer->send($message);
|
||||
$this->gestionRepository->setFactureSentDate($factureId);
|
||||
} catch (Exception $e) {
|
||||
|
||||
@ -1590,6 +1590,12 @@ class PageController extends Controller {
|
||||
$devis = $this->myDb->getDevisOfDefunt($defuntId);
|
||||
if($devis != null){
|
||||
// try {
|
||||
$senderEmailAddress = $this->config->getSystemValue('mail_from_address') ?? null;
|
||||
$senderEmailDomain = $this->config->getSystemValue('mail_domain') ?? null;
|
||||
$senderEmail = null;
|
||||
if($senderEmailAddress && $senderEmailDomain){
|
||||
$senderEmail = $senderEmailAddress.'@'.$senderEmailDomain;
|
||||
}
|
||||
$client_email = $to;
|
||||
$client_nom = $devis['client_nom'];
|
||||
$data = $this->storage->get($ff_pdf)->getContent();
|
||||
@ -1608,6 +1614,10 @@ class PageController extends Controller {
|
||||
"<p>$body_text</p>".
|
||||
$signature
|
||||
);
|
||||
|
||||
if($senderEmail != null){
|
||||
$message->setCc([$senderEmail]);
|
||||
}
|
||||
$this->mailer->send($message);
|
||||
return new DataResponse("", 200, ['Content-Type' => 'application/json']);
|
||||
// } catch (Exception $e) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user