50 |
$this->db = $db; |
$this->db = $db; |
51 |
$this->name = "crabe"; |
$this->name = "crabe"; |
52 |
$this->description = "Modèle de facture complet (Gère l'option fiscale de facturation TVA, le choix du mode de règlement à afficher, logo...)"; |
$this->description = "Modèle de facture complet (Gère l'option fiscale de facturation TVA, le choix du mode de règlement à afficher, logo...)"; |
53 |
$this->format="A4"; |
|
54 |
|
// Dimension page pour format A4 |
55 |
|
$this->page_largeur = 210; |
56 |
|
$this->page_hauteur = 297; |
57 |
|
$this->format = array($this->page_largeur,$this->page_hauteur); |
58 |
|
|
59 |
$this->option_logo = 1; // Affiche logo FAC_PDF_LOGO |
$this->option_logo = 1; // Affiche logo FAC_PDF_LOGO |
60 |
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION |
139 |
if (file_exists($dir)) |
if (file_exists($dir)) |
140 |
{ |
{ |
141 |
// Initialisation facture vierge |
// Initialisation facture vierge |
142 |
$pdf=new FPDF('P','mm','A4'); |
$pdf=new FPDF('P','mm',$this->format); |
143 |
$pdf->Open(); |
$pdf->Open(); |
144 |
$pdf->AddPage(); |
$pdf->AddPage(); |
145 |
|
|
150 |
$pdf->SetCreator("Dolibarr ".DOL_VERSION); |
$pdf->SetCreator("Dolibarr ".DOL_VERSION); |
151 |
$pdf->SetAuthor($user->fullname); |
$pdf->SetAuthor($user->fullname); |
152 |
|
|
153 |
$pdf->SetMargins(10, 10, 10); |
$pdf->SetMargins(10, 8, 10); // Top, Bottom, Left |
154 |
$pdf->SetAutoPageBreak(1,0); |
$pdf->SetAutoPageBreak(1,0); |
155 |
|
|
156 |
$this->_pagehead($pdf, $fac); |
$this->_pagehead($pdf, $fac); |
349 |
/* |
/* |
350 |
* Pied de page |
* Pied de page |
351 |
*/ |
*/ |
352 |
$this->_pagefoot($pdf, $fac); |
$this->_pagefoot($pdf); |
353 |
$pdf->AliasNbPages(); |
$pdf->AliasNbPages(); |
354 |
|
|
355 |
$pdf->Close(); |
$pdf->Close(); |
650 |
$pdf->SetTextColor(0,0,60); |
$pdf->SetTextColor(0,0,60); |
651 |
$pdf->SetFont('Arial','B',13); |
$pdf->SetFont('Arial','B',13); |
652 |
|
|
653 |
$pdf->SetXY(10,6); |
$posy=10; // La marge Top est de 10, on commence donc a 10 |
654 |
|
|
655 |
|
$pdf->SetXY(10,$posy); |
656 |
|
|
657 |
// Logo |
// Logo |
658 |
if (defined("FAC_PDF_LOGO") && FAC_PDF_LOGO) |
if (defined("FAC_PDF_LOGO") && FAC_PDF_LOGO) |
659 |
{ |
{ |
660 |
if (file_exists(FAC_PDF_LOGO)) |
if (is_readable(FAC_PDF_LOGO)) |
661 |
{ |
{ |
662 |
$pdf->Image(FAC_PDF_LOGO, 10, 5, 0, 24); |
$pdf->Image(FAC_PDF_LOGO, 10, $posy, 0, 24); |
663 |
} |
} |
664 |
else |
else |
665 |
{ |
{ |
666 |
$pdf->SetTextColor(200,0,0); |
$pdf->SetTextColor(200,0,0); |
667 |
$pdf->SetFont('Arial','B',8); |
$pdf->SetFont('Arial','B',8); |
668 |
$pdf->MultiCell(80, 3, $langs->trans("ErrorLogoFileNotFound",FAC_PDF_LOGO), 0, 'L'); |
$pdf->MultiCell(100, 3, $langs->trans("ErrorLogoFileNotFound",FAC_PDF_LOGO), 0, 'L'); |
669 |
$pdf->MultiCell(80, 3, $langs->trans("ErrorGoToModuleSetup"), 0, 'L'); |
$pdf->MultiCell(100, 3, $langs->trans("ErrorGoToModuleSetup"), 0, 'L'); |
670 |
} |
} |
671 |
} |
} |
672 |
else if (defined("FAC_PDF_INTITULE")) |
else if (defined("FAC_PDF_INTITULE")) |
673 |
{ |
{ |
674 |
$pdf->MultiCell(80, 6, FAC_PDF_INTITULE, 0, 'L'); |
$pdf->MultiCell(100, 4, FAC_PDF_INTITULE, 0, 'L'); |
675 |
} |
} |
676 |
|
|
677 |
$pdf->SetFont('Arial','B',13); |
$pdf->SetFont('Arial','B',13); |
678 |
$pdf->SetXY(100,5); |
$pdf->SetXY(100,$posy); |
679 |
$pdf->SetTextColor(0,0,60); |
$pdf->SetTextColor(0,0,60); |
680 |
$pdf->MultiCell(100, 10, $langs->trans("Bill")." ".$fac->ref, '' , 'R'); |
$pdf->MultiCell(100, 4, $langs->trans("Bill")." ".$fac->ref, '' , 'R'); |
681 |
$pdf->SetFont('Arial','',12); |
$pdf->SetFont('Arial','',12); |
682 |
$pdf->SetXY(100,11); |
$pdf->SetXY(100,$posy+6); |
683 |
$pdf->SetTextColor(0,0,60); |
$pdf->SetTextColor(0,0,60); |
684 |
$pdf->MultiCell(100, 10, $langs->trans("Date")." : " . dolibarr_print_date($fac->date,"%d %b %Y"), '', 'R'); |
$pdf->MultiCell(100, 4, $langs->trans("Date")." : " . dolibarr_print_date($fac->date,"%d %b %Y"), '', 'R'); |
685 |
|
|
686 |
// Emetteur |
// Emetteur |
687 |
$posy=42; |
$posy=42; |
770 |
} |
} |
771 |
|
|
772 |
/* |
/* |
773 |
* \brief Affiche le pied de page de la facture |
* \brief Affiche le pied de page |
774 |
* \param pdf objet PDF |
* \param pdf objet PDF |
775 |
* \param fac objet facture |
*/ |
776 |
*/ |
function _pagefoot(&$pdf) |
|
function _pagefoot(&$pdf, $fac) |
|
777 |
{ |
{ |
778 |
global $langs, $conf; |
global $langs, $conf; |
779 |
$langs->load("main"); |
$langs->load("main"); |
782 |
|
|
783 |
$html=new Form($this->db); |
$html=new Form($this->db); |
784 |
|
|
|
$footy=14; |
|
|
$pdf->SetY(-$footy); |
|
|
$pdf->SetDrawColor(224,224,224); |
|
|
$pdf->line(10, 282, 200, 282); |
|
|
|
|
|
$footy=13; |
|
|
$pdf->SetFont('Arial','',8); |
|
|
|
|
785 |
// Premiere ligne d'info réglementaires |
// Premiere ligne d'info réglementaires |
786 |
$ligne=""; |
$ligne1=""; |
787 |
if ($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE) |
if ($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE) |
788 |
{ |
{ |
789 |
$ligne.=($ligne?" - ":"").$html->forme_juridique_name($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE); |
$ligne1.=($ligne1?" - ":"").$html->forme_juridique_name($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE); |
790 |
} |
} |
791 |
if ($conf->global->MAIN_INFO_CAPITAL) |
if ($conf->global->MAIN_INFO_CAPITAL) |
792 |
{ |
{ |
793 |
$ligne.=($ligne?" - ":"").$langs->trans("CapitalOf",$conf->global->MAIN_INFO_CAPITAL)." ".$langs->trans("Currency".$conf->monnaie); |
$ligne1.=($ligne1?" - ":"").$langs->trans("CapitalOf",$conf->global->MAIN_INFO_CAPITAL)." ".$langs->trans("Currency".$conf->monnaie); |
794 |
} |
} |
795 |
if ($conf->global->MAIN_INFO_SIRET) |
if ($conf->global->MAIN_INFO_SIRET) |
796 |
{ |
{ |
797 |
$ligne.=($ligne?" - ":"").$langs->transcountry("ProfId2",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_SIRET; |
$ligne1.=($ligne1?" - ":"").$langs->transcountry("ProfId2",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_SIRET; |
798 |
} |
} |
799 |
if ($conf->global->MAIN_INFO_SIREN && (! $conf->global->MAIN_INFO_SIRET || $this->emetteur->code_pays != 'FR')) |
if ($conf->global->MAIN_INFO_SIREN && (! $conf->global->MAIN_INFO_SIRET || $this->emetteur->code_pays != 'FR')) |
800 |
{ |
{ |
801 |
$ligne.=($ligne?" - ":"").$langs->transcountry("ProfId1",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_SIREN; |
$ligne1.=($ligne1?" - ":"").$langs->transcountry("ProfId1",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_SIREN; |
802 |
} |
} |
803 |
if ($conf->global->MAIN_INFO_APE) |
if ($conf->global->MAIN_INFO_APE) |
804 |
{ |
{ |
805 |
$ligne.=($ligne?" - ":"").$langs->transcountry("ProfId3",$this->emetteur->code_pays).": ".MAIN_INFO_APE; |
$ligne1.=($ligne1?" - ":"").$langs->transcountry("ProfId3",$this->emetteur->code_pays).": ".MAIN_INFO_APE; |
806 |
} |
} |
807 |
|
|
|
if ($ligne) |
|
|
{ |
|
|
$pdf->SetXY(8,-$footy); |
|
|
$pdf->MultiCell(200, 2, $ligne, 0, 'C', 0); |
|
|
} |
|
|
|
|
808 |
// Deuxieme ligne d'info réglementaires |
// Deuxieme ligne d'info réglementaires |
809 |
$ligne=""; |
$ligne2=""; |
810 |
if ($conf->global->MAIN_INFO_RCS) |
if ($conf->global->MAIN_INFO_RCS) |
811 |
{ |
{ |
812 |
$ligne.=($ligne?" - ":"").$langs->transcountry("ProfId4",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_RCS; |
$ligne2.=($ligne2?" - ":"").$langs->transcountry("ProfId4",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_RCS; |
813 |
} |
} |
814 |
if ($conf->global->MAIN_INFO_TVAINTRA != '') |
if ($conf->global->MAIN_INFO_TVAINTRA != '') |
815 |
{ |
{ |
816 |
$ligne.=($ligne?" - ":"").$langs->trans("VATIntraShort").": ".$conf->global->MAIN_INFO_TVAINTRA; |
$ligne2.=($ligne2?" - ":"").$langs->trans("VATIntraShort").": ".$conf->global->MAIN_INFO_TVAINTRA; |
817 |
} |
} |
818 |
|
|
819 |
|
$pdf->SetFont('Arial','',8); |
820 |
|
$pdf->SetDrawColor(224,224,224); |
821 |
|
|
822 |
|
// On positionne le debut du bas de page selon nbre de lignes de ce bas de page |
823 |
|
$posy=11 + ($ligne1?3:0) + ($ligne2?3:0); |
824 |
|
|
825 |
|
$pdf->SetY(-$posy); |
826 |
|
$pdf->line(10, $this->page_hauteur-$posy, 200, $this->page_hauteur-$posy); |
827 |
|
$posy--; |
828 |
|
|
829 |
if ($ligne) |
if ($ligne1) |
830 |
|
{ |
831 |
|
$pdf->SetXY(8,-$posy); |
832 |
|
$pdf->MultiCell(200, 2, $ligne1, 0, 'C', 0); |
833 |
|
} |
834 |
|
|
835 |
|
if ($ligne2) |
836 |
{ |
{ |
837 |
$footy-=3; |
$posy-=3; |
838 |
$pdf->SetXY(8,-$footy); |
$pdf->SetXY(8,-$posy); |
839 |
$pdf->MultiCell(200, 2, $ligne , 0, 'C', 0); |
$pdf->MultiCell(200, 2, $ligne2, 0, 'C', 0); |
840 |
} |
} |
841 |
|
|
842 |
$pdf->SetXY(-20,-$footy); |
$pdf->SetXY(-20,-$posy); |
843 |
$pdf->MultiCell(10, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0); |
$pdf->MultiCell(10, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0); |
844 |
} |
} |
845 |
|
|