Fix: Amélioration nb long sur modeles pdf

This commit is contained in:
Laurent Destailleur 2007-12-31 03:18:12 +00:00
parent 89d4abc264
commit 5910c05845
2 changed files with 88 additions and 83 deletions

View File

@ -23,7 +23,7 @@
/** /**
\file htdocs/includes/modules/facture/pdf_crabe.modules.php \file htdocs/includes/modules/facture/pdf_crabe.modules.php
\ingroup facture \ingroup facture
\brief Fichier de la classe permettant de générer les factures au modèle Crabe \brief Fichier de la classe permettant de g<EFBFBD>n<EFBFBD>rer les factures au mod<EFBFBD>le Crabe
\author Laurent Destailleur \author Laurent Destailleur
\version $Revision$ \version $Revision$
*/ */
@ -34,7 +34,7 @@ require_once(DOL_DOCUMENT_ROOT."/product.class.php");
/** /**
\class pdf_crabe \class pdf_crabe
\brief Classe permettant de générer les factures au modèle Crabe \brief Classe permettant de g<EFBFBD>n<EFBFBD>rer les factures au mod<EFBFBD>le Crabe
*/ */
class pdf_crabe extends ModelePDFFactures class pdf_crabe extends ModelePDFFactures
@ -44,7 +44,7 @@ class pdf_crabe extends ModelePDFFactures
/** /**
\brief Constructeur \brief Constructeur
\param db Handler accès base de donnée \param db Handler acc<EFBFBD>s base de donn<EFBFBD>e
*/ */
function pdf_crabe($db) function pdf_crabe($db)
{ {
@ -69,27 +69,27 @@ class pdf_crabe extends ModelePDFFactures
$this->option_logo = 1; // Affiche logo $this->option_logo = 1; // Affiche logo
$this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION
$this->option_modereg = 1; // Affiche mode règlement $this->option_modereg = 1; // Affiche mode règlement
$this->option_condreg = 1; // Affiche conditions règlement $this->option_condreg = 1; // Affiche conditions règlement
$this->option_codeproduitservice = 1; // Affiche code produit-service $this->option_codeproduitservice = 1; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues $this->option_multilang = 1; // Dispo en plusieurs langues
$this->option_escompte = 1; // Affiche si il y a eu escompte $this->option_escompte = 1; // Affiche si il y a eu escompte
$this->option_credit_note = 1; // Gère les avoirs $this->option_credit_note = 1; // Gère les avoirs
if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise') if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise')
$this->franchise=1; $this->franchise=1;
// Recupere emmetteur // Recupere emmetteur
$this->emetteur=$mysoc; $this->emetteur=$mysoc;
if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'était pas défini if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'était pas défini
// Defini position des colonnes // Defini position des colonnes
$this->posxdesc=$this->marge_gauche+1; $this->posxdesc=$this->marge_gauche+1;
$this->posxtva=121; $this->posxtva=116;
$this->posxup=132; $this->posxup=126;
$this->posxqty=151; $this->posxqty=145;
$this->posxdiscount=162; $this->posxdiscount=162;
$this->postotalht=177; $this->postotalht=174;
$this->tva=array(); $this->tva=array();
$this->atleastoneratenotnull=0; $this->atleastoneratenotnull=0;
@ -98,8 +98,8 @@ class pdf_crabe extends ModelePDFFactures
/** /**
* \brief Fonction générant la facture sur le disque * \brief Fonction générant la facture sur le disque
* \param fac Objet facture à générer (ou id si ancienne methode) * \param fac Objet facture à générer (ou id si ancienne methode)
* \return int 1=ok, 0=ko * \return int 1=ok, 0=ko
*/ */
function write_file($fac,$outputlangs='') function write_file($fac,$outputlangs='')
@ -117,7 +117,7 @@ class pdf_crabe extends ModelePDFFactures
if ($conf->facture->dir_output) if ($conf->facture->dir_output)
{ {
// Définition de l'objet $fac (pour compatibilite ascendante) // D<EFBFBD>finition de l'objet $fac (pour compatibilite ascendante)
if (! is_object($fac)) if (! is_object($fac))
{ {
$id = $fac; $id = $fac;
@ -128,7 +128,7 @@ class pdf_crabe extends ModelePDFFactures
$deja_regle = $fac->getSommePaiement(); $deja_regle = $fac->getSommePaiement();
$amount_credit_not_included = $fac->getSommeCreditNote(); $amount_credit_not_included = $fac->getSommeCreditNote();
// Définition de $dir et $file // D<EFBFBD>finition de $dir et $file
if ($fac->specimen) if ($fac->specimen)
{ {
$dir = $conf->facture->dir_output; $dir = $conf->facture->dir_output;
@ -160,7 +160,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf=new FPDI_Protection('P','mm',$this->format); $pdf=new FPDI_Protection('P','mm',$this->format);
$pdfrights = array('print'); // Ne permet que l'impression du document $pdfrights = array('print'); // Ne permet que l'impression du document
$pdfuserpass = ''; // Mot de passe pour l'utilisateur final $pdfuserpass = ''; // Mot de passe pour l'utilisateur final
$pdfownerpass = NULL; // Mot de passe du propriétaire, créé aléatoirement si pas défini $pdfownerpass = NULL; // Mot de passe du propri<EFBFBD>taire, cr<63><72> al<61>atoirement si pas d<>fini
$pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass); $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass);
} }
else else
@ -204,7 +204,7 @@ class pdf_crabe extends ModelePDFFactures
{ {
$tab_top = 88; $tab_top = 88;
$pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page $pdf->SetFont('Arial','', 9); // Dans boucle pour g<EFBFBD>rer multi-page
$pdf->SetXY ($this->posxdesc-1, $tab_top); $pdf->SetXY ($this->posxdesc-1, $tab_top);
$pdf->MultiCell(190, 3, $fac->note_public, 0, 'J'); $pdf->MultiCell(190, 3, $fac->note_public, 0, 'J');
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
@ -251,12 +251,12 @@ class pdf_crabe extends ModelePDFFactures
} }
else else
{ {
// On vérifie si les lignes personnalisées sont formatées avec fckeditor // On v<EFBFBD>rifie si les lignes personnalis<69>es sont format<61>es avec fckeditor
$libelleproduitservice.=dol_htmlentities($fac->lignes[$i]->desc); $libelleproduitservice.=dol_htmlentities($fac->lignes[$i]->desc);
} }
} }
} }
// Si ligne associée à un code produit // Si ligne associ<EFBFBD>e <20> un code produit
if ($fac->lignes[$i]->produit_id) if ($fac->lignes[$i]->produit_id)
{ {
$prodser = new Product($this->db); $prodser = new Product($this->db);
@ -281,40 +281,41 @@ class pdf_crabe extends ModelePDFFactures
if ($fac->lignes[$i]->date_start && $fac->lignes[$i]->date_end) if ($fac->lignes[$i]->date_start && $fac->lignes[$i]->date_end)
{ {
// Affichage durée si il y en a une // Affichage duree si il y en a une
$libelleproduitservice.=dol_htmlentities("\n(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($fac->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($fac->lignes[$i]->date_end).")"); $libelleproduitservice.=dol_htmlentities("\n(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($fac->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($fac->lignes[$i]->date_end).")");
} }
$pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page $pdf->SetFont('Arial','', 9); // Dans boucle pour gerer multi-page
$pdf->writeHTMLCell(112, 4, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1); // Desc
$pdf->writeHTMLCell($this->posxtva-$this->posxdesc-1, 4, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1);
$pdf->SetFont('Arial','', 9); // On repositionne la police par défaut $pdf->SetFont('Arial','', 9); // On repositionne la police par defaut
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
// TVA // TVA
$pdf->SetXY ($this->posxtva, $curY); $pdf->SetXY ($this->posxtva, $curY);
$pdf->MultiCell(10, 4, ($fac->lignes[$i]->tva_tx < 0 ? '*':'').abs($fac->lignes[$i]->tva_tx), 0, 'R'); $pdf->MultiCell($this->posxup-$this->posxtva-1, 4, ($fac->lignes[$i]->tva_tx < 0 ? '*':'').abs($fac->lignes[$i]->tva_tx), 0, 'R');
// Prix unitaire HT avant remise // Prix unitaire HT avant remise
$pdf->SetXY ($this->posxup, $curY); $pdf->SetXY ($this->posxup, $curY);
$pdf->MultiCell(18, 4, price($fac->lignes[$i]->subprice), 0, 'R', 0); $pdf->MultiCell($this->posxqty-$this->posxup-1, 4, price($fac->lignes[$i]->subprice), 0, 'R', 0);
// Quantité // Quantite
$pdf->SetXY ($this->posxqty, $curY); $pdf->SetXY ($this->posxqty, $curY);
$pdf->MultiCell(10, 4, $fac->lignes[$i]->qty, 0, 'R'); $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 4, $fac->lignes[$i]->qty, 0, 'R'); // Enough for 6 chars
// Remise sur ligne // Remise sur ligne
$pdf->SetXY ($this->posxdiscount, $curY); $pdf->SetXY ($this->posxdiscount, $curY);
if ($fac->lignes[$i]->remise_percent) if ($fac->lignes[$i]->remise_percent)
{ {
$pdf->MultiCell(14, 4, dolibarr_print_reduction($fac->lignes[$i]->remise_percent), 0, 'R'); $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 4, dolibarr_print_reduction($fac->lignes[$i]->remise_percent), 0, 'R');
} }
// Total HT ligne // Total HT ligne
$pdf->SetXY ($this->postotalht, $curY); $pdf->SetXY ($this->postotalht, $curY);
$total = price($fac->lignes[$i]->total_ht); $total = price($fac->lignes[$i]->total_ht);
$pdf->MultiCell(23, 4, $total, 0, 'R', 0); $pdf->MultiCell(26, 4, $total, 0, 'R', 0);
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
$tvaligne=$fac->lignes[$i]->total_tva; $tvaligne=$fac->lignes[$i]->total_tva;
@ -539,7 +540,7 @@ class pdf_crabe extends ModelePDFFactures
/* /*
* \brief Affiche infos divers * \brief Affiche infos divers
* \param pdf Objet PDF * \param pdf Objet PDF
* \param fac Objet facture * \param object Objet facture
* \param posy Position depart * \param posy Position depart
* \param outputlangs Objet langs * \param outputlangs Objet langs
* \return y Position pour suite * \return y Position pour suite
@ -563,7 +564,7 @@ class pdf_crabe extends ModelePDFFactures
} }
/* /*
* Conditions de règlements * Conditions de reglements
*/ */
if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement))
{ {
@ -581,7 +582,7 @@ class pdf_crabe extends ModelePDFFactures
} }
/* /*
* Check si absence mode règlement * Check si absence mode reglement
*/ */
if ($object->type != 2 && (! $conf->global->FACTURE_CHQ_NUMBER && ! $conf->global->FACTURE_RIB_NUMBER)) if ($object->type != 2 && (! $conf->global->FACTURE_CHQ_NUMBER && ! $conf->global->FACTURE_RIB_NUMBER))
{ {
@ -595,7 +596,7 @@ class pdf_crabe extends ModelePDFFactures
} }
/* /*
* Propose mode règlement par CHQ * Propose mode reglement par CHQ
*/ */
if ($object->type != 2 && (! $object->mode_reglement_code || $object->mode_reglement_code == 'CHQ')) if ($object->type != 2 && (! $object->mode_reglement_code || $object->mode_reglement_code == 'CHQ'))
{ {
@ -635,7 +636,7 @@ class pdf_crabe extends ModelePDFFactures
} }
/* /*
* Propose mode règlement par RIB * Propose mode reglement par RIB
*/ */
if ($object->type != 2 && (! $object->mode_reglement_code || $object->mode_reglement_code == 'VIR')) if ($object->type != 2 && (! $object->mode_reglement_code || $object->mode_reglement_code == 'VIR'))
{ {
@ -696,7 +697,7 @@ class pdf_crabe extends ModelePDFFactures
/* /*
* \brief Affiche le total à payer * \brief Affiche le total a payer
* \param pdf Objet PDF * \param pdf Objet PDF
* \param object Objet facture * \param object Objet facture
* \param deja_regle Montant deja regle * \param deja_regle Montant deja regle
@ -744,7 +745,7 @@ class pdf_crabe extends ModelePDFFactures
$index = 0; $index = 0;
} }
// Affichage des totaux de TVA par taux (conformément à réglementation) // Affichage des totaux de TVA par taux (conformément à réglementation)
$pdf->SetFillColor(248,248,248); $pdf->SetFillColor(248,248,248);
foreach( $this->tva as $tvakey => $tvaval ) foreach( $this->tva as $tvakey => $tvaval )
@ -808,7 +809,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1);
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price(abs($object->total_ttc - $deja_regle)), $useborder, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle), $useborder, 'R', 1);
$resteapayer=0; $resteapayer=0;
} }
@ -839,7 +840,7 @@ class pdf_crabe extends ModelePDFFactures
{ {
global $conf; global $conf;
// Montants exprimés en (en tab_top - 1) // Montants exprimés en (en tab_top - 1)
$pdf->SetTextColor(0,0,0); $pdf->SetTextColor(0,0,0);
$pdf->SetFont('Arial','',8); $pdf->SetFont('Arial','',8);
$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentities("Currency".$conf->monnaie)); $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentities("Currency".$conf->monnaie));
@ -859,7 +860,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
$pdf->SetXY ($this->posxtva-1, $tab_top+2); $pdf->SetXY ($this->posxtva-1, $tab_top+2);
$pdf->MultiCell(12,2, $outputlangs->transnoentities("VAT"),'','C'); $pdf->MultiCell($this->posxup-$this->posxtva-1,2, $outputlangs->transnoentities("VAT"),'','C');
$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
$pdf->SetXY ($this->posxup-1, $tab_top+2); $pdf->SetXY ($this->posxup-1, $tab_top+2);
@ -867,13 +868,13 @@ class pdf_crabe extends ModelePDFFactures
$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
$pdf->SetXY ($this->posxqty-1, $tab_top+2); $pdf->SetXY ($this->posxqty-1, $tab_top+2);
$pdf->MultiCell(11,2, $outputlangs->transnoentities("Qty"),'','C'); $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
$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);
if ($this->atleastonediscount) if ($this->atleastonediscount)
{ {
$pdf->SetXY ($this->posxdiscount-1, $tab_top+2); $pdf->SetXY ($this->posxdiscount-1, $tab_top+2);
$pdf->MultiCell(16,2, $outputlangs->transnoentities("ReductionShort"),'','C'); $pdf->MultiCell(14,2, $outputlangs->transnoentities("ReductionShort"),'','C');
} }
if ($this->atleastonediscount) if ($this->atleastonediscount)
@ -881,14 +882,14 @@ class pdf_crabe extends ModelePDFFactures
$pdf->line($this->postotalht, $tab_top, $this->postotalht, $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->SetXY ($this->postotalht-1, $tab_top+2);
$pdf->MultiCell(23,2, $outputlangs->transnoentities("TotalHT"),'','C'); $pdf->MultiCell(28,2, $outputlangs->transnoentities("TotalHT"),'','C');
} }
/* /*
* \brief Affiche en-tête facture * \brief Affiche en-tete facture
* \param pdf Objet PDF * \param pdf Objet PDF
* \param fac Objet facture * \param object Objet facture
* \param showadress 0=non, 1=oui * \param showadress 0=non, 1=oui
* \param outputlang Objet lang cible * \param outputlang Objet lang cible
*/ */
@ -1016,7 +1017,7 @@ class pdf_crabe extends ModelePDFFactures
if (defined("FAC_PDF_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) $pdf->MultiCell(80, 4, FAC_PDF_SOCIETE_NOM, 0, 'L'); // deprecated if (defined("FAC_PDF_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) $pdf->MultiCell(80, 4, FAC_PDF_SOCIETE_NOM, 0, 'L'); // deprecated
else $pdf->MultiCell(80, 4, $this->emetteur->nom, 0, 'L'); else $pdf->MultiCell(80, 4, $this->emetteur->nom, 0, 'L');
// Caractéristiques emetteur // Caractéristiques emetteur
$carac_emetteur = ''; $carac_emetteur = '';
if (defined("FAC_PDF_ADRESSE") && FAC_PDF_ADRESSE) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).FAC_PDF_ADRESSE; // deprecated if (defined("FAC_PDF_ADRESSE") && FAC_PDF_ADRESSE) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).FAC_PDF_ADRESSE; // deprecated
else { else {
@ -1076,7 +1077,7 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetFont('Arial','',9); $pdf->SetFont('Arial','',9);
$pdf->MultiCell(106,4, $object->contact->getFullName($outputlangs,1), 0, 'L'); $pdf->MultiCell(106,4, $object->contact->getFullName($outputlangs,1), 0, 'L');
// Caractéristiques client // Caractéristiques client
$carac_client=$object->contact->adresse; $carac_client=$object->contact->adresse;
$carac_client.="\n".$object->contact->cp . " " . $object->contact->ville."\n"; $carac_client.="\n".$object->contact->cp . " " . $object->contact->ville."\n";
if ($this->emetteur->pays_code != $object->contact->pays_code) if ($this->emetteur->pays_code != $object->contact->pays_code)
@ -1091,19 +1092,19 @@ class pdf_crabe extends ModelePDFFactures
$pdf->SetFont('Arial','B',11); $pdf->SetFont('Arial','B',11);
$pdf->MultiCell(106,4, $object->client->nom, 0, 'L'); $pdf->MultiCell(106,4, $object->client->nom, 0, 'L');
// Nom du contact facturation si c'est une société // Nom du contact facturation si c'est une société
$arrayidcontact = $object->getIdContact('external','BILLING'); $arrayidcontact = $object->getIdContact('external','BILLING');
if (sizeof($arrayidcontact) > 0) if (sizeof($arrayidcontact) > 0)
{ {
$object->fetch_contact($arrayidcontact[0]); $object->fetch_contact($arrayidcontact[0]);
// On vérifie si c'est une société ou un particulier // On vérifie si c'est une société ou un particulier
if( !preg_match('#'.$object->contact->getFullName($outputlangs,1).'#isU',$object->client->nom) ) if( !preg_match('#'.$object->contact->getFullName($outputlangs,1).'#isU',$object->client->nom) )
{ {
$carac_client .= "\n".$object->contact->getFullName($outputlangs,1); $carac_client .= "\n".$object->contact->getFullName($outputlangs,1);
} }
} }
// Caractéristiques client // Caractéristiques client
$carac_client.="\n".$object->client->adresse; $carac_client.="\n".$object->client->adresse;
$carac_client.="\n".$object->client->cp . " " . $object->client->ville."\n"; $carac_client.="\n".$object->client->cp . " " . $object->client->ville."\n";
if ($this->emetteur->pays_code != $object->client->pays_code) if ($this->emetteur->pays_code != $object->client->pays_code)
@ -1128,7 +1129,7 @@ class pdf_crabe extends ModelePDFFactures
$html=new Form($this->db); $html=new Form($this->db);
// Premiere ligne d'info réglementaires // Premiere ligne d'info réglementaires
$ligne1=""; $ligne1="";
if ($this->emetteur->forme_juridique_code) if ($this->emetteur->forme_juridique_code)
{ {
@ -1147,7 +1148,7 @@ class pdf_crabe extends ModelePDFFactures
$ligne1.=($ligne1?" - ":"").$outputlangs->transcountry("ProfId1",$this->emetteur->pays_code).": ".$this->emetteur->profid1; $ligne1.=($ligne1?" - ":"").$outputlangs->transcountry("ProfId1",$this->emetteur->pays_code).": ".$this->emetteur->profid1;
} }
// Deuxieme ligne d'info réglementaires // Deuxieme ligne d'info réglementaires
$ligne2=""; $ligne2="";
if ($this->emetteur->profid3) if ($this->emetteur->profid3)
{ {

View File

@ -73,6 +73,7 @@ class pdf_propale_azur extends ModelePDFPropales
$this->option_condreg = 1; // Affiche conditions règlement $this->option_condreg = 1; // Affiche conditions règlement
$this->option_codeproduitservice = 1; // Affiche code produit-service $this->option_codeproduitservice = 1; // Affiche code produit-service
$this->option_multilang = 1; // Dispo en plusieurs langues $this->option_multilang = 1; // Dispo en plusieurs langues
$this->option_escompte = 1; // Affiche si il y a eu escompte
$this->option_credit_note = 1; // Gère les avoirs $this->option_credit_note = 1; // Gère les avoirs
if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise') if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise')
@ -84,11 +85,11 @@ class pdf_propale_azur extends ModelePDFPropales
// Defini position des colonnes // Defini position des colonnes
$this->posxdesc=$this->marge_gauche+1; $this->posxdesc=$this->marge_gauche+1;
$this->posxtva=121; $this->posxtva=116;
$this->posxup=132; $this->posxup=126;
$this->posxqty=151; $this->posxqty=145;
$this->posxdiscount=162; $this->posxdiscount=162;
$this->postotalht=177; $this->postotalht=174;
$this->tva=array(); $this->tva=array();
$this->atleastoneratenotnull=0; $this->atleastoneratenotnull=0;
@ -273,28 +274,29 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page $pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page
$pdf->writeHTMLCell(112, 4, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1); // Description
$pdf->writeHTMLCell($this->posxtva-$this->posxdesc-1, 4, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1);
$pdf->SetFont('Arial','', 9); // On repositionne la police par défaut $pdf->SetFont('Arial','', 9); // On repositionne la police par défaut
$nexY = $pdf->GetY(); $nexY = $pdf->GetY();
// TVA // TVA
$pdf->SetXY ($this->posxtva, $curY); $pdf->SetXY ($this->posxtva, $curY);
$pdf->MultiCell(10, 4, ($propale->lignes[$i]->tva_tx < 0 ? '*':'').abs($propale->lignes[$i]->tva_tx), 0, 'R'); $pdf->MultiCell($this->posxup-$this->posxtva-1, 4, ($propale->lignes[$i]->tva_tx < 0 ? '*':'').abs($propale->lignes[$i]->tva_tx), 0, 'R');
// Prix unitaire HT avant remise // Prix unitaire HT avant remise
$pdf->SetXY ($this->posxup, $curY); $pdf->SetXY ($this->posxup, $curY);
$pdf->MultiCell(18, 4, price($propale->lignes[$i]->subprice), 0, 'R', 0); $pdf->MultiCell($this->posxqty-$this->posxup-1, 4, price($propale->lignes[$i]->subprice), 0, 'R', 0);
// Quantité // Quantité
$pdf->SetXY ($this->posxqty, $curY); $pdf->SetXY ($this->posxqty, $curY);
if ($propale->lignes[$i]->special_code != 3) $pdf->MultiCell(10, 4, $propale->lignes[$i]->qty, 0, 'R'); if ($propale->lignes[$i]->special_code != 3) $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 4, $propale->lignes[$i]->qty, 0, 'R');
// Remise sur ligne // Remise sur ligne
$pdf->SetXY ($this->posxdiscount, $curY); $pdf->SetXY ($this->posxdiscount, $curY);
if ($propale->lignes[$i]->remise_percent && $propale->lignes[$i]->special_code != 3) if ($propale->lignes[$i]->remise_percent && $propale->lignes[$i]->special_code != 3)
{ {
$pdf->MultiCell(14, 4, dolibarr_print_reduction($propale->lignes[$i]->remise_percent), 0, 'R'); $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 4, dolibarr_print_reduction($propale->lignes[$i]->remise_percent), 0, 'R');
} }
// Total HT ligne // Total HT ligne
@ -302,12 +304,12 @@ class pdf_propale_azur extends ModelePDFPropales
if ($propale->lignes[$i]->special_code == 3) if ($propale->lignes[$i]->special_code == 3)
{ {
// Ligne produit en option // Ligne produit en option
$pdf->MultiCell(23, 4, $outputlangs->transnoentities("Option"), 0, 'R', 0); $pdf->MultiCell(26, 4, $outputlangs->transnoentities("Option"), 0, 'R', 0);
} }
else else
{ {
$total = price($propale->lignes[$i]->total_ht); $total = price($propale->lignes[$i]->total_ht);
$pdf->MultiCell(23, 4, $total, 0, 'R', 0); $pdf->MultiCell(26, 4, $total, 0, 'R', 0);
} }
// Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva
@ -402,8 +404,8 @@ class pdf_propale_azur extends ModelePDFPropales
/* /*
* \brief Affiche tableau des versement * \brief Affiche tableau des versement
* \param pdf objet PDF * \param pdf Objet PDF
* \param propale objet propale * \param object Objet propale
*/ */
function _tableau_versements(&$pdf, $object, $posy, $outputlangs) function _tableau_versements(&$pdf, $object, $posy, $outputlangs)
{ {
@ -426,9 +428,9 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->SetFont('Arial','', 9); $pdf->SetFont('Arial','', 9);
/* /*
* Affiche la mention TVA non applicable selon option * If France, show VAT mention if not applicable
*/ */
if ($this->franchise == 1) if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1)
{ {
$pdf->SetFont('Arial','B',8); $pdf->SetFont('Arial','B',8);
$pdf->SetXY($this->marge_gauche, $posy); $pdf->SetXY($this->marge_gauche, $posy);
@ -438,7 +440,7 @@ class pdf_propale_azur extends ModelePDFPropales
} }
/* /*
* Conditions de règlements * Conditions de reglements
*/ */
if ($object->cond_reglement_code || $object->cond_reglement) if ($object->cond_reglement_code || $object->cond_reglement)
{ {
@ -456,7 +458,7 @@ class pdf_propale_azur extends ModelePDFPropales
} }
/* /*
* Check si absence mode règlement * Check si absence mode reglement
*/ */
if (! $conf->global->FACTURE_CHQ_NUMBER && ! $conf->global->FACTURE_RIB_NUMBER) if (! $conf->global->FACTURE_CHQ_NUMBER && ! $conf->global->FACTURE_RIB_NUMBER)
{ {
@ -470,7 +472,7 @@ class pdf_propale_azur extends ModelePDFPropales
} }
/* /*
* Propose mode règlement par CHQ * Propose mode reglement par CHQ
*/ */
if (! $object->mode_reglement_code || $object->mode_reglement_code == 'CHQ') if (! $object->mode_reglement_code || $object->mode_reglement_code == 'CHQ')
{ {
@ -510,7 +512,7 @@ class pdf_propale_azur extends ModelePDFPropales
} }
/* /*
* Propose mode règlement par RIB * Propose mode reglement par RIB
*/ */
if (! $object->mode_reglement_code || $object->mode_reglement_code == 'VIR') if (! $object->mode_reglement_code || $object->mode_reglement_code == 'VIR')
{ {
@ -571,9 +573,9 @@ class pdf_propale_azur extends ModelePDFPropales
/* /*
* \brief Affiche le total à payer * \brief Affiche le total a payer
* \param pdf Objet PDF * \param pdf Objet PDF
* \param prop Objet propale * \param object Objet propale
* \param deja_regle Montant deja regle * \param deja_regle Montant deja regle
* \param posy Position depart * \param posy Position depart
* \param outputlangs Objet langs * \param outputlangs Objet langs
@ -595,7 +597,7 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1);
$pdf->SetXY ($col2x, $tab2_top + 0); $pdf->SetXY ($col2x, $tab2_top + 0);
$pdf->MultiCell($largcol2, $tab2_hl, price(abs($object->total_ht + $object->remise)), 0, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1);
// Remise globale // Remise globale
if ($object->remise > 0) if ($object->remise > 0)
@ -610,7 +612,7 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("WithDiscountTotalHT"), 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("WithDiscountTotalHT"), 0, 'L', 1);
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * 2); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * 2);
$pdf->MultiCell($largcol2, $tab2_hl, price(abs($object->total_ht)), 0, 'R', 0); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht), 0, 'R', 1);
$index = 2; $index = 2;
} }
@ -633,7 +635,7 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT").' '.abs($tvakey).'%'.$tvacompl, 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT").' '.abs($tvakey).'%'.$tvacompl, 0, 'L', 1);
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price(abs($tvaval)), 0, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1);
} }
} }
if (! $this->atleastoneratenotnull) if (! $this->atleastoneratenotnull)
@ -643,7 +645,7 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1);
$pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index);
$pdf->MultiCell($largcol2, $tab2_hl, price(abs($object->total_tva)), 0, 'R', 1); $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1);
} }
$useborder=0; $useborder=0;
@ -731,7 +733,7 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
$pdf->SetXY ($this->posxtva-1, $tab_top+2); $pdf->SetXY ($this->posxtva-1, $tab_top+2);
$pdf->MultiCell(12,2, $outputlangs->transnoentities("VAT"),'','C'); $pdf->MultiCell($this->posxup-$this->posxtva-1,2, $outputlangs->transnoentities("VAT"),'','C');
$pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height);
$pdf->SetXY ($this->posxup-1, $tab_top+2); $pdf->SetXY ($this->posxup-1, $tab_top+2);
@ -739,13 +741,13 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height);
$pdf->SetXY ($this->posxqty-1, $tab_top+2); $pdf->SetXY ($this->posxqty-1, $tab_top+2);
$pdf->MultiCell(11,2, $outputlangs->transnoentities("Qty"),'','C'); $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C');
$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);
if ($this->atleastonediscount) if ($this->atleastonediscount)
{ {
$pdf->SetXY ($this->posxdiscount-1, $tab_top+2); $pdf->SetXY ($this->posxdiscount-1, $tab_top+2);
$pdf->MultiCell(16,2, $outputlangs->transnoentities("ReductionShort"),'','C'); $pdf->MultiCell(14,2, $outputlangs->transnoentities("ReductionShort"),'','C');
} }
if ($this->atleastonediscount) if ($this->atleastonediscount)
@ -753,15 +755,16 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->line($this->postotalht, $tab_top, $this->postotalht, $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->SetXY ($this->postotalht-1, $tab_top+2);
$pdf->MultiCell(23,2, $outputlangs->transnoentities("TotalHT"),'','C'); $pdf->MultiCell(28,2, $outputlangs->transnoentities("TotalHT"),'','C');
} }
/* /*
* \brief Affiche en-tête propale * \brief Affiche en-tête propale
* \param pdf objet PDF * \param pdf Objet PDF
* \param fac objet propale * \param object Objet propale
* \param showadress 0=non, 1=oui * \param showadress 0=non, 1=oui
* \param outputlang Objet lang cible
*/ */
function _pagehead(&$pdf, $object, $showadress=1, $outputlangs) function _pagehead(&$pdf, $object, $showadress=1, $outputlangs)
{ {
@ -792,7 +795,7 @@ class pdf_propale_azur extends ModelePDFPropales
$pdf->SetTextColor(200,0,0); $pdf->SetTextColor(200,0,0);
$pdf->SetFont('Arial','B',8); $pdf->SetFont('Arial','B',8);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L');
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToModuleSetup"), 0, 'L'); $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L');
} }
} }
else if (defined("FAC_PDF_INTITULE")) else if (defined("FAC_PDF_INTITULE"))
@ -962,6 +965,7 @@ class pdf_propale_azur extends ModelePDFPropales
function _pagefoot(&$pdf,$outputlangs) function _pagefoot(&$pdf,$outputlangs)
{ {
global $conf; global $conf;
$html=new Form($this->db); $html=new Form($this->db);
// Premiere ligne d'info réglementaires // Premiere ligne d'info réglementaires