Compare commits

...

52 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
Tiavina
f2f737d6f8 Merge branch 'staging' into production 2025-06-10 17:01:09 +03:00
Tiavina
024df6bcd8 Merge branch 'staging' into production 2025-06-10 15:30:32 +03:00
narindraezway
2b867f27ea Merge branch 'staging' into production 2025-06-05 10:56:58 +03:00
Tiavina
416f4b030a Merge branch 'staging' into production 2025-06-02 15:08:10 +03:00
Tiavina
2d3196ffe4 Merge branch 'staging' into production 2025-05-20 10:21:57 +03:00
narindraezway
fc37e8583d Merge branch 'staging' into production 2025-05-07 15:04:42 +03:00
Tiavina
db6839451b Merge branch 'staging' into production 2025-05-06 16:21:58 +03:00
narindraezway
625e81ac30 Merge branch 'staging' into production 2025-05-05 13:45:31 +03:00
Tiavina
fbce8789c1 Merge branch 'staging' into production 2025-04-30 18:10:30 +03:00
Tiavina
5396c6ad1b Merge branch 'staging' into production 2025-04-30 18:05:52 +03:00
Tiavina
01f9176d32 Merge branch 'staging' into production 2025-04-30 17:51:15 +03:00
Tiavina
f5d1426d12 Merge remote-tracking branch 'origin/staging' into production 2025-04-25 17:30:53 +03:00
Tiavina
8f13e48206 Merge branch 'staging' into production 2025-04-25 15:06:17 +03:00
Tiavina Handrianina
459fda7106 Merge branch 'staging' into 'production'
HOTFIXESdevis list group facturation redirect

See merge request sottye/hytha35!6
2025-04-15 12:27:05 +00:00
Tiavina Handrianina
45f0f81c03 Merge branch 'staging' into 'production'
HOTFIXES OVERRIDE TEMPLATE TYPE CODE

See merge request sottye/hytha35!5
2025-04-15 11:16:07 +00:00
Tiavina Handrianina
1c4a972222 Merge branch 'staging' into 'production'
Deploying facturation at any date for HYTHA 35

See merge request sottye/hytha35!4
2025-04-15 10:16:44 +00:00
Tiavina Handrianina
d065671291 Merge branch 'staging' into 'production'
Deploying compte comptable into production

See merge request sottye/hytha35!3
2025-04-14 13:07:56 +00:00
Tiavina Handrianina
5512c23004 Merge branch 'staging' into 'production'
Merge staging into production

See merge request sottye/hytha35!2
2025-04-10 15:23:52 +00:00
Tiavina
3ea9d4ed52 Merge remote-tracking branch 'origin/staging' into releases/release-hytha-prod 2025-04-07 16:53:43 +03:00
Tiavina
602466d9a9 Merge branch 'staging' into releases/release-hytha-prod 2025-04-04 19:43:40 +03:00
Tiavina
b1fabe9804 Merge branch 'staging' into releases/release-hytha-prod 2025-03-27 08:51:59 +03:00
Tiavina
2bbfe390eb Merge branch 'staging' into releases/release-hytha-prod 2025-03-26 19:55:15 +03:00
Tiavina
12a751c1c3 Merge branch 'staging' into releases/release-hytha-prod 2025-03-26 19:43:51 +03:00
Tiavina
0276655040 Merge branch 'features/feature-devis-group' into releases/release-hytha-prod 2025-03-26 13:06:50 +03:00
Tiavina
5ab91d4be7 Merge branch 'staging' into releases/release-hytha-prod 2025-03-25 13:34:15 +03:00
Tiavina
91c67452c2 Merge branch 'staging' into releases/release-hytha-prod 2025-03-21 09:29:13 +03:00
Tiavina
31633b04d9 Merge branch 'hotfixes/hotfix-update-client' into releases/release-hytha-prod 2025-03-19 11:38:00 +03:00
Tiavina
dc3da8d425 Merge branch 'hotfixes/hotfix-update-client' into releases/release-hytha-prod 2025-03-19 10:50:02 +03:00
Tiavina
ea119f5c73 Merge branch 'hotfixes/hotfix-update-client' into releases/release-hytha-prod 2025-03-19 10:43:24 +03:00
Tiavina
4bd86ae762 Merge branch 'hotfixes/hotfix-update-client' into releases/release-hytha-prod 2025-03-19 10:30:55 +03:00
Tiavina
2c1e771472 Merge branch 'hotfixes/hotfix-update-client' into releases/release-hytha-prod 2025-03-19 10:13:45 +03:00
Tiavina
c07c4aaf88 Merge branch 'staging' into releases/release-hytha-prod 2025-03-18 10:19:21 +03:00
Tiavina
95be6e4827 Merge branch 'staging' into releases/release-hytha-prod 2025-03-17 16:16:16 +03:00
Tiavina
e7c51a4d73 Merge branch 'fixes/fix-rapport-bijoux-text' into releases/release-hytha-prod 2025-03-13 12:06:47 +03:00
Tiavina
f509f5e988 Merge branch 'staging' into releases/release-hytha-prod 2025-03-13 10:53:37 +03:00
Tiavina
f8ff4c6b3e Merge branch 'hotfixes/hotfixe-show-facture-case-and-order-number' into releases/release-hytha-prod 2025-03-07 13:17:00 +03:00
45 changed files with 16903 additions and 4928 deletions

18
.gitignore vendored
View File

@ -1,11 +1,21 @@
# Ignore tout par défaut
* *
*.sql
# Exceptions : fichiers et dossiers à inclure
!.gitignore !.gitignore
!calendar/
!gestion/
!Jenkinsfile !Jenkinsfile
# Inclure tout le contenu de ces dossiers
!calendar/** !calendar/**
!gestion/** !gestion/**
# Ignorer spécifiquement (même dans les dossiers inclus)
*.sql
node_modules/
**/node_modules/
**/package-lock.json
**/composer.lock
**/.env
**/.env.*
**/dist/
**/build/

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

View File

@ -8,9 +8,12 @@ abstract class BddConstant
const DEFAULT_TABLE_PREFIX = "*PREFIX*"; const DEFAULT_TABLE_PREFIX = "*PREFIX*";
const DEFAULT_CLIENT_GROUP_NAME = "Nom du groupe"; const DEFAULT_CLIENT_GROUP_NAME = "Nom du groupe";
const DEFAULT_ADMIN_ID_NEXTCLOUD = 'admin'; const DEFAULT_ADMIN_ID_NEXTCLOUD = 'admin';
const DEFAULT_ADMIN_APP_ID_NEXTCLOUD = "Johann"; const DEFAULT_ADMIN_APP_ID_NEXTCLOUD = "Vanessa";
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);

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

@ -42,7 +42,7 @@ class CareCertificatePdfHandler extends FPDF {
function Header() function Header()
{ {
if($this->logo != "nothing"){ if($this->logo != "nothing"){
$this->Image($this->imagePath."logo.png", 10, 10, 75, 25); $this->Image($this->imagePath."logo.png", 4, 2, 50, 35);
} }
else{ else{
$this->Cell(55,30,''); $this->Cell(55,30,'');

View File

@ -32,7 +32,8 @@ use OCA\Gestion\Helpers\DateHelpers;
use OCA\Gestion\Helpers\FileExportHelpers; use OCA\Gestion\Helpers\FileExportHelpers;
use OCA\Gestion\Helpers\PriceHelpers; use OCA\Gestion\Helpers\PriceHelpers;
class PacemakerCertificatePdfHandler extends FPDF { class PacemakerCertificatePdfHandler extends FPDF
{
private $devisOfDefunt = []; private $devisOfDefunt = [];
private $logo = null; private $logo = null;
@ -42,9 +43,8 @@ class PacemakerCertificatePdfHandler extends FPDF {
function Header() function Header()
{ {
if ($this->logo != "nothing") { if ($this->logo != "nothing") {
$this->Image($this->imagePath."logo.png", 10, 10, 75, 25); $this->Image($this->imagePath . "logo.png", 4, 2, 50, 35);
} } else {
else{
$this->Cell(55, 30, ''); $this->Cell(55, 30, '');
} }
} }
@ -56,13 +56,15 @@ class PacemakerCertificatePdfHandler extends FPDF {
$this->MultiCell(0, 5, utf8_decode(html_entity_decode($this->devisOfDefunt['configuration']->adresse)), 0, 'C'); $this->MultiCell(0, 5, utf8_decode(html_entity_decode($this->devisOfDefunt['configuration']->adresse)), 0, 'C');
} }
public function SetPacemakerCertificateData(array $devisOfDefunt,$logo = null,$signatureImageExist = false){ public function SetPacemakerCertificateData(array $devisOfDefunt, $logo = null, $signatureImageExist = false)
{
$this->devisOfDefunt = $devisOfDefunt; $this->devisOfDefunt = $devisOfDefunt;
$this->logo = $logo; $this->logo = $logo;
$this->signatureImageExist = $signatureImageExist; $this->signatureImageExist = $signatureImageExist;
} }
public function SetPacemakerCertificate(){ public function SetPacemakerCertificate()
{
$this->AddPage(); $this->AddPage();
$this->SetMargins(left: 20, top: 0, right: 20); $this->SetMargins(left: 20, top: 0, right: 20);
$this->SetPacemakerCertificateTitle(); $this->SetPacemakerCertificateTitle();
@ -70,7 +72,8 @@ class PacemakerCertificatePdfHandler extends FPDF {
$this->SetSigning(); $this->SetSigning();
} }
private function SetSigning(){ private function SetSigning()
{
$this->SetXY(140, $this->GetY() + 15); $this->SetXY(140, $this->GetY() + 15);
$this->Cell(0, 10, 'Cachet et signature'); $this->Cell(0, 10, 'Cachet et signature');
@ -79,7 +82,8 @@ class PacemakerCertificatePdfHandler extends FPDF {
} }
} }
private function SetPacemakerCertificateContent(){ private function SetPacemakerCertificateContent()
{
$this->SetFont('ComicSans', '', 14); $this->SetFont('ComicSans', '', 14);
$this->MultiCell(0, 7, FileExportHelpers::FormatTextForExport('La Société ' . $this->devisOfDefunt['configuration']->entreprise . ' habilitée sous le numéro ' . $this->devisOfDefunt['thanato_reference'] . ', certifie par la présente que : ')); $this->MultiCell(0, 7, FileExportHelpers::FormatTextForExport('La Société ' . $this->devisOfDefunt['configuration']->entreprise . ' habilitée sous le numéro ' . $this->devisOfDefunt['thanato_reference'] . ', certifie par la présente que : '));
$this->SetFont('ComicSans', 'B', 14); $this->SetFont('ComicSans', 'B', 14);
@ -94,12 +98,22 @@ class PacemakerCertificatePdfHandler extends FPDF {
$this->MultiCell(0, 6, FileExportHelpers::FormatTextForExport($this->devisOfDefunt['location_of_devis'])); $this->MultiCell(0, 6, FileExportHelpers::FormatTextForExport($this->devisOfDefunt['location_of_devis']));
$this->Ln(6); $this->Ln(6);
$this->SetFont('ComicSans', '', 14); $this->SetFont('ComicSans', '', 14);
$this->Cell(0,6, $this->Cell(
0,
6,
FileExportHelpers::FormatTextForExport("Numéro de série : ") . FileExportHelpers::FormatTextForExport("Numéro de série : ") .
FileExportHelpers::FormatTextForExport($this->devisOfDefunt['defunt_reference_pacemaker']),0,1); FileExportHelpers::FormatTextForExport($this->devisOfDefunt['defunt_reference_pacemaker']),
$this->Cell(0,6, 0,
1
);
$this->Cell(
0,
6,
FileExportHelpers::FormatTextForExport("Marque du produit : ") . FileExportHelpers::FormatTextForExport("Marque du produit : ") .
FileExportHelpers::FormatTextForExport($this->devisOfDefunt['defunt_product_brand']),0,1); FileExportHelpers::FormatTextForExport($this->devisOfDefunt['defunt_product_brand']),
0,
1
);
$this->Cell(0, 12, FileExportHelpers::FormatTextForExport("La présente attestation est établie pour faire valoir ce que de droit."), 0, 5); $this->Cell(0, 12, FileExportHelpers::FormatTextForExport("La présente attestation est établie pour faire valoir ce que de droit."), 0, 5);
$this->Ln(5); $this->Ln(5);
@ -108,7 +122,8 @@ class PacemakerCertificatePdfHandler extends FPDF {
$this->Cell(0, 7, 'le ' . $this->devisOfDefunt['devis_date']->format('d/m/Y'), 0); $this->Cell(0, 7, 'le ' . $this->devisOfDefunt['devis_date']->format('d/m/Y'), 0);
} }
private function SetPacemakerCertificateTitle(){ private function SetPacemakerCertificateTitle()
{
$this->SetY(y: 50); $this->SetY(y: 50);
$this->SetFont('ComicSans', 'B', 20); $this->SetFont('ComicSans', 'B', 20);
$this->Cell(0, 10, 'ATTESTATION DE RETRAIT DE LA', 0, 1, 'C'); $this->Cell(0, 10, 'ATTESTATION DE RETRAIT DE LA', 0, 1, 'C');
@ -126,8 +141,7 @@ class PacemakerCertificatePdfHandler extends FPDF {
$this->MultiCell($w, $h, $text, $border, $align, $fill); $this->MultiCell($w, $h, $text, $border, $align, $fill);
// Reset the line position to the right, like in Cell // Reset the line position to the right, like in Cell
if( $ln==0 ) if ($ln == 0) {
{
$this->SetXY($x, $y); $this->SetXY($x, $y);
} }
} }
@ -150,11 +164,9 @@ class PacemakerCertificatePdfHandler extends FPDF {
$j = 0; $j = 0;
$l = 0; $l = 0;
$nl = 1; $nl = 1;
while($i<$nb) while ($i < $nb) {
{
$c = $s[$i]; $c = $s[$i];
if($c=="\n") if ($c == "\n") {
{
$i++; $i++;
$sep = -1; $sep = -1;
$j = $i; $j = $i;
@ -165,21 +177,17 @@ class PacemakerCertificatePdfHandler extends FPDF {
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

@ -27,26 +27,25 @@ 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", 2, 2, 50,35); $this->Image($this->logoPath . "logo.png", 4, 2, 50, 35);
} } else {
else{
$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);
@ -60,24 +59,28 @@ class DevisPdfHandler extends FPDF {
$this->Cell(0, 10, utf8_decode(html_entity_decode($this->devisData['configuration']->legal_one)), 0, 0, 'C'); $this->Cell(0, 10, utf8_decode(html_entity_decode($this->devisData['configuration']->legal_one)), 0, 0, 'C');
} }
public function SetDevisPdfData(array $devisData,$logo = null){ public function SetDevisPdfData(array $devisData, $logo = null)
{
$this->devisData = $devisData; $this->devisData = $devisData;
$this->logo = $logo; $this->logo = $logo;
} }
public function SetMultipleDevisPdfData(array $multipleDevisData,$logo = null){ public function SetMultipleDevisPdfData(array $multipleDevisData, $logo = null)
{
$this->multipleDevisData = $multipleDevisData; $this->multipleDevisData = $multipleDevisData;
$this->logo = $logo; $this->logo = $logo;
} }
private function DrawDevisCompanyAndClientInfo(){ private function DrawDevisCompanyAndClientInfo()
{
$this->SetY(40); $this->SetY(40);
$this->SetFont('ComicSans', '', 12); $this->SetFont('ComicSans', '', 12);
$this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->devisData['configuration']->entreprise), 0, 0); $this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->devisData['configuration']->entreprise), 0, 0);
$this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->devisData['client_nom']), 0, 1, 'R'); $this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->devisData['client_nom']), 0, 1, 'R');
$this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->devisData['configuration_adresse']), 0, 0); $this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->devisData['configuration_adresse']), 0, 0);
$this->Cell(0, 7, trim(FileExportHelpers::FormatTextForExport($this->devisData['client_real_adress'])), 0, 1, 'R'); $this->Cell(0, 7, trim(FileExportHelpers::FormatTextForExport($this->devisData['client_real_adress'])), 0, 1, 'R');
$this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->devisData['configuration_adresse_city']), 0, 0);border: $this->Cell(0, 7, FileExportHelpers::FormatTextForExport($this->devisData['configuration_adresse_city']), 0, 0);
border:
$this->Cell(0, 7, trim(FileExportHelpers::FormatTextForExport($this->devisData['client_adress_city'])), 0, 1, 'R'); $this->Cell(0, 7, trim(FileExportHelpers::FormatTextForExport($this->devisData['client_adress_city'])), 0, 1, 'R');
$this->Cell(0, 7, FileExportHelpers::FormatTextForExport('Tél : ') . FileExportHelpers::FormatTextForExport($this->devisData['configuration']->telephone), 0, 0); $this->Cell(0, 7, FileExportHelpers::FormatTextForExport('Tél : ') . FileExportHelpers::FormatTextForExport($this->devisData['configuration']->telephone), 0, 0);
$this->Cell(0, 7, 'Siret: ' . $this->devisData['siret'], 0, 1, 'R'); $this->Cell(0, 7, 'Siret: ' . $this->devisData['siret'], 0, 1, 'R');
@ -85,7 +88,8 @@ class DevisPdfHandler extends FPDF {
$this->Ln(3); $this->Ln(3);
} }
private function DrawDevisInfoTable(){ private function DrawDevisInfoTable()
{
$this->SetFont('ComicSans', 'B', 11); $this->SetFont('ComicSans', 'B', 11);
$this->Cell(30, 7, 'DATE', 1, 0, 'C'); $this->Cell(30, 7, 'DATE', 1, 0, 'C');
$this->Cell(80, 7, 'CLIENT', 1, 0, 'C'); $this->Cell(80, 7, 'CLIENT', 1, 0, 'C');
@ -99,7 +103,8 @@ class DevisPdfHandler extends FPDF {
$this->Ln(8); $this->Ln(8);
} }
private function DrawArticlesTable(){ private function DrawArticlesTable()
{
$this->SetLineWidth(0.1); $this->SetLineWidth(0.1);
$this->Rect(10, 105, 190, 100, "D"); $this->Rect(10, 105, 190, 100, "D");
// cadre titre des colonnes // cadre titre des colonnes
@ -111,72 +116,90 @@ class DevisPdfHandler extends FPDF {
$this->Line(175, 105, 175, 205); $this->Line(175, 105, 175, 205);
} }
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
]; ];
} }
private function DrawBankAndTotalPriceInfo($totalPriceArray){ private function DrawBankAndTotalPriceInfo($totalPriceArray)
{
$this->SetY(210); $this->SetY(210);
$this->SetFont('ComicSans', '', 9); $this->SetFont('ComicSans', '', 9);
$this->MultiCell(0, 5, utf8_decode(html_entity_decode("Paiement à votre convenance par chèque à l'ordre de " . $this->devisData['configuration']->entreprise))); $this->MultiCell(0, 5, utf8_decode(html_entity_decode("Paiement à votre convenance par chèque à l'ordre de " . $this->devisData['configuration']->entreprise)));
@ -205,14 +228,16 @@ class DevisPdfHandler extends FPDF {
} }
} }
public function SetMultipleDevisContent(){ public function SetMultipleDevisContent()
{
foreach ($this->multipleDevisData as $devisData) { foreach ($this->multipleDevisData as $devisData) {
$this->devisData = $devisData; $this->devisData = $devisData;
$this->SetDevisContent(); $this->SetDevisContent();
} }
} }
public function SetDevisContent(){ public function SetDevisContent()
{
$this->AddPage(); $this->AddPage();
$this->SetMargins(10, 0, 10); $this->SetMargins(10, 0, 10);
$this->DrawDevisCompanyAndClientInfo(); $this->DrawDevisCompanyAndClientInfo();
@ -223,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;
@ -233,35 +258,35 @@ class DevisPdfHandler extends FPDF {
$this->MultiCell($w, $h, $text, $border, $align, $fill); $this->MultiCell($w, $h, $text, $border, $align, $fill);
// Reset the line position to the right, like in Cell // Reset the line position to the right, like in Cell
if( $ln==0 ) if ($ln == 0) {
{
$this->SetXY($x, $y); $this->SetXY($x, $y);
} }
} }
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;
$l = 0; $l = 0;
$nl = 1; $nl = 1;
while($i<$nb) while ($i < $nb) {
{
$c = $s[$i]; $c = $s[$i];
if($c=="\n") if ($c == "\n") {
{
$i++; $i++;
$sep = -1; $sep = -1;
$j = $i; $j = $i;
@ -269,26 +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\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", 2, 10, 75, 25); $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);
@ -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,22 +495,26 @@ 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

@ -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,17 +48,17 @@ 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", 2, 10, 75, 25); $this->Image($this->logoPath . "logo.png", 4, 2, 50, 35);
$this->AddWatermark(); $this->AddWatermark();
} else { } else {
$this->Cell(55, 30, ''); $this->Cell(55, 30, '');
} }
} }
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,13 +56,15 @@ 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 { try {
@ -73,15 +76,15 @@ class InvoicePdfService {
} 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];
@ -108,8 +111,7 @@ class InvoicePdfService {
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,17 +126,18 @@ 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);
@ -146,7 +149,8 @@ class InvoicePdfService {
]; ];
} }
private function getFacturesFolder(array $factureData,$racinePath){ private function getFacturesFolder(array $factureData, $racinePath)
{
$clientRacineFolder = $racinePath.'CLIENTS/'.mb_strtoupper($factureData["client_nom"], 'UTF-8').'/'; $clientRacineFolder = $racinePath.'CLIENTS/'.mb_strtoupper($factureData["client_nom"], 'UTF-8').'/';
$defuntsFolder = $clientRacineFolder.'DEFUNTS/'.mb_strtoupper($factureData['defunt_nom'], 'UTF-8').'/'.'FACTURES'.'/'; $defuntsFolder = $clientRacineFolder.'DEFUNTS/'.mb_strtoupper($factureData['defunt_nom'], 'UTF-8').'/'.'FACTURES'.'/';
$devisDate = $factureData['devis_date']; $devisDate = $factureData['devis_date'];
@ -160,7 +164,8 @@ 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];
@ -198,8 +203,7 @@ class InvoicePdfService {
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,13 +218,15 @@ class InvoicePdfService {
]; ];
} }
public function generateFacturePdfByFactureIds(array $factureIds,$idNextCloud){ public function generateFacturePdfByFactureIds(array $factureIds, $idNextCloud)
{
foreach($factureIds as $factureId) { foreach($factureIds as $factureId) {
$this->generateFacturePdfByFactureId($factureId, $idNextCloud); $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];
@ -247,8 +253,7 @@ class InvoicePdfService {
$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,11 +261,13 @@ 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');
@ -326,8 +333,7 @@ class InvoicePdfService {
return $factureGeneratedResponse["filenames"]; return $factureGeneratedResponse["filenames"];
} }
return null; return null;
} } catch(Exception) {
catch(Exception){
return null; return null;
} }

View File

@ -31,11 +31,12 @@ use OCA\Gestion\Constants\MultipleFactureTypeConstant;
use OCA\Gestion\Db\Bdd; use OCA\Gestion\Db\Bdd;
use OCA\Gestion\Helpers\DateHelpers; use OCA\Gestion\Helpers\DateHelpers;
use OCP\Files\IRootFolder; use OCP\Files\IRootFolder;
use \FPDF; use FPDF;
use IntlDateFormatter; use IntlDateFormatter;
use OCA\Gestion\Helpers\FileExportHelpers; use OCA\Gestion\Helpers\FileExportHelpers;
class InvoiceRecapService { class InvoiceRecapService
{
/** @var Bdd */ /** @var Bdd */
private $gestionBdd; private $gestionBdd;
@ -47,12 +48,14 @@ class InvoiceRecapService {
private const DEFAULT_NEXTCLOUD_ADMIN = "admin"; private const DEFAULT_NEXTCLOUD_ADMIN = "admin";
public function __construct( public function __construct(
Bdd $gestionBdd, Bdd $gestionBdd,
IRootFolder $rootFolder) { IRootFolder $rootFolder
) {
$this->gestionBdd = $gestionBdd; $this->gestionBdd = $gestionBdd;
$this->rootFolder = $rootFolder; $this->rootFolder = $rootFolder;
} }
private function doesSignatureImageExists(){ private function doesSignatureImageExists()
{
$storage = $this->rootFolder->getUserFolder(self::DEFAULT_NEXTCLOUD_ADMIN); $storage = $this->rootFolder->getUserFolder(self::DEFAULT_NEXTCLOUD_ADMIN);
try { try {
if(isset($storage)) { if(isset($storage)) {
@ -61,14 +64,14 @@ class InvoiceRecapService {
} else { } else {
$signatureExist = false; $signatureExist = false;
} }
} } catch(\OCP\Files\NotFoundException $e) {
catch(\OCP\Files\NotFoundException $e) {
$signatureExist = false; $signatureExist = false;
} }
return $signatureExist; return $signatureExist;
} }
private function doesLogoExist(){ private function doesLogoExist()
{
$storage = $this->rootFolder->getUserFolder(self::DEFAULT_NEXTCLOUD_ADMIN); $storage = $this->rootFolder->getUserFolder(self::DEFAULT_NEXTCLOUD_ADMIN);
try { try {
if(isset($storage)) { if(isset($storage)) {
@ -77,13 +80,13 @@ class InvoiceRecapService {
} else { } else {
return false; return false;
} }
} } catch(\OCP\Files\NotFoundException $e) {
catch(\OCP\Files\NotFoundException $e) {
return false; return false;
} }
} }
private function generateInvoiceRecapPerClientGroupFacturation($clientGroupId,$date,$idNextcloud){ private function generateInvoiceRecapPerClientGroupFacturation($clientGroupId, $date, $idNextcloud)
{
$data_factures = []; $data_factures = [];
$storage = $this->rootFolder->getUserFolder($idNextcloud); $storage = $this->rootFolder->getUserFolder($idNextcloud);
$doesLogoExist = $this->doesLogoExist(); $doesLogoExist = $this->doesLogoExist();
@ -93,7 +96,7 @@ class InvoiceRecapService {
$configurationAddress = $configurationAddresses["address"]; $configurationAddress = $configurationAddresses["address"];
$configurationAddressCity = $configurationAddresses["city"]; $configurationAddressCity = $configurationAddresses["city"];
$factures = json_decode($this->gestionBdd->getClientFacturesByClientGroupFacturationIdAndDate($clientGroupId, $date)); $factures = json_decode($this->gestionBdd->getClientFacturesByClientGroupFacturationIdAndDate($clientGroupId, $date));
$factures = array_filter($factures, callback: function($facture) {return $facture->id_client != NULL; }); $factures = array_filter($factures, callback: function ($facture) {return $facture->id_client != null; });
$clientGroupFacturation = $this->gestionBdd->getClientGroupFacturationById($clientGroupId); $clientGroupFacturation = $this->gestionBdd->getClientGroupFacturationById($clientGroupId);
if($clientGroupFacturation == null) { if($clientGroupFacturation == null) {
return null; return null;
@ -142,7 +145,7 @@ class InvoiceRecapService {
$data_temp = array(); $data_temp = array();
foreach ($data_factures as $key => $facture) { foreach ($data_factures as $key => $facture) {
$datesplit = explode('-', $facture['date_facture']); $datesplit = explode('-', $facture['date_facture']);
if($data_temp[strval($datesplit[0])][strval($datesplit[1])]==NULL) { if($data_temp[strval($datesplit[0])][strval($datesplit[1])] == null) {
$data_temp[strval($datesplit[0])][strval($datesplit[1])] = array(0 => $facture); $data_temp[strval($datesplit[0])][strval($datesplit[1])] = array(0 => $facture);
} else { } else {
array_push($data_temp[strval($datesplit[0])][strval($datesplit[1])], $facture); array_push($data_temp[strval($datesplit[0])][strval($datesplit[1])], $facture);
@ -161,17 +164,18 @@ class InvoiceRecapService {
try { try {
$storage->newFolder(html_entity_decode($defaultConfig[0]->path).'/DOCUMENTS RECAPITULATIFS/'.$key_annee.'/'.$key_mois.' '.strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1])).'/'); $storage->newFolder(html_entity_decode($defaultConfig[0]->path).'/DOCUMENTS RECAPITULATIFS/'.$key_annee.'/'.$key_mois.' '.strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1])).'/');
} catch(\OCP\Files\NotPermittedException $e) { } } catch(\OCP\Files\NotPermittedException $e) {
}
$pdf->AddPage(); $pdf->AddPage();
$pdf->SetLineWidth(0.2); $pdf->SetLineWidth(0.2);
// on sup les 2 cm en bas // on sup les 2 cm en bas
$pdf->SetAutoPagebreak(False); $pdf->SetAutoPagebreak(false);
$pdf->SetMargins(0, 0, 0); $pdf->SetMargins(0, 0, 0);
// logo : 80 de largeur et 55 de hauteur // logo : 80 de largeur et 55 de hauteur
if($doesLogoExist) { if($doesLogoExist) {
$pdf->Image($this->defaultImagePath."logo.png", 2, 2, 50,35); $pdf->Image($this->defaultImagePath."logo.png", 10, 10, 75, 25);
} }
//adresse de mon entreprise //adresse de mon entreprise
@ -223,26 +227,39 @@ class InvoiceRecapService {
// observations // observations
$objetYAxis = 110; $objetYAxis = 110;
$pdf->SetFont( "ComicSans", "BU", 10 ); $pdf->SetXY( 10, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth("Objet:"), 0, "Objet:", 0, "L"); $pdf->SetFont("ComicSans", "BU", 10);
$pdf->SetXY(10, $objetYAxis) ;
$pdf->Cell($pdf->GetStringWidth("Objet:"), 0, "Objet:", 0, "L");
$objet = utf8_decode("Récapitulatif Facturation du mois de ").strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1])); $objet = utf8_decode("Récapitulatif Facturation du mois de ").strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1]));
$pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth($objet), 0, $objet, 0, "L"); $pdf->SetFont("ComicSans", "", 10);
$pdf->SetXY($pdf->GetStringWidth("Objet") + 15, $objetYAxis) ;
$pdf->Cell($pdf->GetStringWidth($objet), 0, $objet, 0, "L");
$objetYAxis += 10; $objetYAxis += 10;
$pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ); $pdf->Cell($pdf->GetStringWidth("Madame, Monsieur"), 0, "Madame, Monsieur", 0, "L"); $pdf->SetFont("ComicSans", "", 10);
$pdf->SetXY($pdf->GetStringWidth("Objet") + 15, $objetYAxis);
$pdf->Cell($pdf->GetStringWidth("Madame, Monsieur"), 0, "Madame, Monsieur", 0, "L");
$text1 = utf8_decode("Veuillez trouver ci-dessous le récapitulatif de la facturation du mois de ").strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1]))."."; $text1 = utf8_decode("Veuillez trouver ci-dessous le récapitulatif de la facturation du mois de ").strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1])).".";
$text2 = utf8_decode("Vous en souhaitant bonne réception."); $text2 = utf8_decode("Vous en souhaitant bonne réception.");
$text3 = utf8_decode("Veuillez agréer, Madame, Monsieur, mes salutations les meilleures."); $text3 = utf8_decode("Veuillez agréer, Madame, Monsieur, mes salutations les meilleures.");
$objetYAxis += 10; $objetYAxis += 10;
$pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth($text1), 0, $text1, 0, "L"); $pdf->SetFont("ComicSans", "", 10);
$pdf->SetXY($pdf->GetStringWidth("Objet") + 15, $objetYAxis) ;
$pdf->Cell($pdf->GetStringWidth($text1), 0, $text1, 0, "L");
$objetYAxis += 5; $objetYAxis += 5;
$pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth($text2), 0, $text2, 0, "L"); $pdf->SetFont("ComicSans", "", 10);
$pdf->SetXY($pdf->GetStringWidth("Objet") + 15, $objetYAxis) ;
$pdf->Cell($pdf->GetStringWidth($text2), 0, $text2, 0, "L");
$objetYAxis += 5; $objetYAxis += 5;
$pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth($text3), 0, $text3, 0, "L"); $pdf->SetFont("ComicSans", "", 10);
$pdf->SetXY($pdf->GetStringWidth("Objet") + 15, $objetYAxis) ;
$pdf->Cell($pdf->GetStringWidth($text3), 0, $text3, 0, "L");
// signature // signature
$pdf->SetFont('ComicSans','',11); $pdf->SetXY( 145, 170); $pdf->SetFont('ComicSans', '', 11);
$pdf->SetXY(145, 170);
$pdf->Cell($pdf->GetStringWidth($defaultConfig[0]->nom.' '.$defaultConfig[0]->prenom), 0, utf8_decode(html_entity_decode($defaultConfig[0]->nom.' '.$defaultConfig[0]->prenom)), 0, 0, 'L'); $pdf->Cell($pdf->GetStringWidth($defaultConfig[0]->nom.' '.$defaultConfig[0]->prenom), 0, utf8_decode(html_entity_decode($defaultConfig[0]->nom.' '.$defaultConfig[0]->prenom)), 0, 0, 'L');
if($doesSignatureExist) { if($doesSignatureExist) {
$pdf->Image($this->defaultImagePath."sign.png", 140, 175, 45, 30); $pdf->Image($this->defaultImagePath."sign.png", 140, 175, 45, 30);
@ -253,9 +270,12 @@ class InvoiceRecapService {
//Positionnement en bas et tout centrer //Positionnement en bas et tout centrer
$pdf->SetFont('ComicSans', '', 6); $pdf->SetFont('ComicSans', '', 6);
$pdf->SetXY( 1, $y0 + 4 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_one)), 0, 0, 'C'); $pdf->SetXY(1, $y0 + 4);
$pdf->SetXY( 1, $y0 + 8 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_two)), 0, 0, 'C'); $pdf->Cell($pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_one)), 0, 0, 'C');
$pdf->SetXY( 1, $y0 + 12 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->telephone)), 0, 0, 'C'); $pdf->SetXY(1, $y0 + 8);
$pdf->Cell($pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_two)), 0, 0, 'C');
$pdf->SetXY(1, $y0 + 12);
$pdf->Cell($pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->telephone)), 0, 0, 'C');
/*$pdf->SetXY( 1, $y0 + 16 ); /*$pdf->SetXY( 1, $y0 + 16 );
$pdf->Cell( $pageWidth, 5, utf8_decode("SIREN 751621293"), 0, 0, 'C');*/ $pdf->Cell( $pageWidth, 5, utf8_decode("SIREN 751621293"), 0, 0, 'C');*/
@ -272,11 +292,11 @@ class InvoiceRecapService {
while ($num_page <= $nb_page) { while ($num_page <= $nb_page) {
$pdf->AddPage(); $pdf->AddPage();
// on sup les 2 cm en bas // on sup les 2 cm en bas
$pdf->SetAutoPagebreak(False); $pdf->SetAutoPagebreak(false);
$pdf->SetMargins(0, 0, 10); $pdf->SetMargins(0, 0, 10);
if($doesLogoExist) { if($doesLogoExist) {
$pdf->Image($this->defaultImagePath."logo.png", 2, 2, 50,35); $pdf->Image($this->defaultImagePath."logo.png", 10, 10, 75, 25);
} }
//adresse de mon entreprise //adresse de mon entreprise
@ -300,7 +320,9 @@ class InvoiceRecapService {
// n° page en haute à droite // n° page en haute à droite
if($nb_page > 1) { if($nb_page > 1) {
$pdf->SetXY( 120, 5 ); $pdf->SetFont( "ComicSans", "B", 9 ); $pdf->Cell( 160, 8, $num_page . '/' . $nb_page, 0, 0, 'C'); $pdf->SetXY(120, 5);
$pdf->SetFont("ComicSans", "B", 9);
$pdf->Cell(160, 8, $num_page . '/' . $nb_page, 0, 0, 'C');
} }
// adresse du facture // adresse du facture
@ -344,21 +366,34 @@ class InvoiceRecapService {
$pdf->Line(25, 80, 25, 225); $pdf->Line(25, 80, 25, 225);
$pdf->Line(46, 80, 46, 225); $pdf->Line(46, 80, 46, 225);
$pdf->Line(99, 80, 99, 225); $pdf->Line(99, 80, 99, 225);
} } else {
else{
$pdf->Line(183, 80, 183, 233); $pdf->Line(183, 80, 183, 233);
$pdf->Line(25, 80, 25, 233); $pdf->Line(25, 80, 25, 233);
$pdf->Line(46, 80, 46, 233); $pdf->Line(46, 80, 46, 233);
$pdf->Line(99, 80, 99, 233); $pdf->Line(99, 80, 99, 233);
} }
// titre colonne // titre colonne
$pdf->SetXY( 1, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 30, 8, FileExportHelpers::FormatTextForExport(""), 0, 0, 'C'); $pdf->SetXY(1, 81);
$pdf->SetXY( 26, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 18, 8, "Date", 0, 0, 'C'); $pdf->SetFont('ComicSans', 'B', 8);
$pdf->SetXY( 47, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 50, 8, FileExportHelpers::FormatTextForExport("Défunt"), 0, 0, 'C'); $pdf->Cell(30, 8, FileExportHelpers::FormatTextForExport(""), 0, 0, 'C');
$pdf->SetXY( 100, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 45, 8, FileExportHelpers::FormatTextForExport("Articles"), 0, 0, 'C'); $pdf->SetXY(26, 81);
$pdf->SetXY( 147, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 13, 8, "H.T.", 0, 0, 'C'); $pdf->SetFont('ComicSans', 'B', 8);
$pdf->SetXY( 168, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 10, 8, "TVA 20%", 0, 0, 'C'); $pdf->Cell(18, 8, "Date", 0, 0, 'C');
$pdf->SetXY( 183, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 22, 8, "T.T.C", 0, 0, 'C'); $pdf->SetXY(47, 81);
$pdf->SetFont('ComicSans', 'B', 8);
$pdf->Cell(50, 8, FileExportHelpers::FormatTextForExport("Défunt"), 0, 0, 'C');
$pdf->SetXY(100, 81);
$pdf->SetFont('ComicSans', 'B', 8);
$pdf->Cell(45, 8, FileExportHelpers::FormatTextForExport("Articles"), 0, 0, 'C');
$pdf->SetXY(147, 81);
$pdf->SetFont('ComicSans', 'B', 8);
$pdf->Cell(13, 8, "H.T.", 0, 0, 'C');
$pdf->SetXY(168, 81);
$pdf->SetFont('ComicSans', 'B', 8);
$pdf->Cell(10, 8, "TVA 20%", 0, 0, 'C');
$pdf->SetXY(183, 81);
$pdf->SetFont('ComicSans', 'B', 8);
$pdf->Cell(22, 8, "T.T.C", 0, 0, 'C');
// (new DateTime($facture['date_soin']))->format('d-M') // (new DateTime($facture['date_soin']))->format('d-M')
$formatter_ds = new IntlDateFormatter('fr_FR', IntlDateFormatter::SHORT, IntlDateFormatter::NONE); $formatter_ds = new IntlDateFormatter('fr_FR', IntlDateFormatter::SHORT, IntlDateFormatter::NONE);
@ -376,20 +411,31 @@ class InvoiceRecapService {
$defuntNameText = $mois[$index_facture_position]['defunt']; $defuntNameText = $mois[$index_facture_position]['defunt'];
$defuntNameTextWidth = $pdf->GetStringWidth($defuntNameText); $defuntNameTextWidth = $pdf->GetStringWidth($defuntNameText);
$defuntNameTextIsMultiline = $defuntNameTextWidth >= 50; $defuntNameTextIsMultiline = $defuntNameTextWidth >= 50;
$pdf->SetXY( 6, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 28, 5, $mois[$index_facture_position]['num'], 0, 0, ''); $pdf->SetXY(6, $y_facture);
$pdf->SetXY( 29, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 28, 5, utf8_decode($formatter_ds->format($date_soin_temp)), 0, 0, ''); $pdf->SetFont('ComicSans', '', 8);
$pdf->Cell(28, 5, $mois[$index_facture_position]['num'], 0, 0, '');
$pdf->SetXY(29, $y_facture);
$pdf->SetFont('ComicSans', '', 8);
$pdf->Cell(28, 5, utf8_decode($formatter_ds->format($date_soin_temp)), 0, 0, '');
$pdf->SetXY(47, $y_facture); $pdf->SetXY(47, $y_facture);
$pdf->SetFont('ComicSans', '', 8); $pdf->SetFont('ComicSans', '', 8);
if($defuntNameTextIsMultiline) { if($defuntNameTextIsMultiline) {
$pdf->MultiCell(50, 5, FileExportHelpers::FormatTextForExport($defuntNameText), 0, 'L'); $pdf->MultiCell(50, 5, FileExportHelpers::FormatTextForExport($defuntNameText), 0, 'L');
} } else {
else{
$pdf->Cell(50, 5, FileExportHelpers::FormatTextForExport($defuntNameText), 0); $pdf->Cell(50, 5, FileExportHelpers::FormatTextForExport($defuntNameText), 0);
} }
$pdf->SetXY( 100, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 38, 5, FileExportHelpers::FormatTextForExport($mois[$index_facture_position]['produit_references']), 0, 0, ''); $pdf->SetXY(100, $y_facture);
$pdf->SetXY( 147, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 13, 5, number_format($mois[$index_facture_position]['montant_htc'],2,'.','').chr(128), 0, 0, 'C'); $pdf->SetFont('ComicSans', '', 8);
$pdf->SetXY( 168, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 10, 5, number_format($mois[$index_facture_position]['montant_tva'],2,'.','').chr(128), 0, 0, 'C'); $pdf->Cell(38, 5, FileExportHelpers::FormatTextForExport($mois[$index_facture_position]['produit_references']), 0, 0, '');
$pdf->SetXY( 183, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 22, 5, number_format($mois[$index_facture_position]['montant_ttc'],2,'.','').chr(128), 0, 0, 'C'); $pdf->SetXY(147, $y_facture);
$pdf->SetFont('ComicSans', '', 8);
$pdf->Cell(13, 5, number_format($mois[$index_facture_position]['montant_htc'], 2, '.', '').chr(128), 0, 0, 'C');
$pdf->SetXY(168, $y_facture);
$pdf->SetFont('ComicSans', '', 8);
$pdf->Cell(10, 5, number_format($mois[$index_facture_position]['montant_tva'], 2, '.', '').chr(128), 0, 0, 'C');
$pdf->SetXY(183, $y_facture);
$pdf->SetFont('ComicSans', '', 8);
$pdf->Cell(22, 5, number_format($mois[$index_facture_position]['montant_ttc'], 2, '.', '').chr(128), 0, 0, 'C');
$montant_ht_total = $montant_ht_total + $mois[$index_facture_position]['montant_htc']; $montant_ht_total = $montant_ht_total + $mois[$index_facture_position]['montant_htc'];
$montant_tva_total = $montant_tva_total + $mois[$index_facture_position]['montant_tva']; $montant_tva_total = $montant_tva_total + $mois[$index_facture_position]['montant_tva'];
@ -406,16 +452,27 @@ class InvoiceRecapService {
$max_nb_toget = ($reste_a_chargee <= 26) ? $reste_a_chargee + 1 : 26; $max_nb_toget = ($reste_a_chargee <= 26) ? $reste_a_chargee + 1 : 26;
// si derniere page alors afficher cadre des TVA // si derniere page alors afficher cadre des TVA
if ($num_page == $nb_page) if ($num_page == $nb_page) {
{
$pdf->Line(5, 225, 205, 225); $pdf->Line(5, 225, 205, 225);
$pdf->SetFont('ComicSans','B',8); $pdf->SetXY( 5, 225 ); $pdf->Cell( 140, 8, 'TOTAL', 0, 0, 'C'); $pdf->SetFont('ComicSans', 'B', 8);
$pdf->SetFont('ComicSans','',8); $pdf->SetXY( 147, 225 ); $pdf->Cell( 13, 8, number_format($montant_ht_total,2,'.','').chr(128), 0, 0, 'C'); $pdf->SetXY(5, 225);
$pdf->SetFont('ComicSans','',8); $pdf->SetXY( 168, 225 ); $pdf->Cell( 10, 8, number_format($montant_tva_total,2,'.','').chr(128), 0, 0, 'C'); $pdf->Cell(140, 8, 'TOTAL', 0, 0, 'C');
$pdf->SetFont('ComicSans','',8); $pdf->SetXY( 183, 225 ); $pdf->Cell( 22, 8, number_format($montant_ttc_total,2,'.','').chr(128), 0, 0, 'C'); $pdf->SetFont('ComicSans', '', 8);
$pdf->SetXY(147, 225);
$pdf->Cell(13, 8, number_format($montant_ht_total, 2, '.', '').chr(128), 0, 0, 'C');
$pdf->SetFont('ComicSans', '', 8);
$pdf->SetXY(168, 225);
$pdf->Cell(10, 8, number_format($montant_tva_total, 2, '.', '').chr(128), 0, 0, 'C');
$pdf->SetFont('ComicSans', '', 8);
$pdf->SetXY(183, 225);
$pdf->Cell(22, 8, number_format($montant_ttc_total, 2, '.', '').chr(128), 0, 0, 'C');
$pdf->SetFont('ComicSans','B',8); $pdf->SetXY( 147, 233 ); $pdf->Cell( 30, 6.5, 'TOTAL TTC', 0, 0, 'C'); $pdf->SetFont('ComicSans', 'B', 8);
$pdf->SetFont('ComicSans','B',8); $pdf->SetXY( 183, 233 ); $pdf->Cell( 22, 6.5, number_format($montant_ttc_total,2,'.','').chr(128), 0, 0, 'C', true); $pdf->SetXY(147, 233);
$pdf->Cell(30, 6.5, 'TOTAL TTC', 0, 0, 'C');
$pdf->SetFont('ComicSans', 'B', 8);
$pdf->SetXY(183, 233);
$pdf->Cell(22, 6.5, number_format($montant_ttc_total, 2, '.', '').chr(128), 0, 0, 'C', true);
$pdf->Line(145, 233, 145, 240); $pdf->Line(145, 233, 145, 240);
$pdf->Line(183, 233, 183, 240); $pdf->Line(183, 233, 183, 240);
$pdf->Line(183, 233, 205, 233); $pdf->Line(183, 233, 205, 233);
@ -430,18 +487,24 @@ class InvoiceRecapService {
$pdf->SetFont('ComicSans', '', 9); $pdf->SetFont('ComicSans', '', 9);
$pdf->SetXY( 10, $y1 ); $pdf->Cell( $pdf->GetPageWidth(), 4, utf8_decode("Loi N° 92-442 du 31 décembre 1992: La présente facture est payable en comptant a réception."), 0, 0, 'L'); $pdf->SetXY(10, $y1);
$pdf->SetXY( 10, $y1 + 4 ); $pdf->Cell( $pdf->GetPageWidth(), 4, utf8_decode("Indemnité forfaitaire pour frais de recouvrement due en cas de retard de paiement: 40").chr(128), 0, 0, 'L'); $pdf->Cell($pdf->GetPageWidth(), 4, utf8_decode("Loi N° 92-442 du 31 décembre 1992: La présente facture est payable en comptant a réception."), 0, 0, 'L');
$pdf->SetXY( 10, $y1 + 8 ); $pdf->Multicell( $pdf->GetPageWidth()-20, 4, utf8_decode("Toute somme non payée dans les trente jours est susceptible de porter intérets à un taux égal à une fois et demi le taux de l'intéret légal."), 0, 0, 'L'); $pdf->SetXY(10, $y1 + 4);
$pdf->Cell($pdf->GetPageWidth(), 4, utf8_decode("Indemnité forfaitaire pour frais de recouvrement due en cas de retard de paiement: 40").chr(128), 0, 0, 'L');
$pdf->SetXY(10, $y1 + 8);
$pdf->Multicell($pdf->GetPageWidth() - 20, 4, utf8_decode("Toute somme non payée dans les trente jours est susceptible de porter intérets à un taux égal à une fois et demi le taux de l'intéret légal."), 0, 0, 'L');
// ************************** // **************************
// pied de page // pied de page
// ************************** // **************************
$pdf->SetFont('ComicSans', '', 6); $pdf->SetFont('ComicSans', '', 6);
$pdf->SetXY( 1, $y0 + 4 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_one)), 0, 0, 'C'); $pdf->SetXY(1, $y0 + 4);
$pdf->SetXY( 1, $y0 + 8 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_two)), 0, 0, 'C'); $pdf->Cell($pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_one)), 0, 0, 'C');
$pdf->SetXY( 1, $y0 + 12 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->telephone)), 0, 0, 'C'); $pdf->SetXY(1, $y0 + 8);
$pdf->Cell($pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_two)), 0, 0, 'C');
$pdf->SetXY(1, $y0 + 12);
$pdf->Cell($pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->telephone)), 0, 0, 'C');
/*$pdf->SetXY( 1, $y0 + 16 ); /*$pdf->SetXY( 1, $y0 + 16 );
$pdf->Cell( $pageWidth, 5, utf8_decode("SIREN 751621293"), 0, 0, 'C');*/ $pdf->Cell( $pageWidth, 5, utf8_decode("SIREN 751621293"), 0, 0, 'C');*/
@ -449,7 +512,8 @@ class InvoiceRecapService {
$num_page++; $num_page++;
} }
$ff_pdf = html_entity_decode( $ff_pdf = html_entity_decode(
$defaultConfig[0]->path). $defaultConfig[0]->path
).
'/DOCUMENTS RECAPITULATIFS/'.$key_annee.'/'.$key_mois.' '. '/DOCUMENTS RECAPITULATIFS/'.$key_annee.'/'.$key_mois.' '.
strtoupper( strtoupper(
FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1]) FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1])
@ -466,7 +530,8 @@ class InvoiceRecapService {
} }
} }
private function generateInvoiceRecapPerClient($clientId,$date,$idNextcloud){ private function generateInvoiceRecapPerClient($clientId, $date, $idNextcloud)
{
$data_factures = []; $data_factures = [];
$storage = $this->rootFolder->getUserFolder($idNextcloud); $storage = $this->rootFolder->getUserFolder($idNextcloud);
$doesLogoExist = $this->doesLogoExist(); $doesLogoExist = $this->doesLogoExist();
@ -479,7 +544,7 @@ class InvoiceRecapService {
clientId: $clientId, clientId: $clientId,
date: $date date: $date
)); ));
$factures = array_filter($factures, callback: function($facture) {return $facture->id_client != NULL; }); $factures = array_filter($factures, callback: function ($facture) {return $facture->id_client != null; });
foreach ($factures as $key => $facture) { foreach ($factures as $key => $facture) {
$facture_temp = array( $facture_temp = array(
'num' => $facture->num, 'num' => $facture->num,
@ -533,7 +598,7 @@ class InvoiceRecapService {
$data_temp = array(); $data_temp = array();
foreach ($data_factures as $key => $facture) { foreach ($data_factures as $key => $facture) {
$datesplit = explode('-', $facture['date_facture']); $datesplit = explode('-', $facture['date_facture']);
if($data_temp[strval($datesplit[0])][strval($datesplit[1])][$facture['id_client']]==NULL) { if($data_temp[strval($datesplit[0])][strval($datesplit[1])][$facture['id_client']] == null) {
$data_temp[strval($datesplit[0])][strval($datesplit[1])][$facture['id_client']] = array(0 => $facture); $data_temp[strval($datesplit[0])][strval($datesplit[1])][$facture['id_client']] = array(0 => $facture);
} else { } else {
array_push($data_temp[strval($datesplit[0])][strval($datesplit[1])][$facture['id_client']], $facture); array_push($data_temp[strval($datesplit[0])][strval($datesplit[1])][$facture['id_client']], $facture);
@ -563,8 +628,7 @@ class InvoiceRecapService {
$clientCity = $facture["group_postal_code"]. " ".$facture["group_city"]; $clientCity = $facture["group_postal_code"]. " ".$facture["group_city"];
$tvaIntraCommuValue = $facture["group_siret_number"]; $tvaIntraCommuValue = $facture["group_siret_number"];
$clientMail = $facture["group_email"]; $clientMail = $facture["group_email"];
} } else {
else{
$clientAddresses = FileExportHelpers::GetAddressAndCityFromAddress($facture['adresse_client']); $clientAddresses = FileExportHelpers::GetAddressAndCityFromAddress($facture['adresse_client']);
$clientAddress = $clientAddresses['address']; $clientAddress = $clientAddresses['address'];
$clientCity = $clientAddresses['city']; $clientCity = $clientAddresses['city'];
@ -579,17 +643,18 @@ class InvoiceRecapService {
try { try {
$storage->newFolder(html_entity_decode($defaultConfig[0]->path).'/DOCUMENTS RECAPITULATIFS/'.$key_annee.'/'.$key_mois.' '.strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1])).'/'); $storage->newFolder(html_entity_decode($defaultConfig[0]->path).'/DOCUMENTS RECAPITULATIFS/'.$key_annee.'/'.$key_mois.' '.strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1])).'/');
} catch(\OCP\Files\NotPermittedException $e) { } } catch(\OCP\Files\NotPermittedException $e) {
}
$pdf->AddPage(); $pdf->AddPage();
$pdf->SetLineWidth(0.2); $pdf->SetLineWidth(0.2);
// on sup les 2 cm en bas // on sup les 2 cm en bas
$pdf->SetAutoPagebreak(False); $pdf->SetAutoPagebreak(false);
$pdf->SetMargins(0, 0, 10); $pdf->SetMargins(0, 0, 10);
// logo : 80 de largeur et 55 de hauteur // logo : 80 de largeur et 55 de hauteur
if($doesLogoExist) { if($doesLogoExist) {
$pdf->Image($this->defaultImagePath."logo.png", 2, 2, 50,35); $pdf->Image($this->defaultImagePath."logo.png", 10, 10, 75, 25);
} }
//adresse de mon entreprise //adresse de mon entreprise
@ -640,26 +705,39 @@ class InvoiceRecapService {
// observations // observations
$objetYAxis = 110; $objetYAxis = 110;
$pdf->SetFont( "ComicSans", "BU", 10 ); $pdf->SetXY( 10, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth("Objet:"), 0, "Objet:", 0, "L"); $pdf->SetFont("ComicSans", "BU", 10);
$pdf->SetXY(10, $objetYAxis) ;
$pdf->Cell($pdf->GetStringWidth("Objet:"), 0, "Objet:", 0, "L");
$objet = utf8_decode("Récapitulatif Facturation du mois de ").strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1])); $objet = utf8_decode("Récapitulatif Facturation du mois de ").strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1]));
$pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth($objet), 0, $objet, 0, "L"); $pdf->SetFont("ComicSans", "", 10);
$pdf->SetXY($pdf->GetStringWidth("Objet") + 15, $objetYAxis) ;
$pdf->Cell($pdf->GetStringWidth($objet), 0, $objet, 0, "L");
$objetYAxis += 10; $objetYAxis += 10;
$pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ); $pdf->Cell($pdf->GetStringWidth("Madame, Monsieur"), 0, "Madame, Monsieur", 0, "L"); $pdf->SetFont("ComicSans", "", 10);
$pdf->SetXY($pdf->GetStringWidth("Objet") + 15, $objetYAxis);
$pdf->Cell($pdf->GetStringWidth("Madame, Monsieur"), 0, "Madame, Monsieur", 0, "L");
$text1 = utf8_decode("Veuillez trouver ci-dessous le récapitulatif de la facturation du mois de ").strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1]))."."; $text1 = utf8_decode("Veuillez trouver ci-dessous le récapitulatif de la facturation du mois de ").strtoupper(FileExportHelpers::ConvertSpecialChar(explode(' ', $date_formated)[1])).".";
$text2 = utf8_decode("Vous en souhaitant bonne réception."); $text2 = utf8_decode("Vous en souhaitant bonne réception.");
$text3 = utf8_decode("Veuillez agréer, Madame, Monsieur, mes salutations les meilleures."); $text3 = utf8_decode("Veuillez agréer, Madame, Monsieur, mes salutations les meilleures.");
$objetYAxis += 10; $objetYAxis += 10;
$pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth($text1), 0, $text1, 0, "L"); $pdf->SetFont("ComicSans", "", 10);
$pdf->SetXY($pdf->GetStringWidth("Objet") + 15, $objetYAxis) ;
$pdf->Cell($pdf->GetStringWidth($text1), 0, $text1, 0, "L");
$objetYAxis += 5; $objetYAxis += 5;
$pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth($text2), 0, $text2, 0, "L"); $pdf->SetFont("ComicSans", "", 10);
$pdf->SetXY($pdf->GetStringWidth("Objet") + 15, $objetYAxis) ;
$pdf->Cell($pdf->GetStringWidth($text2), 0, $text2, 0, "L");
$objetYAxis += 5; $objetYAxis += 5;
$pdf->SetFont( "ComicSans", "", 10 ); $pdf->SetXY( $pdf->GetStringWidth("Objet")+15, $objetYAxis ) ; $pdf->Cell($pdf->GetStringWidth($text3), 0, $text3, 0, "L"); $pdf->SetFont("ComicSans", "", 10);
$pdf->SetXY($pdf->GetStringWidth("Objet") + 15, $objetYAxis) ;
$pdf->Cell($pdf->GetStringWidth($text3), 0, $text3, 0, "L");
// signature // signature
$pdf->SetFont('ComicSans','',11); $pdf->SetXY( 145, 170); $pdf->SetFont('ComicSans', '', 11);
$pdf->SetXY(145, 170);
$pdf->Cell($pdf->GetStringWidth($defaultConfig[0]->nom.' '.$defaultConfig[0]->prenom), 0, utf8_decode(html_entity_decode($defaultConfig[0]->nom.' '.$defaultConfig[0]->prenom)), 0, 0, 'L'); $pdf->Cell($pdf->GetStringWidth($defaultConfig[0]->nom.' '.$defaultConfig[0]->prenom), 0, utf8_decode(html_entity_decode($defaultConfig[0]->nom.' '.$defaultConfig[0]->prenom)), 0, 0, 'L');
if($doesSignatureExist) { if($doesSignatureExist) {
$pdf->Image($this->defaultImagePath."sign.png", 140, 175, 45, 30); $pdf->Image($this->defaultImagePath."sign.png", 140, 175, 45, 30);
@ -669,10 +747,14 @@ class InvoiceRecapService {
$pageWidth = $pdf->GetPageWidth(); $pageWidth = $pdf->GetPageWidth();
//Positionnement en bas et tout centrer //Positionnement en bas et tout centrer
$pdf->SetFont('ComicSans', '', 7); $pdf->SetFont('ComicSans', '', 7);
$pdf->SetXY( 1, $y0 + 4 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->mentions_default)), 0, 0, 'C'); $pdf->SetXY(1, $y0 + 4);
$pdf->SetXY( 1, $y0 + 8 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_one)), 0, 0, 'C'); $pdf->Cell($pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->mentions_default)), 0, 0, 'C');
$pdf->SetXY( 1, $y0 + 12 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_two)), 0, 0, 'C'); $pdf->SetXY(1, $y0 + 8);
$pdf->SetXY( 1, $y0 + 16 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->telephone)), 0, 0, 'C'); $pdf->Cell($pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_one)), 0, 0, 'C');
$pdf->SetXY(1, $y0 + 12);
$pdf->Cell($pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_two)), 0, 0, 'C');
$pdf->SetXY(1, $y0 + 16);
$pdf->Cell($pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->telephone)), 0, 0, 'C');
/*$pdf->SetXY( 1, $y0 + 16 ); /*$pdf->SetXY( 1, $y0 + 16 );
$pdf->Cell( $pageWidth, 5, utf8_decode("SIREN 751621293"), 0, 0, 'C');*/ $pdf->Cell( $pageWidth, 5, utf8_decode("SIREN 751621293"), 0, 0, 'C');*/
@ -689,10 +771,10 @@ class InvoiceRecapService {
while ($num_page <= $nb_page) { while ($num_page <= $nb_page) {
$pdf->AddPage(); $pdf->AddPage();
// on sup les 2 cm en bas // on sup les 2 cm en bas
$pdf->SetAutoPagebreak(False); $pdf->SetAutoPagebreak(false);
$pdf->SetMargins(0, 0, 10); $pdf->SetMargins(0, 0, 10);
if($doesLogoExist) { if($doesLogoExist) {
$pdf->Image($this->defaultImagePath."logo.png", 2, 2, 50,35); $pdf->Image($this->defaultImagePath."logo.png", 10, 10, 75, 25);
} }
//adresse de mon entreprise //adresse de mon entreprise
@ -716,7 +798,9 @@ class InvoiceRecapService {
// n° page en haute à droite // n° page en haute à droite
if($nb_page > 1) { if($nb_page > 1) {
$pdf->SetXY( 120, 5 ); $pdf->SetFont( "ComicSans", "B", 9 ); $pdf->Cell( 160, 8, $num_page . '/' . $nb_page, 0, 0, 'C'); $pdf->SetXY(120, 5);
$pdf->SetFont("ComicSans", "B", 9);
$pdf->Cell(160, 8, $num_page . '/' . $nb_page, 0, 0, 'C');
} }
// adresse du facture // adresse du facture
@ -760,21 +844,34 @@ class InvoiceRecapService {
$pdf->Line(25, 80, 25, 225); $pdf->Line(25, 80, 25, 225);
$pdf->Line(46, 80, 46, 225); $pdf->Line(46, 80, 46, 225);
$pdf->Line(99, 80, 99, 225); $pdf->Line(99, 80, 99, 225);
} } else {
else{
$pdf->Line(183, 80, 183, 233); $pdf->Line(183, 80, 183, 233);
$pdf->Line(25, 80, 25, 233); $pdf->Line(25, 80, 25, 233);
$pdf->Line(46, 80, 46, 233); $pdf->Line(46, 80, 46, 233);
$pdf->Line(99, 80, 99, 233); $pdf->Line(99, 80, 99, 233);
} }
// titre colonne // titre colonne
$pdf->SetXY( 1, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 30, 8, FileExportHelpers::FormatTextForExport(""), 0, 0, 'C'); $pdf->SetXY(1, 81);
$pdf->SetXY( 26, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 18, 8, "Date", 0, 0, 'C'); $pdf->SetFont('ComicSans', 'B', 8);
$pdf->SetXY( 47, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 50, 8, FileExportHelpers::FormatTextForExport("Défunt"), 0, 0, 'C'); $pdf->Cell(30, 8, FileExportHelpers::FormatTextForExport(""), 0, 0, 'C');
$pdf->SetXY( 100, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 45, 8, "Articles", 0, 0, 'C'); $pdf->SetXY(26, 81);
$pdf->SetXY( 147, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 13, 8, "H.T.", 0, 0, 'C'); $pdf->SetFont('ComicSans', 'B', 8);
$pdf->SetXY( 168, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 10, 8, "TVA 20%", 0, 0, 'C'); $pdf->Cell(18, 8, "Date", 0, 0, 'C');
$pdf->SetXY( 183, 81 ); $pdf->SetFont('ComicSans','B',8); $pdf->Cell( 22, 8, "T.T.C", 0, 0, 'C'); $pdf->SetXY(47, 81);
$pdf->SetFont('ComicSans', 'B', 8);
$pdf->Cell(50, 8, FileExportHelpers::FormatTextForExport("Défunt"), 0, 0, 'C');
$pdf->SetXY(100, 81);
$pdf->SetFont('ComicSans', 'B', 8);
$pdf->Cell(45, 8, "Articles", 0, 0, 'C');
$pdf->SetXY(147, 81);
$pdf->SetFont('ComicSans', 'B', 8);
$pdf->Cell(13, 8, "H.T.", 0, 0, 'C');
$pdf->SetXY(168, 81);
$pdf->SetFont('ComicSans', 'B', 8);
$pdf->Cell(10, 8, "TVA 20%", 0, 0, 'C');
$pdf->SetXY(183, 81);
$pdf->SetFont('ComicSans', 'B', 8);
$pdf->Cell(22, 8, "T.T.C", 0, 0, 'C');
// (new DateTime($facture['date_soin']))->format('d-M') // (new DateTime($facture['date_soin']))->format('d-M')
$formatter_ds = new IntlDateFormatter('fr_FR', IntlDateFormatter::SHORT, IntlDateFormatter::NONE); $formatter_ds = new IntlDateFormatter('fr_FR', IntlDateFormatter::SHORT, IntlDateFormatter::NONE);
@ -792,19 +889,31 @@ class InvoiceRecapService {
$defuntNameText = $client[$index_facture_position]['defunt']; $defuntNameText = $client[$index_facture_position]['defunt'];
$defuntNameTextWidth = $pdf->GetStringWidth($defuntNameText); $defuntNameTextWidth = $pdf->GetStringWidth($defuntNameText);
$defuntNameTextIsMultiline = $defuntNameTextWidth >= 50; $defuntNameTextIsMultiline = $defuntNameTextWidth >= 50;
$pdf->SetXY( 6, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 28, 5, $client[$index_facture_position]['num'], 0, 0, ''); $pdf->SetXY(6, $y_facture);
$pdf->SetXY( 29, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 18, 5, utf8_decode($formatter_ds->format($date_soin_temp)), 0, 0, ''); $pdf->SetFont('ComicSans', '', 8);
$pdf->SetXY( 47, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell(28, 5, $client[$index_facture_position]['num'], 0, 0, '');
$pdf->SetXY(29, $y_facture);
$pdf->SetFont('ComicSans', '', 8);
$pdf->Cell(18, 5, utf8_decode($formatter_ds->format($date_soin_temp)), 0, 0, '');
$pdf->SetXY(47, $y_facture);
$pdf->SetFont('ComicSans', '', 8);
if($defuntNameTextIsMultiline) { if($defuntNameTextIsMultiline) {
$pdf->MultiCell(50, 5, FileExportHelpers::FormatTextForExport($defuntNameText)); $pdf->MultiCell(50, 5, FileExportHelpers::FormatTextForExport($defuntNameText));
} } else {
else{
$pdf->Cell(50, 5, FileExportHelpers::FormatTextForExport($defuntNameText), 0); $pdf->Cell(50, 5, FileExportHelpers::FormatTextForExport($defuntNameText), 0);
} }
$pdf->SetXY( 100, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 28, 5, utf8_decode(html_entity_decode($client[$index_facture_position]['produit_references'])), 0, 0, ''); $pdf->SetXY(100, $y_facture);
$pdf->SetXY( 147, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 13, 5, number_format($client[$index_facture_position]['montant_htc'],2,'.','').chr(128), 0, 0, 'C'); $pdf->SetFont('ComicSans', '', 8);
$pdf->SetXY( 168, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 10, 5, number_format($client[$index_facture_position]['montant_tva'],2,'.','').chr(128), 0, 0, 'C'); $pdf->Cell(28, 5, utf8_decode(html_entity_decode($client[$index_facture_position]['produit_references'])), 0, 0, '');
$pdf->SetXY( 183, $y_facture ); $pdf->SetFont('ComicSans','',8); $pdf->Cell( 22, 5, number_format($client[$index_facture_position]['montant_ttc'],2,'.','').chr(128), 0, 0, 'C'); $pdf->SetXY(147, $y_facture);
$pdf->SetFont('ComicSans', '', 8);
$pdf->Cell(13, 5, number_format($client[$index_facture_position]['montant_htc'], 2, '.', '').chr(128), 0, 0, 'C');
$pdf->SetXY(168, $y_facture);
$pdf->SetFont('ComicSans', '', 8);
$pdf->Cell(10, 5, number_format($client[$index_facture_position]['montant_tva'], 2, '.', '').chr(128), 0, 0, 'C');
$pdf->SetXY(183, $y_facture);
$pdf->SetFont('ComicSans', '', 8);
$pdf->Cell(22, 5, number_format($client[$index_facture_position]['montant_ttc'], 2, '.', '').chr(128), 0, 0, 'C');
$montant_ht_total = $montant_ht_total + $client[$index_facture_position]['montant_htc']; $montant_ht_total = $montant_ht_total + $client[$index_facture_position]['montant_htc'];
$montant_tva_total = $montant_tva_total + $client[$index_facture_position]['montant_tva']; $montant_tva_total = $montant_tva_total + $client[$index_facture_position]['montant_tva'];
@ -820,17 +929,28 @@ class InvoiceRecapService {
$max_nb_toget = ($reste_a_chargee <= 26) ? $reste_a_chargee + 1 : 26; $max_nb_toget = ($reste_a_chargee <= 26) ? $reste_a_chargee + 1 : 26;
// si derniere page alors afficher cadre des TVA // si derniere page alors afficher cadre des TVA
if ($num_page == $nb_page) if ($num_page == $nb_page) {
{
$pdf->Line(5, 225, 205, 225); $pdf->Line(5, 225, 205, 225);
$pdf->SetFont('ComicSans','B',8); $pdf->SetXY( 5, 225 ); $pdf->Cell( 140, 8, 'TOTAL', 0, 0, 'C'); $pdf->SetFont('ComicSans', 'B', 8);
$pdf->SetFont('ComicSans','',8); $pdf->SetXY( 147, 225 ); $pdf->Cell( 13, 8, number_format($montant_ht_total,2,'.','').chr(128), 0, 0, 'C'); $pdf->SetXY(5, 225);
$pdf->SetFont('ComicSans','',8); $pdf->SetXY( 168, 225 ); $pdf->Cell( 10, 8, number_format($montant_tva_total,2,'.','').chr(128), 0, 0, 'C'); $pdf->Cell(140, 8, 'TOTAL', 0, 0, 'C');
$pdf->SetFont('ComicSans','',8); $pdf->SetXY( 183, 225 ); $pdf->Cell( 22, 8, number_format($montant_ttc_total,2,'.','').chr(128), 0, 0, 'C'); $pdf->SetFont('ComicSans', '', 8);
$pdf->SetXY(147, 225);
$pdf->Cell(13, 8, number_format($montant_ht_total, 2, '.', '').chr(128), 0, 0, 'C');
$pdf->SetFont('ComicSans', '', 8);
$pdf->SetXY(168, 225);
$pdf->Cell(10, 8, number_format($montant_tva_total, 2, '.', '').chr(128), 0, 0, 'C');
$pdf->SetFont('ComicSans', '', 8);
$pdf->SetXY(183, 225);
$pdf->Cell(22, 8, number_format($montant_ttc_total, 2, '.', '').chr(128), 0, 0, 'C');
$pdf->SetFont('ComicSans','B',8); $pdf->SetXY( 147, 233 ); $pdf->Cell( 30, 6.5, 'TOTAL TTC', 0, 0, 'C'); $pdf->SetFont('ComicSans', 'B', 8);
$pdf->SetFont('ComicSans','B',8); $pdf->SetXY( 183, 233 ); $pdf->Cell( 22, 6.5, number_format($montant_ttc_total,2,'.','').chr(128), 0, 0, 'C', true); $pdf->SetXY(147, 233);
$pdf->Cell(30, 6.5, 'TOTAL TTC', 0, 0, 'C');
$pdf->SetFont('ComicSans', 'B', 8);
$pdf->SetXY(183, 233);
$pdf->Cell(22, 6.5, number_format($montant_ttc_total, 2, '.', '').chr(128), 0, 0, 'C', true);
$pdf->Line(145, 233, 145, 240); $pdf->Line(145, 233, 145, 240);
$pdf->Line(183, 233, 183, 240); $pdf->Line(183, 233, 183, 240);
$pdf->Line(183, 233, 205, 233); $pdf->Line(183, 233, 205, 233);
@ -845,19 +965,26 @@ class InvoiceRecapService {
$pdf->SetFont('ComicSans', '', 9); $pdf->SetFont('ComicSans', '', 9);
$pdf->SetXY( 10, $y1 );$pdf->Cell( $pdf->GetPageWidth(), 4, utf8_decode("Loi N° 92-442 du 31 décembre 1992: La présente facture est payable en comptant a réception."), 0, 0, 'L'); $pdf->SetXY(10, $y1);
$pdf->SetXY( 10, $y1 + 4 );$pdf->Cell( $pdf->GetPageWidth(), 4, utf8_decode("Indemnité forfaitaire pour frais de recouvrement due en cas de retard de paiement: 40").chr(128), 0, 0, 'L'); $pdf->Cell($pdf->GetPageWidth(), 4, utf8_decode("Loi N° 92-442 du 31 décembre 1992: La présente facture est payable en comptant a réception."), 0, 0, 'L');
$pdf->SetXY( 10, $y1 + 8 );$pdf->Multicell( $pdf->GetPageWidth()-20, 4, utf8_decode("Toute somme non payée dans les trente jours est susceptible de porter intérets à un taux égal à une fois et demi le taux de l'intéret légal."), 0, 0, 'L'); $pdf->SetXY(10, $y1 + 4);
$pdf->Cell($pdf->GetPageWidth(), 4, utf8_decode("Indemnité forfaitaire pour frais de recouvrement due en cas de retard de paiement: 40").chr(128), 0, 0, 'L');
$pdf->SetXY(10, $y1 + 8);
$pdf->Multicell($pdf->GetPageWidth() - 20, 4, utf8_decode("Toute somme non payée dans les trente jours est susceptible de porter intérets à un taux égal à une fois et demi le taux de l'intéret légal."), 0, 0, 'L');
// ************************** // **************************
// pied de page // pied de page
// ************************** // **************************
$pdf->SetFont('ComicSans', '', 7); $pdf->SetFont('ComicSans', '', 7);
$pdf->SetXY( 1, $y0 + 4 ); $pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->mentions_default)), 0, 0, 'C'); $pdf->SetXY(1, $y0 + 4);
$pdf->SetXY( 1, $y0 + 8 );$pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_one)), 0, 0, 'C'); $pdf->Cell($pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->mentions_default)), 0, 0, 'C');
$pdf->SetXY( 1, $y0 + 12 );$pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_two)), 0, 0, 'C'); $pdf->SetXY(1, $y0 + 8);
$pdf->SetXY( 1, $y0 + 16 );$pdf->Cell( $pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->telephone)), 0, 0, 'C'); $pdf->Cell($pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_one)), 0, 0, 'C');
$pdf->SetXY(1, $y0 + 12);
$pdf->Cell($pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->legal_two)), 0, 0, 'C');
$pdf->SetXY(1, $y0 + 16);
$pdf->Cell($pageWidth, 5, utf8_decode(html_entity_decode($defaultConfig[0]->telephone)), 0, 0, 'C');
/*$pdf->SetXY( 1, $y0 + 16 ); /*$pdf->SetXY( 1, $y0 + 16 );
$pdf->Cell( $pageWidth, 5, utf8_decode("SIREN 751621293"), 0, 0, 'C');*/ $pdf->Cell( $pageWidth, 5, utf8_decode("SIREN 751621293"), 0, 0, 'C');*/
@ -876,14 +1003,15 @@ class InvoiceRecapService {
} }
} }
public function generateInvoiceRecap($filter,$filterType,$date,$idNextcloud){ public function generateInvoiceRecap($filter, $filterType, $date, $idNextcloud)
{
try { try {
if($filterType == MultipleFactureTypeConstant::GROUP_FILTER_TYPE) { if($filterType == MultipleFactureTypeConstant::GROUP_FILTER_TYPE) {
$this->generateInvoiceRecapPerClientGroupFacturation($filter, $date, $idNextcloud); $this->generateInvoiceRecapPerClientGroupFacturation($filter, $date, $idNextcloud);
} } else {
else{
$this->generateInvoiceRecapPerClient($filter, $date, $idNextcloud); $this->generateInvoiceRecapPerClient($filter, $date, $idNextcloud);
} }
} catch(\OCP\Files\NotFoundException $e) { } } catch(\OCP\Files\NotFoundException $e) {
}
} }
} }

View File

@ -51,7 +51,7 @@ class MailerService {
if (!$signatureImage) { if (!$signatureImage) {
return ""; return "";
} }
return "<img style= 'width: 250px;height: 150px;' src='data:image/jpeg;base64,".base64_encode($signatureImage)."'>" ; return "<img width='170' height='80' style= 'width: 170;height: 80px;display:block;' src='data:image/jpeg;base64,".base64_encode($signatureImage)."'>" ;
} }
private function getSignatureContent(){ private function getSignatureContent(){

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,32 +28,45 @@
?> ?>
</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'); ?>">
@ -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é.";
}
} }
; ;
@ -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">
@ -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,19 +34,45 @@
?> ?>
</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"/>
@ -51,7 +80,9 @@
<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) {
$showRecapButton = true;
}
$factures = array_filter($_['factures'], function ($f) { $factures = array_filter($_['factures'], function ($f) {
$datesplit = explode("-", $f->date_paiement); $datesplit = explode("-", $f->date_paiement);
$year = (int) $datesplit[0]; $year = (int) $datesplit[0];
@ -64,8 +95,7 @@
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'];
} }
} }
@ -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) {
@ -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);
} }
// 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

@ -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;
@ -125,10 +126,27 @@ $currentConfig = json_decode($_['configuration'])[0];
</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
if (isset($facture->tvaInfo) && $facture->tvaInfo->is_exempt) {
echo 'Exonéré';
} else {
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> </tr>
</tbody> </tbody>
</table> </table>

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>