Ajout de la remise unitaire dans lignes produits.

Cartouche émetteur grisé pour un look plus "pro".
This commit is contained in:
Laurent Destailleur 2004-05-15 15:47:01 +00:00
parent 50e19ba363
commit 8b4b660315

View File

@ -34,7 +34,6 @@ Class pdf_crabe {
global $user; global $user;
$fac = new Facture($this->db,"",$facid); $fac = new Facture($this->db,"",$facid);
$fac->fetch($facid); $fac->fetch($facid);
if (defined("FAC_OUTPUTDIR")) if (defined("FAC_OUTPUTDIR"))
{ {
@ -46,12 +45,13 @@ Class pdf_crabe {
umask(0); umask(0);
if (! mkdir($dir, 0755)) if (! mkdir($dir, 0755))
{ {
print "Impossible de créer $dir !"; print "Erreur: Impossible de créer $dir !";
} }
} }
if (file_exists($dir)) if (file_exists($dir))
{ {
// Initialisation facture vierge
$pdf=new FPDF('P','mm','A4'); $pdf=new FPDF('P','mm','A4');
$pdf->Open(); $pdf->Open();
$pdf->AddPage(); $pdf->AddPage();
@ -66,14 +66,8 @@ Class pdf_crabe {
$tab_top = 96; $tab_top = 96;
$tab_height = 110; $tab_height = 110;
/*
*
*/
$pdf->SetFillColor(220,220,220); $pdf->SetFillColor(220,220,220);
$pdf->SetFont('Arial','', 9); $pdf->SetFont('Arial','', 9);
$pdf->SetXY (10, $tab_top + 10 ); $pdf->SetXY (10, $tab_top + 10 );
$iniY = $pdf->GetY(); $iniY = $pdf->GetY();
@ -81,28 +75,46 @@ Class pdf_crabe {
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$nblignes = sizeof($fac->lignes); $nblignes = sizeof($fac->lignes);
// Boucle sur les lignes de factures
for ($i = 0 ; $i < $nblignes ; $i++) for ($i = 0 ; $i < $nblignes ; $i++)
{ {
$curY = $nexY; $curY = $nexY;
// Description produit
$codeproduitservice="";
$pdf->SetXY (11, $curY ); $pdf->SetXY (11, $curY );
$pdf->MultiCell(118, 5, $fac->lignes[$i]->desc, 0, 'J'); if (defined("FACTURE_CODEPRODUITSERVICE") && FACTURE_CODEPRODUITSERVICE) {
// Affiche code produit
$codeproduitservice=" (".$fac->lignes[$i]->produit_id.")";
}
$pdf->MultiCell(118, 5, $fac->lignes[$i]->desc."$codeproduitservice", 0, 'J');
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
$pdf->SetXY (133, $curY); // TVA
$pdf->SetXY (121, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->tva_taux, 0, 'C'); $pdf->MultiCell(10, 5, $fac->lignes[$i]->tva_taux, 0, 'C');
$pdf->SetXY (145, $curY); // Prix unitaire HT
$pdf->SetXY (133, $curY);
$pdf->MultiCell(16, 5, price($fac->lignes[$i]->price), 0, 'R', 0); $pdf->MultiCell(16, 5, price($fac->lignes[$i]->price), 0, 'R', 0);
$pdf->SetXY (164, $curY); // Quantité
$pdf->MultiCell(10, 5, $fac->lignes[$i]->qty, 0, 'C'); $pdf->SetXY (151, $curY);
$pdf->MultiCell(10, 5, $fac->lignes[$i]->qty, 0, 'R');
// Remise sur ligne
$pdf->SetXY (161, $curY);
if ($fac->lignes[$i]->remise_percent) {
$pdf->MultiCell(10, 5, $fac->lignes[$i]->remise_percent."%", 0, 'C');
}
// Total HT
$pdf->SetXY (173, $curY); $pdf->SetXY (173, $curY);
$total = price($fac->lignes[$i]->price * $fac->lignes[$i]->qty); $total = price($fac->lignes[$i]->price * $fac->lignes[$i]->qty);
$pdf->MultiCell(26, 5, $total, 0, 'R', 0); $pdf->MultiCell(26, 5, $total, 0, 'R', 0);
if ($nexY > 200 && $i < $nblignes - 1) if ($nexY > 200 && $i < $nblignes - 1)
{ {
$this->_tableau($pdf, $tab_top, $tab_height, $nexY); $this->_tableau($pdf, $tab_top, $tab_height, $nexY);
@ -120,6 +132,9 @@ Class pdf_crabe {
$this->_tableau_compl($pdf, $fac); $this->_tableau_compl($pdf, $fac);
/*
* Mode de règlement
*/
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)) {
$pdf->SetXY (10, 228); $pdf->SetXY (10, 228);
$pdf->SetTextColor(200,0,0); $pdf->SetTextColor(200,0,0);
@ -172,20 +187,19 @@ Class pdf_crabe {
} }
/* /*
* * Conditions de règlements
*
*/ */
$pdf->SetFont('Arial','U',10); $pdf->SetFont('Arial','U',10);
$pdf->SetXY(10, 220); $pdf->SetXY(10, 220);
$titre = "Conditions de réglement : ".$fac->cond_reglement_facture; $titre = "Conditions de réglement : ".$fac->cond_reglement_facture;
$pdf->MultiCell(190, 5, $titre, 0, 'J'); $pdf->MultiCell(190, 5, $titre, 0, 'J');
$pdf->Close(); $pdf->Close();
$pdf->Output($file); $pdf->Output($file);
return 1; return 1; // Pas d'erreur
} }
else else
{ {
@ -196,7 +210,10 @@ Class pdf_crabe {
{ {
print "Erreur: FAC_OUTPUTDIR non défini !"; print "Erreur: FAC_OUTPUTDIR non défini !";
} }
return 0; // Erreur par defaut
} }
/* /*
* *
* *
@ -234,16 +251,6 @@ Class pdf_crabe {
$tab2_height = $tab2_hl * 4; $tab2_height = $tab2_hl * 4;
$pdf->SetFont('Arial','', 9); $pdf->SetFont('Arial','', 9);
// $pdf->Rect(132, $tab2_top, 68, $tab2_height);
// $pdf->line(174, $tab2_top, 174, $tab2_top + $tab2_height);
// $pdf->line(132, $tab2_top + $tab2_height - 21, 200, $tab2_top + $tab2_height - 21 );
// $pdf->line(132, $tab2_top + $tab2_height - 14, 200, $tab2_top + $tab2_height - 14 );
// $pdf->line(132, $tab2_top + $tab2_height - 7, 200, $tab2_top + $tab2_height - 7 );
$pdf->SetXY (132, $tab2_top + 0);
$pdf->MultiCell(42, $tab2_hl, "Total HT", 0, 'R', 0);
// Affiche la mention TVA non applicable selon option // Affiche la mention TVA non applicable selon option
$pdf->SetXY (10, $tab2_top + 0); $pdf->SetXY (10, $tab2_top + 0);
if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise') { if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise') {
@ -263,16 +270,20 @@ Class pdf_crabe {
} }
} }
// Tableau complémentaire
$pdf->SetXY (132, $tab2_top + 0);
$pdf->MultiCell(42, $tab2_hl, "Total HT", 0, 'R', 0);
$pdf->SetXY (174, $tab2_top + 0); $pdf->SetXY (174, $tab2_top + 0);
$pdf->MultiCell(26, $tab2_hl, price($fac->total_ht + $fac->remise), 0, 'R', 0); $pdf->MultiCell(26, $tab2_hl, price($fac->total_ht + $fac->remise), 0, 'R', 0);
if ($fac->remise > 0) if ($fac->remise > 0)
{ {
$pdf->SetXY (132, $tab2_top + $tab2_hl); $pdf->SetXY (132, $tab2_top + $tab2_hl);
$pdf->MultiCell(42, $tab2_hl, "Remise", 0, 'R', 0); $pdf->MultiCell(42, $tab2_hl, "Remise globale", 0, 'R', 0);
$pdf->SetXY (174, $tab2_top + $tab2_hl); $pdf->SetXY (174, $tab2_top + $tab2_hl);
$pdf->MultiCell(26, $tab2_hl, price($fac->remise), 0, 'R', 0); $pdf->MultiCell(26, $tab2_hl, "-".$fac->remise_percent."%", 0, 'R', 0);
$pdf->SetXY (132, $tab2_top + $tab2_hl * 2); $pdf->SetXY (132, $tab2_top + $tab2_hl * 2);
$pdf->MultiCell(42, $tab2_hl, "Total HT après remise", 0, 'R', 0); $pdf->MultiCell(42, $tab2_hl, "Total HT après remise", 0, 'R', 0);
@ -317,7 +328,7 @@ Class pdf_crabe {
} }
} }
/* /*
* * Grille des lignes de factures
*/ */
Function _tableau(&$pdf, $tab_top, $tab_height, $nexY) Function _tableau(&$pdf, $tab_top, $tab_height, $nexY)
{ {
@ -325,16 +336,19 @@ Class pdf_crabe {
$pdf->Text(11,$tab_top + 5,'Désignation'); $pdf->Text(11,$tab_top + 5,'Désignation');
$pdf->line(132, $tab_top, 132, $tab_top + $tab_height); $pdf->line(120, $tab_top, 120, $tab_top + $tab_height);
$pdf->Text(134,$tab_top + 5,'TVA'); $pdf->Text(122, $tab_top + 5,'TVA');
$pdf->line(144, $tab_top, 144, $tab_top + $tab_height); $pdf->line(132, $tab_top, 132, $tab_top + $tab_height);
$pdf->Text(147,$tab_top + 5,'P.U. HT'); $pdf->Text(135, $tab_top + 5,'P.U. HT');
$pdf->line(150, $tab_top, 150, $tab_top + $tab_height);
$pdf->Text(153, $tab_top + 5,'Qté');
$pdf->line(162, $tab_top, 162, $tab_top + $tab_height); $pdf->line(162, $tab_top, 162, $tab_top + $tab_height);
$pdf->Text(165,$tab_top + 5,'Qté'); $pdf->Text(163, $tab_top + 5,'Remise');
$pdf->line(174, $tab_top, 174, $tab_top + $tab_height); $pdf->line(176, $tab_top, 176, $tab_top + $tab_height);
$pdf->Text(185, $tab_top + 5,'Total HT'); $pdf->Text(185, $tab_top + 5,'Total HT');
$pdf->Rect( 10, $tab_top, 190, $tab_height); $pdf->Rect( 10, $tab_top, 190, $tab_height);
@ -374,6 +388,12 @@ Class pdf_crabe {
$pdf->SetXY(10,$posy-5); $pdf->SetXY(10,$posy-5);
$pdf->MultiCell(66,5, "Emetteur:"); $pdf->MultiCell(66,5, "Emetteur:");
$pdf->SetXY(10,$posy);
$pdf->SetFillColor(230,230,230);
$pdf->MultiCell(82, 34, "", 0, 'R', 1);
$pdf->SetXY(10,$posy+4); $pdf->SetXY(10,$posy+4);
if (defined("FAC_PDF_INTITULE2")) if (defined("FAC_PDF_INTITULE2"))