Merge branch 'fixes/fixe/retour-hytha' into staging

This commit is contained in:
Narindra ezway 2025-04-25 16:55:36 +03:00
commit 33e3c43390
3 changed files with 24 additions and 15 deletions

View File

@ -12,6 +12,8 @@ use OCA\Gestion\Helpers\DateHelpers;
use OCA\Gestion\Service\MailerService; use OCA\Gestion\Service\MailerService;
use OCP\AppFramework\Http\DataResponse; use OCP\AppFramework\Http\DataResponse;
use OCA\Gestion\Service\InvoicePdfService; use OCA\Gestion\Service\InvoicePdfService;
use OCP\IUserSession;
date_default_timezone_set('Europe/Paris'); date_default_timezone_set('Europe/Paris');
class InvoiceController extends Controller class InvoiceController extends Controller
{ {
@ -25,6 +27,9 @@ class InvoiceController extends Controller
private $config; private $config;
private $user;
public function __construct( public function __construct(
$UserId, $UserId,
@ -35,7 +40,8 @@ class InvoiceController extends Controller
InvoicePdfService $invoicePdfService, InvoicePdfService $invoicePdfService,
IRootFolder $rootFolder, IRootFolder $rootFolder,
IMailer $mailer, IMailer $mailer,
MailerService $mailerService MailerService $mailerService,
IUserSession $userSession
) )
{ {
@ -46,6 +52,7 @@ class InvoiceController extends Controller
$this->gestionRepository = $bdd; $this->gestionRepository = $bdd;
$this->mailerService = $mailerService; $this->mailerService = $mailerService;
$this->config = $config; $this->config = $config;
$this->user = $userSession->getUser();
try{ try{
$this->storage = $rootFolder->getUserFolder($this->currentUserIdNextcloud); $this->storage = $rootFolder->getUserFolder($this->currentUserIdNextcloud);
@ -98,12 +105,7 @@ class InvoiceController extends Controller
$factureContent = $factureGeneratedResponse["content"]; $factureContent = $factureGeneratedResponse["content"];
$factureDate = DateHelpers::convertInvoiceDateToMonthAndYearOnly($facture['date_paiement']); $factureDate = DateHelpers::convertInvoiceDateToMonthAndYearOnly($facture['date_paiement']);
try { 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 = $this->mailer->createMessage();
$message->setTo(recipients: [$email => "Facture"]); $message->setTo(recipients: [$email => "Facture"]);
$content = $this->mailer->createAttachment($factureContent, "Facture.pdf", "application/pdf"); $content = $this->mailer->createAttachment($factureContent, "Facture.pdf", "application/pdf");
@ -117,9 +119,11 @@ class InvoiceController extends Controller
"<p> Vous trouverez en pièce jointe la facture des soins de « " . $factureDate . " » .</p>". "<p> Vous trouverez en pièce jointe la facture des soins de « " . $factureDate . " » .</p>".
$signature $signature
); );
if($senderEmail != null){ $authUserEmail = $this->user->getEMailAddress();
$message->setCc([$senderEmail]); if ($authUserEmail) {
$message->setCc([$authUserEmail]);
} }
$this->mailer->send($message); $this->mailer->send($message);
$this->gestionRepository->setFactureSentDate($factureId); $this->gestionRepository->setFactureSentDate($factureId);
} catch (Exception $e) { } catch (Exception $e) {

View File

@ -80,6 +80,9 @@ class PageController extends Controller {
private $rootFolder; private $rootFolder;
private $mailerService; private $mailerService;
/** /**
* Constructor * Constructor
*/ */
@ -99,7 +102,8 @@ class PageController extends Controller {
CertificateService $certificateService, CertificateService $certificateService,
TalkService $talkService, TalkService $talkService,
DevisPdfService $devisPdfService, DevisPdfService $devisPdfService,
MailerService $mailerService MailerService $mailerService,
) { ) {
parent::__construct($AppName, $request); parent::__construct($AppName, $request);
@ -1615,8 +1619,9 @@ class PageController extends Controller {
$signature $signature
); );
if($senderEmail != null){ $authUserEmail = $this->user->getEMailAddress();
$message->setCc([$senderEmail]); if ($authUserEmail) {
$message->setCc([$authUserEmail]);
} }
$this->mailer->send($message); $this->mailer->send($message);
return new DataResponse("", 200, ['Content-Type' => 'application/json']); return new DataResponse("", 200, ['Content-Type' => 'application/json']);

View File

@ -540,10 +540,10 @@ $coverProducts = $_['coverProducts'];
class="form-control rounded-sm" class="form-control rounded-sm"
placeholder="adresse email" placeholder="adresse email"
type="text" type="text"
value="<?= $_['defunt'][0]->client_group_mail ?? $_['defunt'][0]->client_mail; ?>" value="<?= $_['defunt'][0]->client_mail ?? '' ?>"
style="cursor:pointer;margin-right:8px;" style="cursor:pointer;margin-right:8px;"
id="valueSendEmailModal" id="valueSendEmailModal"
data-init-value="<?= $_['defunt'][0]->client_group_mail ?? $_['defunt'][0]->client_mail; ?>" data-init-value="<?= $_['defunt'][0]->client_mail ?? ''; ?>"
> >
</div> </div>
</div> </div>