| [ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> 3 * Copyright (C) 2004-2005 Laurent Destailleur <eldy@users.sourceforge.net> 4 * Copyright (C) 2005 Regis Houssin <regis.houssin@cap-networks.com> 5 * 6 * This program is free software; you can redistribute it and/or modify 7 * it under the terms of the GNU General Public License as published by 8 * the Free Software Foundation; either version 2 of the License, or 9 * (at your option) any later version. 10 * 11 * This program is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU General Public License for more details. 15 * 16 * You should have received a copy of the GNU General Public License 17 * along with this program; if not, write to the Free Software 18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 19 * or see http://www.gnu.org/ 20 * 21 * $Id: pdf_propale_vert.modules.php,v 1.21 2005/11/11 20:11:58 eldy Exp $ 22 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/includes/modules/propale/pdf_propale_vert.modules.php,v $ 23 */ 24 25 /** \file htdocs/includes/modules/propale/pdf_propale_vert.modules.php 26 \ingroup propale 27 \brief Fichier de la classe permettant de générer les propales au modèle Vert 28 \version $Revision: 1.21 $ 29 */ 30 31 require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/modules_propale.php"); 32 33 34 /** \class pdf_propale_vert 35 \brief Classe permettant de générer les propales au modèle Vert 36 */ 37 38 class pdf_propale_vert extends ModelePDFPropales 39 { 40 41 /** \brief Constructeur 42 \param db handler accès base de donnée 43 */ 44 function pdf_propale_vert($db=0) 45 { 46 $this->db = $db; 47 $this->name = "vert"; 48 $this->description = "Affichage de la remise par produit"; 49 50 // Dimension page pour format A4 51 $this->page_largeur = 210; 52 $this->page_hauteur = 297; 53 $this->format = array($this->page_largeur,$this->page_hauteur); 54 55 $this->error = ""; 56 } 57 58 59 /** \brief Renvoi dernière erreur 60 \return string Dernière erreur 61 */ 62 function pdferror() 63 { 64 return $this->error; 65 } 66 67 68 /** 69 \brief Fonction générant la propale sur le disque 70 \param id id de la propale à générer 71 \return int 1=ok, 0=ko 72 */ 73 function write_pdf_file($id) 74 { 75 global $user,$conf,$langs; 76 77 $propale = new Propal($this->db,"",$id); 78 if ($propale->fetch($id)) 79 { 80 81 if ($conf->propal->dir_output) 82 { 83 $propref = sanitize_string($propale->ref); 84 $dir = $conf->propal->dir_output . "/" . $propref ; 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 $pdf->AddPage(); 109 110 $pdf->SetTitle($propale->ref); 111 $pdf->SetSubject("Proposition commerciale"); 112 $pdf->SetCreator("Dolibarr ".DOL_VERSION); 113 $pdf->SetAuthor($user->fullname); 114 115 $this->_pagehead($pdf, $propale); 116 117 /* 118 */ 119 $tab_top = 100; 120 $tab_height = 140; 121 /* 122 * 123 */ 124 125 $pdf->SetFillColor(220,220,220); 126 127 $pdf->SetTextColor(0,0,0); 128 $pdf->SetFont('Arial','', 10); 129 130 $pdf->SetXY (10, $tab_top + 10 ); 131 132 $iniY = $pdf->GetY(); 133 $curY = $pdf->GetY(); 134 $nexY = $pdf->GetY(); 135 $nblignes = sizeof($propale->lignes); 136 137 for ($i = 0 ; $i < $nblignes ; $i++) 138 { 139 140 $curY = $nexY; 141 142 $pdf->SetXY (40, $curY ); 143 144 $pdf->MultiCell(90, 5, $propale->lignes[$i]->desc, 0, 'J', 0); 145 146 $nexY = $pdf->GetY(); 147 148 $pdf->SetXY (10, $curY ); 149 $pdf->SetFont('Arial','', 8); 150 $pdf->MultiCell(30, 5, $propale->lignes[$i]->ref, 0, 'L', 0); 151 152 $pdf->SetFont('Arial','', 10); 153 $pdf->SetXY (132, $curY ); 154 $pdf->MultiCell(10, 5, $propale->lignes[$i]->tva_tx, 0, 'C', 0); 155 156 $pdf->SetXY (142, $curY ); 157 $pdf->MultiCell(8, 5, $propale->lignes[$i]->qty, 0, 'C'); 158 159 $pdf->SetXY (150, $curY ); 160 $pdf->MultiCell(16, 5, price($propale->lignes[$i]->subprice), 0, 'R', 0); 161 162 $pdf->SetXY (166, $curY ); 163 $pdf->MultiCell(14, 5, $propale->lignes[$i]->remise_percent."%", 0, 'R', 0); 164 165 $pdf->SetXY (180, $curY ); 166 $total = price($propale->lignes[$i]->price * $propale->lignes[$i]->qty); 167 $pdf->MultiCell(20, 5, $total, 0, 'R', 0); 168 169 $pdf->line(10, $curY, 200, $curY ); 170 171 if ($nexY > 240 && $i < $nblignes - 1) 172 { 173 $this->_tableau($pdf, $tab_top, $tab_height, $nexY); 174 $pdf->AddPage(); 175 $nexY = $iniY; 176 $this->_pagehead($pdf, $propale); 177 $pdf->SetTextColor(0,0,0); 178 $pdf->SetFont('Arial','', 10); 179 } 180 } 181 182 $this->_tableau($pdf, $tab_top, $tab_height, $nexY); 183 /* 184 * 185 */ 186 $tab2_top = 241; 187 $tab2_lh = 7; 188 $tab2_height = $tab2_lh * 4; 189 190 $pdf->SetFont('Arial','', 11); 191 192 $pdf->Rect(132, $tab2_top, 68, $tab2_height); 193 194 $pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*3), 200, $tab2_top + $tab2_height - ($tab2_lh*3) ); 195 $pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*2), 200, $tab2_top + $tab2_height - ($tab2_lh*2) ); 196 $pdf->line(132, $tab2_top + $tab2_height - $tab2_lh, 200, $tab2_top + $tab2_height - $tab2_lh ); 197 198 $pdf->line(174, $tab2_top, 174, $tab2_top + $tab2_height); 199 200 $pdf->SetXY (132, $tab2_top + 0); 201 $pdf->MultiCell(42, $tab2_lh, $langs->trans("TotalHT"), 0, 'R', 0); 202 203 $pdf->SetXY (132, $tab2_top + $tab2_lh); 204 $pdf->MultiCell(42, $tab2_lh, $langs->trans("GlobalDiscount"), 0, 'R', 0); 205 206 $pdf->SetXY (132, $tab2_top + $tab2_lh*2); 207 $pdf->MultiCell(42, $tab2_lh, "Total HT après remise", 0, 'R', 0); 208 209 $pdf->SetXY (132, $tab2_top + $tab2_lh*3); 210 $pdf->MultiCell(42, $tab2_lh, $langs->trans("TotalVAT"), 0, 'R', 0); 211 212 $pdf->SetXY (132, $tab2_top + ($tab2_lh*4)); 213 $pdf->MultiCell(42, $tab2_lh, $langs->trans("TotalTTC"), 1, 'R', 1); 214 215 $pdf->SetXY (174, $tab2_top + 0); 216 $pdf->MultiCell(26, $tab2_lh, price($propale->total_ht + $propale->remise), 0, 'R', 0); 217 218 $pdf->SetXY (174, $tab2_top + $tab2_lh); 219 $pdf->MultiCell(26, $tab2_lh, price($propale->remise), 0, 'R', 0); 220 221 $pdf->SetXY (174, $tab2_top + $tab2_lh*2); 222 $pdf->MultiCell(26, $tab2_lh, price($propale->total_ht), 0, 'R', 0); 223 224 $pdf->SetXY (174, $tab2_top + $tab2_lh*3); 225 $pdf->MultiCell(26, $tab2_lh, price($propale->total_tva), 0, 'R', 0); 226 227 $pdf->SetXY (174, $tab2_top + ($tab2_lh*4)); 228 $pdf->MultiCell(26, $tab2_lh, price($propale->total_ttc), 1, 'R', 1); 229 230 /* 231 * 232 */ 233 234 $pdf->Output($file); 235 return 1; 236 } 237 } 238 } 239 240 function _tableau(&$pdf, $tab_top, $tab_height, $nexY) 241 { 242 global $langs,$conf; 243 $langs->load("main"); 244 $langs->load("bills"); 245 246 $yt = 100; 247 $pdf->SetFont('Arial','',10); 248 249 $pdf->SetXY(10, $yt); 250 $pdf->MultiCell(30,5,$langs->trans("Ref"),0,'L'); 251 252 $pdf->SetXY(40, $yt); 253 $pdf->MultiCell(90,5,$langs->trans("Designation"),0,'L'); 254 255 $pdf->SetXY(132, $yt); 256 $pdf->line(132, $tab_top, 132, $tab_top + $tab_height); 257 $pdf->MultiCell(10,5,$langs->trans("VAT"),0,'C'); 258 259 $pdf->line(142, $tab_top, 142, $tab_top + $tab_height); 260 $pdf->SetXY(142, $yt); 261 $pdf->MultiCell(8,5,$langs->trans("Qty"),0,'C'); 262 263 $pdf->line(150, $tab_top, 150, $tab_top + $tab_height); 264 $pdf->SetXY(150, $yt); 265 $pdf->MultiCell(16,5,$langs->trans("PriceU"),0,'C'); 266 267 $pdf->line(166, $tab_top, 166, $tab_top + $tab_height); 268 $pdf->SetXY(166, $yt); 269 $pdf->MultiCell(14,5,$langs->trans("Discount"),0,'C'); 270 271 $pdf->line(180, $tab_top, 180, $tab_top + $tab_height); 272 $pdf->SetXY(180, $yt); 273 $pdf->MultiCell(20,5,$langs->trans("Total"),0,'R'); 274 275 // $pdf->Rect(10, $tab_top, 190, $nexY - $tab_top); 276 $pdf->Rect(10, $tab_top, 190, $tab_height); 277 278 279 $pdf->SetTextColor(0,0,0); 280 $pdf->SetFont('Arial','',10); 281 $titre = $langs->trans("AmountInCurrency",$langs->trans("Currency".$conf->monnaie)); 282 $pdf->Text(200 - $pdf->GetStringWidth($titre), 98, $titre); 283 284 $pdf->SetXY(10, ($tab_top + $tab_height + 6)); 285 $pdf->SetFont('Arial','',8); 286 $texte = "En conformité avec la loi 92-1442 du 31/12/92 modifiée, une pénalité sera appliquée pour un retard de paiement au taux d'intérêt légal multiplié par 5. LE matériel reste l'entière propriété de ".MAIN_INFO_SOCIETE_NOM." jusqu'à son paiement intégral. Les configurations sont garanties trois ans (1 an pièce et main d'oeuvre, 2 ans (souris, micro-ventilateurs, claviers, non garanties). Pièces détachées non garanties si montage hors de nos ateliers. La validation d'un devis est soumise à sa signature et encaissement d'un accompte de 30% du montant TTC."; 287 $pdf->MultiCell(120,3,$texte,0,'J'); 288 } 289 290 function _pagehead(&$pdf, $propale) 291 { 292 $pdf->SetXY(10,5); 293 if (defined("FAC_PDF_INTITULE")) 294 { 295 $pdf->SetTextColor(0,0,200); 296 $pdf->SetFont('Arial','B',14); 297 $pdf->MultiCell(76, 8, FAC_PDF_INTITULE, 0, 'L'); 298 } 299 300 $pdf->SetTextColor(70,70,170); 301 if (defined("FAC_PDF_ADRESSE")) 302 { 303 $pdf->SetFont('Arial','',12); 304 $pdf->MultiCell(76, 5, FAC_PDF_ADRESSE); 305 } 306 if (defined("FAC_PDF_TEL")) 307 { 308 $pdf->SetFont('Arial','',10); 309 $pdf->MultiCell(76, 5, "Tél : ".FAC_PDF_TEL); 310 } 311 if (defined("MAIN_INFO_SIREN")) 312 { 313 $pdf->SetFont('Arial','',10); 314 $pdf->MultiCell(76, 5, "SIREN : ".MAIN_INFO_SIREN); 315 } 316 317 if (defined("FAC_PDF_INTITULE2")) 318 { 319 $pdf->SetXY(100,5); 320 $pdf->SetFont('Arial','B',14); 321 $pdf->SetTextColor(0,0,200); 322 $pdf->MultiCell(100, 10, FAC_PDF_INTITULE2, '' , 'R'); 323 } 324 /* 325 * Adresse Client 326 */ 327 $pdf->SetTextColor(0,0,0); 328 $pdf->SetFont('Arial','B',12); 329 $propale->fetch_client(); 330 $pdf->SetXY(102,42); 331 $pdf->MultiCell(96,5, $propale->client->nom); 332 $pdf->SetFont('Arial','B',11); 333 $pdf->SetXY(102,47); 334 $pdf->MultiCell(96,5, $propale->client->adresse . "\n" . $propale->client->cp . " " . $propale->client->ville); 335 $pdf->rect(100, 40, 100, 40); 336 337 338 $pdf->SetTextColor(200,0,0); 339 $pdf->SetFont('Arial','B',12); 340 $pdf->Text(11, 88, "Date : " . strftime("%d %b %Y", $propale->date)); 341 $pdf->Text(11, 94, "Proposition commerciale : ".$propale->ref); 342 343 344 } 345 346 } 347 348 ?>
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 |
|