From 6da0d25acc74fcaee64134f63e91147a905ce1d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 Jan 2009 16:45:04 +0000 Subject: [PATCH] Fix: Miscellanous fix on i18n --- htdocs/compta/bank/account.php | 89 +- .../modules/commande/pdf_edison.modules.php | 2 +- .../modules/commande/pdf_einstein.modules.php | 176 +-- .../modules/facture/pdf_crabe.modules.php | 1091 ++++++++--------- .../modules/facture/pdf_huitre.modules.php | 2 +- .../modules/facture/pdf_oursin.modules.php | 421 +++++-- .../livraison/pdf/pdf_sirocco.modules.php | 2 +- .../livraison/pdf/pdf_typhon.modules.php | 2 +- .../propale/pdf_propale_azur.modules.php | 159 +-- .../pdf/pdf_muscadet.modules.php | 21 +- htdocs/lib/company.lib.php | 22 +- htdocs/lib/functions.lib.php | 27 +- htdocs/translate.class.php | 26 +- 13 files changed, 1134 insertions(+), 906 deletions(-) diff --git a/htdocs/compta/bank/account.php b/htdocs/compta/bank/account.php index af384a870b4..10c40200ebd 100644 --- a/htdocs/compta/bank/account.php +++ b/htdocs/compta/bank/account.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Jean-Louis Bergamo - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * Copytight (C) 2004 Christophe Combelles * Copytight (C) 2005-2007 Regis Houssin * @@ -40,7 +40,7 @@ require_once(DOL_DOCUMENT_ROOT."/fourn/facture/paiementfourn.class.php"); if (!$user->rights->banque->lire) accessforbidden(); - + $langs->load("bills"); @@ -57,15 +57,16 @@ if ($negpage) $mesg=''; - + /* * Action */ +$dateop=-1; if ($_POST["action"] == 'add' && $account && ! isset($_POST["cancel"]) && $user->rights->banque->modifier) { - - if ($_POST["credit"] > 0) + + if (price2num($_POST["credit"]) > 0) { $amount = price2num($_POST["credit"]); } @@ -83,7 +84,7 @@ if ($_POST["action"] == 'add' && $account && ! isset($_POST["cancel"]) && $user- if (! $dateop) $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Date")); if (! $operation) $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Type")); if (! $amount) $mesg=$langs->trans("ErrorFieldRequired",$langs->trans("Amount")); - + if (! $mesg) { $acct=new Account($db,$account); @@ -137,11 +138,11 @@ if ($account || $_GET["ref"]) $viewline = 20; } $acct = new Account($db); - if ($account) + if ($account) { $result=$acct->fetch($account); } - if ($_GET["ref"]) + if ($_GET["ref"]) { $result=$acct->fetch(0,$_GET["ref"]); $account=$acct->id; @@ -169,7 +170,7 @@ if ($account || $_GET["ref"]) $db->free($result); } - + // Definition de sql_rech et param $param=''; $sql_rech=''; @@ -207,7 +208,7 @@ if ($account || $_GET["ref"]) } $sql.= " WHERE b.fk_account=".$acct->id; $sql.= $sql_rech; - + dolibarr_syslog("account.php count transactions - sql=".$sql); $result=$db->query($sql); if ($result) @@ -249,7 +250,7 @@ if ($account || $_GET["ref"]) // Onglets $head=bank_prepare_head($acct); dolibarr_fiche_head($head,'journal',$langs->trans("FinancialAccount"),0); - + print ''; // Ref @@ -265,10 +266,10 @@ if ($account || $_GET["ref"]) print '
'; print '
'; - + if ($mesg) print '
'.$mesg.'
'; - + /** * Search form */ @@ -296,7 +297,7 @@ if ($account || $_GET["ref"]) } $navig.=''; - + // Confirmation delete if ($_GET["action"]=='delete') { @@ -314,8 +315,8 @@ if ($account || $_GET["ref"]) print ''.$navig.''; } - - // Formulaire de saisie d'une opération hors factures + + // Form to add a transaction with no invoice if ($user->rights->banque->modifier && $_GET["action"]=='addline') { print '
'; @@ -339,20 +340,20 @@ if ($account || $_GET["ref"]) print ''; print ''; - $html->select_date(-1,'op',0,0,0,'transaction'); + $html->select_date($dateop,'op',0,0,0,'transaction'); print ''; print ''; - $html->select_types_paiements('','operation','1,2',2,1); - print ''; + $html->select_types_paiements((isset($_POST["operation"])?$_POST["operation"]:''),'operation','1,2',2,1); + print ''; print ''; - print ''; + print ''; if ($nbcategories) { print '
'.$langs->trans("Category").': '; } print ''; - print ''; - print ''; + print ''; + print ''; print ''; print '
'; print ''; @@ -446,10 +447,10 @@ if ($account || $_GET["ref"]) $time = time(); $var=true; - + $num = $db->num_rows($result); $i = 0; $total = 0; $sep = 0; - + while ($i < $num) { $objp = $db->fetch_object($result); @@ -457,7 +458,7 @@ if ($account || $_GET["ref"]) if ($i >= ($nbline - $viewline)) { $var=!$var; - + if ($objp->do > $time && !$sep) { $sep = 1 ; @@ -466,20 +467,20 @@ if ($account || $_GET["ref"]) print " "; print ''; } - + print ""; print "".dolibarr_print_date($objp->do,"day")."\n"; - + print " ".dolibarr_print_date($objp->dv,"day")."\n"; - + print " ".$langs->trans($objp->fk_type)." ".($objp->num_chq?$objp->num_chq:"")."\n"; - + // Description print ''; - + $links = $acct->get_url($objp->rowid); - + $isbanktransfert=false; foreach($links as $key=>$val) { if ($val['type']=='banktransfert') $isbanktransfert=true; } $issocialcontrib=false; @@ -492,11 +493,11 @@ if ($account || $_GET["ref"]) { if (eregi('^\((.*)\)$',$objp->label,$reg)) { - // Genereic description because between (). We show it after translating. + // Genereic description because between (). We show it after translating. print $langs->trans($reg[1]); } else - { + { print dolibarr_trunc($objp->label,60); } } @@ -520,7 +521,7 @@ if ($account || $_GET["ref"]) $chargestatic->ref=$links[$key]['url_id']; print ' '.$chargestatic->getNomUrl(2); } - else if ($links[$key]['type']=='payment_sc') + else if ($links[$key]['type']=='payment_sc') { //print ' - '; /* @@ -530,7 +531,7 @@ if ($account || $_GET["ref"]) print ''; */ } - else if ($links[$key]['type']=='payment_vat') + else if ($links[$key]['type']=='payment_vat') { $paymentvatstatic->id=$links[$key]['url_id']; $paymentvatstatic->ref=$links[$key]['url_id']; @@ -546,12 +547,12 @@ if ($account || $_GET["ref"]) print ''; if (eregi('^\((.*)\)$',$links[$key]['label'],$reg)) { - // Label générique car entre parenthèses. On l'affiche en le traduisant + // Label générique car entre parenthèses. On l'affiche en le traduisant if ($reg[1]=='paiement') $reg[1]='Payment'; print $langs->trans($reg[1]); } else - { + { print $links[$key]['label']; } print ''; @@ -589,7 +590,7 @@ if ($account || $_GET["ref"]) } } print ''; - + if ($objp->amount < 0) { print "".price($objp->amount * -1)." \n"; @@ -598,7 +599,7 @@ if ($account || $_GET["ref"]) { print "  ".price($objp->amount)."\n"; } - + if ($action != 'search') { if ($total >= 0) @@ -614,7 +615,7 @@ if ($account || $_GET["ref"]) { print '-'; } - + // Relevé rappro ou lien edition if ($objp->rappro && $acct->type != 2) // Si non compte cash { @@ -650,14 +651,14 @@ if ($account || $_GET["ref"]) } print ''; } - + print ""; - + } - + $i++; } - + // Affichage total if ($page == 0 && ! $mode_search) { diff --git a/htdocs/includes/modules/commande/pdf_edison.modules.php b/htdocs/includes/modules/commande/pdf_edison.modules.php index 2ca6e54dfb8..55a4e397065 100644 --- a/htdocs/includes/modules/commande/pdf_edison.modules.php +++ b/htdocs/includes/modules/commande/pdf_edison.modules.php @@ -314,7 +314,7 @@ class pdf_edison extends ModelePDFCommandes $pdf->SetTextColor(0,0,0); $pdf->SetFont('Arial','',10); - $titre = $langs->transnoentities("AmountInCurrency",$langs->transnoentities("Currency".$conf->monnaie)); + $titre = $langs->transnoentities("AmountInCurrency",$langs->transnoentitiesnoconv("Currency".$conf->monnaie)); $pdf->Text(200 - $pdf->GetStringWidth($titre), 98, $titre); } diff --git a/htdocs/includes/modules/commande/pdf_einstein.modules.php b/htdocs/includes/modules/commande/pdf_einstein.modules.php index 3a95b6d02eb..54b8c6cddb8 100644 --- a/htdocs/includes/modules/commande/pdf_einstein.modules.php +++ b/htdocs/includes/modules/commande/pdf_einstein.modules.php @@ -441,9 +441,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetFont('Arial','', 9); - /* - * If France, show VAT mention if not applicable - */ + // If France, show VAT mention if not applicable if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1) { $pdf->SetFont('Arial','B',8); @@ -453,9 +451,7 @@ class pdf_einstein extends ModelePDFCommandes $posy=$pdf->GetY()+4; } - /* - * Conditions de reglements - */ + // Show payments conditions if ($object->cond_reglement_code || $object->cond_reglement) { $pdf->SetFont('Arial','B',8); @@ -471,81 +467,89 @@ class pdf_einstein extends ModelePDFCommandes $posy=$pdf->GetY()+3; } - /* - * Check si absence mode reglement - */ - if (! $conf->global->FACTURE_CHQ_NUMBER && ! $conf->global->FACTURE_RIB_NUMBER) + // Check a payment mode is defined + if (empty($object->mode_reglement_code) + && ! $conf->global->FACTURE_CHQ_NUMBER + && ! $conf->global->FACTURE_RIB_NUMBER) { - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0); - $pdf->SetTextColor(0,0,0); + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('Arial','B',8); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0); + $pdf->SetTextColor(0,0,0); - $posy=$pdf->GetY()+1; + $posy=$pdf->GetY()+1; + } + + // Sown payment mode + if ($object->mode_reglement_code + && $object->mode_reglement_code != 'CHQ' + && $object->mode_reglement_code != 'VIR') + { + $pdf->SetFont('Arial','B',8); + $pdf->SetXY($this->marge_gauche, $posy); + $titre = $outputlangs->transnoentities("PaymentMode").':'; + $pdf->MultiCell(80, 5, $titre, 0, 'L'); + + $pdf->SetFont('Arial','',8); + $pdf->SetXY(50, $posy); + $lib_mode_reg=$outputlangs->transnoentities("PaymentMode".$object->mode_reglement_code)!=('PaymentMode'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentMode".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); + $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); + + $posy=$pdf->GetY()+2; + } + + // Show payment mode CHQ + if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') + { + // Si mode reglement non force ou si force a CHQ + if ($conf->global->FACTURE_CHQ_NUMBER) + { + if ($conf->global->FACTURE_CHQ_NUMBER > 0) + { + $account = new Account($this->db); + $account->fetch($conf->global->FACTURE_CHQ_NUMBER); + + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('Arial','B',8); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$outputlangs->convToOutputCharset($account->proprio)).':',0,'L',0); + $posy=$pdf->GetY()+1; + + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('Arial','',8); + $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0); + $posy=$pdf->GetY()+2; + } + if ($conf->global->FACTURE_CHQ_NUMBER == -1) + { + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('Arial','B',8); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedToShort').' '.$outputlangs->convToOutputCharset($this->emetteur->nom).' '.$outputlangs->transnoentities('SendTo').':',0,'L',0); + $posy=$pdf->GetY()+1; + + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('Arial','',8); + $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->adresse_full), 0, 'L', 0); + $posy=$pdf->GetY()+2; + } + } } - /* - * Propose mode reglement par CHQ - */ - if (! $object->mode_reglement_code || $object->mode_reglement_code == 'CHQ') - { - // Si mode reglement non force ou si force a CHQ - if ($conf->global->FACTURE_CHQ_NUMBER) - { - if ($conf->global->FACTURE_CHQ_NUMBER > 0) - { - $account = new Account($this->db); - $account->fetch($conf->global->FACTURE_CHQ_NUMBER); + // If payment mode not forced or forced to VIR, show payment with BAN + if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') + { + if (! empty($conf->global->FACTURE_RIB_NUMBER)) + { + $account = new Account($this->db); + $account->fetch($conf->global->FACTURE_RIB_NUMBER); - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$outputlangs->convToOutputCharset($account->proprio)).':',0,'L',0); - $posy=$pdf->GetY()+1; + $curx=$this->marge_gauche; + $cury=$posy; - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('Arial','',8); - $pdf->MultiCell(80, 3, $account->adresse_proprio, 0, 'L', 0); + $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account); - $posy=$pdf->GetY()+2; - } - if ($conf->global->FACTURE_CHQ_NUMBER == -1) - { - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedToShort').' '.$outputlangs->convToOutputCharset($this->emetteur->nom).' '.$outputlangs->transnoentities('SendTo').':',0,'L',0); - $posy=$pdf->GetY()+1; - - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('Arial','',8); - $pdf->MultiCell(80, 6, $outputlangs->convToOutputCharset($this->emetteur->adresse_full), 0, 'L', 0); - - $posy=$pdf->GetY()+2; - } - } - } - - /* - * Propose mode reglement par RIB - */ - if (! $object->mode_reglement_code || $object->mode_reglement_code == 'VIR') - { - // Si mode reglement non force ou si force a VIR - if ($conf->global->FACTURE_RIB_NUMBER) - { - if ($conf->global->FACTURE_RIB_NUMBER) - { - $account = new Account($this->db); - $account->fetch($conf->global->FACTURE_RIB_NUMBER); - - $curx=$this->marge_gauche; - $cury=$posy; - - $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account); - - $posy+=2; - } - } + $posy+=2; + } } return $posy; @@ -569,7 +573,7 @@ class pdf_einstein extends ModelePDFCommandes $pdf->SetFont('Arial','', 9); // Tableau total - $lltot = 200; $col1x = 120; $col2x = 182; $largcol2 = $lltot - $col2x; + $lltot = 200; $col1x = 120; $col2x = 170; $largcol2 = $lltot - $col2x; // Total HT $pdf->SetFillColor(255,255,255); @@ -671,7 +675,7 @@ class pdf_einstein extends ModelePDFCommandes // Montants exprim�s en (en tab_top - 1) $pdf->SetTextColor(0,0,0); $pdf->SetFont('Arial','',8); - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentities("Currency".$conf->monnaie)); + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie)); $pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre); $pdf->SetDrawColor(128,128,128); @@ -865,9 +869,7 @@ class pdf_einstein extends ModelePDFCommandes if ($usecontact) { // Nom societe - $pdf->SetXY(102,$posy+3); - $pdf->SetFont('Arial','B',11); - $pdf->MultiCell(96,4, $outputlangs->convToOutputCharset($object->client->nom), 0, 'L'); + $carac_client_name=$outputlangs->convToOutputCharset($object->client->nom); // Customer name $carac_client = "\n".$object->contact->getFullName($outputlangs,1,1); @@ -884,16 +886,14 @@ class pdf_einstein extends ModelePDFCommandes else { // Customer name - $pdf->SetXY(102,$posy+3); - $pdf->SetFont('Arial','B',11); - $pdf->MultiCell(96,4, $outputlangs->convToOutputCharset($object->client->nom), 0, 'L'); + $carac_client_name=$outputlangs->convToOutputCharset($object->client->nom); // Nom du contact suivi commande si c'est une soci�t� $arrayidcontact = $object->getIdContact('external','CUSTOMER'); if (sizeof($arrayidcontact) > 0) { $object->fetch_contact($arrayidcontact[0]); - // On v�rifie si c'est une soci�t� ou un particulier + // On verifie si c'est une societe ou un particulier if( !preg_match('#'.$object->contact->getFullName($outputlangs,1).'#isU',$object->client->nom) ) { $carac_client .= "\n".$object->contact->getFullName($outputlangs,1,1); @@ -910,8 +910,14 @@ class pdf_einstein extends ModelePDFCommandes $carac_client.=$outputlangs->convToOutputCharset($object->client->pays)."\n"; } } - // Num�ro TVA intracom - if ($object->client->tva_intra) $carac_client.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$object->client->tva_intra; + // Numero TVA intracom + if ($object->client->tva_intra) $carac_client.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($object->client->tva_intra); + + // Show customer/recipient + $pdf->SetXY(102,$posy+3); + $pdf->SetFont('Arial','B',11); + $pdf->MultiCell(96,4, $carac_client_name, 0, 'L'); + $pdf->SetFont('Arial','',9); $posy=$pdf->GetY()-9; //Auto Y coord readjust for multiline name $pdf->SetXY(102,$posy+6); diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php index a64529b988d..5e4b9fe019e 100644 --- a/htdocs/includes/modules/facture/pdf_crabe.modules.php +++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php @@ -1,7 +1,7 @@ +/* Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005-2008 Regis Houssin - * Copyright (C) 2008 Raphael Bertrand (Resultic) + * Copyright (C) 2008 Raphael Bertrand (Resultic) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,12 +20,12 @@ */ /** - \file htdocs/includes/modules/facture/pdf_crabe.modules.php - \ingroup facture - \brief File of class to generate invoices from crab model - \author Laurent Destailleur - \version $Id$ -*/ + \file htdocs/includes/modules/facture/pdf_crabe.modules.php + \ingroup facture + \brief File of class to generate invoices from crab model + \author Laurent Destailleur + \version $Id$ + */ require_once(DOL_DOCUMENT_ROOT."/includes/modules/facture/modules_facture.php"); require_once(DOL_DOCUMENT_ROOT."/product.class.php"); @@ -34,79 +34,79 @@ require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php"); /** - \class pdf_crabe - \brief Classe permettant de g�n�rer les factures au mod�le Crabe -*/ + \class pdf_crabe + \brief Classe permettant de g�n�rer les factures au mod�le Crabe + */ class pdf_crabe extends ModelePDFFactures { var $emetteur; // Objet societe qui emet - /** - * \brief Constructor - * \param db Database handler - */ - function pdf_crabe($db) - { - global $conf,$langs,$mysoc; + /** + * \brief Constructor + * \param db Database handler + */ + function pdf_crabe($db) + { + global $conf,$langs,$mysoc; - $langs->load("main"); - $langs->load("bills"); + $langs->load("main"); + $langs->load("bills"); - $this->db = $db; - $this->name = "crabe"; - $this->description = $langs->trans('PDFCrabeDescription'); + $this->db = $db; + $this->name = "crabe"; + $this->description = $langs->trans('PDFCrabeDescription'); - // Dimension page pour format A4 - $this->type = 'pdf'; - $this->page_largeur = 210; - $this->page_hauteur = 297; - $this->format = array($this->page_largeur,$this->page_hauteur); - $this->marge_gauche=10; - $this->marge_droite=10; - $this->marge_haute=10; - $this->marge_basse=10; + // Dimension page pour format A4 + $this->type = 'pdf'; + $this->page_largeur = 210; + $this->page_hauteur = 297; + $this->format = array($this->page_largeur,$this->page_hauteur); + $this->marge_gauche=10; + $this->marge_droite=10; + $this->marge_haute=10; + $this->marge_basse=10; - $this->option_logo = 1; // Affiche logo - $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION - $this->option_modereg = 1; // Affiche mode r�glement - $this->option_condreg = 1; // Affiche conditions r�glement - $this->option_codeproduitservice = 1; // Affiche code produit-service - $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_freetext = 1; // Support add of a personalised text + $this->option_logo = 1; // Affiche logo + $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION + $this->option_modereg = 1; // Affiche mode reglement + $this->option_condreg = 1; // Affiche conditions reglement + $this->option_codeproduitservice = 1; // Affiche code produit-service + $this->option_multilang = 1; // Dispo en plusieurs langues + $this->option_escompte = 1; // Affiche si il y a eu escompte + $this->option_credit_note = 1; // Support credit notes + $this->option_freetext = 1; // Support add of a personalised text $this->option_draft_watermark = 1; //Support add of a watermark on drafts - if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise') - $this->franchise=1; + if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise') + $this->franchise=1; - // Recupere emmetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si n'�tait pas d�fini + // Recupere emmetteur + $this->emetteur=$mysoc; + 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 - $this->posxdesc=$this->marge_gauche+1; - $this->posxtva=113; - $this->posxup=126; - $this->posxqty=145; - $this->posxdiscount=162; - $this->postotalht=174; + // Defini position des colonnes + $this->posxdesc=$this->marge_gauche+1; + $this->posxtva=113; + $this->posxup=126; + $this->posxqty=145; + $this->posxdiscount=162; + $this->postotalht=174; - $this->tva=array(); - $this->atleastoneratenotnull=0; - $this->atleastonediscount=0; - } + $this->tva=array(); + $this->atleastoneratenotnull=0; + $this->atleastonediscount=0; + } - /** - * \brief Fonction g�n�rant la facture sur le disque - * \param fac Objet facture � g�n�rer (ou id si ancienne methode) + /** + * \brief Fonction g�n�rant la facture sur le disque + * \param fac Objet facture � g�n�rer (ou id si ancienne methode) * \param outputlangs Lang object for output language - * \return int 1=ok, 0=ko - */ - function write_file($fac,$outputlangs) + * \return int 1=ok, 0=ko + */ + function write_file($fac,$outputlangs) { global $user,$langs,$conf; @@ -234,12 +234,12 @@ class pdf_crabe extends ModelePDFFactures $curY = $tab_top + 8; $nexY = $tab_top + 8; - // Boucle sur les lignes + // Loop on each lines for ($i = 0 ; $i < $nblignes ; $i++) { $curY = $nexY; - // Description de la ligne produit + // Description of product line $libelleproduitservice=dol_htmlentitiesbr($fac->lignes[$i]->libelle,1); if ($fac->lignes[$i]->desc && $fac->lignes[$i]->desc != $fac->lignes[$i]->libelle) { @@ -299,8 +299,6 @@ class pdf_crabe extends ModelePDFFactures //if ($i==0) { print $libelleproduitservice; exit; } $pdf->SetFont('Arial','', 9); // Dans boucle pour gerer multi-page - - // Description $pdf->writeHTMLCell($this->posxtva-$this->posxdesc-1, 3, $this->posxdesc-1, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1); $pdf->SetFont('Arial','', 9); // On repositionne la police par defaut @@ -415,7 +413,7 @@ class pdf_crabe extends ModelePDFFactures $pdf->Output($file); if (! empty($conf->global->MAIN_UMASK)) - @chmod($file, octdec($conf->global->MAIN_UMASK)); + @chmod($file, octdec($conf->global->MAIN_UMASK)); $langs->setPhpLang(); // On restaure langue session return 1; // Pas d'erreur @@ -439,41 +437,41 @@ class pdf_crabe extends ModelePDFFactures } - /** - * \brief Affiche tableau des versement - * \param pdf Objet PDF - * \param fac Objet facture + /** + * \brief Affiche tableau des versement + * \param pdf Objet PDF + * \param fac Objet facture * \param posy Position y in PDF * \param outputlangs Object langs for output * \return int <0 if KO, >0 if OK - */ - function _tableau_versements(&$pdf, $fac, $posy, $outputlangs) + */ + function _tableau_versements(&$pdf, $fac, $posy, $outputlangs) { - $tab3_posx = 120; - $tab3_top = $posy + 8; - $tab3_width = 80; - $tab3_height = 4; + $tab3_posx = 120; + $tab3_top = $posy + 8; + $tab3_width = 80; + $tab3_height = 4; - $pdf->SetFont('Arial','',8); - $pdf->SetXY ($tab3_posx, $tab3_top - 5); - $pdf->MultiCell(60, 5, $outputlangs->transnoentities("PaymentsAlreadyDone"), 0, 'L', 0); + $pdf->SetFont('Arial','',8); + $pdf->SetXY ($tab3_posx, $tab3_top - 5); + $pdf->MultiCell(60, 5, $outputlangs->transnoentities("PaymentsAlreadyDone"), 0, 'L', 0); - $pdf->Rect($tab3_posx, $tab3_top-1, $tab3_width, $tab3_height); + $pdf->Rect($tab3_posx, $tab3_top-1, $tab3_width, $tab3_height); - $pdf->SetXY ($tab3_posx, $tab3_top-1 ); - $pdf->MultiCell(20, 4, $outputlangs->transnoentities("Payment"), 0, 'L', 0); - $pdf->SetXY ($tab3_posx+21, $tab3_top-1 ); - $pdf->MultiCell(20, 4, $outputlangs->transnoentities("Amount"), 0, 'L', 0); - $pdf->SetXY ($tab3_posx+41, $tab3_top-1 ); - $pdf->MultiCell(20, 4, $outputlangs->transnoentities("Type"), 0, 'L', 0); - $pdf->SetXY ($tab3_posx+60, $tab3_top-1 ); - $pdf->MultiCell(20, 4, $outputlangs->transnoentities("Num"), 0, 'L', 0); + $pdf->SetXY ($tab3_posx, $tab3_top-1 ); + $pdf->MultiCell(20, 4, $outputlangs->transnoentities("Payment"), 0, 'L', 0); + $pdf->SetXY ($tab3_posx+21, $tab3_top-1 ); + $pdf->MultiCell(20, 4, $outputlangs->transnoentities("Amount"), 0, 'L', 0); + $pdf->SetXY ($tab3_posx+41, $tab3_top-1 ); + $pdf->MultiCell(20, 4, $outputlangs->transnoentities("Type"), 0, 'L', 0); + $pdf->SetXY ($tab3_posx+60, $tab3_top-1 ); + $pdf->MultiCell(20, 4, $outputlangs->transnoentities("Num"), 0, 'L', 0); $y=0; - $pdf->SetFont('Arial','',6); + $pdf->SetFont('Arial','',6); - // Loop on each credit note included + // Loop on each credit note included $sql = "SELECT re.rowid, re.amount_ht, re.amount_tva, re.amount_ttc,"; $sql.= " re.description, re.fk_facture_source, re.fk_facture_source"; $sql.= " FROM ".MAIN_DB_PREFIX ."societe_remise_except as re"; @@ -482,7 +480,7 @@ class pdf_crabe extends ModelePDFFactures if ($resql) { $num = $this->db->num_rows($resql); - $i=0; + $i=0; $invoice=new Facture($this->db); while ($i < $num) { @@ -491,324 +489,318 @@ class pdf_crabe extends ModelePDFFactures $invoice->fetch($obj->fk_facture_source); - $pdf->SetXY ($tab3_posx, $tab3_top+$y ); - $pdf->MultiCell(20, 4,'', 0, 'L', 0); - $pdf->SetXY ($tab3_posx+21, $tab3_top+$y); - $pdf->MultiCell(20, 4, price($obj->amount_ttc), 0, 'L', 0); - $pdf->SetXY ($tab3_posx+41, $tab3_top+$y); - $pdf->MultiCell(20, 4, $outputlangs->trans("CreditNote"), 0, 'L', 0); - $pdf->SetXY ($tab3_posx+60, $tab3_top+$y); - $pdf->MultiCell(20, 4, $invoice->ref, 0, 'L', 0); + $pdf->SetXY ($tab3_posx, $tab3_top+$y ); + $pdf->MultiCell(20, 4,'', 0, 'L', 0); + $pdf->SetXY ($tab3_posx+21, $tab3_top+$y); + $pdf->MultiCell(20, 4, price($obj->amount_ttc), 0, 'L', 0); + $pdf->SetXY ($tab3_posx+41, $tab3_top+$y); + $pdf->MultiCell(20, 4, $outputlangs->trans("CreditNote"), 0, 'L', 0); + $pdf->SetXY ($tab3_posx+60, $tab3_top+$y); + $pdf->MultiCell(20, 4, $invoice->ref, 0, 'L', 0); - $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3 ); + $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3 ); - $i++; + $i++; } } else { - $this->error=$this->db->lasterror(); + $this->error=$this->db->lasterror(); dolibarr_syslog($this->db,$this->error); - return -1; + return -1; } // Loop on each payment - $sql = "SELECT ".$this->db->pdate("p.datep")."as date, pf.amount as amount, p.fk_paiement as type, p.num_paiement as num "; - $sql.= "FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."paiement_facture as pf "; - $sql.= "WHERE pf.fk_paiement = p.rowid and pf.fk_facture = ".$fac->id." "; - $sql.= "ORDER BY p.datep"; - $resql=$this->db->query($sql); + $sql = "SELECT ".$this->db->pdate("p.datep")."as date, pf.amount as amount, p.fk_paiement as type, p.num_paiement as num "; + $sql.= "FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."paiement_facture as pf "; + $sql.= "WHERE pf.fk_paiement = p.rowid and pf.fk_facture = ".$fac->id." "; + $sql.= "ORDER BY p.datep"; + $resql=$this->db->query($sql); if ($resql) - { - $num = $this->db->num_rows($resql); - $i=0; - while ($i < $num) { - $y+=3; - $row = $this->db->fetch_row($resql); + { + $num = $this->db->num_rows($resql); + $i=0; + while ($i < $num) { + $y+=3; + $row = $this->db->fetch_row($resql); - $pdf->SetXY ($tab3_posx, $tab3_top+$y ); - $pdf->MultiCell(20, 4, dolibarr_print_date($row[0],'day',false,$outputlangs), 0, 'L', 0); - $pdf->SetXY ($tab3_posx+21, $tab3_top+$y); - $pdf->MultiCell(20, 4, price($row[1]), 0, 'L', 0); - $pdf->SetXY ($tab3_posx+41, $tab3_top+$y); - switch ($row[2]) - { - case 1: - $oper = 'TIP'; - break; - case 2: - $oper = 'VIR'; - break; - case 3: - $oper = 'PRE'; - break; - case 4: - $oper = 'LIQ'; - break; - case 5: - $oper = 'VAD'; - break; - case 6: - $oper = 'CB'; - break; - case 7: - $oper = 'CHQ'; - break; - } - $pdf->MultiCell(20, 4, $oper, 0, 'L', 0); - $pdf->SetXY ($tab3_posx+60, $tab3_top+$y); - $pdf->MultiCell(20, 4, $row[3], 0, 'L', 0); + $pdf->SetXY ($tab3_posx, $tab3_top+$y ); + $pdf->MultiCell(20, 4, dolibarr_print_date($row[0],'day',false,$outputlangs), 0, 'L', 0); + $pdf->SetXY ($tab3_posx+21, $tab3_top+$y); + $pdf->MultiCell(20, 4, price($row[1]), 0, 'L', 0); + $pdf->SetXY ($tab3_posx+41, $tab3_top+$y); + switch ($row[2]) + { + case 1: + $oper = 'TIP'; + break; + case 2: + $oper = 'VIR'; + break; + case 3: + $oper = 'PRE'; + break; + case 4: + $oper = 'LIQ'; + break; + case 5: + $oper = 'VAD'; + break; + case 6: + $oper = 'CB'; + break; + case 7: + $oper = 'CHQ'; + break; + } + $pdf->MultiCell(20, 4, $oper, 0, 'L', 0); + $pdf->SetXY ($tab3_posx+60, $tab3_top+$y); + $pdf->MultiCell(20, 4, $row[3], 0, 'L', 0); - $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3 ); + $pdf->line($tab3_posx, $tab3_top+$y+3, $tab3_posx+$tab3_width, $tab3_top+$y+3 ); - $i++; - } - } - else - { - $this->error=$this->db->lasterror(); + $i++; + } + } + else + { + $this->error=$this->db->lasterror(); dolibarr_syslog($this->db,$this->error); - return -1; - } + return -1; + } - } + } /** - * \brief Affiche infos divers - * \param pdf Objet PDF - * \param object Objet facture - * \param posy Position depart - * \param outputlangs Objet langs - * \return y Position pour suite - */ - function _tableau_info(&$pdf, $object, $posy, $outputlangs) - { - global $conf; + * \brief Affiche infos divers + * \param pdf Objet PDF + * \param object Objet facture + * \param posy Position depart + * \param outputlangs Objet langs + * \return y Position pour suite + */ + function _tableau_info(&$pdf, $object, $posy, $outputlangs) + { + global $conf; - $pdf->SetFont('Arial','', 9); + $pdf->SetFont('Arial','', 9); - // If France, show VAT mention if not applicable - if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1) - { - $pdf->SetFont('Arial','B',8); - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); + // If France, show VAT mention if not applicable + if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1) + { + $pdf->SetFont('Arial','B',8); + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); - $posy=$pdf->GetY()+4; - } + $posy=$pdf->GetY()+4; + } - // Show payments conditions - if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) - { - $pdf->SetFont('Arial','B',8); - $pdf->SetXY($this->marge_gauche, $posy); - $titre = $outputlangs->transnoentities("PaymentConditions").':'; - $pdf->MultiCell(80, 5, $titre, 0, 'L'); + // Show payments conditions + if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) + { + $pdf->SetFont('Arial','B',8); + $pdf->SetXY($this->marge_gauche, $posy); + $titre = $outputlangs->transnoentities("PaymentConditions").':'; + $pdf->MultiCell(80, 5, $titre, 0, 'L'); - $pdf->SetFont('Arial','',8); - $pdf->SetXY(50, $posy); - $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement); - $pdf->MultiCell(80, 5, $lib_condition_paiement,0,'L'); + $pdf->SetFont('Arial','',8); + $pdf->SetXY(50, $posy); + $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement); + $pdf->MultiCell(80, 5, $lib_condition_paiement,0,'L'); - $posy=$pdf->GetY()+3; + $posy=$pdf->GetY()+3; } - if ($object->type != 2) - { - // Check a payment mode is defined - if (empty($object->mode_reglement_code) - && ! $conf->global->FACTURE_CHQ_NUMBER - && ! $conf->global->FACTURE_RIB_NUMBER) + if ($object->type != 2) + { + // Check a payment mode is defined + if (empty($object->mode_reglement_code) + && ! $conf->global->FACTURE_CHQ_NUMBER + && ! $conf->global->FACTURE_RIB_NUMBER) { - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0); - $pdf->SetTextColor(0,0,0); + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('Arial','B',8); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0); + $pdf->SetTextColor(0,0,0); - $posy=$pdf->GetY()+1; - } - - // Sown payment mode - if ($object->mode_reglement_code - && $object->mode_reglement_code != 'CHQ' - && $object->mode_reglement_code != 'VIR') - { - $pdf->SetFont('Arial','B',8); - $pdf->SetXY($this->marge_gauche, $posy); - $titre = $outputlangs->transnoentities("PaymentMode").':'; - $pdf->MultiCell(80, 5, $titre, 0, 'L'); - - $pdf->SetFont('Arial','',8); - $pdf->SetXY(50, $posy); - $lib_mode_reg=$outputlangs->transnoentities("PaymentMode".$object->mode_reglement_code)!=('PaymentMode'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentMode".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); - $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); - - $posy=$pdf->GetY()+2; - } - - /* - * Propose mode reglement par CHQ - */ - if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') - { - // Si mode reglement non force ou si force a CHQ - if ($conf->global->FACTURE_CHQ_NUMBER) - { - if ($conf->global->FACTURE_CHQ_NUMBER > 0) - { - $account = new Account($this->db); - $account->fetch($conf->global->FACTURE_CHQ_NUMBER); - - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$outputlangs->convToOutputCharset($account->proprio)).':',0,'L',0); - $posy=$pdf->GetY()+1; - - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('Arial','',8); - $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0); - - $posy=$pdf->GetY()+2; - } - if ($conf->global->FACTURE_CHQ_NUMBER == -1) - { - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedToShort').' '.$outputlangs->convToOutputCharset($this->emetteur->nom).' '.$outputlangs->transnoentities('SendTo').':',0,'L',0); - $posy=$pdf->GetY()+1; - - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('Arial','',8); - $pdf->MultiCell(80, 6, $outputlangs->convToOutputCharset($this->emetteur->adresse_full), 0, 'L', 0); - - $posy=$pdf->GetY()+2; - } - } + $posy=$pdf->GetY()+1; } - /* - * Si mode reglement non force ou si force a VIR, propose mode reglement par RIB - */ - if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') - { - if (! empty($conf->global->FACTURE_RIB_NUMBER)) - { - $account = new Account($this->db); - $account->fetch($conf->global->FACTURE_RIB_NUMBER); + // Sown payment mode + if ($object->mode_reglement_code + && $object->mode_reglement_code != 'CHQ' + && $object->mode_reglement_code != 'VIR') + { + $pdf->SetFont('Arial','B',8); + $pdf->SetXY($this->marge_gauche, $posy); + $titre = $outputlangs->transnoentities("PaymentMode").':'; + $pdf->MultiCell(80, 5, $titre, 0, 'L'); - $curx=$this->marge_gauche; - $cury=$posy; + $pdf->SetFont('Arial','',8); + $pdf->SetXY(50, $posy); + $lib_mode_reg=$outputlangs->transnoentities("PaymentMode".$object->mode_reglement_code)!=('PaymentMode'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentMode".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); + $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); - $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account); - - $posy+=2; - } + $posy=$pdf->GetY()+2; } - } - return $posy; - } + // Show payment mode CHQ + if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') + { + // Si mode reglement non force ou si force a CHQ + if ($conf->global->FACTURE_CHQ_NUMBER) + { + if ($conf->global->FACTURE_CHQ_NUMBER > 0) + { + $account = new Account($this->db); + $account->fetch($conf->global->FACTURE_CHQ_NUMBER); + + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('Arial','B',8); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$outputlangs->convToOutputCharset($account->proprio)).':',0,'L',0); + $posy=$pdf->GetY()+1; + + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('Arial','',8); + $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0); + $posy=$pdf->GetY()+2; + } + if ($conf->global->FACTURE_CHQ_NUMBER == -1) + { + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('Arial','B',8); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedToShort').' '.$outputlangs->convToOutputCharset($this->emetteur->nom).' '.$outputlangs->transnoentities('SendTo').':',0,'L',0); + $posy=$pdf->GetY()+1; + + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('Arial','',8); + $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->adresse_full), 0, 'L', 0); + $posy=$pdf->GetY()+2; + } + } + } + + // If payment mode not forced or forced to VIR, show payment with BAN + if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') + { + if (! empty($conf->global->FACTURE_RIB_NUMBER)) + { + $account = new Account($this->db); + $account->fetch($conf->global->FACTURE_RIB_NUMBER); + + $curx=$this->marge_gauche; + $cury=$posy; + + $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account); + + $posy+=2; + } + } + } + + return $posy; + } - /** - * \brief Affiche le total a payer - * \param pdf Objet PDF - * \param object Objet facture - * \param deja_regle Montant deja regle - * \param posy Position depart - * \param outputlangs Objet langs - * \return y Position pour suite - */ - function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) - { - $tab2_top = $posy; - $tab2_hl = 5; - $tab2_height = $tab2_hl * 4; - $pdf->SetFont('Arial','', 9); + /** + * \brief Affiche le total a payer + * \param pdf Objet PDF + * \param object Objet facture + * \param deja_regle Montant deja regle + * \param posy Position depart + * \param outputlangs Objet langs + * \return y Position pour suite + */ + function _tableau_tot(&$pdf, $object, $deja_regle, $posy, $outputlangs) + { + $tab2_top = $posy; + $tab2_hl = 5; + $tab2_height = $tab2_hl * 4; + $pdf->SetFont('Arial','', 9); - // Tableau total - $lltot = 200; $col1x = 120; $col2x = 182; $largcol2 = $lltot - $col2x; + // Tableau total + $lltot = 200; $col1x = 120; $col2x = 170; $largcol2 = $lltot - $col2x; - $index = 0; + $index = 0; - // Total HT - $pdf->SetFillColor(255,255,255); - $pdf->SetXY ($col1x, $tab2_top + 0); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); - $pdf->SetXY ($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1); + // Total HT + $pdf->SetFillColor(255,255,255); + $pdf->SetXY ($col1x, $tab2_top + 0); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalHT"), 0, 'L', 1); + $pdf->SetXY ($col2x, $tab2_top + 0); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1); - // Affichage des totaux de TVA par taux (conformement a la reglementation) - $pdf->SetFillColor(248,248,248); + // Affichage des totaux de TVA par taux (conformement a la reglementation) + $pdf->SetFillColor(248,248,248); - foreach( $this->tva as $tvakey => $tvaval ) - { - if ($tvakey) // On affiche pas taux 0 - { - $this->atleastoneratenotnull++; + foreach( $this->tva as $tvakey => $tvaval ) + { + if ($tvakey) // On affiche pas taux 0 + { + $this->atleastoneratenotnull++; - $index++; - $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); + $index++; + $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); $tvacompl=''; if (eregi('\*',$tvakey)) { $tvakey=eregi_replace('\*','',$tvakey); $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; } - $totalvat =$outputlangs->transnoentities("TotalVAT").' '; + $totalvat =$outputlangs->transnoentities("TotalVAT").' '; $totalvat.=vatrate($tvakey,1).$tvacompl; $pdf->MultiCell($col2x-$col1x, $tab2_hl, $totalvat, 0, 'L', 1); - $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); - } - } - if (! $this->atleastoneratenotnull) // If not vat at all - { - $index++; - $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1); - $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); - } + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval), 0, 'R', 1); + } + } + if (! $this->atleastoneratenotnull) // If not vat at all + { + $index++; + $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalVAT"), 0, 'L', 1); + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_tva), 0, 'R', 1); + } - $useborder=0; + $useborder=0; // Total TTC - $index++; - $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); - $pdf->SetTextColor(0,0,60); - $pdf->SetFillColor(224,224,224); - $text=$outputlangs->transnoentities("TotalTTC"); - if ($object->type == 2) $text=$outputlangs->transnoentities("TotalTTCToYourCredit"); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $text, $useborder, 'L', 1); - $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1); - $pdf->SetTextColor(0,0,0); + $index++; + $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); + $pdf->SetTextColor(0,0,60); + $pdf->SetFillColor(224,224,224); + $text=$outputlangs->transnoentities("TotalTTC"); + if ($object->type == 2) $text=$outputlangs->transnoentities("TotalTTCToYourCredit"); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $text, $useborder, 'L', 1); + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1); + $pdf->SetTextColor(0,0,0); - $creditnoteamount=$object->getSommeCreditNote(); + $creditnoteamount=$object->getSommeCreditNote(); $resteapayer = $object->total_ttc - $deja_regle - $creditnoteamount; if ($object->paye) $resteapayer=0; if ($deja_regle > 0 || $creditnoteamount > 0) - { - // Already payed - $index++; - $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPayed"), 0, 'L', 0); - $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); + { + // Already payed + $index++; + $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPayed"), 0, 'L', 0); + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); - // Credit note + // Credit note if ($creditnoteamount) { - $index++; - $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0); - $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount), 0, 'R', 0); + $index++; + $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0); + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount), 0, 'R', 0); } $resteapayer = $object->total_ttc - $deja_regle - $creditnoteamount; @@ -817,103 +809,103 @@ class pdf_crabe extends ModelePDFFactures // Escompte if ($object->close_code == 'discount_vat') { - $index++; - $pdf->SetFillColor(255,255,255); + $index++; + $pdf->SetFillColor(255,255,255); - $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1); - $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle), $useborder, 'R', 1); + $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("EscompteOffered"), $useborder, 'L', 1); + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle), $useborder, 'R', 1); $resteapayer=0; } - $index++; + $index++; $pdf->SetTextColor(0,0,60); - $pdf->SetFillColor(224,224,224); - $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); - $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); + $pdf->SetFillColor(224,224,224); + $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 1); + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($resteapayer), $useborder, 'R', 1); // Fin - $pdf->SetFont('Arial','', 9); - $pdf->SetTextColor(0,0,0); - } + $pdf->SetFont('Arial','', 9); + $pdf->SetTextColor(0,0,0); + } - $index++; - return ($tab2_top + ($tab2_hl * $index)); - } + $index++; + return ($tab2_top + ($tab2_hl * $index)); + } - /** - * \brief Affiche la grille des lignes de factures - * \param pdf objet PDF - */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) - { - global $conf; + /** + * \brief Affiche la grille des lignes de factures + * \param pdf objet PDF + */ + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) + { + global $conf; - // Montants exprim�s en (en tab_top - 1) - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('Arial','',8); - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentities("Currency".$conf->monnaie)); - $pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre); + // Amount in (at tab_top - 1) + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('Arial','',8); + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie)); + $pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre); - $pdf->SetDrawColor(128,128,128); + $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 - $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); + // 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 + $pdf->line($this->marge_gauche, $tab_top+5, $this->page_largeur-$this->marge_droite, $tab_top+5); - $pdf->SetFont('Arial','',9); + $pdf->SetFont('Arial','',9); - $pdf->SetXY ($this->posxdesc-1, $tab_top+2); - $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); + $pdf->SetXY ($this->posxdesc-1, $tab_top+2); + $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); - $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); - $pdf->SetXY ($this->posxtva-1, $tab_top+2); - $pdf->MultiCell($this->posxup-$this->posxtva-1,2, $outputlangs->transnoentities("VAT"),'','C'); + $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); + $pdf->SetXY ($this->posxtva-1, $tab_top+2); + $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->SetXY ($this->posxup-1, $tab_top+2); - $pdf->MultiCell(18,2, $outputlangs->transnoentities("PriceUHT"),'','C'); + $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); + $pdf->SetXY ($this->posxup-1, $tab_top+2); + $pdf->MultiCell(18,2, $outputlangs->transnoentities("PriceUHT"),'','C'); - $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); - $pdf->SetXY ($this->posxqty-1, $tab_top+2); - $pdf->MultiCell($this->posxdiscount-$this->posxqty-1,2, $outputlangs->transnoentities("Qty"),'','C'); + $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); + $pdf->SetXY ($this->posxqty-1, $tab_top+2); + $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); - if ($this->atleastonediscount) - { - $pdf->SetXY ($this->posxdiscount-1, $tab_top+2); - $pdf->MultiCell(14,2, $outputlangs->transnoentities("ReductionShort"),'','C'); - } + $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); + if ($this->atleastonediscount) + { + $pdf->SetXY ($this->posxdiscount-1, $tab_top+2); + $pdf->MultiCell(14,2, $outputlangs->transnoentities("ReductionShort"),'','C'); + } - if ($this->atleastonediscount) - { - $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); - } - $pdf->SetXY ($this->postotalht-1, $tab_top+2); - $pdf->MultiCell(28,2, $outputlangs->transnoentities("TotalHT"),'','C'); + if ($this->atleastonediscount) + { + $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); + } + $pdf->SetXY ($this->postotalht-1, $tab_top+2); + $pdf->MultiCell(28,2, $outputlangs->transnoentities("TotalHT"),'','C'); - } + } - /** - * \brief Show header of page - * \param pdf Object PDF - * \param object Object invoice - * \param showadress 0=no, 1=yes - * \param outputlang Object lang for output - */ - function _pagehead(&$pdf, $object, $showadress=1, $outputlangs) - { + /** + * \brief Show header of page + * \param pdf Object PDF + * \param object Object invoice + * \param showadress 0=no, 1=yes + * \param outputlang Object lang for output + */ + function _pagehead(&$pdf, $object, $showadress=1, $outputlangs) + { global $conf,$langs; - $outputlangs->load("main"); - $outputlangs->load("bills"); - $outputlangs->load("propal"); - $outputlangs->load("companies"); + $outputlangs->load("main"); + $outputlangs->load("bills"); + $outputlangs->load("propal"); + $outputlangs->load("companies"); //Affiche le filigrane brouillon - Print Draft Watermark if($object->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) ) @@ -934,148 +926,148 @@ class pdf_crabe extends ModelePDFFactures } //Print content - $pdf->SetTextColor(0,0,60); - $pdf->SetFont('Arial','B',13); + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('Arial','B',13); - $posy=$this->marge_haute; + $posy=$this->marge_haute; - $pdf->SetXY($this->marge_gauche,$posy); + $pdf->SetXY($this->marge_gauche,$posy); // Logo - $logo=$conf->societe->dir_logos.'/'.$this->emetteur->logo; - if ($this->emetteur->logo) - { - if (is_readable($logo)) + $logo=$conf->societe->dir_logos.'/'.$this->emetteur->logo; + if ($this->emetteur->logo) + { + if (is_readable($logo)) { - $pdf->Image($logo, $this->marge_gauche, $posy, 0, 24); - } - else + $pdf->Image($logo, $this->marge_gauche, $posy, 0, 24); + } + else { - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } - } - else if (defined("FAC_PDF_INTITULE")) - { - $pdf->MultiCell(100, 4, FAC_PDF_INTITULE, 0, 'L'); - } + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('Arial','B',8); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + } + } + else if (defined("FAC_PDF_INTITULE")) + { + $pdf->MultiCell(100, 4, FAC_PDF_INTITULE, 0, 'L'); + } - $pdf->SetFont('Arial','B',13); - $pdf->SetXY(100,$posy); - $pdf->SetTextColor(0,0,60); - $title=$outputlangs->transnoentities("Invoice"); - if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement"); - if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir"); - $pdf->MultiCell(100, 4, $title, '' , 'R'); + $pdf->SetFont('Arial','B',13); + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $title=$outputlangs->transnoentities("Invoice"); + if ($object->type == 1) $title=$outputlangs->transnoentities("InvoiceReplacement"); + if ($object->type == 2) $title=$outputlangs->transnoentities("InvoiceAvoir"); + $pdf->MultiCell(100, 4, $title, '' , 'R'); - $pdf->SetFont('Arial','B',12); + $pdf->SetFont('Arial','B',12); - $posy+=6; - $pdf->SetXY(100,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); + $posy+=6; + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $outputlangs->convToOutputCharset($object->ref), '', 'R'); - $posy+=1; - $pdf->SetFont('Arial','',10); + $posy+=1; + $pdf->SetFont('Arial','',10); - $facidnext=$object->getIdReplacingInvoice('validated'); + $facidnext=$object->getIdReplacingInvoice('validated'); if ($object->type == 0 && $facidnext) - { + { $objectreplacing=new Facture($this->db); $objectreplacing->fetch($facidnext); - $posy+=5; - $pdf->SetXY(100,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R'); + $posy+=5; + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementByInvoice").' : '.$outputlangs->convToOutputCharset($objectreplacing->ref), '', 'R'); } - if ($object->type == 1) - { + if ($object->type == 1) + { $objectreplaced=new Facture($this->db); $objectreplaced->fetch($object->fk_facture_source); - $posy+=5; - $pdf->SetXY(100,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R'); + $posy+=5; + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("ReplacementInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R'); } - if ($object->type == 2) - { + if ($object->type == 2) + { $objectreplaced=new Facture($this->db); $objectreplaced->fetch($object->fk_facture_source); - $posy+=5; - $pdf->SetXY(100,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R'); + $posy+=5; + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("CorrectionInvoice").' : '.$outputlangs->convToOutputCharset($objectreplaced->ref), '', 'R'); } - $posy+=5; - $pdf->SetXY(100,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateInvoice")." : " . dolibarr_print_date($object->date,"day",false,$outpulangs), '', 'R'); + $posy+=5; + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateInvoice")." : " . dolibarr_print_date($object->date,"day",false,$outpulangs), '', 'R'); - if ($object->type != 2) - { - $posy+=5; - $pdf->SetXY(100,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEcheance")." : " . dolibarr_print_date($object->date_lim_reglement,"day",false,$outputlangs), '', 'R'); + if ($object->type != 2) + { + $posy+=5; + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEcheance")." : " . dolibarr_print_date($object->date_lim_reglement,"day",false,$outputlangs), '', 'R'); } - 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, $outputlangs->transnoentities("BillFrom").":"); + 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, $outputlangs->transnoentities("BillFrom").":"); - $pdf->SetXY($this->marge_gauche,$posy); - $pdf->SetFillColor(230,230,230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + $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); + $pdf->SetXY($this->marge_gauche+2,$posy+3); - // Nom emetteur - $pdf->SetTextColor(0,0,60); - $pdf->SetFont('Arial','B',11); + // Nom emetteur + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('Arial','B',11); $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($this->emetteur->nom), 0, 'L'); - // Caracteristiques emetteur - $carac_emetteur = ''; - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->adresse); - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->cp).' '.$outputlangs->convToOutputCharset($this->emetteur->ville); - $carac_emetteur .= "\n"; - // Tel - if ($this->emetteur->tel) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".$outputlangs->convToOutputCharset($this->emetteur->tel); - // Fax - if ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($this->emetteur->fax); - // EMail - if ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($this->emetteur->email); - // Web - if ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($this->emetteur->url); + // Caracteristiques emetteur + $carac_emetteur = ''; + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->adresse); + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($this->emetteur->cp).' '.$outputlangs->convToOutputCharset($this->emetteur->ville); + $carac_emetteur .= "\n"; + // Tel + if ($this->emetteur->tel) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".$outputlangs->convToOutputCharset($this->emetteur->tel); + // Fax + if ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$outputlangs->convToOutputCharset($this->emetteur->fax); + // EMail + if ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$outputlangs->convToOutputCharset($this->emetteur->email); + // Web + if ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$outputlangs->convToOutputCharset($this->emetteur->url); - $pdf->SetFont('Arial','',9); - $pdf->SetXY($this->marge_gauche+2,$posy+8); - $pdf->MultiCell(80,3, $carac_emetteur); + $pdf->SetFont('Arial','',9); + $pdf->SetXY($this->marge_gauche+2,$posy+8); + $pdf->MultiCell(80,3, $carac_emetteur); - // Client destinataire - $posy=42; - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('Arial','',8); - $pdf->SetXY(102,$posy-5); - $pdf->MultiCell(80,5, $outputlangs->transnoentities("BillTo").":"); - $object->fetch_client(); + // Client destinataire + $posy=42; + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('Arial','',8); + $pdf->SetXY(102,$posy-5); + $pdf->MultiCell(80,5, $outputlangs->transnoentities("BillTo").":"); + $object->fetch_client(); - // Cadre client destinataire - $pdf->rect(100, $posy, 100, $hautcadre); + // Cadre client destinataire + $pdf->rect(100, $posy, 100, $hautcadre); // If BILLING contact defined on invoice, we use it @@ -1091,13 +1083,10 @@ class pdf_crabe extends ModelePDFFactures } if ($usecontact) { - // Nom societe - $pdf->SetXY(102,$posy+3); - $pdf->SetFont('Arial','B',11); - // On peut utiliser le nom de la societe du contact facturation + // On peut utiliser le nom de la societe du contact if ($conf->global->FACTURE_USE_COMPANY_NAME_OF_BILL_CONTACT) $socname = $object->contact->socname; else $socname = $object->client->nom; - $pdf->MultiCell(96,4, $outputlangs->convToOutputCharset($socname), 0, 'L'); + $carac_client_name=$outputlangs->convToOutputCharset($socname); // Customer name $carac_client = "\n".$object->contact->getFullName($outputlangs,1,1); @@ -1114,9 +1103,7 @@ class pdf_crabe extends ModelePDFFactures else { // Nom client - $pdf->SetXY(102,$posy+3); - $pdf->SetFont('Arial','B',11); - $pdf->MultiCell(96,4, $outputlangs->convToOutputCharset($object->client->nom), 0, 'L'); + $carac_client_name=$outputlangs->convToOutputCharset($object->client->nom); // Nom du contact facturation si c'est une societe $arrayidcontact = $object->getIdContact('external','BILLING'); @@ -1134,32 +1121,38 @@ class pdf_crabe extends ModelePDFFactures $carac_client.="\n".$outputlangs->convToOutputCharset($object->client->adresse); $carac_client.="\n".$outputlangs->convToOutputCharset($object->client->cp) . " " . $outputlangs->convToOutputCharset($object->client->ville)."\n"; - //Pays si different de l'emetteur - if ($this->emetteur->pays_code != $object->client->pays_code) - { - $carac_client.=$outputlangs->convToOutputCharset($object->client->pays)."\n"; - } + //Pays si different de l'emetteur + if ($this->emetteur->pays_code != $object->client->pays_code) + { + $carac_client.=$outputlangs->convToOutputCharset($object->client->pays)."\n"; + } } // Numero TVA intracom if ($object->client->tva_intra) $carac_client.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($object->client->tva_intra); - $pdf->SetFont('Arial','',9); + + // Show customer/recipient + $pdf->SetXY(102,$posy+3); + $pdf->SetFont('Arial','B',11); + $pdf->MultiCell(96,4, $carac_client_name, 0, 'L'); + + $pdf->SetFont('Arial','',9); $posy=$pdf->GetY()-9; //Auto Y coord readjust for multiline name $pdf->SetXY(102,$posy+6); $pdf->MultiCell(86,4, $carac_client); } } - /** - * \brief Show footer of page - * \param pdf Object PDF - * \param object Object invoice - * \param outputlang Object lang for output - * \remarks Need this->emetteur object - */ - function _pagefoot(&$pdf,$object,$outputlangs) - { + /** + * \brief Show footer of page + * \param pdf Object PDF + * \param object Object invoice + * \param outputlang Object lang for output + * \remarks Need this->emetteur object + */ + function _pagefoot(&$pdf,$object,$outputlangs) + { return pdf_pagefoot($pdf,$outputlangs,'FACTURE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); - } + } } diff --git a/htdocs/includes/modules/facture/pdf_huitre.modules.php b/htdocs/includes/modules/facture/pdf_huitre.modules.php index b390d203e5b..215b12f393e 100644 --- a/htdocs/includes/modules/facture/pdf_huitre.modules.php +++ b/htdocs/includes/modules/facture/pdf_huitre.modules.php @@ -583,7 +583,7 @@ class pdf_huitre extends ModelePDFFactures // Montants exprimes en euros $pdf->SetTextColor(0,0,0); $pdf->SetFont('Arial','',10); - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentities("Currency".$conf->monnaie)); + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie)); $pdf->Text(200 - $pdf->GetStringWidth($titre), 94, $titre); } diff --git a/htdocs/includes/modules/facture/pdf_oursin.modules.php b/htdocs/includes/modules/facture/pdf_oursin.modules.php index d5d9f3a906d..94d223ec263 100644 --- a/htdocs/includes/modules/facture/pdf_oursin.modules.php +++ b/htdocs/includes/modules/facture/pdf_oursin.modules.php @@ -1,8 +1,8 @@ +/* Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005 Sylvain SCATTOLINI * Copyright (C) 2006 Rodolphe Quiedeville - * Copyright (C) 2008 Raphael Bertrand (Resultic) + * Copyright (C) 2008 Raphael Bertrand (Resultic) * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -70,12 +70,12 @@ class pdf_oursin extends ModelePDFFactures $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION - $this->option_modereg = 1; // Gere choix mode r�glement FACTURE_CHQ_NUMBER, FACTURE_RIB_NUMBER - $this->option_condreg = 1; // Affiche conditions r�glement + $this->option_modereg = 1; // Gere choix mode reglement FACTURE_CHQ_NUMBER, FACTURE_RIB_NUMBER + $this->option_condreg = 1; // Affiche conditions reglement $this->option_codeproduitservice = 1; // Affiche code produit-service $this->option_multilang = 1; // Dispo en plusieurs langues $this->option_escompte = 0; // Affiche si il y a eu escompte - $this->option_credit_note = 1; // G�re les avoirs + $this->option_credit_note = 1; // Gere les avoirs $this->option_draft_watermark = 1; //Support add of a watermark on drafts if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise') @@ -88,8 +88,8 @@ class pdf_oursin extends ModelePDFFactures /** - * \brief Fonction g�n�rant la facture sur le disque - * \param fac Objet facture � g�n�rer (ou id si ancienne methode) + * \brief Fonction generant la facture sur le disque + * \param fac Objet facture a generer (ou id si ancienne methode) * \param outputlangs Lang object for output language * \return int 1=ok, 0=ko */ @@ -110,7 +110,7 @@ class pdf_oursin extends ModelePDFFactures if ($conf->facture->dir_output) { - // D�finition de l'objet $fac (pour compatibilite ascendante) + // Definition de l'objet $fac (pour compatibilite ascendante) if (! is_object($fac)) { $id = $fac; @@ -189,29 +189,71 @@ class pdf_oursin extends ModelePDFFactures $nexY = $pdf->GetY(); $nblignes = sizeof($fac->lignes); - // Boucle sur les lignes de factures + // Loop on each lines for ($i = 0 ; $i < $nblignes ; $i++) { $curY = $nexY; - // Description produit - $codeproduitservice=""; - $pdf->SetXY ($this->marges['g']+ 1, $curY ); - if (defined("FACTURE_CODEPRODUITSERVICE") && FACTURE_CODEPRODUITSERVICE) { - // Affiche code produit si ligne associ�e � un code produit + // Description of product line + $libelleproduitservice=dol_htmlentitiesbr($fac->lignes[$i]->libelle,1); + if ($fac->lignes[$i]->desc && $fac->lignes[$i]->desc != $fac->lignes[$i]->libelle) + { + if ($libelleproduitservice) $libelleproduitservice.="
"; - $prodser = new Product($this->db); - - $prodser->fetch($fac->lignes[$i]->produit_id); - if ($prodser->ref) { - $codeproduitservice=" - ".$outputlangs->transnoentities("ProductCode")." ".$prodser->ref; + if ($fac->lignes[$i]->desc == '(CREDIT_NOTE)' && $fac->lignes[$i]->fk_remise_except) + { + $discount=new DiscountAbsolute($this->db); + $discount->fetch($fac->lignes[$i]->fk_remise_except); + $libelleproduitservice=dol_htmlentitiesbr($langs->trans("DiscountFromCreditNote",$discount->ref_facture_source),1); + } + else + { + if ($fac->lignes[$i]->produit_id) + { + $libelleproduitservice.=dol_htmlentitiesbr($fac->lignes[$i]->desc,1); + } + else + { + //$fac->lignes[$i]->desc='�zaaaa'; + //print dol_string_is_good_iso($fac->lignes[$i]->desc); + //print dol_htmlentitiesbr($fac->lignes[$i]->desc); + //print exit; + $libelleproduitservice.=dol_htmlentitiesbr($fac->lignes[$i]->desc,1); + } } } - if ($fac->lignes[$i]->date_start && $fac->lignes[$i]->date_end) { - // Affichage dur�e si il y en a une - $codeproduitservice.=" (".$outputlangs->transnoentities("From")." ".dolibarr_print_date($fac->lignes[$i]->date_start,'',false,$outputlangs)." ".$langs->transnoentities("to")." ".dolibarr_print_date($fac->lignes[$i]->date_end,'',false,$outputlangs).")"; + + // Si ligne associee a un code produit + if ($fac->lignes[$i]->produit_id) + { + $prodser = new Product($this->db); + $prodser->fetch($fac->lignes[$i]->produit_id); + // On ajoute la ref + if ($prodser->ref) + { + $prefix_prodserv = ""; + if($prodser->isservice()) + { + $prefix_prodserv = $outputlangs->transnoentities("Service")." "; + } + else + { + $prefix_prodserv = $outputlangs->transnoentities("Product")." "; + } + + $libelleproduitservice=$prefix_prodserv.$prodser->ref." - ".$libelleproduitservice; + } + } - $pdf->MultiCell(108, 5, $outputlangs->convToOutputCharset($fac->lignes[$i]->desc).$codeproduitservice, 0, 'J'); + + if ($fac->lignes[$i]->date_start && $fac->lignes[$i]->date_end) + { + // Affichage duree si il y en a une + $libelleproduitservice.="
".dol_htmlentitiesbr("(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($fac->lignes[$i]->date_start,'',false,$outputlangs)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($fac->lignes[$i]->date_end,'',false,$outputlangs).")",1); + } + //if ($i==0) { print $libelleproduitservice; exit; } + + $pdf->writeHTMLCell(108, 3, $this->posxdesc-1, $curY, $outputlangs->convToOutputCharset($libelleproduitservice), 0, 1); $nexY = $pdf->GetY(); @@ -253,8 +295,13 @@ class pdf_oursin extends ModelePDFFactures } $posy=$this->_tableau($pdf, $tab_top, $tab_height, $nexY, $fac, $outputlangs); + $bottomlasttab=$tab_top + $tab_height + 1; - $posy=$this->_tableau_tot($pdf, $fac, $deja_regle, $outputlangs); + // Affiche zone infos + $posy=$this->_tableau_info($pdf, $fac, $bottomlasttab, $outputlangs); + + // Affiche zone totaux + $posy=$this->_tableau_tot($pdf, $fac, $deja_regle, $bottomlasttab, $outputlangs); // Affiche zone versements if ($deja_regle || $amount_credit_not_included) @@ -262,61 +309,6 @@ class pdf_oursin extends ModelePDFFactures $posy=$this->_tableau_versements($pdf, $fac, $posy, $outputlangs); } - // Mode de r�glement - if ((! defined("FACTURE_CHQ_NUMBER") || ! FACTURE_CHQ_NUMBER) && (! defined("FACTURE_RIB_NUMBER") || ! FACTURE_RIB_NUMBER)) { - $pdf->SetXY ($this->marges['g'], 228); - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorCreateBankAccount"),0,'L',0); - $pdf->SetTextColor(0,0,0); - } - - // Propose mode reglement par CHQ - if (defined("FACTURE_CHQ_NUMBER")) - { - if (FACTURE_CHQ_NUMBER > 0) - { - $account = new Account($this->db); - $account->fetch(FACTURE_CHQ_NUMBER); - - $pdf->SetXY ($this->marges['g'], 225); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo').' '.$account->proprio.' '.$langs->transnoentities('SendTo').':',0,'L',0); - $pdf->SetXY ($this->marges['g'], 230); - $pdf->SetFont('Arial','',8); - $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0); - } - } - - // Propose mode reglement par RIB - if (defined("FACTURE_RIB_NUMBER")) - { - if (FACTURE_RIB_NUMBER > 0) - { - $account = new Account($this->db); - $account->fetch(FACTURE_RIB_NUMBER); - - $cury=240; - $curx=$this->marges['g']; - - $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account); - } - } - - // Conditions de reglements - if ($fac->cond_reglement_code) - { - $pdf->SetFont('Arial','B',10); - $pdf->SetXY($this->marges['g'], 217); - $titre = $outputlangs->transnoentities("PaymentConditions").':'; - $pdf->MultiCell(80, 5, $titre, 0, 'L'); - $pdf->SetFont('Arial','',10); - $pdf->SetXY($this->marges['g']+44, 217); - $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$fac->cond_reglement_code)!=('PaymentCondition'.$fac->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$fac->cond_reglement_code):$outputlangs->convToOutputCharset($fac->cond_reglement); - $pdf->MultiCell(80, 5, $lib_condition_paiement,0,'L'); - } - // Pied de page $this->_pagefoot($pdf, $fac, $outputlangs); $pdf->AliasNbPages(); @@ -484,13 +476,146 @@ class pdf_oursin extends ModelePDFFactures } - /* + /** + * \brief Affiche infos divers + * \param pdf Objet PDF + * \param object Objet facture + * \param posy Position depart + * \param outputlangs Objet langs + * \return y Position pour suite + */ + function _tableau_info(&$pdf, $object, $posy, $outputlangs) + { + global $conf; + + $pdf->SetFont('Arial','', 9); + + // If France, show VAT mention if not applicable + if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1) + { + $pdf->SetFont('Arial','B',8); + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); + + $posy=$pdf->GetY()+4; + } + + // Show payments conditions + if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) + { + $pdf->SetFont('Arial','B',8); + $pdf->SetXY($this->marge_gauche, $posy); + $titre = $outputlangs->transnoentities("PaymentConditions").':'; + $pdf->MultiCell(80, 5, $titre, 0, 'L'); + + $pdf->SetFont('Arial','',8); + $pdf->SetXY(50, $posy); + $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code)!=('PaymentCondition'.$object->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$object->cond_reglement_code):$outputlangs->convToOutputCharset($object->cond_reglement); + $pdf->MultiCell(80, 5, $lib_condition_paiement,0,'L'); + + $posy=$pdf->GetY()+3; + } + + + if ($object->type != 2) + { + // Check a payment mode is defined + if (empty($object->mode_reglement_code) + && ! $conf->global->FACTURE_CHQ_NUMBER + && ! $conf->global->FACTURE_RIB_NUMBER) + { + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('Arial','B',8); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0); + $pdf->SetTextColor(0,0,0); + + $posy=$pdf->GetY()+1; + } + + // Sown payment mode + if ($object->mode_reglement_code + && $object->mode_reglement_code != 'CHQ' + && $object->mode_reglement_code != 'VIR') + { + $pdf->SetFont('Arial','B',8); + $pdf->SetXY($this->marge_gauche, $posy); + $titre = $outputlangs->transnoentities("PaymentMode").':'; + $pdf->MultiCell(80, 5, $titre, 0, 'L'); + + $pdf->SetFont('Arial','',8); + $pdf->SetXY(50, $posy); + $lib_mode_reg=$outputlangs->transnoentities("PaymentMode".$object->mode_reglement_code)!=('PaymentMode'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentMode".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); + $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); + + $posy=$pdf->GetY()+2; + } + + // Show payment mode CHQ + if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') + { + // Si mode reglement non force ou si force a CHQ + if ($conf->global->FACTURE_CHQ_NUMBER) + { + if ($conf->global->FACTURE_CHQ_NUMBER > 0) + { + $account = new Account($this->db); + $account->fetch($conf->global->FACTURE_CHQ_NUMBER); + + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('Arial','B',8); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$outputlangs->convToOutputCharset($account->proprio)).':',0,'L',0); + $posy=$pdf->GetY()+1; + + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('Arial','',8); + $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0); + $posy=$pdf->GetY()+2; + } + if ($conf->global->FACTURE_CHQ_NUMBER == -1) + { + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('Arial','B',8); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedToShort').' '.$outputlangs->convToOutputCharset($this->emetteur->nom).' '.$outputlangs->transnoentities('SendTo').':',0,'L',0); + $posy=$pdf->GetY()+1; + + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('Arial','',8); + $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->adresse_full), 0, 'L', 0); + $posy=$pdf->GetY()+2; + } + } + } + + // If payment mode not forced or forced to VIR, show payment with BAN + if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') + { + if (! empty($conf->global->FACTURE_RIB_NUMBER)) + { + $account = new Account($this->db); + $account->fetch($conf->global->FACTURE_RIB_NUMBER); + + $curx=$this->marge_gauche; + $cury=$posy; + + $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account); + + $posy+=2; + } + } + } + + return $posy; + } + + + /** * \brief Affiche le total � payer * \param pdf objet PDF * \param fac objet facture * \param deja_regle montant deja regle */ - function _tableau_tot(&$pdf, $fac, $deja_regle, $outputlangs) + function _tableau_tot(&$pdf, $fac, $deja_regle, $posy, $outputlangs) { global $langs; $langs->load("main"); @@ -537,47 +662,47 @@ class pdf_oursin extends ModelePDFFactures $pdf->MultiCell(26, $tab2_hl, price($fac->total_ttc), 0, 'R', 0); $pdf->SetTextColor(0,0,0); - $creditnoteamount=$fac->getSommeCreditNote(); + $creditnoteamount=$fac->getSommeCreditNote(); $resteapayer = $fac->total_ttc - $deja_regle - $creditnoteamount; if ($object->paye) $resteapayer=0; if ($deja_regle > 0 || $creditnoteamount > 0) - { + { $pdf->SetFont('Arial','', 10); // Already payed - $index++; + $index++; $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPayed"), 0, 'L', 0); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell(26, $tab2_hl, price($deja_regle), 0, 'R', 0); - // Credit note + // Credit note if ($creditnoteamount) { - $index++; - $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0); - $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount), 0, 'R', 0); + $index++; + $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("CreditNotes"), 0, 'L', 0); + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($creditnoteamount), 0, 'R', 0); } $resteapayer = $object->total_ttc - $deja_regle - $creditnoteamount; if ($object->paye) $resteapayer=0; - $index++; + $index++; $pdf->SetTextColor(0,0,60); - $pdf->SetFont('Arial','B', 11); + $pdf->SetFont('Arial','B', 11); $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), 0, 'L', 0); - $pdf->SetFillColor(224,224,224); + $pdf->SetFillColor(224,224,224); $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); $pdf->MultiCell(26, $tab2_hl, price($fac->total_ttc - $deja_regle), 0, 'R', 0); $pdf->SetTextColor(0,0,0); } - $index++; - return ($tab2_top + ($tab2_hl * $index)); + $index++; + return ($tab2_top + ($tab2_hl * $index)); } /* @@ -605,13 +730,15 @@ class pdf_oursin extends ModelePDFFactures for ($i = 0 ; $i < $nblignes ; $i++) if ($fac->lignes[$i]->remise_percent) { - $rem=1; + $rem=1; } if ($rem==1) { $pdf->Text($this->marges['g']+163, $tab_top + 5,$outputlangs->transnoentities("Note")); } $pdf->Text($this->marges['g']+175, $tab_top + 5, $outputlangs->transnoentities("TotalHT")); + + return $pdf->GetY(); } /* @@ -656,18 +783,18 @@ class pdf_oursin extends ModelePDFFactures if ($this->emetteur->logo) { if (is_readable($logo)) - { - $taille=getimagesize($logo); - $longueur=$taille[0]/2.835; - $pdf->Image($logo, $this->marges['g'], $this->marges['h'], 0, 24); - } - else - { - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(80, 3, $langs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); - $pdf->MultiCell(80, 3, $langs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); - } + { + $taille=getimagesize($logo); + $longueur=$taille[0]/2.835; + $pdf->Image($logo, $this->marges['g'], $this->marges['h'], 0, 24); + } + else + { + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('Arial','B',8); + $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorLogoFileNotFound",$logo), 0, 'L'); + $pdf->MultiCell(80, 3, $outputlangs->transnoentities("ErrorGoToGlobalSetup"), 0, 'L'); + } } else if (defined("FAC_PDF_INTITULE")) { @@ -724,11 +851,76 @@ class pdf_oursin extends ModelePDFFactures $pdf->SetXY($this->marges['g']+100,$posy-5); $pdf->SetFont('Arial','B',11); $fac->fetch_client(); + + $object=$fac; + + // If BILLING contact defined on invoice, we use it + $usecontact=false; + if ($conf->global->FACTURE_USE_BILL_CONTACT_AS_RECIPIENT) + { + $arrayidcontact=$object->getIdContact('external','BILLING'); + if (sizeof($arrayidcontact) > 0) + { + $usecontact=true; + $result=$object->fetch_contact($arrayidcontact[0]); + } + } + if ($usecontact) + { + // On peut utiliser le nom de la societe du contact facturation + if ($conf->global->FACTURE_USE_COMPANY_NAME_OF_BILL_CONTACT) $socname = $object->contact->socname; + else $socname = $object->client->nom; + $carac_client_name=$outputlangs->convToOutputCharset($socname); + + // Customer name + $carac_client = "\n".$object->contact->getFullName($outputlangs,1,1); + + // Customer properties + $carac_client.="\n".$outputlangs->convToOutputCharset($object->contact->address); + $carac_client.="\n".$outputlangs->convToOutputCharset($object->contact->cp) . " " . $outputlangs->convToOutputCharset($object->contact->ville)."\n"; + //Pays si different de l'emetteur + if ($this->emetteur->pays_code != $object->contact->pays_code) + { + $carac_client.=$outputlangs->convToOutputCharset($object->contact->pays)."\n"; + } + } + else + { + // Nom client + $carac_client_name=$outputlangs->convToOutputCharset($object->client->nom); + + // Nom du contact facturation si c'est une societe + $arrayidcontact = $object->getIdContact('external','BILLING'); + if (sizeof($arrayidcontact) > 0) + { + $object->fetch_contact($arrayidcontact[0]); + // On verifie si c'est une societe ou un particulier + if( !preg_match('#'.$object->contact->getFullName($outputlangs,1).'#isU',$object->client->nom) ) + { + $carac_client .= "\n".$object->contact->getFullName($outputlangs,1,1); + } + } + + // Caracteristiques client + $carac_client.="\n".$outputlangs->convToOutputCharset($object->client->adresse); + $carac_client.="\n".$outputlangs->convToOutputCharset($object->client->cp) . " " . $outputlangs->convToOutputCharset($object->client->ville)."\n"; + + //Pays si different de l'emetteur + if ($this->emetteur->pays_code != $object->client->pays_code) + { + $carac_client.=$outputlangs->convToOutputCharset($object->client->pays)."\n"; + } + } + // Numero TVA intracom + if ($object->client->tva_intra) $carac_client.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($object->client->tva_intra); + + // Show customer/recipient + $pdf->SetFont('Arial','B',11); $pdf->SetXY($this->marges['g']+100,$posy+4); - $pdf->MultiCell(86,4, $outputlangs->transnoentities($fac->client->nom), 0, 'L'); + $pdf->MultiCell(86,4, $carac_client_name, 0, 'L'); $pdf->SetFont('Arial','B',10); $pdf->SetXY($this->marges['g']+100,$posy+12); - $pdf->MultiCell(86,4, $outputlangs->transnoentities($fac->client->adresse) . "\n\n" . $outputlangs->transnoentities($fac->client->cp) . " " . $outputlangs->transnoentities($fac->client->ville)); + $pdf->MultiCell(86,4, $carac_client); /* * ref facture @@ -773,16 +965,11 @@ class pdf_oursin extends ModelePDFFactures } } - /* - * monnaie - */ + // Amount in (at tab_top - 1) $pdf->SetTextColor(0,0,0); $pdf->SetFont('Arial','',10); - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentities("Currency".$conf->monnaie)); + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie)); $pdf->Text(200 - $pdf->GetStringWidth($titre), 94, $titre); - /* - */ - } /* diff --git a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php index a78badbf9d9..29c3054960c 100644 --- a/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php +++ b/htdocs/includes/modules/livraison/pdf/pdf_sirocco.modules.php @@ -298,7 +298,7 @@ class pdf_sirocco extends ModelePDFDeliveryOrder $pdf->SetTextColor(0,0,0); $pdf->SetFont('Arial','',10); - // $titre = $langs->transnoentities("AmountInCurrency",$langs->transnoentities("Currency".$conf->monnaie)); + // $titre = $langs->transnoentities("AmountInCurrency",$langs->transnoentitiesnoconv("Currency".$conf->monnaie)); // $pdf->Text(200 - $pdf->GetStringWidth($titre), 98, $titre); } diff --git a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php index f7293a62050..2a80d1e5aa4 100644 --- a/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php +++ b/htdocs/includes/modules/livraison/pdf/pdf_typhon.modules.php @@ -351,7 +351,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder // Montants exprimes en (en tab_top - 1) $pdf->SetTextColor(0,0,0); $pdf->SetFont('Arial','',8); - //$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentities("Currency".$conf->monnaie)); + //$titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie)); //$pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre); $pdf->SetDrawColor(128,128,128); diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php index ca47d18e86a..6e7f1c3940f 100644 --- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php @@ -438,10 +438,10 @@ class pdf_propale_azur extends ModelePDFPropales } - /* + /** * \brief Affiche infos divers * \param pdf Objet PDF - * \param object Objet propale + * \param object Objet facture * \param posy Position depart * \param outputlangs Objet langs * \return y Position pour suite @@ -452,9 +452,7 @@ class pdf_propale_azur extends ModelePDFPropales $pdf->SetFont('Arial','', 9); - /* - * If France, show VAT mention if not applicable - */ + // If France, show VAT mention if not applicable if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1) { $pdf->SetFont('Arial','B',8); @@ -464,10 +462,8 @@ class pdf_propale_azur extends ModelePDFPropales $posy=$pdf->GetY()+4; } - /* - * Conditions de reglements - */ - if ($object->cond_reglement_code || $object->cond_reglement) + // Show payments conditions + if ($object->type != 2 && ($object->cond_reglement_code || $object->cond_reglement)) { $pdf->SetFont('Arial','B',8); $pdf->SetXY($this->marge_gauche, $posy); @@ -482,79 +478,90 @@ class pdf_propale_azur extends ModelePDFPropales $posy=$pdf->GetY()+3; } - /* - * Check si absence mode reglement - */ - if (! $conf->global->FACTURE_CHQ_NUMBER && ! $conf->global->FACTURE_RIB_NUMBER) - { - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0); - $pdf->SetTextColor(0,0,0); - $posy=$pdf->GetY()+1; - } - - /* - * Propose mode reglement par CHQ - */ - if (! $object->mode_reglement_code || $object->mode_reglement_code == 'CHQ') + if ($object->type != 2) { - // Si mode reglement non force ou si force a CHQ - if ($conf->global->FACTURE_CHQ_NUMBER) + // Check a payment mode is defined + if (empty($object->mode_reglement_code) + && ! $conf->global->FACTURE_CHQ_NUMBER + && ! $conf->global->FACTURE_RIB_NUMBER) { - if ($conf->global->FACTURE_CHQ_NUMBER > 0) + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('Arial','B',8); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities("ErrorNoPaiementModeConfigured"),0,'L',0); + $pdf->SetTextColor(0,0,0); + + $posy=$pdf->GetY()+1; + } + + // Sown payment mode + if ($object->mode_reglement_code + && $object->mode_reglement_code != 'CHQ' + && $object->mode_reglement_code != 'VIR') + { + $pdf->SetFont('Arial','B',8); + $pdf->SetXY($this->marge_gauche, $posy); + $titre = $outputlangs->transnoentities("PaymentMode").':'; + $pdf->MultiCell(80, 5, $titre, 0, 'L'); + $pdf->SetFont('Arial','',8); + $pdf->SetXY(50, $posy); + $lib_mode_reg=$outputlangs->transnoentities("PaymentMode".$object->mode_reglement_code)!=('PaymentMode'.$object->mode_reglement_code)?$outputlangs->transnoentities("PaymentMode".$object->mode_reglement_code):$outputlangs->convToOutputCharset($object->mode_reglement); + $pdf->MultiCell(80, 5, $lib_mode_reg,0,'L'); + + $posy=$pdf->GetY()+2; + } + + // Show payment mode CHQ + if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'CHQ') + { + // Si mode reglement non force ou si force a CHQ + if ($conf->global->FACTURE_CHQ_NUMBER) { - $account = new Account($this->db); - $account->fetch($conf->global->FACTURE_CHQ_NUMBER); + if ($conf->global->FACTURE_CHQ_NUMBER > 0) + { + $account = new Account($this->db); + $account->fetch($conf->global->FACTURE_CHQ_NUMBER); - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$outputlangs->convToOutputCharset($account->proprio)).':',0,'L',0); - $posy=$pdf->GetY()+1; + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('Arial','B',8); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$outputlangs->convToOutputCharset($account->proprio)).':',0,'L',0); + $posy=$pdf->GetY()+1; - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('Arial','',8); - $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0); + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('Arial','',8); + $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($account->adresse_proprio), 0, 'L', 0); + $posy=$pdf->GetY()+2; + } + if ($conf->global->FACTURE_CHQ_NUMBER == -1) + { + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('Arial','B',8); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedToShort').' '.$outputlangs->convToOutputCharset($this->emetteur->nom).' '.$outputlangs->transnoentities('SendTo').':',0,'L',0); + $posy=$pdf->GetY()+1; - $posy=$pdf->GetY()+2; - } - if ($conf->global->FACTURE_CHQ_NUMBER == -1) - { - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedToShort').' '.$outputlangs->convToOutputCharset($this->emetteur->nom).' '.$outputlangs->transnoentities('SendTo').':',0,'L',0); - $posy=$pdf->GetY()+1; - - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('Arial','',8); - $pdf->MultiCell(80, 6, $outputlangs->convToOutputCharset($this->emetteur->adresse_full), 0, 'L', 0); - - $posy=$pdf->GetY()+2; + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('Arial','',8); + $pdf->MultiCell(80, 3, $outputlangs->convToOutputCharset($this->emetteur->adresse_full), 0, 'L', 0); + $posy=$pdf->GetY()+2; + } } } - } - /* - * Propose mode reglement par RIB - */ - if (! $object->mode_reglement_code || $object->mode_reglement_code == 'VIR') - { - // Si mode reglement non force ou si force a VIR - if ($conf->global->FACTURE_RIB_NUMBER) + // If payment mode not forced or forced to VIR, show payment with BAN + if (empty($object->mode_reglement_code) || $object->mode_reglement_code == 'VIR') { - if ($conf->global->FACTURE_RIB_NUMBER) + if (! empty($conf->global->FACTURE_RIB_NUMBER)) { $account = new Account($this->db); $account->fetch($conf->global->FACTURE_RIB_NUMBER); - $curx=$this->marge_gauche; - $cury=$posy; + $curx=$this->marge_gauche; + $cury=$posy; - $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account); + $posy=pdf_bank($pdf,$outputlangs,$curx,$cury,$account); - $posy+=2; + $posy+=2; } } } @@ -580,7 +587,7 @@ class pdf_propale_azur extends ModelePDFPropales $pdf->SetFont('Arial','', 9); // Tableau total - $lltot = 200; $col1x = 120; $col2x = 182; $largcol2 = $lltot - $col2x; + $lltot = 200; $col1x = 120; $col2x = 170; $largcol2 = $lltot - $col2x; // Total HT $pdf->SetFillColor(255,255,255); @@ -695,7 +702,7 @@ class pdf_propale_azur extends ModelePDFPropales // Montants exprimés en (en tab_top - 1) $pdf->SetTextColor(0,0,0); $pdf->SetFont('Arial','',8); - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentities("Currency".$conf->monnaie)); + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie)); $pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre); $pdf->SetDrawColor(128,128,128); @@ -894,10 +901,10 @@ class pdf_propale_azur extends ModelePDFPropales } if ($usecontact) { - // Nom societe - $pdf->SetXY(102,$posy+3); - $pdf->SetFont('Arial','B',11); - $pdf->MultiCell(96,4, $outputlangs->convToOutputCharset($object->client->nom), 0, 'L'); + // On peut utiliser le nom de la societe du contact + if ($conf->global->PROPALE_USE_COMPANY_NAME_OF_CUSTOMER_CONTACT) $socname = $object->contact->socname; + else $socname = $object->client->nom; + $carac_client_name=$outputlangs->convToOutputCharset($socname); // Nom client $carac_client = "\n".$object->contact->getFullName($outputlangs,1,1); @@ -914,9 +921,7 @@ class pdf_propale_azur extends ModelePDFPropales else { // Nom client - $pdf->SetXY(102,$posy+3); - $pdf->SetFont('Arial','B',11); - $pdf->MultiCell(96,4, $outputlangs->convToOutputCharset($object->client->nom), 0, 'L'); + $carac_client_name=$outputlangs->convToOutputCharset($object->client->nom); // Nom du contact suivi propal si c'est une société $arrayidcontact = $object->getIdContact('external','CUSTOMER'); @@ -942,6 +947,12 @@ class pdf_propale_azur extends ModelePDFPropales } // Numéro TVA intracom if ($object->client->tva_intra) $carac_client.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$object->client->tva_intra; + + // Show customer/recipient + $pdf->SetXY(102,$posy+3); + $pdf->SetFont('Arial','B',11); + $pdf->MultiCell(96,4, $carac_client_name, 0, 'L'); + $pdf->SetFont('Arial','',9); $posy=$pdf->GetY()-9; //Auto Y coord readjust for multiline name $pdf->SetXY(102,$posy+6); diff --git a/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php b/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php index 6dca4807a06..3a8463386c1 100644 --- a/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php +++ b/htdocs/includes/modules/supplier_order/pdf/pdf_muscadet.modules.php @@ -572,7 +572,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // Montants exprim�s en (en tab_top - 1 $pdf->SetTextColor(0,0,0); $pdf->SetFont('Arial','',8); - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentities("Currency".$conf->monnaie)); + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentitiesnoconv("Currency".$conf->monnaie)); $pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre); $pdf->SetDrawColor(128,128,128); @@ -690,7 +690,7 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $pdf->SetFont('Arial','B',11); $pdf->MultiCell(80, 4, $outputlangs->convToOutputCharset($mysoc->nom), 0, 'L'); - // Caract�ristiques emetteur + // Caracteristiques emetteur $carac_emetteur = ''; $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($mysoc->adresse); $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->convToOutputCharset($mysoc->cp).' '.$outputlangs->convToOutputCharset($mysoc->ville); @@ -723,17 +723,22 @@ class pdf_muscadet extends ModelePDFSuppliersOrders // 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, $outputlangs->convToOutputCharset($object->client->nom), 0, 'L'); + $carac_client_name = $outputlangs->convToOutputCharset($object->client->nom); - // Caract�ristiques client $carac_client=$outputlangs->convToOutputCharset($object->client->adresse); $carac_client.="\n".$outputlangs->convToOutputCharset($object->client->cp) . " " . $outputlangs->convToOutputCharset($object->client->ville)."\n"; + + // Numero TVA intracom if ($object->client->tva_intra) $carac_client.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$outputlangs->convToOutputCharset($object->client->tva_intra); + + // Show customer/recipient + $pdf->SetXY(102,$posy+3); + $pdf->SetFont('Arial','B',11); + $pdf->MultiCell(96,4, $carac_client_name, 0, 'L'); + $pdf->SetFont('Arial','',9); - $pdf->SetXY(102,$posy+8); + $posy=$pdf->GetY()-9; //Auto Y coord readjust for multiline name + $pdf->SetXY(102,$posy+6); $pdf->MultiCell(86,4, $carac_client); } } diff --git a/htdocs/lib/company.lib.php b/htdocs/lib/company.lib.php index d1295284375..3329b8c39f5 100644 --- a/htdocs/lib/company.lib.php +++ b/htdocs/lib/company.lib.php @@ -345,7 +345,7 @@ function show_actions_todo($conf,$langs,$db,$objsoc,$objcon='') $actionstatic=new ActionComm($db); $userstatic=new User($db); $contactstatic = new Contact($db); - + if (is_object($objcon) && $objcon->id) print_titre($langs->trans("TasksHistoryForThisContact")); else print_titre($langs->trans("ActionsOnCompany")); @@ -409,7 +409,7 @@ function show_actions_todo($conf,$langs,$db,$objsoc,$objcon='') $actionstatic->id=$obj->id; print ''.$actionstatic->getNomUrl(1,16).''; } - + print ''.$obj->label.''; // Contact pour cette action @@ -424,7 +424,7 @@ function show_actions_todo($conf,$langs,$db,$objsoc,$objcon='') { print ' '; } - + print ''; $userstatic->id=$obj->fk_user_author; $userstatic->login=$obj->login; @@ -441,7 +441,7 @@ function show_actions_todo($conf,$langs,$db,$objsoc,$objcon='') else { // Aucun action a faire - + } $db->free($result); } @@ -605,7 +605,7 @@ function show_actions_done($conf,$langs,$db,$objsoc,$objcon='') // Note print ''.dolibarr_trunc($histo[$key]['note'], 30).''; - + // Objet lie print ''; if ($histo[$key]['pid'] && $conf->propal->enabled) @@ -642,7 +642,7 @@ function show_actions_done($conf,$langs,$db,$objsoc,$objcon='') { print ' '; } - + // Auteur print ''; $userstatic->id=$histo[$key]['userid']; @@ -672,11 +672,11 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account) { $pdf->SetXY ($curx, $cury); $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0); $cury+=4; - + $usedetailedbban=$account->useDetailedBBAN(); - + if ($usedetailedbban) { $pdf->SetFont('Arial','B',6); @@ -693,7 +693,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account) $pdf->SetXY ($curx+60, $cury); $pdf->MultiCell(13, 3, $outputlangs->transnoentities("BankAccountNumberKey"), 0, 'C', 0); $pdf->line($curx+73, $cury, $curx+73, $cury+10 ); - + $pdf->SetFont('Arial','',8); $pdf->SetXY ($curx, $cury+6); $pdf->MultiCell(18, 3, $outputlangs->convToOutputCharset($account->code_banque), 0, 'C', 0); @@ -711,7 +711,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account) $pdf->MultiCell(90, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0); $cury-=9; } - + $pdf->SetXY ($curx, $cury+12); $pdf->MultiCell(90, 3, $outputlangs->transnoentities("Residence").': ' . $outputlangs->convToOutputCharset($account->domiciliation), 0, 'L', 0); $pdf->SetXY ($curx, $cury+22); diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index 5178fa6e396..5e42aac8e8b 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -2079,24 +2079,25 @@ function price($amount, $html=0, $outlangs='', $trunc=1, $rounding=2) } /** - * \brief Fonction qui retourne un numerique conforme SQL, depuis un montant issu d'une saisie - * utilisateur. - * \remarks Fonction a appeler sur montants saisis avant un insert en base - * \param amount Montant a formater - * \param rounding 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT) - * 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT) - * 'MS'=Round to Max Shown (MAIN_MAX_DECIMALS_SHOWN) - * ''=No rounding - * \return string Montant au format numerique universel et SQL (Exemple: '99.99999') - * \seealso price Fonction inverse de price2num + * \brief Function that return a number with universal decimal format (decimal separator is '.') from + * an amount typed by a user. + * \remarks Function to use on each input amount before any numeric test or database insert. + * \param amount Amount to convert/clean + * \param rounding ''=No rounding + * 'MU'=Round to Max unit price (MAIN_MAX_DECIMALS_UNIT) + * 'MT'=Round to Max for totals with Tax (MAIN_MAX_DECIMALS_TOT) + * 'MS'=Round to Max Shown (MAIN_MAX_DECIMALS_SHOWN) + * \param alreadysqlnb Put 1 if you know that content is already universal format number + * \return string Amount with universal numeric format (Example: '99.99999') + * \seealso price Opposite function of price2num */ -function price2num($amount,$rounding='',$alreadysqlnb=-1) +function price2num($amount,$rounding='',$alreadysqlnb=0) { global $langs,$conf; // Round PHP function does not allow number like '1,234.56' nor '1.234,56' nor '1 234,56' // Numbers must be '1234.56' - // Decimal delimiter for database SQL request must be '.' + // Decimal delimiter for PHP and database SQL requests must be '.' $dec=','; $thousand=' '; if ($langs->trans("SeparatorDecimal") != "SeparatorDecimal") $dec=$langs->trans("SeparatorDecimal"); if ($langs->trans("SeparatorThousand")!= "SeparatorThousand") $thousand=$langs->trans("SeparatorThousand"); @@ -2122,7 +2123,7 @@ function price2num($amount,$rounding='',$alreadysqlnb=-1) $amount=str_replace($dec,'.',$amount); } - // Now if rounding required + // Now, make a rounding if required if ($rounding) { $nbofdectoround=''; diff --git a/htdocs/translate.class.php b/htdocs/translate.class.php index 75dc047bc75..5046af7d134 100644 --- a/htdocs/translate.class.php +++ b/htdocs/translate.class.php @@ -382,7 +382,7 @@ class Translate { * Si il n'y a pas de correspondance pour ce texte, on cherche dans fichier alternatif * et si toujours pas trouve, il est retourne tel quel. * Parameters of this method must not contains any HTML tags. - * \param key cl� de chaine a traduire + * \param key key of string to translate * \param param1 chaine de param1 * \param param2 chaine de param1 * \param param3 chaine de param1 @@ -401,6 +401,30 @@ class Translate { } + /** + * \brief Return translated value of a text string + * Si il n'y a pas de correspondance pour ce texte, on cherche dans fichier alternatif + * et si toujours pas trouve, il est retourne tel quel. + * Parameters of this method must not contains any HTML tags. + * \param key key of string to translate + * \param param1 chaine de param1 + * \param param2 chaine de param1 + * \param param3 chaine de param1 + * \param param4 chaine de param1 + * \return string chaine traduite + */ + function transnoentitiesnoconv($key, $param1='', $param2='', $param3='', $param4='') + { + $newstr=$key; + if ($this->getTransFromTab($newstr)) + { + // Si la traduction est disponible + $newstr=sprintf($this->tab_translate[$newstr],$param1,$param2,$param3,$param4); + } + return $newstr; + } + + /** * \brief Retourne la version traduite du texte passe en parametre complete du code pays * \param str chaine a traduire