feat add is_tva client

This commit is contained in:
Tolotsoa 2025-08-18 14:49:35 +03:00
parent d10dce3880
commit 9a1c8bca86
37 changed files with 16645 additions and 4754 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,52 @@
<?php
declare(strict_types=1);
namespace OCA\Gestion\Migration;
use Closure;
use OCP\DB\ISchemaWrapper;
use OCP\Migration\IOutput;
use OCP\Migration\SimpleMigrationStep;
use OCP\IDBConnection;
/**
* Migration pour ajouter le champ is_tva à la table oc_gestion_client
*/
class Version20001Date20250812120000 extends SimpleMigrationStep
{
private IDbConnection $db;
public function __construct(IDbConnection $db)
{
$this->db = $db;
}
/**
* @param IOutput $output
* @param Closure $schemaClosure The `\Closure` returns a `ISchemaWrapper`
* @param array $options
* @return null|ISchemaWrapper
*/
public function changeSchema(IOutput $output, Closure $schemaClosure, array $options): ?ISchemaWrapper
{
/** @var ISchemaWrapper $schema */
$schema = $schemaClosure();
$tableprefix = "gestion_";
// Vérifier si la table existe
if ($schema->hasTable($tableprefix.'client')) {
$table = $schema->getTable($tableprefix.'client');
// Ajouter le champ is_tva s'il n'existe pas déjà
if (!$table->hasColumn('is_tva')) {
$table->addColumn('is_tva', 'smallint', [
'notnull' => true,
'default' => 1,
'comment' => 'Indique si le client est assujetti à la TVA (1=oui, 0=non)',
'unsigned' => true,
'length' => 1
]);
$output->info('Champ is_tva ajouté à la table gestion_client');
return $schema;
}
}
return null;
}
}

View File

@ -27,18 +27,17 @@ declare(strict_types=1);
namespace OCA\Gestion\Service\Devis\Pdf; namespace OCA\Gestion\Service\Devis\Pdf;
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;
class DevisPdfHandler extends FPDF class DevisPdfHandler extends FPDF
{ {
private $multipleDevisData = []; private $multipleDevisData = [];
private $devisData = []; private $devisData = [];
private $logo = null; private $logo = null;
private $logoPath = "/var/www/html/data/admin/files/.gestion/"; private $logoPath = "/var/www/html/data/admin/files/.gestion/";
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);
@ -46,7 +45,7 @@ class DevisPdfHandler extends FPDF
$this->Cell(55, 30, ''); $this->Cell(55, 30, '');
} }
} }
function Footer() public function Footer()
{ {
$this->SetY(-40); $this->SetY(-40);
$this->SetFont('ComicSans', '', 7); $this->SetFont('ComicSans', '', 7);
@ -119,67 +118,82 @@ class DevisPdfHandler extends FPDF
private function DrawArticlesTableHeader() private function DrawArticlesTableHeader()
{ {
$tvaValue = $this->devisData["configuration"]->tva_default; $tvaDefault = $this->devisData["configuration"]->tva_default;
$clientTvaStatus = isset($this->devisData["tva"]) ? (int)$this->devisData["tva"] : 1;
// Déterminer le libellé TVA selon le statut du client
$tvaLabel = ($clientTvaStatus === 0) ? "TVA 0%" : "TVA " . $tvaDefault . "%";
$this->SetFont('ComicSans', '', 10); $this->SetFont('ComicSans', '', 10);
$this->SetXY(10, 106); $this->SetXY(10, 106);
$this->Cell(20, 8, "Date", 0, 0, 'C'); $this->Cell(20, 8, "Date", 0, 0, 'C');
$this->SetXY(35, 106); $this->SetXY(35, 106);
$this->Cell(100, 8, "Description", 0, 0, 'C'); $this->Cell(100, 8, "Description", 0, 0, 'C');
$this->SetXY(135, 106); $this->SetXY(135, 106);
$this->Cell(20, 8, "Prix Uni. HT", 0, 0, 'C'); $this->Cell(20, 8, "Prix Uni. HT", 0, 0, 'C');
$this->SetXY(155, 106); $this->SetXY(155, 106);
$this->Cell(20, 8, 'TVA ' . $tvaValue . '%', 0, 0, 'C'); $this->Cell(20, 8, $tvaLabel, 0, 0, 'C');
$this->SetXY(175, 106); $this->SetXY(175, 106);
$this->Cell(25, 8, "Prix Uni. TTC", 0, 0, 'C'); $this->Cell(25, 8, "Prix Uni. TTC", 0, 0, 'C');
} }
public function DrawArticlesTableValueAndReturnTotalPrice() public function DrawArticlesTableValueAndReturnTotalPrice()
{ {
$this->SetFont('ComicSans', '', 10); $this->SetFont('ComicSans', '', 10);
$tvaValue = $this->devisData["configuration"]->tva_default; $tvaDefault = $this->devisData["configuration"]->tva_default;
$clientTvaStatus = isset($this->devisData["tva"]) ? (int)$this->devisData["tva"] : 1;
// Déterminer le taux de TVA à appliquer selon le statut du client
$tvaValue = ($clientTvaStatus === 0) ? 0 : $tvaDefault;
$tvaLabel = ($clientTvaStatus === 0) ? "0%" : $tvaDefault . "%";
$totalHt = 0; $totalHt = 0;
$totalTtc = 0; $totalTtc = 0;
$totalTva = 0; $totalTva = 0;
$products = $this->devisData["products"]; $products = $this->devisData["products"];
$yValue = 116; $yValue = 116;
foreach ($products as $product) { foreach ($products as $product) {
$valueHt = $product['produit_price'] * $product['quantite']; $valueHt = $product['produit_price'] * $product['quantite'];
// Calculer la TVA selon le statut du client
if ($clientTvaStatus === 0) {
// Client exonéré - pas de TVA
$valueTtc = $valueHt;
$tvaAmount = 0;
} else {
// Client soumis à la TVA - utiliser le calcul normal
$valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt, $tvaValue); $valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt, $tvaValue);
$tvaAmount = $valueTtc - $valueHt;
}
$totalHt += $valueHt; $totalHt += $valueHt;
$totalTtc += $valueTtc; $totalTtc += $valueTtc;
$totalTva += $tvaAmount;
$productDescription = $product["produit_description"]; $productDescription = $product["produit_description"];
$dateValue = ""; $dateValue = "";
if ($product === end($products)) { if ($product === end($products)) {
$dateValue = $this->devisData['devis_date']; $dateValue = $this->devisData['devis_date'];
$productDescription .= " de " . FileExportHelpers::GetSexeLabel($this->devisData['defunt_sexe']) . ' ' . $this->devisData["defunt_nom"]; $productDescription .= " de " . FileExportHelpers::GetSexeLabel($this->devisData['defunt_sexe']) . ' ' . $this->devisData["defunt_nom"];
} }
$tvaAmount = $valueTtc - $valueHt;
$this->SetXY(10, $yValue); $this->SetXY(10, $yValue);
$this->Cell(20, 6, $dateValue, 0, 0); $this->Cell(20, 6, $dateValue, 0, 0);
$this->SetXY(35, $yValue); $this->SetXY(35, $yValue);
$this->MultiAlignCell(100, 6, utf8_decode(html_entity_decode($productDescription)), 0, '0', ); $this->MultiAlignCell(100, 6, utf8_decode(html_entity_decode($productDescription)), 0, '0', );
$this->SetXY(135, $yValue); $this->SetXY(135, $yValue);
$this->Cell(20, 6, number_format($valueHt, 2, '.', '') . chr(128), 0, 0, 'C'); $this->Cell(20, 6, number_format($valueHt, 2, '.', '') . chr(128), 0, 0, 'C');
$this->SetXY(155, $yValue); $this->SetXY(155, $yValue);
$this->Cell(20, 6, number_format($tvaAmount, 2, '.', '') . chr(128), 0, 0, 'C'); $this->Cell(20, 6, number_format($tvaAmount, 2, '.', '') . chr(128), 0, 0, 'C');
$this->SetXY(175, $yValue); $this->SetXY(175, $yValue);
$this->Cell(25, 6, number_format($valueTtc, 2, '.', '') . chr(128), 0, 1, 'C'); $this->Cell(25, 6, number_format($valueTtc, 2, '.', '') . chr(128), 0, 1, 'C');
$yValue += 12; $yValue += 12;
$totalTva += $tvaAmount;
} }
return [ return [
"TOTAL HT" => $totalHt, "TOTAL HT" => $totalHt,
"TVA " . $tvaValue . "%" => $totalTva, "TVA " . $tvaLabel => $totalTva,
"TOTAL TTC" => $totalTtc "TOTAL TTC" => $totalTtc
]; ];
} }
@ -234,7 +248,7 @@ class DevisPdfHandler extends FPDF
$this->DrawBankAndTotalPriceInfo($totalPriceValue); $this->DrawBankAndTotalPriceInfo($totalPriceValue);
} }
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;
@ -249,19 +263,22 @@ class DevisPdfHandler 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;
@ -277,22 +294,26 @@ class DevisPdfHandler 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;
} }
} }

View File

@ -25,6 +25,7 @@ declare(strict_types=1);
*/ */
namespace OCA\Gestion\Service\Devis\Pdf; namespace OCA\Gestion\Service\Devis\Pdf;
require_once __DIR__ . '/../../../../vendor/autoload.php'; require_once __DIR__ . '/../../../../vendor/autoload.php';
use DateTime; use DateTime;
@ -90,6 +91,7 @@ class DevisPdfService
private function formatDevisDataToPdfDataFormat($devis, $configuration) private function formatDevisDataToPdfDataFormat($devis, $configuration)
{ {
$devisDate = $devis['devis_date']; $devisDate = $devis['devis_date'];
$tva = isset($devis["tva"]) ? $devis["tva"] : 1;
$devisDate = DateTime::createFromFormat('Y-m-d', $devisDate); $devisDate = DateTime::createFromFormat('Y-m-d', $devisDate);
$devisDate = $devisDate->format('d-m-Y'); $devisDate = $devisDate->format('d-m-Y');
$devis['devis_date'] = $devisDate; $devis['devis_date'] = $devisDate;
@ -99,6 +101,7 @@ class DevisPdfService
$firstClient = $this->gestionBdd->getFirstClient(); $firstClient = $this->gestionBdd->getFirstClient();
$devis["siret"] = $firstClient != null ? $firstClient['legal_one'] : ''; $devis["siret"] = $firstClient != null ? $firstClient['legal_one'] : '';
$devis["products"] = $products; $devis["products"] = $products;
$devis["tva"] = $tva;
$clientAdresses = FileExportHelpers::GetAddressAndCityFromAddress($devis["client_adresse"]); $clientAdresses = FileExportHelpers::GetAddressAndCityFromAddress($devis["client_adresse"]);
$devis["client_real_adress"] = $clientAdresses["address"]; $devis["client_real_adress"] = $clientAdresses["address"];
$devis["client_adress_city"] = $clientAdresses["city"]; $devis["client_adress_city"] = $clientAdresses["city"];

View File

@ -27,7 +27,7 @@ declare(strict_types=1);
namespace OCA\Gestion\Service; namespace OCA\Gestion\Service;
use DateTime; use DateTime;
use \FPDF; use FPDF;
use OCA\Gestion\Constants\MultipleFactureTypeConstant; use OCA\Gestion\Constants\MultipleFactureTypeConstant;
use OCA\Gestion\Helpers\DateHelpers; use OCA\Gestion\Helpers\DateHelpers;
use OCA\Gestion\Helpers\FileExportHelpers; use OCA\Gestion\Helpers\FileExportHelpers;
@ -35,7 +35,6 @@ use OCA\Gestion\Helpers\PriceHelpers;
class InvoicePdfHandler extends FPDF class InvoicePdfHandler extends FPDF
{ {
private $multipleFactureData = []; private $multipleFactureData = [];
private $factureData = []; private $factureData = [];
private $logo = null; private $logo = null;
@ -49,7 +48,7 @@ class InvoicePdfHandler extends FPDF
private $articleTablesHeight = 130; private $articleTablesHeight = 130;
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);
@ -59,7 +58,7 @@ class InvoicePdfHandler extends FPDF
} }
} }
function AddWatermark() public function AddWatermark()
{ {
$this->SetAlpha(0.2); $this->SetAlpha(0.2);
@ -84,7 +83,7 @@ class InvoicePdfHandler 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);
@ -93,7 +92,7 @@ class InvoicePdfHandler extends FPDF
} }
function Footer() public function Footer()
{ {
$this->SetY(-34); $this->SetY(-34);
$this->SetFont('ComicSans', '', 7); $this->SetFont('ComicSans', '', 7);
@ -283,21 +282,22 @@ class InvoicePdfHandler extends FPDF
private function DrawArticlesTableHeader() private function DrawArticlesTableHeader()
{ {
$additionalMargRight = 1; $additionalMargRight = 1;
$tvaValue = $this->factureData["configuration"]->tva_default; $tvaDefault = $this->factureData["configuration"]->tva_default;
$clientTvaStatus = isset($this->factureData["tva"]) ? (int)$this->factureData["tva"] : 1;
// Déterminer le libellé TVA selon le statut du client
$tvaLabel = ($clientTvaStatus === 0) ? "TVA 0%" : "TVA " . $tvaDefault . "%";
$columnNameY = $this->startingYOfArticlesTable - 1; $columnNameY = $this->startingYOfArticlesTable - 1;
$this->SetFont('ComicSans', '', 10); $this->SetFont('ComicSans', '', 10);
$this->SetXY(12 + $additionalMargRight, $columnNameY); $this->SetXY(12 + $additionalMargRight, $columnNameY);
$this->Cell(7, 10, "Date", 0, 0, 'C'); $this->Cell(7, 10, "Date", 0, 0, 'C');
$this->SetXY(30 + $additionalMargRight, $columnNameY); $this->SetXY(30 + $additionalMargRight, $columnNameY);
$this->Cell(100, 10, "Description", 0, 0, 'C'); $this->Cell(100, 10, "Description", 0, 0, 'C');
$this->SetXY(143 + $additionalMargRight, $columnNameY); $this->SetXY(143 + $additionalMargRight, $columnNameY);
$this->Cell(20, 10, "Prix Uni. HT", 0, 0, 'C'); $this->Cell(20, 10, "Prix Uni. HT", 0, 0, 'C');
$this->SetXY(163 + $additionalMargRight, $columnNameY); $this->SetXY(163 + $additionalMargRight, $columnNameY);
$this->Cell(20, 10, 'TVA ' . $tvaValue . '%', 0, 0, 'C'); $this->Cell(20, 10, $tvaLabel, 0, 0, 'C');
$this->SetXY(185, $columnNameY); $this->SetXY(185, $columnNameY);
$this->Cell(20, 10, "Prix Uni. TTC", 0, 0, 'C'); $this->Cell(20, 10, "Prix Uni. TTC", 0, 0, 'C');
} }
@ -308,49 +308,62 @@ class InvoicePdfHandler extends FPDF
$devisDate = $this->factureData['devis_date']; $devisDate = $this->factureData['devis_date'];
$devisDate = DateTime::createFromFormat('Y-m-d', $devisDate); $devisDate = DateTime::createFromFormat('Y-m-d', $devisDate);
$devisDate = $devisDate->format('d-m-Y'); $devisDate = $devisDate->format('d-m-Y');
$tvaValue = $this->factureData["configuration"]->tva_default;
$tvaDefault = $this->factureData["configuration"]->tva_default;
$clientTvaStatus = isset($this->factureData["tva"]) ? (int)$this->factureData["tva"] : 1;
// Déterminer le taux de TVA à appliquer selon le statut du client
$tvaValue = ($clientTvaStatus === 0) ? 0 : $tvaDefault;
$tvaLabel = ($clientTvaStatus === 0) ? "0%" : $tvaDefault . "%";
$totalHt = 0; $totalHt = 0;
$totalTtc = 0; $totalTtc = 0;
$totalTva = 0; $totalTva = 0;
$products = $this->factureData["products"]; $products = $this->factureData["products"];
$yValue = $this->startingYOfArticlesTable + 13; $yValue = $this->startingYOfArticlesTable + 13;
$maxDescriptionWidth = 102; $maxDescriptionWidth = 102;
foreach ($products as $product) {
foreach ($products as $product) {
$valueHt = $product['produit_price'] * $product['quantite']; $valueHt = $product['produit_price'] * $product['quantite'];
// Calculer la TVA selon le statut du client
if ($clientTvaStatus === 0) {
// Client exonéré - pas de TVA
$valueTtc = $valueHt;
$tvaAmount = 0;
} else {
// Client soumis à la TVA - utiliser le calcul normal
$valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt, $tvaValue); $valueTtc = PriceHelpers::calculPriceWithVatValue($valueHt, $tvaValue);
$tvaAmount = $valueTtc - $valueHt;
}
$totalHt += $valueHt; $totalHt += $valueHt;
$totalTtc += $valueTtc; $totalTtc += $valueTtc;
$totalTva += $tvaAmount;
$productDescription = $product["produit_description"]; $productDescription = $product["produit_description"];
$dateValue = ""; $dateValue = "";
if ($product === end($products)) { if ($product === end($products)) {
$dateValue = $devisDate; $dateValue = $devisDate;
$productDescription .= " de " . FileExportHelpers::GetSexeLabel($this->factureData['defunt_sexe']) . ' ' . $this->factureData["defunt_nom"]; $productDescription .= " de " . FileExportHelpers::GetSexeLabel($this->factureData['defunt_sexe']) . ' ' . $this->factureData["defunt_nom"];
} }
$tvaAmount = $valueTtc - $valueHt;
$this->SetXY(5, $yValue); $this->SetXY(5, $yValue);
$this->Cell(5, 6, $dateValue, 0, 0); $this->Cell(5, 6, $dateValue, 0, 0);
$this->SetXY(30, $yValue); $this->SetXY(30, $yValue);
$this->MultiAlignCell($maxDescriptionWidth, 6, utf8_decode(html_entity_decode($productDescription)), 0, '0', ); $this->MultiAlignCell($maxDescriptionWidth, 6, utf8_decode(html_entity_decode($productDescription)), 0, '0', );
$this->SetXY(144, $yValue); $this->SetXY(144, $yValue);
$this->Cell(20, 6, number_format($valueHt, 2, '.', '') . chr(128), 0, 0, 'C'); $this->Cell(20, 6, number_format($valueHt, 2, '.', '') . chr(128), 0, 0, 'C');
$this->SetXY(165, $yValue); $this->SetXY(165, $yValue);
$this->Cell(20, 6, number_format($tvaAmount, 2, '.', '') . chr(128), 0, 0, 'C'); $this->Cell(20, 6, number_format($tvaAmount, 2, '.', '') . chr(128), 0, 0, 'C');
$this->SetXY(182, $yValue); $this->SetXY(182, $yValue);
$this->Cell(25, 6, number_format($valueTtc, 2, '.', '') . chr(128), 0, 1, 'C'); $this->Cell(25, 6, number_format($valueTtc, 2, '.', '') . chr(128), 0, 1, 'C');
$yValue += 12; $yValue += 12;
$totalTva += $tvaAmount;
} }
return [ return [
"TOTAL HT" => $totalHt, "TOTAL HT" => $totalHt,
"TVA " . $tvaValue . "%" => $totalTva, "TVA " . $tvaLabel => $totalTva,
"TOTAL TTC" => $totalTtc "TOTAL TTC" => $totalTtc
]; ];
} }
@ -413,7 +426,7 @@ class InvoicePdfHandler extends FPDF
$this->DrawBankAndTotalPriceInfo($totalPriceValue); $this->DrawBankAndTotalPriceInfo($totalPriceValue);
} }
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;
@ -428,19 +441,22 @@ class InvoicePdfHandler 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;
@ -456,22 +472,26 @@ class InvoicePdfHandler 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;
} }
} }

View File

@ -41,7 +41,8 @@ use OCA\Gestion\Service\InvoiceRecap\InvoiceRecapService;
use OCP\DB\Exception; use OCP\DB\Exception;
use OCP\Files\IRootFolder; use OCP\Files\IRootFolder;
class InvoicePdfService { class InvoicePdfService
{
/** @var Bdd */ /** @var Bdd */
private $gestionBdd; private $gestionBdd;
@ -55,61 +56,62 @@ class InvoicePdfService {
public function __construct( public function __construct(
Bdd $gestionBdd, Bdd $gestionBdd,
IRootFolder $rootFolder, IRootFolder $rootFolder,
InvoiceRecapService $invoiceRecapService) { InvoiceRecapService $invoiceRecapService
) {
$this->gestionBdd = $gestionBdd; $this->gestionBdd = $gestionBdd;
$this->rootFolder = $rootFolder; $this->rootFolder = $rootFolder;
$this->invoiceRecapService = $invoiceRecapService; $this->invoiceRecapService = $invoiceRecapService;
} }
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 {
if(isset($storage)){ try {
if(isset($storage)) {
$file = $storage->get('/.gestion/logo.png'); $file = $storage->get('/.gestion/logo.png');
}else{ } else {
return "nothing"; return "nothing";
} }
} 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 generateFactureSinglePdfByFactureId($factureId,$idNextCloud){ private function generateFactureSinglePdfByFactureId($factureId, $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];
$logo = $this->getLogo(); $logo = $this->getLogo();
$invoicePdfData = $this->gestionBdd->getInvoicePdfData($factureId,$currentConfig); $invoicePdfData = $this->gestionBdd->getInvoicePdfData($factureId, $currentConfig);
if($invoicePdfData == null){ if($invoicePdfData == null) {
return null; return null;
} }
$clean_folder = html_entity_decode(string: $currentConfig->path).'/'; $clean_folder = html_entity_decode(string: $currentConfig->path).'/';
$factureFolders = $this->getFacturesFolder($invoicePdfData,$clean_folder); $factureFolders = $this->getFacturesFolder($invoicePdfData, $clean_folder);
$pdf = new InvoicePdfHandler(); $pdf = new InvoicePdfHandler();
$pdf->AddFont('ComicSans','','Comic Sans MS.php'); $pdf->AddFont('ComicSans', '', 'Comic Sans MS.php');
$pdf->AddFont('ComicSans','B','comic-sans-bold.php'); $pdf->AddFont('ComicSans', 'B', 'comic-sans-bold.php');
$pdf->InvoicePdfFactory($invoicePdfData,$logo); $pdf->InvoicePdfFactory($invoicePdfData, $logo);
$pdf->SetFactureContent(); $pdf->SetFactureContent();
$pdfContent = $pdf->Output('','S'); $pdfContent = $pdf->Output('', 'S');
$pdfFilename = $pdf->GetInvoiceFilename(); $pdfFilename = $pdf->GetInvoiceFilename();
$prefixPdf = "FACTURE"; $prefixPdf = "FACTURE";
if($invoicePdfData['is_negative']){ if($invoicePdfData['is_negative']) {
$prefixPdf = "AVOIR"; $prefixPdf = "AVOIR";
} }
$pdfFilename = $prefixPdf."_".$pdfFilename; $pdfFilename = $prefixPdf."_".$pdfFilename;
$filenames = []; $filenames = [];
foreach($factureFolders as $folder){ foreach($factureFolders as $folder) {
try { try {
$storage->newFolder($folder); $storage->newFolder($folder);
} } catch(\OCP\Files\NotPermittedException $e) {
catch(\OCP\Files\NotPermittedException $e) {
} }
$ff_pdf = $folder.$pdfFilename.'.pdf'; $ff_pdf = $folder.$pdfFilename.'.pdf';
$storage->newFile($ff_pdf); $storage->newFile($ff_pdf);
@ -124,18 +126,19 @@ class InvoicePdfService {
]; ];
} }
public function generateFacturePdfByFactureId($factureId,$idNextCloud){ public function generateFacturePdfByFactureId($factureId, $idNextCloud)
{
$factureType = $this->gestionBdd->getFactureTypeByFactureId($factureId); $factureType = $this->gestionBdd->getFactureTypeByFactureId($factureId);
if($factureType == FactureTypeConstant::TYPE_SINGLE){ if($factureType == FactureTypeConstant::TYPE_SINGLE) {
return $this->generateFactureSinglePdfByFactureId($factureId,$idNextCloud); return $this->generateFactureSinglePdfByFactureId($factureId, $idNextCloud);
} } else {
else{ return $this->generateFactureGroupPdfByFactureId($factureId, $idNextCloud);
return $this->generateFactureGroupPdfByFactureId($factureId,$idNextCloud);
} }
} }
private function getGroupFactureFolder(array $factureData,$racinePath){ private function getGroupFactureFolder(array $factureData, $racinePath)
$clientRacineFolder = $racinePath.'CLIENTS/'.mb_strtoupper($factureData["group_name"],'UTF-8').'/'; {
$clientRacineFolder = $racinePath.'CLIENTS/'.mb_strtoupper($factureData["group_name"], 'UTF-8').'/';
$factureDate = $factureData['date_paiement']; $factureDate = $factureData['date_paiement'];
$factureDatetime = new DateTime($factureDate); $factureDatetime = new DateTime($factureDate);
$factureDateYear = $factureDatetime->format('Y'); $factureDateYear = $factureDatetime->format('Y');
@ -146,9 +149,10 @@ class InvoicePdfService {
]; ];
} }
private function getFacturesFolder(array $factureData,$racinePath){ private function getFacturesFolder(array $factureData, $racinePath)
$clientRacineFolder = $racinePath.'CLIENTS/'.mb_strtoupper($factureData["client_nom"],'UTF-8').'/'; {
$defuntsFolder = $clientRacineFolder.'DEFUNTS/'.mb_strtoupper($factureData['defunt_nom'],'UTF-8').'/'.'FACTURES'.'/'; $clientRacineFolder = $racinePath.'CLIENTS/'.mb_strtoupper($factureData["client_nom"], 'UTF-8').'/';
$defuntsFolder = $clientRacineFolder.'DEFUNTS/'.mb_strtoupper($factureData['defunt_nom'], 'UTF-8').'/'.'FACTURES'.'/';
$devisDate = $factureData['devis_date']; $devisDate = $factureData['devis_date'];
$devisDatetime = new DateTime($devisDate); $devisDatetime = new DateTime($devisDate);
$devisDateYear = $devisDatetime->format('Y'); $devisDateYear = $devisDatetime->format('Y');
@ -160,18 +164,19 @@ class InvoicePdfService {
]; ];
} }
private function generateFactureGroupPdfByFactureId($factureId,$idNextCloud){ private function generateFactureGroupPdfByFactureId($factureId, $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];
$logo = $this->getLogo(); $logo = $this->getLogo();
$invoicePdfData = $this->gestionBdd->getInvoiceGroupPdfData($factureId,$currentConfig); $invoicePdfData = $this->gestionBdd->getInvoiceGroupPdfData($factureId, $currentConfig);
if($invoicePdfData == null){ if($invoicePdfData == null) {
return ""; return "";
} }
$templateType = $invoicePdfData['template_type_key']; $templateType = $invoicePdfData['template_type_key'];
$clean_folder = html_entity_decode(string: $currentConfig->path).'/'; $clean_folder = html_entity_decode(string: $currentConfig->path).'/';
$factureFolders = $this->getGroupFactureFolder($invoicePdfData,$clean_folder); $factureFolders = $this->getGroupFactureFolder($invoicePdfData, $clean_folder);
//For testing //For testing
// $templateType = ClientTemplateTypeConstant::OGF; // $templateType = ClientTemplateTypeConstant::OGF;
@ -188,18 +193,17 @@ class InvoicePdfService {
$pdf = new InvoiceGroupPdfHandler(); $pdf = new InvoiceGroupPdfHandler();
break; break;
} }
$pdf->AddFont('ComicSans','','Comic Sans MS.php'); $pdf->AddFont('ComicSans', '', 'Comic Sans MS.php');
$pdf->AddFont('ComicSans','B','comic-sans-bold.php'); $pdf->AddFont('ComicSans', 'B', 'comic-sans-bold.php');
$pdf->InvoicePdfFactory($invoicePdfData,$logo); $pdf->InvoicePdfFactory($invoicePdfData, $logo);
$pdf->SetFactureContent(); $pdf->SetFactureContent();
$pdfContent = $pdf->Output('','S'); $pdfContent = $pdf->Output('', 'S');
$pdfFilename = $pdf->GetInvoiceFilename(); $pdfFilename = $pdf->GetInvoiceFilename();
$filenames = []; $filenames = [];
foreach($factureFolders as $folder){ foreach($factureFolders as $folder) {
try { try {
$storage->newFolder($folder); $storage->newFolder($folder);
} } catch(\OCP\Files\NotPermittedException $e) {
catch(\OCP\Files\NotPermittedException $e) {
} }
$ff_pdf = $folder.$pdfFilename.'.pdf'; $ff_pdf = $folder.$pdfFilename.'.pdf';
$storage->newFile($ff_pdf); $storage->newFile($ff_pdf);
@ -214,41 +218,42 @@ class InvoicePdfService {
]; ];
} }
public function generateFacturePdfByFactureIds(array $factureIds,$idNextCloud){ public function generateFacturePdfByFactureIds(array $factureIds, $idNextCloud)
foreach( $factureIds as $factureId ){ {
$this->generateFacturePdfByFactureId($factureId,$idNextCloud); foreach($factureIds as $factureId) {
$this->generateFacturePdfByFactureId($factureId, $idNextCloud);
} }
} }
public function generateMultipleInvoicePdfByClientAndMonthYear($filter,$month,$year,$idNextCloud,$filterType){ public function generateMultipleInvoicePdfByClientAndMonthYear($filter, $month, $year, $idNextCloud, $filterType)
{
$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];
$logo = $this->getLogo(); $logo = $this->getLogo();
$invoiceData = $this->gestionBdd->getInvoicePdfDataByClientAndMonthYear($filter,$month,$year,$currentConfig,$filterType); $invoiceData = $this->gestionBdd->getInvoicePdfDataByClientAndMonthYear($filter, $month, $year, $currentConfig, $filterType);
if(empty($invoiceData)){ if(empty($invoiceData)) {
return null; return null;
} }
$pdf = new InvoicePdfHandler(); $pdf = new InvoicePdfHandler();
$pdf->AddFont('ComicSans','','Comic Sans MS.php'); $pdf->AddFont('ComicSans', '', 'Comic Sans MS.php');
$pdf->AddFont('ComicSans','B','comic-sans-bold.php'); $pdf->AddFont('ComicSans', 'B', 'comic-sans-bold.php');
$pdf->MutlipleInvoicePdfFactory($invoiceData,$logo); $pdf->MutlipleInvoicePdfFactory($invoiceData, $logo);
$pdf->SetMultipleFactureContent(); $pdf->SetMultipleFactureContent();
$racinePath = html_entity_decode(string: $currentConfig->path).'/'; $racinePath = html_entity_decode(string: $currentConfig->path).'/';
$clientNameInFolder = $invoiceData[0]["client_nom"]; $clientNameInFolder = $invoiceData[0]["client_nom"];
if($invoiceData[0]['facture_type'] == MultipleFactureTypeConstant::GROUP_FILTER_TYPE){ if($invoiceData[0]['facture_type'] == MultipleFactureTypeConstant::GROUP_FILTER_TYPE) {
if($invoiceData[0]["group_name"] != null && $invoiceData[0]["group_name"] != ""){ if($invoiceData[0]["group_name"] != null && $invoiceData[0]["group_name"] != "") {
$clientNameInFolder = $invoiceData[0]["group_name"]; $clientNameInFolder = $invoiceData[0]["group_name"];
} }
} }
$clientRacineFolder = $racinePath.'CLIENTS/'.mb_strtoupper($clientNameInFolder,'UTF-8').'/'; $clientRacineFolder = $racinePath.'CLIENTS/'.mb_strtoupper($clientNameInFolder, 'UTF-8').'/';
$filename = "FACTURE".'_'.$pdf->GetMultipleInvoiceFilename($month,$year); $filename = "FACTURE".'_'.$pdf->GetMultipleInvoiceFilename($month, $year);
$filenamePath = $clientRacineFolder.$filename.'.pdf'; $filenamePath = $clientRacineFolder.$filename.'.pdf';
$pdfContent = $pdf->Output('','S'); $pdfContent = $pdf->Output('', 'S');
try { try {
$storage->newFolder($clientRacineFolder); $storage->newFolder($clientRacineFolder);
} } catch(\OCP\Files\NotPermittedException $e) {
catch(\OCP\Files\NotPermittedException $e) {
} }
$storage->newFile($filenamePath); $storage->newFile($filenamePath);
$file_pdf = $storage->get($filenamePath); $file_pdf = $storage->get($filenamePath);
@ -256,12 +261,14 @@ class InvoicePdfService {
return $filenamePath; return $filenamePath;
} }
public function generateInvoiceRecap($filter,$filterType,$date,$idNextCloud){ public function generateInvoiceRecap($filter, $filterType, $date, $idNextCloud)
$this->invoiceRecapService->generateInvoiceRecap($filter,$filterType,$date,$idNextCloud); {
$this->invoiceRecapService->generateInvoiceRecap($filter, $filterType, $date, $idNextCloud);
} }
public function exportGroupOfDevisIntoFacture($clientId,$clientType,$month,$year,$facturationDate,$idNextcloud = BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD){ public function exportGroupOfDevisIntoFacture($clientId, $clientType, $month, $year, $facturationDate, $idNextcloud = BddConstant::DEFAULT_ADMIN_ID_NEXTCLOUD)
try{ {
try {
$datetime = new Datetime(); $datetime = new Datetime();
$month = $month ?? $datetime->format('m'); $month = $month ?? $datetime->format('m');
$year = $year ?? $datetime->format('Y'); $year = $year ?? $datetime->format('Y');
@ -277,15 +284,15 @@ class InvoicePdfService {
//Si il a devis qui n est pas encore facturés //Si il a devis qui n est pas encore facturés
//Cree un facture, atttaché l ID du facture au devis et generer le pdf //Cree un facture, atttaché l ID du facture au devis et generer le pdf
if($clientType == MultipleFactureTypeConstant::CLIENT_FILTER_TYPE){ if($clientType == MultipleFactureTypeConstant::CLIENT_FILTER_TYPE) {
$devisIds = $this->gestionBdd->getDevisIdsByClientIdAndDate($clientId,$facturationDate,$devisMentionFiltersToBeInvoiced); $devisIds = $this->gestionBdd->getDevisIdsByClientIdAndDate($clientId, $facturationDate, $devisMentionFiltersToBeInvoiced);
$fkClientId = $clientId; $fkClientId = $clientId;
$factureId = $this->gestionBdd->getFactureIdByClientIdAndDate($clientId,$facturationDate); $factureId = $this->gestionBdd->getFactureIdByClientIdAndDate($clientId, $facturationDate);
}else{ } else {
$devisIds = $this->gestionBdd->getDevisIdsByClientGroupFacturationIdAnDate($clientId , $facturationDate , $devisMentionFiltersToBeInvoiced ); $devisIds = $this->gestionBdd->getDevisIdsByClientGroupFacturationIdAnDate($clientId, $facturationDate, $devisMentionFiltersToBeInvoiced);
$fkClientGroupFacturationId = $clientId; $fkClientGroupFacturationId = $clientId;
$factureId = $this->gestionBdd->getFactureIdByClientGroupFacturationIdAndDate($clientId,$facturationDate); $factureId = $this->gestionBdd->getFactureIdByClientGroupFacturationIdAndDate($clientId, $facturationDate);
} }
// if($clientType == MultipleFactureTypeConstant::CLIENT_FILTER_TYPE){ // if($clientType == MultipleFactureTypeConstant::CLIENT_FILTER_TYPE){
@ -321,13 +328,12 @@ class InvoicePdfService {
$fkClientGroupFacturationId $fkClientGroupFacturationId
); );
} }
$this->gestionBdd->invoiceListOfDevisIds($devisIds , $factureId); $this->gestionBdd->invoiceListOfDevisIds($devisIds, $factureId);
$factureGeneratedResponse = $this->generateFactureGroupPdfByFactureId($factureId,$idNextcloud); $factureGeneratedResponse = $this->generateFactureGroupPdfByFactureId($factureId, $idNextcloud);
return $factureGeneratedResponse["filenames"]; return $factureGeneratedResponse["filenames"];
} }
return null; return null;
} } catch(Exception) {
catch(Exception){
return null; return null;
} }

File diff suppressed because it is too large Load Diff

View File

@ -215,13 +215,45 @@ export function getGlobal(id_devis) {
}) })
}).done((function (res) { }).done((function (res) {
var myresp = JSON.parse(response)[0]; var myresp = JSON.parse(response)[0];
var total = JSON.parse(res).total; var devisData = JSON.parse(res);
var tva = parseFloat(myresp.tva_default); var total = devisData.total;
var clientTvaStatus = devisData.client_tva_status;
// S'assurer que total est un nombre
total = parseFloat(total);
clientTvaStatus = parseInt(clientTvaStatus);
var tvaDefault = parseFloat(myresp.tva_default);
$('#totaldevis tbody').empty(); $('#totaldevis tbody').empty();
$('#totaldevis tbody').append('<tr><td>' + cur.format(total) + '</td><td id="tva">' + tva + ' %</td><td id="totaltva">' + cur.format(Math.round((total * tva)) / 100) + '</td><td>' + cur.format(Math.round((total * (tva + 100))) / 100) + '</td></tr>');
if (clientTvaStatus === 0) {
// Client exonéré de TVA - TVA = 0%
$('#totaldevis tbody').append(
'<tr>' +
'<td>' + cur.format(total) + '</td>' +
'<td id="tva">0 %</td>' +
'<td id="totaltva">' + cur.format(0) + '</td>' +
'<td>' + cur.format(total) + '</td>' +
'</tr>'
);
} else {
// Client soumis à la TVA - utiliser le taux par défaut
var montantTva = Math.round((total * tvaDefault)) / 100;
var totalTTC = Math.round((total * (tvaDefault + 100))) / 100;
$('#totaldevis tbody').append(
'<tr>' +
'<td>' + cur.format(total) + '</td>' +
'<td id="tva">' + tvaDefault + ' %</td>' +
'<td id="totaltva">' + cur.format(montantTva) + '</td>' +
'<td>' + cur.format(totalTTC) + '</td>' +
'</tr>'
);
}
$('#mentions_default').html(myresp.mentions_default); $('#mentions_default').html(myresp.mentions_default);
})); }));
}) });
} }
export function getGlobalPromise() { export function getGlobalPromise() {

View File

@ -10,15 +10,18 @@ export class Client {
*/ */
constructor(myresp) { constructor(myresp) {
this.id = myresp.id; this.id = myresp.id;
this.entreprise = ((myresp.entreprise.length === 0) ? '-' : myresp.entreprise); this.code_comptable = ((myresp.code_comptable && myresp.code_comptable.length > 0) ? myresp.code_comptable : '-'); // AJOUTÉ
this.prenom = ((myresp.prenom.length === 0) ? '-' : myresp.prenom); this.agence = ((myresp.agence && myresp.agence.length > 0) ? myresp.agence : '-'); // AJOUTÉ
this.nom = ((myresp.nom.length === 0) ? '-' : myresp.nom); this.entreprise = ((myresp.entreprise && myresp.entreprise.length > 0) ? myresp.entreprise : '-');
this.legal_one = ((myresp.legal_one.length === 0) ? '-' : myresp.legal_one); this.prenom = ((myresp.prenom && myresp.prenom.length > 0) ? myresp.prenom : '-');
this.telephone = ((myresp.telephone.length === 0) ? '-' : myresp.telephone); this.nom = ((myresp.nom && myresp.nom.length > 0) ? myresp.nom : '-');
this.mail = ((myresp.mail.length === 0) ? '-' : myresp.mail); this.legal_one = ((myresp.legal_one && myresp.legal_one.length > 0) ? myresp.legal_one : '-');
this.adresse = ((myresp.adresse.length === 0) ? '-' : myresp.adresse); this.telephone = ((myresp.telephone && myresp.telephone.length > 0) ? myresp.telephone : '-');
this.clientGroupName = ((myresp.client_group_name.length === 0) ? '-' : myresp.client_group_name); this.mail = ((myresp.mail && myresp.mail.length > 0) ? myresp.mail : '-');
this.clientGroupFacturationName = ((myresp.client_group_facturation_name.length === 0) ? '-' : myresp.client_group_facturation_name); this.adresse = ((myresp.adresse && myresp.adresse.length > 0) ? myresp.adresse : '-');
this.is_tva = myresp.is_tva !== undefined && myresp.is_tva !== null ? myresp.is_tva : 0;
this.clientGroupName = ((myresp.client_group_name && myresp.client_group_name.length > 0) ? myresp.client_group_name : '-');
this.clientGroupFacturationName = ((myresp.client_group_facturation_name && myresp.client_group_facturation_name.length > 0) ? myresp.client_group_facturation_name : '-');
let clientGroupId = 0; let clientGroupId = 0;
if(myresp.fk_client_group_id != null && myresp.fk_client_group_id.length > 0){ if(myresp.fk_client_group_id != null && myresp.fk_client_group_id.length > 0){
@ -40,17 +43,21 @@ export class Client {
let myrow = [ let myrow = [
'<input class="clientToExport" data-id= '+ this.id + ' type="checkbox" name="clientToExport" value="' + this.id + '"/>', '<input class="clientToExport" data-id= '+ this.id + ' type="checkbox" name="clientToExport" value="' + this.id + '"/>',
'<div>' + this.id + '</div>', '<div>' + this.id + '</div>',
'<div class="editable" data-table="client" data-column="entreprise" data-id="' + this.id + '">' + this.entreprise + '</div>', '<div class="editable" data-table="client" data-column="code_comptable" data-id="' + this.id + '">' + this.code_comptable + '</div>',
'<div class="editable" data-table="client" data-column="agence" data-id="' + this.id + '">' + this.agence + '</div>',
'<div class="editable" data-table="client" data-column="prenom" data-id="' + this.id + '">' + this.prenom + '</div>', '<div class="editable" data-table="client" data-column="prenom" data-id="' + this.id + '">' + this.prenom + '</div>',
'<div class="editable" data-table="client" data-column="nom" data-id="' + this.id + '">' + this.nom + '</div>', '<div class="editable" data-table="client" data-column="nom" data-id="' + this.id + '">' + this.nom + '</div>',
'<div class="editable" data-table="client" data-column="entreprise" data-id="' + this.id + '">' + this.entreprise + '</div>',
'<div class="editable" data-table="client" data-column="legal_one" data-id="' + this.id + '">' + this.legal_one + '</div>', '<div class="editable" data-table="client" data-column="legal_one" data-id="' + this.id + '">' + this.legal_one + '</div>',
'<div class="editable" data-table="client" data-column="telephone" data-id="' + this.id + '">' + this.telephone + '</div>', '<div class="editable" data-table="client" data-column="telephone" data-id="' + this.id + '">' + this.telephone + '</div>',
'<div class="editable" data-table="client" data-column="mail" data-id="' + this.id + '">' + this.mail + '</div>', '<div class="editable" data-table="client" data-column="mail" data-id="' + this.id + '">' + this.mail + '</div>',
'<div class="editable" data-table="client" data-column="adresse" data-id="' + this.id + '">' + this.adresse + '</div>', '<div class="editable" data-table="client" data-column="adresse" data-id="' + this.id + '">' + this.adresse + '</div>',
'<div><input type="checkbox" class="gestion-checkbox" data-table="client" data-column="is_tva" data-id="' + this.id + '" ' + (this.is_tva == 1 || this.is_tva == true ? 'checked' : '') + ' /></div>',
'<div class="selectClientGroupList" data-table="client" data-column="fk_client_group_id" data-id="' + this.id + '" data-current="' + this.clientGroupId + '">' + this.clientGroupName + '</div>', '<div class="selectClientGroupList" data-table="client" data-column="fk_client_group_id" data-id="' + this.id + '" data-current="' + this.clientGroupId + '">' + this.clientGroupName + '</div>',
'<div class="selectClientGroupFacturationList" data-table="client" data-column="fk_client_group_facturation_id" data-id="' + this.id + '" data-current="' + this.clientGroupFacturationId + '">' + this.clientGroupFacturationName + '</div>', '<div class="selectClientGroupFacturationList" data-table="client" data-column="fk_client_group_facturation_id" data-id="' + this.id + '" data-current="' + this.clientGroupFacturationId + '">' + this.clientGroupFacturationName + '</div>',
'<center><div data-modifier="client" data-id=' + this.id + ' data-table="client" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div></center>' '<div><center><div data-modifier="client" data-id=' + this.id + ' data-table="client" style="display:inline-block;margin-right:0px;" class="deleteItem icon-delete"></div></center></div>' // MODIFIÉ
]; ];
return myrow; return myrow;
} }
@ -82,7 +89,8 @@ export class Client {
oReq.setRequestHeader("Content-Type", "application/json"); oReq.setRequestHeader("Content-Type", "application/json");
oReq.onload = function(e){ oReq.onload = function(e){
if (this.status == 200) { if (this.status == 200) {
LoadDT(clientDT, JSON.parse(this.response), Client); const data = JSON.parse(this.response);
LoadDT(clientDT, data, Client);
}else{ }else{
showError(this.response); showError(this.response);
} }
@ -100,7 +108,8 @@ export class Client {
oReq.setRequestHeader("Content-Type", "application/json"); oReq.setRequestHeader("Content-Type", "application/json");
oReq.onload = function(e){ oReq.onload = function(e){
if (this.status == 200) { if (this.status == 200) {
callback(JSON.parse(this.response)); const data = JSON.parse(this.response);
callback(data);
}else{ }else{
showError(this.response); showError(this.response);
} }

View File

@ -17,8 +17,9 @@
?> ?>
</select>&nbsp;&nbsp; </select>&nbsp;&nbsp;
<select name="annee" id="yearselector"> <select name="annee" id="yearselector">
<option value="-1" <?php if ((int) $_GET['annee'] == -1) <option value="-1" <?php if ((int) $_GET['annee'] == -1) {
echo 'selected' ?>>Toutes les années</option> echo 'selected';
} ?>>Toutes les années</option>
<?php <?php
$currentYear = date('Y'); $currentYear = date('Y');
for ($year = $currentYear; $year >= $currentYear - 10; $year--) { for ($year = $currentYear; $year >= $currentYear - 10; $year--) {
@ -27,35 +28,48 @@
?> ?>
</select>&nbsp;&nbsp; </select>&nbsp;&nbsp;
<select name="mois" id="monthselector"> <select name="mois" id="monthselector">
<option value="0" <?php if ((int) $_GET['mois'] == 0) <option value="0" <?php if ((int) $_GET['mois'] == 0) {
echo 'selected' ?>>Tous les mois</option> echo 'selected';
<option value="1" <?php if ((int) $_GET['mois'] == 1) } ?>>Tous les mois</option>
echo 'selected' ?>>Janvier</option> <option value="1" <?php if ((int) $_GET['mois'] == 1) {
<option value="2" <?php if ((int) $_GET['mois'] == 2) echo 'selected';
echo 'selected' ?>>Fevrier</option> } ?>>Janvier</option>
<option value="3" <?php if ((int) $_GET['mois'] == 3) <option value="2" <?php if ((int) $_GET['mois'] == 2) {
echo 'selected' ?>>Mars</option> echo 'selected';
<option value="4" <?php if ((int) $_GET['mois'] == 4) } ?>>Fevrier</option>
echo 'selected' ?>>Avril</option> <option value="3" <?php if ((int) $_GET['mois'] == 3) {
<option value="5" <?php if ((int) $_GET['mois'] == 5) echo 'selected';
echo 'selected' ?>>Mai</option> } ?>>Mars</option>
<option value="6" <?php if ((int) $_GET['mois'] == 6) <option value="4" <?php if ((int) $_GET['mois'] == 4) {
echo 'selected' ?>>Juin</option> echo 'selected';
<option value="7" <?php if ((int) $_GET['mois'] == 7) } ?>>Avril</option>
echo 'selected' ?>>Juillet</option> <option value="5" <?php if ((int) $_GET['mois'] == 5) {
<option value="8" <?php if ((int) $_GET['mois'] == 8) echo 'selected';
echo 'selected' ?>>Août</option> } ?>>Mai</option>
<option value="9" <?php if ((int) $_GET['mois'] == 9) <option value="6" <?php if ((int) $_GET['mois'] == 6) {
echo 'selected' ?>>Septembre</option> echo 'selected';
<option value="10" <?php if ((int) $_GET['mois'] == 10) } ?>>Juin</option>
echo 'selected' ?>>Octobre</option> <option value="7" <?php if ((int) $_GET['mois'] == 7) {
<option value="11" <?php if ((int) $_GET['mois'] == 11) echo 'selected';
echo 'selected' ?>>Novembre</option> } ?>>Juillet</option>
<option value="12" <?php if ((int) $_GET['mois'] == 12) <option value="8" <?php if ((int) $_GET['mois'] == 8) {
echo 'selected' ?>>Decembre</option> echo 'selected';
} ?>>Août</option>
<option value="9" <?php if ((int) $_GET['mois'] == 9) {
echo 'selected';
} ?>>Septembre</option>
<option value="10" <?php if ((int) $_GET['mois'] == 10) {
echo 'selected';
} ?>>Octobre</option>
<option value="11" <?php if ((int) $_GET['mois'] == 11) {
echo 'selected';
} ?>>Novembre</option>
<option value="12" <?php if ((int) $_GET['mois'] == 12) {
echo 'selected';
} ?>>Decembre</option>
</select>&nbsp;&nbsp; </select>&nbsp;&nbsp;
<input type="hidden" name="filterType" id="filterType" <input type="hidden" name="filterType" id="filterType"
value="<?php echo ($_GET['filterType'] ?? 'group'); ?>"> value="<?php echo($_GET['filterType'] ?? 'group'); ?>">
<input type="submit" value="Filtrer" /> <input type="submit" value="Filtrer" />
</form> </form>
<div class="d-flex flex-row"> <div class="d-flex flex-row">
@ -110,8 +124,9 @@
<div id="gestion-canvas" class="canvas_div_pdf"> <div id="gestion-canvas" class="canvas_div_pdf">
<?php <?php
if ($_SERVER['REQUEST_METHOD'] == 'GET' && strcmp($_GET['cli'], '') != 0) { if ($_SERVER['REQUEST_METHOD'] == 'GET' && strcmp($_GET['cli'], '') != 0) {
if (sizeof($devis) == 0) if (sizeof($devis) == 0) {
echo "Aucun devis trouvé."; echo "Aucun devis trouvé.";
}
} }
; ;
@ -197,7 +212,7 @@
style="display:inline" style="display:inline"
data-table="devis" data-column="order_number" data-table="devis" data-column="order_number"
data-id="<?php echo $currentDevis->id;?>"> data-id="<?php echo $currentDevis->id;?>">
<?php echo ($currentDevis->order_number == "" ) ? "-" : $currentDevis->order_number ; ?> <?php echo ($currentDevis->order_number == "") ? "-" : $currentDevis->order_number ; ?>
</div> </div>
</div> </div>
<hr /> <hr />
@ -209,7 +224,7 @@
style="display:inline" style="display:inline"
data-table="devis" data-column="case_number" data-table="devis" data-column="case_number"
data-id="<?php echo $currentDevis->id;?>"> data-id="<?php echo $currentDevis->id;?>">
<?php echo ($currentDevis->case_number == "" ) ? "-" : $currentDevis->case_number ; ?> <?php echo ($currentDevis->case_number == "") ? "-" : $currentDevis->case_number ; ?>
</div> </div>
</div> </div>
<hr /> <hr />
@ -255,13 +270,25 @@
<?php <?php
$totalhtc = 0; $totalhtc = 0;
$tva = json_decode($_['configuration'])[0]->tva_default; $tva = json_decode($_['configuration'])[0]->tva_default;
$clientTvaStatus = isset($currentDevis->tva) ? (int)$currentDevis->tva : 1;
$totalttc = 0; $totalttc = 0;
$totalprice = 0; $totalprice = 0;
foreach ($currentDevis->dproduits as $key => $produit) { foreach ($currentDevis->dproduits as $key => $produit) {
$totalhtc = $totalhtc + ($produit->quantite * $produit->prix_unitaire); $totalhtc = $totalhtc + ($produit->quantite * $produit->prix_unitaire);
} }
// Calculer la TVA selon le statut du client
if ($clientTvaStatus === 0) {
// Client exonéré de TVA
$tva = 0;
$totalttc = 0;
$totalprice = $totalhtc;
} else {
// Client soumis à la TVA
$totalttc = ($totalhtc * $tva) / 100; $totalttc = ($totalhtc * $tva) / 100;
$totalprice = $totalhtc + $totalttc; $totalprice = $totalhtc + $totalttc;
}
?> ?>
<tr> <tr>
<td>&euro;<?php echo number_format($totalhtc, 2) ?></td> <td>&euro;<?php echo number_format($totalhtc, 2) ?></td>

View File

@ -1,5 +1,6 @@
<div class="d-flex flex-column w-100 p-4"> <div class="d-flex flex-column w-100 p-4">
<?php $factures = []; $showRecapButton=false;?> <?php $factures = [];
$showRecapButton = false;?>
<div class="d-flex justify-content-between"> <div class="d-flex justify-content-between">
<form method="get" class="d-flex flex-row align-items-center"> <form method="get" class="d-flex flex-row align-items-center">
<select name="cli" id="clientselector"> <select name="cli" id="clientselector">
@ -8,7 +9,7 @@
?> ?>
<option <option
<?php <?php
if($_GET['cli'] == $client->id && $_GET['filterType'] == $client->client_type){ if($_GET['cli'] == $client->id && $_GET['filterType'] == $client->client_type) {
echo 'selected'; echo 'selected';
} }
?> ?>
@ -22,7 +23,9 @@
?> ?>
</select>&nbsp;&nbsp; </select>&nbsp;&nbsp;
<select name="annee" id="yearselector"> <select name="annee" id="yearselector">
<option value="-1" <?php if((int) $_GET['annee'] == -1) echo 'selected' ?>>Toutes les années</option> <option value="-1" <?php if((int) $_GET['annee'] == -1) {
echo 'selected';
} ?>>Toutes les années</option>
<?php <?php
$currentYear = date('Y'); $currentYear = date('Y');
for ($year = $currentYear; $year >= $currentYear - 10; $year--) { for ($year = $currentYear; $year >= $currentYear - 10; $year--) {
@ -31,49 +34,76 @@
?> ?>
</select>&nbsp;&nbsp; </select>&nbsp;&nbsp;
<select name="mois" id="monthselector"> <select name="mois" id="monthselector">
<option value="0" <?php if((int) $_GET['mois'] == 0) echo 'selected' ?>>Tous les mois</option> <option value="0" <?php if((int) $_GET['mois'] == 0) {
<option value="1" <?php if((int) $_GET['mois'] == 1) echo 'selected' ?>>Janvier</option> echo 'selected';
<option value="2" <?php if((int) $_GET['mois'] == 2) echo 'selected' ?>>Fevrier</option> } ?>>Tous les mois</option>
<option value="3" <?php if((int) $_GET['mois'] == 3) echo 'selected' ?>>Mars</option> <option value="1" <?php if((int) $_GET['mois'] == 1) {
<option value="4" <?php if((int) $_GET['mois'] == 4) echo 'selected' ?>>Avril</option> echo 'selected';
<option value="5" <?php if((int) $_GET['mois'] == 5) echo 'selected' ?>>Mai</option> } ?>>Janvier</option>
<option value="6" <?php if((int) $_GET['mois'] == 6) echo 'selected' ?>>Juin</option> <option value="2" <?php if((int) $_GET['mois'] == 2) {
<option value="7" <?php if((int) $_GET['mois'] == 7) echo 'selected' ?>>Juillet</option> echo 'selected';
<option value="8" <?php if((int) $_GET['mois'] == 8) echo 'selected' ?>>Août</option> } ?>>Fevrier</option>
<option value="9" <?php if((int) $_GET['mois'] == 9) echo 'selected' ?>>Septembre</option> <option value="3" <?php if((int) $_GET['mois'] == 3) {
<option value="10" <?php if((int) $_GET['mois'] == 10) echo 'selected' ?>>Octobre</option> echo 'selected';
<option value="11" <?php if((int) $_GET['mois'] == 11) echo 'selected' ?>>Novembre</option> } ?>>Mars</option>
<option value="12" <?php if((int) $_GET['mois'] == 12) echo 'selected' ?>>Decembre</option> <option value="4" <?php if((int) $_GET['mois'] == 4) {
echo 'selected';
} ?>>Avril</option>
<option value="5" <?php if((int) $_GET['mois'] == 5) {
echo 'selected';
} ?>>Mai</option>
<option value="6" <?php if((int) $_GET['mois'] == 6) {
echo 'selected';
} ?>>Juin</option>
<option value="7" <?php if((int) $_GET['mois'] == 7) {
echo 'selected';
} ?>>Juillet</option>
<option value="8" <?php if((int) $_GET['mois'] == 8) {
echo 'selected';
} ?>>Août</option>
<option value="9" <?php if((int) $_GET['mois'] == 9) {
echo 'selected';
} ?>>Septembre</option>
<option value="10" <?php if((int) $_GET['mois'] == 10) {
echo 'selected';
} ?>>Octobre</option>
<option value="11" <?php if((int) $_GET['mois'] == 11) {
echo 'selected';
} ?>>Novembre</option>
<option value="12" <?php if((int) $_GET['mois'] == 12) {
echo 'selected';
} ?>>Decembre</option>
</select>&nbsp;&nbsp; </select>&nbsp;&nbsp;
<input type="hidden" name="filterType" id="filterType" value="<?php echo ($_GET['filterType'] ?? 'client'); ?>"> <input type="hidden" name="filterType" id="filterType" value="<?php echo($_GET['filterType'] ?? 'client'); ?>">
<input type="submit" value="Filtrer"/> <input type="submit" value="Filtrer"/>
</form> </form>
<div class="d-flex flex-row"> <div class="d-flex flex-row">
<?php <?php
if($_SERVER['REQUEST_METHOD'] == 'GET') { if($_SERVER['REQUEST_METHOD'] == 'GET') {
if(intval($_GET['mois'])!=0 && intval($_GET['annee'])!=0) $showRecapButton = true; if(intval($_GET['mois']) != 0 && intval($_GET['annee']) != 0) {
$factures = array_filter($_['factures'], function($f) { $showRecapButton = true;
}
$factures = array_filter($_['factures'], function ($f) {
$datesplit = explode("-", $f->date_paiement); $datesplit = explode("-", $f->date_paiement);
$year = (int) $datesplit[0]; $year = (int) $datesplit[0];
$month = (int) $datesplit[1]; $month = (int) $datesplit[1];
$checkClient = false; $checkClient = false;
$filterType = "client"; $filterType = "client";
if(array_key_exists('filterType',$_GET) && $_GET['filterType'] == 'group'){ if(array_key_exists('filterType', $_GET) && $_GET['filterType'] == 'group') {
$filterType = "group"; $filterType = "group";
} }
if($_GET['cli'] != null && $_GET['cli'] != '') { if($_GET['cli'] != null && $_GET['cli'] != '') {
if($filterType == "group"){ if($filterType == "group") {
$checkClient = $f->fk_client_group_facturation_id == $_GET['cli']; $checkClient = $f->fk_client_group_facturation_id == $_GET['cli'];
} } else {
else{
$checkClient = $f->id_cli == $_GET['cli']; $checkClient = $f->id_cli == $_GET['cli'];
} }
} }
$checkYear = ((int) ($_GET['annee']) == -1)?(true):($year==((int) $_GET['annee'])); $checkYear = ((int) ($_GET['annee']) == -1) ? (true) : ($year == ((int) $_GET['annee']));
$checkMounth = (((int) $_GET['mois']) == 0)? (true): ($month==((int) $_GET['mois'])); $checkMounth = (((int) $_GET['mois']) == 0) ? (true) : ($month == ((int) $_GET['mois']));
return $checkClient && $checkYear && $checkMounth; return $checkClient && $checkYear && $checkMounth;
}); });
if(sizeof($factures)>0) { if(sizeof($factures) > 0) {
?> ?>
<?php if($showRecapButton) {?><button class="btn btn-secondary" type="button" id="documentrecap">Generer le document recapitulatif</button><?php }?> <?php if($showRecapButton) {?><button class="btn btn-secondary" type="button" id="documentrecap">Generer le document recapitulatif</button><?php }?>
<button class="btn btn-secondary ml-2" type="button" id="exportMultipleFactureToPdf"><?php p($l->t('Save in Nextcloud'));?></button> <button class="btn btn-secondary ml-2" type="button" id="exportMultipleFactureToPdf"><?php p($l->t('Save in Nextcloud'));?></button>
@ -87,7 +117,9 @@
<div class="canvas_div_pdf"> <div class="canvas_div_pdf">
<?php <?php
if($_SERVER['REQUEST_METHOD'] == 'GET') { if($_SERVER['REQUEST_METHOD'] == 'GET') {
if(sizeof($factures)==0) echo "Aucune facture trouvée."; if(sizeof($factures) == 0) {
echo "Aucune facture trouvée.";
}
}; };
foreach ($factures as $key => $facture) { foreach ($factures as $key => $facture) {
@ -112,9 +144,9 @@
</div> </div>
<div class="col-2 h-100 m-0" style="min-height:250px;"> <div class="col-2 h-100 m-0" style="min-height:250px;">
<?php <?php
if(isset($_['logo']) && $_['logo'] !== "nothing"){ if(isset($_['logo']) && $_['logo'] !== "nothing") {
echo "<center><a><img alt='".$l->t('Company logo')."' class=\"img-fluid\" src=\"data:image/png;base64, ".$_['logo']."\"/></a></center>"; echo "<center><a><img alt='".$l->t('Company logo')."' class=\"img-fluid\" src=\"data:image/png;base64, ".$_['logo']."\"/></a></center>";
}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>";
} }
?> ?>
@ -148,7 +180,7 @@
<div class="row"> <div class="row">
<div class="col col-md"> <div class="col col-md">
<hr /> <hr />
<div class="col col-xl mb-3 text-center" style="display:inline" ><?php echo ($facture->dcomment == "" ) ? "-" : $facture->dcomment ; ?></div> <div class="col col-xl mb-3 text-center" style="display:inline" ><?php echo ($facture->dcomment == "") ? "-" : $facture->dcomment ; ?></div>
<hr /> <hr />
</div> </div>
</div> </div>
@ -172,7 +204,7 @@
<td><?php echo $produit->comment ?></td> <td><?php echo $produit->comment ?></td>
<td><?php echo $produit->quantite ?></td> <td><?php echo $produit->quantite ?></td>
<td>&euro;<?php echo number_format($produit->prix_unitaire, 2) ?></td> <td>&euro;<?php echo number_format($produit->prix_unitaire, 2) ?></td>
<td>&euro;<?php echo number_format($produit->prix_unitaire*$produit->quantite, 2) ?></td> <td>&euro;<?php echo number_format($produit->prix_unitaire * $produit->quantite, 2) ?></td>
</tr> </tr>
<?php } ?> <?php } ?>
</tbody> </tbody>
@ -192,13 +224,26 @@
<?php <?php
$totalhtc = 0; $totalhtc = 0;
$tva = json_decode($_['configuration'])[0]->tva_default; $tva = json_decode($_['configuration'])[0]->tva_default;
$clientTvaStatus = isset($facture->tva_cli) ? (int)$facture->tva_cli : 1;
$totalttc = 0; $totalttc = 0;
$totalprice = 0; $totalprice = 0;
foreach ($facture->dproduits as $key => $produit) { foreach ($facture->dproduits as $key => $produit) {
$totalhtc = $totalhtc + ($produit->quantite*$produit->prix_unitaire); $totalhtc = $totalhtc + ($produit->quantite * $produit->prix_unitaire);
} }
$totalttc = ($totalhtc * $tva)/100;
// Calculer la TVA selon le statut du client
if ($clientTvaStatus === 0) {
// Client exonéré de TVA
$tva = 0;
$totalttc = 0;
$totalprice = $totalhtc;
} else {
// Client soumis à la TVA
$totalttc = ($totalhtc * $tva) / 100;
$totalprice = $totalhtc + $totalttc; $totalprice = $totalhtc + $totalttc;
}
?> ?>
<tr> <tr>
<td>&euro;<?php echo number_format($totalhtc, 2) ?></td> <td>&euro;<?php echo number_format($totalhtc, 2) ?></td>

View File

@ -27,11 +27,14 @@
<th><?php p($l->t('ID'));?></th> <th><?php p($l->t('ID'));?></th>
<th><?php p($l->t('Code comptable'));?></th> <th><?php p($l->t('Code comptable'));?></th>
<th><?php p($l->t('Agence'));?></th> <th><?php p($l->t('Agence'));?></th>
<th><?php p($l->t('Prénom'));?></th> <!-- AJOUTÉ -->
<th><?php p($l->t('Nom'));?></th> <!-- AJOUTÉ -->
<th><?php p($l->t('Company'));?></th> <th><?php p($l->t('Company'));?></th>
<th><?php p($l->t('Legal information'));?></th> <th><?php p($l->t('Legal information'));?></th>
<th><?php p($l->t('Phone number'));?></th> <th><?php p($l->t('Phone number'));?></th>
<th><?php p($l->t('Email'));?></th> <th><?php p($l->t('Email'));?></th>
<th><?php p($l->t('Address'));?></th> <th><?php p($l->t('Address'));?></th>
<th><?php p($l->t('TVA'));?></th>
<th><?php p($l->t('Groupes tarifaires'));?></th> <th><?php p($l->t('Groupes tarifaires'));?></th>
<th><?php p($l->t('Groupes facturations'));?></th> <th><?php p($l->t('Groupes facturations'));?></th>
<th><?php p($l->t('Actions'));?></th> <th><?php p($l->t('Actions'));?></th>