diff --git a/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php b/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php index 058c271021c..1bf1c420246 100644 --- a/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php +++ b/htdocs/fourn/commande/modules/pdf/pdf_muscadet.modules.php @@ -22,12 +22,12 @@ */ /** - \file htdocs/fourn/commande/modules/pdf_muscadet.modules.php - \ingroup fournisseur - \brief Fichier de la classe permettant de générer les commandes fournisseurs au modèle Muscadet - \author Regis Houssin - \version $Revision$ -*/ + \file htdocs/fourn/commande/modules/pdf_muscadet.modules.php + \ingroup fournisseur + \brief Fichier de la classe permettant de générer les commandes fournisseurs au modèle Muscadet + \author Regis Houssin + \version $Revision$ + */ require_once(DOL_DOCUMENT_ROOT."/fourn/commande/modules/modules_commandefournisseur.php"); require_once(DOL_DOCUMENT_ROOT."/fourn/fournisseur.commande.class.php"); @@ -36,103 +36,103 @@ require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); /** - \class pdf_muscadet - \brief Classe permettant de générer les commandes fournisseurs au modèle Muscadet -*/ + \class pdf_muscadet + \brief Classe permettant de générer les commandes fournisseurs au modèle Muscadet + */ class pdf_muscadet extends ModelePDFSuppliersOrders { - - /** - \brief Constructeur - \param db Handler accès base de donnée - */ - function pdf_muscadet($db) - { - global $conf,$langs,$mysoc; - $langs->load("main"); - $langs->load("bills"); + /** + \brief Constructeur + \param db Handler accès base de donnée + */ + function pdf_muscadet($db) + { + global $conf,$langs,$mysoc; - $this->db = $db; - $this->name = "muscadet"; - $this->description = "Modèle de commandes fournisseur complet (logo...)"; + $langs->load("main"); + $langs->load("bills"); - // 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->db = $db; + $this->name = "muscadet"; + $this->description = "Modèle de commandes fournisseur complet (logo...)"; - if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise') - $this->franchise=1; + // 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; - // 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 + $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 - // Defini position des colonnes - $this->posxdesc=$this->marge_gauche+1; - $this->posxtva=121; - $this->posxup=132; - $this->posxqty=151; - $this->posxdiscount=162; - $this->postotalht=177; - - $this->tva=array(); - $this->atleastoneratenotnull=0; - $this->atleastonediscount=0; + 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 + + // Defini position des colonnes + $this->posxdesc=$this->marge_gauche+1; + $this->posxtva=121; + $this->posxup=132; + $this->posxqty=151; + $this->posxdiscount=162; + $this->postotalht=177; + + $this->tva=array(); + $this->atleastoneratenotnull=0; + $this->atleastonediscount=0; } - /** - \brief Renvoi dernière erreur - \return string Dernière erreur - */ - function pdferror() - { - return $this->error; - } + /** + \brief Renvoi dernière erreur + \return string Dernière erreur + */ + function pdferror() + { + return $this->error; + } - /** - \brief Fonction générant la commande sur le disque - \param id Id de la commande à générer - \return int 1=ok, 0=ko - */ - function write_file($com,$outputlangs='') - { - global $user,$langs,$conf; + /** + \brief Fonction générant la commande sur le disque + \param id Id de la commande à générer + \return int 1=ok, 0=ko + */ + function write_file($com,$outputlangs='') + { + global $user,$langs,$conf; if (! is_object($outputlangs)) $outputlangs=$langs; - $outputlangs->load("main"); - $outputlangs->load("companies"); - $outputlangs->load("bills"); - $outputlangs->load("products"); - $outputlangs->load("orders"); - $outputlangs->load("dict"); + $outputlangs->load("main"); + $outputlangs->load("companies"); + $outputlangs->load("bills"); + $outputlangs->load("products"); + $outputlangs->load("orders"); + $outputlangs->load("dict"); $outputlangs->setPhpLang(); - if ($conf->fournisseur->commande->dir_output) - { + if ($conf->fournisseur->commande->dir_output) + { // Définition de l'objet $com (pour compatibilite ascendante) - if (! is_object($com)) - { - $id = $com; - $com = new CommandeFournisseur($this->db); - $ret=$com->fetch($id); + if (! is_object($com)) + { + $id = $com; + $com = new CommandeFournisseur($this->db); + $ret=$com->fetch($id); } - $deja_regle = ""; + $deja_regle = ""; // Définition de $dir et $file if ($com->specimen) @@ -147,710 +147,648 @@ class pdf_muscadet extends ModelePDFSuppliersOrders $file = $dir . "/" . $comref . ".pdf"; } - if (! file_exists($dir)) - { - if (create_exdir($dir) < 0) - { + if (! file_exists($dir)) + { + if (create_exdir($dir) < 0) + { $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); - return 0; - } - - } + return 0; + } - if (file_exists($dir)) - { - $nblignes = sizeof($com->lignes); - - - // Protection et encryption du pdf - if ($conf->global->PDF_SECURITY_ENCRYPTION) - { - $pdf=new FPDI_Protection('P','mm',$this->format); - $pdfrights = array('print'); // Ne permet que l'impression du document - $pdfuserpass = ''; // Mot de passe pour l'utilisateur final - $pdfownerpass = NULL; // Mot de passe du propriétaire, créé aléatoirement si pas défini - $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass); - } - else - { - $pdf=new FPDI('P','mm',$this->format); } - $pdf->Open(); - $pdf->AddPage(); + if (file_exists($dir)) + { + $nblignes = sizeof($com->lignes); - $pdf->SetDrawColor(128,128,128); - $pdf->SetTitle($com->ref); - $pdf->SetSubject($outputlangs->transnoentities("Order")); - $pdf->SetCreator("Dolibarr ".DOL_VERSION); - $pdf->SetAuthor($user->fullname); + // Protection et encryption du pdf + if ($conf->global->PDF_SECURITY_ENCRYPTION) + { + $pdf=new FPDI_Protection('P','mm',$this->format); + $pdfrights = array('print'); // Ne permet que l'impression du document + $pdfuserpass = ''; // Mot de passe pour l'utilisateur final + $pdfownerpass = NULL; // Mot de passe du propriétaire, créé aléatoirement si pas défini + $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass); + } + else + { + $pdf=new FPDI('P','mm',$this->format); + } - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right - $pdf->SetAutoPageBreak(1,0); + $pdf->Open(); + $pdf->AddPage(); - // Positionne $this->atleastonediscount si on a au moins une remise - for ($i = 0 ; $i < $nblignes ; $i++) - { - if ($com->lignes[$i]->remise_percent) - { - $this->atleastonediscount++; - } - } + $pdf->SetDrawColor(128,128,128); - $this->_pagehead($pdf, $com, 1, $outputlangs); + $pdf->SetTitle($com->ref); + $pdf->SetSubject($outputlangs->transnoentities("Order")); + $pdf->SetCreator("Dolibarr ".DOL_VERSION); + $pdf->SetAuthor($user->fullname); - $pagenb = 1; - $tab_top = 90; - $tab_top_newpage = 50; - $tab_height = 110; - $tab_height_newpage = 180; - - // Affiche notes - if ($com->note_public) - { - $tab_top = 88; + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetAutoPageBreak(1,0); - $pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page - $pdf->SetXY ($this->posxdesc-1, $tab_top); - $pdf->MultiCell(190, 3, $com->note_public, 0, 'J'); - $nexY = $pdf->GetY(); - $height_note=$nexY-$tab_top; - - // Rect prend une longueur en 3eme param - $pdf->SetDrawColor(192,192,192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + // Positionne $this->atleastonediscount si on a au moins une remise + for ($i = 0 ; $i < $nblignes ; $i++) + { + if ($com->lignes[$i]->remise_percent) + { + $this->atleastonediscount++; + } + } - $tab_height = $tab_height - $height_note; - $tab_top = $nexY+6; - } - else - { - $height_note=0; - } + $this->_pagehead($pdf, $com, 1, $outputlangs); - $iniY = $tab_top + 8; - $curY = $tab_top + 8; - $nexY = $tab_top + 8; + $pagenb = 1; + $tab_top = 90; + $tab_top_newpage = 50; + $tab_height = 110; + $tab_height_newpage = 180; - // Boucle sur les lignes - for ($i = 0 ; $i < $nblignes ; $i++) - { - $curY = $nexY; + // Affiche notes + if ($com->note_public) + { + $tab_top = 88; - // Description de la ligne produit - $libelleproduitservice=dol_htmlentitiesbr($com->lignes[$i]->libelle,1); - if ($com->lignes[$i]->desc&&$com->lignes[$i]->desc!=$com->lignes[$i]->libelle) - { - if ($libelleproduitservice) $libelleproduitservice.="
"; - $libelleproduitservice.=dol_htmlentitiesbr($com->lignes[$i]->desc,1); - } - // Si ligne associée à un code produit - if ($com->lignes[$i]->fk_product) - { - $libelleproduitservice=$outputlangs->transnoentities("Product")." ".$com->lignes[$i]->ref_fourn." - ".$libelleproduitservice; - } - if ($com->lignes[$i]->date_start && $com->lignes[$i]->date_end) - { - // Affichage durée si il y en a une - $libelleproduitservice.="
".dol_htmlentitiesbr("(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($com->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($com->lignes[$i]->date_end).")",1); - } + $pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page + $pdf->SetXY ($this->posxdesc-1, $tab_top); + $pdf->MultiCell(190, 3, $com->note_public, 0, 'J'); + $nexY = $pdf->GetY(); + $height_note=$nexY-$tab_top; + + // Rect prend une longueur en 3eme param + $pdf->SetDrawColor(192,192,192); + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); - $pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page + $tab_height = $tab_height - $height_note; + $tab_top = $nexY+6; + } + else + { + $height_note=0; + } - $pdf->writeHTMLCell(108, 4, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1); - - $pdf->SetFont('Arial','', 9); // On repositionne la police par défaut + $iniY = $tab_top + 8; + $curY = $tab_top + 8; + $nexY = $tab_top + 8; - $nexY = $pdf->GetY(); + // Boucle sur les lignes + for ($i = 0 ; $i < $nblignes ; $i++) + { + $curY = $nexY; - // TVA - $pdf->SetXY ($this->posxtva, $curY); - $pdf->MultiCell(10, 4, ($com->lignes[$i]->tva_tx < 0 ? '*':'').abs($com->lignes[$i]->tva_tx), 0, 'R'); + // Description de la ligne produit + $libelleproduitservice=dol_htmlentitiesbr($com->lignes[$i]->libelle,1); + if ($com->lignes[$i]->desc&&$com->lignes[$i]->desc!=$com->lignes[$i]->libelle) + { + if ($libelleproduitservice) $libelleproduitservice.="
"; + $libelleproduitservice.=dol_htmlentitiesbr($com->lignes[$i]->desc,1); + } + // Si ligne associée à un code produit + if ($com->lignes[$i]->fk_product) + { + $libelleproduitservice=$outputlangs->transnoentities("Product")." ".$com->lignes[$i]->ref_fourn." - ".$libelleproduitservice; + } + if ($com->lignes[$i]->date_start && $com->lignes[$i]->date_end) + { + // Affichage durée si il y en a une + $libelleproduitservice.="
".dol_htmlentitiesbr("(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($com->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($com->lignes[$i]->date_end).")",1); + } - // Prix unitaire HT avant remise - $pdf->SetXY ($this->posxup, $curY); - $pdf->MultiCell(18, 4, price($com->lignes[$i]->subprice), 0, 'R', 0); + $pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page - // Quantité - $pdf->SetXY ($this->posxqty, $curY); - $pdf->MultiCell(10, 4, $com->lignes[$i]->qty, 0, 'R'); + $pdf->writeHTMLCell(108, 4, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1); - // Remise sur ligne - $pdf->SetXY ($this->posxdiscount, $curY); - if ($com->lignes[$i]->remise_percent) - { - $pdf->MultiCell(14, 4, $com->lignes[$i]->remise_percent."%", 0, 'R'); - } + $pdf->SetFont('Arial','', 9); // On repositionne la police par défaut - // Total HT ligne - $pdf->SetXY ($this->postotalht, $curY); - $total = price($com->lignes[$i]->total_ht); - $pdf->MultiCell(23, 4, $total, 0, 'R', 0); + $nexY = $pdf->GetY(); - // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva - $tvaligne=$com->lignes[$i]->total_tva; - if ($com->remise_percent) $tvaligne-=($tvaligne*$com->remise_percent)/100; - $vatrate=(string) $com->lignes[$i]->tva_tx; - if ($com->lignes[$i]->info_bits & 0x01 == 0x01) $vatrate.='*'; - $this->tva[$vatrate] += $tvaligne; + // TVA + $pdf->SetXY ($this->posxtva, $curY); + $pdf->MultiCell(10, 4, ($com->lignes[$i]->tva_tx < 0 ? '*':'').abs($com->lignes[$i]->tva_tx), 0, 'R'); - $nexY+=2; // Passe espace entre les lignes + // Prix unitaire HT avant remise + $pdf->SetXY ($this->posxup, $curY); + $pdf->MultiCell(18, 4, price($com->lignes[$i]->subprice), 0, 'R', 0); - if ($nexY > 200 && $i < ($nblignes - 1)) - { - $this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); - $this->_pagefoot($pdf, $outputlangs); - - // Nouvelle page - $pdf->AddPage(); - $pagenb++; - $this->_pagehead($pdf, $com, 0, $outputlangs); - - $nexY = $tab_top_newpage + 8; - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('Arial','', 10); - } + // Quantité + $pdf->SetXY ($this->posxqty, $curY); + $pdf->MultiCell(10, 4, $com->lignes[$i]->qty, 0, 'R'); - } - // Affiche cadre tableau - if ($pagenb == 1) - { - $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); - $bottomlasttab=$tab_top + $tab_height + 1; - } - else - { - $this->_tableau($pdf, $tab_top_newpage, $tab_height, $nexY, $outputlangs); - $bottomlasttab=$tab_top_newpage + $tab_height + 1; - } - - $deja_regle = ""; + // Remise sur ligne + $pdf->SetXY ($this->posxdiscount, $curY); + if ($com->lignes[$i]->remise_percent) + { + $pdf->MultiCell(14, 4, $com->lignes[$i]->remise_percent."%", 0, 'R'); + } - $posy=$this->_tableau_tot($pdf, $com, $deja_regle, $bottomlasttab, $outputlangs); - - if ($deja_regle) { - $this->_tableau_versements($pdf, $fac, $posy); - } + // Total HT ligne + $pdf->SetXY ($this->postotalht, $curY); + $total = price($com->lignes[$i]->total_ht); + $pdf->MultiCell(23, 4, $total, 0, 'R', 0); - /* - * Mode de règlement - */ - if ((! defined("FACTURE_CHQ_NUMBER") || ! FACTURE_CHQ_NUMBER) && (! defined("FACTURE_RIB_NUMBER") || ! FACTURE_RIB_NUMBER)) - { - $pdf->SetXY ($this->marge_gauche, 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); - } + // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva + $tvaligne=$com->lignes[$i]->total_tva; + if ($com->remise_percent) $tvaligne-=($tvaligne*$com->remise_percent)/100; + $vatrate=(string) $com->lignes[$i]->tva_tx; + if ($com->lignes[$i]->info_bits & 0x01 == 0x01) $vatrate.='*'; + $this->tva[$vatrate] += $tvaligne; - /* - * Propose mode règlement par CHQ - */ - /* - if (defined("FACTURE_CHQ_NUMBER")) - { - if (FACTURE_CHQ_NUMBER > 0) - { - $account = new Account($this->db); - $account->fetch(FACTURE_CHQ_NUMBER); + $nexY+=2; // Passe espace entre les lignes - $pdf->SetXY ($this->marge_gauche, 227); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(90, 3, "Règlement par chèque à l'ordre de ".$account->proprio." envoyé à:",0,'L',0); - $pdf->SetXY ($this->marge_gauche, 231); - $pdf->SetFont('Arial','',8); - $pdf->MultiCell(80, 3, $account->adresse_proprio, 0, 'L', 0); - } - } - */ - - /* - * Propose mode règlement par RIB - */ - /* - if (defined("FACTURE_RIB_NUMBER")) - { - if (FACTURE_RIB_NUMBER > 0) - { - $account = new Account($this->db); - $account->fetch(FACTURE_RIB_NUMBER); + if ($nexY > 200 && $i < ($nblignes - 1)) + { + $this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); + $this->_pagefoot($pdf, $outputlangs); + + // Nouvelle page + $pdf->AddPage(); + $pagenb++; + $this->_pagehead($pdf, $com, 0, $outputlangs); + + $nexY = $tab_top_newpage + 8; + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('Arial','', 10); + } - $this->marges['g']=$this->marge_gauche; - - $cury=242; - $pdf->SetXY ($this->marges['g'], $cury); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(90, 3, "Règlement par virement sur le compte bancaire suivant:", 0, 'L', 0); - $cury+=4; - $pdf->SetFont('Arial','B',6); - $pdf->line($this->marges['g']+1, $cury, $this->marges['g']+1, $cury+10 ); - $pdf->SetXY ($this->marges['g'], $cury); - $pdf->MultiCell(18, 3, "Code banque", 0, 'C', 0); - $pdf->line($this->marges['g']+18, $cury, $this->marges['g']+18, $cury+10 ); - $pdf->SetXY ($this->marges['g']+18, $cury); - $pdf->MultiCell(18, 3, "Code guichet", 0, 'C', 0); - $pdf->line($this->marges['g']+36, $cury, $this->marges['g']+36, $cury+10 ); - $pdf->SetXY ($this->marges['g']+36, $cury); - $pdf->MultiCell(24, 3, "Numéro compte", 0, 'C', 0); - $pdf->line($this->marges['g']+60, $cury, $this->marges['g']+60, $cury+10 ); - $pdf->SetXY ($this->marges['g']+60, $cury); - $pdf->MultiCell(13, 3, "Clé RIB", 0, 'C', 0); - $pdf->line($this->marges['g']+73, $cury, $this->marges['g']+73, $cury+10 ); - - $pdf->SetFont('Arial','',8); - $pdf->SetXY ($this->marges['g'], $cury+5); - $pdf->MultiCell(18, 3, $account->code_banque, 0, 'C', 0); - $pdf->SetXY ($this->marges['g']+18, $cury+5); - $pdf->MultiCell(18, 3, $account->code_guichet, 0, 'C', 0); - $pdf->SetXY ($this->marges['g']+36, $cury+5); - $pdf->MultiCell(24, 3, $account->number, 0, 'C', 0); - $pdf->SetXY ($this->marges['g']+60, $cury+5); - $pdf->MultiCell(13, 3, $account->cle_rib, 0, 'C', 0); - - $pdf->SetXY ($this->marges['g'], $cury+12); - $pdf->MultiCell(90, 3, "Domiciliation : " . $account->domiciliation, 0, 'L', 0); - $pdf->SetXY ($this->marges['g'], $cury+22); - $pdf->MultiCell(90, 3, "Prefix IBAN : " . $account->iban_prefix, 0, 'L', 0); - $pdf->SetXY ($this->marges['g'], $cury+25); - $pdf->MultiCell(90, 3, "BIC : " . $account->bic, 0, 'L', 0); + } + // Affiche cadre tableau + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); + $bottomlasttab=$tab_top + $tab_height + 1; + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $tab_height, $nexY, $outputlangs); + $bottomlasttab=$tab_top_newpage + $tab_height + 1; + } - } - } - */ - - /* - * Conditions de règlements - */ - /* Pour l'instant les conditions de règlement ne sont pas gérées sur les propales */ - /* - $pdf->SetFont('Arial','B',10); - $pdf->SetXY($this->marge_gauche, 217); - $titre = "Conditions de réglement:"; - $pdf->MultiCell(80, 5, $titre, 0, 'L'); - $pdf->SetFont('Arial','',10); - $pdf->SetXY(54, 217); - $pdf->MultiCell(80, 5, $prop->cond_reglement_facture,0,'L'); - */ + $deja_regle = ""; - /* - * Pied de page - */ - $this->_pagefoot($pdf, $outputlangs); - $pdf->AliasNbPages(); - - $pdf->Close(); + $posy=$this->_tableau_tot($pdf, $com, $deja_regle, $bottomlasttab, $outputlangs); - $pdf->Output($file); + if ($deja_regle) { + $this->_tableau_versements($pdf, $fac, $posy); + } - return 1; // Pas d'erreur - } - else - { - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); - return 0; - } - } - else - { - $this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR"); - return 0; - } - $this->error=$langs->trans("ErrorUnknown"); - return 0; // Erreur par defaut - } + /* + * Mode de règlement + */ + if ((! defined("FACTURE_CHQ_NUMBER") || ! FACTURE_CHQ_NUMBER) && (! defined("FACTURE_RIB_NUMBER") || ! FACTURE_RIB_NUMBER)) + { + $pdf->SetXY ($this->marge_gauche, 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); + } - /** - * \brief Affiche le total à payer - * \param pdf Objet PDF - * \param object Objet order - * \param deja_regle Montant deja regle - * \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); + /* + * Propose mode règlement par CHQ + */ + /* + if (defined("FACTURE_CHQ_NUMBER")) + { + if (FACTURE_CHQ_NUMBER > 0) + { + $account = new Account($this->db); + $account->fetch(FACTURE_CHQ_NUMBER); - // Affiche la mention TVA non applicable selon option - $pdf->SetXY ($this->marge_gauche, $tab2_top + 0); - if ($this->franchise==1) - { - $pdf->MultiCell(100, $tab2_hl, "* TVA non applicable art-293B du CGI", 0, 'L', 0); - } + $pdf->SetXY ($this->marge_gauche, 227); + $pdf->SetFont('Arial','B',8); + $pdf->MultiCell(90, 3, "Règlement par chèque à l'ordre de ".$account->proprio." envoyé à:",0,'L',0); + $pdf->SetXY ($this->marge_gauche, 231); + $pdf->SetFont('Arial','',8); + $pdf->MultiCell(80, 3, $account->adresse_proprio, 0, 'L', 0); + } + } + */ - // Tableau total - $lltot = 200; $col1x = 120; $col2x = 182; $largcol2 = $lltot - $col2x; + /* + * Propose mode règlement par RIB + */ + /* + if (defined("FACTURE_RIB_NUMBER")) + { + if (FACTURE_RIB_NUMBER > 0) + { + $account = new Account($this->db); + $account->fetch(FACTURE_RIB_NUMBER); - // 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); + $this->marges['g']=$this->marge_gauche; - $pdf->SetXY ($col2x, $tab2_top + 0); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1); + $cury=242; + $pdf->SetXY ($this->marges['g'], $cury); + $pdf->SetFont('Arial','B',8); + $pdf->MultiCell(90, 3, "Règlement par virement sur le compte bancaire suivant:", 0, 'L', 0); + $cury+=4; + $pdf->SetFont('Arial','B',6); + $pdf->line($this->marges['g']+1, $cury, $this->marges['g']+1, $cury+10 ); + $pdf->SetXY ($this->marges['g'], $cury); + $pdf->MultiCell(18, 3, "Code banque", 0, 'C', 0); + $pdf->line($this->marges['g']+18, $cury, $this->marges['g']+18, $cury+10 ); + $pdf->SetXY ($this->marges['g']+18, $cury); + $pdf->MultiCell(18, 3, "Code guichet", 0, 'C', 0); + $pdf->line($this->marges['g']+36, $cury, $this->marges['g']+36, $cury+10 ); + $pdf->SetXY ($this->marges['g']+36, $cury); + $pdf->MultiCell(24, 3, "Numéro compte", 0, 'C', 0); + $pdf->line($this->marges['g']+60, $cury, $this->marges['g']+60, $cury+10 ); + $pdf->SetXY ($this->marges['g']+60, $cury); + $pdf->MultiCell(13, 3, "Clé RIB", 0, 'C', 0); + $pdf->line($this->marges['g']+73, $cury, $this->marges['g']+73, $cury+10 ); - // Remise globale - if ($object->remise > 0) - { - $pdf->SetXY ($col1x, $tab2_top + $tab2_hl); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("GlobalDiscount"), 0, 'L', 1); + $pdf->SetFont('Arial','',8); + $pdf->SetXY ($this->marges['g'], $cury+5); + $pdf->MultiCell(18, 3, $account->code_banque, 0, 'C', 0); + $pdf->SetXY ($this->marges['g']+18, $cury+5); + $pdf->MultiCell(18, 3, $account->code_guichet, 0, 'C', 0); + $pdf->SetXY ($this->marges['g']+36, $cury+5); + $pdf->MultiCell(24, 3, $account->number, 0, 'C', 0); + $pdf->SetXY ($this->marges['g']+60, $cury+5); + $pdf->MultiCell(13, 3, $account->cle_rib, 0, 'C', 0); + + $pdf->SetXY ($this->marges['g'], $cury+12); + $pdf->MultiCell(90, 3, "Domiciliation : " . $account->domiciliation, 0, 'L', 0); + $pdf->SetXY ($this->marges['g'], $cury+22); + $pdf->MultiCell(90, 3, "Prefix IBAN : " . $account->iban_prefix, 0, 'L', 0); + $pdf->SetXY ($this->marges['g'], $cury+25); + $pdf->MultiCell(90, 3, "BIC : " . $account->bic, 0, 'L', 0); - $pdf->SetXY ($col2x, $tab2_top + $tab2_hl); - $pdf->MultiCell($largcol2, $tab2_hl, "-".$object->remise_percent."%", 0, 'R', 1); + } + } + */ - $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * 2); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, "Total HT après remise", 0, 'L', 1); + /* + * Conditions de règlements + */ + /* Pour l'instant les conditions de règlement ne sont pas gérées sur les propales */ + /* + $pdf->SetFont('Arial','B',10); + $pdf->SetXY($this->marge_gauche, 217); + $titre = "Conditions de réglement:"; + $pdf->MultiCell(80, 5, $titre, 0, 'L'); + $pdf->SetFont('Arial','',10); + $pdf->SetXY(54, 217); + $pdf->MultiCell(80, 5, $prop->cond_reglement_facture,0,'L'); + */ - $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * 2); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht), 0, 'R', 0); + /* + * Pied de page + */ + $this->_pagefoot($pdf, $outputlangs); + $pdf->AliasNbPages(); - $index = 2; - } - else - { - $index = 0; - } + $pdf->Close(); - // Affichage des totaux de TVA par taux (conformément à réglementation) - $pdf->SetFillColor(248,248,248); + $pdf->Output($file); - foreach( $this->tva as $tvakey => $tvaval ) - { - if ($tvakey) // On affiche pas taux 0 - { - $this->atleastoneratenotnull++; - - $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.=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); - } - - $useborder=0; - - $index++; - $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); - $pdf->SetTextColor(0,0,60); - $pdf->SetFillColor(224,224,224); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + return 1; // Pas d'erreur + } + else + { + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); + return 0; + } + } + else + { + $this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR"); + return 0; + } + $this->error=$langs->trans("ErrorUnknown"); + return 0; // Erreur par defaut + } - $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1); - $pdf->SetFont('Arial','', 9); - $pdf->SetTextColor(0,0,0); + /** + * \brief Affiche le total à payer + * \param pdf Objet PDF + * \param object Objet order + * \param deja_regle Montant deja regle + * \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); - if ($deja_regle > 0) - { - $index++; - - $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPayed"), 0, 'L', 0); + // Affiche la mention TVA non applicable selon option + $pdf->SetXY ($this->marge_gauche, $tab2_top + 0); + if ($this->franchise==1) + { + $pdf->MultiCell(100, $tab2_hl, "* TVA non applicable art-293B du CGI", 0, 'L', 0); + } - $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); + // Tableau total + $lltot = 200; $col1x = 120; $col2x = 182; $largcol2 = $lltot - $col2x; - $index++; - $pdf->SetTextColor(0,0,60); - //$pdf->SetFont('Arial','B', 9); - $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("RemainderToPay"), $useborder, 'L', 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 + $tab2_hl * $index); - $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle), $useborder, 'R', 1); - $pdf->SetFont('Arial','', 9); - $pdf->SetTextColor(0,0,0); - } - - $index++; - return ($tab2_top + ($tab2_hl * $index)); - } + $pdf->SetXY ($col2x, $tab2_top + 0); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1); - /** - * \brief Affiche la grille des lignes de propales - * \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); + // Remise globale + if ($object->remise > 0) + { + $pdf->SetXY ($col1x, $tab2_top + $tab2_hl); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("GlobalDiscount"), 0, 'L', 1); - $pdf->SetDrawColor(128,128,128); + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl); + $pdf->MultiCell($largcol2, $tab2_hl, "-".$object->remise_percent."%", 0, 'R', 1); - // 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+6, $this->page_largeur-$this->marge_droite, $tab_top+6); + $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * 2); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, "Total HT après remise", 0, 'L', 1); - $pdf->SetFont('Arial','',10); + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * 2); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht), 0, 'R', 0); - $pdf->SetXY ($this->posxdesc-1, $tab_top+2); - $pdf->MultiCell(108,2, $outputlangs->transnoentities("Designation"),'','L'); + $index = 2; + } + else + { + $index = 0; + } - $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); - $pdf->SetXY ($this->posxtva-1, $tab_top+2); - $pdf->MultiCell(12,2, $outputlangs->transnoentities("VAT"),'','C'); + // Affichage des totaux de TVA par taux (conformément à réglementation) + $pdf->SetFillColor(248,248,248); - $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'); + foreach( $this->tva as $tvakey => $tvaval ) + { + if ($tvakey) // On affiche pas taux 0 + { + $this->atleastoneratenotnull++; + + $index++; + $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); - $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); - $pdf->SetXY ($this->posxqty-1, $tab_top+2); - $pdf->MultiCell(11,2, $outputlangs->transnoentities("Qty"),'','C'); + $tvacompl=''; - $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(16,2, $outputlangs->transnoentities("ReductionShort"),'','C'); - } + if (eregi('\*',$tvakey)) + { + $tvakey=eregi_replace('\*','',$tvakey); + $tvacompl = " (".$outputlangs->transnoentities("NonPercuRecuperable").")"; + } - 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(23,2, $outputlangs->transnoentities("TotalHT"),'','C'); + $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); + } - /** - * \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 $langs,$conf,$mysoc; + $useborder=0; - $outputlangs->load("main"); - $outputlangs->load("bills"); - $outputlangs->load("orders"); - $outputlangs->load("companies"); - - $pdf->SetTextColor(0,0,60); - $pdf->SetFont('Arial','B',13); + $index++; + $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); + $pdf->SetTextColor(0,0,60); + $pdf->SetFillColor(224,224,224); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); - $posy=$this->marge_haute; - - $pdf->SetXY($this->marge_gauche,$posy); + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc), $useborder, 'R', 1); + $pdf->SetFont('Arial','', 9); + $pdf->SetTextColor(0,0,0); + + if ($deja_regle > 0) + { + $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); + + $index++; + $pdf->SetTextColor(0,0,60); + //$pdf->SetFont('Arial','B', 9); + $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($object->total_ttc - $deja_regle), $useborder, 'R', 1); + $pdf->SetFont('Arial','', 9); + $pdf->SetTextColor(0,0,0); + } + + $index++; + return ($tab2_top + ($tab2_hl * $index)); + } + + /** + * \brief Affiche la grille des lignes de propales + * \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); + + $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+6, $this->page_largeur-$this->marge_droite, $tab_top+6); + + $pdf->SetFont('Arial','',10); + + $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(12,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->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); + $pdf->SetXY ($this->posxqty-1, $tab_top+2); + $pdf->MultiCell(11,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(16,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(23,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) + { + global $langs,$conf,$mysoc; + + $outputlangs->load("main"); + $outputlangs->load("bills"); + $outputlangs->load("orders"); + $outputlangs->load("companies"); + + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('Arial','B',13); + + $posy=$this->marge_haute; + + $pdf->SetXY($this->marge_gauche,$posy); // Logo - $logo=$conf->societe->dir_logos.'/'.$mysoc->logo; - if ($mysoc->logo) - { - if (is_readable($logo)) - { - $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("ErrorGoToModuleSetup"), 0, 'L'); - } - } - else if(defined("MAIN_INFO_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) - { - $pdf->MultiCell(100, 4, MAIN_INFO_SOCIETE_NOM, 0, 'L'); - } + $logo=$conf->societe->dir_logos.'/'.$mysoc->logo; + if ($mysoc->logo) + { + if (is_readable($logo)) + { + $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("ErrorGoToModuleSetup"), 0, 'L'); + } + } + else if(defined("MAIN_INFO_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) + { + $pdf->MultiCell(100, 4, MAIN_INFO_SOCIETE_NOM, 0, 'L'); + } - $pdf->SetFont('Arial','B',13); - $pdf->SetXY(100,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Order")." ".$object->ref, '' , 'R'); - $pdf->SetFont('Arial','',12); - - $posy+=6; - $pdf->SetXY(100,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dolibarr_print_date($object->date,"day"), '', 'R'); + $pdf->SetFont('Arial','B',13); + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Order")." ".$object->ref, '' , 'R'); + $pdf->SetFont('Arial','',12); - 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+2,$posy+3); - - // Nom emetteur - $pdf->SetTextColor(0,0,60); - $pdf->SetFont('Arial','B',11); - if (defined("FAC_PDF_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) $pdf->MultiCell(80, 4, FAC_PDF_SOCIETE_NOM, 0, 'L'); - else $pdf->MultiCell(80, 4, $mysoc->nom, 0, 'L'); - - // Caractéristiques emetteur - $carac_emetteur = ''; - if (defined("FAC_PDF_ADRESSE") && FAC_PDF_ADRESSE) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).FAC_PDF_ADRESSE; - else { - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$mysoc->adresse; - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$mysoc->cp.' '.$mysoc->ville; - } - $carac_emetteur .= "\n"; - // Tel - if (defined("FAC_PDF_TEL") && FAC_PDF_TEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".FAC_PDF_TEL; - elseif ($mysoc->tel) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".$mysoc->tel; - // Fax - if (defined("FAC_PDF_FAX") && FAC_PDF_FAX) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".FAC_PDF_FAX; - elseif ($mysoc->fax) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$mysoc->fax; - // EMail + $posy+=6; + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Date")." : " . dolibarr_print_date($object->date,"day"), '', '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").":"); + + + $pdf->SetXY($this->marge_gauche,$posy); + $pdf->SetFillColor(230,230,230); + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + + + $pdf->SetXY($this->marge_gauche+2,$posy+3); + + // Nom emetteur + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('Arial','B',11); + if (defined("FAC_PDF_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) $pdf->MultiCell(80, 4, FAC_PDF_SOCIETE_NOM, 0, 'L'); + else $pdf->MultiCell(80, 4, $mysoc->nom, 0, 'L'); + + // Caractéristiques emetteur + $carac_emetteur = ''; + if (defined("FAC_PDF_ADRESSE") && FAC_PDF_ADRESSE) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).FAC_PDF_ADRESSE; + else { + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$mysoc->adresse; + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$mysoc->cp.' '.$mysoc->ville; + } + $carac_emetteur .= "\n"; + // Tel + if (defined("FAC_PDF_TEL") && FAC_PDF_TEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".FAC_PDF_TEL; + elseif ($mysoc->tel) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".$mysoc->tel; + // Fax + if (defined("FAC_PDF_FAX") && FAC_PDF_FAX) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".FAC_PDF_FAX; + elseif ($mysoc->fax) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$mysoc->fax; + // EMail if (defined("FAC_PDF_MEL") && FAC_PDF_MEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".FAC_PDF_MEL; - elseif ($mysoc->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$mysoc->email; - // Web + elseif ($mysoc->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$mysoc->email; + // Web if (defined("FAC_PDF_WWW") && FAC_PDF_WWW) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".FAC_PDF_WWW; - elseif ($mysoc->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$mysoc->url; - - $pdf->SetFont('Arial','',9); - $pdf->SetXY($this->marge_gauche+2,$posy+8); - $pdf->MultiCell(80,4, $carac_emetteur); - - // Client destinataire - $posy=42; - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('Arial','',8); - $pdf->SetXY(100,$posy-5); - $pdf->MultiCell(80,5, $outputlangs->transnoentities("BillTo").":"); + elseif ($mysoc->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$mysoc->url; + + $pdf->SetFont('Arial','',9); + $pdf->SetXY($this->marge_gauche+2,$posy+8); + $pdf->MultiCell(80,4, $carac_emetteur); + + // Client destinataire + $posy=42; + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('Arial','',8); + $pdf->SetXY(100,$posy-5); + $pdf->MultiCell(80,5, $outputlangs->transnoentities("BillTo").":"); // $client = new Societe($this->db); - $client->fetch($object->socid); + $client->fetch($object->socid); $object->client = $client; - // - - // Cadre client destinataire - $pdf->rect(100, $posy, 100, $hautcadre); - + // + + // 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, $object->client->nom, 0, 'L'); - + $pdf->SetXY(102,$posy+3); + $pdf->SetFont('Arial','B',11); + $pdf->MultiCell(106,4, $object->client->nom, 0, 'L'); + // Caractéristiques client - $carac_client=$object->client->adresse; - $carac_client.="\n".$object->client->cp . " " . $object->client->ville."\n"; + $carac_client=$object->client->adresse; + $carac_client.="\n".$object->client->cp . " " . $object->client->ville."\n"; if ($object->client->tva_intra) $carac_client.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$object->client->tva_intra; - $pdf->SetFont('Arial','',9); - $pdf->SetXY(102,$posy+8); - $pdf->MultiCell(86,4, $carac_client); - } - } + $pdf->SetFont('Arial','',9); + $pdf->SetXY(102,$posy+8); + $pdf->MultiCell(86,4, $carac_client); + } + } - /** - * \brief Show footer of page - * \param pdf Object PDF - * \param outputlang Object lang for output - */ - function _pagefoot(&$pdf, $outputlangs) - { - global $conf; - - $outputlangs->load("dict"); - - // Premiere ligne d'info réglementaires - $ligne1=""; - if ($this->emetteur->forme_juridique_code) - { - $ligne1.=($ligne1?" - ":"").getFormeJuridiqueLabel($this->emetteur->forme_juridique_code); - } - if ($this->emetteur->capital) - { - $ligne1.=($ligne1?" - ":"").$outputlangs->transnoentities("CapitalOf",$this->emetteur->capital)." ".$outputlangs->transnoentities("Currency".$conf->monnaie); - } - if ($this->emetteur->profid2) - { - $ligne1.=($ligne1?" - ":"").$outputlangs->transcountry("ProfId2",$this->emetteur->pays_code).": ".$this->emetteur->profid2; - } - if ($this->emetteur->profid1 && (! $this->emetteur->profid2 || $this->emetteur->pays_code != 'FR')) - { - $ligne1.=($ligne1?" - ":"").$outputlangs->transcountry("ProfId1",$this->emetteur->pays_code).": ".$this->emetteur->profid1; - } - - // Deuxieme ligne d'info réglementaires - $ligne2=""; - if ($this->emetteur->profid3) - { - $ligne2.=($ligne2?" - ":"").$outputlangs->transcountry("ProfId3",$this->emetteur->pays_code).": ".$this->emetteur->profid3; - } - if ($this->emetteur->profid4) - { - $ligne2.=($ligne2?" - ":"").$outputlangs->transcountry("ProfId4",$this->emetteur->pays_code).": ".$this->emetteur->profid4; - } - if ($this->emetteur->tva_intra != '') - { - $ligne2.=($ligne2?" - ":"").$outputlangs->transnoentities("VATIntraShort").": ".$this->emetteur->tva_intra; - } - - $pdf->SetFont('Arial','',8); - $pdf->SetDrawColor(224,224,224); - - // On positionne le debut du bas de page selon nbre de lignes de ce bas de page - $posy=$this->marge_basse + 1 + ($ligne1?3:0) + ($ligne2?3:0); - - $pdf->SetY(-$posy); - $pdf->line($this->marge_gauche, $this->page_hauteur-$posy, 200, $this->page_hauteur-$posy); - $posy--; - - if ($ligne1) - { - $pdf->SetXY($this->marge_gauche,-$posy); - $pdf->MultiCell(200, 2, $ligne1, 0, 'C', 0); - } - - if ($ligne2) - { - $posy-=3; - $pdf->SetXY($this->marge_gauche,-$posy); - $pdf->MultiCell(200, 2, $ligne2, 0, 'C', 0); - } - - $pdf->SetXY(-20,-$posy); - $pdf->MultiCell(10, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0); - } + /** + * \brief Show footer of page + * \param pdf Object PDF + * \param outputlang Object lang for output + */ + function _pagefoot(&$pdf, $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/commande/pdf_edison.modules.php b/htdocs/includes/modules/commande/pdf_edison.modules.php index c12231eba41..23282377cdc 100644 --- a/htdocs/includes/modules/commande/pdf_edison.modules.php +++ b/htdocs/includes/modules/commande/pdf_edison.modules.php @@ -19,83 +19,94 @@ * or see http://www.gnu.org/ */ -/** - \file htdocs/includes/modules/commande/pdf_edison.modules.php - \ingroup commande - \brief Fichier de la classe permettant de g�n�rer les commandes au mod�le Edison - \version $Id$ -*/ +/** + \file htdocs/includes/modules/commande/pdf_edison.modules.php + \ingroup commande + \brief Fichier de la classe permettant de generer les commandes au modele Edison + \version $Id$ + */ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php"); - +require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); /** - \class pdf_edison - \brief Classe permettant de g�n�rer les commandes au mod�le Edison -*/ + \class pdf_edison + \brief Classe permettant de g�n�rer les commandes au mod�le Edison + */ class pdf_edison extends ModelePDFCommandes { + var $emetteur; // Objet societe qui emet + + /** + * \brief Constructeur + * \param db handler acc�s base de donn�e + */ + function pdf_edison($db=0) + { + global $conf,$langs,$mysoc; - /** \brief Constructeur - \param db handler acc�s base de donn�e - */ - function pdf_edison($db=0) - { + $langs->load("main"); + $langs->load("bills"); + $this->db = $db; - $this->name = "edison"; - $this->description = "Modele de commande simple"; + $this->name = "edison"; + $this->description = "Modele de commande simple"; - // 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->option_multilang = 0; // Dispo en plusieurs langues + // 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_multilang = 0; // Dispo en plusieurs langues $this->option_draft_watermark = 1; //Support add of a watermark on drafts - $this->error = ""; - } - + $this->error = ""; + } + + + /** \brief Renvoi derni�re erreur + \return string Derni�re erreur + */ + function pdferror() + { + return $this->error; + } + - /** \brief Renvoi derni�re erreur - \return string Derni�re erreur - */ - function pdferror() - { - return $this->error; - } - - /** - \brief Fonction g�n�rant la commande sur le disque - \param id id de la propale � g�n�rer - \return int 1=ok, 0=ko - */ + \brief Fonction generant la commande sur le disque + \param com id de la propale a generer + \return int 1=ok, 0=ko + */ function write_file($com,$outputlangs='') { global $user,$conf,$langs,$mysco; if (! is_object($outputlangs)) $outputlangs=$langs; $outputlangs->load("main"); - $outputlangs->load("companies"); - $outputlangs->load("bills"); - $outputlangs->load("products"); - + $outputlangs->load("companies"); + $outputlangs->load("bills"); + $outputlangs->load("products"); + $outputlangs->setPhpLang(); - - // D�finition de l'objet $com (pour compatibilite ascendante) - if (! is_object($com)) - { - $id = $com; - $com = new Commande($this->db,"",$id); - $ret=$com->fetch($id); + + // Definition de l'objet $com (pour compatibilite ascendante) + if (! is_object($com)) + { + $id = $com; + $com = new Commande($this->db,"",$id); + $ret=$com->fetch($id); } - if ($conf->commande->dir_output) - { - // D�finition de $dir et $file + if ($conf->commande->dir_output) + { + // Definition of $dir and $file if ($com->specimen) { $dir = $conf->commande->dir_output; @@ -107,7 +118,7 @@ class pdf_edison extends ModelePDFCommandes $dir = $conf->commande->dir_output . "/" . $comref; $file = $dir . "/" . $comref . ".pdf"; } - + if (! file_exists($dir)) { if (create_exdir($dir) < 0) @@ -117,85 +128,85 @@ class pdf_edison extends ModelePDFCommandes return 0; } } - - if (file_exists($dir)) - { - // Protection et encryption du pdf - if ($conf->global->PDF_SECURITY_ENCRYPTION) - { + + if (file_exists($dir)) + { + // Protection et encryption du pdf + if ($conf->global->PDF_SECURITY_ENCRYPTION) + { $pdf=new FPDI_Protection('P','mm',$this->format); - $pdfrights = array('print'); // Ne permet que l'impression du document - $pdfuserpass = ''; // Mot de passe pour l'utilisateur final - $pdfownerpass = NULL; // Mot de passe du propri�taire, cr�� al�atoirement si pas d�fini - $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass); - } - else - { - $pdf=new FPDI('P','mm',$this->format); + $pdfrights = array('print'); // Ne permet que l'impression du document + $pdfuserpass = ''; // Mot de passe pour l'utilisateur final + $pdfownerpass = NULL; // Mot de passe du propri�taire, cr�� al�atoirement si pas d�fini + $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass); + } + else + { + $pdf=new FPDI('P','mm',$this->format); } - - $pdf->Open(); - $pdf->AddPage(); - $pdf->SetDrawColor(128,128,128); + $pdf->Open(); + $pdf->AddPage(); - $pdf->SetTitle($com->ref); - $pdf->SetSubject($langs->transnoentities("Order")); - $pdf->SetCreator("Dolibarr ".DOL_VERSION); - $pdf->SetAuthor($user->fullname); + $pdf->SetDrawColor(128,128,128); - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right - $pdf->SetAutoPageBreak(1,0); + $pdf->SetTitle($com->ref); + $pdf->SetSubject($langs->transnoentities("Order")); + $pdf->SetCreator("Dolibarr ".DOL_VERSION); + $pdf->SetAuthor($user->fullname); - $this->_pagehead($pdf, $com, 1, $outputlangs); + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetAutoPageBreak(1,0); + + $this->_pagehead($pdf, $com, 1, $outputlangs); $tab_top = 100; $tab_height = 140; - + $pdf->SetFillColor(220,220,220); - + $pdf->SetTextColor(0,0,0); $pdf->SetFont('Arial','', 10); - + $pdf->SetXY (10, $tab_top + 10 ); - + $iniY = $pdf->GetY(); $curY = $pdf->GetY(); $nexY = $pdf->GetY(); $nblignes = sizeof($com->lignes); - + for ($i = 0 ; $i < $nblignes ; $i++) { - + $curY = $nexY; - + $pdf->SetXY (30, $curY ); - + $pdf->MultiCell(100, 5, $com->lignes[$i]->desc, 0, 'J', 0); - + $nexY = $pdf->GetY(); - + $pdf->SetXY (10, $curY ); - + $pdf->MultiCell(20, 5, $com->lignes[$i]->ref, 0, 'C'); - + $pdf->SetXY (133, $curY ); $pdf->MultiCell(10, 5, $com->lignes[$i]->tva_tx, 0, 'C'); - + $pdf->SetXY (145, $curY ); $pdf->MultiCell(10, 5, $com->lignes[$i]->qty, 0, 'C'); - + $pdf->SetXY (156, $curY ); $pdf->MultiCell(18, 5, price($com->lignes[$i]->price), 0, 'R', 0); - + $pdf->SetXY (174, $curY ); $total = price($com->lignes[$i]->total_ht); $pdf->MultiCell(26, 5, $total, 0, 'R', 0); - + $pdf->line(10, $curY, 200, $curY ); - + if ($nexY > 240 && $i < $nblignes - 1) { $this->_tableau($pdf, $tab_top, $tab_height, $nexY); @@ -206,130 +217,129 @@ class pdf_edison extends ModelePDFCommandes $pdf->SetFont('Arial','', 10); } } - + $this->_tableau($pdf, $tab_top, $tab_height, $nexY); /* - * - */ + * + */ $tab2_top = 241; $tab2_lh = 7; $tab2_height = $tab2_lh * 4; - + $pdf->SetFont('Arial','', 11); - + $pdf->Rect(132, $tab2_top, 68, $tab2_height); - + $pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*3), 200, $tab2_top + $tab2_height - ($tab2_lh*3) ); $pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*2), 200, $tab2_top + $tab2_height - ($tab2_lh*2) ); $pdf->line(132, $tab2_top + $tab2_height - $tab2_lh, 200, $tab2_top + $tab2_height - $tab2_lh ); - + $pdf->line(174, $tab2_top, 174, $tab2_top + $tab2_height); - + $pdf->SetXY (132, $tab2_top + 0); $pdf->MultiCell(42, $tab2_lh, $langs->transnoentities("TotalHT"), 0, 'R', 0); - + $pdf->SetXY (132, $tab2_top + $tab2_lh); - $pdf->MultiCell(42, $tab2_lh, $langs->transnoentities("Reduction"), 0, 'R', 0); - - $pdf->SetXY (132, $tab2_top + $tab2_lh*2); - $pdf->MultiCell(42, $tab2_lh, "Total HT apr�s remise", 0, 'R', 0); - - $pdf->SetXY (132, $tab2_top + $tab2_lh*3); $pdf->MultiCell(42, $tab2_lh, $langs->transnoentities("TotalVAT"), 0, 'R', 0); - - $pdf->SetXY (132, $tab2_top + ($tab2_lh*4)); + + $pdf->SetXY (132, $tab2_top + ($tab2_lh*2)); $pdf->MultiCell(42, $tab2_lh, $langs->transnoentities("TotalTTC"), 1, 'R', 1); - + $pdf->SetXY (174, $tab2_top + 0); $pdf->MultiCell(26, $tab2_lh, price($com->total_ht + $com->remise), 0, 'R', 0); - + $pdf->SetXY (174, $tab2_top + $tab2_lh); $pdf->MultiCell(26, $tab2_lh, price($com->remise), 0, 'R', 0); - + $pdf->SetXY (174, $tab2_top + $tab2_lh*2); $pdf->MultiCell(26, $tab2_lh, price($com->total_ht), 0, 'R', 0); - + $pdf->SetXY (174, $tab2_top + $tab2_lh*3); $pdf->MultiCell(26, $tab2_lh, price($com->total_tva), 0, 'R', 0); - + $pdf->SetXY (174, $tab2_top + ($tab2_lh*4)); $pdf->MultiCell(26, $tab2_lh, price($com->total_ttc), 1, 'R', 1); - - + + // Pied de page + $this->_pagefoot($pdf,$com,$outputlangs); + $pdf->AliasNbPages(); + + $pdf->Close(); + $pdf->Output($file); $langs->setPhpLang(); // On restaure langue session return 1; } } - else - { - $this->error=$outputlangs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR"); + else + { + $this->error=$outputlangs->transnoentities("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR"); $langs->setPhpLang(); // On restaure langue session - return 0; - } + return 0; + } - $this->error=$outputlangs->transnoentities("ErrorUnknown"); + $this->error=$outputlangs->transnoentities("ErrorUnknown"); $langs->setPhpLang(); // On restaure langue session - return 0; // Erreur par defaut + return 0; // Erreur par defaut } - function _tableau(&$pdf, $tab_top, $tab_height, $nexY) - { - global $langs,$conf; - $langs->load("main"); - $langs->load("bills"); + function _tableau(&$pdf, $tab_top, $tab_height, $nexY) + { + global $langs,$conf; + $langs->load("main"); + $langs->load("bills"); - $pdf->SetFont('Arial','',11); - - $pdf->Text(30,$tab_top + 5,$langs->transnoentities("Designation")); - - $pdf->line(132, $tab_top, 132, $tab_top + $tab_height); - $pdf->Text(134,$tab_top + 5,$langs->transnoentities("VAT")); - - $pdf->line(144, $tab_top, 144, $tab_top + $tab_height); - $pdf->Text(147,$tab_top + 5,$langs->transnoentities("Qty")); - - $pdf->line(156, $tab_top, 156, $tab_top + $tab_height); - $pdf->Text(160,$tab_top + 5,$langs->transnoentities("PriceU")); - - $pdf->line(174, $tab_top, 174, $tab_top + $tab_height); - $pdf->Text(187,$tab_top + 5,$langs->transnoentities("Total")); - - // $pdf->Rect(10, $tab_top, 190, $nexY - $tab_top); - $pdf->Rect(10, $tab_top, 190, $tab_height); + $pdf->SetFont('Arial','',11); + + $pdf->Text(30,$tab_top + 5,$langs->transnoentities("Designation")); + + $pdf->line(132, $tab_top, 132, $tab_top + $tab_height); + $pdf->Text(134,$tab_top + 5,$langs->transnoentities("VAT")); + + $pdf->line(144, $tab_top, 144, $tab_top + $tab_height); + $pdf->Text(147,$tab_top + 5,$langs->transnoentities("Qty")); + + $pdf->line(156, $tab_top, 156, $tab_top + $tab_height); + $pdf->Text(160,$tab_top + 5,$langs->transnoentities("PriceU")); + + $pdf->line(174, $tab_top, 174, $tab_top + $tab_height); + $pdf->Text(187,$tab_top + 5,$langs->transnoentities("Total")); + + // $pdf->Rect(10, $tab_top, 190, $nexY - $tab_top); + $pdf->Rect(10, $tab_top, 190, $tab_height); - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('Arial','',10); - $titre = $langs->transnoentities("AmountInCurrency",$langs->transnoentities("Currency".$conf->monnaie)); - $pdf->Text(200 - $pdf->GetStringWidth($titre), 98, $titre); + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('Arial','',10); + $titre = $langs->transnoentities("AmountInCurrency",$langs->transnoentities("Currency".$conf->monnaie)); + $pdf->Text(200 - $pdf->GetStringWidth($titre), 98, $titre); - } + } function _pagehead(&$pdf, $com) { global $conf,$langs,$mysoc; $langs->load("orders"); - //Affiche le filigrane brouillon - Print Draft Watermark - if($com->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) - { - $watermark_angle=atan($this->page_hauteur/$this->page_largeur); - $watermark_x=5; - $watermark_y=$this->page_hauteur-25; //Set to $this->page_hauteur-50 or less if problems - $watermark_width=$this->page_hauteur; - $pdf->SetFont('Arial','B',50); - $pdf->SetTextColor(255,192,203); - //rotate - $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k)); - //print watermark - $pdf->SetXY($watermark_x,$watermark_y); - $pdf->Cell($watermark_width,25,clean_html($conf->global->COMMANDE_DRAFT_WATERMARK),0,2,"C",0); - //antirotate - $pdf->_out('Q'); - } - //Print content - + //Affiche le filigrane brouillon - Print Draft Watermark + if($com->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) + { + $watermark_angle=atan($this->page_hauteur/$this->page_largeur); + $watermark_x=5; + $watermark_y=$this->page_hauteur-25; //Set to $this->page_hauteur-50 or less if problems + $watermark_width=$this->page_hauteur; + $pdf->SetFont('Arial','B',50); + $pdf->SetTextColor(255,192,203); + //rotate + $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k)); + //print watermark + $pdf->SetXY($watermark_x,$watermark_y); + $pdf->Cell($watermark_width,25,clean_html($conf->global->COMMANDE_DRAFT_WATERMARK),0,2,"C",0); + //antirotate + $pdf->_out('Q'); + } + //Print content + $pdf->SetXY(10,8); if (defined("MAIN_INFO_SOCIETE_NOM")) { @@ -337,8 +347,8 @@ class pdf_edison extends ModelePDFCommandes $pdf->SetFont('Arial','B',14); $pdf->MultiCell(76, 4, MAIN_INFO_SOCIETE_NOM, 0, 'L'); } - - $pdf->SetX(10); + + $pdf->SetX(10); $pdf->SetTextColor(70,70,170); if (defined("FAC_PDF_ADRESSE")) { @@ -355,7 +365,7 @@ class pdf_edison extends ModelePDFCommandes $pdf->SetFont('Arial','',10); $pdf->MultiCell(76, 5, "SIREN : ".MAIN_INFO_SIREN); } - + if (defined("FAC_PDF_INTITULE2")) { $pdf->SetXY(100,5); @@ -364,8 +374,8 @@ class pdf_edison extends ModelePDFCommandes $pdf->MultiCell(100, 10, FAC_PDF_INTITULE2, '' , 'R'); } /* - * Adresse Client - */ + * Adresse Client + */ $pdf->SetTextColor(0,0,0); $pdf->SetFont('Arial','B',12); $client = new Societe($this->db); @@ -377,16 +387,22 @@ class pdf_edison extends ModelePDFCommandes $pdf->SetXY(102,$pdf->GetY()); $pdf->MultiCell(96,5, $com->client->adresse . "\n" . $com->client->cp . " " . $com->client->ville); $pdf->rect(100, 40, 100, 40); - - + + $pdf->SetTextColor(200,0,0); $pdf->SetFont('Arial','B',12); $pdf->Text(11, 88, "Date : " . dolibarr_print_date($com->date,'day')); $pdf->Text(11, 94, $langs->transnoentities("Order")." ".$com->ref); - - } - + + /* + * \brief Affiche le pied de page + * \param pdf objet PDF + */ + function _pagefoot(&$pdf,$object,$outputlangs) + { + return pdf_pagefoot($pdf,$outputlangs,'COMMANDE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); + } } ?> diff --git a/htdocs/includes/modules/commande/pdf_einstein.modules.php b/htdocs/includes/modules/commande/pdf_einstein.modules.php index da86a8c47e7..a6e51a49ae0 100644 --- a/htdocs/includes/modules/commande/pdf_einstein.modules.php +++ b/htdocs/includes/modules/commande/pdf_einstein.modules.php @@ -20,12 +20,12 @@ */ /** - \file htdocs/includes/modules/commande/pdf_einstein.modules.php - \ingroup commande - \brief Fichier de la classe permettant de générer les commandes au modèle Einstein - \author Laurent Destailleur - \version $Id$ -*/ + \file htdocs/includes/modules/commande/pdf_einstein.modules.php + \ingroup commande + \brief Fichier de la classe permettant de générer les commandes au modèle Einstein + \author Laurent Destailleur + \version $Id$ + */ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/commande/modules_commande.php"); require_once(DOL_DOCUMENT_ROOT."/product.class.php"); @@ -33,101 +33,101 @@ require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); /** - \class pdf_einstein - \brief Classe permettant de générer les commandes au modèle Einstein -*/ + \class pdf_einstein + \brief Classe permettant de générer les commandes au modèle Einstein + */ class pdf_einstein extends ModelePDFCommandes { var $emetteur; // Objet societe qui emet - /** - \brief Constructeur - \param db Handler accès base de donnée - */ - function pdf_einstein($db) - { - global $conf,$langs,$mysoc; + /** + \brief Constructeur + \param db Handler accès base de donnée + */ + function pdf_einstein($db) + { + global $conf,$langs,$mysoc; $langs->load("main"); - $langs->load("bills"); + $langs->load("bills"); - $this->db = $db; - $this->name = "einstein"; - $this->description = $langs->trans('PDFEinsteinDescription'); + $this->db = $db; + $this->name = "einstein"; + $this->description = $langs->trans('PDFEinsteinDescription'); - // 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_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_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 commande sur le disque - * \param com Objet commande à générer + /** + * \brief Fonction générant la commande sur le disque + * \param com Objet commande à générer * \param outputlangs Lang object for output language - * \return int 1=ok, 0=ko - */ - function write_file($com,$outputlangs='') - { - global $user,$langs,$conf; + * \return int 1=ok, 0=ko + */ + function write_file($com,$outputlangs='') + { + global $user,$langs,$conf; if (! is_object($outputlangs)) $outputlangs=$langs; $outputlangs->load("main"); $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("bills"); - $outputlangs->load("products"); - $outputlangs->load("orders"); + $outputlangs->load("companies"); + $outputlangs->load("bills"); + $outputlangs->load("products"); + $outputlangs->load("orders"); $outputlangs->setPhpLang(); - if ($conf->commande->dir_output) + if ($conf->commande->dir_output) { // Définition de l'objet $com (pour compatibilite ascendante) - if (! is_object($com)) - { - $id = $com; - $com = new Commande($this->db,"",$id); - $ret=$com->fetch($id); + if (! is_object($com)) + { + $id = $com; + $com = new Commande($this->db,"",$id); + $ret=$com->fetch($id); } - $deja_regle = ""; + $deja_regle = ""; // Définition de $dir et $file if ($com->specimen) @@ -143,886 +143,816 @@ class pdf_einstein extends ModelePDFCommandes } if (! file_exists($dir)) - { - if (create_exdir($dir) < 0) - { - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); - return 0; - } - } + { + if (create_exdir($dir) < 0) + { + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); + return 0; + } + } - if (file_exists($dir)) - { - $nblignes = sizeof($com->lignes); + if (file_exists($dir)) + { + $nblignes = sizeof($com->lignes); - // Protection et encryption du pdf - if ($conf->global->PDF_SECURITY_ENCRYPTION) - { + // Protection et encryption du pdf + if ($conf->global->PDF_SECURITY_ENCRYPTION) + { $pdf=new FPDI_Protection('P','mm',$this->format); - $pdfrights = array('print'); // Ne permet que l'impression du document - $pdfuserpass = ''; // Mot de passe pour l'utilisateur final - $pdfownerpass = NULL; // Mot de passe du propriétaire, créé aléatoirement si pas défini - $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass); - } - else - { - $pdf=new FPDI('P','mm',$this->format); + $pdfrights = array('print'); // Ne permet que l'impression du document + $pdfuserpass = ''; // Mot de passe pour l'utilisateur final + $pdfownerpass = NULL; // Mot de passe du propriétaire, créé aléatoirement si pas défini + $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass); + } + else + { + $pdf=new FPDI('P','mm',$this->format); } - $pdf->Open(); - $pdf->AddPage(); + $pdf->Open(); + $pdf->AddPage(); - $pdf->SetDrawColor(128,128,128); + $pdf->SetDrawColor(128,128,128); - $pdf->SetTitle($com->ref); - $pdf->SetSubject($outputlangs->transnoentities("Order")); - $pdf->SetCreator("Dolibarr ".DOL_VERSION); - $pdf->SetAuthor($user->fullname); + $pdf->SetTitle($com->ref); + $pdf->SetSubject($outputlangs->transnoentities("Order")); + $pdf->SetCreator("Dolibarr ".DOL_VERSION); + $pdf->SetAuthor($user->fullname); - $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right - $pdf->SetAutoPageBreak(1,0); + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetAutoPageBreak(1,0); - // Positionne $this->atleastonediscount si on a au moins une remise - for ($i = 0 ; $i < $nblignes ; $i++) - { - if ($com->lignes[$i]->remise_percent) - { - $this->atleastonediscount++; - } - } + // Positionne $this->atleastonediscount si on a au moins une remise + for ($i = 0 ; $i < $nblignes ; $i++) + { + if ($com->lignes[$i]->remise_percent) + { + $this->atleastonediscount++; + } + } - // Tete de page - $this->_pagehead($pdf, $com, 1, $outputlangs); + // Tete de page + $this->_pagehead($pdf, $com, 1, $outputlangs); - $pagenb = 1; - $tab_top = 90; - $tab_top_newpage = 50; - $tab_height = 110; - $tab_height_newpage = 180; + $pagenb = 1; + $tab_top = 90; + $tab_top_newpage = 50; + $tab_height = 110; + $tab_height_newpage = 180; // Affiche notes - if ($com->note_public) - { - $tab_top = 88; + if ($com->note_public) + { + $tab_top = 88; - $pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page - $pdf->SetXY ($this->posxdesc-1, $tab_top); - $pdf->MultiCell(190, 3, $com->note_public, 0, 'J'); - $nexY = $pdf->GetY(); - $height_note=$nexY-$tab_top; + $pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page + $pdf->SetXY ($this->posxdesc-1, $tab_top); + $pdf->MultiCell(190, 3, $com->note_public, 0, 'J'); + $nexY = $pdf->GetY(); + $height_note=$nexY-$tab_top; - // Rect prend une longueur en 3eme param - $pdf->SetDrawColor(192,192,192); - $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); + // Rect prend une longueur en 3eme param + $pdf->SetDrawColor(192,192,192); + $pdf->Rect($this->marge_gauche, $tab_top-1, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $height_note+1); - $tab_height = $tab_height - $height_note; - $tab_top = $nexY+6; - } - else - { - $height_note=0; - } + $tab_height = $tab_height - $height_note; + $tab_top = $nexY+6; + } + else + { + $height_note=0; + } - $iniY = $tab_top + 8; - $curY = $tab_top + 8; - $nexY = $tab_top + 8; + $iniY = $tab_top + 8; + $curY = $tab_top + 8; + $nexY = $tab_top + 8; - // Boucle sur les lignes - for ($i = 0 ; $i < $nblignes ; $i++) - { - $curY = $nexY; + // Boucle sur les lignes + for ($i = 0 ; $i < $nblignes ; $i++) + { + $curY = $nexY; - // Description de la ligne produit - $libelleproduitservice=dol_htmlentitiesbr($com->lignes[$i]->libelle,1); - if ($com->lignes[$i]->desc && $com->lignes[$i]->desc!=$com->lignes[$i]->libelle) - { - if ($libelleproduitservice) $libelleproduitservice.="
"; - if ($com->lignes[$i]->desc == '(CREDIT_NOTE)' && $com->lignes[$i]->fk_remise_except) - { - $discount=new DiscountAbsolute($this->db); - $discount->fetch($com->lignes[$i]->fk_remise_except); - $libelleproduitservice=dol_htmlentitiesbr($langs->trans("DiscountFromCreditNote",$discount->ref_facture_source),1); - } - else - { - $libelleproduitservice.=dol_htmlentitiesbr($com->lignes[$i]->desc,1); - } - } - // Si ligne associée à un code produit - if ($com->lignes[$i]->fk_product) - { - $prodser = new Product($this->db); - $prodser->fetch($com->lignes[$i]->fk_product); + // Description de la ligne produit + $libelleproduitservice=dol_htmlentitiesbr($com->lignes[$i]->libelle,1); + if ($com->lignes[$i]->desc && $com->lignes[$i]->desc!=$com->lignes[$i]->libelle) + { + if ($libelleproduitservice) $libelleproduitservice.="
"; + if ($com->lignes[$i]->desc == '(CREDIT_NOTE)' && $com->lignes[$i]->fk_remise_except) + { + $discount=new DiscountAbsolute($this->db); + $discount->fetch($com->lignes[$i]->fk_remise_except); + $libelleproduitservice=dol_htmlentitiesbr($langs->trans("DiscountFromCreditNote",$discount->ref_facture_source),1); + } + else + { + $libelleproduitservice.=dol_htmlentitiesbr($com->lignes[$i]->desc,1); + } + } + // Si ligne associée à un code produit + if ($com->lignes[$i]->fk_product) + { + $prodser = new Product($this->db); + $prodser->fetch($com->lignes[$i]->fk_product); // On ajoute la ref - if ($prodser->ref) + if ($prodser->ref) { $prefix_prodserv = ""; - if($prodser->isservice()) - $prefix_prodserv = $outputlangs->transnoentities("Service")." "; - else - $prefix_prodserv = $outputlangs->transnoentities("Product")." "; + if($prodser->isservice()) + $prefix_prodserv = $outputlangs->transnoentities("Service")." "; + else + $prefix_prodserv = $outputlangs->transnoentities("Product")." "; - $libelleproduitservice=$prefix_prodserv.$prodser->ref." - ".$libelleproduitservice; - } + $libelleproduitservice=$prefix_prodserv.$prodser->ref." - ".$libelleproduitservice; + } - } + } - if ($com->lignes[$i]->date_start && $com->lignes[$i]->date_end) - { - // Affichage duree si il y en a une - $libelleproduitservice.="
".dol_htmlentitiesbr("(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($com->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($com->lignes[$i]->date_end).")",1); - } + if ($com->lignes[$i]->date_start && $com->lignes[$i]->date_end) + { + // Affichage duree si il y en a une + $libelleproduitservice.="
".dol_htmlentitiesbr("(".$outputlangs->transnoentities("From")." ".dolibarr_print_date($com->lignes[$i]->date_start)." ".$outputlangs->transnoentities("to")." ".dolibarr_print_date($com->lignes[$i]->date_end).")",1); + } - $pdf->SetFont('Arial','', 9); // Dans boucle pour gerer multi-page + $pdf->SetFont('Arial','', 9); // Dans boucle pour gerer multi-page // Description - $pdf->writeHTMLCell($this->posxtva-$this->posxdesc-1, 3, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1); + $pdf->writeHTMLCell($this->posxtva-$this->posxdesc-1, 3, $this->posxdesc-1, $curY, $libelleproduitservice, 0, 1); - $pdf->SetFont('Arial','', 9); // On repositionne la police par défaut - - $nexY = $pdf->GetY(); + $pdf->SetFont('Arial','', 9); // On repositionne la police par défaut - // TVA - $pdf->SetXY ($this->posxtva, $curY); - $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, vatrate($com->lignes[$i]->tva_tx,1,$com->lignes[$i]->info_bits), 0, 'R'); + $nexY = $pdf->GetY(); - // Prix unitaire HT avant remise - $pdf->SetXY ($this->posxup, $curY); - $pdf->MultiCell($this->posxqty-$this->posxup-1, 3, price($com->lignes[$i]->subprice), 0, 'R', 0); + // TVA + $pdf->SetXY ($this->posxtva, $curY); + $pdf->MultiCell($this->posxup-$this->posxtva-1, 3, vatrate($com->lignes[$i]->tva_tx,1,$com->lignes[$i]->info_bits), 0, 'R'); - // Quantity - $pdf->SetXY ($this->posxqty, $curY); - $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $com->lignes[$i]->qty, 0, 'R'); + // Prix unitaire HT avant remise + $pdf->SetXY ($this->posxup, $curY); + $pdf->MultiCell($this->posxqty-$this->posxup-1, 3, price($com->lignes[$i]->subprice), 0, 'R', 0); - // Remise sur ligne - $pdf->SetXY ($this->posxdiscount, $curY); - if ($com->lignes[$i]->remise_percent) - { - $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, dolibarr_print_reduction($com->lignes[$i]->remise_percent), 0, 'R'); - } + // Quantity + $pdf->SetXY ($this->posxqty, $curY); + $pdf->MultiCell($this->posxdiscount-$this->posxqty-1, 3, $com->lignes[$i]->qty, 0, 'R'); - // Total HT ligne - $pdf->SetXY ($this->postotalht, $curY); - $total = price($com->lignes[$i]->total_ht); - $pdf->MultiCell(26, 4, $total, 0, 'R', 0); + // Remise sur ligne + $pdf->SetXY ($this->posxdiscount, $curY); + if ($com->lignes[$i]->remise_percent) + { + $pdf->MultiCell($this->postotalht-$this->posxdiscount-1, 3, dolibarr_print_reduction($com->lignes[$i]->remise_percent), 0, 'R'); + } - // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva - $tvaligne=$com->lignes[$i]->total_tva; - if ($com->remise_percent) $tvaligne-=($tvaligne*$com->remise_percent)/100; - $vatrate=(string) $com->lignes[$i]->tva_tx; + // Total HT ligne + $pdf->SetXY ($this->postotalht, $curY); + $total = price($com->lignes[$i]->total_ht); + $pdf->MultiCell(26, 4, $total, 0, 'R', 0); + + // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva + $tvaligne=$com->lignes[$i]->total_tva; + if ($com->remise_percent) $tvaligne-=($tvaligne*$com->remise_percent)/100; + $vatrate=(string) $com->lignes[$i]->tva_tx; if ($com->lignes[$i]->info_bits & 0x01 == 0x01) $vatrate.='*'; - $this->tva[$vatrate] += $tvaligne; + $this->tva[$vatrate] += $tvaligne; - $nexY+=2; // Passe espace entre les lignes + $nexY+=2; // Passe espace entre les lignes - if ($nexY > ($tab_top+$tab_height) && $i < ($nblignes - 1)) - { - if ($pagenb == 1) - { - $this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); - } - else - { - $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); - } + if ($nexY > ($tab_top+$tab_height) && $i < ($nblignes - 1)) + { + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY, $outputlangs); + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $tab_height_newpage, $nexY, $outputlangs); + } $this->_pagefoot($pdf,$outputlangs); - // Nouvelle page - $pdf->AddPage(); - $pagenb++; - $this->_pagehead($pdf, $com, 0, $outputlangs); + // Nouvelle page + $pdf->AddPage(); + $pagenb++; + $this->_pagehead($pdf, $com, 0, $outputlangs); - $nexY = $tab_top_newpage + 8; - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('Arial','', 10); - } + $nexY = $tab_top_newpage + 8; + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('Arial','', 10); + } - } + } - // Affiche cadre tableau - if ($pagenb == 1) - { - $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); - $bottomlasttab=$tab_top + $tab_height + 1; - } - else - { - $this->_tableau($pdf, $tab_top_newpage, $tab_height, $nexY, $outputlangs); - $bottomlasttab=$tab_top_newpage + $tab_height + 1; - } + // Affiche cadre tableau + if ($pagenb == 1) + { + $this->_tableau($pdf, $tab_top, $tab_height, $nexY, $outputlangs); + $bottomlasttab=$tab_top + $tab_height + 1; + } + else + { + $this->_tableau($pdf, $tab_top_newpage, $tab_height, $nexY, $outputlangs); + $bottomlasttab=$tab_top_newpage + $tab_height + 1; + } // Affiche zone infos - $posy=$this->_tableau_info($pdf, $com, $bottomlasttab, $outputlangs); - // Affiche zone totaux - $posy=$this->_tableau_tot($pdf, $com, $deja_regle, $bottomlasttab, $outputlangs); + $posy=$this->_tableau_info($pdf, $com, $bottomlasttab, $outputlangs); + // Affiche zone totaux + $posy=$this->_tableau_tot($pdf, $com, $deja_regle, $bottomlasttab, $outputlangs); - // Affiche zone versements - if ($deja_regle) + // Affiche zone versements + if ($deja_regle) { - $posy=$this->_tableau_versements($pdf, $com, $posy, $outputlangs); - } + $posy=$this->_tableau_versements($pdf, $com, $posy, $outputlangs); + } - // Pied de page - $this->_pagefoot($pdf,$outputlangs); - $pdf->AliasNbPages(); + // Pied de page + $this->_pagefoot($pdf,$outputlangs); + $pdf->AliasNbPages(); - $pdf->Close(); + $pdf->Close(); - $pdf->Output($file); + $pdf->Output($file); $langs->setPhpLang(); // On restaure langue session - return 1; // Pas d'erreur - } - else - { - $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); + return 1; // Pas d'erreur + } + else + { + $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); $langs->setPhpLang(); // On restaure langue session - return 0; - } - } - else - { - $this->error=$langs->trans("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR"); + return 0; + } + } + else + { + $this->error=$langs->trans("ErrorConstantNotDefined","COMMANDE_OUTPUTDIR"); $langs->setPhpLang(); // On restaure langue session - return 0; - } - $this->error=$langs->trans("ErrorUnknown"); + return 0; + } + $this->error=$langs->trans("ErrorUnknown"); $langs->setPhpLang(); // On restaure langue session - return 0; // Erreur par defaut - } + return 0; // Erreur par defaut + } - /* - * \brief Affiche tableau des versement - * \param pdf Objet PDF - * \param object Objet commande + /* + * \brief Affiche tableau des versement + * \param pdf Objet PDF + * \param object Objet commande * \param posy Position y in PDF * \param outputlangs Object langs for output * \return int <0 if KO, >0 if OK - */ - function _tableau_versements(&$pdf, $object, $posy, $outputlangs) + */ + function _tableau_versements(&$pdf, $object, $posy, $outputlangs) { - - } + + } /* - * \brief Affiche infos divers - * \param pdf Objet PDF - * \param object Objet commande - * \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 commande + * \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); - - $posy=$pdf->GetY()+4; - } - - /* - * Conditions de reglements - */ - if ($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):$object->cond_reglement; - $pdf->MultiCell(80, 5, $lib_condition_paiement,0,'L'); - - $posy=$pdf->GetY()+3; - } - - /* - * Check si absence mode reglement - */ - if (! $conf->global->FACTURE_CHQ_NUMBER && ! $conf->global->FACTURE_RIB_NUMBER) + /* + * If France, show VAT mention if not applicable + */ + if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1) { - $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->SetFont('Arial','B',8); + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); - $posy=$pdf->GetY()+1; - } - - /* - * 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); - - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio).':',0,'L',0); - $posy=$pdf->GetY()+1; - - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('Arial','',8); - $pdf->MultiCell(80, 3, $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').' '.$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, $this->emetteur->adresse_full, 0, 'L', 0); - - $posy=$pdf->GetY()+2; - } - } + $posy=$pdf->GetY()+4; } - /* - * 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); - - $this->marges['g']=$this->marge_gauche; - - $cury=$posy; - $pdf->SetXY ($this->marges['g'], $cury); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0); - $cury+=4; - $pdf->SetFont('Arial','B',6); - $pdf->line($this->marges['g']+1, $cury, $this->marges['g']+1, $cury+10 ); - $pdf->SetXY ($this->marges['g'], $cury); - $pdf->MultiCell(18, 3, $outputlangs->transnoentities("BankCode"), 0, 'C', 0); - $pdf->line($this->marges['g']+18, $cury, $this->marges['g']+18, $cury+10 ); - $pdf->SetXY ($this->marges['g']+18, $cury); - $pdf->MultiCell(18, 3, $outputlangs->transnoentities("DeskCode"), 0, 'C', 0); - $pdf->line($this->marges['g']+36, $cury, $this->marges['g']+36, $cury+10 ); - $pdf->SetXY ($this->marges['g']+36, $cury); - $pdf->MultiCell(24, 3, $outputlangs->transnoentities("BankAccountNumber"), 0, 'C', 0); - $pdf->line($this->marges['g']+60, $cury, $this->marges['g']+60, $cury+10 ); - $pdf->SetXY ($this->marges['g']+60, $cury); - $pdf->MultiCell(13, 3, $outputlangs->transnoentities("BankAccountNumberKey"), 0, 'C', 0); - $pdf->line($this->marges['g']+73, $cury, $this->marges['g']+73, $cury+10 ); - - $pdf->SetFont('Arial','',8); - $pdf->SetXY ($this->marges['g'], $cury+5); - $pdf->MultiCell(18, 3, $account->code_banque, 0, 'C', 0); - $pdf->SetXY ($this->marges['g']+18, $cury+5); - $pdf->MultiCell(18, 3, $account->code_guichet, 0, 'C', 0); - $pdf->SetXY ($this->marges['g']+36, $cury+5); - $pdf->MultiCell(24, 3, $account->number, 0, 'C', 0); - $pdf->SetXY ($this->marges['g']+60, $cury+5); - $pdf->MultiCell(13, 3, $account->cle_rib, 0, 'C', 0); - - $pdf->SetXY ($this->marges['g'], $cury+12); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities("Residence").' : ' . $account->domiciliation, 0, 'L', 0); - $pdf->SetXY ($this->marges['g'], $cury+22); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities("IbanPrefix").' : ' . $account->iban_prefix, 0, 'L', 0); - $pdf->SetXY ($this->marges['g'], $cury+25); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities("BIC").' : ' . $account->bic, 0, 'L', 0); - - $posy=$pdf->GetY()+2; - } - } + /* + * Conditions de reglements + */ + if ($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):$object->cond_reglement; + $pdf->MultiCell(80, 5, $lib_condition_paiement,0,'L'); + + $posy=$pdf->GetY()+3; } - - return $posy; - } + + /* + * 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') + { + // 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',$account->proprio).':',0,'L',0); + $posy=$pdf->GetY()+1; + + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('Arial','',8); + $pdf->MultiCell(80, 3, $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').' '.$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, $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); + + $this->marges['g']=$this->marge_gauche; + + $cury=$posy; + $pdf->SetXY ($this->marges['g'], $cury); + $pdf->SetFont('Arial','B',8); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0); + $cury+=4; + $pdf->SetFont('Arial','B',6); + $pdf->line($this->marges['g']+1, $cury, $this->marges['g']+1, $cury+10 ); + $pdf->SetXY ($this->marges['g'], $cury); + $pdf->MultiCell(18, 3, $outputlangs->transnoentities("BankCode"), 0, 'C', 0); + $pdf->line($this->marges['g']+18, $cury, $this->marges['g']+18, $cury+10 ); + $pdf->SetXY ($this->marges['g']+18, $cury); + $pdf->MultiCell(18, 3, $outputlangs->transnoentities("DeskCode"), 0, 'C', 0); + $pdf->line($this->marges['g']+36, $cury, $this->marges['g']+36, $cury+10 ); + $pdf->SetXY ($this->marges['g']+36, $cury); + $pdf->MultiCell(24, 3, $outputlangs->transnoentities("BankAccountNumber"), 0, 'C', 0); + $pdf->line($this->marges['g']+60, $cury, $this->marges['g']+60, $cury+10 ); + $pdf->SetXY ($this->marges['g']+60, $cury); + $pdf->MultiCell(13, 3, $outputlangs->transnoentities("BankAccountNumberKey"), 0, 'C', 0); + $pdf->line($this->marges['g']+73, $cury, $this->marges['g']+73, $cury+10 ); + + $pdf->SetFont('Arial','',8); + $pdf->SetXY ($this->marges['g'], $cury+5); + $pdf->MultiCell(18, 3, $account->code_banque, 0, 'C', 0); + $pdf->SetXY ($this->marges['g']+18, $cury+5); + $pdf->MultiCell(18, 3, $account->code_guichet, 0, 'C', 0); + $pdf->SetXY ($this->marges['g']+36, $cury+5); + $pdf->MultiCell(24, 3, $account->number, 0, 'C', 0); + $pdf->SetXY ($this->marges['g']+60, $cury+5); + $pdf->MultiCell(13, 3, $account->cle_rib, 0, 'C', 0); + + $pdf->SetXY ($this->marges['g'], $cury+12); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities("Residence").' : ' . $account->domiciliation, 0, 'L', 0); + $pdf->SetXY ($this->marges['g'], $cury+22); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities("IbanPrefix").' : ' . $account->iban_prefix, 0, 'L', 0); + $pdf->SetXY ($this->marges['g'], $cury+25); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities("BIC").' : ' . $account->bic, 0, 'L', 0); + + $posy=$pdf->GetY()+2; + } + } + } + + return $posy; + } - /* - * \brief Affiche le total a payer - * \param pdf Objet PDF - * \param object Objet commande - * \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 commande + * \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 = 182; $largcol2 = $lltot - $col2x; - // 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); + // 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); + $pdf->SetXY ($col2x, $tab2_top + 0); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1); - $index = 0; + $index = 0; - // Affichage des totaux de TVA par taux (conformément à réglementation) - $pdf->SetFillColor(248,248,248); + // Affichage des totaux de TVA par taux (conformément à réglementation) + $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").")"; + $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->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($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($object->total_tva), 0, 'R', 1); + } - $useborder=0; + $useborder=0; - $index++; - $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); - $pdf->SetTextColor(0,0,60); - $pdf->SetFillColor(224,224,224); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + $index++; + $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); + $pdf->SetTextColor(0,0,60); + $pdf->SetFillColor(224,224,224); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $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); + $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); - if ($deja_regle > 0) - { - $index++; + if ($deja_regle > 0) + { + $index++; - $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPayed"), 0, 'L', 0); + $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); + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); $resteapayer = $object->total_ttc - $deja_regle; - $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); + $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->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 commandes - * \param pdf objet PDF - */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) - { - global $conf; + /** + * \brief Affiche la grille des lignes de commandes + * \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); + // 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); - $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 Affiche en-tête commande - * \param pdf Objet PDF - * \param com Objet commande - * \param showadress 0=non, 1=oui - * \param outputlang Objet lang cible - */ - function _pagehead(&$pdf, $object, $showadress=1, $outputlangs) - { + /* + * \brief Affiche en-tête commande + * \param pdf Objet PDF + * \param com Objet commande + * \param showadress 0=non, 1=oui + * \param outputlang Objet lang cible + */ + 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->COMMANDE_DRAFT_WATERMARK)) ) - { - $watermark_angle=atan($this->page_hauteur/$this->page_largeur); - $watermark_x=5; - $watermark_y=$this->page_hauteur-25; //Set to $this->page_hauteur-50 or less if problems - $watermark_width=$this->page_hauteur; - $pdf->SetFont('Arial','B',50); - $pdf->SetTextColor(255,192,203); - //rotate - $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k)); - //print watermark - $pdf->SetXY($watermark_x,$watermark_y); - $pdf->Cell($watermark_width,25,clean_html($conf->global->COMMANDE_DRAFT_WATERMARK),0,2,"C",0); - //antirotate - $pdf->_out('Q'); - } - //Print content - - $pdf->SetTextColor(0,0,60); - $pdf->SetFont('Arial','B',13); - - $posy=$this->marge_haute; - - $pdf->SetXY($this->marge_gauche,$posy); - - // 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->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("Order"); - $pdf->MultiCell(100, 4, $title, '' , 'R'); - - $pdf->SetFont('Arial','B',12); - - $posy+=6; - $pdf->SetXY(100,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $object->ref, '', 'R'); - - $posy+=1; - $pdf->SetFont('Arial','',10); - - $posy+=5; - $pdf->SetXY(100,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dolibarr_print_date($object->date,"%d %b %Y"), '', '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").":"); - - - $pdf->SetXY($this->marge_gauche,$posy); - $pdf->SetFillColor(230,230,230); - $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); - - - $pdf->SetXY($this->marge_gauche+2,$posy+3); - - // Nom emetteur - $pdf->SetTextColor(0,0,60); - $pdf->SetFont('Arial','B',11); - if (defined("FAC_PDF_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) $pdf->MultiCell(80, 4, FAC_PDF_SOCIETE_NOM, 0, 'L'); - else $pdf->MultiCell(80, 4, $this->emetteur->nom, 0, 'L'); - - // Caractéristiques emetteur - $carac_emetteur = ''; - if (defined("FAC_PDF_ADRESSE") && FAC_PDF_ADRESSE) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).FAC_PDF_ADRESSE; - else { - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$this->emetteur->adresse; - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$this->emetteur->cp.' '.$this->emetteur->ville; - } - $carac_emetteur .= "\n"; - - // Tel - if (defined("FAC_PDF_TEL") && FAC_PDF_TEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".FAC_PDF_TEL; - elseif ($this->emetteur->tel) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".$this->emetteur->tel; - - // Fax - if (defined("FAC_PDF_FAX") && FAC_PDF_FAX) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".FAC_PDF_FAX; - elseif ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$this->emetteur->fax; - - // EMail - if (defined("FAC_PDF_MEL") && FAC_PDF_MEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".FAC_PDF_MEL; - elseif ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$this->emetteur->email; - - // Web - if (defined("FAC_PDF_WWW") && FAC_PDF_WWW) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".FAC_PDF_WWW; - elseif ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$this->emetteur->url; - - $pdf->SetFont('Arial','',9); - $pdf->SetXY($this->marge_gauche+2,$posy+8); - $pdf->MultiCell(80,4, $carac_emetteur); - - // Client destinataire - $posy=42; - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('Arial','',8); - $pdf->SetXY(102,$posy-5); - $pdf->MultiCell(80,5, $outputlangs->transnoentities("BillTo").":"); - $object->fetch_client(); - - // Cadre client destinataire - $pdf->rect(100, $posy, 100, $hautcadre); - - // If CUSTOMER contact defined on invoice, we use it - $usecontact=false; - if ($conf->global->COMMANDE_USE_CUSTOMER_CONTACT_AS_RECIPIENT) - { - $arrayidcontact=$object->getIdContact('external','CUSTOMER'); - if (sizeof($arrayidcontact) > 0) - { - $usecontact=true; - $result=$object->fetch_contact($arrayidcontact[0]); - } - } - - if ($usecontact) - { - // Nom societe - $pdf->SetXY(102,$posy+3); - $pdf->SetFont('Arial','B',11); - $pdf->MultiCell(96,4, $object->client->nom, 0, 'L'); - - // Nom client - $carac_client = "\n".$object->contact->getFullName($outputlangs,1,1); - - // Caractéristiques client - $carac_client.="\n".$object->contact->adresse; - $carac_client.="\n".$object->contact->cp . " " . $object->contact->ville."\n"; - //Pays si different de l'emetteur - if ($this->emetteur->pays_code != $object->contact->pays_code) - { - dol_entity_decode($carac_client.=$object->contact->pays)."\n"; - } - } - else - { - // Nom client - $pdf->SetXY(102,$posy+3); - $pdf->SetFont('Arial','B',11); - $pdf->MultiCell(96,4, $object->client->nom, 0, 'L'); - - // 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 - if( !preg_match('#'.$object->contact->getFullName($outputlangs,1).'#isU',$object->client->nom) ) - { - $carac_client .= "\n".$object->contact->getFullName($outputlangs,1,1); - } - } - - // Caractéristiques client - $carac_client.="\n".$object->client->adresse; - $carac_client.="\n".$object->client->cp . " " . $object->client->ville."\n"; - - //Pays si different de l'emetteur - if ($this->emetteur->pays_code != $object->client->pays_code) - { - $carac_client.=dol_entity_decode($object->client->pays)."\n"; - } - } - // Numéro TVA intracom - if ($object->client->tva_intra) $carac_client.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$object->client->tva_intra; - $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 Affiche le pied de page - * \param pdf objet PDF - */ - function _pagefoot(&$pdf,$outputlangs) - { - global $conf; - - // Line of free text - $ligne=(! empty($conf->global->COMMANDE_FREE_TEXT))?$conf->global->COMMANDE_FREE_TEXT:""; - - // Premiere ligne d'info réglementaires - $ligne1=""; - if ($this->emetteur->forme_juridique_code) - { - $ligne1.=($ligne1?" - ":"").getFormeJuridiqueLabel($this->emetteur->forme_juridique_code); - } - if ($this->emetteur->capital) - { - $ligne1.=($ligne1?" - ":"").$outputlangs->transnoentities("CapitalOf",$this->emetteur->capital)." ".$outputlangs->transnoentities("Currency".$conf->monnaie); - } - if ($this->emetteur->profid2) - { - $ligne1.=($ligne1?" - ":"").$outputlangs->transcountrynoentities("ProfId2",$this->emetteur->pays_code).": ".$this->emetteur->profid2; - } - if ($this->emetteur->profid1 && (! $this->emetteur->profid2 || $this->emetteur->pays_code != 'FR')) - { - $ligne1.=($ligne1?" - ":"").$outputlangs->transcountrynoentities("ProfId1",$this->emetteur->pays_code).": ".$this->emetteur->profid1; - } - - // Deuxieme ligne d'info réglementaires - $ligne2=""; - if ($this->emetteur->profid3) - { - $ligne2.=($ligne2?" - ":"").$outputlangs->transcountrynoentities("ProfId3",$this->emetteur->pays_code).": ".$this->emetteur->profid3; - } - if ($this->emetteur->profid4) - { - $ligne2.=($ligne2?" - ":"").$outputlangs->transcountrynoentities("ProfId4",$this->emetteur->pays_code).": ".$this->emetteur->profid4; - } - if ($this->emetteur->tva_intra != '') - { - $ligne2.=($ligne2?" - ":"").$outputlangs->transnoentities("VATIntraShort").": ".$this->emetteur->tva_intra; - } - - $pdf->SetFont('Arial','',7); - $pdf->SetDrawColor(224,224,224); - - // On positionne le debut du bas de page selon nbre de lignes de ce bas de page - $posy=$this->marge_basse + 1 + ($ligne?6:0) + ($ligne1?3:0) + ($ligne2?3:0); - - if ($ligne) + //Affiche le filigrane brouillon - Print Draft Watermark + if($object->statut==0 && (! empty($conf->global->COMMANDE_DRAFT_WATERMARK)) ) { - $pdf->SetXY($this->marge_gauche,-$posy); - $pdf->MultiCell(190, 3, $ligne, 0, 'L', 0); - $posy-=9; // 6 of ligne + 3 of MultiCell + $watermark_angle=atan($this->page_hauteur/$this->page_largeur); + $watermark_x=5; + $watermark_y=$this->page_hauteur-25; //Set to $this->page_hauteur-50 or less if problems + $watermark_width=$this->page_hauteur; + $pdf->SetFont('Arial','B',50); + $pdf->SetTextColor(255,192,203); + //rotate + $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k)); + //print watermark + $pdf->SetXY($watermark_x,$watermark_y); + $pdf->Cell($watermark_width,25,clean_html($conf->global->COMMANDE_DRAFT_WATERMARK),0,2,"C",0); + //antirotate + $pdf->_out('Q'); } - - $pdf->SetY(-$posy); - $pdf->line($this->marge_gauche, $this->page_hauteur-$posy, 200, $this->page_hauteur-$posy); - $posy--; + //Print content + + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('Arial','B',13); - if ($ligne1) - { - $pdf->SetXY($this->marge_gauche,-$posy); - $pdf->MultiCell(200, 2, $ligne1, 0, 'C', 0); - } + $posy=$this->marge_haute; - if ($ligne2) - { - $posy-=3; - $pdf->SetXY($this->marge_gauche,-$posy); - $pdf->MultiCell(200, 2, $ligne2, 0, 'C', 0); - } + $pdf->SetXY($this->marge_gauche,$posy); - $pdf->SetXY(-20,-$posy); - $pdf->MultiCell(11, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0); - } + // 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->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("Order"); + $pdf->MultiCell(100, 4, $title, '' , 'R'); + + $pdf->SetFont('Arial','B',12); + + $posy+=6; + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $object->ref, '', 'R'); + + $posy+=1; + $pdf->SetFont('Arial','',10); + + $posy+=5; + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("OrderDate")." : " . dolibarr_print_date($object->date,"%d %b %Y"), '', '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").":"); + + + $pdf->SetXY($this->marge_gauche,$posy); + $pdf->SetFillColor(230,230,230); + $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); + + + $pdf->SetXY($this->marge_gauche+2,$posy+3); + + // Nom emetteur + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('Arial','B',11); + if (defined("FAC_PDF_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) $pdf->MultiCell(80, 4, FAC_PDF_SOCIETE_NOM, 0, 'L'); + else $pdf->MultiCell(80, 4, $this->emetteur->nom, 0, 'L'); + + // Caractéristiques emetteur + $carac_emetteur = ''; + if (defined("FAC_PDF_ADRESSE") && FAC_PDF_ADRESSE) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).FAC_PDF_ADRESSE; + else { + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$this->emetteur->adresse; + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$this->emetteur->cp.' '.$this->emetteur->ville; + } + $carac_emetteur .= "\n"; + + // Tel + if (defined("FAC_PDF_TEL") && FAC_PDF_TEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".FAC_PDF_TEL; + elseif ($this->emetteur->tel) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".$this->emetteur->tel; + + // Fax + if (defined("FAC_PDF_FAX") && FAC_PDF_FAX) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".FAC_PDF_FAX; + elseif ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$this->emetteur->fax; + + // EMail + if (defined("FAC_PDF_MEL") && FAC_PDF_MEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".FAC_PDF_MEL; + elseif ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$this->emetteur->email; + + // Web + if (defined("FAC_PDF_WWW") && FAC_PDF_WWW) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".FAC_PDF_WWW; + elseif ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$this->emetteur->url; + + $pdf->SetFont('Arial','',9); + $pdf->SetXY($this->marge_gauche+2,$posy+8); + $pdf->MultiCell(80,4, $carac_emetteur); + + // Client destinataire + $posy=42; + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('Arial','',8); + $pdf->SetXY(102,$posy-5); + $pdf->MultiCell(80,5, $outputlangs->transnoentities("BillTo").":"); + $object->fetch_client(); + + // Cadre client destinataire + $pdf->rect(100, $posy, 100, $hautcadre); + + // If CUSTOMER contact defined on invoice, we use it + $usecontact=false; + if ($conf->global->COMMANDE_USE_CUSTOMER_CONTACT_AS_RECIPIENT) + { + $arrayidcontact=$object->getIdContact('external','CUSTOMER'); + if (sizeof($arrayidcontact) > 0) + { + $usecontact=true; + $result=$object->fetch_contact($arrayidcontact[0]); + } + } + + if ($usecontact) + { + // Nom societe + $pdf->SetXY(102,$posy+3); + $pdf->SetFont('Arial','B',11); + $pdf->MultiCell(96,4, $object->client->nom, 0, 'L'); + + // Nom client + $carac_client = "\n".$object->contact->getFullName($outputlangs,1,1); + + // Caractéristiques client + $carac_client.="\n".$object->contact->adresse; + $carac_client.="\n".$object->contact->cp . " " . $object->contact->ville."\n"; + //Pays si different de l'emetteur + if ($this->emetteur->pays_code != $object->contact->pays_code) + { + dol_entity_decode($carac_client.=$object->contact->pays)."\n"; + } + } + else + { + // Nom client + $pdf->SetXY(102,$posy+3); + $pdf->SetFont('Arial','B',11); + $pdf->MultiCell(96,4, $object->client->nom, 0, 'L'); + + // 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 + if( !preg_match('#'.$object->contact->getFullName($outputlangs,1).'#isU',$object->client->nom) ) + { + $carac_client .= "\n".$object->contact->getFullName($outputlangs,1,1); + } + } + + // Caractéristiques client + $carac_client.="\n".$object->client->adresse; + $carac_client.="\n".$object->client->cp . " " . $object->client->ville."\n"; + + //Pays si different de l'emetteur + if ($this->emetteur->pays_code != $object->client->pays_code) + { + $carac_client.=dol_entity_decode($object->client->pays)."\n"; + } + } + // Numéro TVA intracom + if ($object->client->tva_intra) $carac_client.="\n".$outputlangs->transnoentities("VATIntraShort").': '.$object->client->tva_intra; + $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 Affiche le pied de page + * \param pdf objet PDF + */ + function _pagefoot(&$pdf,$outputlangs) + { + return pdf_pagefoot($pdf,$outputlangs,'COMMANDE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); + } } diff --git a/htdocs/includes/modules/facture/pdf_crabe.modules.php b/htdocs/includes/modules/facture/pdf_crabe.modules.php index 45b7101ab41..a6cc510630a 100644 --- a/htdocs/includes/modules/facture/pdf_crabe.modules.php +++ b/htdocs/includes/modules/facture/pdf_crabe.modules.php @@ -22,7 +22,7 @@ /** \file htdocs/includes/modules/facture/pdf_crabe.modules.php \ingroup facture - \brief Fichier de la classe permettant de g�n�rer les factures au mod�le Crabe + \brief File of class to generate invoices from crab model \author Laurent Destailleur \version $Id$ */ @@ -43,9 +43,9 @@ class pdf_crabe extends ModelePDFFactures /** - \brief Constructeur - \param db Handler accès base de donn�e - */ + * \brief Constructor + * \param db Database handler + */ function pdf_crabe($db) { global $conf,$langs,$mysoc; @@ -384,7 +384,7 @@ class pdf_crabe extends ModelePDFFactures } // Pied de page - $this->_pagefoot($pdf,$outputlangs); + $this->_pagefoot($pdf,$fac,$outputlangs); $pdf->AliasNbPages(); $pdf->Close(); @@ -1174,82 +1174,13 @@ class pdf_crabe extends ModelePDFFactures /** * \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,$outputlangs) + function _pagefoot(&$pdf,$object,$outputlangs) { - global $conf; - - // Line of free text - $ligne=(! empty($conf->global->FACTURE_FREE_TEXT))?$conf->global->FACTURE_FREE_TEXT:""; - - // Premiere ligne d'info réglementaires - $ligne1=""; - if ($this->emetteur->forme_juridique_code) - { - $ligne1.=($ligne1?" - ":"").getFormeJuridiqueLabel($this->emetteur->forme_juridique_code); - } - if ($this->emetteur->capital) - { - $ligne1.=($ligne1?" - ":"").$outputlangs->transnoentities("CapitalOf",$this->emetteur->capital)." ".$outputlangs->transnoentities("Currency".$conf->monnaie); - } - // Prof Id - if ($this->emetteur->profid2) - { - $ligne1.=($ligne1?" - ":"").$outputlangs->transcountrynoentities("ProfId2",$this->emetteur->pays_code).": ".$this->emetteur->profid2; - } - if ($this->emetteur->profid1 && (! $this->emetteur->profid2 || $this->emetteur->pays_code != 'FR')) - { - $ligne1.=($ligne1?" - ":"").$outputlangs->transcountrynoentities("ProfId1",$this->emetteur->pays_code).": ".$this->emetteur->profid1; - } - - // Deuxieme ligne d'info réglementaires - $ligne2=""; - if ($this->emetteur->profid3) - { - $ligne2.=($ligne2?" - ":"").$outputlangs->transcountrynoentities("ProfId3",$this->emetteur->pays_code).": ".$this->emetteur->profid3; - } - if ($this->emetteur->profid4) - { - $ligne2.=($ligne2?" - ":"").$outputlangs->transcountrynoentities("ProfId4",$this->emetteur->pays_code).": ".$this->emetteur->profid4; - } - if ($this->emetteur->tva_intra != '') - { - $ligne2.=($ligne2?" - ":"").$outputlangs->transnoentities("VATIntraShort").": ".$this->emetteur->tva_intra; - } - - $pdf->SetFont('Arial','',7); - $pdf->SetDrawColor(224,224,224); - - // On positionne le debut du bas de page selon nbre de lignes de ce bas de page - $posy=$this->marge_basse + 1 + ($ligne?6:0) + ($ligne1?3:0) + ($ligne2?3:0); - - if ($ligne) - { - $pdf->SetXY($this->marge_gauche,-$posy); - $pdf->MultiCell(190, 3, $ligne, 0, 'L', 0); - $posy-=9; // 6 of ligne + 3 of MultiCell - } - - $pdf->SetY(-$posy); - $pdf->line($this->marge_gauche, $this->page_hauteur-$posy, 200, $this->page_hauteur-$posy); - $posy--; - - if ($ligne1) - { - $pdf->SetXY($this->marge_gauche,-$posy); - $pdf->MultiCell(200, 2, $ligne1, 0, 'C', 0); - } - - if ($ligne2) - { - $posy-=3; - $pdf->SetXY($this->marge_gauche,-$posy); - $pdf->MultiCell(200, 2, $ligne2, 0, 'C', 0); - } - - $pdf->SetXY(-20,-$posy); - $pdf->MultiCell(11, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0); + 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 f01546ca7ff..4d3636e13c3 100644 --- a/htdocs/includes/modules/facture/pdf_huitre.modules.php +++ b/htdocs/includes/modules/facture/pdf_huitre.modules.php @@ -20,203 +20,208 @@ */ /** - \file htdocs/includes/modules/facture/pdf_huitre.modules.php - \ingroup facture - \brief Fichier de la classe permettant de générer les factures au modèle Huitre - \author Laurent Destailleur - \version $Id$ -*/ + \file htdocs/includes/modules/facture/pdf_huitre.modules.php + \ingroup facture + \brief Fichier de la classe permettant de générer les factures au modèle Huitre + \author Laurent Destailleur + \version $Id$ + */ -require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php"); +require_once(DOL_DOCUMENT_ROOT."/includes/modules/facture/modules_facture.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); /** - \class pdf_huitre - \brief Classe permettant de générer les factures au modèle Huitre -*/ + \class pdf_huitre + \brief Classe permettant de générer les factures au modèle Huitre + */ class pdf_huitre extends ModelePDFFactures { - var $emetteur; // Objet societe qui emet + var $emetteur; // Objet societe qui emet - /** \brief Constructeur - \param db handler accès base de donnée - */ - function pdf_huitre($db) - { - global $conf,$langs,$mysoc; + /** \brief Constructeur + \param db handler accès base de donnée + */ + function pdf_huitre($db) + { + global $conf,$langs,$mysoc; - $langs->load("main"); - $langs->load("bills"); - $langs->load("products"); + $langs->load("main"); + $langs->load("bills"); + $langs->load("products"); - $this->db = $db; - $this->name = "huitre"; - $this->description = $langs->transnoentities('PDFHuitreDescription'); + $this->db = $db; + $this->name = "huitre"; + $this->description = $langs->transnoentities('PDFHuitreDescription'); - // 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->option_logo = 1; // Affiche logo FAC_PDF_LOGO - $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION - $this->option_modereg = 0; // Gere choix mode règlement FACTURE_CHQ_NUMBER, FACTURE_RIB_NUMBER - $this->option_condreg = 1; // Affiche conditions règlement - $this->option_codeproduitservice = 0; // 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 = 0; // Gère les avoirs - $this->option_draft_watermark = 1; //Support add of a watermark on drafts - - // 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 - } - - - /** - * \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='') - { - global $user,$langs,$conf; - - if (! is_object($outputlangs)) $outputlangs=$langs; - $outputlangs->load("main"); - $outputlangs->load("companies"); - $outputlangs->load("bills"); - $outputlangs->load("products"); + // 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; - $outputlangs->setPhpLang(); + $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO + $this->option_tva = 0; // Gere option tva FACTURE_TVAOPTION + $this->option_modereg = 0; // Gere choix mode règlement FACTURE_CHQ_NUMBER, FACTURE_RIB_NUMBER + $this->option_condreg = 1; // Affiche conditions règlement + $this->option_codeproduitservice = 0; // 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 = 0; // Gère les avoirs + $this->option_draft_watermark = 1; //Support add of a watermark on drafts - if ($conf->facture->dir_output) - { - // Définition de l'objet $fac (pour compatibilite ascendante) - if (! is_object($fac)) + // 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 + } + + + /** + * \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='') + { + global $user,$langs,$conf; + + if (! is_object($outputlangs)) $outputlangs=$langs; + $outputlangs->load("main"); + $outputlangs->load("companies"); + $outputlangs->load("bills"); + $outputlangs->load("products"); + + $outputlangs->setPhpLang(); + + if ($conf->facture->dir_output) + { + // Définition de l'objet $fac (pour compatibilite ascendante) + if (! is_object($fac)) { - $id = $fac; - $fac = new Facture($this->db,"",$id); - $ret=$fac->fetch($id); + $id = $fac; + $fac = new Facture($this->db,"",$id); + $ret=$fac->fetch($id); } - // Définition de $dir et $file - if ($fac->specimen) + // Définition de $dir et $file + if ($fac->specimen) { - $dir = $conf->facture->dir_output; - $file = $dir . "/SPECIMEN.pdf"; + $dir = $conf->facture->dir_output; + $file = $dir . "/SPECIMEN.pdf"; } - else + else { - $facref = sanitize_string($fac->ref); - $dir = $conf->facture->dir_output . "/" . $facref; - $file = $dir . "/" . $facref . ".pdf"; + $facref = sanitize_string($fac->ref); + $dir = $conf->facture->dir_output . "/" . $facref; + $file = $dir . "/" . $facref . ".pdf"; } - if (! file_exists($dir)) + if (! file_exists($dir)) { - if (create_exdir($dir) < 0) - { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); - $langs->setPhpLang(); // On restaure langue session - return 0; - } + if (create_exdir($dir) < 0) + { + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + $langs->setPhpLang(); // On restaure langue session + return 0; + } } - if (file_exists($dir)) + if (file_exists($dir)) { - // Protection et encryption du pdf - if ($conf->global->PDF_SECURITY_ENCRYPTION) - { + // Protection et encryption du pdf + if ($conf->global->PDF_SECURITY_ENCRYPTION) + { $pdf=new FPDI_Protection('P','mm','A4'); - $pdfrights = array('print'); // Ne permet que l'impression du document - $pdfuserpass = ''; // Mot de passe pour l'utilisateur final - $pdfownerpass = NULL; // Mot de passe du propriétaire, créé aléatoirement si pas défini - $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass); - } - else - { - $pdf=new FPDI('P','mm',$this->format); + $pdfrights = array('print'); // Ne permet que l'impression du document + $pdfuserpass = ''; // Mot de passe pour l'utilisateur final + $pdfownerpass = NULL; // Mot de passe du propriétaire, créé aléatoirement si pas défini + $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass); + } + else + { + $pdf=new FPDI('P','mm',$this->format); } - $pdf->Open(); - $pdf->AddPage(); + $pdf->Open(); + $pdf->AddPage(); - $this->_pagehead($pdf, $fac, $outputlangs); + $this->_pagehead($pdf, $fac, $outputlangs); - $pdf->SetTitle($fac->ref); - $pdf->SetSubject($langs->transnoentities("Bill")); - $pdf->SetCreator("Dolibarr (By ADYTEK)".DOL_VERSION); - $pdf->SetAuthor($user->fullname); - $pdf->SetMargins(10, 10, 10); - $pdf->SetAutoPageBreak(1,0); - $tab_top = 100; - $tab_height = 110; + $pdf->SetTitle($fac->ref); + $pdf->SetSubject($langs->transnoentities("Bill")); + $pdf->SetCreator("Dolibarr (By ADYTEK)".DOL_VERSION); + $pdf->SetAuthor($user->fullname); + $pdf->SetMargins(10, 10, 10); + $pdf->SetAutoPageBreak(1,0); + $tab_top = 100; + $tab_height = 110; - $pdf->SetFillColor(242,239,119); + $pdf->SetFillColor(242,239,119); - $pdf->SetFont('Arial','', 9); + $pdf->SetFont('Arial','', 9); - $pdf->SetXY (10, $tab_top + 10 ); + $pdf->SetXY (10, $tab_top + 10 ); - $iniY = $pdf->GetY(); - $curY = $pdf->GetY(); - $nexY = $pdf->GetY(); - $nblignes = sizeof($fac->lignes); + $iniY = $pdf->GetY(); + $curY = $pdf->GetY(); + $nexY = $pdf->GetY(); + $nblignes = sizeof($fac->lignes); - // Boucle sur les lignes de factures - for ($i = 0 ; $i < $nblignes ; $i++) - { - $curY = $nexY; + // Boucle sur les lignes de factures + for ($i = 0 ; $i < $nblignes ; $i++) + { + $curY = $nexY; - $pdf->SetXY (11, $curY ); - $pdf->MultiCell(118, 5, $fac->lignes[$i]->desc, 0, 'J'); + $pdf->SetXY (11, $curY ); + $pdf->MultiCell(118, 5, $fac->lignes[$i]->desc, 0, 'J'); - $nexY = $pdf->GetY(); + $nexY = $pdf->GetY(); - $pdf->SetXY (133, $curY); - $pdf->MultiCell(10, 5, $fac->lignes[$i]->tva_tx, 0, 'C'); + $pdf->SetXY (133, $curY); + $pdf->MultiCell(10, 5, $fac->lignes[$i]->tva_tx, 0, 'C'); - $pdf->SetXY (145, $curY); - $pdf->MultiCell(10, 5, $fac->lignes[$i]->qty, 0, 'C'); + $pdf->SetXY (145, $curY); + $pdf->MultiCell(10, 5, $fac->lignes[$i]->qty, 0, 'C'); - $pdf->SetXY (156, $curY); - $pdf->MultiCell(18, 5, price($fac->lignes[$i]->price), 0, 'R', 0); + $pdf->SetXY (156, $curY); + $pdf->MultiCell(18, 5, price($fac->lignes[$i]->price), 0, 'R', 0); - $pdf->SetXY (174, $curY); - $total = price($fac->lignes[$i]->total_ht); - $pdf->MultiCell(26, 5, $total, 0, 'R', 0); + $pdf->SetXY (174, $curY); + $total = price($fac->lignes[$i]->total_ht); + $pdf->MultiCell(26, 5, $total, 0, 'R', 0); - if ($nexY > 200 && $i < $nblignes - 1) - { + if ($nexY > 200 && $i < $nblignes - 1) + { $this->_tableau($pdf, $tab_top, $tab_height, $nexY); $pdf->AddPage(); $nexY = $iniY; $this->_pagehead($pdf, $fac, $outputlangs); $pdf->SetTextColor(0,0,0); $pdf->SetFont('Arial','', 10); - } + } - } - $this->_tableau($pdf, $tab_top, $tab_height, $nexY); + } + $this->_tableau($pdf, $tab_top, $tab_height, $nexY); - $this->_tableau_tot($pdf, $fac); + $this->_tableau_tot($pdf, $fac); - $this->_tableau_compl($pdf, $fac); + $this->_tableau_compl($pdf, $fac); - /* - * - */ - if (defined("FACTURE_RIB_NUMBER")) - { - if (FACTURE_RIB_NUMBER > 0) - { + /* + * + */ + if (defined("FACTURE_RIB_NUMBER")) + { + if (FACTURE_RIB_NUMBER > 0) + { $account = new Account($this->db); $account->fetch(FACTURE_RIB_NUMBER); @@ -231,434 +236,377 @@ class pdf_huitre extends ModelePDFFactures $pdf->MultiCell(40, 4, $langs->transnoentities("Residence").' : ' . $account->domiciliation, 0, 'L', 0); $pdf->MultiCell(40, 4, $langs->transnoentities("IbanPrefix").' : ' . $account->iban_prefix, 0, 'L', 0); $pdf->MultiCell(40, 4, $langs->transnoentities("BIC").' : ' . $account->bic, 0, 'L', 0); - } - } + } + } - /* - * - * - */ + /* + * + * + */ - if ( $fac->note_public) - { - $pdf->SetFont('Arial','',7); - $pdf->SetXY(10, 211); - $note = $langs->transnoentities("Note").' : '.$fac->note_public; - $pdf->MultiCell(110, 3, $note, 0, 'J'); - } + if ( $fac->note_public) + { + $pdf->SetFont('Arial','',7); + $pdf->SetXY(10, 211); + $note = $langs->transnoentities("Note").' : '.$fac->note_public; + $pdf->MultiCell(110, 3, $note, 0, 'J'); + } - $pdf->SetFont('Arial','U',11); - $pdf->SetXY(10, 225); - $titre = $outputlangs->transnoentities("PaymentConditions").' : '; - $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$fac->cond_reglement_code)!=('PaymentCondition'.$fac->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$fac->cond_reglement_code):$fac->cond_reglement; - $titre.=$lib_condition_paiement; - $pdf->MultiCell(190, 5, $titre, 0, 'J'); + $pdf->SetFont('Arial','U',11); + $pdf->SetXY(10, 225); + $titre = $outputlangs->transnoentities("PaymentConditions").' : '; + $lib_condition_paiement=$outputlangs->transnoentities("PaymentCondition".$fac->cond_reglement_code)!=('PaymentCondition'.$fac->cond_reglement_code)?$outputlangs->transnoentities("PaymentCondition".$fac->cond_reglement_code):$fac->cond_reglement; + $titre.=$lib_condition_paiement; + $pdf->MultiCell(190, 5, $titre, 0, 'J'); - $pdf->SetFont('Arial','',6); - $pdf->SetXY(10, 265); - $pdf->MultiCell(90, 2, $langs->transnoentities('LawApplicationPart1'), 0, 'J'); - $pdf->SetXY(10, 267); - $pdf->MultiCell(90, 2, $langs->transnoentities('LawApplicationPart2'), 0, 'J'); - $pdf->SetXY(10, 269); - $pdf->MultiCell(90, 2, $langs->transnoentities('LawApplicationPart3'), 0, 'J'); - $pdf->SetXY(10, 271); - $pdf->MultiCell(90, 2, $langs->transnoentities('LawApplicationPart4'), 0, 'J'); + $this->_pagefoot($pdf, $fac, $outputlangs); + $pdf->AliasNbPages(); + //---- + $pdf->SetTextColor(0,0,0); + $pdf->SetFillColor(242,239,119); - $pdf->SetFont('Arial','',7); - $pdf->SetXY(85, 271); - $pdf->MultiCell(90, 3, $langs->transnoentities('VATDischarged'), 0, 'J'); - - $this->_pagefoot($pdf, $fac); - $pdf->AliasNbPages(); - //---- - $pdf->SetTextColor(0,0,0); - $pdf->SetFillColor(242,239,119); - - $pdf->SetLineWidth(0.5); + $pdf->SetLineWidth(0.5); - $pdf->Close(); + $pdf->Close(); - $pdf->Output($file); + $pdf->Output($file); - $langs->setPhpLang(); // On restaure langue session - return 1; // Pas d'erreur + $langs->setPhpLang(); // On restaure langue session + return 1; // Pas d'erreur } - else + else { - $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); - $langs->setPhpLang(); // On restaure langue session - return 0; + $this->error=$langs->transnoentities("ErrorCanNotCreateDir",$dir); + $langs->setPhpLang(); // On restaure langue session + return 0; } - } - else - { - $this->error=$langs->transnoentities("ErrorConstantNotDefined","FAC_OUTPUTDIR"); - $langs->setPhpLang(); // On restaure langue session - return 0; - } - $this->error=$langs->transnoentities("ErrorUnknown"); - $langs->setPhpLang(); // On restaure langue session - return 0; // Erreur par defaut - } - - - /* - * - * - * - */ - function RoundedRect($x, $y, $w, $h,$r, $style = '') - { - $k = $this->k; - $hp = $this->h; - if($style=='F') - $op='f'; - elseif($style=='FD' or $style=='DF') - $op='B'; - else - $op='S'; - $MyArc = 4/3 * (sqrt(2) - 1); - $this->_out(sprintf('%.2f %.2f m',($x+$r)*$k,($hp-$y)*$k )); - $xc = $x+$w-$r ; - $yc = $y+$r; - $this->_out(sprintf('%.2f %.2f l', $xc*$k,($hp-$y)*$k )); - - $this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc); - $xc = $x+$w-$r ; - $yc = $y+$h-$r; - $this->_out(sprintf('%.2f %.2f l',($x+$w)*$k,($hp-$yc)*$k)); - $this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r); - $xc = $x+$r ; - $yc = $y+$h-$r; - $this->_out(sprintf('%.2f %.2f l',$xc*$k,($hp-($y+$h))*$k)); - $this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc); - $xc = $x+$r ; - $yc = $y+$r; - $this->_out(sprintf('%.2f %.2f l',($x)*$k,($hp-$yc)*$k )); - $this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r); - $this->_out($op); - } - - function _Arc($x1, $y1, $x2, $y2, $x3, $y3) - { - $h = $this->h; - $this->_out(sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $x1*$this->k, ($h-$y1)*$this->k, - $x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k)); - } - /////////////////////////////// - function _tableau_compl(&$pdf, $fac) - { - global $langs; - $langs->load("main"); - $langs->load("bills"); - - $tab3_top = 240; - $tab3_height = 18; - $tab3_width = 60; - - $pdf->Rect(10, $tab3_top, $tab3_width, $tab3_height); - - $pdf->line(10, $tab3_top + 6, $tab3_width+10, $tab3_top + 6 ); - $pdf->line(10, $tab3_top + 12, $tab3_width+10, $tab3_top + 12 ); - - $pdf->line(40, $tab3_top, 40, $tab3_top + $tab3_height ); - - $pdf->SetFont('Arial','',8); - $pdf->SetXY (10, $tab3_top - 6); - $pdf->MultiCell(60, 6, $langs->transnoentities("ExtraInfos"), 0, 'L', 0); - $pdf->SetXY (10, $tab3_top ); - $pdf->MultiCell(20, 6, $langs->transnoentities("RegulatedOn"), 0, 'L', 0); - $pdf->SetXY (10, $tab3_top + 6); - $pdf->MultiCell(60, 6, $langs->transnoentities("ChequeOrTransferNumber"), 0, 'L', 0); - $pdf->SetXY (10, $tab3_top + 12); - $pdf->MultiCell(20, 6, $langs->transnoentities("Bank"), 0, 'L', 0); - } - - /* - * \brief Affiche le total à payer - * \param pdf objet PDF - * \param fac objet facture - */ - function _tableau_tot(&$pdf, $fac) - { - global $langs; - $langs->load("main"); - $langs->load("bills"); - - $tab2_top = 212; - $tab2_hl = 5; - $tab2_height = $tab2_hl * 4; - $pdf->SetFont('Arial','', 9); - - // $pdf->Rect(132, $tab2_top, 68, $tab2_height); - // $pdf->line(174, $tab2_top, 174, $tab2_top + $tab2_height); - - // $pdf->line(132, $tab2_top + $tab2_height - 21, 200, $tab2_top + $tab2_height - 21 ); - // $pdf->line(132, $tab2_top + $tab2_height - 14, 200, $tab2_top + $tab2_height - 14 ); - // $pdf->line(132, $tab2_top + $tab2_height - 7, 200, $tab2_top + $tab2_height - 7 ); - - $pdf->SetXY (132, $tab2_top + 0); - $pdf->MultiCell(42, $tab2_hl, $langs->transnoentities("TotalHT"), 0, 'R', 0); - - $pdf->SetXY (174, $tab2_top + 0); - $pdf->MultiCell(26, $tab2_hl, price($fac->total_ht + $fac->remise), 0, 'R', 0); - - $index = 1; - - $pdf->SetXY (132, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell(42, $tab2_hl, $langs->transnoentities("TotalVAT"), 0, 'R', 0); - - $pdf->SetXY (174, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell(26, $tab2_hl, price($fac->total_tva), 0, 'R', 0); - - $pdf->SetXY (132, $tab2_top + $tab2_hl * ($index+1)); - $pdf->MultiCell(42, $tab2_hl, $langs->transnoentities("TotalTTC"), 0, 'R', 1); - - $pdf->SetXY (174, $tab2_top + $tab2_hl * ($index+1)); - $pdf->MultiCell(26, $tab2_hl, price($fac->total_ttc), 0, 'R', 1); - - $deja_regle = $fac->getSommePaiement(); - - if ($deja_regle > 0) - { - $pdf->SetXY (132, $tab2_top + $tab2_hl * ($index+2)); - $pdf->MultiCell(42, $tab2_hl, $langs->transnoentities("AlreadyPayed"), 0, 'R', 0); - - $pdf->SetXY (174, $tab2_top + $tab2_hl * ($index+2)); - $pdf->MultiCell(26, $tab2_hl, price($deja_regle), 0, 'R', 0); - - $pdf->SetXY (132, $tab2_top + $tab2_hl * ($index+3)); - $pdf->MultiCell(42, $tab2_hl, $langs->transnoentities("RemainderToPay"), 0, 'R', 1); - - $pdf->SetXY (174, $tab2_top + $tab2_hl * ($index+3)); - $pdf->MultiCell(26, $tab2_hl, price($fac->total_ttc - $deja_regle), 0, 'R', 1); - } - } - /* - * \brief Affiche la grille des lignes de factures - * \param pdf objet PDF - */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY) - { - global $langs; - $langs->load("main"); - $langs->load("bills"); - - $pdf->SetFont('Arial','',10); - - $pdf->Text(11,$tab_top + 5,$langs->transnoentities("Designation")); - - $pdf->line(132, $tab_top, 132, $tab_top + $tab_height); - $pdf->Text(134,$tab_top + 5,$langs->transnoentities("VAT")); - - $pdf->line(144, $tab_top, 144, $tab_top + $tab_height); - $pdf->Text(147,$tab_top + 5,$langs->transnoentities("Qty")); - - $pdf->line(156, $tab_top, 156, $tab_top + $tab_height); - $pdf->Text(160,$tab_top + 5,$langs->transnoentities("PriceU")); - - $pdf->line(174, $tab_top, 174, $tab_top + $tab_height); - $pdf->Text(187,$tab_top + 5,$langs->transnoentities("Total")); - - $pdf->Rect(10, $tab_top, 190, $tab_height); - $pdf->line(10, $tab_top + 10, 200, $tab_top + 10 ); - } - - /* - * \brief Affiche en-tête facture - * \param pdf objet PDF - * \param fac objet facture - */ - function _pagehead(&$pdf, $fac, $outputlangs) - { - global $conf; - - $outputlangs->load("main"); - $outputlangs->load("bills"); - $outputlangs->load("propal"); - $outputlangs->load("companies"); - - $tab4_top = 60; - $tab4_hl = 6; - $tab4_sl = 4; - $ligne = 2; - - //Affiche le filigrane brouillon - Print Draft Watermark - if($fac->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) ) - { - $watermark_angle=atan($this->page_hauteur/$this->page_largeur); - $watermark_x=5; - $watermark_y=$this->page_hauteur-50; - $watermark_width=$this->page_hauteur; - $pdf->SetFont('Arial','B',50); - $pdf->SetTextColor(255,192,203); - //rotate - $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k)); - //print watermark - $pdf->SetXY($watermark_x,$watermark_y); - $pdf->Cell($watermark_width,25,clean_html($conf->global->FACTURE_DRAFT_WATERMARK),0,2,"C",0); - //antirotate - $pdf->_out('Q'); + } + else + { + $this->error=$langs->transnoentities("ErrorConstantNotDefined","FAC_OUTPUTDIR"); + $langs->setPhpLang(); // On restaure langue session + return 0; + } + $this->error=$langs->transnoentities("ErrorUnknown"); + $langs->setPhpLang(); // On restaure langue session + return 0; // Erreur par defaut } - //Print content - - $pdf->SetXY(10,5); - // Logo - $logo=$conf->societe->dir_logos.'/'.$this->emetteur->logo; - if ($this->emetteur->logo) - { - if (is_readable($logo)) + + /* + * + * + * + */ + function RoundedRect($x, $y, $w, $h,$r, $style = '') + { + $k = $this->k; + $hp = $this->h; + if($style=='F') + $op='f'; + elseif($style=='FD' or $style=='DF') + $op='B'; + else + $op='S'; + $MyArc = 4/3 * (sqrt(2) - 1); + $this->_out(sprintf('%.2f %.2f m',($x+$r)*$k,($hp-$y)*$k )); + $xc = $x+$w-$r ; + $yc = $y+$r; + $this->_out(sprintf('%.2f %.2f l', $xc*$k,($hp-$y)*$k )); + + $this->_Arc($xc + $r*$MyArc, $yc - $r, $xc + $r, $yc - $r*$MyArc, $xc + $r, $yc); + $xc = $x+$w-$r ; + $yc = $y+$h-$r; + $this->_out(sprintf('%.2f %.2f l',($x+$w)*$k,($hp-$yc)*$k)); + $this->_Arc($xc + $r, $yc + $r*$MyArc, $xc + $r*$MyArc, $yc + $r, $xc, $yc + $r); + $xc = $x+$r ; + $yc = $y+$h-$r; + $this->_out(sprintf('%.2f %.2f l',$xc*$k,($hp-($y+$h))*$k)); + $this->_Arc($xc - $r*$MyArc, $yc + $r, $xc - $r, $yc + $r*$MyArc, $xc - $r, $yc); + $xc = $x+$r ; + $yc = $y+$r; + $this->_out(sprintf('%.2f %.2f l',($x)*$k,($hp-$yc)*$k )); + $this->_Arc($xc - $r, $yc - $r*$MyArc, $xc - $r*$MyArc, $yc - $r, $xc, $yc - $r); + $this->_out($op); + } + + function _Arc($x1, $y1, $x2, $y2, $x3, $y3) + { + $h = $this->h; + $this->_out(sprintf('%.2f %.2f %.2f %.2f %.2f %.2f c ', $x1*$this->k, ($h-$y1)*$this->k, + $x2*$this->k, ($h-$y2)*$this->k, $x3*$this->k, ($h-$y3)*$this->k)); + } + /////////////////////////////// + function _tableau_compl(&$pdf, $fac) + { + global $langs; + $langs->load("main"); + $langs->load("bills"); + + $tab3_top = 240; + $tab3_height = 18; + $tab3_width = 60; + + $pdf->Rect(10, $tab3_top, $tab3_width, $tab3_height); + + $pdf->line(10, $tab3_top + 6, $tab3_width+10, $tab3_top + 6 ); + $pdf->line(10, $tab3_top + 12, $tab3_width+10, $tab3_top + 12 ); + + $pdf->line(40, $tab3_top, 40, $tab3_top + $tab3_height ); + + $pdf->SetFont('Arial','',8); + $pdf->SetXY (10, $tab3_top - 6); + $pdf->MultiCell(60, 6, $langs->transnoentities("ExtraInfos"), 0, 'L', 0); + $pdf->SetXY (10, $tab3_top ); + $pdf->MultiCell(20, 6, $langs->transnoentities("RegulatedOn"), 0, 'L', 0); + $pdf->SetXY (10, $tab3_top + 6); + $pdf->MultiCell(60, 6, $langs->transnoentities("ChequeOrTransferNumber"), 0, 'L', 0); + $pdf->SetXY (10, $tab3_top + 12); + $pdf->MultiCell(20, 6, $langs->transnoentities("Bank"), 0, 'L', 0); + } + + /* + * \brief Affiche le total à payer + * \param pdf objet PDF + * \param fac objet facture + */ + function _tableau_tot(&$pdf, $fac) + { + global $langs; + $langs->load("main"); + $langs->load("bills"); + + $tab2_top = 212; + $tab2_hl = 5; + $tab2_height = $tab2_hl * 4; + $pdf->SetFont('Arial','', 9); + + // $pdf->Rect(132, $tab2_top, 68, $tab2_height); + // $pdf->line(174, $tab2_top, 174, $tab2_top + $tab2_height); + + // $pdf->line(132, $tab2_top + $tab2_height - 21, 200, $tab2_top + $tab2_height - 21 ); + // $pdf->line(132, $tab2_top + $tab2_height - 14, 200, $tab2_top + $tab2_height - 14 ); + // $pdf->line(132, $tab2_top + $tab2_height - 7, 200, $tab2_top + $tab2_height - 7 ); + + $pdf->SetXY (132, $tab2_top + 0); + $pdf->MultiCell(42, $tab2_hl, $langs->transnoentities("TotalHT"), 0, 'R', 0); + + $pdf->SetXY (174, $tab2_top + 0); + $pdf->MultiCell(26, $tab2_hl, price($fac->total_ht + $fac->remise), 0, 'R', 0); + + $index = 1; + + $pdf->SetXY (132, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell(42, $tab2_hl, $langs->transnoentities("TotalVAT"), 0, 'R', 0); + + $pdf->SetXY (174, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell(26, $tab2_hl, price($fac->total_tva), 0, 'R', 0); + + $pdf->SetXY (132, $tab2_top + $tab2_hl * ($index+1)); + $pdf->MultiCell(42, $tab2_hl, $langs->transnoentities("TotalTTC"), 0, 'R', 1); + + $pdf->SetXY (174, $tab2_top + $tab2_hl * ($index+1)); + $pdf->MultiCell(26, $tab2_hl, price($fac->total_ttc), 0, 'R', 1); + + $deja_regle = $fac->getSommePaiement(); + + if ($deja_regle > 0) + { + $pdf->SetXY (132, $tab2_top + $tab2_hl * ($index+2)); + $pdf->MultiCell(42, $tab2_hl, $langs->transnoentities("AlreadyPayed"), 0, 'R', 0); + + $pdf->SetXY (174, $tab2_top + $tab2_hl * ($index+2)); + $pdf->MultiCell(26, $tab2_hl, price($deja_regle), 0, 'R', 0); + + $pdf->SetXY (132, $tab2_top + $tab2_hl * ($index+3)); + $pdf->MultiCell(42, $tab2_hl, $langs->transnoentities("RemainderToPay"), 0, 'R', 1); + + $pdf->SetXY (174, $tab2_top + $tab2_hl * ($index+3)); + $pdf->MultiCell(26, $tab2_hl, price($fac->total_ttc - $deja_regle), 0, 'R', 1); + } + } + /* + * \brief Affiche la grille des lignes de factures + * \param pdf objet PDF + */ + function _tableau(&$pdf, $tab_top, $tab_height, $nexY) + { + global $langs; + $langs->load("main"); + $langs->load("bills"); + + $pdf->SetFont('Arial','',10); + + $pdf->Text(11,$tab_top + 5,$langs->transnoentities("Designation")); + + $pdf->line(132, $tab_top, 132, $tab_top + $tab_height); + $pdf->Text(134,$tab_top + 5,$langs->transnoentities("VAT")); + + $pdf->line(144, $tab_top, 144, $tab_top + $tab_height); + $pdf->Text(147,$tab_top + 5,$langs->transnoentities("Qty")); + + $pdf->line(156, $tab_top, 156, $tab_top + $tab_height); + $pdf->Text(160,$tab_top + 5,$langs->transnoentities("PriceU")); + + $pdf->line(174, $tab_top, 174, $tab_top + $tab_height); + $pdf->Text(187,$tab_top + 5,$langs->transnoentities("Total")); + + $pdf->Rect(10, $tab_top, 190, $tab_height); + $pdf->line(10, $tab_top + 10, 200, $tab_top + 10 ); + } + + /* + * \brief Affiche en-tête facture + * \param pdf objet PDF + * \param fac objet facture + */ + function _pagehead(&$pdf, $fac, $outputlangs) + { + global $conf; + + $outputlangs->load("main"); + $outputlangs->load("bills"); + $outputlangs->load("propal"); + $outputlangs->load("companies"); + + $tab4_top = 60; + $tab4_hl = 6; + $tab4_sl = 4; + $ligne = 2; + + //Affiche le filigrane brouillon - Print Draft Watermark + if($fac->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) ) + { + $watermark_angle=atan($this->page_hauteur/$this->page_largeur); + $watermark_x=5; + $watermark_y=$this->page_hauteur-50; + $watermark_width=$this->page_hauteur; + $pdf->SetFont('Arial','B',50); + $pdf->SetTextColor(255,192,203); + //rotate + $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k)); + //print watermark + $pdf->SetXY($watermark_x,$watermark_y); + $pdf->Cell($watermark_width,25,clean_html($conf->global->FACTURE_DRAFT_WATERMARK),0,2,"C",0); + //antirotate + $pdf->_out('Q'); + } + //Print content + + $pdf->SetXY(10,5); + + // Logo + $logo=$conf->societe->dir_logos.'/'.$this->emetteur->logo; + if ($this->emetteur->logo) + { + if (is_readable($logo)) { - $pdf->Image($logo, 10, 5,45.0, 25.0); + $pdf->Image($logo, 10, 5,45.0, 25.0); } - else + 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'); + $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")) - { - $pdf->MultiCell(80, 6, FAC_PDF_INTITULE, 0, 'L'); - } - - $pdf->SetDrawColor(192,192,192); - $pdf->line(9, 5, 200, 5 ); - $pdf->line(9, 30, 200, 30 ); - - $pdf->SetFont('Arial','B',7); - $pdf->SetTextColor(128,128,128); - - if (defined("FAC_PDF_ADRESSE")) - { - $pdf->SetXY( $tab4_top , $tab4_hl ); - $pdf->MultiCell(80, 3, FAC_PDF_ADRESSE, '' , 'L'); - } - $pdf->SetFont('Arial','',7); - if (defined("FAC_PDF_TEL")) - { - $pdf->SetXY( $tab4_top , $tab4_hl + 2*$tab4_sl ); - $pdf->MultiCell(80, 3, $outputlangs->transnoentities('FullPhoneNumber').' : ' . FAC_PDF_TEL, '' , 'L'); - } - if (defined("FAC_PDF_FAX")) - { - $pdf->SetXY( $tab4_top , $tab4_hl + 3*$tab4_sl ); - $pdf->MultiCell(80, 3, $outputlangs->transnoentities('TeleFax').' : ' . FAC_PDF_FAX, '' , 'L'); - } - if (defined("FAC_PDF_MEL")) - { - $pdf->SetXY( $tab4_top , $tab4_hl + 4*$tab4_sl ); - $pdf->MultiCell(80, 3, $outputlangs->transnoentities('Email').' : ' . FAC_PDF_MEL, '' , 'L'); - } - if (defined("FAC_PDF_WWW")) - { - $pdf->SetXY( $tab4_top , $tab4_hl + 5*$tab4_sl ); - $pdf->MultiCell(80, 3, $outputlangs->transnoentities('Web').' : ' . FAC_PDF_WWW, '' , 'L'); - } - $pdf->SetTextColor(70,70,170); - - - /* - * Definition du document - */ - $pdf->SetXY(150,16); - $pdf->SetFont('Arial','B',16); - $pdf->SetTextColor(0,0,200); - $pdf->MultiCell(50, 2, strtoupper($outputlangs->transnoentities("Invoice")), '' , 'C'); - - /* - * Adresse Client - */ - $pdf->SetTextColor(0,0,0); - $pdf->SetFillColor(242,239,119); - - // $this->RoundedRect(100, 40, 100, 40, 3, 'F'); - $pdf->rect(100, 40, 100, 40, 'F'); - $pdf->SetFont('Arial','B',12); - $fac->fetch_client(); - $pdf->SetXY(102,42); - $pdf->MultiCell(96,5, $fac->client->nom, 0, 'C'); - $pdf->SetFont('Arial','B',11); - $pdf->SetXY(102,$pdf->GetY()+3); - $pdf->MultiCell(96,5, $fac->client->adresse . "\n\n" . $fac->client->cp . " " . $fac->client->ville , 0, 'C'); - - - - - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('Arial','B',14); - $pdf->Text(11, 88, $outputlangs->transnoentities('Date')); - $pdf->Text(35, 88, ": " . dolibarr_print_date($fac->date,'day')); - $pdf->Text(11, 94, $outputlangs->transnoentities('Invoice')); - $pdf->Text(35, 94, ": ".$fac->ref); - - // Montants exprimes en euros - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('Arial','',10); - $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentities("Currency".$conf->monnaie)); - $pdf->Text(200 - $pdf->GetStringWidth($titre), 94, $titre); - - } + } + else if (defined("FAC_PDF_INTITULE")) + { + $pdf->MultiCell(80, 6, FAC_PDF_INTITULE, 0, 'L'); + } - /* - * \brief Affiche le pied de page de la facture - * \param pdf objet PDF - * \param fac objet facture - */ - function _pagefoot(&$pdf, $fac) - { - global $langs, $conf; - $langs->load("main"); - $langs->load("bills"); - $langs->load("companies"); + $pdf->SetDrawColor(192,192,192); + $pdf->line(9, 5, 200, 5 ); + $pdf->line(9, 30, 200, 30 ); - $footy=13; - $pdf->SetFont('Arial','',8); + $pdf->SetFont('Arial','B',7); + $pdf->SetTextColor(128,128,128); - $ligne=""; - if (defined('MAIN_INFO_CAPITAL') && MAIN_INFO_CAPITAL) { - $ligne=$langs->transnoentities('LimitedLiabilityCompanyCapital').' '. MAIN_INFO_CAPITAL." ".$langs->transnoentities("Currency".$conf->monnaie); - } - if (defined('MAIN_INFO_SIREN') && MAIN_INFO_SIREN) { - $ligne.=($ligne?" - ":"").$langs->transcountrynoentities("ProfId1",$this->emetteur->pays_code).": ".MAIN_INFO_SIREN; - } - if (defined('MAIN_INFO_SIRET') && MAIN_INFO_SIRET) { - $ligne.=($ligne?" - ":"").$langs->transcountrynoentities("ProfId2",$this->emetteur->pays_code).": ".MAIN_INFO_SIRET; - } - if (defined('MAIN_INFO_RCS') && MAIN_INFO_RCS) { - $ligne.=($ligne?" - ":"").$langs->transcountrynoentities("ProfId4",$this->emetteur->pays_code).": ".MAIN_INFO_RCS; - } - if ($ligne) { - $pdf->SetY(-$footy); - $pdf->MultiCell(190, 3, $ligne, 0, 'C'); - $footy-=3; - } + if (defined("FAC_PDF_ADRESSE")) + { + $pdf->SetXY( $tab4_top , $tab4_hl ); + $pdf->MultiCell(80, 3, FAC_PDF_ADRESSE, '' , 'L'); + } + $pdf->SetFont('Arial','',7); + if (defined("FAC_PDF_TEL")) + { + $pdf->SetXY( $tab4_top , $tab4_hl + 2*$tab4_sl ); + $pdf->MultiCell(80, 3, $outputlangs->transnoentities('FullPhoneNumber').' : ' . FAC_PDF_TEL, '' , 'L'); + } + if (defined("FAC_PDF_FAX")) + { + $pdf->SetXY( $tab4_top , $tab4_hl + 3*$tab4_sl ); + $pdf->MultiCell(80, 3, $outputlangs->transnoentities('TeleFax').' : ' . FAC_PDF_FAX, '' , 'L'); + } + if (defined("FAC_PDF_MEL")) + { + $pdf->SetXY( $tab4_top , $tab4_hl + 4*$tab4_sl ); + $pdf->MultiCell(80, 3, $outputlangs->transnoentities('Email').' : ' . FAC_PDF_MEL, '' , 'L'); + } + if (defined("FAC_PDF_WWW")) + { + $pdf->SetXY( $tab4_top , $tab4_hl + 5*$tab4_sl ); + $pdf->MultiCell(80, 3, $outputlangs->transnoentities('Web').' : ' . FAC_PDF_WWW, '' , 'L'); + } + $pdf->SetTextColor(70,70,170); - // Affiche le numéro de TVA intracommunautaire - if (MAIN_INFO_TVAINTRA == 'MAIN_INFO_TVAINTRA') { - $pdf->SetY(-$footy); - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(190, 3, $langs->transnoentities("ErrorVATIntraNotConfigured"),0,'L',0); - $pdf->MultiCell(190, 3, $langs->transnoentities("ErrorGoToGlobalSetup"),0,'L',0); - $pdf->SetTextColor(0,0,0); - } - elseif (MAIN_INFO_TVAINTRA != '') { - $pdf->SetY(-$footy); - $pdf->MultiCell(190, 3, $langs->transnoentities("IntracommunityVATNumber")." : ".MAIN_INFO_TVAINTRA, 0, 'C'); - } - $pdf->SetXY(-10,-10); - $pdf->MultiCell(11, 3, $pdf->PageNo().'/{nb}', 0, 'R'); + /* + * Definition du document + */ + $pdf->SetXY(150,16); + $pdf->SetFont('Arial','B',16); + $pdf->SetTextColor(0,0,200); + $pdf->MultiCell(50, 2, strtoupper($outputlangs->transnoentities("Invoice")), '' , 'C'); - } + /* + * Adresse Client + */ + $pdf->SetTextColor(0,0,0); + $pdf->SetFillColor(242,239,119); + + // $this->RoundedRect(100, 40, 100, 40, 3, 'F'); + $pdf->rect(100, 40, 100, 40, 'F'); + $pdf->SetFont('Arial','B',12); + $fac->fetch_client(); + $pdf->SetXY(102,42); + $pdf->MultiCell(96,5, $fac->client->nom, 0, 'C'); + $pdf->SetFont('Arial','B',11); + $pdf->SetXY(102,$pdf->GetY()+3); + $pdf->MultiCell(96,5, $fac->client->adresse . "\n\n" . $fac->client->cp . " " . $fac->client->ville , 0, 'C'); + + + + + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('Arial','B',14); + $pdf->Text(11, 88, $outputlangs->transnoentities('Date')); + $pdf->Text(35, 88, ": " . dolibarr_print_date($fac->date,'day')); + $pdf->Text(11, 94, $outputlangs->transnoentities('Invoice')); + $pdf->Text(35, 94, ": ".$fac->ref); + + // Montants exprimes en euros + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('Arial','',10); + $titre = $outputlangs->transnoentities("AmountInCurrency",$outputlangs->transnoentities("Currency".$conf->monnaie)); + $pdf->Text(200 - $pdf->GetStringWidth($titre), 94, $titre); + + } + + /* + * \brief Affiche le pied de page de la facture + * \param pdf objet PDF + * \param fac objet facture + */ + function _pagefoot(&$pdf, $fac, $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_oursin.modules.php b/htdocs/includes/modules/facture/pdf_oursin.modules.php index 05946aef253..25797cc5a86 100644 --- a/htdocs/includes/modules/facture/pdf_oursin.modules.php +++ b/htdocs/includes/modules/facture/pdf_oursin.modules.php @@ -18,90 +18,93 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * or see http://www.gnu.org/ - * - * $Id$ */ /** - \file htdocs/includes/modules/facture/pdf_oursin.modules.php - \ingroup facture - \brief Fichier de la classe permettant de générer les factures au modèle oursin - \author Sylvain SCATTOLINI basé sur un modèle de Laurent Destailleur - \version $Revision$ -*/ + \file htdocs/includes/modules/facture/pdf_oursin.modules.php + \ingroup facture + \brief Fichier de la classe permettant de générer les factures au modèle oursin + \author Sylvain SCATTOLINI basé sur un modèle de Laurent Destailleur + \version $Id$ + */ require_once(DOL_DOCUMENT_ROOT."/product.class.php"); -require_once(DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php"); +require_once(DOL_DOCUMENT_ROOT."/includes/modules/facture/modules_facture.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); /** - \class pdf_oursin - \brief Classe permettant de générer les factures au modèle oursin -*/ + \class pdf_oursin + \brief Classe permettant de générer les factures au modèle oursin + */ class pdf_oursin extends ModelePDFFactures { - var $emetteur; // Objet societe qui emet - var $marges=array("g"=>10,"h"=>5,"d"=>10,"b"=>15); - - /** - \brief Constructeur - \param db handler accès base de donnée - */ - function pdf_oursin($db) - { - global $conf,$langs,$mysoc; - - $langs->load("main"); - $langs->load("bills"); - $langs->load("products"); - - $this->db = $db; - $this->name = "oursin"; - $this->description = $langs->transnoentities('PDFOursinDescription'); - - // 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->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_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_draft_watermark = 1; //Support add of a watermark on drafts + var $emetteur; // Objet societe qui emet + var $marges=array("g"=>10,"h"=>5,"d"=>10,"b"=>15); - 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 - } - - /** - * \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 - */ + \brief Constructeur + \param db handler accès base de donnée + */ + function pdf_oursin($db) + { + global $conf,$langs,$mysoc; + + $langs->load("main"); + $langs->load("bills"); + $langs->load("products"); + + $this->db = $db; + $this->name = "oursin"; + $this->description = $langs->transnoentities('PDFOursinDescription'); + + // 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 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_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_draft_watermark = 1; //Support add of a watermark on drafts + + 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 + } + + + /** + * \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='') { global $user,$langs,$conf; - + if (! is_object($outputlangs)) $outputlangs=$langs; $outputlangs->load("main"); $outputlangs->load("companies"); $outputlangs->load("bills"); $outputlangs->load("products"); - + $outputlangs->setPhpLang(); - + if ($conf->facture->dir_output) { // Définition de l'objet $fac (pour compatibilite ascendante) @@ -115,7 +118,7 @@ class pdf_oursin extends ModelePDFFactures $deja_regle = $fac->getSommePaiement(); $amount_credit_not_included = $fac->getSommeCreditNote(); - + // Définition de $dir et $file if ($fac->specimen) { @@ -141,7 +144,7 @@ class pdf_oursin extends ModelePDFFactures if (file_exists($dir)) { - + // Protection et encryption du pdf if ($conf->global->PDF_SECURITY_ENCRYPTION) { @@ -342,7 +345,7 @@ class pdf_oursin extends ModelePDFFactures } // Pied de page - $this->_pagefoot($pdf, $fac); + $this->_pagefoot($pdf, $fac, $outputlangs); $pdf->AliasNbPages(); $pdf->Close(); @@ -372,9 +375,9 @@ class pdf_oursin 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 @@ -402,7 +405,7 @@ class pdf_oursin extends ModelePDFFactures $pdf->MultiCell(20, 4, $outputlangs->transnoentities("Num"), 0, 'L', 0); $y=0; - + // 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"; @@ -412,7 +415,7 @@ class pdf_oursin extends ModelePDFFactures if ($resql) { $num = $this->db->num_rows($resql); - $i=0; + $i=0; $invoice=new Facture($this->db); while ($i < $num) { @@ -421,25 +424,25 @@ class pdf_oursin 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=$outputlangs->trans("ErrorSQL")." sql=".$sql; + $this->error=$outputlangs->trans("ErrorSQL")." sql=".$sql; dolibarr_syslog($this->db,$this->error); - return -1; + return -1; } // Loop on each payment @@ -465,27 +468,27 @@ class pdf_oursin extends ModelePDFFactures $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; + 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); @@ -506,11 +509,11 @@ class pdf_oursin extends ModelePDFFactures } /* - * \brief Affiche le total à payer - * \param pdf objet PDF - * \param fac objet facture - * \param deja_regle montant deja regle - */ + * \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) { global $langs; @@ -525,8 +528,8 @@ class pdf_oursin extends ModelePDFFactures $pdf->SetXY ($this->marges['g'], $tab2_top + 0); /* - * 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->MultiCell(100, $tab2_hl, $langs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); @@ -576,275 +579,233 @@ class pdf_oursin extends ModelePDFFactures } } - /* - * \brief Affiche la grille des lignes de factures - * \param pdf objet PDF - */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $fac) - { - global $langs; - $langs->load("main"); - $langs->load("bills"); - - $pdf->line( $this->marges['g'], $tab_top+8, 210-$this->marges['d'], $tab_top+8 ); - $pdf->line( $this->marges['g'], $tab_top + $tab_height, 210-$this->marges['d'], $tab_top + $tab_height ); - - $pdf->SetFont('Arial','B',10); - - $pdf->Text($this->marges['g']+2,$tab_top + 5, $langs->transnoentities("Designation")); - if ($this->franchise!=1) $pdf->Text($this->marges['g']+120, $tab_top + 5, $langs->transnoentities("VAT")); - $pdf->Text($this->marges['g']+135, $tab_top + 5,$langs->transnoentities("PriceUHT")); - $pdf->Text($this->marges['g']+153, $tab_top + 5, $langs->transnoentities("Qty")); - - $nblignes = sizeof($fac->lignes); - $rem=0; - for ($i = 0 ; $i < $nblignes ; $i++) - if ($fac->lignes[$i]->remise_percent) + /* + * \brief Affiche la grille des lignes de factures + * \param pdf objet PDF + */ + function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $fac) { + global $langs; + $langs->load("main"); + $langs->load("bills"); + + $pdf->line( $this->marges['g'], $tab_top+8, 210-$this->marges['d'], $tab_top+8 ); + $pdf->line( $this->marges['g'], $tab_top + $tab_height, 210-$this->marges['d'], $tab_top + $tab_height ); + + $pdf->SetFont('Arial','B',10); + + $pdf->Text($this->marges['g']+2,$tab_top + 5, $langs->transnoentities("Designation")); + if ($this->franchise!=1) $pdf->Text($this->marges['g']+120, $tab_top + 5, $langs->transnoentities("VAT")); + $pdf->Text($this->marges['g']+135, $tab_top + 5,$langs->transnoentities("PriceUHT")); + $pdf->Text($this->marges['g']+153, $tab_top + 5, $langs->transnoentities("Qty")); + + $nblignes = sizeof($fac->lignes); + $rem=0; + for ($i = 0 ; $i < $nblignes ; $i++) + if ($fac->lignes[$i]->remise_percent) + { $rem=1; + } + if ($rem==1) + { + $pdf->Text($this->marges['g']+163, $tab_top + 5,'Rem.'); + } + $pdf->Text($this->marges['g']+175, $tab_top + 5, $langs->transnoentities("TotalHT")); } - if ($rem==1) - { - $pdf->Text($this->marges['g']+163, $tab_top + 5,'Rem.'); - } - $pdf->Text($this->marges['g']+175, $tab_top + 5, $langs->transnoentities("TotalHT")); - } - /* - * \brief Affiche en-tête facture - * \param pdf objet PDF - * \param fac objet facture - */ - function _pagehead(&$pdf, $fac) - { - global $langs,$conf; - $langs->load("main"); - $langs->load("bills"); - $langs->load("propal"); - $langs->load("companies"); - - //Affiche le filigrane brouillon - Print Draft Watermark - if($fac->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) ) + /* + * \brief Affiche en-tête facture + * \param pdf objet PDF + * \param fac objet facture + */ + function _pagehead(&$pdf, $fac) { - $watermark_angle=atan($this->page_hauteur/$this->page_largeur); - $watermark_x=5; - $watermark_y=$this->page_hauteur-50; - $watermark_width=$this->page_hauteur; - $pdf->SetFont('Arial','B',50); - $pdf->SetTextColor(255,192,203); - //rotate - $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k)); - //print watermark - $pdf->SetXY($watermark_x,$watermark_y); - $pdf->Cell($watermark_width,25,clean_html($conf->global->FACTURE_DRAFT_WATERMARK),0,2,"C",0); - //antirotate - $pdf->_out('Q'); + global $langs,$conf; + $langs->load("main"); + $langs->load("bills"); + $langs->load("propal"); + $langs->load("companies"); + + //Affiche le filigrane brouillon - Print Draft Watermark + if($fac->statut==0 && (! empty($conf->global->FACTURE_DRAFT_WATERMARK)) ) + { + $watermark_angle=atan($this->page_hauteur/$this->page_largeur); + $watermark_x=5; + $watermark_y=$this->page_hauteur-50; + $watermark_width=$this->page_hauteur; + $pdf->SetFont('Arial','B',50); + $pdf->SetTextColor(255,192,203); + //rotate + $pdf->_out(sprintf('q %.5F %.5F %.5F %.5F %.2F %.2F cm 1 0 0 1 %.2F %.2F cm',cos($watermark_angle),sin($watermark_angle),-sin($watermark_angle),cos($watermark_angle),$watermark_x*$pdf->k,($pdf->h-$watermark_y)*$pdf->k,-$watermark_x*$pdf->k,-($pdf->h-$watermark_y)*$pdf->k)); + //print watermark + $pdf->SetXY($watermark_x,$watermark_y); + $pdf->Cell($watermark_width,25,clean_html($conf->global->FACTURE_DRAFT_WATERMARK),0,2,"C",0); + //antirotate + $pdf->_out('Q'); + } + //Print content + + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('Arial','B',13); + + $pdf->SetXY($this->marges['g'],6); + + // Logo + $logo=$conf->societe->dir_logos.'/'.$this->emetteur->logo; + 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'); + } + } + else if (defined("FAC_PDF_INTITULE")) + { + $pdf->MultiCell(80, 6, FAC_PDF_INTITULE, 0, 'L'); + } + + + /* + * Emetteur + */ + $posy=$this->marges['h']+24; + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('Arial','',8); + $pdf->SetXY($this->marges['g'],$posy-5); + + + $pdf->SetXY($this->marges['g'],$posy); + $pdf->SetFillColor(255,255,255); + $pdf->MultiCell(82, 34, "", 0, 'R', 1); + + + $pdf->SetXY($this->marges['g'],$posy+4); + + // Nom emetteur + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('Arial','B',12); + if (defined("FAC_PDF_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) // Prioritaire sur MAIN_INFO_SOCIETE_NOM + { + $pdf->MultiCell(80, 4, FAC_PDF_SOCIETE_NOM, 0, 'L'); + } + else // Par defaut + { + $pdf->MultiCell(80, 4, MAIN_INFO_SOCIETE_NOM, 0, 'L'); + } + + // Caractéristiques emetteur + $pdf->SetFont('Arial','',9); + if (defined("FAC_PDF_ADRESSE")) + { + $pdf->MultiCell(80, 4, FAC_PDF_ADRESSE); + } + if (defined("FAC_PDF_TEL") && FAC_PDF_TEL) + { + $pdf->MultiCell(80, 4, $langs->transnoentities("Phone").": ".FAC_PDF_TEL); + } + if (defined("FAC_PDF_MEL") && FAC_PDF_MEL) + { + $pdf->MultiCell(80, 4, $langs->transnoentities("Email").": ".FAC_PDF_MEL); + } + if (defined("FAC_PDF_WWW") && FAC_PDF_WWW) + { + $pdf->MultiCell(80, 4, $langs->transnoentities("Web").": ".FAC_PDF_WWW); + } + + $pdf->SetFont('Arial','',7); + if (defined("MAIN_INFO_SIREN") && MAIN_INFO_SIREN) + { + $pdf->MultiCell(80, 4, $langs->transcountrynoentities("ProfId1",$this->emetteur->pays_code).": ".MAIN_INFO_SIREN); + } + elseif (defined("MAIN_INFO_SIRET") && MAIN_INFO_SIRET) + { + $pdf->MultiCell(80, 4, $langs->transcountrynoentities("ProfId2",$this->emetteur->pays_code).": ".MAIN_INFO_SIRET); + } + + + /* + * Client + */ + $posy=45; + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('Arial','',8); + $pdf->SetXY($this->marges['g']+100,$posy-5); + $pdf->SetFont('Arial','B',11); + $fac->fetch_client(); + $pdf->SetXY($this->marges['g']+100,$posy+4); + $pdf->MultiCell(86,4, $fac->client->nom, 0, 'L'); + $pdf->SetFont('Arial','B',10); + $pdf->SetXY($this->marges['g']+100,$posy+12); + $pdf->MultiCell(86,4, $fac->client->adresse . "\n\n" . $fac->client->cp . " " . $fac->client->ville); + + /* + * ref facture + */ + $posy=65; + $pdf->SetFont('Arial','B',13); + $pdf->SetXY($this->marges['g'],$posy); + $pdf->SetTextColor(0,0,0); + $pdf->MultiCell(100, 10, $langs->transnoentities("Bill").' '.$langs->transnoentities("Of").' '.dolibarr_print_date($fac->date,"%d %B %Y"), '' , 'L'); + $pdf->SetFont('Arial','B',11); + $pdf->SetXY($this->marges['g'],$posy+6); + $pdf->SetTextColor(22,137,210); + $pdf->MultiCell(100, 10, $langs->transnoentities("RefBill")." : " . $fac->ref, '', 'L'); + $pdf->SetTextColor(0,0,0); + + /* + * ref projet + */ + if ($fac->projetid > 0) + { + $projet = New Project($fac->db); + $projet->fetch($fac->projetid); + $pdf->SetFont('Arial','',9); + $pdf->MultiCell(60, 4, $langs->transnoentities("Project")." : ".$projet->title); + } + + /* + * ref propal + */ + $sql = "SELECT ".$fac->db->pdate("p.datep")." as dp, p.ref, p.rowid as propalid"; + $sql .= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."fa_pr as fp WHERE fp.fk_propal = p.rowid AND fp.fk_facture = $fac->id"; + $result = $fac->db->query($sql); + if ($result) + { + $objp = $fac->db->fetch_object(); + $pdf->SetFont('Arial','',9); + $pdf->MultiCell(60, 4, $langs->transnoentities("RefProposal")." : ".$objp->ref); + } + + /* + * monnaie + */ + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('Arial','',10); + $titre = $langs->transnoentities("AmountInCurrency",$langs->transnoentities("Currency".$conf->monnaie)); + $pdf->Text(200 - $pdf->GetStringWidth($titre), 94, $titre); + /* + */ + } - //Print content - $pdf->SetTextColor(0,0,60); - $pdf->SetFont('Arial','B',13); - - $pdf->SetXY($this->marges['g'],6); - - // Logo - $logo=$conf->societe->dir_logos.'/'.$this->emetteur->logo; - 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'); - } - } - else if (defined("FAC_PDF_INTITULE")) - { - $pdf->MultiCell(80, 6, FAC_PDF_INTITULE, 0, 'L'); - } - - - /* - * Emetteur - */ - $posy=$this->marges['h']+24; - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('Arial','',8); - $pdf->SetXY($this->marges['g'],$posy-5); - - - $pdf->SetXY($this->marges['g'],$posy); - $pdf->SetFillColor(255,255,255); - $pdf->MultiCell(82, 34, "", 0, 'R', 1); - - - $pdf->SetXY($this->marges['g'],$posy+4); - - // Nom emetteur - $pdf->SetTextColor(0,0,60); - $pdf->SetFont('Arial','B',12); - if (defined("FAC_PDF_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) // Prioritaire sur MAIN_INFO_SOCIETE_NOM - { - $pdf->MultiCell(80, 4, FAC_PDF_SOCIETE_NOM, 0, 'L'); - } - else // Par defaut - { - $pdf->MultiCell(80, 4, MAIN_INFO_SOCIETE_NOM, 0, 'L'); - } - - // Caractéristiques emetteur - $pdf->SetFont('Arial','',9); - if (defined("FAC_PDF_ADRESSE")) - { - $pdf->MultiCell(80, 4, FAC_PDF_ADRESSE); - } - if (defined("FAC_PDF_TEL") && FAC_PDF_TEL) - { - $pdf->MultiCell(80, 4, $langs->transnoentities("Phone").": ".FAC_PDF_TEL); - } - if (defined("FAC_PDF_MEL") && FAC_PDF_MEL) - { - $pdf->MultiCell(80, 4, $langs->transnoentities("Email").": ".FAC_PDF_MEL); - } - if (defined("FAC_PDF_WWW") && FAC_PDF_WWW) - { - $pdf->MultiCell(80, 4, $langs->transnoentities("Web").": ".FAC_PDF_WWW); - } - - $pdf->SetFont('Arial','',7); - if (defined("MAIN_INFO_SIREN") && MAIN_INFO_SIREN) - { - $pdf->MultiCell(80, 4, $langs->transcountrynoentities("ProfId1",$this->emetteur->pays_code).": ".MAIN_INFO_SIREN); - } - elseif (defined("MAIN_INFO_SIRET") && MAIN_INFO_SIRET) - { - $pdf->MultiCell(80, 4, $langs->transcountrynoentities("ProfId2",$this->emetteur->pays_code).": ".MAIN_INFO_SIRET); - } - - - /* - * Client - */ - $posy=45; - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('Arial','',8); - $pdf->SetXY($this->marges['g']+100,$posy-5); - $pdf->SetFont('Arial','B',11); - $fac->fetch_client(); - $pdf->SetXY($this->marges['g']+100,$posy+4); - $pdf->MultiCell(86,4, $fac->client->nom, 0, 'L'); - $pdf->SetFont('Arial','B',10); - $pdf->SetXY($this->marges['g']+100,$posy+12); - $pdf->MultiCell(86,4, $fac->client->adresse . "\n\n" . $fac->client->cp . " " . $fac->client->ville); - - /* - * ref facture - */ - $posy=65; - $pdf->SetFont('Arial','B',13); - $pdf->SetXY($this->marges['g'],$posy); - $pdf->SetTextColor(0,0,0); - $pdf->MultiCell(100, 10, $langs->transnoentities("Bill").' '.$langs->transnoentities("Of").' '.dolibarr_print_date($fac->date,"%d %B %Y"), '' , 'L'); - $pdf->SetFont('Arial','B',11); - $pdf->SetXY($this->marges['g'],$posy+6); - $pdf->SetTextColor(22,137,210); - $pdf->MultiCell(100, 10, $langs->transnoentities("RefBill")." : " . $fac->ref, '', 'L'); - $pdf->SetTextColor(0,0,0); - - /* - * ref projet - */ - if ($fac->projetid > 0) - { - $projet = New Project($fac->db); - $projet->fetch($fac->projetid); - $pdf->SetFont('Arial','',9); - $pdf->MultiCell(60, 4, $langs->transnoentities("Project")." : ".$projet->title); - } - - /* - * ref propal - */ - $sql = "SELECT ".$fac->db->pdate("p.datep")." as dp, p.ref, p.rowid as propalid"; - $sql .= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."fa_pr as fp WHERE fp.fk_propal = p.rowid AND fp.fk_facture = $fac->id"; - $result = $fac->db->query($sql); - if ($result) - { - $objp = $fac->db->fetch_object(); - $pdf->SetFont('Arial','',9); - $pdf->MultiCell(60, 4, $langs->transnoentities("RefProposal")." : ".$objp->ref); - } - - /* - * monnaie - */ - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('Arial','',10); - $titre = $langs->transnoentities("AmountInCurrency",$langs->transnoentities("Currency".$conf->monnaie)); - $pdf->Text(200 - $pdf->GetStringWidth($titre), 94, $titre); - /* - */ - - } - - /* - * \brief Affiche le pied de page de la facture - * \param pdf objet PDF - * \param fac objet facture - */ - function _pagefoot(&$pdf, $fac) - { - global $langs, $conf; - $langs->load("main"); - $langs->load("bills"); - $langs->load("companies"); - - $footy=13; - $pdf->SetFont('Arial','',8); - - $ligne=""; - if (defined('MAIN_INFO_CAPITAL') && MAIN_INFO_CAPITAL) { - $ligne=$langs->transnoentities('LimitedLiabilityCompanyCapital').' '. MAIN_INFO_CAPITAL." ".$langs->transnoentities("Currency".$conf->monnaie); - } - if (defined('MAIN_INFO_SIREN') && MAIN_INFO_SIREN) { - $ligne.=($ligne?" - ":"").$langs->transcountrynoentities("ProfId1",$this->emetteur->pays_code).": ".MAIN_INFO_SIREN; - } - if (defined('MAIN_INFO_SIRET') && MAIN_INFO_SIRET) { - $ligne.=($ligne?" - ":"").$langs->transcountrynoentities("ProfId2",$this->emetteur->pays_code).": ".MAIN_INFO_SIRET; - } - if (defined('MAIN_INFO_RCS') && MAIN_INFO_RCS) { - $ligne.=($ligne?" - ":"").$langs->transcountrynoentities("ProfId4",$this->emetteur->pays_code).": ".MAIN_INFO_RCS; - } - if ($ligne) { - $pdf->SetY(-$footy); - $pdf->MultiCell(190, 3, $ligne, 0, 'C'); - $footy-=3; - } - - // Affiche le numéro de TVA intracommunautaire - if (MAIN_INFO_TVAINTRA == 'MAIN_INFO_TVAINTRA') { - $pdf->SetY(-$footy); - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(190, 3, $langs->transnoentities("ErrorVATIntraNotConfigured"),0,'L',0); - $pdf->MultiCell(190, 3, $langs->transnoentities("ErrorGoToGlobalSetup"),0,'L',0); - $pdf->SetTextColor(0,0,0); - } - elseif (MAIN_INFO_TVAINTRA != '') { - $pdf->SetY(-$footy); - $pdf->MultiCell(190, 3, $langs->transnoentities("IntracommunityVATNumber")." : ".MAIN_INFO_TVAINTRA, 0, 'C'); - } - - $pdf->SetXY(-15,-15); - $pdf->MultiCell(11, 3, $pdf->PageNo().'/{nb}', 0, 'R'); - } + /* + * \brief Affiche le pied de page de la facture + * \param pdf objet PDF + * \param fac objet facture + */ + function _pagefoot(&$pdf, $fac, $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/fichinter/pdf_soleil.modules.php b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php index d814e0aaa1e..be5ef4fb0d3 100644 --- a/htdocs/includes/modules/fichinter/pdf_soleil.modules.php +++ b/htdocs/includes/modules/fichinter/pdf_soleil.modules.php @@ -20,68 +20,68 @@ */ /** - \file htdocs/includes/modules/fichinter/pdf_soleil.modules.php - \ingroup ficheinter - \brief Fichier de la classe permettant de générer les fiches d'intervention au modèle Soleil - \version $Id$ -*/ + \file htdocs/includes/modules/fichinter/pdf_soleil.modules.php + \ingroup ficheinter + \brief Fichier de la classe permettant de générer les fiches d'intervention au modèle Soleil + \version $Id$ + */ require_once(DOL_DOCUMENT_ROOT."/includes/modules/fichinter/modules_fichinter.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); /** - \class pdf_soleil - \brief Classe permettant de générer les fiches d'intervention au modèle Soleil -*/ + \class pdf_soleil + \brief Classe permettant de générer les fiches d'intervention au modèle Soleil + */ class pdf_soleil extends ModelePDFFicheinter { - /** - \brief Constructeur - \param db Handler accès base de donnée - */ - function pdf_soleil($db=0) - { + /** + \brief Constructeur + \param db Handler accès base de donnée + */ + function pdf_soleil($db=0) + { global $conf,$langs,$mysoc; - $this->db = $db; - $this->name = 'soleil'; - $this->description = "Modèle de fiche d'intervention standard"; + $this->db = $db; + $this->name = 'soleil'; + $this->description = "Modèle de fiche d'intervention standard"; - // 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 = 0; // Gere option tva FACTURE_TVAOPTION - $this->option_modereg = 0; // Affiche mode règlement - $this->option_condreg = 0; // Affiche conditions règlement - $this->option_codeproduitservice = 0; // Affiche code produit-service - $this->option_multilang = 0; // Dispo en plusieurs langues + // 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 = 0; // Gere option tva FACTURE_TVAOPTION + $this->option_modereg = 0; // Affiche mode règlement + $this->option_condreg = 0; // Affiche conditions règlement + $this->option_codeproduitservice = 0; // Affiche code produit-service + $this->option_multilang = 0; // Dispo en plusieurs langues $this->option_draft_watermark = 1; //Support add of a watermark on drafts - - // Recupere code pays de l'emmetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->code_pays) $this->emetteur->code_pays=substr($langs->defaultlang,-2); // Par defaut, si n'était pas défini - } - /** - \brief Fonction générant la fiche d'intervention sur le disque - \param fichinter Object fichinter - \return int 1=ok, 0=ko - */ - function write_file($fichinter,$outputlangs='') + // Recupere code pays de l'emmetteur + $this->emetteur=$mysoc; + if (! $this->emetteur->code_pays) $this->emetteur->code_pays=substr($langs->defaultlang,-2); // Par defaut, si n'était pas défini + } + + /** + \brief Fonction générant la fiche d'intervention sur le disque + \param fichinter Object fichinter + \return int 1=ok, 0=ko + */ + function write_file($fichinter,$outputlangs='') { global $user,$langs,$conf,$mysoc; - + if (! is_object($outputlangs)) $outputlangs=$langs; $outputlangs->load("main"); $outputlangs->load("dict"); @@ -103,7 +103,7 @@ class pdf_soleil extends ModelePDFFicheinter dolibarr_print_error($db,$fichinter->error); } } - + $fichref = sanitize_string($fichinter->ref); $dir = $conf->fichinter->dir_output; if (! eregi('specimen',$fichref)) $dir.= "/" . $fichref; @@ -117,7 +117,7 @@ class pdf_soleil extends ModelePDFFicheinter return 0; } } - + if (file_exists($dir)) { // Protection et encryption du pdf @@ -137,12 +137,15 @@ class pdf_soleil extends ModelePDFFicheinter $pdf->Open(); $pdf->AddPage(); + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetAutoPageBreak(1,0); + //Affiche le filigrane brouillon - Print Draft Watermark - if($fichinter->statut==0 && (! empty($conf->global->FICHINTER_DRAFT_WATERMARK)) ) + if($fichinter->statut==0 && (! empty($conf->global->FICHINTER_DRAFT_WATERMARK)) ) { $watermark_angle=atan($this->page_hauteur/$this->page_largeur); $watermark_x=5; - $watermark_y=$this->page_hauteur-50; + $watermark_y=$this->page_hauteur-50; $watermark_width=$this->page_hauteur; $pdf->SetFont('Arial','B',50); $pdf->SetTextColor(255,192,203); @@ -154,10 +157,10 @@ class pdf_soleil extends ModelePDFFicheinter //antirotate $pdf->_out('Q'); } - //Print content - + //Print content + $posy=$this->marge_haute; - + $pdf->SetXY($this->marge_gauche,$posy); // Logo @@ -222,8 +225,8 @@ class pdf_soleil extends ModelePDFFicheinter /* - * Adresse Client - */ + * Adresse Client + */ $pdf->SetTextColor(0,0,0); $pdf->SetFont('Arial','B',12); $fichinter->fetch_client(); @@ -257,26 +260,26 @@ class pdf_soleil extends ModelePDFFicheinter $pdf->SetXY (10, $tab_top + 8 ); $pdf->writeHTMLCell(190, 5, 10, $tab_top + 8, dol_htmlentitiesbr($fichinter->description), 0, 'J', 0); - + //dolibarr_syslog("desc=".dol_htmlentitiesbr($fichinter->description)); $num = sizeof($fichinter->lignes); $i=0; if ($num) { while ($i < $num) - { + { $fichinterligne = $fichinter->lignes[$i]; $valide = $fichinterligne->id ? $fichinterligne->fetch($fichinterligne->id) : 0; if ($valide>0) { - $pdf->SetXY (20, $tab_top + 16 + $i * 20); - $pdf->writeHTMLCell(190, 8, 20, $tab_top + 16 + $i * 20, - dol_htmlentitiesbr($langs->transnoentities("Date")." : ".dolibarr_print_date($fichinterligne->datei)." - ".$langs->transnoentities("Duration")." : ".ConvertSecondToTime($fichinterligne->duration)), 0, 'J', 0); - - $pdf->SetXY (20, $tab_top + 22 + $i * 20); - $pdf->writeHTMLCell(170, 8, 20, $tab_top + 22 + $i * 20, - dol_htmlentitiesbr($fichinterligne->desc,1), 0, 'L', 0); + $pdf->SetXY (20, $tab_top + 16 + $i * 20); + $pdf->writeHTMLCell(190, 8, 20, $tab_top + 16 + $i * 20, + dol_htmlentitiesbr($langs->transnoentities("Date")." : ".dolibarr_print_date($fichinterligne->datei)." - ".$langs->transnoentities("Duration")." : ".ConvertSecondToTime($fichinterligne->duration)), 0, 'J', 0); + + $pdf->SetXY (20, $tab_top + 22 + $i * 20); + $pdf->writeHTMLCell(170, 8, 20, $tab_top + 22 + $i * 20, + dol_htmlentitiesbr($fichinterligne->desc,1), 0, 'L', 0); $tab_height+=20; } $i++; @@ -284,26 +287,30 @@ class pdf_soleil extends ModelePDFFicheinter } $pdf->Rect(10, $tab_top, 190, $tab_height); $pdf->SetXY (10, $pdf->GetY() + 20 ); - $pdf->MultiCell(60, 5, '', 0, 'J', 0); + $pdf->MultiCell(60, 5, '', 0, 'J', 0); - $pdf->SetXY(20,220); - $pdf->MultiCell(66,5, $langs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0); + $pdf->SetXY(20,220); + $pdf->MultiCell(66,5, $langs->transnoentities("NameAndSignatureOfInternalContact"),0,'L',0); - $pdf->SetXY(20,225); - $pdf->MultiCell(80,30, '', 1); + $pdf->SetXY(20,225); + $pdf->MultiCell(80,30, '', 1); - $pdf->SetXY(110,220); - $pdf->MultiCell(80,5, $langs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0); + $pdf->SetXY(110,220); + $pdf->MultiCell(80,5, $langs->transnoentities("NameAndSignatureOfExternalContact"),0,'L',0); - $pdf->SetXY(110,225); - $pdf->MultiCell(80,30, '', 1); + $pdf->SetXY(110,225); + $pdf->MultiCell(80,30, '', 1); $pdf->SetFont('Arial','', 9); // On repositionne la police par defaut + $this->_pagefoot($pdf,$outputlangs); + $pdf->AliasNbPages(); + $pdf->Close(); $pdf->Output($file); + $langs->setPhpLang(); // On restaure langue session return 1; } else @@ -321,76 +328,14 @@ class pdf_soleil extends ModelePDFFicheinter return 0; // Erreur par defaut } - /* - * \brief Affiche le pied de page - * \param pdf objet PDF - */ - function _pagefoot(&$pdf,$outputlangs) - { - global $conf; - - // Premiere ligne d'info reglementaires - $ligne1=""; - if ($this->emetteur->forme_juridique_code) - { - $ligne1.=($ligne1?" - ":"").getFormeJuridiqueLabel($this->emetteur->forme_juridique_code); - } - if ($this->emetteur->capital) - { - $ligne1.=($ligne1?" - ":"").$outputlangs->transnoentities("CapitalOf",$this->emetteur->capital)." ".$outputlangs->transnoentities("Currency".$conf->monnaie); - } - if ($this->emetteur->profid2) - { - $ligne1.=($ligne1?" - ":"").$outputlangs->transcountrynoentities("ProfId2",$this->emetteur->pays_code).": ".$this->emetteur->profid2; - } - if ($this->emetteur->profid1 && (! $this->emetteur->profid2 || $this->emetteur->pays_code != 'FR')) - { - $ligne1.=($ligne1?" - ":"").$outputlangs->transcountrynoentities("ProfId1",$this->emetteur->pays_code).": ".$this->emetteur->profid1; - } - - // Deuxieme ligne d'info reglementaires - $ligne2=""; - if ($this->emetteur->profid3) - { - $ligne2.=($ligne2?" - ":"").$outputlangs->transcountrynoentities("ProfId3",$this->emetteur->pays_code).": ".$this->emetteur->profid3; - } - if ($this->emetteur->profid4) - { - $ligne2.=($ligne2?" - ":"").$outputlangs->transcountrynoentities("ProfId4",$this->emetteur->pays_code).": ".$this->emetteur->profid4; - } - if ($this->emetteur->tva_intra != '') - { - $ligne2.=($ligne2?" - ":"").$outputlangs->transnoentities("VATIntraShort").": ".$this->emetteur->tva_intra; - } - - $pdf->SetFont('Arial','',8); - $pdf->SetDrawColor(224,224,224); - - // On positionne le debut du bas de page selon nbre de lignes de ce bas de page - //Todo: correction provisoire afin de régler le problème du bas de page - //$posy=$this->marge_basse + 1 + ($ligne1?3:0) + ($ligne2?3:0); - $posy=$this->marge_basse + 11 + ($ligne1?3:0) + ($ligne2?3:0); - - $pdf->SetY(-$posy); - $pdf->line($this->marge_gauche, $this->page_hauteur-$posy, 200, $this->page_hauteur-$posy); - $posy--; - - if ($ligne1) - { - $pdf->SetXY($this->marge_gauche,-$posy); - $pdf->MultiCell(200, 2, $ligne1, 0, 'C', 0); - } - - if ($ligne2) - { - $posy-=3; - $pdf->SetXY($this->marge_gauche,-$posy); - $pdf->MultiCell(200, 2, $ligne2, 0, 'C', 0); - } - - //$pdf->SetXY(-20,-$posy); - //$pdf->MultiCell(11, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0); - } + /* + * \brief Affiche le pied de page + * \param pdf objet PDF + */ + function _pagefoot(&$pdf,$outputlangs) + { + return pdf_pagefoot($pdf,$outputlangs,'FICHEINTER_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); + } } diff --git a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php index fb0ad281c36..81ac63619d0 100644 --- a/htdocs/includes/modules/propale/pdf_propale_azur.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_azur.modules.php @@ -20,12 +20,12 @@ */ /** - \file htdocs/includes/modules/propale/pdf_propale_azur.modules.php - \ingroup propale - \brief Fichier de la classe permettant de générer les propales au modèle Azur - \author Laurent Destailleur - \version $Id$ -*/ + \file htdocs/includes/modules/propale/pdf_propale_azur.modules.php + \ingroup propale + \brief Fichier de la classe permettant de générer les propales au modèle Azur + \author Laurent Destailleur + \version $Id$ + */ require_once(DOL_DOCUMENT_ROOT."/includes/modules/propale/modules_propale.php"); require_once(DOL_DOCUMENT_ROOT."/product.class.php"); @@ -33,77 +33,77 @@ require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); /** - \class pdf_propale_azur - \brief Classe permettant de générer les propales au modèle Azur -*/ + \class pdf_propale_azur + \brief Classe permettant de générer les propales au modèle Azur + */ class pdf_propale_azur extends ModelePDFPropales { var $emetteur; // Objet societe qui emet - /** - \brief Constructeur - \param db Handler accès base de donnée - */ - function pdf_propale_azur($db) - { - global $conf,$langs,$mysoc; + /** + \brief Constructeur + \param db Handler accès base de donnée + */ + function pdf_propale_azur($db) + { + global $conf,$langs,$mysoc; $langs->load("main"); - $langs->load("bills"); + $langs->load("bills"); - $this->db = $db; - $this->name = "azur"; - $this->description = $langs->trans('PDFAzurDescription'); + $this->db = $db; + $this->name = "azur"; + $this->description = $langs->trans('PDFAzurDescription'); - // 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_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_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 propale sur le disque - \param propale Objet propal à générer (ou id si ancienne methode) + \brief Fonction générant la propale sur le disque + \param propale Objet propal à générer (ou id si ancienne methode) \param outputlangs Lang object for output language \return int 1=ok, 0=ko - */ + */ function write_file($propale,$outputlangs='') { global $user,$langs,$conf; @@ -111,10 +111,10 @@ class pdf_propale_azur extends ModelePDFPropales if (! is_object($outputlangs)) $outputlangs=$langs; $outputlangs->load("main"); $outputlangs->load("dict"); - $outputlangs->load("companies"); - $outputlangs->load("bills"); - $outputlangs->load("propal"); - $outputlangs->load("products"); + $outputlangs->load("companies"); + $outputlangs->load("bills"); + $outputlangs->load("propal"); + $outputlangs->load("products"); $outputlangs->setPhpLang(); @@ -155,18 +155,18 @@ class pdf_propale_azur extends ModelePDFPropales { $nblignes = sizeof($propale->lignes); - // Protection et encryption du pdf - if ($conf->global->PDF_SECURITY_ENCRYPTION) - { - $pdf=new FPDI_Protection('P','mm',$this->format); - $pdfrights = array('print'); // Ne permet que l'impression du document - $pdfuserpass = ''; // Mot de passe pour l'utilisateur final - $pdfownerpass = NULL; // Mot de passe du propriétaire, créé aléatoirement si pas défini - $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass); - } - else - { - $pdf=new FPDI('P','mm',$this->format); + // Protection et encryption du pdf + if ($conf->global->PDF_SECURITY_ENCRYPTION) + { + $pdf=new FPDI_Protection('P','mm',$this->format); + $pdfrights = array('print'); // Ne permet que l'impression du document + $pdfuserpass = ''; // Mot de passe pour l'utilisateur final + $pdfownerpass = NULL; // Mot de passe du propriétaire, créé aléatoirement si pas défini + $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass); + } + else + { + $pdf=new FPDI('P','mm',$this->format); } $pdf->Open(); @@ -191,7 +191,7 @@ class pdf_propale_azur extends ModelePDFPropales } } - // Tete de page + // Tete de page $this->_pagehead($pdf, $propale, 1, $outputlangs); $pagenb = 1; @@ -239,7 +239,7 @@ class pdf_propale_azur extends ModelePDFPropales { if ($libelleproduitservice) $libelleproduitservice.="
"; - if ($propale->lignes[$i]->desc == '(CREDIT_NOTE)' && $propale->lignes[$i]->fk_remise_except) + if ($propale->lignes[$i]->desc == '(CREDIT_NOTE)' && $propale->lignes[$i]->fk_remise_except) { $discount=new DiscountAbsolute($this->db); $discount->fetch($propale->lignes[$i]->fk_remise_except); @@ -261,9 +261,9 @@ class pdf_propale_azur extends ModelePDFPropales { $prefix_prodserv = ""; if($prodser->isservice()) - $prefix_prodserv = $outputlangs->transnoentities("Service")." "; + $prefix_prodserv = $outputlangs->transnoentities("Service")." "; else - $prefix_prodserv = $outputlangs->transnoentities("Product")." "; + $prefix_prodserv = $outputlangs->transnoentities("Product")." "; $libelleproduitservice=$prefix_prodserv.$prodser->ref." - ".$libelleproduitservice; } @@ -315,15 +315,15 @@ class pdf_propale_azur extends ModelePDFPropales $pdf->MultiCell(26, 4, $total, 0, 'R', 0); } - // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva - $tvaligne=$propale->lignes[$i]->total_tva; - if ($propale->remise_percent) $tvaligne-=($tvaligne*$propale->remise_percent)/100; - $vatrate=(string) $propale->lignes[$i]->tva_tx; + // Collecte des totaux par valeur de tva dans $this->tva["taux"]=total_tva + $tvaligne=$propale->lignes[$i]->total_tva; + if ($propale->remise_percent) $tvaligne-=($tvaligne*$propale->remise_percent)/100; + $vatrate=(string) $propale->lignes[$i]->tva_tx; if ($propale->lignes[$i]->info_bits & 0x01 == 0x01) $vatrate.='*'; - $this->tva[$vatrate] += $tvaligne; + $this->tva[$vatrate] += $tvaligne; $nexY+=2; // Passe espace entre les lignes - + //on récupère la description du produit suivant $follow_descproduitservice = $propale->lignes[$i+1]->desc; //on compte le nombre de ligne afin de vérifier la place disponible @@ -366,13 +366,13 @@ class pdf_propale_azur extends ModelePDFPropales $bottomlasttab=$tab_top_newpage + $tab_height_newpage + 1; } - // Affiche zone infos - $posy=$this->_tableau_info($pdf, $propale, $bottomlasttab, $outputlangs); + // Affiche zone infos + $posy=$this->_tableau_info($pdf, $propale, $bottomlasttab, $outputlangs); - // Affiche zone totaux + // Affiche zone totaux $posy=$this->_tableau_tot($pdf, $propale, $deja_regle, $bottomlasttab, $outputlangs); - // Affiche zone versements + // Affiche zone versements if ($deja_regle) { $posy=$this->_tableau_versements($pdf, $propale, $posy, $outputlangs); @@ -408,369 +408,369 @@ class pdf_propale_azur extends ModelePDFPropales return 0; // Erreur par defaut } - /* - * \brief Affiche tableau des versement - * \param pdf Objet PDF - * \param object Objet propale - */ - function _tableau_versements(&$pdf, $object, $posy, $outputlangs) + /* + * \brief Affiche tableau des versement + * \param pdf Objet PDF + * \param object Objet propale + */ + function _tableau_versements(&$pdf, $object, $posy, $outputlangs) { } /* - * \brief Affiche infos divers - * \param pdf Objet PDF - * \param object Objet propale - * \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 propale + * \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); - - $posy=$pdf->GetY()+4; - } - - /* - * Conditions de reglements - */ - if ($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):$object->cond_reglement; - $pdf->MultiCell(80, 5, $lib_condition_paiement,0,'L'); - - $posy=$pdf->GetY()+3; - } - - /* - * Check si absence mode reglement - */ - if (! $conf->global->FACTURE_CHQ_NUMBER && ! $conf->global->FACTURE_RIB_NUMBER) + /* + * If France, show VAT mention if not applicable + */ + if ($this->emetteur->pays_code == 'FR' && $this->franchise == 1) { - $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->SetFont('Arial','B',8); + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("VATIsNotUsedForInvoice"), 0, 'L', 0); - $posy=$pdf->GetY()+1; - } - - /* - * 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); - - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByChequeOrderedTo',$account->proprio).':',0,'L',0); - $posy=$pdf->GetY()+1; - - $pdf->SetXY($this->marge_gauche, $posy); - $pdf->SetFont('Arial','',8); - $pdf->MultiCell(80, 3, $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').' '.$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, $this->emetteur->adresse_full, 0, 'L', 0); - - $posy=$pdf->GetY()+2; - } - } + $posy=$pdf->GetY()+4; } - - /* - * 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); - - $this->marges['g']=$this->marge_gauche; - - $cury=$posy; - $pdf->SetXY ($this->marges['g'], $cury); - $pdf->SetFont('Arial','B',8); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0); - $cury+=4; - $pdf->SetFont('Arial','B',6); - $pdf->line($this->marges['g']+1, $cury, $this->marges['g']+1, $cury+10 ); - $pdf->SetXY ($this->marges['g'], $cury); - $pdf->MultiCell(18, 3, $outputlangs->transnoentities("BankCode"), 0, 'C', 0); - $pdf->line($this->marges['g']+18, $cury, $this->marges['g']+18, $cury+10 ); - $pdf->SetXY ($this->marges['g']+18, $cury); - $pdf->MultiCell(18, 3, $outputlangs->transnoentities("DeskCode"), 0, 'C', 0); - $pdf->line($this->marges['g']+36, $cury, $this->marges['g']+36, $cury+10 ); - $pdf->SetXY ($this->marges['g']+36, $cury); - $pdf->MultiCell(24, 3, $outputlangs->transnoentities("BankAccountNumber"), 0, 'C', 0); - $pdf->line($this->marges['g']+60, $cury, $this->marges['g']+60, $cury+10 ); - $pdf->SetXY ($this->marges['g']+60, $cury); - $pdf->MultiCell(13, 3, $outputlangs->transnoentities("BankAccountNumberKey"), 0, 'C', 0); - $pdf->line($this->marges['g']+73, $cury, $this->marges['g']+73, $cury+10 ); - - $pdf->SetFont('Arial','',8); - $pdf->SetXY ($this->marges['g'], $cury+5); - $pdf->MultiCell(18, 3, $account->code_banque, 0, 'C', 0); - $pdf->SetXY ($this->marges['g']+18, $cury+5); - $pdf->MultiCell(18, 3, $account->code_guichet, 0, 'C', 0); - $pdf->SetXY ($this->marges['g']+36, $cury+5); - $pdf->MultiCell(24, 3, $account->number, 0, 'C', 0); - $pdf->SetXY ($this->marges['g']+60, $cury+5); - $pdf->MultiCell(13, 3, $account->cle_rib, 0, 'C', 0); - - $pdf->SetXY ($this->marges['g'], $cury+12); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities("Residence").' : ' . $account->domiciliation, 0, 'L', 0); - $pdf->SetXY ($this->marges['g'], $cury+22); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities("IbanPrefix").' : ' . $account->iban_prefix, 0, 'L', 0); - $pdf->SetXY ($this->marges['g'], $cury+25); - $pdf->MultiCell(90, 3, $outputlangs->transnoentities("BIC").' : ' . $account->bic, 0, 'L', 0); - - $posy=$pdf->GetY()+2; - } - } + + /* + * Conditions de reglements + */ + if ($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):$object->cond_reglement; + $pdf->MultiCell(80, 5, $lib_condition_paiement,0,'L'); + + $posy=$pdf->GetY()+3; } - - return $posy; - } + + /* + * 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') + { + // 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',$account->proprio).':',0,'L',0); + $posy=$pdf->GetY()+1; + + $pdf->SetXY($this->marge_gauche, $posy); + $pdf->SetFont('Arial','',8); + $pdf->MultiCell(80, 3, $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').' '.$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, $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); + + $this->marges['g']=$this->marge_gauche; + + $cury=$posy; + $pdf->SetXY ($this->marges['g'], $cury); + $pdf->SetFont('Arial','B',8); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities('PaymentByTransferOnThisBankAccount').':', 0, 'L', 0); + $cury+=4; + $pdf->SetFont('Arial','B',6); + $pdf->line($this->marges['g']+1, $cury, $this->marges['g']+1, $cury+10 ); + $pdf->SetXY ($this->marges['g'], $cury); + $pdf->MultiCell(18, 3, $outputlangs->transnoentities("BankCode"), 0, 'C', 0); + $pdf->line($this->marges['g']+18, $cury, $this->marges['g']+18, $cury+10 ); + $pdf->SetXY ($this->marges['g']+18, $cury); + $pdf->MultiCell(18, 3, $outputlangs->transnoentities("DeskCode"), 0, 'C', 0); + $pdf->line($this->marges['g']+36, $cury, $this->marges['g']+36, $cury+10 ); + $pdf->SetXY ($this->marges['g']+36, $cury); + $pdf->MultiCell(24, 3, $outputlangs->transnoentities("BankAccountNumber"), 0, 'C', 0); + $pdf->line($this->marges['g']+60, $cury, $this->marges['g']+60, $cury+10 ); + $pdf->SetXY ($this->marges['g']+60, $cury); + $pdf->MultiCell(13, 3, $outputlangs->transnoentities("BankAccountNumberKey"), 0, 'C', 0); + $pdf->line($this->marges['g']+73, $cury, $this->marges['g']+73, $cury+10 ); + + $pdf->SetFont('Arial','',8); + $pdf->SetXY ($this->marges['g'], $cury+5); + $pdf->MultiCell(18, 3, $account->code_banque, 0, 'C', 0); + $pdf->SetXY ($this->marges['g']+18, $cury+5); + $pdf->MultiCell(18, 3, $account->code_guichet, 0, 'C', 0); + $pdf->SetXY ($this->marges['g']+36, $cury+5); + $pdf->MultiCell(24, 3, $account->number, 0, 'C', 0); + $pdf->SetXY ($this->marges['g']+60, $cury+5); + $pdf->MultiCell(13, 3, $account->cle_rib, 0, 'C', 0); + + $pdf->SetXY ($this->marges['g'], $cury+12); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities("Residence").' : ' . $account->domiciliation, 0, 'L', 0); + $pdf->SetXY ($this->marges['g'], $cury+22); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities("IbanPrefix").' : ' . $account->iban_prefix, 0, 'L', 0); + $pdf->SetXY ($this->marges['g'], $cury+25); + $pdf->MultiCell(90, 3, $outputlangs->transnoentities("BIC").' : ' . $account->bic, 0, 'L', 0); + + $posy=$pdf->GetY()+2; + } + } + } + + return $posy; + } - /* - * \brief Affiche le total a payer - * \param pdf Objet PDF - * \param object Objet propale - * \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 propale + * \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 = 182; $largcol2 = $lltot - $col2x; - // 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); + // 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); + $pdf->SetXY ($col2x, $tab2_top + 0); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ht + $object->remise), 0, 'R', 1); - $index = 0; + $index = 0; - // Affichage des totaux de TVA par taux (conformément à réglementation) - $pdf->SetFillColor(248,248,248); - foreach( $this->tva as $tvakey => $tvaval ) - { - if ($tvakey) // On affiche pas taux 0 - { - $this->atleastoneratenotnull++; + // Affichage des totaux de TVA par taux (conformément à réglementation) + $pdf->SetFillColor(248,248,248); + 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").")"; + $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->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($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($object->total_tva), 0, 'R', 1); + } - $useborder=0; + $useborder=0; - $index++; - $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); - $pdf->SetTextColor(0,0,60); - $pdf->SetFillColor(224,224,224); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $useborder, 'L', 1); + $index++; + $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); + $pdf->SetTextColor(0,0,60); + $pdf->SetFillColor(224,224,224); + $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("TotalTTC"), $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); + $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); - if ($deja_regle > 0) - { - $index++; + if ($deja_regle > 0) + { + $index++; - $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); - $pdf->MultiCell($col2x-$col1x, $tab2_hl, $outputlangs->transnoentities("AlreadyPayed"), 0, 'L', 0); + $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); + $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); $resteapayer = $object->total_ttc - $deja_regle; if ($object->paye) $resteapayer=0; 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 ($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 ($col2x, $tab2_top + $tab2_hl * $index); + $pdf->MultiCell($largcol2, $tab2_hl, price($object->total_ttc - $deja_regle), $useborder, 'R', 1); $resteapayer=0; } - $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); + $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->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 propales - * \param pdf objet PDF - */ - function _tableau(&$pdf, $tab_top, $tab_height, $nexY, $outputlangs) - { - global $conf; + /** + * \brief Affiche la grille des lignes de propales + * \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); + // 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); - $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 Affiche en-tête propale - * \param pdf Objet PDF - * \param object Objet propale - * \param showadress 0=non, 1=oui - * \param outputlang Objet lang cible - */ - function _pagehead(&$pdf, $object, $showadress=1, $outputlangs) - { - global $conf,$langs; + /* + * \brief Affiche en-tête propale + * \param pdf Objet PDF + * \param object Objet propale + * \param showadress 0=non, 1=oui + * \param outputlang Objet lang cible + */ + 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->PROPALE_DRAFT_WATERMARK)) ) + if($object->statut==0 && (! empty($conf->global->PROPALE_DRAFT_WATERMARK)) ) { $watermark_angle=atan($this->page_hauteur/$this->page_largeur); $watermark_x=5; @@ -786,121 +786,121 @@ class pdf_propale_azur extends ModelePDFPropales //antirotate $pdf->_out('Q'); } - + //Prepare la suite - $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)) - { - $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'); - } + $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->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("CommercialProposal"); + $pdf->SetFont('Arial','B',13); + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $title=$outputlangs->transnoentities("CommercialProposal"); $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")." : " . $object->ref, '', 'R'); + $posy+=6; + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 4, $outputlangs->transnoentities("Ref")." : " . $object->ref, '', 'R'); $posy+=1; - $pdf->SetFont('Arial','',10); + $pdf->SetFont('Arial','',10); - $posy+=5; - $pdf->SetXY(100,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dolibarr_print_date($object->date,"day"), '', 'R'); + $posy+=5; + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("Date")." : " . dolibarr_print_date($object->date,"day"), '', 'R'); - $posy+=5; - $pdf->SetXY(100,$posy); - $pdf->SetTextColor(0,0,60); - $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dolibarr_print_date($object->fin_validite,"day"), '', 'R'); + $posy+=5; + $pdf->SetXY(100,$posy); + $pdf->SetTextColor(0,0,60); + $pdf->MultiCell(100, 3, $outputlangs->transnoentities("DateEndPropal")." : " . dolibarr_print_date($object->fin_validite,"day"), '', '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); - if (defined("FAC_PDF_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) $pdf->MultiCell(80, 4, FAC_PDF_SOCIETE_NOM, 0, 'L'); - else $pdf->MultiCell(80, 4, $this->emetteur->nom, 0, 'L'); + // Nom emetteur + $pdf->SetTextColor(0,0,60); + $pdf->SetFont('Arial','B',11); + if (defined("FAC_PDF_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) $pdf->MultiCell(80, 4, FAC_PDF_SOCIETE_NOM, 0, 'L'); + else $pdf->MultiCell(80, 4, $this->emetteur->nom, 0, 'L'); - // Caractéristiques emetteur - $carac_emetteur = ''; - if (defined("FAC_PDF_ADRESSE") && FAC_PDF_ADRESSE) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).FAC_PDF_ADRESSE; - else { - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$this->emetteur->adresse; - $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$this->emetteur->cp.' '.$this->emetteur->ville; - } - $carac_emetteur .= "\n"; - // Tel - if (defined("FAC_PDF_TEL") && FAC_PDF_TEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".FAC_PDF_TEL; - elseif ($this->emetteur->tel) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".$this->emetteur->tel; - // Fax - if (defined("FAC_PDF_FAX") && FAC_PDF_FAX) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".FAC_PDF_FAX; - elseif ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$this->emetteur->fax; - // EMail + // Caractéristiques emetteur + $carac_emetteur = ''; + if (defined("FAC_PDF_ADRESSE") && FAC_PDF_ADRESSE) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).FAC_PDF_ADRESSE; + else { + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$this->emetteur->adresse; + $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$this->emetteur->cp.' '.$this->emetteur->ville; + } + $carac_emetteur .= "\n"; + // Tel + if (defined("FAC_PDF_TEL") && FAC_PDF_TEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".FAC_PDF_TEL; + elseif ($this->emetteur->tel) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Phone").": ".$this->emetteur->tel; + // Fax + if (defined("FAC_PDF_FAX") && FAC_PDF_FAX) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".FAC_PDF_FAX; + elseif ($this->emetteur->fax) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Fax").": ".$this->emetteur->fax; + // EMail if (defined("FAC_PDF_MEL") && FAC_PDF_MEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".FAC_PDF_MEL; - elseif ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$this->emetteur->email; - // Web + elseif ($this->emetteur->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Email").": ".$this->emetteur->email; + // Web if (defined("FAC_PDF_WWW") && FAC_PDF_WWW) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".FAC_PDF_WWW; - elseif ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$this->emetteur->url; + elseif ($this->emetteur->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$outputlangs->transnoentities("Web").": ".$this->emetteur->url; - $pdf->SetFont('Arial','',9); - $pdf->SetXY($this->marge_gauche+2,$posy+8); - $pdf->MultiCell(80,4, $carac_emetteur); + $pdf->SetFont('Arial','',9); + $pdf->SetXY($this->marge_gauche+2,$posy+8); + $pdf->MultiCell(80,4, $carac_emetteur); - // Client destinataire - $posy=42; - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('Arial','',8); - $pdf->SetXY(102,$posy-5); - $pdf->MultiCell(80,5, $outputlangs->transnoentities("BillTo").":"); + // 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 $usecontact=false; @@ -920,7 +920,7 @@ class pdf_propale_azur extends ModelePDFPropales $pdf->SetXY(102,$posy+3); $pdf->SetFont('Arial','B',11); $pdf->MultiCell(96,4, $object->client->nom, 0, 'L'); - + // Nom client $carac_client = "\n".$object->contact->getFullName($outputlangs,1,1); @@ -936,11 +936,11 @@ class pdf_propale_azur extends ModelePDFPropales else { // Nom client - $pdf->SetXY(102,$posy+3); - $pdf->SetFont('Arial','B',11); - $pdf->MultiCell(96,4, $object->client->nom, 0, 'L'); - - // Nom du contact suivi propal si c'est une société + $pdf->SetXY(102,$posy+3); + $pdf->SetFont('Arial','B',11); + $pdf->MultiCell(96,4, $object->client->nom, 0, 'L'); + + // Nom du contact suivi propal si c'est une société $arrayidcontact = $object->getIdContact('external','CUSTOMER'); if (sizeof($arrayidcontact) > 0) { @@ -953,9 +953,9 @@ class pdf_propale_azur extends ModelePDFPropales } // Caractéristiques client - $carac_client.="\n".$object->client->adresse; - $carac_client.="\n".$object->client->cp . " " . $object->client->ville."\n"; - + $carac_client.="\n".$object->client->adresse; + $carac_client.="\n".$object->client->cp . " " . $object->client->ville."\n"; + //Pays si different de l'emetteur if ($this->emetteur->pays_code != $object->client->pays_code) { @@ -964,91 +964,21 @@ 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; - $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); + $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 Affiche le pied de page - * \param pdf objet PDF - */ - function _pagefoot(&$pdf,$outputlangs) - { - global $conf; - - // Line of free text - $ligne=(! empty($conf->global->PROPALE_FREE_TEXT))?$conf->global->PROPALE_FREE_TEXT:""; - - // Premiere ligne d'info réglementaires - $ligne1=""; - if ($this->emetteur->forme_juridique_code) - { - $ligne1.=($ligne1?" - ":"").getFormeJuridiqueLabel($this->emetteur->forme_juridique_code); - } - if ($this->emetteur->capital) - { - $ligne1.=($ligne1?" - ":"").$outputlangs->transnoentities("CapitalOf",$this->emetteur->capital)." ".$outputlangs->transnoentities("Currency".$conf->monnaie); - } - if ($this->emetteur->profid2) - { - $ligne1.=($ligne1?" - ":"").$outputlangs->transcountrynoentities("ProfId2",$this->emetteur->pays_code).": ".$this->emetteur->profid2; - } - if ($this->emetteur->profid1 && (! $this->emetteur->profid2 || $this->emetteur->pays_code != 'FR')) - { - $ligne1.=($ligne1?" - ":"").$outputlangs->transcountrynoentities("ProfId1",$this->emetteur->pays_code).": ".$this->emetteur->profid1; - } - - // Deuxieme ligne d'info réglementaires - $ligne2=""; - if ($this->emetteur->profid3) - { - $ligne2.=($ligne2?" - ":"").$outputlangs->transcountrynoentities("ProfId3",$this->emetteur->pays_code).": ".$this->emetteur->profid3; - } - if ($this->emetteur->profid4) - { - $ligne2.=($ligne2?" - ":"").$outputlangs->transcountrynoentities("ProfId4",$this->emetteur->pays_code).": ".$this->emetteur->profid4; - } - if ($this->emetteur->tva_intra != '') - { - $ligne2.=($ligne2?" - ":"").$outputlangs->transnoentities("VATIntraShort").": ".$this->emetteur->tva_intra; - } - - $pdf->SetFont('Arial','',7); - $pdf->SetDrawColor(224,224,224); - - // On positionne le debut du bas de page selon nbre de lignes de ce bas de page - $posy=$this->marge_basse + 1 + ($ligne?6:0) + ($ligne1?3:0) + ($ligne2?3:0); - - if ($ligne) - { - $pdf->SetXY($this->marge_gauche,-$posy); - $pdf->MultiCell(190, 3, $ligne, 0, 'L', 0); - $posy-=9; // 6 of ligne + 3 of MultiCell - } - - $pdf->SetY(-$posy); - $pdf->line($this->marge_gauche, $this->page_hauteur-$posy, 200, $this->page_hauteur-$posy); - $posy--; - - if ($ligne1) - { - $pdf->SetXY($this->marge_gauche,-$posy); - $pdf->MultiCell(200, 2, $ligne1, 0, 'C', 0); - } - - if ($ligne2) - { - $posy-=3; - $pdf->SetXY($this->marge_gauche,-$posy); - $pdf->MultiCell(200, 2, $ligne2, 0, 'C', 0); - } - - $pdf->SetXY(-20,-$posy); - $pdf->MultiCell(11, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0); - } + /* + * \brief Affiche le pied de page + * \param pdf objet PDF + */ + function _pagefoot(&$pdf,$outputlangs) + { + return pdf_pagefoot($pdf,$outputlangs,'PROPALE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); + } } diff --git a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php index 4fd9de8597d..a2d2a1b8b2f 100644 --- a/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php +++ b/htdocs/includes/modules/propale/pdf_propale_jaune.modules.php @@ -20,68 +20,88 @@ */ /** \file htdocs/includes/modules/propale/pdf_propale_jaune.modules.php - \ingroup propale - \brief Fichier de la classe permettant de générer les propales au modèle Jaune - \version $Id$ -*/ + \ingroup propale + \brief Fichier de la classe permettant de générer les propales au modèle Jaune + \version $Id$ + */ require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); -/** \class pdf_propale_jaune - \brief Classe permettant de générer les propales au modèle Jaune -*/ +/** + * \class pdf_propale_jaune + * \brief Classe permettant de générer les propales au modèle Jaune + */ class pdf_propale_jaune extends ModelePDFPropales { var $emetteur; // Objet societe qui emet - /** \brief Constructeur - \param db handler accès base de donnée - */ - function pdf_propale_jaune($db=0) - { - global $conf,$langs,$mysoc; + /** + * \brief Constructeur + * \param db handler accès base de donnée + */ + function pdf_propale_jaune($db=0) + { + global $conf,$langs,$mysoc; - $this->db = $db; - $this->name = "jaune"; - $this->description = "Modèle de proposition Jaune"; - - // 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); + $langs->load("main"); + $langs->load("bills"); + $this->db = $db; + $this->name = "jaune"; + $this->description = "Modèle de proposition Jaune"; + + // 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_draft_watermark = 1; //Support add of a watermark on drafts - $this->error = ""; + $this->error = ""; - // Recupere emmetteur - $this->emetteur=$mysoc; - if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si on trouve pas - } + // Recupere emmetteur + $this->emetteur=$mysoc; + if (! $this->emetteur->pays_code) $this->emetteur->pays_code=substr($langs->defaultlang,-2); // Par defaut, si on trouve pas + } /** \brief Renvoi dernière erreur - \return string Dernière erreur - */ + \return string Dernière erreur + */ function pdferror() { - return $this->error; + return $this->error; } /** - \brief Fonction générant la propale sur le disque - \param propale Objet propal + \brief Fonction générant la propale sur le disque + \param propale Objet propal \param outputlangs Lang object for output language \return int 1=ok, 0=ko - */ + */ function write_file($propale,$outputlangs='') { - global $user,$conf,$langs; + global $user,$langs,$conf; + + if (! is_object($outputlangs)) $outputlangs=$langs; + $outputlangs->load("main"); + $outputlangs->load("dict"); + $outputlangs->load("companies"); + $outputlangs->load("bills"); + $outputlangs->load("propal"); + $outputlangs->load("products"); + + $outputlangs->setPhpLang(); if ($conf->propal->dir_output) { @@ -117,38 +137,41 @@ class pdf_propale_jaune extends ModelePDFPropales if (file_exists($dir)) { - // Protection et encryption du pdf - if ($conf->global->PDF_SECURITY_ENCRYPTION) - { + // Protection et encryption du pdf + if ($conf->global->PDF_SECURITY_ENCRYPTION) + { $pdf=new FPDI_Protection('P','mm',$this->format); - $pdfrights = array('print'); // Ne permet que l'impression du document - $pdfuserpass = ''; // Mot de passe pour l'utilisateur final - $pdfownerpass = NULL; // Mot de passe du propriétaire, créé aléatoirement si pas défini - $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass); - } - else - { - $pdf=new FPDI('P','mm',$this->format); + $pdfrights = array('print'); // Ne permet que l'impression du document + $pdfuserpass = ''; // Mot de passe pour l'utilisateur final + $pdfownerpass = NULL; // Mot de passe du propriétaire, créé aléatoirement si pas défini + $pdf->SetProtection($pdfrights,$pdfuserpass,$pdfownerpass); + } + else + { + $pdf=new FPDI('P','mm',$this->format); } $pdf->Open(); - + $pdf->AddPage(); + $pdf->SetTitle($propale->ref); $pdf->SetSubject("Proposition commerciale"); $pdf->SetCreator("Dolibarr ".DOL_VERSION); $pdf->SetAuthor($user->fullname); - $pdf->AddPage(); - - $this->_pagehead($pdf, $propale); + $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right + $pdf->SetAutoPageBreak(1,0); + + // Tete de page + $this->_pagehead($pdf, $propale, $outputlangs); /* - */ + */ $tab_top = 100; $tab_height = 150; /* - * - */ + * + */ $pdf->SetFillColor(242,239,119); @@ -190,10 +213,12 @@ class pdf_propale_jaune extends ModelePDFPropales if ($nexY > 240 && $i < $nblignes - 1) { + $this->_pagefoot($pdf,$propale,$outputlangs); + $this->_tableau($pdf, $tab_top, $tab_height, $nexY); $pdf->AddPage(); $nexY = $iniY; - $this->_pagehead($pdf, $propale); + $this->_pagehead($pdf, $propale, $outputlangs); $pdf->SetTextColor(0,0,0); $pdf->SetFont('Arial','', 10); } @@ -201,8 +226,8 @@ class pdf_propale_jaune extends ModelePDFPropales $this->_tableau($pdf, $tab_top, $tab_height, $nexY); /* - * - */ + * + */ $tab2_top = 254; $tab2_lh = 7; $tab2_height = $tab2_lh * 3; @@ -218,13 +243,13 @@ class pdf_propale_jaune extends ModelePDFPropales $pdf->line(174, $tab2_top, 174, $tab2_top + $tab2_height); $pdf->SetXY (132, $tab2_top + 0); - $pdf->MultiCell(42, $tab2_lh, "Total HT", 0, 'R', 0); + $pdf->MultiCell(42, $tab2_lh, $outputlangs->trans("TotalHT"), 0, 'R', 0); $pdf->SetXY (132, $tab2_top + $tab2_lh); - $pdf->MultiCell(42, $tab2_lh, "Total TVA", 0, 'R', 0); + $pdf->MultiCell(42, $tab2_lh, $outputlangs->trans("TotalTVA"), 0, 'R', 0); $pdf->SetXY (132, $tab2_top + ($tab2_lh*2)); - $pdf->MultiCell(42, $tab2_lh, "Total TTC", 1, 'R', 1); + $pdf->MultiCell(42, $tab2_lh, $outputlangs->trans("TotalTTC"), 1, 'R', 1); $pdf->SetXY (174, $tab2_top + 0); $pdf->MultiCell(26, $tab2_lh, price($propale->total_ht), 0, 'R', 0); @@ -235,58 +260,60 @@ class pdf_propale_jaune extends ModelePDFPropales $pdf->SetXY (174, $tab2_top + ($tab2_lh*2)); $pdf->MultiCell(26, $tab2_lh, price($propale->total_ttc), 1, 'R', 1); - /* - * - */ + // Pied de page + $this->_pagefoot($pdf,$propale,$outputlangs); + $pdf->AliasNbPages(); + + $pdf->Close(); $pdf->Output($file); + + $langs->setPhpLang(); // On restaure langue session return 1; } } } - function _tableau(&$pdf, $tab_top, $tab_height, $nexY) - { - global $langs,$conf; - $langs->load("main"); - $langs->load("bills"); + function _tableau(&$pdf, $tab_top, $tab_height, $nexY) + { + global $langs,$conf; + $langs->load("main"); + $langs->load("bills"); - $pdf->SetFont('Arial','',11); + $pdf->SetFont('Arial','',11); - $pdf->SetXY(10,$tab_top); - $pdf->MultiCell(20,10,$langs->transnoentities("Ref"),0,'C',1); + $pdf->SetXY(10,$tab_top); + $pdf->MultiCell(20,10,$langs->transnoentities("Ref"),0,'C',1); - $pdf->SetXY(30,$tab_top); - $pdf->MultiCell(102,10,$langs->transnoentities("Designation"),0,'L',1); + $pdf->SetXY(30,$tab_top); + $pdf->MultiCell(102,10,$langs->transnoentities("Designation"),0,'L',1); - $pdf->line(132, $tab_top, 132, $tab_top + $tab_height); - $pdf->SetXY(132,$tab_top); - $pdf->MultiCell(12, 10,$langs->transnoentities("VAT"),0,'C',1); + $pdf->line(132, $tab_top, 132, $tab_top + $tab_height); + $pdf->SetXY(132,$tab_top); + $pdf->MultiCell(12, 10,$langs->transnoentities("VAT"),0,'C',1); - $pdf->line(144, $tab_top, 144, $tab_top + $tab_height); - $pdf->SetXY(144,$tab_top); - $pdf->MultiCell(10,10,$langs->transnoentities("Qty"),0,'C',1); + $pdf->line(144, $tab_top, 144, $tab_top + $tab_height); + $pdf->SetXY(144,$tab_top); + $pdf->MultiCell(10,10,$langs->transnoentities("Qty"),0,'C',1); - $pdf->line(154, $tab_top, 154, $tab_top + $tab_height); - $pdf->SetXY(154,$tab_top); - $pdf->MultiCell(22,10,$langs->transnoentities("PriceU"),0,'R',1); + $pdf->line(154, $tab_top, 154, $tab_top + $tab_height); + $pdf->SetXY(154,$tab_top); + $pdf->MultiCell(22,10,$langs->transnoentities("PriceU"),0,'R',1); - $pdf->line(176, $tab_top, 176, $tab_top + $tab_height); - $pdf->SetXY(176,$tab_top); - $pdf->MultiCell(24,10,$langs->transnoentities("Total"),0,'R',1); + $pdf->line(176, $tab_top, 176, $tab_top + $tab_height); + $pdf->SetXY(176,$tab_top); + $pdf->MultiCell(24,10,$langs->transnoentities("Total"),0,'R',1); - $pdf->Rect(10, $tab_top, 190, $tab_height); + $pdf->Rect(10, $tab_top, 190, $tab_height); - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('Arial','',10); - $titre = $langs->transnoentities("AmountInCurrency",$langs->transnoentities("Currency".$conf->monnaie)); - $pdf->Text(10,280, $titre); - } + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('Arial','',10); + } - function _pagehead(&$pdf, $propale) - { - //Affiche le filigrane brouillon - Print Draft Watermark - if($propale->statut==0 && defined("PROPALE_DRAFT_WATERMARK") ) + function _pagehead(&$pdf, $propale, $outputlangs) + { + //Affiche le filigrane brouillon - Print Draft Watermark + if($propale->statut==0 && defined("PROPALE_DRAFT_WATERMARK") ) { $watermark_angle=deg2rad(55); $watermark_x=5; @@ -302,66 +329,77 @@ class pdf_propale_jaune extends ModelePDFPropales //antirotate $pdf->_out('Q'); } - - //print Content - - $pdf->SetXY(12,42); - if (defined("FAC_PDF_INTITULE")) - { + + //print Content + + $pdf->SetXY(12,42); + if (defined("FAC_PDF_INTITULE")) + { $pdf->SetTextColor(0,0,200); $pdf->SetFont('Arial','B',14); $pdf->MultiCell(76, 8, FAC_PDF_INTITULE, 0, 'L'); - } + } - $pdf->SetTextColor(70,70,170); - if (defined("FAC_PDF_ADRESSE")) - { + $pdf->SetTextColor(70,70,170); + if (defined("FAC_PDF_ADRESSE")) + { $pdf->SetX(12); $pdf->SetFont('Arial','',12); $pdf->MultiCell(76, 5, FAC_PDF_ADRESSE); - } - if (defined("FAC_PDF_TEL")) - { + } + if (defined("FAC_PDF_TEL")) + { $pdf->SetX(12); $pdf->SetFont('Arial','',10); $pdf->MultiCell(76, 5, "Tél : ".FAC_PDF_TEL); - } - if (defined("MAIN_INFO_SIREN")) - { + } + if (defined("MAIN_INFO_SIREN")) + { $pdf->SetX(12); $pdf->SetFont('Arial','',10); $pdf->MultiCell(76, 5, "SIREN : ".MAIN_INFO_SIREN); + } + $pdf->rect(10, 40, 80, 40); + + $pdf->SetXY(10,5); + $pdf->SetFont('Arial','B',16); + $pdf->SetTextColor(0,0,200); + $pdf->MultiCell(200, 20, "PROPOSITION COMMERCIALE", '' , 'C'); + + /* + * Adresse Client + */ + $pdf->SetTextColor(0,0,0); + $pdf->SetFont('Arial','B',12); + $propale->fetch_client(); + $pdf->SetXY(102,42); + $pdf->MultiCell(96,5, $propale->client->nom); + $pdf->SetFont('Arial','B',11); + $pdf->SetXY(102,$pdf->GetY()); + $pdf->MultiCell(96,5, $propale->client->adresse . "\n" . $propale->client->cp . " " . $propale->client->ville); + $pdf->rect(100, 40, 100, 40); + + $pdf->SetTextColor(200,0,0); + $pdf->SetFont('Arial','B',12); + + $pdf->rect(10, 90, 100, 10); + $pdf->rect(110, 90, 90, 10); + + $pdf->SetXY(10,90); + $pdf->MultiCell(110, 10, $outputlangs->trans("Ref")." : ".$propale->ref); + $pdf->SetXY(110,90); + $pdf->MultiCell(100, 10, $outputlangs->trans("Date")." : " . dolibarr_print_date($propale->date,'day')); } - $pdf->rect(10, 40, 80, 40); - $pdf->SetXY(10,5); - $pdf->SetFont('Arial','B',16); - $pdf->SetTextColor(0,0,200); - $pdf->MultiCell(200, 20, "PROPOSITION COMMERCIALE", '' , 'C'); + /* + * \brief Affiche le pied de page + * \param pdf Object PDF + * \param object Object proposal + */ + function _pagefoot(&$pdf,$object,$outputlangs) + { + return pdf_pagefoot($pdf,$outputlangs,'PROPALE_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); + } - /* - * Adresse Client - */ - $pdf->SetTextColor(0,0,0); - $pdf->SetFont('Arial','B',12); - $propale->fetch_client(); - $pdf->SetXY(102,42); - $pdf->MultiCell(96,5, $propale->client->nom); - $pdf->SetFont('Arial','B',11); - $pdf->SetXY(102,$pdf->GetY()); - $pdf->MultiCell(96,5, $propale->client->adresse . "\n" . $propale->client->cp . " " . $propale->client->ville); - $pdf->rect(100, 40, 100, 40); - - $pdf->SetTextColor(200,0,0); - $pdf->SetFont('Arial','B',12); - - $pdf->rect(10, 90, 100, 10); - $pdf->rect(110, 90, 90, 10); - - $pdf->SetXY(10,90); - $pdf->MultiCell(110, 10, "Numéro : ".$propale->ref); - $pdf->SetXY(110,90); - $pdf->MultiCell(100, 10, "Date : " . dolibarr_print_date($propale->date,'day')); - } } ?> diff --git a/htdocs/lib/company.lib.php b/htdocs/lib/company.lib.php index 3d4450e6020..0f0ce676b0a 100644 --- a/htdocs/lib/company.lib.php +++ b/htdocs/lib/company.lib.php @@ -20,11 +20,11 @@ */ /** - \file htdocs/lib/company.lib.php - \brief Ensemble de fonctions de base pour le module societe - \ingroup societe - \version $Id$ -*/ + \file htdocs/lib/company.lib.php + \brief Ensemble de fonctions de base pour le module societe + \ingroup societe + \version $Id$ + */ function societe_prepare_head($objsoc) { @@ -57,7 +57,7 @@ function societe_prepare_head($objsoc) $head[$h][1] = $langs->trans("Supplier"); $head[$h][2] = 'supplier'; $h++; - } + } if ($conf->facture->enabled || $conf->compta->enabled || $conf->comptaexpert->enabled) { $langs->load("compta"); @@ -73,7 +73,7 @@ function societe_prepare_head($objsoc) $head[$h][0] = DOL_URL_ROOT.'/categories/categorie.php?socid='.$objsoc->id; $head[$h][1] = $langs->trans('Categories'); $head[$h][2] = 'category'; - $h++; + $h++; } if ($user->societe_id == 0) { @@ -107,7 +107,7 @@ function societe_prepare_head($objsoc) } if ($user->societe_id == 0) - { + { $head[$h][0] = DOL_URL_ROOT.'/societe/info.php?socid='.$objsoc->id; $head[$h][1] = $langs->trans("Info"); $head[$h][2] = 'info'; @@ -133,36 +133,36 @@ function societe_prepare_head2($objsoc) $h = 0; $head = array(); - $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$objsoc->id; - $head[$h][1] = $langs->trans("Card"); + $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$objsoc->id; + $head[$h][1] = $langs->trans("Card"); $head[$h][2] = 'company'; - $h++; - - $head[$h][0] = DOL_URL_ROOT .'/societe/rib.php?socid='.$objsoc->id; - $head[$h][1] = $langs->trans("BankAccount")." $account->number"; + $h++; + + $head[$h][0] = DOL_URL_ROOT .'/societe/rib.php?socid='.$objsoc->id; + $head[$h][1] = $langs->trans("BankAccount")." $account->number"; $head[$h][2] = 'rib'; - $h++; - - $head[$h][0] = 'lien.php?socid='.$objsoc->id; - $head[$h][1] = $langs->trans("Links"); + $h++; + + $head[$h][0] = 'lien.php?socid='.$objsoc->id; + $head[$h][1] = $langs->trans("Links"); $head[$h][2] = 'links'; - $h++; - - $head[$h][0] = 'commerciaux.php?socid='.$objsoc->id; - $head[$h][1] = $langs->trans("SalesRepresentative"); + $h++; + + $head[$h][0] = 'commerciaux.php?socid='.$objsoc->id; + $head[$h][1] = $langs->trans("SalesRepresentative"); $head[$h][2] = 'salesrepresentative'; - $h++; - + $h++; + return $head; } /** -* \brief Retourne le nom traduit ou code+nom d'un pays -* \param id id du pays -* \param withcode 1=affiche code + nom -* \return string Nom traduit du pays -*/ + * \brief Retourne le nom traduit ou code+nom d'un pays + * \param id id du pays + * \param withcode 1=affiche code + nom + * \return string Nom traduit du pays + */ function getCountryLabel($id,$withcode=0) { global $db,$langs; @@ -200,7 +200,7 @@ function getFormeJuridiqueLabel($code) global $db,$langs; if (! $code) return ''; - + $sql = "SELECT libelle FROM ".MAIN_DB_PREFIX."c_forme_juridique"; $sql.= " WHERE code='$code'"; @@ -232,316 +232,316 @@ function show_contacts($conf,$langs,$db,$objsoc) { global $user; global $bc; - + $contactstatic = new Contact($db); - + if ($conf->clicktodial->enabled) - { - $user->fetch_clicktodial(); // lecture des infos de clicktodial - } + { + $user->fetch_clicktodial(); // lecture des infos de clicktodial + } print_titre($langs->trans("ContactsForCompany")); - print ''; + print '
'; - print ''; - print ''; - print ''; - print ""; - if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) - { - print ''; - } - print ""; + print ''; + print ''; + print ''; + print ""; + if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) + { + print ''; + } + print ""; - $sql = "SELECT p.rowid, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note "; - $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; - $sql .= " WHERE p.fk_soc = ".$objsoc->id; - $sql .= " ORDER by p.datec"; + $sql = "SELECT p.rowid, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note "; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as p"; + $sql .= " WHERE p.fk_soc = ".$objsoc->id; + $sql .= " ORDER by p.datec"; - $result = $db->query($sql); - $i = 0; - $num = $db->num_rows($result); - $var=true; + $result = $db->query($sql); + $i = 0; + $num = $db->num_rows($result); + $var=true; - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($result); - $var = !$var; - - print ""; - - print ''; - - print ''; - - // Lien click to dial - print '"; + + print ''; + + print ''; + + // Lien click to dial + print ''; - print ''; - print ''; + print ''; + print ''; - - print ''; - - if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) - { - print ''; - } - - print "\n"; - $i++; - } - } - else - { - //print ""; - //print ''; - //print "\n"; - } - print "
'.$langs->trans("Name").''.$langs->trans("Poste").''.$langs->trans("Tel").''.$langs->trans("Fax").''.$langs->trans("EMail").'  
'.$langs->trans("Name").''.$langs->trans("Poste").''.$langs->trans("Tel").''.$langs->trans("Fax").''.$langs->trans("EMail").'  
'; - $contactstatic->id = $obj->rowid; - $contactstatic->name = $obj->name; - $contactstatic->firstname = $obj->firstname; - print $contactstatic->getNomUrl(1); - print ''.$obj->poste.''; - if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) - print ''; - print dolibarr_print_phone($obj->phone); - if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) - print ''; + if ($num) + { + while ($i < $num) + { + $obj = $db->fetch_object($result); + $var = !$var; + + print "
'; + $contactstatic->id = $obj->rowid; + $contactstatic->name = $obj->name; + $contactstatic->firstname = $obj->firstname; + print $contactstatic->getNomUrl(1); + print ''.$obj->poste.''; + if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) + print ''; + print dolibarr_print_phone($obj->phone); + if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) + print ''; if ($obj->phone) print dol_phone_link($obj->phone); - print ''; - if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) - print ''; - print dolibarr_print_phone($obj->fax); - if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) - print ''; - print ' '; - if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) - print ''; - print $obj->email; - if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) - print ''; + print ''; + if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) + print ''; + print dolibarr_print_phone($obj->fax); + if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) + print ''; + print ' '; + if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) + print ''; + print $obj->email; + if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) + print ''; // \TODO //if ($obj->email) print dol_email_link($obj->email); - print ' '; - print "rowid."\">"; - print img_edit(); - print ''; - print img_object($langs->trans("Rendez-Vous"),"action"); - print '
'.$langs->trans("NoContactsYetDefined").'
\n"; + print ' '; - print "
\n"; + print ''; + print "rowid."\">"; + print img_edit(); + print ''; + + if ($conf->agenda->enabled && $user->rights->agenda->myactions->create) + { + print ''; + print img_object($langs->trans("Rendez-Vous"),"action"); + print ''; + } + + print "\n"; + $i++; + } + } + else + { + //print ""; + //print ''.$langs->trans("NoContactsYetDefined").''; + //print "\n"; + } + print "\n"; + + print "
\n"; } /** -* \brief Show html area with actions to do -*/ + * \brief Show html area with actions to do + */ function show_actions_todo($conf,$langs,$db,$objsoc) { global $bc; - - if ($conf->agenda->enabled) - { + + if ($conf->agenda->enabled) + { require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php"); $actionstatic=new ActionComm($db); $userstatic=new User($db); $contactstatic = new Contact($db); - + print_titre($langs->trans("ActionsOnCompany")); - - print ''; - print ''; - print ''; - print ''; - - $sql = "SELECT a.id, a.label,"; - $sql.= " ".$db->pdate("a.datep")." as dp,"; - $sql.= " ".$db->pdate("a.datea")." as da,"; - $sql.= " a.percent,"; - $sql.= " c.code as acode, c.libelle, a.propalrowid, a.fk_user_author, a.fk_contact,"; + + print '
'.$langs->trans("ActionsToDoShort").' 
'; + print ''; + print ''; + print ''; + + $sql = "SELECT a.id, a.label,"; + $sql.= " ".$db->pdate("a.datep")." as dp,"; + $sql.= " ".$db->pdate("a.datea")." as da,"; + $sql.= " a.percent,"; + $sql.= " c.code as acode, c.libelle, a.propalrowid, a.fk_user_author, a.fk_contact,"; $sql.= " u.login, u.rowid,"; $sql.= " sp.name, sp.firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; - $sql.= " WHERE a.fk_soc = ".$objsoc->id; - $sql.= " AND u.rowid = a.fk_user_author"; - $sql.= " AND c.id=a.fk_action AND a.percent < 100"; - $sql.= " ORDER BY a.datep DESC, a.id DESC"; - + $sql.= " WHERE a.fk_soc = ".$objsoc->id; + $sql.= " AND u.rowid = a.fk_user_author"; + $sql.= " AND c.id=a.fk_action AND a.percent < 100"; + $sql.= " ORDER BY a.datep DESC, a.id DESC"; + dolibarr_syslog("company.lib::show_actions_todo sql=".$sql); - $result=$db->query($sql); - if ($result) - { - $i = 0 ; - $num = $db->num_rows($result); - $var=true; - - if ($num) - { - while ($i < $num) - { - $var = !$var; - - $obj = $db->fetch_object($result); - print ""; - - print '\n"; - $oldyear = strftime("%Y",$obj->dp); - - print '\n"; - $oldmonth = strftime("%Y%b",$obj->dp); - - print '\n"; - print ''; - + $result=$db->query($sql); + if ($result) + { + $i = 0 ; + $num = $db->num_rows($result); + $var=true; + + if ($num) + { + while ($i < $num) + { + $var = !$var; + + $obj = $db->fetch_object($result); + print ""; + + print '\n"; + $oldyear = strftime("%Y",$obj->dp); + + print '\n"; + $oldmonth = strftime("%Y%b",$obj->dp); + + print '\n"; + print ''; + // Picto warning print ''; - - // Status/Percent - print ''; - - if ($obj->propalrowid) - { - print ''; - } - else - { - $actionstatic->code=$obj->acode; - $actionstatic->libelle=$obj->libelle; - $actionstatic->id=$obj->id; - print ''; - } - print ''; - - // Contact pour cette action - if ($obj->fk_contact > 0) - { - $contactstatic->name=$obj->name; - $contactstatic->firstname=$obj->firstname; - $contactstatic->id=$obj->fk_contact; - print ''; - } - else - { - print ''; - } - - print ''; + + if ($obj->propalrowid) + { + print ''; + } + else + { + $actionstatic->code=$obj->acode; + $actionstatic->libelle=$obj->libelle; + $actionstatic->id=$obj->id; + print ''; + } + print ''; + + // Contact pour cette action + if ($obj->fk_contact > 0) + { + $contactstatic->name=$obj->name; + $contactstatic->firstname=$obj->firstname; + $contactstatic->id=$obj->fk_contact; + print ''; + } + else + { + print ''; + } + + print ''; - + // Statut - print ''; - - print "\n"; - $i++; - } + print ''; + + print "\n"; + $i++; + } } else { // Aucun action a faire } - $db->free($result); - } - else - { - dolibarr_print_error($db); - } - print "
'.$langs->trans("ActionsToDoShort").' 
'.strftime("%Y",$obj->dp)."' .strftime("%b",$obj->dp)."'.strftime("%d",$obj->dp)."'.strftime("%H:%M",$obj->dp).'
'.strftime("%Y",$obj->dp)."' .strftime("%b",$obj->dp)."'.strftime("%d",$obj->dp)."'.strftime("%H:%M",$obj->dp).''; if (date("U",$obj->dp) < time()) print ' '.img_warning("Late"); else print ' '; print ' '.img_object($langs->trans("ShowAction"),"task"); - $transcode=$langs->trans("Action".$obj->acode); - $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); - print $libelle; - print ''.$actionstatic->getNomUrl(1,16).''.$obj->label.''.$contactstatic->getNomUrl(1).' '; + + // Status/Percent + print ' '.img_object($langs->trans("ShowAction"),"task"); + $transcode=$langs->trans("Action".$obj->acode); + $libelle=($transcode!="Action".$obj->acode?$transcode:$obj->libelle); + print $libelle; + print ''.$actionstatic->getNomUrl(1,16).''.$obj->label.''.$contactstatic->getNomUrl(1).' '; $userstatic->id=$obj->fk_user_author; $userstatic->login=$obj->login; print $userstatic->getLoginUrl(1); print ''.$actionstatic->LibStatut($obj->percent,3).'
'.$actionstatic->LibStatut($obj->percent,3).'
\n"; - - print "
\n"; - } + $db->free($result); + } + else + { + dolibarr_print_error($db); + } + print "\n"; + + print "
\n"; + } } /** -* \brief Show html area with actions done -*/ + * \brief Show html area with actions done + */ function show_actions_done($conf,$langs,$db,$objsoc) { global $bc; - + if ($conf->agenda->enabled) - { - require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php"); + { + require_once(DOL_DOCUMENT_ROOT."/actioncomm.class.php"); require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); - $actionstatic=new ActionComm($db); - $userstatic=new User($db); - $contactstatic = new Contact($db); - $facturestatic=new Facture($db); - - print ''; - print ''; - print ''; - print ''; - - $sql = "SELECT a.id, a.label,"; - $sql.= " ".$db->pdate("a.datep")." as dp,"; - $sql.= " ".$db->pdate("a.datep2")." as dp2,"; - $sql.= " a.percent,"; - $sql.= " a.propalrowid, a.fk_facture, a.fk_user_author, a.fk_contact,"; - $sql.= " c.code as acode, c.libelle,"; - $sql.= " u.login, u.rowid,"; - $sql.= " sp.name, sp.firstname"; - $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; - $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; - $sql.= " WHERE a.fk_soc = ".$objsoc->id; - $sql.= " AND u.rowid = a.fk_user_author"; - $sql.= " AND c.id=a.fk_action AND a.percent = 100"; - $sql.= " ORDER BY a.datep2 DESC, a.id DESC"; - + $actionstatic=new ActionComm($db); + $userstatic=new User($db); + $contactstatic = new Contact($db); + $facturestatic=new Facture($db); + + print '
'.$langs->trans("ActionsDoneShort").'
'; + print ''; + print ''; + print ''; + + $sql = "SELECT a.id, a.label,"; + $sql.= " ".$db->pdate("a.datep")." as dp,"; + $sql.= " ".$db->pdate("a.datep2")." as dp2,"; + $sql.= " a.percent,"; + $sql.= " a.propalrowid, a.fk_facture, a.fk_user_author, a.fk_contact,"; + $sql.= " c.code as acode, c.libelle,"; + $sql.= " u.login, u.rowid,"; + $sql.= " sp.name, sp.firstname"; + $sql.= " FROM ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; + $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; + $sql.= " WHERE a.fk_soc = ".$objsoc->id; + $sql.= " AND u.rowid = a.fk_user_author"; + $sql.= " AND c.id=a.fk_action AND a.percent = 100"; + $sql.= " ORDER BY a.datep2 DESC, a.id DESC"; + dolibarr_syslog("comm/fiche.php sql=".$sql); - $result=$db->query($sql); - if ($result) - { - $i = 0 ; - $num = $db->num_rows($result); - $oldyear=''; - $oldmonth=''; - $var=true; - - while ($i < $num) - { - $var = !$var; - - $obj = $db->fetch_object($result); - print ""; - - // Champ date - print '\n"; - $oldyear = strftime("%Y",$obj->dp2); - print '\n"; - $oldmonth = strftime("%Y%b",$obj->dp2); - print '\n"; - print '\n"; - + $result=$db->query($sql); + if ($result) + { + $i = 0 ; + $num = $db->num_rows($result); + $oldyear=''; + $oldmonth=''; + $var=true; + + while ($i < $num) + { + $var = !$var; + + $obj = $db->fetch_object($result); + print ""; + + // Champ date + print '\n"; + $oldyear = strftime("%Y",$obj->dp2); + print '\n"; + $oldmonth = strftime("%Y%b",$obj->dp2); + print '\n"; + print '\n"; + // Picto - print ''; - - // Espace - print ''; - + print ''; + + // Espace + print ''; + // Action - print ''; - - // Objet lie - print ''; - + print ''; + // Libelle - print ''; - - // Contact pour cette action - if ($obj->fk_contact > 0) - { + print ''; + + // Contact pour cette action + if ($obj->fk_contact > 0) + { $contactstatic->name=$obj->name; $contactstatic->firstname=$obj->firstname; $contactstatic->id=$obj->fk_contact; - print ''; - } - else - { - print ''; - } - + print ''; + } + else + { + print ''; + } + // Auteur - print ''; - + // Statut - print ''; - - print "\n"; - $i++; - } - - $db->free($result); - } - else - { - dolibarr_print_error($db); - } - - print "
'.$langs->trans("ActionsDoneShort").'
'.strftime("%Y",$obj->dp2)."'.strftime("%b",$obj->dp2)."'.strftime("%d",$obj->dp2)."'.strftime("%H:%M",$obj->dp2)."
'.strftime("%Y",$obj->dp2)."'.strftime("%b",$obj->dp2)."'.strftime("%d",$obj->dp2)."'.strftime("%H:%M",$obj->dp2)."    '; - $actionstatic->code=$obj->acode; - $actionstatic->libelle=$obj->libelle; - $actionstatic->id=$obj->id; - print $actionstatic->getNomUrl(1,16); + print ''; + $actionstatic->code=$obj->acode; + $actionstatic->libelle=$obj->libelle; + $actionstatic->id=$obj->id; + print $actionstatic->getNomUrl(1,16); print ''; + + // Objet lie + print ''; if ($obj->propalrowid) { print ''.img_object($langs->trans("ShowPropal"),"propal"); @@ -556,47 +556,136 @@ function show_actions_done($conf,$langs,$db,$objsoc) print $facturestatic->getNomUrl(1,'compta'); } else print ' '; - print ''.$obj->label.''.$obj->label.''.$contactstatic->getNomUrl(1).' '.$contactstatic->getNomUrl(1).' '; + print ''; $userstatic->id=$obj->rowid; $userstatic->login=$obj->login; print $userstatic->getLoginUrl(1); print ''.$actionstatic->LibStatut($obj->percent,3).'
\n"; - print "
\n"; - } + print ''.$actionstatic->LibStatut($obj->percent,3).''; + + print "\n"; + $i++; + } + + $db->free($result); + } + else + { + dolibarr_print_error($db); + } + + print "\n"; + print "
\n"; + } +} + + +/** + * \brief Show footer of page for PDF generation + * \param pdf Object PDF + * \param outputlang Object lang for output + * \param paramfreetext Constant name of free text + * \param fromcompany Object company + * \param marge_basse + * \param marge_gauche + * \param page_hauteur + */ +function pdf_pagefoot(&$pdf,$outputlangs,$paramfreetext,$fromcompany,$marge_basse,$marge_gauche,$page_hauteur) +{ + global $conf; + + //$paramfreetext='FACTURE_FREE_TEXT'; + + // Line of free text + $ligne=(! empty($conf->global->$paramfreetext))?$conf->global->$paramfreetext:""; + + // First line of company infos + $ligne1=""; + if ($fromcompany->forme_juridique_code) + { + $ligne1.=($ligne1?" - ":"").getFormeJuridiqueLabel($fromcompany->forme_juridique_code); + } + if ($fromcompany->capital) + { + $ligne1.=($ligne1?" - ":"").$outputlangs->transnoentities("CapitalOf",$fromcompany->capital)." ".$outputlangs->transnoentities("Currency".$conf->monnaie); + } + // Prof Id + if ($fromcompany->profid1 && ($fromcompany->pays_code != 'FR' || ! $fromcompany->profid2)) + { + $ligne1.=($ligne1?" - ":"").$outputlangs->transcountrynoentities("ProfId1",$fromcompany->pays_code).": ".$fromcompany->profid1; + } + if ($fromcompany->profid2) + { + $ligne1.=($ligne1?" - ":"").$outputlangs->transcountrynoentities("ProfId2",$fromcompany->pays_code).": ".$fromcompany->profid2; + } + + // Second line of company infos + $ligne2=""; + if ($fromcompany->profid3) + { + $ligne2.=($ligne2?" - ":"").$outputlangs->transcountrynoentities("ProfId3",$fromcompany->pays_code).": ".$fromcompany->profid3; + } + if ($fromcompany->profid4) + { + $ligne2.=($ligne2?" - ":"").$outputlangs->transcountrynoentities("ProfId4",$fromcompany->pays_code).": ".$fromcompany->profid4; + } + if ($fromcompany->tva_intra != '') + { + $ligne2.=($ligne2?" - ":"").$outputlangs->transnoentities("VATIntraShort").": ".$fromcompany->tva_intra; + } + + $pdf->SetFont('Arial','',7); + $pdf->SetDrawColor(224,224,224); + + // On positionne le debut du bas de page selon nbre de lignes de ce bas de page + $posy=$marge_basse + 1 + ($ligne?6:0) + ($ligne1?3:0) + ($ligne2?3:0); + + if ($ligne) + { + $pdf->SetXY($marge_gauche,-$posy); + $pdf->MultiCell(190, 3, $ligne, 0, 'L', 0); + $posy-=9; // 6 of ligne + 3 of MultiCell + } + + $pdf->SetY(-$posy); + $pdf->line($marge_gauche, $page_hauteur-$posy, 200, $page_hauteur-$posy); + $posy--; + + if ($ligne1) + { + $pdf->SetXY($marge_gauche,-$posy); + $pdf->MultiCell(200, 2, $ligne1, 0, 'C', 0); + } + + if ($ligne2) + { + $posy-=3; + $pdf->SetXY($marge_gauche,-$posy); + $pdf->MultiCell(200, 2, $ligne2, 0, 'C', 0); + } + + $pdf->SetXY(-20,-$posy); + $pdf->MultiCell(11, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0); } ?> diff --git a/htdocs/livraison/mods/pdf/pdf_typhon.modules.php b/htdocs/livraison/mods/pdf/pdf_typhon.modules.php index a04c8451bf4..a7c665a2609 100644 --- a/htdocs/livraison/mods/pdf/pdf_typhon.modules.php +++ b/htdocs/livraison/mods/pdf/pdf_typhon.modules.php @@ -39,16 +39,20 @@ require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); class pdf_typhon extends ModelePDFDeliveryOrder { - - /** - \brief Constructeur - \param db Handler acc�s base de donn�e - */ + var $emetteur; // Objet societe qui emet + + /** + * \brief Constructor + * \param db Database handler + */ function pdf_typhon($db) { - global $conf,$langs; + global $conf,$langs,$mysoc; - $this->db = $db; + $langs->load("main"); + $langs->load("bills"); + + $this->db = $db; $this->name = "typhon"; $this->description = "Modele de bon de livraison complet (logo...)"; @@ -67,10 +71,11 @@ class pdf_typhon extends ModelePDFDeliveryOrder $this->option_modereg = 1; // Gere choix mode reglement FACTURE_CHQ_NUMBER, FACTURE_RIB_NUMBER $this->option_codeproduitservice = 1; // Affiche code produit-service if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise') - $this->franchise=1; + $this->franchise=1; - // Recupere code pays de l'emmetteur - 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 $this->tva=array(); @@ -271,7 +276,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder if ($nexY > 200 && $i < ($nblignes - 1)) { $this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY); - $this->_pagefoot($pdf); + $this->_pagefoot($pdf,$outputlangs); // Nouvelle page $pdf->AddPage(); @@ -300,7 +305,7 @@ class pdf_typhon extends ModelePDFDeliveryOrder /* * Pied de page */ - $this->_pagefoot($pdf); + $this->_pagefoot($pdf,$outputlangs); $pdf->AliasNbPages(); $pdf->Close(); @@ -518,76 +523,13 @@ class pdf_typhon extends ModelePDFDeliveryOrder } - /* + /** * \brief Affiche le pied de page * \param pdf objet PDF */ - function _pagefoot(&$pdf) + function _pagefoot(&$pdf,$outputlangs) { - global $langs, $conf; - $langs->load("main"); - $langs->load("bills"); - $langs->load("companies"); - - // Premiere ligne d'info r�glementaires - $ligne1=""; - if ($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE) - { - $ligne1.=($ligne1?" - ":"").getFormeJuridiqueLabel($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE); - } - if ($conf->global->MAIN_INFO_CAPITAL) - { - $ligne1.=($ligne1?" - ":"").$langs->transnoentities("CapitalOf",$conf->global->MAIN_INFO_CAPITAL)." ".$langs->transnoentities("Currency".$conf->monnaie); - } - if ($conf->global->MAIN_INFO_SIRET) - { - $ligne1.=($ligne1?" - ":"").$langs->transcountrynoentities("ProfId2",$this->emetteur->pays_code).": ".$conf->global->MAIN_INFO_SIRET; - } - if ($conf->global->MAIN_INFO_SIREN && (! $conf->global->MAIN_INFO_SIRET || $this->emetteur->pays_code != 'FR')) - { - $ligne1.=($ligne1?" - ":"").$langs->transcountrynoentities("ProfId1",$this->emetteur->pays_code).": ".$conf->global->MAIN_INFO_SIREN; - } - if ($conf->global->MAIN_INFO_APE) - { - $ligne1.=($ligne1?" - ":"").$langs->transcountrynoentities("ProfId3",$this->emetteur->pays_code).": ".MAIN_INFO_APE; - } - - // Deuxieme ligne d'info reglementaires - $ligne2=""; - if ($conf->global->MAIN_INFO_RCS) - { - $ligne2.=($ligne2?" - ":"").$langs->transcountrynoentities("ProfId4",$this->emetteur->pays_code).": ".$conf->global->MAIN_INFO_RCS; - } - if ($conf->global->MAIN_INFO_TVAINTRA != '') - { - $ligne2.=($ligne2?" - ":"").$langs->transnoentities("VATIntraShort").": ".$conf->global->MAIN_INFO_TVAINTRA; - } - - $pdf->SetFont('Arial','',8); - $pdf->SetDrawColor(224,224,224); - - // On positionne le debut du bas de page selon nbre de lignes de ce bas de page - $posy=$this->marge_basse + 1 + ($ligne1?3:0) + ($ligne2?3:0); - - $pdf->SetY(-$posy); - $pdf->line($this->marge_gauche, $this->page_hauteur-$posy, 200, $this->page_hauteur-$posy); - $posy--; - - if ($ligne1) - { - $pdf->SetXY($this->marge_gauche,-$posy); - $pdf->MultiCell(200, 2, $ligne1, 0, 'C', 0); - } - - if ($ligne2) - { - $posy-=3; - $pdf->SetXY($this->marge_gauche,-$posy); - $pdf->MultiCell(200, 2, $ligne2, 0, 'C', 0); - } - - $pdf->SetXY(-20,-$posy); - $pdf->MultiCell(10, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0); + return pdf_pagefoot($pdf,$outputlangs,'DELIVERY_FREE_TEXT',$this->emetteur,$this->marge_basse,$this->marge_gauche,$this->page_hauteur); } }