[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2003 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_propale_orange.modules.php,v 1.2 2005/12/18 13:26:00 hregis Exp $ 21 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/includes/modules/propale/pdf_propale_orange.modules.php,v $ 22 */ 23 24 /** \file htdocs/includes/modules/propale/pdf_propale_Orange.modules.php 25 \ingroup propale 26 \brief Fichier de la classe permettant de générer les propales au modèle Orange 27 \version $Revision: 1.2 $ 28 */ 29 30 require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php"); 31 32 33 /** \class pdf_propale_Orange 34 \brief Classe permettant de générer les propales au modèle orange 35 */ 36 37 class pdf_propale_orange extends ModelePDFPropales 38 { 39 40 /** \brief Constructeur 41 \param db handler accès base de donnée 42 */ 43 function pdf_propale_orange($db=0) 44 { 45 $this->db = $db; 46 $this->name = "orange"; 47 $this->description = "Modèle de proposition Orange ancien Adytek"; 48 49 // Dimension page pour format A4 50 $this->page_largeur = 210; 51 $this->page_hauteur = 297; 52 $this->format = array($this->page_largeur,$this->page_hauteur); 53 54 $this->error = ""; 55 } 56 57 58 /** \brief Renvoi dernière erreur 59 \return string Dernière erreur 60 */ 61 function pdferror() 62 { 63 return $this->error; 64 } 65 66 67 /** 68 \brief Fonction générant la propale sur le disque 69 \param id id de la propale à générer 70 \return int 1=ok, 0=ko 71 */ 72 function write_pdf_file($id) 73 { 74 global $user,$conf,$langs; 75 76 $propale = new Propal($this->db,"",$id); 77 if ($propale->fetch($id)) 78 { 79 80 if ($conf->propal->dir_output) 81 { 82 $propref = sanitize_string($propale->ref); 83 $dir = $conf->propal->dir_output . "/" . $propref ; 84 85 if (! file_exists($dir)) 86 { 87 if (create_exdir($dir) < 0) 88 { 89 $this->error=$langs->trans("ErrorCanNotCreateDir",$dir); 90 return 0; 91 } 92 } 93 } 94 else 95 { 96 $this->error=$langs->trans("ErrorConstantNotDefined","PROPALE_OUTPUTDIR"); 97 return 0; 98 } 99 100 $propref = sanitize_string($propale->ref); 101 $file = $dir . "/" . $propref . ".pdf"; 102 103 if (file_exists($dir)) 104 { 105 106 $pdf=new FPDF('P','mm',$this->format); 107 $pdf->Open(); 108 109 $pdf->SetTitle($fac->ref); 110 $pdf->SetSubject("Proposition commerciale"); 111 $pdf->SetCreator("Orange Dolibarr ".DOL_VERSION); 112 $pdf->SetAuthor($user->fullname); 113 114 115 $pdf->AddPage(); 116 $pdf->SetMargins(10, 10, 10); 117 $pdf->SetAutoPageBreak(1,0); 118 119 $this->_pagehead($pdf, $propale); 120 121 /* 122 */ 123 $tab_top = 100; 124 $tab_height = 150; 125 /* 126 * 127 */ 128 129 $pdf->SetFillColor(242,239,119); 130 131 $pdf->SetTextColor(0,0,0); 132 $pdf->SetFont('Arial','', 10); 133 134 $pdf->SetXY (10, $tab_top + 10 ); 135 136 $iniY = $pdf->GetY(); 137 $curY = $pdf->GetY(); 138 $nexY = $pdf->GetY(); 139 $nblignes = sizeof($propale->lignes); 140 141 for ($i = 0 ; $i < $nblignes ; $i++) 142 { 143 $curY = $nexY; 144 $total = price($propale->lignes[$i]->price * $propale->lignes[$i]->qty); 145 146 $pdf->SetXY (30, $curY ); 147 $pdf->MultiCell(102, 5, $propale->lignes[$i]->libelle, 0, 'J', 0); 148 149 $pdf->SetFont('Arial','', 8); 150 $nexY = $pdf->GetY(); 151 152 $pdf->SetXY (10, $curY ); 153 $pdf->MultiCell(20, 5, $propale->lignes[$i]->ref, 0, 'C', 0); 154 $pdf->SetFont('Arial','', 10); 155 $pdf->SetXY (132, $curY ); 156 $pdf->MultiCell(12, 5, $propale->lignes[$i]->tva_tx, 0, 'C', 0); 157 158 $pdf->SetXY (144, $curY ); 159 $pdf->MultiCell(10, 5, $propale->lignes[$i]->qty, 0, 'C', 0); 160 161 $pdf->SetXY (154, $curY ); 162 $pdf->MultiCell(22, 5, price($propale->lignes[$i]->price), 0, 'R', 0); 163 164 $pdf->SetXY (176, $curY ); 165 $pdf->MultiCell(24, 5, $total, 0, 'R', 0); 166 167 $pdf->line(10, $curY, 200, $curY ); 168 169 if ($nexY > 240 && $i < $nblignes - 1) 170 { 171 $this->_tableau($pdf, $tab_top, $tab_height, $nexY); 172 $pdf->AddPage(); 173 $nexY = $iniY; 174 $this->_pagehead($pdf, $propale); 175 $pdf->SetTextColor(0,0,0); 176 $pdf->SetFont('Arial','', 10); 177 } 178 } 179 180 $this->_tableau($pdf, $tab_top, $tab_height, $nexY); 181 /* 182 * 183 */ 184 $tab2_top = 254; 185 $tab2_lh = 7; 186 $tab2_height = $tab2_lh * 3; 187 188 $pdf->SetFont('Arial','', 11); 189 190 $pdf->Rect(132, $tab2_top, 68, $tab2_height); 191 192 $pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*3), 200, $tab2_top + $tab2_height - ($tab2_lh*3) ); 193 $pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*2), 200, $tab2_top + $tab2_height - ($tab2_lh*2) ); 194 $pdf->line(132, $tab2_top + $tab2_height - $tab2_lh, 200, $tab2_top + $tab2_height - $tab2_lh ); 195 196 $pdf->line(174, $tab2_top, 174, $tab2_top + $tab2_height); 197 198 $pdf->SetXY (132, $tab2_top + 0); 199 $pdf->MultiCell(42, $tab2_lh, "Total HT", 0, 'R', 0); 200 201 $pdf->SetXY (132, $tab2_top + $tab2_lh); 202 $pdf->MultiCell(42, $tab2_lh, "Total TVA", 0, 'R', 0); 203 204 $pdf->SetXY (132, $tab2_top + ($tab2_lh*2)); 205 $pdf->MultiCell(42, $tab2_lh, "Total TTC", 1, 'R', 1); 206 207 $pdf->SetXY (174, $tab2_top + 0); 208 $pdf->MultiCell(26, $tab2_lh, price($propale->total_ht), 0, 'R', 0); 209 210 $pdf->SetXY (174, $tab2_top + $tab2_lh); 211 $pdf->MultiCell(26, $tab2_lh, price($propale->total_tva), 0, 'R', 0); 212 213 $pdf->SetXY (174, $tab2_top + ($tab2_lh*2)); 214 $pdf->MultiCell(26, $tab2_lh, price($propale->total_ttc), 1, 'R', 1); 215 216 /* 217 * 218 */ 219 $pdf->SetFont('Arial','',7); 220 $pdf->SetXY(10, 250); 221 $note = "Note : ".$propale->note; 222 $pdf->MultiCell(110, 3, $note, 0, 'J'); 223 224 225 226 $this->_pagefoot($pdf, $propale); 227 $pdf->AliasNbPages(); 228 229 $pdf->Close(); 230 231 232 $pdf->Output($file); 233 234 return 1; 235 } 236 } 237 } 238 239 function _tableau(&$pdf, $tab_top, $tab_height, $nexY) 240 { 241 global $langs; 242 $langs->load("main"); 243 $langs->load("bills"); 244 245 $pdf->SetFont('Arial','',11); 246 247 $pdf->SetXY(10,$tab_top); 248 $pdf->MultiCell(20,10,$langs->trans("Ref"),0,'C',1); 249 250 $pdf->SetXY(30,$tab_top); 251 $pdf->MultiCell(102,10,$langs->trans("Designation"),0,'L',1); 252 253 $pdf->line(132, $tab_top, 132, $tab_top + $tab_height); 254 $pdf->SetXY(132,$tab_top); 255 $pdf->MultiCell(12, 10,$langs->trans("VAT"),0,'C',1); 256 257 $pdf->line(144, $tab_top, 144, $tab_top + $tab_height); 258 $pdf->SetXY(144,$tab_top); 259 $pdf->MultiCell(10,10,$langs->trans("Qty"),0,'C',1); 260 261 $pdf->line(154, $tab_top, 154, $tab_top + $tab_height); 262 $pdf->SetXY(154,$tab_top); 263 $pdf->MultiCell(22,10,$langs->trans("PriceU"),0,'R',1); 264 265 $pdf->line(176, $tab_top, 176, $tab_top + $tab_height); 266 $pdf->SetXY(176,$tab_top); 267 $pdf->MultiCell(24,10,$langs->trans("Total"),0,'R',1); 268 269 $pdf->Rect(10, $tab_top, 190, $tab_height); 270 271 } 272 function _pagefoot(&$pdf, $propale) 273 { 274 $pdf->SetFont('Arial','I',8); 275 // FAC_PDF_ADRESSE FAC_PDF_TEL 276 277 $pdf->SetFont('Arial','',8); 278 $pdf->SetY(-13); 279 $pdf->MultiCell(190, 3, FAC_PDF_INTITULE . " - SARL au Capital de " . MAIN_INFO_CAPITAL . " - " . MAIN_INFO_RCS." " . MAIN_INFO_SIREN , 0, 'C'); 280 $pdf->SetY(-10); 281 $pdf->MultiCell(190, 3, "N° TVA Intracommunautaire : " . MAIN_INFO_TVAINTRA , 0, 'C'); 282 $pdf->SetXY(-10,-10); 283 $pdf->MultiCell(10, 3, $pdf->PageNo().'/{nb}', 0, 'R'); 284 285 } 286 287 function _pagehead(&$pdf, $propale) 288 { 289 global $langs,$conf; 290 $langs->load("main"); 291 $langs->load("bills"); 292 293 $tab4_top = 60; 294 $tab4_hl = 6; 295 $tab4_sl = 4; 296 $ligne = 2; 297 298 if (defined("FAC_PDF_LOGO") && FAC_PDF_LOGO) $logo=DOL_DATA_ROOT.FAC_PDF_LOGO; 299 if ($logo) 300 { 301 $pdf->SetXY(10,5); 302 if (is_readable($logo)) 303 { 304 $pdf->Image($logo, 10, 5,45.0, 25.0, 'PNG'); 305 } 306 else { 307 $pdf->SetTextColor(200,0,0); 308 $pdf->SetFont('Arial','B',8); 309 $pdf->MultiCell(80, 3, $langs->trans("ErrorLogoFileNotFound",$logo), 0, 'L'); 310 $pdf->MultiCell(80, 3, $langs->trans("ErrorGoToModuleSetup"), 0, 'L'); 311 } 312 } 313 else if (defined("FAC_PDF_INTITULE")) 314 { 315 $pdf->MultiCell(80, 6, FAC_PDF_INTITULE, 0, 'L'); 316 } 317 318 $pdf->SetDrawColor(192,192,192); 319 $pdf->line(9, 5, 200, 5 ); 320 $pdf->line(9, 30, 200, 30 ); 321 322 $pdf->SetFont('Arial','B',7); 323 $pdf->SetTextColor(128,128,128); 324 325 if (defined("FAC_PDF_ADRESSE")) 326 { 327 $pdf->SetXY( $tab4_top , $tab4_hl ); 328 $pdf->MultiCell(40, 3, FAC_PDF_ADRESSE, '' , 'L'); 329 } 330 $pdf->SetFont('Arial','',7); 331 if (defined("FAC_PDF_TEL")) 332 { 333 $pdf->SetXY( $tab4_top , $tab4_hl + 2*$tab4_sl ); 334 $pdf->MultiCell(40, 3, "Téléphone : " . FAC_PDF_TEL, '' , 'L'); 335 } 336 if (defined("FAC_PDF_FAX")) 337 { 338 $pdf->SetXY( $tab4_top , $tab4_hl + 3*$tab4_sl ); 339 $pdf->MultiCell(40, 3, "Télécopie : " . FAC_PDF_FAX, '' , 'L'); 340 } 341 if (defined("FAC_PDF_MEL")) 342 { 343 $pdf->SetXY( $tab4_top , $tab4_hl + 4*$tab4_sl ); 344 $pdf->MultiCell(40, 3, "E-mail : " . FAC_PDF_MEL, '' , 'L'); 345 } 346 if (defined("FAC_PDF_WWW")) 347 { 348 $pdf->SetXY( $tab4_top , $tab4_hl + 5*$tab4_sl ); 349 $pdf->MultiCell(40, 3, "Internet : " . FAC_PDF_WWW, '' , 'L'); 350 } 351 $pdf->SetTextColor(70,70,170); 352 353 /* 354 * Definition du document 355 */ 356 $pdf->SetXY(10,50); 357 $pdf->SetFont('Arial','B',16); 358 $pdf->SetTextColor(0,0,200); 359 $pdf->MultiCell(50, 8, "PROPOSITION COMMERCIALE", '' , 'C'); 360 361 /* 362 * Adresse Client 363 */ 364 $pdf->SetTextColor(0,0,0); 365 $pdf->SetFillColor(242,239,119); 366 $pdf->rect(100, 40, 100, 40, 'F'); 367 $pdf->SetFont('Arial','B',12); 368 $propale->fetch_client(); 369 $pdf->SetXY(102,42); 370 $pdf->MultiCell(86,5, $propale->client->nom, 0, 'C'); 371 $pdf->SetFont('Arial','B',11); 372 $pdf->SetXY(102,50); 373 $pdf->MultiCell(86,5, $propale->client->adresse . "\n\n" . $propale->client->cp . " " . $propale->client->ville, 0, 'C'); 374 375 376 377 $pdf->SetTextColor(200,0,0); 378 $pdf->SetFont('Arial','B',14); 379 //$pdf->Text(11, 88, "Date : " . strftime("%d %b %Y", $propale->date)); 380 //$pdf->Text(11, 94, "Numéro : ".$propale->ref); 381 $pdf->Text(11, 88, $langs->trans("Date")); 382 $pdf->Text(35, 88, ": " . strftime("%d %b %Y", $propale->date)); 383 $pdf->Text(11, 94, $langs->trans("Ref")); 384 $pdf->Text(35, 94, ": ".$propale->ref); 385 /* 386 */ 387 $pdf->SetTextColor(0,0,0); 388 $pdf->SetFont('Arial','',10); 389 $titre = $langs->trans("AmountInCurrency",$langs->trans("Currency".$conf->monnaie)); 390 $pdf->Text(200 - $pdf->GetStringWidth($titre), 98, $titre); 391 /* 392 */ 393 394 } 395 396 } 397 398 ?> 399
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 |
![]() |