Compare commits

..

9 Commits

Author SHA1 Message Date
796bea7d41 Merge branch 'production-dv-thanato' into production 2025-08-18 14:50:40 +03:00
ece8666881 fix add gitignore 2025-08-18 14:49:36 +03:00
9a1c8bca86 feat add is_tva client 2025-08-18 14:49:35 +03:00
narindraezway
d10dce3880 Refactor email signature handling to include user name in footer content 2025-08-18 14:49:34 +03:00
narindraezway
63ff1428d8 Update admin app ID 2025-08-18 14:49:34 +03:00
narindraezway
1983f506c8 Fix signature image dimensions email 2025-08-18 14:49:34 +03:00
Tiavina
458ad6588a log production dv thanato 2025-08-18 14:49:33 +03:00
Tiavina
7dd75e4076 Merge branch 'staging' into production 2025-08-01 13:40:43 +03:00
narindraezway
5a880677c4 Merge branch 'staging' into production 2025-07-09 13:50:01 +03:00
7 changed files with 121 additions and 184 deletions

4
.gitignore vendored
View File

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

View File

@ -1844,48 +1844,51 @@ 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); {
if($devis != null){ $devis = $this->myDb->getDevisOfDefunt($defuntId);
// try { if($devis != null) {
$senderEmailAddress = $this->config->getSystemValue('mail_from_address') ?? null; // try {
$senderEmailDomain = $this->config->getSystemValue('mail_domain') ?? null; $senderEmailAddress = $this->config->getSystemValue('mail_from_address') ?? null;
$senderEmail = null; $senderEmailDomain = $this->config->getSystemValue('mail_domain') ?? null;
if($senderEmailAddress && $senderEmailDomain){ $senderEmail = null;
$senderEmail = $senderEmailAddress.'@'.$senderEmailDomain; if($senderEmailAddress && $senderEmailDomain) {
} $senderEmail = $senderEmailAddress.'@'.$senderEmailDomain;
$client_email = $to; }
$client_nom = $devis['client_nom']; $client_email = $to;
$data = $this->storage->get($ff_pdf)->getContent(); $client_nom = $devis['client_nom'];
$message = $this->mailer->createMessage(); $data = $this->storage->get($ff_pdf)->getContent();
$message->setTo(recipients: [$client_email => $client_nom]); $message = $this->mailer->createMessage();
// $message->setFrom([$client_email => $client_nom]); $message->setTo(recipients: [$client_email => $client_nom]);
$content = $this->mailer->createAttachment($data, basename($ff_pdf), "application/pdf"); // $message->setFrom([$client_email => $client_nom]);
$message->attach($content); $content = $this->mailer->createAttachment($data, basename($ff_pdf), "application/pdf");
$message->setSubject($subject); $message->attach($content);
$body_text = $addName ? ($body." de ".$devis['defunt_nom'] ) : $body; $message->setSubject($subject);
$cautionText = "MERCI DE NE PAS REPONDRE A CET EMAIL."; $body_text = $addName ? ($body." de ".$devis['defunt_nom']) : $body;
$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>".
"<p>$cautionText</p>" $signature
); );
$appAdminEmail = BddConstant::DEFAULT_ATTESTATION_CC_EMAIL; $appAdminEmail = $this->myDb->getUserEmailByNextcloudId(BddConstant::DEFAULT_ADMIN_APP_ID_NEXTCLOUD);
$message->setCc([$appAdminEmail]); if ($appAdminEmail) {
$this->mailer->send($message); $message->setCc([$appAdminEmail]);
return new DataResponse("", 200, ['Content-Type' => 'application/json']); }
// } catch (Exception $e) { $this->mailer->send($message);
// return new DataResponse("Is your global mail server configured in Nextcloud ?", 500, ['Content-Type' => 'application/json']); 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']);
} // }
public function getUserNameForEmailSignature (){ }
$configs = json_decode($this->myDb->getConfiguration(self::DEFAULT_NEXTCLOUD_ADMIN)); }
$currentConfig = $configs[0]; public function getUserNameForEmailSignature()
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 LOWER(group_user.gid) = ? AND WHERE group_user.gid = ? AND
thanato.fk_user_uuid IS NULL; thanato.fk_user_uuid IS NULL;
"; ";
return $this->execSQL($sql,[strtolower(BddConstant::DEFAULT_THANATOS_GROUP_NAME)]); return $this->execSQL($sql, [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,21 +5329,6 @@ 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']);
@ -5352,7 +5337,6 @@ 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'],
@ -5360,6 +5344,7 @@ COMMENTAIRES: ".$comment;
$facture['year'], $facture['year'],
$devisMentionFilters $devisMentionFilters
); );
} else { } else {
$devisList = $this->getDevisDataGroupByFactureId($factureId, $devisMentionFilters); $devisList = $this->getDevisDataGroupByFactureId($factureId, $devisMentionFilters);
} }
@ -5370,7 +5355,6 @@ 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'],
@ -5382,36 +5366,22 @@ 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;
@ -5420,19 +5390,10 @@ 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;
public function Header() 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,32 +66,32 @@ class InvoiceGroupPdfHandler extends FPDF
$this->DrawInvoiceCompanyAndClientInfo(); $this->DrawInvoiceCompanyAndClientInfo();
$this->DrawInvoiceInfoTable(); $this->DrawInvoiceInfoTable();
} }
public function AddWatermark() function AddWatermark()
{ {
$this->SetAlpha(0.2); $this->SetAlpha(0.2);
$imagePath = $this->logoPath . "filigrane_pdf.png"; $imagePath = $this->logoPath . "filigrane_pdf.png";
list($originalWidth, $originalHeight) = getimagesize($imagePath); list($originalWidth, $originalHeight) = getimagesize($imagePath);
// Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm) // Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm)
// Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm) // Convertir les dimensions de pixels à mm (1 pixel = 0.264583 mm)
$originalWidth = $originalWidth * 0.264583; $originalWidth = $originalWidth * 0.264583;
$originalHeight = $originalHeight * 0.264583; $originalHeight = $originalHeight * 0.264583;
// Augmenter l'échelle, par exemple, 1.5 pour 150% de la taille d'origine // Augmenter l'échelle, par exemple, 1.5 pour 150% de la taille d'origine
$scale = 1.7; $scale = 1.7;
$width = $originalWidth * $scale; $width = $originalWidth * $scale;
$height = $originalHeight * $scale; $height = $originalHeight * $scale;
// Calculer la position pour centrer l'image // Calculer la position pour centrer l'image
$x = (210 - $width) / 2 + 15; // Décalage à droite de 15 mm $x = (210 - $width) / 2 + 15; // Décalage à droite de 15 mm
$y = ((297 - $height) / 2) + 21; // 297 mm est la hauteur d'une page A4 $y = ((297 - $height) / 2) + 21; // 297 mm est la hauteur d'une page A4
// Ajouter l'image en filigrane // Ajouter l'image en filigrane
$this->Image($imagePath, $x, $y, $width, $height); // Chemin, position x, position y, largeur, hauteur $this->Image($imagePath, $x, $y, $width, $height); // Chemin, position x, position y, largeur, hauteur
$this->SetAlpha(0.1); // Définir l'opacité $this->SetAlpha(0.1); // Définir l'opacité
} }
public function SetAlpha($alpha) 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
} }
public function Footer() function Footer()
{ {
$this->SetY(-34); $this->SetY(-34);
$this->SetFont('ComicSans', '', 7); $this->SetFont('ComicSans', '', 7);
@ -325,7 +325,7 @@ class InvoiceGroupPdfHandler extends FPDF
public function DrawArticlesTableValue() public function DrawArticlesTableValue()
{ {
// Set espacement avant de continue // Set espacement avant de continue
$this->SetFont('ComicSans', '', 10); $this->SetFont('ComicSans', '', 10);
$devisData = $this->factureData['devis']; $devisData = $this->factureData['devis'];
@ -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();
} }
public function MultiAlignCell($w, $h, $text, $border = 0, $ln = 0, $align = 'L', $fill = false) 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,22 +464,19 @@ class InvoiceGroupPdfHandler extends FPDF
} }
} }
public function NbLines($w, $txt) 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;
@ -495,25 +492,21 @@ 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;
} }
@ -523,42 +516,38 @@ 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;
@ -566,9 +555,8 @@ 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,17 +2,16 @@
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;
$isFactureClientGroup = $facture->isFactureClientGroup; $isFactureClientGroup = $facture->isFactureClientGroup;
$currentConfig = json_decode($_['configuration'])[0]; $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">
@ -35,7 +34,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')); ?>
@ -43,7 +42,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 }?>
@ -89,8 +88,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>
@ -114,43 +113,26 @@ foreach ($devisList as $currentDevis) {
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"> <td class="text-center"><?php echo (PriceHelpers::formatDecimalPrice($currentConfig->tva_default).'€'); ?></td>
<?php <td class="text-center"><?php echo (PriceHelpers::formatDecimalPrice($facture->totalTva).'€'); ?></td>
// Affichage simple : Exonéré ou taux par défaut <td class="text-center"><?php echo (PriceHelpers::formatDecimalPrice($facture->totalTtc).'€'); ?></td>
if (isset($facture->tvaInfo) && $facture->tvaInfo->is_exempt) { </tr>
echo 'Exonéré'; </tbody>
} else { </table>
echo PriceHelpers::formatDecimalPrice($facture->tvaInfo->rate).'%'; </div>
}
?>
</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>