[feat]: add send email to client from defunt certificate
This commit is contained in:
parent
528afe379e
commit
8c9194e504
File diff suppressed because one or more lines are too long
@ -1,3 +1,75 @@
|
||||
/*!
|
||||
* Bootstrap backdrop.js v5.2.3 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Bootstrap base-component.js v5.2.3 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Bootstrap component-functions.js v5.2.3 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Bootstrap config.js v5.2.3 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Bootstrap data.js v5.2.3 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Bootstrap event-handler.js v5.2.3 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Bootstrap focustrap.js v5.2.3 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Bootstrap index.js v5.2.3 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Bootstrap manipulator.js v5.2.3 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Bootstrap modal.js v5.2.3 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Bootstrap scrollbar.js v5.2.3 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Bootstrap selector-engine.js v5.2.3 (https://getbootstrap.com/)
|
||||
* Copyright 2011-2022 The Bootstrap Authors (https://github.com/twbs/bootstrap/graphs/contributors)
|
||||
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/main/LICENSE)
|
||||
*/
|
||||
|
||||
/*!
|
||||
* Sizzle CSS Selector Engine v2.3.9
|
||||
* https://sizzlejs.com/
|
||||
|
||||
@ -36,7 +36,7 @@ date_default_timezone_set('Europe/Paris');
|
||||
|
||||
class PageController extends Controller {
|
||||
private $idNextcloud;
|
||||
private $myDb;
|
||||
private Bdd $myDb;
|
||||
// private $src_path = "/var/www/html/apps/gestion/img/";
|
||||
private $src_path = "/var/www/html/custom_apps/gestion/img/";
|
||||
|
||||
@ -1580,6 +1580,28 @@ class PageController extends Controller {
|
||||
|
||||
}
|
||||
|
||||
public function sendAttachmentToClientByDefunt($defuntId, $ff_pdf, $subject, $body, $addName = false){
|
||||
$devis = $this->myDb->getDevisOfDefunt($defuntId);
|
||||
if($devis != null){
|
||||
try {
|
||||
$client_email = $devis['client_mail'];
|
||||
$client_nom = $devis['client_nom'];
|
||||
$data = file_get_contents($ff_pdf);
|
||||
$message = $this->mailer->createMessage();
|
||||
$message->setTo(recipients: [$client_email => $client_nom]);
|
||||
// $message->setFrom([$client_email => $client_nom]);
|
||||
$content = $this->mailer->createAttachment($data,$ff_pdf,"x-pdf");
|
||||
$message->attach($content);
|
||||
$message->setSubject($subject);
|
||||
$message->setPlainBody($addName ? $body." de ".$devis['defunt_nom']: $body);
|
||||
$this->mailer->send($message);
|
||||
return new DataResponse("", 200, ['Content-Type' => 'application/json']);
|
||||
} catch (Exception $e) {
|
||||
return new DataResponse("Is your global mail server configured in Nextcloud ?", 500, ['Content-Type' => 'application/json']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @NoAdminRequired
|
||||
* @NoCSRFRequired
|
||||
@ -2005,7 +2027,7 @@ class PageController extends Controller {
|
||||
* @NoCSRFRequired
|
||||
* @param string $numdefunt
|
||||
*/
|
||||
public function saveRapportSoin($numdefunt){
|
||||
public function saveRapportSoin($numdefunt, $isSendEmail = false){
|
||||
$defaultConfig = json_decode($this->myDb->getConfiguration(BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD));
|
||||
$defunt = json_decode($this->myDb->getOneDefunt($numdefunt, $this->idNextcloud))[0];
|
||||
$observations = json_decode($this->myDb->getListObservations($numdefunt, $this->idNextcloud));
|
||||
@ -2252,6 +2274,11 @@ class PageController extends Controller {
|
||||
$file_pdf = $this->storage->get($ff_pdf);
|
||||
$file_pdf->putContent($pdfContent);
|
||||
|
||||
if($ff_pdf != null && $isSendEmail){
|
||||
//send email
|
||||
$this->sendAttachmentToClientByDefunt($defunt->id, $ff_pdf, "Rapport soins", " Veuiller trouver ci-joint le rapport de soins de ".$nomDefunt.".");
|
||||
}
|
||||
|
||||
$res = array();
|
||||
$res['path'] = $folderDestination;
|
||||
return json_encode($res);
|
||||
@ -2291,7 +2318,7 @@ class PageController extends Controller {
|
||||
* @NoCSRFRequired
|
||||
* @param string $numdefunt
|
||||
*/
|
||||
public function saveRapportBijoux($numdefunt,$withPhotos = false){
|
||||
public function saveRapportBijoux($numdefunt,$withPhotos = false, $isSendEmail = false){
|
||||
if($withPhotos != null && $withPhotos == 1){
|
||||
$withPhotos = true;
|
||||
}
|
||||
@ -2428,6 +2455,11 @@ class PageController extends Controller {
|
||||
$file_pdf = $this->storage->get($ff_pdf);
|
||||
$file_pdf->putContent($pdfContent);
|
||||
|
||||
if($ff_pdf != null && $isSendEmail){
|
||||
//send email
|
||||
$this->sendAttachmentToClientByDefunt($defunt->id, $ff_pdf, "Rapport des bijoux", " Veuiller trouver ci-joint le rapport des bijoux de ".$nomDefunt.".");
|
||||
}
|
||||
|
||||
$res = array();
|
||||
$res['path'] = $folderDestination;
|
||||
return json_encode($res);
|
||||
@ -2636,9 +2668,13 @@ class PageController extends Controller {
|
||||
* @param int $defuntId
|
||||
*/
|
||||
|
||||
public function exportCareCertificate($defuntId){
|
||||
public function exportCareCertificate($defuntId, $isSendEmail = false){
|
||||
try{
|
||||
$careCertificateFilename = $this->certificateService->generateCareCertificate($defuntId,$this->idNextcloud);
|
||||
if($careCertificateFilename != null && $isSendEmail){
|
||||
//send email
|
||||
$this->sendAttachmentToClientByDefunt($defuntId, $careCertificateFilename, "Attestation de soins", " Veuiller trouver ci-joint l'attestation de soins ", true);
|
||||
}
|
||||
return $careCertificateFilename;
|
||||
}
|
||||
catch(\OCP\Files\NotFoundException $e) { }
|
||||
@ -2781,9 +2817,14 @@ class PageController extends Controller {
|
||||
* @param int $defuntId
|
||||
*/
|
||||
|
||||
public function saveAttestationPacemaker($defuntId){
|
||||
public function saveAttestationPacemaker($defuntId, $isSendEmail = false){
|
||||
try{
|
||||
$careCertificateFilename = $this->certificateService->generatePacemakerCertificate($defuntId,$this->idNextcloud);
|
||||
if($careCertificateFilename != null && $isSendEmail){
|
||||
//send email
|
||||
$this->sendAttachmentToClientByDefunt($defuntId, $careCertificateFilename, "Attestation pacemaker", " Veuiller trouver ci-joint l'attestation de pacemaker ", true);
|
||||
|
||||
}
|
||||
return $careCertificateFilename;
|
||||
}
|
||||
catch(\OCP\Files\NotFoundException $e) { }
|
||||
|
||||
@ -3444,6 +3444,7 @@ class Bdd {
|
||||
defunt.product_reference as defunt_product_reference,
|
||||
client.nom as client_nom,
|
||||
client.prenom as client_prenom,
|
||||
client.mail as client_mail,
|
||||
client.entreprise as client_entreprise,
|
||||
client.adresse as client_adresse,
|
||||
thanato.nom as thanato_nom,
|
||||
|
||||
@ -1,10 +1,11 @@
|
||||
import "@nextcloud/dialogs/dist/index.css";
|
||||
import Modal from 'bootstrap/js/dist/modal';
|
||||
import "datatables.net-dt/css/jquery.dataTables.css";
|
||||
import "../css/mycss.css";
|
||||
|
||||
import { globalConfiguration } from "./modules/mainFunction.mjs";
|
||||
import "./listener/main_listener";
|
||||
import { setDefuntCover, setDefuntPacemakerPhoto,setBijouxPhoto,getBibliotheques, getBijouxById, getHypodermiquesyId, getObservationsById, getproduits, saveAttestationPacemaker,exportCareCertificate, saveRapportBijoux, saveRapportSoin, updateDB } from "./modules/ajaxRequest.mjs";
|
||||
import { getBibliotheques, exportCareCertificate,getBijouxById, getHypodermiquesyId, getObservationsById, getproduits, saveAttestationPacemaker, saveRapportBijoux, saveRapportSoin, setBijouxPhoto, setDefuntCover, setDefuntPacemakerPhoto, updateDB } from "./modules/ajaxRequest.mjs";
|
||||
import { globalConfiguration } from "./modules/mainFunction.mjs";
|
||||
|
||||
let bibliotheques = [];
|
||||
let sortedBibliotheques = [];
|
||||
@ -99,15 +100,17 @@ window.addEventListener("DOMContentLoaded", function () {
|
||||
break;
|
||||
}
|
||||
}
|
||||
saveRapportBijoux({
|
||||
numdefunt: defuntid,
|
||||
withPhotos: selectedValue
|
||||
});
|
||||
$('#saveRapportBijouxModal').hide();
|
||||
modalElement.data('export-type', 'rapport-bijoux')
|
||||
modalElement.data('export-with-photos', selectedValue)
|
||||
modalElement.modal('show')
|
||||
// saveRapportBijoux({
|
||||
// numdefunt: defuntid,
|
||||
// withPhotos: selectedValue
|
||||
// });
|
||||
});
|
||||
|
||||
|
||||
|
||||
setDefuntCoverButton.addEventListener("click",function(){
|
||||
const productCoverRadios = document.getElementsByName('coverProductsRadioButton');
|
||||
let selectedValue = null;
|
||||
@ -123,15 +126,57 @@ window.addEventListener("DOMContentLoaded", function () {
|
||||
});
|
||||
})
|
||||
|
||||
const modalElement = $('#confirmSendEmailModal')
|
||||
const _ = new Modal(modalElement[0],{
|
||||
backdrop: false
|
||||
})
|
||||
$('#valdateSendEmailModal').on('click', function(){
|
||||
const type = modalElement.data('export-type')
|
||||
const isSendEmail = $('#valueSendEmailModal').is(':checked')
|
||||
switch(type){
|
||||
case 'care-certificate':
|
||||
exportCareCertificate({defuntId : defuntid, isSendEmail})
|
||||
break;
|
||||
case 'pacemaker':
|
||||
saveAttestationPacemaker({ defuntId: defuntid ,isSendEmail});
|
||||
break;
|
||||
case 'rapport-soin':
|
||||
saveRapportSoin({ numdefunt: defuntid ,isSendEmail});
|
||||
break;
|
||||
case 'rapport-bijoux':
|
||||
const selectedValue = modalElement.data('export-with-photos')
|
||||
saveRapportBijoux({
|
||||
numdefunt: defuntid,
|
||||
withPhotos: selectedValue ,
|
||||
isSendEmail
|
||||
});
|
||||
default:
|
||||
break;
|
||||
}
|
||||
modalElement.modal('hide')
|
||||
$('#valueSendEmailModal').prop('checked', false);
|
||||
})
|
||||
$('#closeSendEmailModal').on('click', function(){
|
||||
modalElement.data('export-type', null)
|
||||
modalElement.modal('hide')
|
||||
$('#valueSendEmailModal').prop('checked', false);
|
||||
})
|
||||
|
||||
exportCareCertificateButton.addEventListener("click",function(){
|
||||
exportCareCertificate({defuntId : defuntid});
|
||||
modalElement.data('export-type', 'care-certificate')
|
||||
modalElement.modal('show')
|
||||
// exportCareCertificate({defuntId : defuntid});
|
||||
})
|
||||
pacemakerBtn.addEventListener("click", function(){
|
||||
saveAttestationPacemaker({ defuntId: defuntid });
|
||||
modalElement.data('export-type', 'pacemaker')
|
||||
modalElement.modal('show')
|
||||
// saveAttestationPacemaker({ defuntId: defuntid });
|
||||
});
|
||||
|
||||
rapportSoinBtn.addEventListener("click", function(){
|
||||
saveRapportSoin({ numdefunt: defuntid });
|
||||
modalElement.data('export-type', 'rapport-soin')
|
||||
modalElement.modal('show')
|
||||
// saveRapportSoin({ numdefunt: defuntid });
|
||||
});
|
||||
|
||||
$(document).on("change", ".photoBijouUpload", function () {
|
||||
|
||||
@ -454,7 +454,9 @@
|
||||
</div>
|
||||
<div class="col-12" style="margin-bottom: 32px">
|
||||
<div class="d-flex flex-row justify-content-between">
|
||||
<div><h6>OBSERVATIONS</h6></div>
|
||||
<div>
|
||||
<h6>OBSERVATIONS</h6>
|
||||
</div>
|
||||
<button id="defuntAddObservation" class="btn btn-secondary" type="button">Ajouter une observation</button>
|
||||
</div>
|
||||
<hr>
|
||||
@ -474,7 +476,9 @@
|
||||
</div>
|
||||
<div class="col-12" style="margin-bottom: 32px">
|
||||
<div class="d-flex flex-row justify-content-between">
|
||||
<div><h6>BIJOU(X)</h6></div>
|
||||
<div>
|
||||
<h6>BIJOU(X)</h6>
|
||||
</div>
|
||||
<button id="defuntAddBijou" class="btn btn-secondary" type="button">Ajouter un bijou</button>
|
||||
</div>
|
||||
<hr>
|
||||
@ -519,4 +523,23 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal" id="confirmSendEmailModal" data-backdrop="false" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Confirmeation de l'envoi par email</h5>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="form-group form-check d-flex align-items-center">
|
||||
<input type="checkbox" style="cursor:pointer;margin-right:8px;" id="valueSendEmailModal">
|
||||
<label class="form-check-label" for="valueSendEmailModal">Envoyer un email ?</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button id="closeSendEmailModal" type="button" class="btn btn-secondary">Annuler</button>
|
||||
<button id="valdateSendEmailModal" type="button" class="btn btn-primary">Valider</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
Loading…
x
Reference in New Issue
Block a user