[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2003-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 4 * 5 * This program is free software; you can redistribute it and/or modify 6 * it under the terms of the GNU General Public License as published by 7 * the Free Software Foundation; either version 2 of the License, or 8 * (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 18 * or see http://www.gnu.org/ 19 * 20 * $Id: pdf_bernique.modules.php,v 1.23 2005/11/11 20:11:58 eldy Exp $ 21 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/includes/modules/facture/pdf_bernique.modules.php,v $ 22 */ 23 24 /** 25 \file htdocs/includes/modules/facture/pdf_bernique.modules.php 26 \ingroup facture 27 \brief Fichier de la classe permettant de générer les factures au modèle Bernique 28 \author Laurent Destailleur 29 \version $Revision: 1.23 $ 30 */ 31 32 require_once (DOL_DOCUMENT_ROOT ."/includes/modules/facture/modules_facture.php"); 33 34 35 /** 36 \class pdf_bernique 37 \brief Classe permettant de générer les factures au modèle Bernique 38 */ 39 40 class pdf_bernique extends ModelePDFFactures { 41 42 function pdf_bernique($db=0) 43 { 44 $this->db = $db; 45 $this->description = "Modèle pour les factures avec plusieurs taux de tva, inclus aussi le numéro de TVA Intracommunautaire"; 46 47 // Dimension page pour format A4 48 $this->page_largeur = 210; 49 $this->page_hauteur = 297; 50 $this->format = array($this->page_largeur,$this->page_hauteur); 51 } 52 53 function write_pdf_file($facid) 54 { 55 global $user,$langs,$conf; 56 57 $langs->load("main"); 58 $langs->load("bills"); 59 $langs->load("products"); 60 61 $fac = new Facture($this->db,"",$facid); 62 $fac->fetch($facid); 63 if ($conf->facture->dir_output) 64 { 65 66 $facref = sanitize_string($fac->ref); 67 $dir = $conf->facture->dir_output . "/" . $facref . "/" ; 68 $file = $dir . $facref . ".pdf"; 69 70 if (! file_exists($dir)) 71 { 72 if (create_exdir($dir) < 0) 73 { 74 $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); 75 return 0; 76 } 77 } 78 79 if (file_exists($dir)) 80 { 81 // Initialisation facture vierge 82 $pdf=new FPDF('P','mm','A4'); 83 $pdf->Open(); 84 $pdf->AddPage(); 85 86 $this->_pagehead($pdf, $fac); 87 88 $pdf->SetTitle($fac->ref); 89 $pdf->SetSubject($langs->trans("Bill")); 90 $pdf->SetCreator("Dolibarr ".DOL_VERSION); 91 $pdf->SetAuthor($user->fullname); 92 93 $tab_top = 100; 94 $tab_height = 110; 95 96 /* 97 * 98 */ 99 100 $pdf->SetFillColor(220,220,220); 101 102 $pdf->SetFont('Arial','', 9); 103 104 $pdf->SetXY (10, $tab_top + 10 ); 105 106 $iniY = $pdf->GetY(); 107 $curY = $pdf->GetY(); 108 $nexY = $pdf->GetY(); 109 $nblignes = sizeof($fac->lignes); 110 111 for ($i = 0 ; $i < $nblignes ; $i++) 112 { 113 $curY = $nexY; 114 115 $pdf->SetXY (11, $curY ); 116 $pdf->MultiCell(118, 5, $fac->lignes[$i]->desc, 0, 'J'); 117 118 $nexY = $pdf->GetY(); 119 120 $pdf->SetXY (133, $curY); 121 $pdf->MultiCell(10, 5, $fac->lignes[$i]->tva_taux, 0, 'C'); 122 123 $pdf->SetXY (145, $curY); 124 $pdf->MultiCell(10, 5, $fac->lignes[$i]->qty, 0, 'C'); 125 126 $pdf->SetXY (156, $curY); 127 $pdf->MultiCell(18, 5, price($fac->lignes[$i]->price), 0, 'R', 0); 128 129 $pdf->SetXY (174, $curY); 130 $total = price($fac->lignes[$i]->price * $fac->lignes[$i]->qty); 131 $pdf->MultiCell(26, 5, $total, 0, 'R', 0); 132 133 if ($nexY > 200 && $i < $nblignes - 1) 134 { 135 $this->_tableau($pdf, $tab_top, $tab_height, $nexY); 136 $pdf->AddPage(); 137 $nexY = $iniY; 138 $this->_pagehead($pdf, $fac); 139 $pdf->SetTextColor(0,0,0); 140 $pdf->SetFont('Arial','', 10); 141 } 142 143 } 144 $this->_tableau($pdf, $tab_top, $tab_height, $nexY); 145 146 $this->_tableau_tot($pdf, $fac, $tab_top, $tab_height); 147 148 $this->_tableau_compl($pdf, $fac); 149 150 /* 151 * 152 */ 153 if (defined("FACTURE_RIB_NUMBER")) 154 { 155 if (FACTURE_RIB_NUMBER > 0) 156 { 157 $account = new Account($this->db); 158 $account->fetch(FACTURE_RIB_NUMBER); 159 160 $pdf->SetXY (10, 49); 161 $pdf->SetFont('Arial','U',8); 162 $pdf->MultiCell(40, 4, "Coordonnées bancaires", 0, 'L', 0); 163 $pdf->SetFont('Arial','',8); 164 $pdf->MultiCell(40, 4, "Code banque : " . $account->code_banque, 0, 'L', 0); 165 $pdf->MultiCell(40, 4, "Code guichet : " . $account->code_guichet, 0, 'L', 0); 166 $pdf->MultiCell(50, 4, "Numéro compte : " . $account->number, 0, 'L', 0); 167 $pdf->MultiCell(40, 4, "Clé RIB : " . $account->cle_rib, 0, 'L', 0); 168 $pdf->MultiCell(40, 4, "Domiciliation : " . $account->domiciliation, 0, 'L', 0); 169 $pdf->MultiCell(40, 4, "Prefix IBAN : " . $account->iban_prefix, 0, 'L', 0); 170 $pdf->MultiCell(40, 4, "BIC : " . $account->bic, 0, 'L', 0); 171 } 172 } 173 174 /* 175 * 176 * 177 */ 178 179 $pdf->SetFont('Arial','',9); 180 $pdf->SetXY(10, 260); 181 $pdf->MultiCell(190, 5, "Numéro de TVA intracommunautaire : ".MAIN_INFO_TVAINTRA, 0, 'J'); 182 $pdf->MultiCell(190, 5, "Accepte le réglement des sommes dues par chèques libellés à mon nom en ma qualité de Membre d'une Association de Gestion agréée par l'Administration Fiscale.", 0, 'J'); 183 184 $pdf->Close(); 185 186 $pdf->Output($file); 187 188 return 1; 189 } 190 else 191 { 192 $this->error="Erreur: Le répertoire '$dir' n'existe pas et Dolibarr n'a pu le créer."; 193 return 0; 194 } 195 } 196 else 197 { 198 $this->error="Erreur: FAC_OUTPUTDIR non défini !"; 199 return 0; 200 } 201 } 202 /* 203 * 204 * 205 * 206 */ 207 function _tableau_compl(&$pdf, $fac) 208 { 209 $tab3_top = 240; 210 $tab3_height = 18; 211 $tab3_width = 60; 212 213 $pdf->Rect(10, $tab3_top, $tab3_width, $tab3_height); 214 215 $pdf->line(10, $tab3_top + 6, $tab3_width+10, $tab3_top + 6 ); 216 $pdf->line(10, $tab3_top + 12, $tab3_width+10, $tab3_top + 12 ); 217 218 $pdf->line(30, $tab3_top, 30, $tab3_top + $tab3_height ); 219 220 $pdf->SetFont('Arial','',8); 221 $pdf->SetXY (10, $tab3_top - 6); 222 $pdf->MultiCell(60, 6, "Informations complémentaires", 0, 'L', 0); 223 $pdf->SetXY (10, $tab3_top ); 224 $pdf->MultiCell(20, 6, "Réglé le", 0, 'L', 0); 225 $pdf->SetXY (10, $tab3_top + 6); 226 $pdf->MultiCell(20, 6, "Chèque N°", 0, 'L', 0); 227 $pdf->SetXY (10, $tab3_top + 12); 228 $pdf->MultiCell(20, 6, "Banque", 0, 'L', 0); 229 230 $pdf->SetFont('Arial','U',12); 231 $titre = "Conditions de réglement : ".$fac->cond_reglement_facture; 232 $pdf->SetXY(200 - $pdf->GetStringWidth($titre), $tab3_top + 10); 233 $pdf->MultiCell(120, 5, $titre, 0, 'J'); 234 } 235 236 function _tableau_tot(&$pdf, $fac, $top, $height) 237 { 238 global $langs; 239 $langs->load("main"); 240 $langs->load("bills"); 241 242 243 $tab2_top = $top + $height; 244 $tab2_hl = 5; 245 $tab2_height = $tab2_hl * 4; 246 $pdf->SetFont('Arial','', 9); 247 248 $tvas = $fac->getSumTva(); 249 $i = 0; 250 251 $tab4_top = $tab2_top + 2 + ($tab2_hl * 2); 252 253 foreach ($tvas as $key => $value) 254 { 255 $pdf->SetXY (10, $tab4_top + ( $i * $tab2_hl)); 256 $pdf->MultiCell(25, $tab2_hl, "TVA à ". $key."%", 0, 'L', 0); 257 $pdf->SetXY (35, $tab4_top + ( $i * $tab2_hl)); 258 $pdf->MultiCell(20, $tab2_hl, price($tvas[$key]), 0, 'R', 0); 259 $i++; 260 $pdf->line(10, $tab4_top + ($tab2_hl * $i), 55, $tab4_top + ($tab2_hl * $i) ); 261 } 262 $pdf->line(10, $tab4_top, 55, $tab4_top ); 263 $pdf->line(10, $tab4_top, 10, $tab4_top + ($tab2_hl * $i)); 264 $pdf->line(35, $tab4_top, 35, $tab4_top + ($tab2_hl * $i)); 265 $pdf->line(55, $tab4_top, 55, $tab4_top + ($tab2_hl * $i)); 266 267 268 $pdf->Rect(10, $tab2_top, 190, $tab2_hl * 2); 269 $pdf->line(10, $tab2_top + $tab2_hl, 200, $tab2_top + $tab2_hl); 270 271 272 $pdf->SetXY (132, $tab2_top + 0); 273 $pdf->MultiCell(42, $tab2_hl, $langs->trans("TotalHT"), 0, 'R', 0); 274 275 $pdf->SetXY (11, $tab2_top + $tab2_hl); 276 $pdf->MultiCell(42, $tab2_hl, $langs->trans("Discount")." ". $fac->remise_percent . " %", 0, 'L', 0); 277 278 $pdf->SetXY (132, $tab2_top + $tab2_hl * 2); 279 $pdf->MultiCell(42, $tab2_hl, "Total HT aprés remise", 0, 'R', 0); 280 281 $pdf->SetXY (132, $tab2_top + $tab2_hl * 3); 282 $pdf->MultiCell(42, $tab2_hl, $langs->trans("TotalVAT"), 0, 'R', 0); 283 284 $pdf->SetXY (132, $tab2_top + $tab2_hl * 4); 285 $pdf->MultiCell(42, $tab2_hl, $langs->trans("TotalTTC"), 0, 'R', 1); 286 287 $pdf->SetXY (174, $tab2_top + 0); 288 $pdf->MultiCell(26, $tab2_hl, price($fac->total_ht + $fac->remise), 0, 'R', 0); 289 290 $pdf->SetXY (174, $tab2_top + $tab2_hl); 291 $pdf->MultiCell(26, $tab2_hl, price($fac->remise), 0, 'R', 0); 292 293 $pdf->SetXY (174, $tab2_top + $tab2_hl * 2); 294 $pdf->MultiCell(26, $tab2_hl, price($fac->total_ht), 0, 'R', 0); 295 296 $pdf->SetXY (174, $tab2_top + $tab2_hl * 3); 297 $pdf->MultiCell(26, $tab2_hl, price($fac->total_tva), 0, 'R', 0); 298 299 $pdf->SetXY (174, $tab2_top + $tab2_hl * 4); 300 $pdf->MultiCell(26, $tab2_hl, price($fac->total_ttc), 0, 'R', 1); 301 } 302 /* 303 * 304 */ 305 function _tableau(&$pdf, $tab_top, $tab_height, $nexY) 306 { 307 global $langs; 308 $langs->load("main"); 309 $langs->load("bills"); 310 311 $pdf->SetFont('Arial','',10); 312 313 $pdf->Text(11,$tab_top + 5,$langs->trans("Designation")); 314 315 $pdf->line(132, $tab_top, 132, $tab_top + $tab_height); 316 $pdf->Text(134,$tab_top + 5,$langs->trans("VAT")); 317 318 $pdf->line(144, $tab_top, 144, $tab_top + $tab_height); 319 $pdf->Text(147,$tab_top + 5,$langs->trans("Qty")); 320 321 $pdf->line(156, $tab_top, 156, $tab_top + $tab_height); 322 $pdf->Text(160,$tab_top + 5,$langs->trans("PriceU")); 323 324 $pdf->line(174, $tab_top, 174, $tab_top + $tab_height); 325 $pdf->Text(187,$tab_top + 5,$langs->trans("Total")); 326 327 $pdf->Rect(10, $tab_top, 190, $tab_height); 328 $pdf->line(10, $tab_top + 10, 200, $tab_top + 10 ); 329 } 330 /* 331 * 332 * 333 * 334 * 335 */ 336 function _pagehead(&$pdf, $fac) 337 { 338 global $langs,$conf; 339 $langs->load("main"); 340 $langs->load("bills"); 341 342 $pdf->SetXY(10,5); 343 if (defined("FAC_PDF_INTITULE")) 344 { 345 $pdf->SetTextColor(0,0,200); 346 $pdf->SetFont('Arial','B',14); 347 $pdf->MultiCell(60, 8, FAC_PDF_INTITULE, 0, 'L'); 348 } 349 350 $pdf->SetTextColor(70,70,170); 351 if (defined("FAC_PDF_ADRESSE")) 352 { 353 $pdf->SetFont('Arial','',12); 354 $pdf->MultiCell(40, 5, FAC_PDF_ADRESSE); 355 } 356 if (defined("FAC_PDF_TEL")) 357 { 358 $pdf->SetFont('Arial','',10); 359 $pdf->MultiCell(40, 5, "Tél : ".FAC_PDF_TEL); 360 } 361 if (defined("MAIN_INFO_SIREN")) 362 { 363 $pdf->SetFont('Arial','',10); 364 $pdf->MultiCell(40, 5, "SIREN : ".MAIN_INFO_SIREN); 365 } 366 367 if (defined("FAC_PDF_INTITULE2")) 368 { 369 $pdf->SetXY(100,5); 370 $pdf->SetFont('Arial','B',14); 371 $pdf->SetTextColor(0,0,200); 372 $pdf->MultiCell(100, 10, FAC_PDF_INTITULE2, '' , 'R'); 373 } 374 /* 375 * Adresse Client 376 */ 377 $pdf->SetTextColor(0,0,0); 378 $pdf->SetFont('Arial','B',12); 379 $fac->fetch_client(); 380 $pdf->SetXY(102,42); 381 $pdf->MultiCell(66,5, $fac->client->nom); 382 $pdf->SetFont('Arial','B',11); 383 $pdf->SetXY(102,$pdf->GetY()); 384 $pdf->MultiCell(66,5, $fac->client->adresse . "\n" . $fac->client->cp . " " . $fac->client->ville); 385 $pdf->rect(100, 40, 100, 40); 386 387 388 $pdf->SetTextColor(200,0,0); 389 $pdf->SetFont('Arial','B',14); 390 $pdf->Text(11, 88, "Date : " . strftime("%d %b %Y", $fac->date)); 391 $pdf->Text(11, 94, "Facture : ".$fac->ref); 392 393 /* 394 */ 395 $pdf->SetTextColor(0,0,0); 396 $pdf->SetFont('Arial','',10); 397 $titre = $langs->trans("AmountInCurrency",$langs->trans("Currency".$conf->monnaie)); 398 $pdf->Text(200 - $pdf->GetStringWidth($titre), 98, $titre); 399 /* 400 */ 401 402 } 403 } 404 405 ?>
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 |
![]() |