[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?PHP 2 /* Copyright (C) 2003 Rodolphe Quiedeville <rodolphe@quiedeville.org> 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: methode_expedition.modules.php,v 1.5 2005/09/03 15:14:34 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/expedition/mods/methode_expedition.modules.php,v $ 21 * 22 */ 23 24 require_once(FPDF_PATH.'fpdf.php'); 25 26 Class methode_expedition 27 { 28 29 Function methode_expedition($db=0) 30 { 31 $this->db = $db; 32 $this->name = "NON DEFINIT"; 33 $this->description = "ERREUR DANS LA DEFINITION DU MODULE."; 34 } 35 36 Function Active($statut) 37 { 38 // Mise a jour du statut 39 $sql = "UPDATE ".MAIN_DB_PREFIX."expedition_methode set statut = $statut "; 40 $sql.= " WHERE rowid = ".$this->id; 41 42 $resql = $this->db->query($sql); 43 44 if ($resql) 45 { 46 $af = $this->db->affected_rows($resql); 47 48 if ($af == 0 && $statut == 1) 49 { 50 // On créé la méthode dans la base 51 52 $sql = "INSERT INTO ".MAIN_DB_PREFIX."expedition_methode"; 53 $sql .= " (rowid, statut, code, libelle, description)"; 54 $sql .= " VALUES (".$this->id.",1,'$this->code','$this->name','$this->description')"; 55 56 $resql = $this->db->query($sql); 57 58 if (! $resql) 59 { 60 dolibarr_syslog("methode_expedition::Active Erreur 2"); 61 } 62 } 63 } 64 else 65 { 66 dolibarr_syslog("methode_expedition::Active Erreur 1"); 67 } 68 } 69 70 Function write_pdf_file($id) 71 { 72 global $user; 73 $propale = new Propal($this->db,"",$id); 74 if ($propale->fetch($id)) 75 { 76 77 if (defined("PROPALE_OUTPUTDIR")) 78 { 79 $dir = PROPALE_OUTPUTDIR . "/" . $propale->ref ; 80 umask(0); 81 if (! file_exists($dir)) 82 { 83 mkdir($dir, 0755); 84 } 85 } 86 else 87 { 88 print "PROPALE_OUTPUTDIR non définit !"; 89 } 90 91 $file = $dir . "/" . $propale->ref . ".pdf"; 92 93 if (file_exists($dir)) 94 { 95 96 $pdf=new FPDF('P','mm','A4'); 97 $pdf->Open(); 98 $pdf->AddPage(); 99 100 $pdf->SetTitle($propale->ref); 101 $pdf->SetSubject("Proposition commerciale"); 102 $pdf->SetCreator("Dolibarr ".DOL_VERSION); 103 $pdf->SetAuthor($user->fullname); 104 105 $this->_pagehead($pdf, $propale); 106 107 /* 108 */ 109 $tab_top = 100; 110 $tab_height = 150; 111 /* 112 * 113 */ 114 115 $pdf->SetFillColor(220,220,220); 116 117 $pdf->SetTextColor(0,0,0); 118 $pdf->SetFont('Arial','', 10); 119 120 $pdf->SetXY (10, $tab_top + 10 ); 121 122 $iniY = $pdf->GetY(); 123 $curY = $pdf->GetY(); 124 $nexY = $pdf->GetY(); 125 $nblignes = sizeof($propale->lignes); 126 127 for ($i = 0 ; $i < $nblignes ; $i++) 128 { 129 130 $curY = $nexY; 131 132 $pdf->SetXY (30, $curY ); 133 134 $pdf->MultiCell(100, 5, $propale->lignes[$i]->desc, 0, 'J', 0); 135 136 $nexY = $pdf->GetY(); 137 138 $pdf->SetXY (10, $curY ); 139 140 $pdf->MultiCell(20, 5, $propale->lignes[$i]->ref, 0, 'C'); 141 142 $pdf->SetXY (133, $curY ); 143 $pdf->MultiCell(10, 5, $propale->lignes[$i]->tva_tx, 0, 'C'); 144 145 $pdf->SetXY (145, $curY ); 146 $pdf->MultiCell(10, 5, $propale->lignes[$i]->qty, 0, 'C'); 147 148 $pdf->SetXY (156, $curY ); 149 $pdf->MultiCell(18, 5, price($propale->lignes[$i]->price), 0, 'R', 0); 150 151 $pdf->SetXY (174, $curY ); 152 $total = price($propale->lignes[$i]->price * $propale->lignes[$i]->qty); 153 $pdf->MultiCell(26, 5, $total, 0, 'R', 0); 154 155 $pdf->line(10, $curY, 200, $curY ); 156 157 if ($nexY > 240 && $i < $nblignes - 1) 158 { 159 $this->_tableau($pdf, $tab_top, $tab_height, $nexY); 160 $pdf->AddPage(); 161 $nexY = $iniY; 162 $this->_pagehead($pdf, $propale); 163 $pdf->SetTextColor(0,0,0); 164 $pdf->SetFont('Arial','', 10); 165 } 166 } 167 168 $this->_tableau($pdf, $tab_top, $tab_height, $nexY); 169 /* 170 * 171 */ 172 $tab2_top = 254; 173 $tab2_lh = 7; 174 $tab2_height = $tab2_lh * 3; 175 176 $pdf->SetFont('Arial','', 11); 177 178 $pdf->Rect(132, $tab2_top, 68, $tab2_height); 179 180 $pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*3), 200, $tab2_top + $tab2_height - ($tab2_lh*3) ); 181 $pdf->line(132, $tab2_top + $tab2_height - ($tab2_lh*2), 200, $tab2_top + $tab2_height - ($tab2_lh*2) ); 182 $pdf->line(132, $tab2_top + $tab2_height - $tab2_lh, 200, $tab2_top + $tab2_height - $tab2_lh ); 183 184 $pdf->line(174, $tab2_top, 174, $tab2_top + $tab2_height); 185 186 $pdf->SetXY (132, $tab2_top + 0); 187 $pdf->MultiCell(42, $tab2_lh, "Total HT", 0, 'R', 0); 188 189 $pdf->SetXY (132, $tab2_top + $tab2_lh); 190 $pdf->MultiCell(42, $tab2_lh, "Total TVA", 0, 'R', 0); 191 192 $pdf->SetXY (132, $tab2_top + ($tab2_lh*2)); 193 $pdf->MultiCell(42, $tab2_lh, "Total TTC", 1, 'R', 1); 194 195 $pdf->SetXY (174, $tab2_top + 0); 196 $pdf->MultiCell(26, $tab2_lh, price($propale->total_ht), 0, 'R', 0); 197 198 $pdf->SetXY (174, $tab2_top + $tab2_lh); 199 $pdf->MultiCell(26, $tab2_lh, price($propale->total_tva), 0, 'R', 0); 200 201 $pdf->SetXY (174, $tab2_top + ($tab2_lh*2)); 202 $pdf->MultiCell(26, $tab2_lh, price($propale->total_ttc), 1, 'R', 1); 203 204 /* 205 * 206 */ 207 208 $pdf->Output($file); 209 210 } 211 } 212 } 213 214 Function _tableau(&$pdf, $tab_top, $tab_height, $nexY) 215 { 216 217 $pdf->SetFont('Arial','',11); 218 219 $pdf->Text(30,$tab_top + 5,'Désignation'); 220 221 $pdf->line(132, $tab_top, 132, $tab_top + $tab_height); 222 $pdf->Text(134,$tab_top + 5,'TVA'); 223 224 $pdf->line(144, $tab_top, 144, $tab_top + $tab_height); 225 $pdf->Text(147,$tab_top + 5,'Qté'); 226 227 $pdf->line(156, $tab_top, 156, $tab_top + $tab_height); 228 $pdf->Text(160,$tab_top + 5,'P.U.'); 229 230 $pdf->line(174, $tab_top, 174, $tab_top + $tab_height); 231 $pdf->Text(187,$tab_top + 5,'Total'); 232 233 // $pdf->Rect(10, $tab_top, 190, $nexY - $tab_top); 234 $pdf->Rect(10, $tab_top, 190, $tab_height); 235 236 237 $pdf->SetTextColor(0,0,0); 238 $pdf->SetFont('Arial','',10); 239 $titre = $langs->trans("AmountInCurrency",$langs->trans("Currency".$conf->monnaie)); 240 $pdf->Text(200 - $pdf->GetStringWidth($titre), 98, $titre); 241 242 } 243 244 Function _pagehead(&$pdf, $propale) 245 { 246 $pdf->SetXY(10,5); 247 if (defined("FAC_PDF_INTITULE")) 248 { 249 $pdf->SetTextColor(0,0,200); 250 $pdf->SetFont('Times','B',14); 251 $pdf->MultiCell(76, 8, FAC_PDF_INTITULE, 0, 'L'); 252 } 253 254 $pdf->SetTextColor(70,70,170); 255 if (defined("FAC_PDF_ADRESSE")) 256 { 257 $pdf->SetFont('Times','',12); 258 $pdf->MultiCell(76, 5, FAC_PDF_ADRESSE); 259 } 260 if (defined("FAC_PDF_TEL")) 261 { 262 $pdf->SetFont('Times','',10); 263 $pdf->MultiCell(76, 5, "Tél : ".FAC_PDF_TEL); 264 } 265 if (defined("FAC_PDF_SIREN")) 266 { 267 $pdf->SetFont('Times','',10); 268 $pdf->MultiCell(76, 5, "SIREN : ".FAC_PDF_SIREN); 269 } 270 271 if (defined("FAC_PDF_INTITULE2")) 272 { 273 $pdf->SetXY(100,5); 274 $pdf->SetFont('Times','B',14); 275 $pdf->SetTextColor(0,0,200); 276 $pdf->MultiCell(100, 10, FAC_PDF_INTITULE2, '' , 'R'); 277 } 278 /* 279 * Adresse Client 280 */ 281 $pdf->SetTextColor(0,0,0); 282 $pdf->SetFont('Courier','B',12); 283 $propale->fetch_client(); 284 $pdf->SetXY(102,42); 285 $pdf->MultiCell(96,5, $propale->client->nom); 286 $pdf->SetFont('Courier','B',11); 287 $pdf->SetXY(102,47); 288 $pdf->MultiCell(96,5, $propale->client->adresse . "\n" . $propale->client->cp . " " . $propale->client->ville); 289 $pdf->rect(100, 40, 100, 40); 290 291 292 $pdf->SetTextColor(200,0,0); 293 $pdf->SetFont('Courier','B',12); 294 $pdf->Text(11, 88, "Date : " . strftime("%d %b %Y", $propale->date)); 295 $pdf->Text(11, 94, "Proposition commerciale : ".$propale->ref); 296 297 298 } 299 300 } 301 302 ?>
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 |
![]() |