[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 3 * 4 * This program is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation; either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program; if not, write to the Free Software 16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 * or see http://www.gnu.org/ 18 * 19 * $Id: pdf_propale_azur.modules.php,v 1.37.2.2 2006/01/04 20:14:37 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/includes/modules/propale/pdf_propale_azur.modules.php,v $ 21 */ 22 23 /** 24 \file htdocs/includes/modules/propale/pdf_propale_azur.modules.php 25 \ingroup propale 26 \brief Fichier de la classe permettant de générer les propales au modèle Azur 27 \author Laurent Destailleur 28 \version $Revision: 1.37.2.2 $ 29 */ 30 31 require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php"); 32 require_once(DOL_DOCUMENT_ROOT."/product.class.php"); 33 34 35 /** 36 \class pdf_propale_azur 37 \brief Classe permettant de générer les propales au modèle Azur 38 */ 39 40 class pdf_propale_azur extends ModelePDFPropales 41 { 42 43 /** 44 \brief Constructeur 45 \param db Handler accès base de donnée 46 */ 47 function pdf_propale_azur($db) 48 { 49 global $conf,$langs; 50 51 $this->db = $db; 52 $this->name = "azur"; 53 $this->description = "Modèle de propositions commerciales complet (logo...)"; 54 55 // Dimension page pour format A4 56 $this->page_largeur = 210; 57 $this->page_hauteur = 297; 58 $this->format = array($this->page_largeur,$this->page_hauteur); 59 $this->marge_gauche=10; 60 $this->marge_droite=10; 61 $this->marge_haute=10; 62 $this->marge_basse=10; 63 64 $this->option_logo = 1; // Affiche logo FAC_PDF_LOGO 65 $this->option_tva = 1; // Gere option tva FACTURE_TVAOPTION 66 $this->option_modereg = 1; // Gere choix mode règlement FACTURE_CHQ_NUMBER, FACTURE_RIB_NUMBER 67 $this->option_codeproduitservice = 1; // Affiche code produit-service 68 $this->option_tvaintra = 1; // Affiche tva intra MAIN_INFO_TVAINTRA 69 $this->option_capital = 1; // Affiche capital MAIN_INFO_CAPITAL 70 if (defined("FACTURE_TVAOPTION") && FACTURE_TVAOPTION == 'franchise') 71 $this->franchise=1; 72 73 // Recupere code pays de l'emmetteur 74 $this->emetteur->code_pays=substr($langs->defaultlang,-2); // Par defaut, si on trouve pas 75 $sql = "SELECT code from ".MAIN_DB_PREFIX."c_pays"; 76 $sql .= " WHERE rowid = '".$conf->global->MAIN_INFO_SOCIETE_PAYS."'"; 77 $result=$this->db->query($sql); 78 if ($result) { 79 $obj = $this->db->fetch_object($result); 80 if ($obj->code) $this->emetteur->code_pays=$obj->code; 81 } 82 else { 83 dolibarr_print_error($this->db); 84 } 85 $this->db->free($result); 86 87 $this->tva=array(); 88 89 // Defini position des colonnes 90 $this->posxdesc=$this->marge_gauche+1; 91 $this->posxtva=121; 92 $this->posxup=132; 93 $this->posxqty=151; 94 $this->posxdiscount=162; 95 $this->postotalht=177; 96 97 $this->atleastoneratenotnull=0; 98 $this->atleastonediscount=0; 99 } 100 101 /** 102 \brief Renvoi dernière erreur 103 \return string Dernière erreur 104 */ 105 function pdferror() 106 { 107 return $this->error; 108 } 109 110 /** 111 \brief Fonction générant la propale sur le disque 112 \param id Id de la propale à générer 113 \return int 1=ok, 0=ko 114 \remarks Variables utilisées 115 \remarks MAIN_INFO_SOCIETE_NOM 116 \remarks MAIN_INFO_ADRESSE 117 \remarks MAIN_INFO_CP 118 \remarks MAIN_INFO_VILLE 119 \remarks MAIN_INFO_TEL 120 \remarks MAIN_INFO_FAX 121 \remarks MAIN_INFO_WEB 122 \remarks MAIN_INFO_SIRET 123 \remarks MAIN_INFO_SIREN 124 \remarks MAIN_INFO_RCS 125 \remarks MAIN_INFO_CAPITAL 126 \remarks MAIN_INFO_TVAINTRA 127 \remarks MAIN_INFO_LOGO 128 */ 129 function write_pdf_file($id) 130 { 131 global $user,$langs,$conf; 132 133 $langs->load("main"); 134 $langs->load("bills"); 135 $langs->load("products"); 136 $langs->load("propal"); 137 138 if ($conf->propal->dir_output) 139 { 140 $prop = new Propal($this->db,"",$id); 141 $ret=$prop->fetch($id); 142 $nblignes = sizeof($prop->lignes); 143 144 $propref = sanitize_string($prop->ref); 145 $dir = $conf->propal->dir_output . "/" . $propref; 146 $file = $dir . "/" . $propref . ".pdf"; 147 148 if (! file_exists($dir)) 149 { 150 if (create_exdir($dir) < 0) 151 { 152 $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); 153 return 0; 154 } 155 } 156 157 if (file_exists($dir)) 158 { 159 // Initialisation document vierge 160 $pdf=new FPDF('P','mm',$this->format); 161 $pdf->Open(); 162 $pdf->AddPage(); 163 164 $pdf->SetDrawColor(128,128,128); 165 166 $pdf->SetTitle($prop->ref); 167 $pdf->SetSubject($langs->trans("Bill")); 168 $pdf->SetCreator("Dolibarr ".DOL_VERSION); 169 $pdf->SetAuthor($user->fullname); 170 171 $pdf->SetMargins($this->marge_gauche, $this->marge_haute, $this->marge_droite); // Left, Top, Right 172 $pdf->SetAutoPageBreak(1,0); 173 174 // Positionne $this->atleastonediscount si on a au moins une remise 175 for ($i = 0 ; $i < $nblignes ; $i++) 176 { 177 if ($prop->lignes[$i]->remise_percent) 178 { 179 $this->atleastonediscount++; 180 } 181 } 182 183 $this->_pagehead($pdf, $prop); 184 185 $pagenb = 1; 186 $tab_top = 90; 187 $tab_top_newpage = 50; 188 $tab_height = 110; 189 190 $iniY = $tab_top + 8; 191 $curY = $tab_top + 8; 192 $nexY = $tab_top + 8; 193 194 // Boucle sur les lignes 195 for ($i = 0 ; $i < $nblignes ; $i++) 196 { 197 $curY = $nexY; 198 199 // Description de la ligne produit 200 $libelleproduitservice=$prop->lignes[$i]->libelle; 201 if ($prop->lignes[$i]->desc&&$prop->lignes[$i]->desc!=$prop->lignes[$i]->libelle) 202 { 203 if ($libelleproduitservice) $libelleproduitservice.="\n"; 204 $libelleproduitservice.=$prop->lignes[$i]->desc; 205 } 206 // Si ligne associée à un code produit 207 if ($prop->lignes[$i]->product_id) 208 { 209 $prodser = new Product($this->db); 210 211 $prodser->fetch($prop->lignes[$i]->product_id); 212 if ($prodser->ref) 213 { 214 $libelleproduitservice=$langs->trans("Product")." ".$prodser->ref." - ".$libelleproduitservice; 215 } 216 217 // Ajoute description du produit 218 if ($conf->global->PROP_ADD_PROD_DESC) 219 { 220 if ($prop->lignes[$i]->product_desc&&$prop->lignes[$i]->product_desc!=$fac->lignes[$i]->libelle&&$prop->lignes[$i]->product_desc!=$prop->lignes[$i]->desc) 221 { 222 if ($libelleproduitservice) $libelleproduitservice.="\n"; 223 $libelleproduitservice.=$prop->lignes[$i]->product_desc; 224 } 225 } 226 } 227 if ($prop->lignes[$i]->date_start && $prop->lignes[$i]->date_end) 228 { 229 // Affichage durée si il y en a une 230 $libelleproduitservice.="\n(".$langs->trans("From")." ".dolibarr_print_date($prop->lignes[$i]->date_start)." ".$langs->trans("to")." ".dolibarr_print_date($prop->lignes[$i]->date_end).")"; 231 } 232 233 $pdf->SetFont('Arial','', 9); // Dans boucle pour gérer multi-page 234 235 $pdf->SetXY ($this->posxdesc-1, $curY); 236 $pdf->MultiCell(108, 4, $libelleproduitservice, 0, 'J'); 237 238 $nexY = $pdf->GetY(); 239 240 // TVA 241 $pdf->SetXY ($this->posxtva, $curY); 242 $pdf->MultiCell(10, 4, ($prop->lignes[$i]->tva_tx < 0 ? '*':'').abs($prop->lignes[$i]->tva_tx), 0, 'R'); 243 244 // Prix unitaire HT avant remise 245 $pdf->SetXY ($this->posxup, $curY); 246 $pdf->MultiCell(18, 4, price($prop->lignes[$i]->subprice), 0, 'R', 0); 247 248 // Quantité 249 $pdf->SetXY ($this->posxqty, $curY); 250 $pdf->MultiCell(10, 4, $prop->lignes[$i]->qty, 0, 'R'); 251 252 // Remise sur ligne 253 $pdf->SetXY ($this->posxdiscount, $curY); 254 if ($prop->lignes[$i]->remise_percent) 255 { 256 $pdf->MultiCell(14, 4, $prop->lignes[$i]->remise_percent."%", 0, 'R'); 257 } 258 259 // Total HT ligne 260 $pdf->SetXY ($this->postotalht, $curY); 261 $total = price($prop->lignes[$i]->price * $prop->lignes[$i]->qty); 262 $pdf->MultiCell(23, 4, $total, 0, 'R', 0); 263 264 // Collecte des totaux par valeur de tva 265 // dans le tableau tva["taux"]=total_tva 266 $tvaligne=$prop->lignes[$i]->price * $prop->lignes[$i]->qty; 267 if ($prop->remise_percent) $tvaligne-=($tvaligne*$prop->remise_percent)/100; 268 $this->tva[ (string)$prop->lignes[$i]->tva_tx ] += $tvaligne; 269 270 $nexY+=2; // Passe espace entre les lignes 271 272 if ($nexY > 200 && $i < ($nblignes - 1)) 273 { 274 $this->_tableau($pdf, $tab_top, $tab_height + 20, $nexY); 275 $this->_pagefoot($pdf); 276 277 // Nouvelle page 278 $pdf->AddPage(); 279 $pagenb++; 280 $this->_pagehead($pdf, $prop, 0); 281 282 $nexY = $tab_top_newpage + 8; 283 $pdf->SetTextColor(0,0,0); 284 $pdf->SetFont('Arial','', 10); 285 } 286 287 } 288 // Affiche cadre tableau 289 if ($pagenb == 1) 290 { 291 $this->_tableau($pdf, $tab_top, $tab_height, $nexY); 292 $bottomlasttab=$tab_top + $tab_height + 1; 293 } 294 else 295 { 296 $this->_tableau($pdf, $tab_top_newpage, $tab_height, $nexY); 297 $bottomlasttab=$tab_top_newpage + $tab_height + 1; 298 } 299 300 $deja_regle = ""; 301 302 $posy=$this->_tableau_tot($pdf, $prop, $deja_regle, $bottomlasttab); 303 304 if ($deja_regle) { 305 $this->_tableau_versements($pdf, $fac, $posy); 306 } 307 308 /* 309 * Mode de règlement 310 */ 311 if ((! defined("FACTURE_CHQ_NUMBER") || ! FACTURE_CHQ_NUMBER) && (! defined("FACTURE_RIB_NUMBER") || ! FACTURE_RIB_NUMBER)) 312 { 313 $pdf->SetXY ($this->marge_gauche, 228); 314 $pdf->SetTextColor(200,0,0); 315 $pdf->SetFont('Arial','B',8); 316 $pdf->MultiCell(90, 3, $langs->trans("ErrorNoPaiementModeConfigured"),0,'L',0); 317 $pdf->MultiCell(90, 3, $langs->trans("ErrorCreateBankAccount"),0,'L',0); 318 $pdf->SetTextColor(0,0,0); 319 } 320 321 /* 322 * Propose mode règlement par CHQ 323 */ 324 /* 325 if (defined("FACTURE_CHQ_NUMBER")) 326 { 327 if (FACTURE_CHQ_NUMBER > 0) 328 { 329 $account = new Account($this->db); 330 $account->fetch(FACTURE_CHQ_NUMBER); 331 332 $pdf->SetXY ($this->marge_gauche, 227); 333 $pdf->SetFont('Arial','B',8); 334 $pdf->MultiCell(90, 3, "Règlement par chèque à l'ordre de ".$account->proprio." envoyé à:",0,'L',0); 335 $pdf->SetXY ($this->marge_gauche, 231); 336 $pdf->SetFont('Arial','',8); 337 $pdf->MultiCell(80, 3, $account->adresse_proprio, 0, 'L', 0); 338 } 339 } 340 */ 341 342 /* 343 * Propose mode règlement par RIB 344 */ 345 /* 346 if (defined("FACTURE_RIB_NUMBER")) 347 { 348 if (FACTURE_RIB_NUMBER > 0) 349 { 350 $account = new Account($this->db); 351 $account->fetch(FACTURE_RIB_NUMBER); 352 353 $this->marges['g']=$this->marge_gauche; 354 355 $cury=242; 356 $pdf->SetXY ($this->marges['g'], $cury); 357 $pdf->SetFont('Arial','B',8); 358 $pdf->MultiCell(90, 3, "Règlement par virement sur le compte bancaire suivant:", 0, 'L', 0); 359 $cury+=4; 360 $pdf->SetFont('Arial','B',6); 361 $pdf->line($this->marges['g']+1, $cury, $this->marges['g']+1, $cury+10 ); 362 $pdf->SetXY ($this->marges['g'], $cury); 363 $pdf->MultiCell(18, 3, "Code banque", 0, 'C', 0); 364 $pdf->line($this->marges['g']+18, $cury, $this->marges['g']+18, $cury+10 ); 365 $pdf->SetXY ($this->marges['g']+18, $cury); 366 $pdf->MultiCell(18, 3, "Code guichet", 0, 'C', 0); 367 $pdf->line($this->marges['g']+36, $cury, $this->marges['g']+36, $cury+10 ); 368 $pdf->SetXY ($this->marges['g']+36, $cury); 369 $pdf->MultiCell(24, 3, "Numéro compte", 0, 'C', 0); 370 $pdf->line($this->marges['g']+60, $cury, $this->marges['g']+60, $cury+10 ); 371 $pdf->SetXY ($this->marges['g']+60, $cury); 372 $pdf->MultiCell(13, 3, "Clé RIB", 0, 'C', 0); 373 $pdf->line($this->marges['g']+73, $cury, $this->marges['g']+73, $cury+10 ); 374 375 $pdf->SetFont('Arial','',8); 376 $pdf->SetXY ($this->marges['g'], $cury+5); 377 $pdf->MultiCell(18, 3, $account->code_banque, 0, 'C', 0); 378 $pdf->SetXY ($this->marges['g']+18, $cury+5); 379 $pdf->MultiCell(18, 3, $account->code_guichet, 0, 'C', 0); 380 $pdf->SetXY ($this->marges['g']+36, $cury+5); 381 $pdf->MultiCell(24, 3, $account->number, 0, 'C', 0); 382 $pdf->SetXY ($this->marges['g']+60, $cury+5); 383 $pdf->MultiCell(13, 3, $account->cle_rib, 0, 'C', 0); 384 385 $pdf->SetXY ($this->marges['g'], $cury+12); 386 $pdf->MultiCell(90, 3, "Domiciliation : " . $account->domiciliation, 0, 'L', 0); 387 $pdf->SetXY ($this->marges['g'], $cury+22); 388 $pdf->MultiCell(90, 3, "Prefix IBAN : " . $account->iban_prefix, 0, 'L', 0); 389 $pdf->SetXY ($this->marges['g'], $cury+25); 390 $pdf->MultiCell(90, 3, "BIC : " . $account->bic, 0, 'L', 0); 391 392 } 393 } 394 */ 395 396 /* 397 * Conditions de règlements 398 */ 399 /* Pour l'instant les conditions de règlement ne sont pas gérées sur les propales */ 400 /* 401 $pdf->SetFont('Arial','B',10); 402 $pdf->SetXY($this->marge_gauche, 217); 403 $titre = "Conditions de réglement:"; 404 $pdf->MultiCell(80, 5, $titre, 0, 'L'); 405 $pdf->SetFont('Arial','',10); 406 $pdf->SetXY(54, 217); 407 $pdf->MultiCell(80, 5, $prop->cond_reglement_facture,0,'L'); 408 */ 409 410 /* 411 * Pied de page 412 */ 413 $this->_pagefoot($pdf); 414 $pdf->AliasNbPages(); 415 416 $pdf->Close(); 417 418 $pdf->Output($file); 419 420 return 1; // Pas d'erreur 421 } 422 else 423 { 424 $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); 425 return 0; 426 } 427 } 428 else 429 { 430 $this->error=$langs->trans("ErrorConstantNotDefined","PROP_OUTPUTDIR"); 431 return 0; 432 } 433 $this->error=$langs->trans("ErrorUnknown"); 434 return 0; // Erreur par defaut 435 } 436 437 /* 438 * \brief Affiche le total à payer 439 * \param pdf Objet PDF 440 * \param prop Objet propale 441 * \param deja_regle Montant deja regle 442 * \return y Position pour suite 443 */ 444 function _tableau_tot(&$pdf, $prop, $deja_regle, $posy) 445 { 446 global $langs; 447 $langs->load("main"); 448 $langs->load("bills"); 449 450 $tab2_top = $posy; 451 $tab2_hl = 5; 452 $tab2_height = $tab2_hl * 4; 453 $pdf->SetFont('Arial','', 9); 454 455 // Affiche la mention TVA non applicable selon option 456 $pdf->SetXY ($this->marge_gauche, $tab2_top + 0); 457 if ($this->franchise==1) 458 { 459 $pdf->MultiCell(100, $tab2_hl, "* TVA non applicable art-293B du CGI", 0, 'L', 0); 460 } 461 462 // Tableau total 463 $lltot = 200; $col1x = 120; $col2x = 182; $largcol2 = $lltot - $col2x; 464 465 // Total HT 466 $pdf->SetFillColor(256,256,256); 467 $pdf->SetXY ($col1x, $tab2_top + 0); 468 $pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("TotalHT"), 0, 'L', 1); 469 470 $pdf->SetXY ($col2x, $tab2_top + 0); 471 $pdf->MultiCell($largcol2, $tab2_hl, price($prop->total_ht + $prop->remise), 0, 'R', 1); 472 473 // Remise globale 474 if ($prop->remise > 0) 475 { 476 $pdf->SetXY ($col1x, $tab2_top + $tab2_hl); 477 $pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("GlobalDiscount"), 0, 'L', 1); 478 479 $pdf->SetXY ($col2x, $tab2_top + $tab2_hl); 480 $pdf->MultiCell($largcol2, $tab2_hl, "-".$prop->remise_percent."%", 0, 'R', 1); 481 482 $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * 2); 483 $pdf->MultiCell($col2x-$col1x, $tab2_hl, "Total HT après remise", 0, 'L', 1); 484 485 $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * 2); 486 $pdf->MultiCell($largcol2, $tab2_hl, price($prop->total_ht), 0, 'R', 0); 487 488 $index = 2; 489 } 490 else 491 { 492 $index = 0; 493 } 494 495 // Affichage des totaux de TVA par taux (conformément à réglementation) 496 $pdf->SetFillColor(248,248,248); 497 foreach( $this->tva as $tvakey => $tvaval ) 498 { 499 if ($tvakey) // On affiche pas taux 0 500 { 501 $this->atleastoneratenotnull++; 502 503 $index++; 504 $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); 505 $tvacompl = ( (float)$tvakey < 0 ) ? " (".$langs->trans("NonPercuRecuperable").")" : '' ; 506 $pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("TotalVAT").' '.abs($tvakey).'%'.$tvacompl, 0, 'L', 1); 507 508 $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); 509 $pdf->MultiCell($largcol2, $tab2_hl, price($tvaval * abs((float)$tvakey) / 100 ), 0, 'R', 1); 510 } 511 } 512 if (! $this->atleastoneratenotnull) 513 { 514 $index++; 515 $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); 516 $pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("TotalVAT"), 0, 'L', 1); 517 518 $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); 519 $pdf->MultiCell($largcol2, $tab2_hl, price($prop->total_tva), 0, 'R', 1); 520 } 521 522 $useborder=0; 523 524 $index++; 525 $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); 526 $pdf->SetTextColor(0,0,60); 527 $pdf->SetFillColor(224,224,224); 528 $pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("TotalTTC"), $useborder, 'L', 1); 529 530 $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); 531 $pdf->MultiCell($largcol2, $tab2_hl, price($prop->total_ttc), $useborder, 'R', 1); 532 $pdf->SetFont('Arial','', 9); 533 $pdf->SetTextColor(0,0,0); 534 535 if ($deja_regle > 0) 536 { 537 $index++; 538 539 $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); 540 $pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("AlreadyPayed"), 0, 'L', 0); 541 542 $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); 543 $pdf->MultiCell($largcol2, $tab2_hl, price($deja_regle), 0, 'R', 0); 544 545 $index++; 546 $pdf->SetTextColor(0,0,60); 547 //$pdf->SetFont('Arial','B', 9); 548 $pdf->SetXY ($col1x, $tab2_top + $tab2_hl * $index); 549 $pdf->MultiCell($col2x-$col1x, $tab2_hl, $langs->trans("RemainderToPay"), $useborder, 'L', 1); 550 551 $pdf->SetXY ($col2x, $tab2_top + $tab2_hl * $index); 552 $pdf->MultiCell($largcol2, $tab2_hl, price($prop->total_ttc - $deja_regle), $useborder, 'R', 1); 553 $pdf->SetFont('Arial','', 9); 554 $pdf->SetTextColor(0,0,0); 555 } 556 557 $index++; 558 return ($tab2_top + ($tab2_hl * $index)); 559 } 560 561 /* 562 * \brief Affiche la grille des lignes de propales 563 * \param pdf objet PDF 564 */ 565 function _tableau(&$pdf, $tab_top, $tab_height, $nexY) 566 { 567 global $langs,$conf; 568 $langs->load("main"); 569 $langs->load("bills"); 570 571 // Montants exprimés en (en tab_top - 1) 572 $pdf->SetTextColor(0,0,0); 573 $pdf->SetFont('Arial','',8); 574 $titre = $langs->trans("AmountInCurrency",$langs->trans("Currency".$conf->monnaie)); 575 $pdf->Text($this->page_largeur - $this->marge_droite - $pdf->GetStringWidth($titre), $tab_top-1, $titre); 576 577 $pdf->SetDrawColor(128,128,128); 578 579 // Rect prend une longueur en 3eme param 580 $pdf->Rect($this->marge_gauche, $tab_top, $this->page_largeur-$this->marge_gauche-$this->marge_droite, $tab_height); 581 // line prend une position y en 3eme param 582 $pdf->line($this->marge_gauche, $tab_top+6, $this->page_largeur-$this->marge_droite, $tab_top+6); 583 584 $pdf->SetFont('Arial','',10); 585 586 $pdf->SetXY ($this->posxdesc-1, $tab_top+2); 587 $pdf->MultiCell(108,2, $langs->trans("Designation"),'','L'); 588 589 $pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height); 590 $pdf->SetXY ($this->posxtva-1, $tab_top+2); 591 $pdf->MultiCell(12,2, $langs->trans("VAT"),'','C'); 592 593 $pdf->line($this->posxup-1, $tab_top, $this->posxup-1, $tab_top + $tab_height); 594 $pdf->SetXY ($this->posxup-1, $tab_top+2); 595 $pdf->MultiCell(18,2, $langs->trans("PriceUHT"),'','C'); 596 597 $pdf->line($this->posxqty-1, $tab_top, $this->posxqty-1, $tab_top + $tab_height); 598 $pdf->SetXY ($this->posxqty-1, $tab_top+2); 599 $pdf->MultiCell(11,2, $langs->trans("Qty"),'','C'); 600 601 $pdf->line($this->posxdiscount-1, $tab_top, $this->posxdiscount-1, $tab_top + $tab_height); 602 if ($this->atleastonediscount) 603 { 604 $pdf->SetXY ($this->posxdiscount-1, $tab_top+2); 605 $pdf->MultiCell(16,2, $langs->trans("Discount"),'','C'); 606 } 607 608 if ($this->atleastonediscount) 609 { 610 $pdf->line($this->postotalht, $tab_top, $this->postotalht, $tab_top + $tab_height); 611 } 612 $pdf->SetXY ($this->postotalht-1, $tab_top+2); 613 $pdf->MultiCell(23,2, $langs->trans("TotalHT"),'','C'); 614 615 } 616 617 /* 618 * \brief Affiche en-tête propale 619 * \param pdf objet PDF 620 * \param fac objet propale 621 * \param showadress 0=non, 1=oui 622 */ 623 function _pagehead(&$pdf, $prop, $showadress=1) 624 { 625 global $langs,$conf,$mysoc; 626 627 $langs->load("main"); 628 $langs->load("bills"); 629 $langs->load("propal"); 630 $langs->load("companies"); 631 632 $pdf->SetTextColor(0,0,60); 633 $pdf->SetFont('Arial','B',13); 634 635 $posy=$this->marge_haute; 636 637 $pdf->SetXY($this->marge_gauche,$posy); 638 639 // Logo 640 $logo=$mysoc->logo; 641 if (defined("FAC_PDF_LOGO") && FAC_PDF_LOGO) $logo=DOL_DATA_ROOT.FAC_PDF_LOGO; 642 if ($logo) 643 { 644 if (is_readable($logo)) 645 { 646 $pdf->Image($logo, $this->marge_gauche, $posy, 0, 24); 647 } 648 else 649 { 650 $pdf->SetTextColor(200,0,0); 651 $pdf->SetFont('Arial','B',8); 652 $pdf->MultiCell(100, 3, $langs->trans("ErrorLogoFileNotFound",$logo), 0, 'L'); 653 $pdf->MultiCell(100, 3, $langs->trans("ErrorGoToModuleSetup"), 0, 'L'); 654 } 655 } 656 else if (defined("FAC_PDF_INTITULE")) 657 { 658 $pdf->MultiCell(100, 4, FAC_PDF_INTITULE, 0, 'L'); 659 } 660 661 $pdf->SetFont('Arial','B',13); 662 $pdf->SetXY(100,$posy); 663 $pdf->SetTextColor(0,0,60); 664 $pdf->MultiCell(100, 4, $langs->trans("Proposal")." ".$prop->ref, '' , 'R'); 665 $pdf->SetFont('Arial','',12); 666 667 $posy+=6; 668 $pdf->SetXY(100,$posy); 669 $pdf->SetTextColor(0,0,60); 670 $pdf->MultiCell(100, 4, $langs->trans("Date")." : " . dolibarr_print_date($prop->date,"%d %b %Y"), '', 'R'); 671 672 if ($showadress) 673 { 674 // Emetteur 675 $posy=42; 676 $hautcadre=40; 677 $pdf->SetTextColor(0,0,0); 678 $pdf->SetFont('Arial','',8); 679 $pdf->SetXY($this->marge_gauche,$posy-5); 680 $pdf->MultiCell(66,5, $langs->trans("BillFrom").":"); 681 682 683 $pdf->SetXY($this->marge_gauche,$posy); 684 $pdf->SetFillColor(230,230,230); 685 $pdf->MultiCell(82, $hautcadre, "", 0, 'R', 1); 686 687 688 $pdf->SetXY($this->marge_gauche+2,$posy+3); 689 690 // Nom emetteur 691 $pdf->SetTextColor(0,0,60); 692 $pdf->SetFont('Arial','B',11); 693 if (defined("FAC_PDF_SOCIETE_NOM") && FAC_PDF_SOCIETE_NOM) $pdf->MultiCell(80, 4, FAC_PDF_SOCIETE_NOM, 0, 'L'); 694 else $pdf->MultiCell(80, 4, $mysoc->nom, 0, 'L'); 695 696 // Caractéristiques emetteur 697 $carac_emetteur = ''; 698 if (defined("FAC_PDF_ADRESSE") && FAC_PDF_ADRESSE) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).FAC_PDF_ADRESSE; 699 else { 700 $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$mysoc->adresse; 701 $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$mysoc->cp.' '.$mysoc->ville; 702 } 703 $carac_emetteur .= "\n"; 704 // Tel 705 if (defined("FAC_PDF_TEL") && FAC_PDF_TEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Phone").": ".FAC_PDF_TEL; 706 elseif ($mysoc->tel) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Phone").": ".$mysoc->tel; 707 // Fax 708 if (defined("FAC_PDF_FAX") && FAC_PDF_FAX) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Fax").": ".FAC_PDF_FAX; 709 elseif ($mysoc->fax) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Fax").": ".$mysoc->fax; 710 // EMail 711 if (defined("FAC_PDF_MEL") && FAC_PDF_MEL) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Email").": ".FAC_PDF_MEL; 712 elseif ($mysoc->email) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Email").": ".$mysoc->email; 713 // Web 714 if (defined("FAC_PDF_WWW") && FAC_PDF_WWW) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Web").": ".FAC_PDF_WWW; 715 elseif ($mysoc->url) $carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Web").": ".$mysoc->url; 716 717 $pdf->SetFont('Arial','',9); 718 $pdf->SetXY($this->marge_gauche+2,$posy+8); 719 $pdf->MultiCell(80,4, $carac_emetteur); 720 721 // Client destinataire 722 $posy=42; 723 $pdf->SetTextColor(0,0,0); 724 $pdf->SetFont('Arial','',8); 725 $pdf->SetXY(102,$posy-5); 726 $pdf->MultiCell(80,5, $langs->trans("BillTo").":"); 727 $prop->fetch_client(); 728 729 // Cadre client destinataire 730 $pdf->rect(100, $posy, 100, $hautcadre); 731 732 // Nom client 733 $pdf->SetXY(102,$posy+3); 734 $pdf->SetFont('Arial','B',11); 735 $pdf->MultiCell(106,4, $prop->client->nom, 0, 'L'); 736 737 // Caractéristiques client 738 $carac_client=$prop->client->adresse; 739 $carac_client.="\n".$prop->client->cp . " " . $prop->client->ville."\n"; 740 if ($prop->client->tva_intra) $carac_client.="\n".$langs->trans("VATIntraShort").': '.$prop->client->tva_intra; 741 $pdf->SetFont('Arial','',9); 742 $pdf->SetXY(102,$posy+8); 743 $pdf->MultiCell(86,4, $carac_client); 744 } 745 746 } 747 748 /* 749 * \brief Affiche le pied de page 750 * \param pdf objet PDF 751 */ 752 function _pagefoot(&$pdf) 753 { 754 global $langs, $conf; 755 $langs->load("main"); 756 $langs->load("bills"); 757 $langs->load("companies"); 758 759 $html=new Form($this->db); 760 761 // Premiere ligne d'info réglementaires 762 $ligne1=""; 763 if ($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE) 764 { 765 $ligne1.=($ligne1?" - ":"").$html->forme_juridique_name($conf->global->MAIN_INFO_SOCIETE_FORME_JURIDIQUE); 766 } 767 if ($conf->global->MAIN_INFO_CAPITAL) 768 { 769 $ligne1.=($ligne1?" - ":"").$langs->trans("CapitalOf",$conf->global->MAIN_INFO_CAPITAL)." ".$langs->trans("Currency".$conf->monnaie); 770 } 771 if ($conf->global->MAIN_INFO_SIRET) 772 { 773 $ligne1.=($ligne1?" - ":"").$langs->transcountry("ProfId2",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_SIRET; 774 } 775 if ($conf->global->MAIN_INFO_SIREN && (! $conf->global->MAIN_INFO_SIRET || $this->emetteur->code_pays != 'FR')) 776 { 777 $ligne1.=($ligne1?" - ":"").$langs->transcountry("ProfId1",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_SIREN; 778 } 779 if ($conf->global->MAIN_INFO_APE) 780 { 781 $ligne1.=($ligne1?" - ":"").$langs->transcountry("ProfId3",$this->emetteur->code_pays).": ".MAIN_INFO_APE; 782 } 783 784 // Deuxieme ligne d'info réglementaires 785 $ligne2=""; 786 if ($conf->global->MAIN_INFO_RCS) 787 { 788 $ligne2.=($ligne2?" - ":"").$langs->transcountry("ProfId4",$this->emetteur->code_pays).": ".$conf->global->MAIN_INFO_RCS; 789 } 790 if ($conf->global->MAIN_INFO_TVAINTRA != '') 791 { 792 $ligne2.=($ligne2?" - ":"").$langs->trans("VATIntraShort").": ".$conf->global->MAIN_INFO_TVAINTRA; 793 } 794 795 $pdf->SetFont('Arial','',8); 796 $pdf->SetDrawColor(224,224,224); 797 798 // On positionne le debut du bas de page selon nbre de lignes de ce bas de page 799 $posy=$this->marge_basse + 1 + ($ligne1?3:0) + ($ligne2?3:0); 800 801 $pdf->SetY(-$posy); 802 $pdf->line($this->marge_gauche, $this->page_hauteur-$posy, 200, $this->page_hauteur-$posy); 803 $posy--; 804 805 if ($ligne1) 806 { 807 $pdf->SetXY($this->marge_gauche,-$posy); 808 $pdf->MultiCell(200, 2, $ligne1, 0, 'C', 0); 809 } 810 811 if ($ligne2) 812 { 813 $posy-=3; 814 $pdf->SetXY($this->marge_gauche,-$posy); 815 $pdf->MultiCell(200, 2, $ligne2, 0, 'C', 0); 816 } 817 818 $pdf->SetXY(-20,-$posy); 819 $pdf->MultiCell(10, 2, $pdf->PageNo().'/{nb}', 0, 'R', 0); 820 } 821 822 } 823 824 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 12:29:37 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |