Compare commits

..

16 Commits

Author SHA1 Message Date
61332b2b09 fix change is_tva in tva on Bdd.php 2025-08-24 21:44:44 +03:00
96d117ead5 feat add is_tva group facture 2025-08-24 21:29:34 +03:00
477196fa39 fix remove filigran_pdf in header 2025-08-24 21:23:39 +03:00
64d54fe4f5 feat add is_tva client 2025-08-19 23:02:52 +03:00
020244b4e0 fix delete signature mail 2025-08-19 17:31:18 +03:00
fb94393033 fix gitignore 2025-08-19 17:27:24 +03:00
Tiavina
3a05613b60 add dot in caution text 2025-07-17 12:05:25 +03:00
Tiavina
1f03b91871 update default email cc 2025-07-17 12:05:03 +03:00
Tiavina
760902963b add caution text in attestation email templates 2025-07-17 12:00:53 +03:00
Tiavina
21e8ee8d67 hotfiexs hfc 2025-07-16 15:39:33 +03:00
narindraezway
de0ed31ccb Merge branch 'staging' into production-dv-thanato 2025-07-11 11:03:04 +03:00
narindraezway
39f7cb6247 Refactor email signature handling to include user name in footer content 2025-07-09 16:44:45 +03:00
narindraezway
fd2754c9eb Update admin app ID 2025-07-09 16:44:09 +03:00
narindraezway
69eea552fb Fix signature image dimensions email 2025-07-09 16:43:13 +03:00
narindraezway
4db0935d71 Merge branch 'staging' into production-dv-thanato 2025-07-09 13:52:25 +03:00
Tiavina
9f8c3dc8ec log production dv thanato 2025-06-24 12:03:06 +03:00
7 changed files with 184 additions and 121 deletions

4
.gitignore vendored
View File

@ -5,10 +5,6 @@
!.gitignore !.gitignore
!Jenkinsfile !Jenkinsfile
# Dossiers à inclure
!calendar/
!gestion/
# Inclure tout le contenu de ces dossiers # Inclure tout le contenu de ces dossiers
!calendar/** !calendar/**
!gestion/** !gestion/**

View File

@ -13,4 +13,7 @@ abstract class BddConstant
const ISLEAVEPROPERTYONVCALENDAR = "ISLEAVE"; const ISLEAVEPROPERTYONVCALENDAR = "ISLEAVE";
const DEFAULT_THANATOS_GROUP_NAME = "Thanatos"; const DEFAULT_THANATOS_GROUP_NAME = "Thanatos";
const DEFAULT_ATTESTATION_CC_EMAIL = "attestation@h-f-c.info";
const DEFAULT_INVOICE_CC_EMAIL = "attestation@h-f-c.info";
} }

View File

@ -116,10 +116,8 @@ 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
); );
$appAdminEmail = $this->gestionRepository->getUserEmailByNextcloudId(BddConstant::DEFAULT_ADMIN_APP_ID_NEXTCLOUD); $appAdminEmail = BddConstant::DEFAULT_INVOICE_CC_EMAIL;
if ($appAdminEmail) { $message->setCc([$appAdminEmail]);
$message->setCc([$appAdminEmail]);
}
$this->mailer->send($message); $this->mailer->send($message);
$this->gestionRepository->setFactureSentDate($factureId); $this->gestionRepository->setFactureSentDate($factureId);

View File

@ -1844,51 +1844,48 @@ class PageController extends Controller
} }
public function sendAttachmentToClientByDefunt($defuntId, $ff_pdf, $to, $subject, $body, $addName = false) public function sendAttachmentToClientByDefunt($defuntId, $ff_pdf, $to,$subject, $body, $addName = false){
{ $devis = $this->myDb->getDevisOfDefunt($defuntId);
$devis = $this->myDb->getDevisOfDefunt($defuntId); if($devis != null){
if($devis != null) { // try {
// try { $senderEmailAddress = $this->config->getSystemValue('mail_from_address') ?? null;
$senderEmailAddress = $this->config->getSystemValue('mail_from_address') ?? null; $senderEmailDomain = $this->config->getSystemValue('mail_domain') ?? null;
$senderEmailDomain = $this->config->getSystemValue('mail_domain') ?? null; $senderEmail = null;
$senderEmail = null; if($senderEmailAddress && $senderEmailDomain){
if($senderEmailAddress && $senderEmailDomain) { $senderEmail = $senderEmailAddress.'@'.$senderEmailDomain;
$senderEmail = $senderEmailAddress.'@'.$senderEmailDomain; }
} $client_email = $to;
$client_email = $to; $client_nom = $devis['client_nom'];
$client_nom = $devis['client_nom']; $data = $this->storage->get($ff_pdf)->getContent();
$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, basename($ff_pdf), "application/pdf");
$content = $this->mailer->createAttachment($data, basename($ff_pdf), "application/pdf"); $message->attach($content);
$message->attach($content); $message->setSubject($subject);
$message->setSubject($subject); $body_text = $addName ? ($body." de ".$devis['defunt_nom'] ) : $body;
$body_text = $addName ? ($body." de ".$devis['defunt_nom']) : $body; $cautionText = "MERCI DE NE PAS REPONDRE A CET EMAIL.";
$signature = $this->mailerService->getFooterContent($this->getUserNameForEmailSignature()); $signature = $this->mailerService->getFooterContent($this->getUserNameForEmailSignature());
$message->setHtmlBody( $message->setHtmlBody(
"<p>Bonjour.</p>". "<p>Bonjour.</p>".
"<p>$body_text</p>". "<p>$body_text</p>".
$signature "<p>$cautionText</p>"
); );
$appAdminEmail = $this->myDb->getUserEmailByNextcloudId(BddConstant::DEFAULT_ADMIN_APP_ID_NEXTCLOUD); $appAdminEmail = BddConstant::DEFAULT_ATTESTATION_CC_EMAIL;
if ($appAdminEmail) { $message->setCc([$appAdminEmail]);
$message->setCc([$appAdminEmail]); $this->mailer->send($message);
} return new DataResponse("", 200, ['Content-Type' => 'application/json']);
$this->mailer->send($message); // } catch (Exception $e) {
return new DataResponse("", 200, ['Content-Type' => 'application/json']); // return new DataResponse("Is your global mail server configured in Nextcloud ?", 500, ['Content-Type' => 'application/json']);
// } catch (Exception $e) { // }
// return new DataResponse("Is your global mail server configured in Nextcloud ?", 500, ['Content-Type' => 'application/json']); }
// } }
} public function getUserNameForEmailSignature (){
} $configs = json_decode($this->myDb->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN));
public function getUserNameForEmailSignature() $currentConfig = $configs[0];
{ return $currentConfig->nom . " " . $currentConfig->prenom;
$configs = json_decode($this->myDb->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN)); }
$currentConfig = $configs[0];
return $currentConfig->nom . " " . $currentConfig->prenom;
}
/** /**
* @NoAdminRequired * @NoAdminRequired

View File

@ -4723,11 +4723,11 @@ COMMENTAIRES: ".$comment;
FROM ".self::DEFAULT_TABLE_PREFIX."users as users FROM ".self::DEFAULT_TABLE_PREFIX."users as users
JOIN .".self::DEFAULT_TABLE_PREFIX."group_user group_user ON users.uid = group_user.uid JOIN .".self::DEFAULT_TABLE_PREFIX."group_user group_user ON users.uid = group_user.uid
LEFT JOIN ".$this->tableprefix."thanato as thanato on users.uid = thanato.fk_user_uuid LEFT JOIN ".$this->tableprefix."thanato as thanato on users.uid = thanato.fk_user_uuid
WHERE group_user.gid = ? AND WHERE LOWER(group_user.gid) = ? AND
thanato.fk_user_uuid IS NULL; thanato.fk_user_uuid IS NULL;
"; ";
return $this->execSQL($sql, [BddConstant::DEFAULT_THANATOS_GROUP_NAME]); return $this->execSQL($sql,[strtolower(BddConstant::DEFAULT_THANATOS_GROUP_NAME)]);
} }
public function doDevisIdsListIdsBelongsToTheSameClientFacturationGroup(array $devisIds) public function doDevisIdsListIdsBelongsToTheSameClientFacturationGroup(array $devisIds)
@ -5318,7 +5318,7 @@ COMMENTAIRES: ".$comment;
$configuration = $this->getConfiguration(BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD); $configuration = $this->getConfiguration(BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD);
$configuration = json_decode($configuration); $configuration = json_decode($configuration);
$currentConfig = $configuration[0]; $currentConfig = $configuration[0];
$tvaValue = $currentConfig->tva_default;
$isFactureSingleClient = $facture['fk_client_id'] != null $isFactureSingleClient = $facture['fk_client_id'] != null
&& $facture['fk_client_id'] != 0; && $facture['fk_client_id'] != 0;
@ -5329,6 +5329,21 @@ COMMENTAIRES: ".$comment;
$devis = $this->getDevisByFkFactureId($factureId); $devis = $this->getDevisByFkFactureId($factureId);
$factureGroupIsRelatedToAnyDevis = $devis != null; $factureGroupIsRelatedToAnyDevis = $devis != null;
// LOGIQUE TVA SIMPLIFIÉE
$tvaValue = (float)$currentConfig->tva_default;
$isTvaApplicable = true;
// Récupérer le statut TVA du client de cette facture
$clientId = $facture['fk_client_id'];
if ($clientId != null && $clientId != 0) {
$client = $this->getClientById($clientId);
$client = $this->getClientById($clientId);
if (isset($client['tva']) && $client['tva'] == 0) {
$isTvaApplicable = false;
$tvaValue = 0;
}
}
if($isFactureSingleClient) { if($isFactureSingleClient) {
$client = $this->getClientById($facture['fk_client_id']); $client = $this->getClientById($facture['fk_client_id']);
@ -5337,6 +5352,7 @@ COMMENTAIRES: ".$comment;
$facture['client_address'] = $client["client_address"]; $facture['client_address'] = $client["client_address"];
$facture['siret'] = $client["client_legal_one"]; $facture['siret'] = $client["client_legal_one"];
$facture['mail'] = $client["client_mail"]; $facture['mail'] = $client["client_mail"];
if (!$factureGroupIsRelatedToAnyDevis) { if (!$factureGroupIsRelatedToAnyDevis) {
$devisList = $this->getDevisDataByClientIdAndMonthYear( $devisList = $this->getDevisDataByClientIdAndMonthYear(
$facture['fk_client_id'], $facture['fk_client_id'],
@ -5344,7 +5360,6 @@ COMMENTAIRES: ".$comment;
$facture['year'], $facture['year'],
$devisMentionFilters $devisMentionFilters
); );
} else { } else {
$devisList = $this->getDevisDataGroupByFactureId($factureId, $devisMentionFilters); $devisList = $this->getDevisDataGroupByFactureId($factureId, $devisMentionFilters);
} }
@ -5355,6 +5370,7 @@ COMMENTAIRES: ".$comment;
$facture['client_address'] = $clientGroupFacturation["address"] . ' - ' .$clientGroupFacturation["postal_code"] . ' ' . $clientGroupFacturation['city']; $facture['client_address'] = $clientGroupFacturation["address"] . ' - ' .$clientGroupFacturation["postal_code"] . ' ' . $clientGroupFacturation['city'];
$facture['siret'] = $clientGroupFacturation["siret_number"]; $facture['siret'] = $clientGroupFacturation["siret_number"];
$facture['mail'] = $clientGroupFacturation["email"]; $facture['mail'] = $clientGroupFacturation["email"];
if (!$factureGroupIsRelatedToAnyDevis) { if (!$factureGroupIsRelatedToAnyDevis) {
$devisList = $this->getDevisDataByClientGroupFacturationIdAndMonthYear( $devisList = $this->getDevisDataByClientGroupFacturationIdAndMonthYear(
$facture['fk_client_group_facturation_id'], $facture['fk_client_group_facturation_id'],
@ -5366,22 +5382,36 @@ COMMENTAIRES: ".$comment;
$devisList = $this->getDevisDataGroupByFactureId($factureId, $devisMentionFilters); $devisList = $this->getDevisDataGroupByFactureId($factureId, $devisMentionFilters);
} }
} }
$factureTotalHt = 0; $factureTotalHt = 0;
$factureTotalTva = 0; $factureTotalTva = 0;
$factureTotalTtc = 0; $factureTotalTtc = 0;
foreach($devisList as &$currentDevis) { foreach($devisList as &$currentDevis) {
$totalHt = 0; $totalHt = 0;
$totalTva = 0; $totalTva = 0;
$totalTtc = 0; $totalTtc = 0;
$devisProducts = $this->getDevisProduits($currentDevis['devis_id']); $devisProducts = $this->getDevisProduits($currentDevis['devis_id']);
foreach($devisProducts as $currentProduct) { foreach($devisProducts as $currentProduct) {
$valueHt = $currentProduct['produit_price'] * $currentProduct['quantite']; $valueHt = $currentProduct['produit_price'] * $currentProduct['quantite'];
$valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt, $tvaValue);
// CALCUL SIMPLE : TVA OU PAS TVA
if ($isTvaApplicable) {
// Client soumis à TVA : utiliser le taux par défaut
$valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt, $tvaValue);
$tvaAmount = $valueTtc - $valueHt;
} else {
// Client exonéré : TTC = HT
$valueTtc = $valueHt;
$tvaAmount = 0;
}
$totalHt += $valueHt; $totalHt += $valueHt;
$totalTtc += $valueTtc; $totalTtc += $valueTtc;
$tvaAmount = $valueTtc - $valueHt;
$totalTva += $tvaAmount; $totalTva += $tvaAmount;
} }
$currentDevis["totalHt"] = $totalHt; $currentDevis["totalHt"] = $totalHt;
$currentDevis["totalTtc"] = $totalTtc; $currentDevis["totalTtc"] = $totalTtc;
$currentDevis["totalTva"] = $totalTva; $currentDevis["totalTva"] = $totalTva;
@ -5390,10 +5420,19 @@ COMMENTAIRES: ".$comment;
$factureTotalTva += $totalTva; $factureTotalTva += $totalTva;
$facture["devisList"][] = $currentDevis; $facture["devisList"][] = $currentDevis;
} }
$facture["totalHt"] = $factureTotalHt; $facture["totalHt"] = $factureTotalHt;
$facture["totalTtc"] = $factureTotalTtc; $facture["totalTtc"] = $factureTotalTtc;
$facture["totalTva"] = $factureTotalTva; $facture["totalTva"] = $factureTotalTva;
$facture["isFactureClientGroup"] = !$isFactureSingleClient; $facture["isFactureClientGroup"] = !$isFactureSingleClient;
// INFOS TVA POUR LE TEMPLATE
$facture["tvaInfo"] = [
'is_applicable' => $isTvaApplicable,
'rate' => $tvaValue,
'is_exempt' => !$isTvaApplicable
];
return $facture; return $facture;
} }

View File

@ -27,7 +27,7 @@ declare(strict_types=1);
namespace OCA\Gestion\Service\InvoiceGroupPdfHandler; namespace OCA\Gestion\Service\InvoiceGroupPdfHandler;
use DateTime; use DateTime;
use \FPDF; use FPDF;
use OCA\Gestion\Helpers\FileExportHelpers; use OCA\Gestion\Helpers\FileExportHelpers;
use OCA\Gestion\Helpers\PriceHelpers; use OCA\Gestion\Helpers\PriceHelpers;
@ -54,11 +54,11 @@ class InvoiceGroupPdfHandler extends FPDF
public $additionalArticlesLineBasedOnMultiline = 0; public $additionalArticlesLineBasedOnMultiline = 0;
public $interLigneHeader = 5; public $interLigneHeader = 5;
function Header() public function Header()
{ {
if ($this->logo != "nothing") { if ($this->logo != "nothing") {
$this->Image($this->logoPath . "logo.png", 4, 2, 50, 35); $this->Image($this->logoPath . "logo.png", 4, 2, 50, 35);
$this->AddWatermark(); //$this->AddWatermark();
} else { } else {
$this->Cell(55, 30, ''); $this->Cell(55, 30, '');
} }
@ -66,7 +66,7 @@ class InvoiceGroupPdfHandler extends FPDF
$this->DrawInvoiceCompanyAndClientInfo(); $this->DrawInvoiceCompanyAndClientInfo();
$this->DrawInvoiceInfoTable(); $this->DrawInvoiceInfoTable();
} }
function AddWatermark() public function AddWatermark()
{ {
$this->SetAlpha(0.2); $this->SetAlpha(0.2);
@ -91,7 +91,7 @@ class InvoiceGroupPdfHandler extends FPDF
$this->SetAlpha(0.1); // Définir l'opacité $this->SetAlpha(0.1); // Définir l'opacité
} }
function SetAlpha($alpha) public function SetAlpha($alpha)
{ {
// Appliquer la transparence au document // Appliquer la transparence au document
$this->SetFillColor(255, 255, 255, $alpha * 255); $this->SetFillColor(255, 255, 255, $alpha * 255);
@ -106,7 +106,7 @@ class InvoiceGroupPdfHandler extends FPDF
} }
function Footer() public function Footer()
{ {
$this->SetY(-34); $this->SetY(-34);
$this->SetFont('ComicSans', '', 7); $this->SetFont('ComicSans', '', 7);
@ -335,7 +335,7 @@ class InvoiceGroupPdfHandler extends FPDF
$totalTva = 0; $totalTva = 0;
$yValue = $this->startingYOfArticlesTable + 13; $yValue = $this->startingYOfArticlesTable + 13;
// $maxDescriptionWidth = 102; // $maxDescriptionWidth = 102;
$maxDescriptionWidth = 104.3; $maxDescriptionWidth = 104.3;
$currentIndexPosition = $this->currentIndexPosition; $currentIndexPosition = $this->currentIndexPosition;
for ($currentIndexPosition; $currentIndexPosition < ($this->initialIndexPosition + $this->devisCountToGet); $currentIndexPosition++) { for ($currentIndexPosition; $currentIndexPosition < ($this->initialIndexPosition + $this->devisCountToGet); $currentIndexPosition++) {
$currentDevis = $devisData[$currentIndexPosition]; $currentDevis = $devisData[$currentIndexPosition];
@ -449,7 +449,7 @@ class InvoiceGroupPdfHandler extends FPDF
$this->DrawBankAndTotalPriceInfo(); $this->DrawBankAndTotalPriceInfo();
} }
function MultiAlignCell($w, $h, $text, $border = 0, $ln = 0, $align = 'L', $fill = false) public function MultiAlignCell($w, $h, $text, $border = 0, $ln = 0, $align = 'L', $fill = false)
{ {
// Store reset values for (x,y) positions // Store reset values for (x,y) positions
$x = $this->GetX() + $w; $x = $this->GetX() + $w;
@ -464,19 +464,22 @@ class InvoiceGroupPdfHandler extends FPDF
} }
} }
function NbLines($w, $txt) public function NbLines($w, $txt)
{ {
// Compute the number of lines a MultiCell of width w will take // Compute the number of lines a MultiCell of width w will take
if (!isset($this->CurrentFont)) if (!isset($this->CurrentFont)) {
$this->Error('No font has been set'); $this->Error('No font has been set');
}
$cw = $this->CurrentFont['cw']; $cw = $this->CurrentFont['cw'];
if ($w == 0) if ($w == 0) {
$w = $this->w - $this->rMargin - $this->x; $w = $this->w - $this->rMargin - $this->x;
}
$wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize; $wmax = ($w - 2 * $this->cMargin) * 1000 / $this->FontSize;
$s = str_replace("\r", '', (string) $txt); $s = str_replace("\r", '', (string) $txt);
$nb = strlen($s); $nb = strlen($s);
if ($nb > 0 && $s[$nb - 1] == "\n") if ($nb > 0 && $s[$nb - 1] == "\n") {
$nb--; $nb--;
}
$sep = -1; $sep = -1;
$i = 0; $i = 0;
$j = 0; $j = 0;
@ -492,21 +495,25 @@ class InvoiceGroupPdfHandler extends FPDF
$nl++; $nl++;
continue; continue;
} }
if ($c == ' ') if ($c == ' ') {
$sep = $i; $sep = $i;
}
$l += $cw[$c]; $l += $cw[$c];
if ($l > $wmax) { if ($l > $wmax) {
if ($sep == -1) { if ($sep == -1) {
if ($i == $j) if ($i == $j) {
$i++; $i++;
} else }
} else {
$i = $sep + 1; $i = $sep + 1;
}
$sep = -1; $sep = -1;
$j = $i; $j = $i;
$l = 0; $l = 0;
$nl++; $nl++;
} else } else {
$i++; $i++;
}
} }
return $nl; return $nl;
} }
@ -516,38 +523,42 @@ class InvoiceGroupPdfHandler extends FPDF
{ {
$k = $this->k; $k = $this->k;
$hp = $this->h; $hp = $this->h;
if ($style == 'F') if ($style == 'F') {
$op = 'f'; $op = 'f';
elseif ($style == 'FD' || $style == 'DF') } elseif ($style == 'FD' || $style == 'DF') {
$op = 'B'; $op = 'B';
else } else {
$op = 'S'; $op = 'S';
}
$MyArc = 4 / 3 * (sqrt(2) - 1); $MyArc = 4 / 3 * (sqrt(2) - 1);
$this->_out(sprintf('%.2F %.2F m', ($x + $r) * $k, ($hp - $y) * $k)); $this->_out(sprintf('%.2F %.2F m', ($x + $r) * $k, ($hp - $y) * $k));
$xc = $x + $w - $r; $xc = $x + $w - $r;
$yc = $y + $r; $yc = $y + $r;
$this->_out(sprintf('%.2F %.2F l', $xc * $k, ($hp - $y) * $k)); $this->_out(sprintf('%.2F %.2F l', $xc * $k, ($hp - $y) * $k));
if (strpos($corners, '2') === false) if (strpos($corners, '2') === false) {
$this->_out(sprintf('%.2F %.2F l', ($x + $w) * $k, ($hp - $y) * $k)); $this->_out(sprintf('%.2F %.2F l', ($x + $w) * $k, ($hp - $y) * $k));
else } else {
$this->_Arc($xc + $r * $MyArc, $yc - $r, $xc + $r, $yc - $r * $MyArc, $xc + $r, $yc); $this->_Arc($xc + $r * $MyArc, $yc - $r, $xc + $r, $yc - $r * $MyArc, $xc + $r, $yc);
}
$xc = $x + $w - $r; $xc = $x + $w - $r;
$yc = $y + $h - $r; $yc = $y + $h - $r;
$this->_out(sprintf('%.2F %.2F l', ($x + $w) * $k, ($hp - $yc) * $k)); $this->_out(sprintf('%.2F %.2F l', ($x + $w) * $k, ($hp - $yc) * $k));
if (strpos($corners, '3') === false) if (strpos($corners, '3') === false) {
$this->_out(sprintf('%.2F %.2F l', ($x + $w) * $k, ($hp - ($y + $h)) * $k)); $this->_out(sprintf('%.2F %.2F l', ($x + $w) * $k, ($hp - ($y + $h)) * $k));
else } else {
$this->_Arc($xc + $r, $yc + $r * $MyArc, $xc + $r * $MyArc, $yc + $r, $xc, $yc + $r); $this->_Arc($xc + $r, $yc + $r * $MyArc, $xc + $r * $MyArc, $yc + $r, $xc, $yc + $r);
}
$xc = $x + $r; $xc = $x + $r;
$yc = $y + $h - $r; $yc = $y + $h - $r;
$this->_out(sprintf('%.2F %.2F l', $xc * $k, ($hp - ($y + $h)) * $k)); $this->_out(sprintf('%.2F %.2F l', $xc * $k, ($hp - ($y + $h)) * $k));
if (strpos($corners, '4') === false) if (strpos($corners, '4') === false) {
$this->_out(sprintf('%.2F %.2F l', ($x) * $k, ($hp - ($y + $h)) * $k)); $this->_out(sprintf('%.2F %.2F l', ($x) * $k, ($hp - ($y + $h)) * $k));
else } else {
$this->_Arc($xc - $r * $MyArc, $yc + $r, $xc - $r, $yc + $r * $MyArc, $xc - $r, $yc); $this->_Arc($xc - $r * $MyArc, $yc + $r, $xc - $r, $yc + $r * $MyArc, $xc - $r, $yc);
}
$xc = $x + $r; $xc = $x + $r;
$yc = $y + $r; $yc = $y + $r;
@ -555,8 +566,9 @@ class InvoiceGroupPdfHandler extends FPDF
if (strpos($corners, '1') === false) { if (strpos($corners, '1') === false) {
$this->_out(sprintf('%.2F %.2F l', ($x) * $k, ($hp - $y) * $k)); $this->_out(sprintf('%.2F %.2F l', ($x) * $k, ($hp - $y) * $k));
$this->_out(sprintf('%.2F %.2F l', ($x + $r) * $k, ($hp - $y) * $k)); $this->_out(sprintf('%.2F %.2F l', ($x + $r) * $k, ($hp - $y) * $k));
} else } else {
$this->_Arc($xc - $r, $yc - $r * $MyArc, $xc - $r * $MyArc, $yc - $r, $xc, $yc - $r); $this->_Arc($xc - $r, $yc - $r * $MyArc, $xc - $r * $MyArc, $yc - $r, $xc, $yc - $r);
}
$this->_out($op); $this->_out($op);
} }

View File

@ -2,6 +2,7 @@
use OC\URLGenerator; use OC\URLGenerator;
use OCA\Gestion\Helpers\PriceHelpers; use OCA\Gestion\Helpers\PriceHelpers;
$facture = $_['facture']; $facture = $_['facture'];
$factureOrderNumber = $facture->facture_order_number == '' ? '-' : $facture->facture_order_number; $factureOrderNumber = $facture->facture_order_number == '' ? '-' : $facture->facture_order_number;
$factureCaseNumber = $facture->facture_case_number == '' ? '-' : $facture->facture_case_number; $factureCaseNumber = $facture->facture_case_number == '' ? '-' : $facture->facture_case_number;
@ -11,7 +12,7 @@ $currentConfig = json_decode($_['configuration'])[0];
<div class="bootstrap-iso"> <div class="bootstrap-iso">
<div id="factureId" data-id="<?php echo $facture->id; ?>"></div> <div id="factureId" data-id="<?php echo $facture->id; ?>"></div>
<div id="factureIdentifier" data-id="<?php echo $facture->id; ?>"></div> <div id="factureIdentifier" data-id="<?php echo $facture->id; ?>"></div>
<h2 class="mt-3 mb-3 text-center"> <?php echo ('Facture n° '.$facture->num); ?> <h2 class="mt-3 mb-3 text-center"> <?php echo('Facture n° '.$facture->num); ?>
</h2> </h2>
<hr /> <hr />
<div class="row"> <div class="row">
@ -34,7 +35,7 @@ $currentConfig = json_decode($_['configuration'])[0];
} else { } else {
echo "<span style='font-size:12px' id='Company-logo' data-html2canvas-ignore><b><center>" . $l->t('You can add your company logo here.') . "</center></b><br/><i>" . $l->t('To add a logo, drop the logo.png file in ".gestion" folder at the root of your Nextcloud Files app. Remember to set "Show hidden files".') . "</i><br/><br/><center>" . $l->t('This message will not appear on generated PDF.') . "</center></span>"; echo "<span style='font-size:12px' id='Company-logo' data-html2canvas-ignore><b><center>" . $l->t('You can add your company logo here.') . "</center></b><br/><i>" . $l->t('To add a logo, drop the logo.png file in ".gestion" folder at the root of your Nextcloud Files app. Remember to set "Show hidden files".') . "</i><br/><br/><center>" . $l->t('This message will not appear on generated PDF.') . "</center></span>";
} }
?> ?>
</div> </div>
<div class="col-5 h-100 m-0" style="min-height:250px;"> <div class="col-5 h-100 m-0" style="min-height:250px;">
<h5 class="p-3 m-0 text-dark text-center border border-2 border-dark"><?php p($l->t('TO')); ?> <h5 class="p-3 m-0 text-dark text-center border border-2 border-dark"><?php p($l->t('TO')); ?>
@ -42,7 +43,7 @@ $currentConfig = json_decode($_['configuration'])[0];
<p style="min-height:180px;" <p style="min-height:180px;"
class="p-3 m-0 h-100 text-center text-dark text-center border border-top-0 border-2 border-dark"> class="p-3 m-0 h-100 text-center text-dark text-center border border-top-0 border-2 border-dark">
<span><?php echo $facture->group_name; ?></span><br /> <span><?php echo $facture->group_name; ?></span><br />
<?php if($isFactureClientGroup == false){ <?php if($isFactureClientGroup == false) {
?> ?>
<span><?php echo $facture->client_name; ?></span><br /> <span><?php echo $facture->client_name; ?></span><br />
<?php }?> <?php }?>
@ -88,8 +89,8 @@ $currentConfig = json_decode($_['configuration'])[0];
<tbody> <tbody>
<?php <?php
$devisList = $facture->devisList; $devisList = $facture->devisList;
foreach ($devisList as $currentDevis) { foreach ($devisList as $currentDevis) {
?> ?>
<tr> <tr>
<td><?php echo $currentDevis->devis_full_number; ?></td> <td><?php echo $currentDevis->devis_full_number; ?></td>
<td><?php echo $currentDevis->defunt_nom; ?></td> <td><?php echo $currentDevis->defunt_nom; ?></td>
@ -113,26 +114,43 @@ $currentConfig = json_decode($_['configuration'])[0];
class="mb-2 btn btn-outline-success sendmail" class="mb-2 btn btn-outline-success sendmail"
><?php p($l->t('Send by email'));?></button> ><?php p($l->t('Send by email'));?></button>
</div> </div>
<div class="mt-0 table-responsive"> <div class="mt-0 table-responsive">
<table id="totalFactureGroupPrice" class="table table-striped table-xl"> <table id="totalFactureGroupPrice" class="table table-striped table-xl">
<thead class="bg-dark text-white"> <thead class="bg-dark text-white">
<tr> <tr>
<th class="text-center"><?php p($l->t('Total without VAT')); ?></th> <th class="text-center"><?php p($l->t('Total without VAT')); ?></th>
<th class="text-center"><?php p($l->t('VAT Rate')); ?></th> <th class="text-center"><?php p($l->t('VAT Rate')); ?></th>
<th class="text-center"><?php p($l->t('Total VAT')); ?></th> <th class="text-center"><?php p($l->t('Total VAT')); ?></th>
<th class="text-center"><?php p($l->t('Total Price')); ?></th> <th class="text-center"><?php p($l->t('Total Price')); ?></th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td class="text-center"><?php echo (PriceHelpers::formatDecimalPrice($facture->totalHt).'€'); ?></td> <td class="text-center"><?php echo PriceHelpers::formatDecimalPrice($facture->totalHt).'€'; ?></td>
<td class="text-center"><?php echo (PriceHelpers::formatDecimalPrice($currentConfig->tva_default).'€'); ?></td> <td class="text-center">
<td class="text-center"><?php echo (PriceHelpers::formatDecimalPrice($facture->totalTva).'€'); ?></td> <?php
<td class="text-center"><?php echo (PriceHelpers::formatDecimalPrice($facture->totalTtc).'€'); ?></td> // Affichage simple : Exonéré ou taux par défaut
</tr> if (isset($facture->tvaInfo) && $facture->tvaInfo->is_exempt) {
</tbody> echo 'Exonéré';
</table> } else {
</div> echo PriceHelpers::formatDecimalPrice($facture->tvaInfo->rate).'%';
}
?>
</td>
<td class="text-center">
<?php
if (isset($facture->tvaInfo) && $facture->tvaInfo->is_exempt) {
echo '0,00€';
} else {
echo PriceHelpers::formatDecimalPrice($facture->totalTva).'€';
}
?>
</td>
<td class="text-center"><?php echo PriceHelpers::formatDecimalPrice($facture->totalTtc).'€'; ?></td>
</tr>
</tbody>
</table>
</div>
<div class="col m-0 pb-0 alert alert-info text-center"> <div class="col m-0 pb-0 alert alert-info text-center">
<p><span id="mentions_default"><?php p($l->t('Please set in global configuration')); ?></span></p> <p><span id="mentions_default"><?php p($l->t('Please set in global configuration')); ?></span></p>
</div> </div>