Fix: Gestion des modeles de propale et factures sur plusieurs pages.

This commit is contained in:
Laurent Destailleur 2005-11-28 00:02:08 +00:00
parent 71fb60eff3
commit 0994ea85e7
2 changed files with 186 additions and 120 deletions

View File

@ -175,11 +175,11 @@ class pdf_crabe extends ModelePDFFactures
$this->_pagehead($pdf, $fac);
$tab_top = 96;
$pagenb = 1;
$tab_top = 90;
$tab_top_newpage = 50;
$tab_height = 110;
$pdf->SetFont('Arial','', 9);
$iniY = $tab_top + 8;
$curY = $tab_top + 8;
$nexY = $tab_top + 8;
@ -212,6 +212,8 @@ class pdf_crabe extends ModelePDFFactures
$libelleproduitservice.="\n(".$langs->trans("From")." ".dolibarr_print_date($fac->lignes[$i]->date_start)." ".$langs->trans("to")." ".dolibarr_print_date($fac->lignes[$i]->date_end).")";
}
$pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page
$pdf->SetXY ($this->posxdesc-1, $curY);
$pdf->MultiCell(108, 4, $libelleproduitservice, 0, 'J');
@ -249,22 +251,37 @@ class pdf_crabe extends ModelePDFFactures
$nexY+=2; // Passe espace entre les lignes
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 + 20, $nexY);
$this->_pagefoot($pdf);
// Nouvelle page
$pdf->AddPage();
$nexY = $iniY;
$this->_pagehead($pdf, $fac);
$pagenb++;
$this->_pagehead($pdf, $fac, 0);
$nexY = $tab_top_newpage + 8;
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 10);
}
}
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
// Affiche cadre tableau
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
$bottomlasttab=$tab_top + $tab_height + 1;
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $tab_height, $nexY);
$bottomlasttab=$tab_top_newpage + $tab_height + 1;
}
$deja_regle = $fac->getSommePaiement();
$posy=$this->_tableau_tot($pdf, $fac, $deja_regle);
$posy=$this->_tableau_tot($pdf, $fac, $deja_regle, $bottomlasttab);
if ($deja_regle) {
$this->_tableau_versements($pdf, $fac, $posy);
@ -406,7 +423,7 @@ class pdf_crabe extends ModelePDFFactures
$langs->load("bills");
$tab3_posx = 120;
$tab3_top = $posy + 6;
$tab3_top = $posy + 8;
$tab3_width = 80;
$tab3_height = 4;
@ -491,13 +508,13 @@ class pdf_crabe extends ModelePDFFactures
* \param deja_regle Montant deja regle
* \return y Position pour suite
*/
function _tableau_tot(&$pdf, $fac, $deja_regle)
function _tableau_tot(&$pdf, $fac, $deja_regle, $posy)
{
global $langs;
$langs->load("main");
$langs->load("bills");
$tab2_top = 207;
$tab2_top = $posy;
$tab2_hl = 5;
$tab2_height = $tab2_hl * 4;
$pdf->SetFont('Arial','', 9);
@ -619,10 +636,18 @@ class pdf_crabe extends ModelePDFFactures
*/
function _tableau(&$pdf, $tab_top, $tab_height, $nexY)
{
global $langs;
global $langs,$conf;
$langs->load("main");
$langs->load("bills");
// Montants exprimés en (en tab_top - 1)
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8);
$titre = $langs->trans("AmountInCurrency",$langs->trans("Currency".$conf->monnaie));
$pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre);
$pdf->SetDrawColor(128,128,128);
// Rect prend une longueur en 3eme param
$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
// line prend une position y en 3eme param
@ -654,7 +679,7 @@ class pdf_crabe extends ModelePDFFactures
if ($this->atleastonediscount)
{
$pdf->line($this->postotalht-1, $tab_top, $this->postotalht-1, $tab_top + $tab_height);
$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
}
$pdf->SetXY ($this->postotalht-1, $tab_top+2);
$pdf->MultiCell(23,2, $langs->trans("TotalHT"),'','C');
@ -662,11 +687,12 @@ class pdf_crabe extends ModelePDFFactures
}
/*
* \brief Affiche en-tête facture
* \param pdf objet PDF
* \param fac objet facture
* \brief Affiche en-tête facture
* \param pdf Objet PDF
* \param fac Objet facture
* \param showadress 0=non, 1=oui
*/
function _pagehead(&$pdf, $fac)
function _pagehead(&$pdf, $fac, $showadress=1)
{
global $langs,$conf,$mysoc;
@ -709,86 +735,85 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 4, $langs->trans("Bill")." ".$fac->ref, '' , 'R');
$pdf->SetFont('Arial','',12);
$pdf->SetXY(100,$posy+6);
$posy+=6;
$pdf->SetXY(100,$posy);
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 4, $langs->trans("Date")." : " . dolibarr_print_date($fac->date,"%d %b %Y"), '', 'R');
// Emetteur
$posy=42;
$hautcadre=40;
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8);
$pdf->SetXY($this->marge_gauche,$posy-5);
$pdf->MultiCell(66,5, $langs->trans("BillFrom").":");
$pdf->SetXY($this->marge_gauche,$posy);
$pdf->SetFillColor(230,230,230);
$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
$pdf->SetXY($this->marge_gauche+2,$posy+3);
// Nom emetteur
$pdf->SetTextColor(0,0,60);
$pdf->SetFont('Arial','B',11);
if (defined("FAC_PDF_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) $pdf->MultiCell(80, 4, FAC_PDF_SOCIETE_NOM, 0, 'L');
else $pdf->MultiCell(80, 4, $mysoc->nom, 0, 'L');
// Caractéristiques emetteur
$carac_emetteur = '';
if (defined("FAC_PDF_ADRESSE") && FAC_PDF_ADRESSE) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).FAC_PDF_ADRESSE;
else {
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$mysoc->adresse;
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$mysoc->cp.' '.$mysoc->ville;
if ($showadress)
{
// Emetteur
$posy=42;
$hautcadre=40;
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8);
$pdf->SetXY($this->marge_gauche,$posy-5);
$pdf->MultiCell(66,5, $langs->trans("BillFrom").":");
$pdf->SetXY($this->marge_gauche,$posy);
$pdf->SetFillColor(230,230,230);
$pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1);
$pdf->SetXY($this->marge_gauche+2,$posy+3);
// Nom emetteur
$pdf->SetTextColor(0,0,60);
$pdf->SetFont('Arial','B',11);
if (defined("FAC_PDF_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) $pdf->MultiCell(80, 4, FAC_PDF_SOCIETE_NOM, 0, 'L');
else $pdf->MultiCell(80, 4, $mysoc->nom, 0, 'L');
// Caractéristiques emetteur
$carac_emetteur = '';
if (defined("FAC_PDF_ADRESSE") && FAC_PDF_ADRESSE) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).FAC_PDF_ADRESSE;
else {
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$mysoc->adresse;
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$mysoc->cp.' '.$mysoc->ville;
}
$carac_emetteur .= "\n";
// Tel
if (defined("FAC_PDF_TEL") && FAC_PDF_TEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Phone").": ".FAC_PDF_TEL;
elseif ($mysoc->tel) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Phone").": ".$mysoc->tel;
// Fax
if (defined("FAC_PDF_FAX") && FAC_PDF_FAX) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Fax").": ".FAC_PDF_FAX;
elseif ($mysoc->fax) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Fax").": ".$mysoc->fax;
// EMail
if (defined("FAC_PDF_MEL") && FAC_PDF_MEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Email").": ".FAC_PDF_MEL;
elseif ($mysoc->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Email").": ".$mysoc->email;
// Web
if (defined("FAC_PDF_WWW") && FAC_PDF_WWW) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Web").": ".FAC_PDF_WWW;
elseif ($mysoc->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Web").": ".$mysoc->url;
$pdf->SetFont('Arial','',9);
$pdf->SetXY($this->marge_gauche+2,$posy+8);
$pdf->MultiCell(80,4, $carac_emetteur);
// Client destinataire
$posy=42;
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8);
$pdf->SetXY(102,$posy-5);
$pdf->MultiCell(80,5, $langs->trans("BillTo").":");
$fac->fetch_client();
// Cadre client destinataire
$pdf->rect(100, $posy, 100, $hautcadre);
// Nom client
$pdf->SetXY(102,$posy+3);
$pdf->SetFont('Arial','B',11);
$pdf->MultiCell(106,4, $fac->client->nom, 0, 'L');
// Caractéristiques client
$carac_client=$fac->client->adresse;
$carac_client.="\n".$fac->client->cp . " " . $fac->client->ville."\n";
if ($fac->client->tva_intra) $carac_client.="\n".$langs->trans("VATIntraShort").': '.$fac->client->tva_intra;
$pdf->SetFont('Arial','',9);
$pdf->SetXY(102,$posy+8);
$pdf->MultiCell(86,4, $carac_client);
}
$carac_emetteur .= "\n";
// Tel
if (defined("FAC_PDF_TEL") && FAC_PDF_TEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Phone").": ".FAC_PDF_TEL;
elseif ($mysoc->tel) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Phone").": ".$mysoc->tel;
// Fax
if (defined("FAC_PDF_FAX") && FAC_PDF_FAX) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Fax").": ".FAC_PDF_FAX;
elseif ($mysoc->fax) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Fax").": ".$mysoc->fax;
// EMail
if (defined("FAC_PDF_MEL") && FAC_PDF_MEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Email").": ".FAC_PDF_MEL;
elseif ($mysoc->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Email").": ".$mysoc->email;
// Web
if (defined("FAC_PDF_WWW") && FAC_PDF_WWW) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Web").": ".FAC_PDF_WWW;
elseif ($mysoc->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Web").": ".$mysoc->url;
$pdf->SetFont('Arial','',9);
$pdf->SetXY($this->marge_gauche+2,$posy+8);
$pdf->MultiCell(80,4, $carac_emetteur);
// Client destinataire
$posy=42;
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8);
$pdf->SetXY(102,$posy-5);
$pdf->MultiCell(80,5, $langs->trans("BillTo").":");
$fac->fetch_client();
// Cadre client destinataire
$pdf->rect(100, $posy, 100, $hautcadre);
// Nom client
$pdf->SetXY(102,$posy+3);
$pdf->SetFont('Arial','B',11);
$pdf->MultiCell(106,4, $fac->client->nom, 0, 'L');
// Caractéristiques client
$carac_client=$fac->client->adresse;
$carac_client.="\n".$fac->client->cp . " " . $fac->client->ville."\n";
if ($fac->client->tva_intra) $carac_client.="\n".$langs->trans("VATIntraShort").': '.$fac->client->tva_intra;
$pdf->SetFont('Arial','',9);
$pdf->SetXY(102,$posy+8);
$pdf->MultiCell(86,4, $carac_client);
// Montants exprimés en
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',10);
$titre = $langs->trans("AmountInCurrency",$langs->trans("Currency".$conf->monnaie));
$pdf->Text(200 - $pdf->GetStringWidth($titre), 94, $titre);
}
/*

View File

@ -94,6 +94,7 @@ class pdf_propale_azur extends ModelePDFPropales
$this->posxdiscount=162;
$this->postotalht=177;
$this->atleastoneratenotnull=0;
$this->atleastonediscount=0;
}
@ -170,13 +171,22 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right
$pdf->SetAutoPageBreak(1,0);
// Positionne $this->atleastonediscount si on a au moins une remise
for ($i = 0 ; $i < $nblignes ; $i++)
{
if ($prop->lignes[$i]->remise_percent)
{
$this->atleastonediscount++;
}
}
$this->_pagehead($pdf, $prop);
$tab_top = 96;
$pagenb = 1;
$tab_top = 90;
$tab_top_newpage = 50;
$tab_height = 110;
$pdf->SetFont('Arial','', 9);
$iniY = $tab_top + 8;
$curY = $tab_top + 8;
$nexY = $tab_top + 8;
@ -211,6 +221,8 @@ class pdf_propale_azur extends ModelePDFPropales
$libelleproduitservice.="\n(".$langs->trans("From")." ".dolibarr_print_date($prop->lignes[$i]->date_start)." ".$langs->trans("to")." ".dolibarr_print_date($prop->lignes[$i]->date_end).")";
}
$pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page
$pdf->SetXY ($this->posxdesc-1, $curY);
$pdf->MultiCell(108, 4, $libelleproduitservice, 0, 'J');
@ -248,20 +260,41 @@ class pdf_propale_azur extends ModelePDFPropales
$nexY+=2; // Passe espace entre les lignes
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 + 20, $nexY);
$this->_pagefoot($pdf);
// Nouvelle page
$pdf->AddPage();
$nexY = $iniY;
$this->_pagehead($pdf, $prop);
$pagenb++;
$this->_pagehead($pdf, $prop, 0);
$nexY = $tab_top_newpage + 8;
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','', 10);
}
}
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
// Affiche cadre tableau
if ($pagenb == 1)
{
$this->_tableau($pdf, $tab_top, $tab_height, $nexY);
$bottomlasttab=$tab_top + $tab_height + 1;
}
else
{
$this->_tableau($pdf, $tab_top_newpage, $tab_height, $nexY);
$bottomlasttab=$tab_top_newpage + $tab_height + 1;
}
$posy=$this->_tableau_tot($pdf, $prop, "");
$deja_regle = "";
$posy=$this->_tableau_tot($pdf, $prop, $deja_regle, $bottomlasttab);
if ($deja_regle) {
$this->_tableau_versements($pdf, $fac, $posy);
}
/*
* Mode de règlement
@ -399,13 +432,13 @@ class pdf_propale_azur extends ModelePDFPropales
* \param deja_regle Montant deja regle
* \return y Position pour suite
*/
function _tableau_tot(&$pdf, $prop, $deja_regle)
function _tableau_tot(&$pdf, $prop, $deja_regle, $posy)
{
global $langs;
$langs->load("main");
$langs->load("bills");
$tab2_top = 207;
$tab2_top = $posy;
$tab2_hl = 5;
$tab2_height = $tab2_hl * 4;
$pdf->SetFont('Arial','', 9);
@ -522,10 +555,18 @@ class pdf_propale_azur extends ModelePDFPropales
*/
function _tableau(&$pdf, $tab_top, $tab_height, $nexY)
{
global $langs;
global $langs,$conf;
$langs->load("main");
$langs->load("bills");
// Montants exprimés en (en tab_top - 1)
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8);
$titre = $langs->trans("AmountInCurrency",$langs->trans("Currency".$conf->monnaie));
$pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre);
$pdf->SetDrawColor(128,128,128);
// Rect prend une longueur en 3eme param
$pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height);
// line prend une position y en 3eme param
@ -557,7 +598,7 @@ class pdf_propale_azur extends ModelePDFPropales
if ($this->atleastonediscount)
{
$pdf->line($this->postotalht-1, $tab_top, $this->postotalht-1, $tab_top + $tab_height);
$pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height);
}
$pdf->SetXY ($this->postotalht-1, $tab_top+2);
$pdf->MultiCell(23,2, $langs->trans("TotalHT"),'','C');
@ -565,11 +606,12 @@ class pdf_propale_azur extends ModelePDFPropales
}
/*
* \brief Affiche en-tête propale
* \param pdf objet PDF
* \param fac objet propale
*/
function _pagehead(&$pdf, $prop)
* \brief Affiche en-tête propale
* \param pdf objet PDF
* \param fac objet propale
* \param showadress 0=non, 1=oui
*/
function _pagehead(&$pdf, $prop, $showadress=1)
{
global $langs,$conf,$mysoc;
@ -612,10 +654,14 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 4, $langs->trans("Proposal")." ".$prop->ref, '' , 'R');
$pdf->SetFont('Arial','',12);
$pdf->SetXY(100,$posy+6);
$posy+=6;
$pdf->SetXY(100,$posy);
$pdf->SetTextColor(0,0,60);
$pdf->MultiCell(100, 4, $langs->trans("Date")." : " . dolibarr_print_date($prop->date,"%d %b %Y"), '', 'R');
if ($showadress)
{
// Emetteur
$posy=42;
$hautcadre=40;
@ -686,12 +732,7 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->SetFont('Arial','',9);
$pdf->SetXY(102,$posy+8);
$pdf->MultiCell(86,4, $carac_client);
// Montants exprimés en
$pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',10);
$titre = $langs->trans("AmountInCurrency",$langs->trans("Currency".$conf->monnaie));
$pdf->Text(200 - $pdf->GetStringWidth($titre), 94, $titre);
}
}