feat add attestation absence pacemacker

This commit is contained in:
Tolotsoa 2025-09-30 14:23:03 +03:00
parent cfe88df7ba
commit 1a4068481f
8 changed files with 703 additions and 352 deletions

View File

@ -99,6 +99,7 @@ return [
// generation attestation pacemaker, rapport de soins, de bijoux // generation attestation pacemaker, rapport de soins, de bijoux
['name' => 'page#saveAttestationPacemaker', 'url' => '/saveAttestationPacemaker', 'verb' => 'POST'], ['name' => 'page#saveAttestationPacemaker', 'url' => '/saveAttestationPacemaker', 'verb' => 'POST'],
['name' => 'page#saveAttestationAbsentPacemaker', 'url' => '/saveAttestationAbsentPacemaker', 'verb' => 'POST'],
['name' => 'page#saveRapportSoin', 'url' => '/saveRapportSoin', 'verb' => 'POST'], ['name' => 'page#saveRapportSoin', 'url' => '/saveRapportSoin', 'verb' => 'POST'],
['name' => 'page#saveRapportBijoux', 'url' => '/saveRapportBijoux', 'verb' => 'POST'], ['name' => 'page#saveRapportBijoux', 'url' => '/saveRapportBijoux', 'verb' => 'POST'],

File diff suppressed because one or more lines are too long

View File

@ -2031,12 +2031,14 @@ class PageController extends Controller
* @NoAdminRequired * @NoAdminRequired
* @NoCSRFRequired * @NoCSRFRequired
*/ */
public function apiReloadFec() { public function apiReloadFec()
{
$this->reloadFec(); $this->reloadFec();
return new DataResponse("", 200, ['Content-Type' => 'application/json']); return new DataResponse("", 200, ['Content-Type' => 'application/json']);
} }
private function reloadFec(){ private function reloadFec()
{
$current_config = json_decode($this->myDb->getConfiguration($this->idNextcloud)); $current_config = json_decode($this->myDb->getConfiguration($this->idNextcloud));
$clean_folder = html_entity_decode($current_config[0]->path).'/'; $clean_folder = html_entity_decode($current_config[0]->path).'/';
@ -2072,8 +2074,7 @@ class PageController extends Controller
}; };
$facture_temp['montant_tva'] = ($facture_temp['montant_htc'] * $facture_temp['tva']) / 100; $facture_temp['montant_tva'] = ($facture_temp['montant_htc'] * $facture_temp['tva']) / 100;
$facture_temp['montant_ttc'] = $facture_temp['montant_tva'] + $facture_temp['montant_htc']; $facture_temp['montant_ttc'] = $facture_temp['montant_tva'] + $facture_temp['montant_htc'];
} } else {
else{
$devis = $this->myDb->getDevisByFkFactureId($facture->id); $devis = $this->myDb->getDevisByFkFactureId($facture->id);
$factureGroupIsRelatedToAnyDevis = $devis != null; $factureGroupIsRelatedToAnyDevis = $devis != null;
$mentionFilters = [ $mentionFilters = [
@ -2095,8 +2096,7 @@ class PageController extends Controller
$mentionFilters $mentionFilters
); );
} }
} } else {
else{
$facture_temp["client"] = $facture->group_code_comptable ?? '-'; $facture_temp["client"] = $facture->group_code_comptable ?? '-';
$facture_temp["nom_client"] = $facture->facture_group_name; $facture_temp["nom_client"] = $facture->facture_group_name;
@ -2138,10 +2138,10 @@ class PageController extends Controller
$data_temp = array(); $data_temp = array();
foreach ($data_factures as $key => $facture) { foreach ($data_factures as $key => $facture) {
$datesplit = explode('-', $facture['date_facture']); $datesplit = explode('-', $facture['date_facture']);
if($data_temp[strval($datesplit[0])]==NULL) { if($data_temp[strval($datesplit[0])] == null) {
$data_temp[strval($datesplit[0])][strval($datesplit[1])] = array(0 => $facture); $data_temp[strval($datesplit[0])][strval($datesplit[1])] = array(0 => $facture);
} else { } else {
if($data_temp[strval($datesplit[0])][strval($datesplit[1])]==NULL) { if($data_temp[strval($datesplit[0])][strval($datesplit[1])] == null) {
$data_temp[strval($datesplit[0])][strval($datesplit[1])] = array(0 => $facture); $data_temp[strval($datesplit[0])][strval($datesplit[1])] = array(0 => $facture);
} else { } else {
array_push($data_temp[strval($datesplit[0])][strval($datesplit[1])], $facture); array_push($data_temp[strval($datesplit[0])][strval($datesplit[1])], $facture);
@ -2174,7 +2174,8 @@ class PageController extends Controller
$_clean_folder = $clean_folder.'FEC/'.$key_annee.'/'; $_clean_folder = $clean_folder.'FEC/'.$key_annee.'/';
try { try {
$this->storage->newFolder($_clean_folder); $this->storage->newFolder($_clean_folder);
} catch(\OCP\Files\NotPermittedException $e) { } } catch(\OCP\Files\NotPermittedException $e) {
}
foreach ($annee as $key_mois => $mois) { foreach ($annee as $key_mois => $mois) {
// Initialize FEC headers // Initialize FEC headers
@ -2283,9 +2284,11 @@ class PageController extends Controller
} }
} }
} catch(\OCP\Files\NotFoundException $e) { } } catch(\OCP\Files\NotFoundException $e) {
}
} catch(\OCP\Files\NotPermittedException $e) { } } catch(\OCP\Files\NotPermittedException $e) {
}
} }
private function refreshFEC() private function refreshFEC()
@ -3659,6 +3662,29 @@ class PageController extends Controller
} }
/**
* @NoAdminRequired
* @NoCSRFRequired
* @param int $defuntId
*/
public function saveAttestationAbsentPacemaker($defuntId, $email = '')
{
try {
$careCertificateFilename = $this->certificateService->generatePacemakerAbsentCertificate($defuntId, $this->idNextcloud);
if($careCertificateFilename != null && trim($email) != '') {
//send email
$this->sendAttachmentToClientByDefunt($defuntId, $careCertificateFilename, $email, "Retrait de pile", "Vous trouverez en pièce jointe l'attestation de retrait de pile ", true);
}
return $careCertificateFilename;
} catch(\OCP\Files\NotFoundException $e) {
}
}
/** /**
* @NoAdminRequired * @NoAdminRequired
* @NoCSRFRequired * @NoCSRFRequired

View File

@ -29,12 +29,14 @@ namespace OCA\Gestion\Service\Certificate;
use DateTime; use DateTime;
use DateTimeImmutable; use DateTimeImmutable;
use OCA\Gestion\Db\Bdd; use OCA\Gestion\Db\Bdd;
use OCP\Files\IRootFolder;
use OCA\Gestion\Helpers\DateHelpers; use OCA\Gestion\Helpers\DateHelpers;
use OCA\Gestion\Service\Certificate\PdfHandler\CareCertificatePdfHandler; use OCA\Gestion\Service\Certificate\PdfHandler\CareCertificatePdfHandler;
use OCA\Gestion\Service\Certificate\PdfHandler\PacemakerCertificatePdfHandler; use OCA\Gestion\Service\Certificate\PdfHandler\PacemakerCertificatePdfHandler;
use OCP\Files\IRootFolder; use OCA\Gestion\Service\Certificate\PdfHandler\PacemakerAbsentCertificatePdfHandler;
class CertificateService { class CertificateService
{
/** @var Bdd */ /** @var Bdd */
private $gestionBdd; private $gestionBdd;
@ -44,12 +46,14 @@ class CertificateService {
private const DEFAULT_NEXTCLOUD_ADMIN = "admin"; private const DEFAULT_NEXTCLOUD_ADMIN = "admin";
public function __construct( public function __construct(
Bdd $gestionBdd, Bdd $gestionBdd,
IRootFolder $rootFolder) { IRootFolder $rootFolder
) {
$this->gestionBdd = $gestionBdd; $this->gestionBdd = $gestionBdd;
$this->rootFolder = $rootFolder; $this->rootFolder = $rootFolder;
} }
private function signatureImageExists(){ private function signatureImageExists()
{
$storage = $this->rootFolder->getUserFolder(self::DEFAULT_NEXTCLOUD_ADMIN); $storage = $this->rootFolder->getUserFolder(self::DEFAULT_NEXTCLOUD_ADMIN);
try { try {
if(isset($storage)) { if(isset($storage)) {
@ -58,13 +62,13 @@ class CertificateService {
} else { } else {
$signatureExist = false; $signatureExist = false;
} }
} } catch(\OCP\Files\NotFoundException $e) {
catch(\OCP\Files\NotFoundException $e) {
$signatureExist = false; $signatureExist = false;
} }
return $signatureExist; return $signatureExist;
} }
private function tamponImageExist(){ private function tamponImageExist()
{
$storage = $this->rootFolder->getUserFolder(self::DEFAULT_NEXTCLOUD_ADMIN); $storage = $this->rootFolder->getUserFolder(self::DEFAULT_NEXTCLOUD_ADMIN);
try { try {
if(isset($storage)) { if(isset($storage)) {
@ -73,14 +77,14 @@ class CertificateService {
} else { } else {
$signatureExist = false; $signatureExist = false;
} }
} } catch(\OCP\Files\NotFoundException $e) {
catch(\OCP\Files\NotFoundException $e) {
$signatureExist = false; $signatureExist = false;
} }
return $signatureExist; return $signatureExist;
} }
private function getLogo(){ private function getLogo()
{
$storage = $this->rootFolder->getUserFolder(self::DEFAULT_NEXTCLOUD_ADMIN); $storage = $this->rootFolder->getUserFolder(self::DEFAULT_NEXTCLOUD_ADMIN);
try { try {
try { try {
@ -92,14 +96,14 @@ class CertificateService {
} catch(\OCP\Files\NotFoundException $e) { } catch(\OCP\Files\NotFoundException $e) {
$file = $storage->get('/.gestion/logo.jpeg'); $file = $storage->get('/.gestion/logo.jpeg');
} }
} } catch(\OCP\Files\NotFoundException $e) {
catch(\OCP\Files\NotFoundException $e) {
return "nothing"; return "nothing";
} }
return base64_encode($file->getContent()); return base64_encode($file->getContent());
} }
private function setDevisOfDefuntDefaultValue($devisOfDefunt){ private function setDevisOfDefuntDefaultValue($devisOfDefunt)
{
$devisOfDefunt["devis_date"] = new DateTimeImmutable($devisOfDefunt["devis_date"]); $devisOfDefunt["devis_date"] = new DateTimeImmutable($devisOfDefunt["devis_date"]);
$locationOfDevis = ""; $locationOfDevis = "";
if($devisOfDefunt['lieu_nom'] != null) { if($devisOfDefunt['lieu_nom'] != null) {
@ -133,7 +137,8 @@ class CertificateService {
return $devisOfDefunt; return $devisOfDefunt;
} }
public function generateCareCertificate($defuntId,$idNextCloud){ public function generateCareCertificate($defuntId, $idNextCloud)
{
$storage = $this->rootFolder->getUserFolder($idNextCloud); $storage = $this->rootFolder->getUserFolder($idNextCloud);
$configs = json_decode($this->gestionBdd->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN)); $configs = json_decode($this->gestionBdd->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN));
$currentConfig = $configs[0]; $currentConfig = $configs[0];
@ -158,8 +163,7 @@ class CertificateService {
$pdf->SetCareCertificate(); $pdf->SetCareCertificate();
try { try {
$storage->newFolder($folderDestination); $storage->newFolder($folderDestination);
} } catch(\OCP\Files\NotPermittedException $e) {
catch(\OCP\Files\NotPermittedException $e) {
} }
$pdfContent = $pdf->Output('', 'S'); $pdfContent = $pdf->Output('', 'S');
$storage->newFile($filenamePath); $storage->newFile($filenamePath);
@ -168,7 +172,8 @@ class CertificateService {
return $filenamePath; return $filenamePath;
} }
private function getCareCertificateFolder($devisOfDefunt){ private function getCareCertificateFolder($devisOfDefunt)
{
$careCertificateFolder = 'CLIENTS/' $careCertificateFolder = 'CLIENTS/'
.mb_strtoupper($devisOfDefunt["client_nom"], 'UTF-8') .mb_strtoupper($devisOfDefunt["client_nom"], 'UTF-8')
.'/DEFUNTS/' .'/DEFUNTS/'
@ -178,12 +183,14 @@ class CertificateService {
return $careCertificateFolder; return $careCertificateFolder;
} }
private function GetCareCertificateFilename($devisOfDefunt){ private function GetCareCertificateFilename($devisOfDefunt)
{
$filename = 'ATTESTATION_SOIN_'.mb_strtoupper($devisOfDefunt['defunt_nom'], 'UTF-8'); $filename = 'ATTESTATION_SOIN_'.mb_strtoupper($devisOfDefunt['defunt_nom'], 'UTF-8');
return $filename; return $filename;
} }
private function getPacemakerCertificateFolder($devisOfDefunt){ private function getPacemakerCertificateFolder($devisOfDefunt)
{
$folder = 'CLIENTS/' $folder = 'CLIENTS/'
.mb_strtoupper($devisOfDefunt["client_nom"], 'UTF-8') .mb_strtoupper($devisOfDefunt["client_nom"], 'UTF-8')
.'/DEFUNTS/' .'/DEFUNTS/'
@ -193,12 +200,14 @@ class CertificateService {
return $folder; return $folder;
} }
private function getPacemakerCertificateFilename($devisOfDefunt){ private function getPacemakerCertificateFilename($devisOfDefunt)
{
$filename = 'ATTESTATION_PACEMAKER_'.mb_strtoupper($devisOfDefunt['defunt_nom'], 'UTF-8'); $filename = 'ATTESTATION_PACEMAKER_'.mb_strtoupper($devisOfDefunt['defunt_nom'], 'UTF-8');
return $filename; return $filename;
} }
public function generatePacemakerCertificate($defuntId,$idNextCloud){ public function generatePacemakerCertificate($defuntId, $idNextCloud)
{
$storage = $this->rootFolder->getUserFolder($idNextCloud); $storage = $this->rootFolder->getUserFolder($idNextCloud);
$configs = json_decode($this->gestionBdd->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN)); $configs = json_decode($this->gestionBdd->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN));
$currentConfig = $configs[0]; $currentConfig = $configs[0];
@ -223,8 +232,48 @@ class CertificateService {
$pdf->SetPacemakerCertificate(); $pdf->SetPacemakerCertificate();
try { try {
$storage->newFolder($folderDestination); $storage->newFolder($folderDestination);
} catch(\OCP\Files\NotPermittedException $e) {
} }
catch(\OCP\Files\NotPermittedException $e) { $pdfContent = $pdf->Output('', 'S');
$storage->newFile($filenamePath);
$pdfFile = $storage->get($filenamePath);
$pdfFile->putContent($pdfContent);
return $filenamePath;
}
private function getPacemakerAbsentCertificateFilename($devisOfDefunt)
{
$filename = 'ATTESTATION_ABSENCE_PACEMAKER_'.mb_strtoupper($devisOfDefunt['defunt_nom'], 'UTF-8');
return $filename;
}
public function generatePacemakerAbsentCertificate($defuntId, $idNextCloud)
{
$storage = $this->rootFolder->getUserFolder($idNextCloud);
$configs = json_decode($this->gestionBdd->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN));
$currentConfig = $configs[0];
$logo = $this->getLogo();
$devisOfDefunt = $this->gestionBdd->getDevisOfDefunt($defuntId);
if($devisOfDefunt == null) {
return null;
}
$devisOfDefunt["configuration"] = $currentConfig;
$devisOfDefunt = $this->setDevisOfDefuntDefaultValue($devisOfDefunt);
$clean_folder = html_entity_decode(string: $currentConfig->path).'/';
$pacemakerCertificateFolder = $this->getPacemakerCertificateFolder($devisOfDefunt);
$folderDestination = $clean_folder.$pacemakerCertificateFolder;
$pdfFilename = $this->getPacemakerAbsentCertificateFilename($devisOfDefunt);
$filenamePath = $clean_folder.$pacemakerCertificateFolder.$pdfFilename.'.pdf';
$pdf = new PacemakerAbsentCertificatePdfHandler();
$pdf->AddFont('ComicSans', '', 'Comic Sans MS.php');
$pdf->AddFont('ComicSans', 'B', 'comic-sans-bold.php');
$signatureImageExist = $this->signatureImageExists();
$tamponImageExist = $this->tamponImageExist();
$pdf->SetPacemakerCertificateData($devisOfDefunt, $logo, $signatureImageExist, $tamponImageExist);
$pdf->SetPacemakerCertificate();
try {
$storage->newFolder($folderDestination);
} catch(\OCP\Files\NotPermittedException $e) {
} }
$pdfContent = $pdf->Output('', 'S'); $pdfContent = $pdf->Output('', 'S');
$storage->newFile($filenamePath); $storage->newFile($filenamePath);

View File

@ -0,0 +1,239 @@
<?php
declare(strict_types=1);
/**
* Calendar App
*
* @copyright 2021 Anna Larch <anna.larch@gmx.net>
*
* @author Anna Larch <anna.larch@gmx.net>
* @author Richard Steinmetz <richard@steinmetz.cloud>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE
* License as published by the Free Software Foundation; either
* version 3 of the License, or any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
namespace OCA\Gestion\Service\Certificate\PdfHandler;
use DateTime;
use FPDF;
use OCA\Gestion\Helpers\DateHelpers;
use OCA\Gestion\Helpers\FileExportHelpers;
use OCA\Gestion\Helpers\PriceHelpers;
class PacemakerAbsentCertificatePdfHandler extends FPDF
{
private $devisOfDefunt = [];
private $logo = null;
private $signatureImageExist = false;
private $tamponImageExist = false;
private $imagePath = "/var/www/html/data/admin/files/.gestion/";
public function Header()
{
if ($this->logo != "nothing") {
$this->Image($this->imagePath . "logo.png", 10, 10, 50, 35);
}
// En-tête avec les informations de l'entreprise - SOUS le logo
$this->SetXY(10, 50); // Position sous le logo
$this->SetFont('Arial', 'B', 12);
$this->Cell(0, 5, FileExportHelpers::FormatTextForExport($this->devisOfDefunt['configuration']->entreprise), 0, 1);
$this->SetFont('Arial', '', 10);
$this->MultiCell(0, 4, FileExportHelpers::FormatTextForExport($this->devisOfDefunt['configuration']->adresse), 0, 'L');
if (isset($this->devisOfDefunt['configuration']->telephone)) {
$this->Cell(0, 4, 'Tel : ' . FileExportHelpers::FormatTextForExport($this->devisOfDefunt['configuration']->telephone), 0, 1);
}
if (isset($this->devisOfDefunt['thanato_reference'])) {
$this->Cell(0, 4, 'Habilitation : ' . FileExportHelpers::FormatTextForExport($this->devisOfDefunt['thanato_reference']), 0, 1);
}
if (isset($this->devisOfDefunt['configuration']->siret)) {
$this->Cell(0, 4, 'Siret : ' . FileExportHelpers::FormatTextForExport($this->devisOfDefunt['configuration']->siret), 0, 1);
}
}
public function Footer()
{
$this->SetY(-15);
$this->MultiCell(0, 5, utf8_decode(html_entity_decode($this->devisOfDefunt['configuration']->legal_one)), 0, 'C');
$this->MultiCell(0, 5, utf8_decode(html_entity_decode($this->devisOfDefunt['configuration']->adresse)), 0, 'C');
}
public function SetPacemakerCertificateData(array $devisOfDefunt, $logo = null, $signatureImageExist = false, $tamponImageExist = false)
{
$this->devisOfDefunt = $devisOfDefunt;
$this->logo = $logo;
$this->signatureImageExist = $signatureImageExist;
$this->tamponImageExist = $tamponImageExist;
}
public function SetPacemakerCertificate()
{
$this->AddPage();
$this->SetMargins(left: 20, top: 0, right: 20);
$this->SetPacemakerCertificateTitle();
$this->SetPacemakerCertificateContent();
}
private function SetPacemakerCertificateContent()
{
$this->SetY(100); // Position réduite après le titre
$this->SetFont('Arial', '', 12);
// Déterminer le genre selon la civilité
$civilite = isset($this->devisOfDefunt['thanato_civilite']) ? $this->devisOfDefunt['thanato_civilite'] : 'Madame';
$pronom = 'Je soussignée';
$profession = 'thanatopractrice diplômée';
// Adaptation selon la civilité
if (strtolower($civilite) === 'monsieur' || strtolower($civilite) === 'm.' || strtolower($civilite) === 'mr') {
$pronom = 'Je soussigné';
$profession = 'thanatopracteur diplômé';
}
// Texte principal avec genre adapté
$mainText = $pronom . ', ' . $civilite . ' ' .
mb_convert_encoding(html_entity_decode($this->devisOfDefunt['thanato_prenom']), 'ISO-8859-1', 'UTF-8'). ' ' .mb_convert_encoding(html_entity_decode($this->devisOfDefunt['thanato_nom']), 'ISO-8859-1', 'UTF-8').
', ' . $profession . ', certifie ne pas avoir constaté, à la palpation, la présence d\'un pacemaker pour :';
$this->MultiCell(0, 6, FileExportHelpers::FormatTextForExport($mainText));
$this->Ln(8);
// Nom du défunt
$this->SetFont('Arial', 'B', 12);
$this->Cell(20, 8, 'Nom :', 0, 0);
$this->SetFont('Arial', '', 12);
$this->Cell(0, 8, FileExportHelpers::FormatTextForExport(mb_convert_encoding(html_entity_decode($this->devisOfDefunt['defunt_nom']), 'ISO-8859-1', 'UTF-8')), 0, 1);
$this->Ln(3);
// Date
$this->SetFont('Arial', 'B', 12);
$this->Cell(20, 8, 'Date :', 0, 0);
$this->SetFont('Arial', '', 12);
if (isset($this->devisOfDefunt['devis_date'])) {
$this->Cell(0, 8, $this->devisOfDefunt['devis_date']->format('d/m/Y'), 0, 1);
} else {
$this->Cell(0, 8, '', 0, 1);
}
$this->Ln(3);
// Lieu d'intervention
$this->SetFont('Arial', 'B', 12);
$this->Cell(40, 8, 'Lieu d\'intervention :', 0, 0);
$this->SetFont('Arial', '', 12);
$lieu = isset($this->devisOfDefunt['lieu_intervention']) ?
$this->devisOfDefunt['lieu_intervention'] :
$this->devisOfDefunt['location_of_devis'];
// Utiliser MultiCell pour permettre le retour à la ligne
$this->SetX(20); // Retour au début de la ligne
$this->SetFont('Arial', 'B', 12);
$this->Cell(40, 8, 'Lieu d\'intervention :', 0, 1); // 1 pour aller à la ligne suivante
$this->SetFont('Arial', '', 12);
$this->MultiCell(0, 6, FileExportHelpers::FormatTextForExport($lieu), 0, 'L');
// Signatures et cachet - juste après le lieu d'intervention
$this->Ln(15); // Petit espace après le lieu d'intervention
if ($this->signatureImageExist) {
$this->Image($this->imagePath."sign.png", 140, $this->GetY(), 40, 16);
}
if($this->tamponImageExist) {
$this->SetXY(120, $this->GetY() + 20); // Augmenté de 5 à 20 pour plus d'espace
$this->Image($this->imagePath."sign.jpg", 120, $this->GetY(), 80, 35);
}
}
private function SetPacemakerCertificateTitle()
{
$this->SetY(y: 85); // Titre plus bas pour éviter l'en-tête
$this->SetFont('Arial', 'B', 16);
$this->Cell(0, 10, FileExportHelpers::FormatTextForExport('ATTESTATION D\'ABSENCE DE PACEMAKER'), 0, 1, 'C');
$this->Ln(5); // Espace réduit après le titre
}
public function MultiAlignCell($w, $h, $text, $border = 0, $ln = 0, $align = 'L', $fill = false)
{
// Store reset values for (x,y) positions
$x = $this->GetX() + $w;
$y = $this->GetY();
// Make a call to FPDF's MultiCell
$this->MultiCell($w, $h, $text, $border, $align, $fill);
// Reset the line position to the right, like in Cell
if ($ln == 0) {
$this->SetXY($x, $y);
}
}
public function NbLines($w, $txt)
{
// Compute the number of lines a MultiCell of width w will take
if (!isset($this->CurrentFont)) {
$this->Error('No font has been set');
}
$cw = $this->CurrentFont['cw'];
if ($w == 0) {
$w = $this->w - $this->rMargin - $this->x;
}
$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
$s = str_replace("\r", '', (string) $txt);
$nb = strlen($s);
if ($nb > 0 && $s[$nb - 1] == "\n") {
$nb--;
}
$sep = -1;
$i = 0;
$j = 0;
$l = 0;
$nl = 1;
while ($i < $nb) {
$c = $s[$i];
if ($c == "\n") {
$i++;
$sep = -1;
$j = $i;
$l = 0;
$nl++;
continue;
}
if ($c == ' ') {
$sep = $i;
}
$l += $cw[$c];
if ($l > $wmax) {
if ($sep == -1) {
if ($i == $j) {
$i++;
}
} else {
$i = $sep + 1;
}
$sep = -1;
$j = $i;
$l = 0;
$nl++;
} else {
$i++;
}
}
return $nl;
}
}

View File

@ -4,7 +4,7 @@ import "datatables.net-dt/css/jquery.dataTables.css";
import "../css/mycss.css"; import "../css/mycss.css";
import "./listener/main_listener"; import "./listener/main_listener";
import { getBibliotheques, exportCareCertificate,getBijouxById, getHypodermiquesyId, getObservationsById, getproduits, saveAttestationPacemaker, saveRapportBijoux, saveRapportSoin, setBijouxPhoto, setDefuntCover, setDefuntPacemakerPhoto, updateDB } from "./modules/ajaxRequest.mjs"; import { getBibliotheques, exportCareCertificate,getBijouxById, getHypodermiquesyId, getObservationsById, getproduits, saveAttestationPacemaker, saveAttestationAbsentPacemaker, saveRapportBijoux, saveRapportSoin, setBijouxPhoto, setDefuntCover, setDefuntPacemakerPhoto, updateDB } from "./modules/ajaxRequest.mjs";
import { globalConfiguration } from "./modules/mainFunction.mjs"; import { globalConfiguration } from "./modules/mainFunction.mjs";
let bibliotheques = []; let bibliotheques = [];
@ -77,6 +77,7 @@ window.addEventListener("DOMContentLoaded", function () {
}); });
var pacemakerBtn = document.getElementById("pacemakerBtn"); var pacemakerBtn = document.getElementById("pacemakerBtn");
var pacemakerAbsentBtn = document.getElementById("pacemakerAbsentBtn");
var rapportSoinBtn = document.getElementById("rapportSoinBtn"); var rapportSoinBtn = document.getElementById("rapportSoinBtn");
var exportCareCertificateButton = document.getElementById("exportCareCertificate"); var exportCareCertificateButton = document.getElementById("exportCareCertificate");
var setDefuntCoverButton = this.document.getElementById("coverProductsSetButton"); var setDefuntCoverButton = this.document.getElementById("coverProductsSetButton");
@ -144,6 +145,9 @@ window.addEventListener("DOMContentLoaded", function () {
case 'pacemaker': case 'pacemaker':
saveAttestationPacemaker({ defuntId: defuntid ,email: isSendEmail ? email: ''}); saveAttestationPacemaker({ defuntId: defuntid ,email: isSendEmail ? email: ''});
break; break;
case 'pacemakerAbsent':
saveAttestationAbsentPacemaker({ defuntId: defuntid ,email: isSendEmail ? email: ''});
break;
case 'rapport-soin': case 'rapport-soin':
saveRapportSoin({ numdefunt: defuntid ,email: isSendEmail ? email: ''}); saveRapportSoin({ numdefunt: defuntid ,email: isSendEmail ? email: ''});
break; break;
@ -182,6 +186,12 @@ window.addEventListener("DOMContentLoaded", function () {
modalElement.modal('show') modalElement.modal('show')
// saveAttestationPacemaker({ defuntId: defuntid }); // saveAttestationPacemaker({ defuntId: defuntid });
}); });
pacemakerAbsentBtn.addEventListener("click", function(){
modalTitle.text("Générer l'attestation d'absence pacemaker")
modalElement.data('export-type', 'pacemakerAbsent')
modalElement.modal('show')
// saveAttestationPacemaker({ defuntId: defuntid });
});
rapportSoinBtn.addEventListener("click", function(){ rapportSoinBtn.addEventListener("click", function(){
modalElement.data('export-type', 'rapport-soin') modalElement.data('export-type', 'rapport-soin')

View File

@ -678,6 +678,31 @@ export function saveAttestationPacemaker(myData) {
}); });
}; };
/**
* Save pdf in nextcloud
* @param {*} myData
*/
export function saveAttestationAbsentPacemaker(myData) {
showLoader();
$.ajax({
url: baseUrl + '/saveAttestationAbsentPacemaker',
type: 'POST',
contentType: 'application/json',
data: JSON.stringify(myData)
}).done(function (response) {
if(!response) {
showMessage('Ce defunt n\'appartient à aucun devis.');
} else {
showSuccess('Sauvegardé dans '+ response);
}
}).fail(function (response, code) {
showMessage(t('gestion', 'Erreur dans la génération d\'attestation pacemaker'));
}).always(function () {
hideLoader();
});
};
/** /**
* Save pdf in nextcloud * Save pdf in nextcloud
* @param {*} myData * @param {*} myData

View File

@ -30,6 +30,7 @@ $coverProducts = $_['coverProducts'];
<div class="div"> <div class="div">
<button id="exportCareCertificate" class="btn btn-secondary" type="button">Générer l'attestation de soins</button> <button id="exportCareCertificate" class="btn btn-secondary" type="button">Générer l'attestation de soins</button>
<button id="pacemakerBtn" class="btn btn-secondary" type="button">Générer l'attestation retrait de pile</button> <button id="pacemakerBtn" class="btn btn-secondary" type="button">Générer l'attestation retrait de pile</button>
<button id="pacemakerAbsentBtn" class="btn btn-secondary" type="button">Générer l'attestation d'Absence de Pacemacker</button>
<button id="rapportSoinBtn" class="btn btn-secondary" type="button">Générer le rapport de soins</button> <button id="rapportSoinBtn" class="btn btn-secondary" type="button">Générer le rapport de soins</button>
<button id="showRapportBijouxExportModal" class="btn btn-secondary" type="button" data-toggle="modal" data-target="#saveRapportBijouxModal">Générer le rapport des bijoux</button> <button id="showRapportBijouxExportModal" class="btn btn-secondary" type="button" data-toggle="modal" data-target="#saveRapportBijouxModal">Générer le rapport des bijoux</button>
</div> </div>