55 |
$this->page_largeur = 210; |
$this->page_largeur = 210; |
56 |
$this->page_hauteur = 297; |
$this->page_hauteur = 297; |
57 |
$this->format = array($this->page_largeur,$this->page_hauteur); |
$this->format = array($this->page_largeur,$this->page_hauteur); |
58 |
|
$this->marge_gauche=10; |
59 |
|
$this->marge_droite=10; |
60 |
$this->marge_haute=10; |
$this->marge_haute=10; |
61 |
$this->marge_basse=10; |
$this->marge_basse=10; |
62 |
|
|
86 |
$this->tva=array(); |
$this->tva=array(); |
87 |
|
|
88 |
// Defini position des colonnes |
// Defini position des colonnes |
89 |
$this->posxdesc=11; |
$this->posxdesc=$this->marge_gauche+1; |
90 |
$this->posxtva=121; |
$this->posxtva=121; |
91 |
$this->posxup=132; |
$this->posxup=132; |
92 |
$this->posxqty=151; |
$this->posxqty=151; |
93 |
$this->posxdiscount=162; |
$this->posxdiscount=162; |
94 |
$this->postotalht=177; |
$this->postotalht=177; |
95 |
|
|
96 |
|
$this->atleastoneratenotnull=0; |
97 |
|
$this->atleastonediscount=0; |
98 |
} |
} |
99 |
|
|
100 |
|
|
128 |
{ |
{ |
129 |
$fac = new Facture($this->db,"",$id); |
$fac = new Facture($this->db,"",$id); |
130 |
$ret=$fac->fetch($id); |
$ret=$fac->fetch($id); |
131 |
|
$nblignes = sizeof($fac->lignes); |
132 |
|
|
133 |
$facref = sanitize_string($fac->ref); |
$facref = sanitize_string($fac->ref); |
134 |
$dir = $conf->facture->dir_output . "/" . $facref; |
$dir = $conf->facture->dir_output . "/" . $facref; |
157 |
$pdf->SetCreator("Dolibarr ".DOL_VERSION); |
$pdf->SetCreator("Dolibarr ".DOL_VERSION); |
158 |
$pdf->SetAuthor($user->fullname); |
$pdf->SetAuthor($user->fullname); |
159 |
|
|
160 |
$pdf->SetMargins($this->marge_haute, $this->marge_basse, 10); // Top, Bottom, Left |
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right |
161 |
$pdf->SetAutoPageBreak(1,0); |
$pdf->SetAutoPageBreak(1,0); |
162 |
|
|
163 |
|
// Positionne $this->atleastonediscount si on a au moins une remise |
164 |
|
for ($i = 0 ; $i < $nblignes ; $i++) |
165 |
|
{ |
166 |
|
if ($fac->lignes[$i]->remise_percent) |
167 |
|
{ |
168 |
|
$this->atleastonediscount++; |
169 |
|
} |
170 |
|
} |
171 |
|
|
172 |
$this->_pagehead($pdf, $fac); |
$this->_pagehead($pdf, $fac); |
173 |
|
|
174 |
$tab_top = 96; |
$tab_top = 96; |
179 |
$iniY = $tab_top + 8; |
$iniY = $tab_top + 8; |
180 |
$curY = $tab_top + 8; |
$curY = $tab_top + 8; |
181 |
$nexY = $tab_top + 8; |
$nexY = $tab_top + 8; |
|
$nblignes = sizeof($fac->lignes); |
|
182 |
|
|
183 |
// Boucle sur les lignes |
// Boucle sur les lignes |
184 |
for ($i = 0 ; $i < $nblignes ; $i++) |
for ($i = 0 ; $i < $nblignes ; $i++) |
269 |
/* |
/* |
270 |
* Mode de règlement |
* Mode de règlement |
271 |
*/ |
*/ |
272 |
if ((! defined("FACTURE_CHQ_NUMBER") || ! FACTURE_CHQ_NUMBER) && (! defined("FACTURE_RIB_NUMBER") || ! FACTURE_RIB_NUMBER)) { |
if ((! defined("FACTURE_CHQ_NUMBER") || ! FACTURE_CHQ_NUMBER) && (! defined("FACTURE_RIB_NUMBER") || ! FACTURE_RIB_NUMBER)) |
273 |
$pdf->SetXY (10, 228); |
{ |
274 |
|
$pdf->SetXY($this->marge_gauche, 228); |
275 |
$pdf->SetTextColor(200,0,0); |
$pdf->SetTextColor(200,0,0); |
276 |
$pdf->SetFont('Arial','B',8); |
$pdf->SetFont('Arial','B',8); |
277 |
$pdf->MultiCell(90, 3, $langs->trans("ErrorNoPaiementModeConfigured"),0,'L',0); |
$pdf->MultiCell(90, 3, $langs->trans("ErrorNoPaiementModeConfigured"),0,'L',0); |
289 |
$account = new Account($this->db); |
$account = new Account($this->db); |
290 |
$account->fetch(FACTURE_CHQ_NUMBER); |
$account->fetch(FACTURE_CHQ_NUMBER); |
291 |
|
|
292 |
$pdf->SetXY (10, 227); |
$pdf->SetXY($this->marge_gauche, 227); |
293 |
$pdf->SetFont('Arial','B',8); |
$pdf->SetFont('Arial','B',8); |
294 |
$pdf->MultiCell(90, 3, "Règlement par chèque à l'ordre de ".$account->proprio." envoyé à:",0,'L',0); |
$pdf->MultiCell(90, 3, "Règlement par chèque à l'ordre de ".$account->proprio." envoyé à:",0,'L',0); |
295 |
$pdf->SetXY (10, 231); |
$pdf->SetXY($this->marge_gauche, 231); |
296 |
$pdf->SetFont('Arial','',8); |
$pdf->SetFont('Arial','',8); |
297 |
$pdf->MultiCell(80, 3, $account->adresse_proprio, 0, 'L', 0); |
$pdf->MultiCell(80, 3, $account->adresse_proprio, 0, 'L', 0); |
298 |
} |
} |
308 |
$account = new Account($this->db); |
$account = new Account($this->db); |
309 |
$account->fetch(FACTURE_RIB_NUMBER); |
$account->fetch(FACTURE_RIB_NUMBER); |
310 |
|
|
311 |
$this->marges['g']=10; |
$this->marges['g']=$this->marge_gauche; |
312 |
|
|
313 |
$cury=242; |
$cury=242; |
314 |
$pdf->SetXY ($this->marges['g'], $cury); |
$pdf->SetXY ($this->marges['g'], $cury); |
354 |
* Conditions de règlements |
* Conditions de règlements |
355 |
*/ |
*/ |
356 |
$pdf->SetFont('Arial','B',10); |
$pdf->SetFont('Arial','B',10); |
357 |
$pdf->SetXY(10, 217); |
$pdf->SetXY($this->marge_gauche, 217); |
358 |
$titre = "Conditions de réglement:"; |
$titre = "Conditions de réglement:"; |
359 |
$pdf->MultiCell(80, 5, $titre, 0, 'L'); |
$pdf->MultiCell(80, 5, $titre, 0, 'L'); |
360 |
$pdf->SetFont('Arial','',10); |
$pdf->SetFont('Arial','',10); |
499 |
$pdf->SetFont('Arial','', 9); |
$pdf->SetFont('Arial','', 9); |
500 |
|
|
501 |
// Affiche la mention TVA non applicable selon option |
// Affiche la mention TVA non applicable selon option |
502 |
$pdf->SetXY (10, $tab2_top + 0); |
$pdf->SetXY($this->marge_gauche, $tab2_top + 0); |
503 |
if ($this->franchise==1) |
if ($this->franchise==1) |
504 |
{ |
{ |
505 |
$pdf->MultiCell(100, $tab2_hl, "* TVA non applicable art-293B du CGI", 0, 'L', 0); |
$pdf->MultiCell(100, $tab2_hl, "* TVA non applicable art-293B du CGI", 0, 'L', 0); |
539 |
} |
} |
540 |
|
|
541 |
// Affichage des totaux de TVA par taux (conformément à réglementation) |
// Affichage des totaux de TVA par taux (conformément à réglementation) |
|
$atleastoneratenotnull=0; |
|
542 |
$pdf->SetFillColor(248,248,248); |
$pdf->SetFillColor(248,248,248); |
543 |
foreach( $this->tva as $tvakey => $tvaval ) |
foreach( $this->tva as $tvakey => $tvaval ) |
544 |
{ |
{ |
545 |
if ($tvakey) // On affiche pas taux 0 |
if ($tvakey) // On affiche pas taux 0 |
546 |
{ |
{ |
547 |
$atleastoneratenotnull++; |
$this->atleastoneratenotnull++; |
548 |
|
|
549 |
$index++; |
$index++; |
550 |
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); |
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); |
555 |
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval * (float)$tvakey / 100 ), 0, 'R', 1); |
$pdf->MultiCell($largcol2, $tab2_hl, price($tvaval * (float)$tvakey / 100 ), 0, 'R', 1); |
556 |
} |
} |
557 |
} |
} |
558 |
if (! $atleastoneratenotnull) |
if (! $this->atleastoneratenotnull) |
559 |
{ |
{ |
560 |
$index++; |
$index++; |
561 |
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); |
$pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); |
562 |
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("TotalVAT"), 0, 'L', 1); |
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("TotalVAT"), 0, 'L', 1); |
563 |
|
|
564 |
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); |
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); |
565 |
$pdf->MultiCell($largcol2, $tab2_hl, price(0), 0, 'R', 1); |
$pdf->MultiCell($largcol2, $tab2_hl, price($fac->total_tva), 0, 'R', 1); |
566 |
} |
} |
567 |
|
|
568 |
$useborder=0; |
$useborder=0; |
619 |
$langs->load("main"); |
$langs->load("main"); |
620 |
$langs->load("bills"); |
$langs->load("bills"); |
621 |
|
|
622 |
$pdf->Rect( 10, $tab_top, 190, $tab_height); |
// Rect prend une longueur en 3eme param |
623 |
$pdf->line( 10, $tab_top+6, 200, $tab_top+6 ); |
$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); |
624 |
|
// line prend une position y en 3eme param |
625 |
|
$pdf->line($this->marge_gauche, $tab_top+6, $this->page_largeur-$this->marge_droite, $tab_top+6); |
626 |
|
|
627 |
$pdf->SetFont('Arial','',10); |
$pdf->SetFont('Arial','',10); |
628 |
|
|
642 |
$pdf->MultiCell(11,2, $langs->trans("Qty"),'','C'); |
$pdf->MultiCell(11,2, $langs->trans("Qty"),'','C'); |
643 |
|
|
644 |
$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); |
$pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); |
645 |
$pdf->SetXY ($this->posxdiscount-1, $tab_top+2); |
if ($this->atleastonediscount) |
646 |
$pdf->MultiCell(16,2, $langs->trans("Discount"),'','C'); |
{ |
647 |
|
$pdf->SetXY ($this->posxdiscount-1, $tab_top+2); |
648 |
$pdf->line($this->postotalht-1, $tab_top, $this->postotalht-1, $tab_top + $tab_height); |
$pdf->MultiCell(16,2, $langs->trans("Discount"),'','C'); |
649 |
|
} |
650 |
|
|
651 |
|
if ($this->atleastonediscount) |
652 |
|
{ |
653 |
|
$pdf->line($this->postotalht-1, $tab_top, $this->postotalht-1, $tab_top + $tab_height); |
654 |
|
} |
655 |
$pdf->SetXY ($this->postotalht-1, $tab_top+2); |
$pdf->SetXY ($this->postotalht-1, $tab_top+2); |
656 |
$pdf->MultiCell(23,2, $langs->trans("TotalHT"),'','C'); |
$pdf->MultiCell(23,2, $langs->trans("TotalHT"),'','C'); |
657 |
|
|
673 |
$pdf->SetTextColor(0,0,60); |
$pdf->SetTextColor(0,0,60); |
674 |
$pdf->SetFont('Arial','B',13); |
$pdf->SetFont('Arial','B',13); |
675 |
|
|
676 |
$posy=$this->marge_haute; // La marge Top est de 10, on commence donc a 10 |
$posy=$this->marge_haute; |
677 |
|
|
678 |
$pdf->SetXY(10,$posy); |
$pdf->SetXY($this->marge_gauche,$posy); |
679 |
|
|
680 |
// Logo |
// Logo |
681 |
if (defined("FAC_PDF_LOGO") && FAC_PDF_LOGO) |
if (defined("FAC_PDF_LOGO") && FAC_PDF_LOGO) |
682 |
{ |
{ |
683 |
if (is_readable(FAC_PDF_LOGO)) |
if (is_readable(FAC_PDF_LOGO)) |
684 |
{ |
{ |
685 |
$pdf->Image(FAC_PDF_LOGO, 10, $posy, 0, 24); |
$pdf->Image(FAC_PDF_LOGO, $this->marge_gauche, $posy, 0, 24); |
686 |
} |
} |
687 |
else |
else |
688 |
{ |
{ |
711 |
$hautcadre=40; |
$hautcadre=40; |
712 |
$pdf->SetTextColor(0,0,0); |
$pdf->SetTextColor(0,0,0); |
713 |
$pdf->SetFont('Arial','',8); |
$pdf->SetFont('Arial','',8); |
714 |
$pdf->SetXY(10,$posy-5); |
$pdf->SetXY($this->marge_gauche,$posy-5); |
715 |
$pdf->MultiCell(66,5, $langs->trans("BillFrom").":"); |
$pdf->MultiCell(66,5, $langs->trans("BillFrom").":"); |
716 |
|
|
717 |
|
|
718 |
$pdf->SetXY(10,$posy); |
$pdf->SetXY($this->marge_gauche,$posy); |
719 |
$pdf->SetFillColor(230,230,230); |
$pdf->SetFillColor(230,230,230); |
720 |
$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); |
721 |
|
|
722 |
|
|
723 |
$pdf->SetXY(10,$posy+3); |
$pdf->SetXY($this->marge_gauche,$posy+3); |
724 |
|
|
725 |
// Nom emetteur |
// Nom emetteur |
726 |
$pdf->SetTextColor(0,0,60); |
$pdf->SetTextColor(0,0,60); |
758 |
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Web").": ".FAC_PDF_WWW; |
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Web").": ".FAC_PDF_WWW; |
759 |
} |
} |
760 |
$pdf->SetFont('Arial','',9); |
$pdf->SetFont('Arial','',9); |
761 |
$pdf->SetXY(12,$posy+8); |
$pdf->SetXY($this->marge_gauche+2,$posy+8); |
762 |
$pdf->MultiCell(80,4, $carac_emetteur); |
$pdf->MultiCell(80,4, $carac_emetteur); |
763 |
|
|
764 |
// Client destinataire |
// Client destinataire |
846 |
$posy=$this->marge_basse + 1 + ($ligne1?3:0) + ($ligne2?3:0); |
$posy=$this->marge_basse + 1 + ($ligne1?3:0) + ($ligne2?3:0); |
847 |
|
|
848 |
$pdf->SetY(-$posy); |
$pdf->SetY(-$posy); |
849 |
$pdf->line(10, $this->page_hauteur-$posy, 200, $this->page_hauteur-$posy); |
$pdf->line($this->marge_gauche, $this->page_hauteur-$posy, 200, $this->page_hauteur-$posy); |
850 |
$posy--; |
$posy--; |
851 |
|
|
852 |
if ($ligne1) |
if ($ligne1) |
853 |
{ |
{ |
854 |
$pdf->SetXY(8,-$posy); |
$pdf->SetXY($this->marge_gauche,-$posy); |
855 |
$pdf->MultiCell(200, 2, $ligne1, 0, 'C', 0); |
$pdf->MultiCell(200, 2, $ligne1, 0, 'C', 0); |
856 |
} |
} |
857 |
|
|
858 |
if ($ligne2) |
if ($ligne2) |
859 |
{ |
{ |
860 |
$posy-=3; |
$posy-=3; |
861 |
$pdf->SetXY(8,-$posy); |
$pdf->SetXY($this->marge_gauche,-$posy); |
862 |
$pdf->MultiCell(200, 2, $ligne2, 0, 'C', 0); |
$pdf->MultiCell(200, 2, $ligne2, 0, 'C', 0); |
863 |
} |
} |
864 |
|
|