[update]: send email

This commit is contained in:
Tsiresy Milà 2025-03-06 17:24:27 +03:00
parent 8c9194e504
commit 8a8eaee297
4 changed files with 118 additions and 9 deletions

104
gestion/.gitignore vendored Normal file
View File

@ -0,0 +1,104 @@
### Intellij ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
## Directory-based project format
.idea/
/*.iml
# if you remove the above rule, at least ignore user-specific stuff:
# .idea/workspace.xml
# .idea/tasks.xml
# .idea/dictionaries
# and these sensitive or high-churn files:
# .idea/dataSources.ids
# .idea/dataSources.xml
# .idea/sqlDataSources.xml
# .idea/dynamic.xml
# and, if using gradle::
# .idea/gradle.xml
# .idea/libraries
## File-based project format
*.ipr
*.iws
## Additional for IntelliJ
out/
# generated by mpeltonen/sbt-idea plugin
.idea_modules/
# generated by JIRA plugin
atlassian-ide-plugin.xml
# generated by Crashlytics plugin (for Android Studio and Intellij)
com_crashlytics_export_strings.xml
### OSX ###
.DS_Store
.AppleDouble
.LSOverride
# Icon must end with two \r
Icon
# Thumbnails
._*
# Files that might appear on external disk
.Spotlight-V100
.Trashes
# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk
### Sass ###
build/.sass-cache/
### Composer ###
composer.phar
/vendor-bin/*/vendor
# vim ex mode
.vimrc
# kdevelop
.kdev
*.kdev4
build/
node_modules/
src/fonts
*.clover
# just sane ignores
.*.sw[po]
*.bak
*.BAK
*~
*.orig
*.class
.cvsignore
Thumbs.db
*.py[co]
_darcs/*
CVS/*
.svn/*
RCS/*
/.project
.php-cs-fixer.cache
.phpunit.result.cache
coverage/
js/public
css/public
!/src/
!/src/*

View File

@ -1583,22 +1583,22 @@ class PageController extends Controller {
public function sendAttachmentToClientByDefunt($defuntId, $ff_pdf, $subject, $body, $addName = false){ public function sendAttachmentToClientByDefunt($defuntId, $ff_pdf, $subject, $body, $addName = false){
$devis = $this->myDb->getDevisOfDefunt($defuntId); $devis = $this->myDb->getDevisOfDefunt($defuntId);
if($devis != null){ if($devis != null){
try { // try {
$client_email = $devis['client_mail']; $client_email = $devis['client_group_mail'] ?? $devis['client_email'];
$client_nom = $devis['client_nom']; $client_nom = $devis['client_nom'];
$data = file_get_contents($ff_pdf); $data = $this->storage->get($ff_pdf)->getContent();
$message = $this->mailer->createMessage(); $message = $this->mailer->createMessage();
$message->setTo(recipients: [$client_email => $client_nom]); $message->setTo(recipients: [$client_email => $client_nom]);
// $message->setFrom([$client_email => $client_nom]); // $message->setFrom([$client_email => $client_nom]);
$content = $this->mailer->createAttachment($data,$ff_pdf,"x-pdf"); $content = $this->mailer->createAttachment($data, "test.pdf", "application/pdf");
$message->attach($content); $message->attach($content);
$message->setSubject($subject); $message->setSubject($subject);
$message->setPlainBody($addName ? $body." de ".$devis['defunt_nom']: $body); $message->setPlainBody($addName ? $body." de ".$devis['defunt_nom']: $body);
$this->mailer->send($message); $this->mailer->send($message);
return new DataResponse("", 200, ['Content-Type' => 'application/json']); return new DataResponse("", 200, ['Content-Type' => 'application/json']);
} catch (Exception $e) { // } catch (Exception $e) {
return new DataResponse("Is your global mail server configured in Nextcloud ?", 500, ['Content-Type' => 'application/json']); // return new DataResponse("Is your global mail server configured in Nextcloud ?", 500, ['Content-Type' => 'application/json']);
} // }
} }
} }

View File

@ -735,10 +735,13 @@ class Bdd {
.$this->tableprefix."thanato.date_habilitation, " .$this->tableprefix."thanato.date_habilitation, "
.$this->tableprefix."thanato.reference as reference_habilitation, " .$this->tableprefix."thanato.reference as reference_habilitation, "
.$this->tableprefix."lieu.adresse as adresse_lieu, " .$this->tableprefix."lieu.adresse as adresse_lieu, "
.$this->tableprefix."client.mail as client_mail, "
.$this->tableprefix."client_group_facturation.email as client_group_mail, "
.$this->tableprefix."lieu.nom as nom_lieu .$this->tableprefix."lieu.nom as nom_lieu
FROM ".$this->tableprefix."defunt FROM ".$this->tableprefix."defunt
LEFT JOIN ".$this->tableprefix."devis on ".$this->tableprefix."devis.id_defunt = ".$this->tableprefix."defunt.id LEFT JOIN ".$this->tableprefix."devis on ".$this->tableprefix."devis.id_defunt = ".$this->tableprefix."defunt.id
LEFT JOIN ".$this->tableprefix."client on ".$this->tableprefix."devis.id_client = ".$this->tableprefix."client.id LEFT JOIN ".$this->tableprefix."client on ".$this->tableprefix."devis.id_client = ".$this->tableprefix."client.id
LEFT JOIN ".$this->tableprefix."client_group_facturation on ".$this->tableprefix."client.fk_client_group_facturation_id = ".$this->tableprefix."client_group_facturation.id
LEFT JOIN ".$this->tableprefix."lieu on ".$this->tableprefix."devis.id_lieu = ".$this->tableprefix."lieu.id LEFT JOIN ".$this->tableprefix."lieu on ".$this->tableprefix."devis.id_lieu = ".$this->tableprefix."lieu.id
LEFT JOIN ".$this->tableprefix."thanato on ".$this->tableprefix."devis.id_thanato = ".$this->tableprefix."thanato.id LEFT JOIN ".$this->tableprefix."thanato on ".$this->tableprefix."devis.id_thanato = ".$this->tableprefix."thanato.id
WHERE ".$this->tableprefix."defunt.id = ?"; WHERE ".$this->tableprefix."defunt.id = ?";
@ -3445,6 +3448,7 @@ class Bdd {
client.nom as client_nom, client.nom as client_nom,
client.prenom as client_prenom, client.prenom as client_prenom,
client.mail as client_mail, client.mail as client_mail,
client_group_facturation.email as client_group_mail,
client.entreprise as client_entreprise, client.entreprise as client_entreprise,
client.adresse as client_adresse, client.adresse as client_adresse,
thanato.nom as thanato_nom, thanato.nom as thanato_nom,
@ -3455,6 +3459,7 @@ class Bdd {
LEFT JOIN ".$this->tableprefix."lieu as lieu on devis.id_lieu = lieu.id LEFT JOIN ".$this->tableprefix."lieu as lieu on devis.id_lieu = lieu.id
LEFT JOIN ".$this->tableprefix."defunt as defunt on devis.id_defunt = defunt.id LEFT JOIN ".$this->tableprefix."defunt as defunt on devis.id_defunt = defunt.id
LEFT JOIN ".$this->tableprefix."client as client on devis.id_client = client.id LEFT JOIN ".$this->tableprefix."client as client on devis.id_client = client.id
LEFT JOIN ".$this->tableprefix."client_group_facturation as client_group_facturation on client.fk_client_group_facturation_id = client_group_facturation.id
LEFT JOIN ".$this->tableprefix."thanato as thanato on devis.id_thanato = thanato.id LEFT JOIN ".$this->tableprefix."thanato as thanato on devis.id_thanato = thanato.id
WHERE devis.id_defunt = ? ;"; WHERE devis.id_defunt = ? ;";

View File

@ -527,12 +527,12 @@ $coverProducts = $_['coverProducts'];
<div class="modal-dialog"> <div class="modal-dialog">
<div class="modal-content"> <div class="modal-content">
<div class="modal-header"> <div class="modal-header">
<h5 class="modal-title">Confirmeation de l'envoi par email</h5> <h5 class="modal-title">Confirmation de l'envoi par email</h5>
</div> </div>
<div class="modal-body"> <div class="modal-body">
<div class="form-group form-check d-flex align-items-center"> <div class="form-group form-check d-flex align-items-center">
<input type="checkbox" style="cursor:pointer;margin-right:8px;" id="valueSendEmailModal"> <input type="checkbox" style="cursor:pointer;margin-right:8px;" id="valueSendEmailModal">
<label class="form-check-label" for="valueSendEmailModal">Envoyer un email ?</label> <label class="form-check-label" for="valueSendEmailModal">Voulez-vous envoyer par email le fichier à <?= $_['defunt'][0]->client_group_mail ?? $_['defunt'][0]->client_mail;?> ?</label>
</div> </div>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">