Merge remote-tracking branch 'origin/staging' into production

This commit is contained in:
Tiavina 2025-04-25 17:30:53 +03:00
commit f5d1426d12
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 OCP\AppFramework\Http\DataResponse;
use OCA\Gestion\Service\InvoicePdfService;
use OCP\IUserSession;
date_default_timezone_set('Europe/Paris');
class InvoiceController extends Controller
{
@ -25,6 +27,9 @@ class InvoiceController extends Controller
private $config;
private $user;
public function __construct(
$UserId,
@ -35,7 +40,8 @@ class InvoiceController extends Controller
InvoicePdfService $invoicePdfService,
IRootFolder $rootFolder,
IMailer $mailer,
MailerService $mailerService
MailerService $mailerService,
IUserSession $userSession
)
{
@ -46,6 +52,7 @@ class InvoiceController extends Controller
$this->gestionRepository = $bdd;
$this->mailerService = $mailerService;
$this->config = $config;
$this->user = $userSession->getUser();
try{
$this->storage = $rootFolder->getUserFolder($this->currentUserIdNextcloud);
@ -98,12 +105,7 @@ 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");
@ -117,9 +119,11 @@ 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]);
$authUserEmail = $this->user->getEMailAddress();
if ($authUserEmail) {
$message->setCc([$authUserEmail]);
}
$this->mailer->send($message);
$this->gestionRepository->setFactureSentDate($factureId);
} catch (Exception $e) {

View File

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

View File

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