[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?php 2 /* Copyright (C) 2003-2004 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: pdf_paiement.class.php,v 1.13 2005/09/03 15:14:34 eldy Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/includes/modules/rapport/pdf_paiement.class.php,v $ 21 * 22 */ 23 24 /** 25 \file htdocs/includes/modules/rapport/pdf_paiement.class.php 26 \ingroup banque 27 \brief Fichier de la classe permettant de générer les rapports de paiement 28 \version $Revision: 1.13 $ 29 */ 30 31 require_once(FPDF_PATH.'fpdf.php'); 32 33 34 /** \class pdf_paiement 35 \brief Classe permettant de générer les rapports de paiement 36 */ 37 38 class pdf_paiement 39 { 40 41 /** \brief Constructeur 42 \param db handler accès base de donnée 43 */ 44 function pdf_paiement($db=0) 45 { 46 $this->db = $db; 47 $this->description = "Liste des paiements"; 48 49 $this->url = DOL_URL_ROOT."/document/rapport/" . "paiements" . ".pdf"; 50 51 $this->tab_top = 30; 52 53 $this->line_height = 5; 54 $this->line_per_page = 25; 55 $this->tab_height = 230;//$this->line_height * $this->line_per_page; 56 57 } 58 59 function print_link() 60 { 61 if (file_exists($this->file)) 62 { 63 print '<a href="'.$this->url.'">paiements.pdf</a>'; 64 print '<table><tr>'; 65 print '<td align="right">'.filesize($this->file). ' bytes</td>'; 66 print '<td align="right">'.strftime("%d %b %Y %H:%M:%S",filemtime($this->file)).'</td>'; 67 print '</tr></table>'; 68 } 69 } 70 71 function Header(&$pdf, $page, $pages) 72 { 73 $pdf->SetFont('Arial','B',12); 74 $pdf->Text(10, 10, FAC_PDF_INTITULE); 75 76 $pdf->SetFont('Arial','B',12); 77 $pdf->Text(90, 10, "Liste des paiements encaissés"); 78 79 $pdf->SetFont('Arial','B',12); 80 $pdf->Text(11, 16, "Date : " . strftime("%d %b %Y", time())); 81 82 $pdf->SetFont('Arial','B',12); 83 $pdf->Text(11, 22, "Page " . $page); 84 // $pdf->Text(11, 22, "Page " . $page . " sur " . $pages); 85 86 $pdf->SetFont('Arial','',12); 87 88 $pdf->Text(11,$this->tab_top + 6,'Date'); 89 90 $pdf->line(40, $this->tab_top, 40, $this->tab_top + $this->tab_height + 10); 91 $pdf->Text(42, $this->tab_top + 6,'Type paiement'); 92 93 $pdf->line(80, $this->tab_top, 80, $this->tab_top + $this->tab_height + 10); 94 $pdf->Text(82, $this->tab_top + 6,'Facture'); 95 96 $pdf->line(120, $this->tab_top, 120, $this->tab_top + $this->tab_height + 10); 97 $pdf->Text(122, $this->tab_top + 6,'Montant Fac'); 98 99 $pdf->line(160, $this->tab_top, 160, $this->tab_top + $this->tab_height + 10); 100 101 $pdf->SetXY (160, $this->tab_top); 102 $pdf->MultiCell(40, 10, "Montant", 0, 'R'); 103 104 $pdf->Rect(10, $this->tab_top, 190, $this->tab_height + 10); 105 $pdf->line(10, $this->tab_top + 10, 200, $this->tab_top + 10 ); 106 107 } 108 109 function Body(&$pdf, $page, $lines) 110 { 111 $pdf->SetFont('Arial','', 9); 112 $oldprowid = 0; 113 $pdf->SetFillColor(220,220,220); 114 $yp = 0; 115 for ($j = 0 ; $j < sizeof($lines) ; $j++) 116 { 117 $i = $j; 118 if ($oldprowid <> $lines[$j][7]) 119 { 120 if ($yp > 200) 121 { 122 $page++; 123 $pdf->AddPage(); 124 $this->Header($pdf, $page, $pages); 125 $pdf->SetFont('Arial','', 9); 126 $yp = 0; 127 } 128 129 130 $pdf->SetXY (10, $this->tab_top + 10 + $yp); 131 $pdf->MultiCell(30, $this->line_height, $lines[$j][1], 0, 'J', 1); 132 133 $pdf->SetXY (40, $this->tab_top + 10 + $yp); 134 $pdf->MultiCell(40, $this->line_height, $lines[$j][2], 0, 'J', 1); 135 136 $pdf->SetXY (80, $this->tab_top + 10 + $yp); 137 $pdf->MultiCell(40, $this->line_height, '', 0, 'J', 1); 138 139 $pdf->SetXY (120, $this->tab_top + 10 + $yp); 140 $pdf->MultiCell(40, $this->line_height, $lines[$j][3], 0, 'J', 1); 141 142 $pdf->SetXY (160, $this->tab_top + 10 + $yp); 143 $pdf->MultiCell(40, $this->line_height, $lines[$j][4], 0, 'R', 1); 144 $yp = $yp + 5; 145 } 146 147 $pdf->SetXY (80, $this->tab_top + 10 + $yp); 148 $pdf->MultiCell(40, $this->line_height, $lines[$j][0], 0, 'J', 0); 149 150 $pdf->SetXY (120, $this->tab_top + 10 + $yp); 151 $pdf->MultiCell(40, $this->line_height, $lines[$j][5], 0, 'J', 0); 152 153 $pdf->SetXY (160, $this->tab_top + 10 + $yp); 154 $pdf->MultiCell(40, $this->line_height, $lines[$j][6], 0, 'R', 0); 155 $yp = $yp + 5; 156 157 if ($oldprowid <> $lines[$j][7]) 158 { 159 $oldprowid = $lines[$j][7]; 160 } 161 162 // if ($i < $this->line_per_page - 1) 163 // { 164 // $pdf->line(10, $this->tab_top + 10 + (($i+1) * $this->line_height), 200, $this->tab_top + 10 + (($i+1) * $this->line_height)); 165 // } 166 } 167 } 168 169 170 /** 171 \brief Fonction générant le rapport sur le disque 172 \param _dir repertoire 173 \param month mois du rapport 174 \param year annee du rapport 175 */ 176 function write_pdf_file($_dir, $month, $year) 177 { 178 if (! file_exists($_dir)) 179 { 180 umask(0); 181 if (! mkdir($_dir, 0755)) 182 { 183 print "Impossible de créer $_dir !"; 184 die; 185 } 186 } 187 $_dir = $_dir . '/' . $year . '/'; 188 if (! file_exists($_dir)) 189 { 190 umask(0); 191 if (! mkdir($_dir, 0755)) 192 { 193 print "Impossible de créer $_dir !"; 194 die; 195 } 196 } 197 198 $month = substr("0".$month, strlen("0".$month)-2,2); 199 $_file = $_dir . "paiements-$month-$year" . ".pdf"; 200 201 202 $pdf = new FPDF('P','mm','A4'); 203 $pdf->Open(); 204 205 /* 206 * 207 */ 208 209 $sql = "SELECT ".$this->db->pdate("p.datep")." as dp, f.facnumber"; 210 $sql .= ", c.libelle as paiement_type, p.num_paiement"; 211 $sql .= ", p.amount as paiement_amount, f.total_ttc as facture_amount "; 212 $sql .= ", pf.amount as pf_amount "; 213 $sql .= ", p.rowid as prowid"; 214 $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p, ".MAIN_DB_PREFIX."facture as f, "; 215 $sql .= MAIN_DB_PREFIX."c_paiement as c, ".MAIN_DB_PREFIX."paiement_facture as pf"; 216 217 $sql .= " WHERE pf.fk_facture = f.rowid AND pf.fk_paiement = p.rowid"; 218 219 $sql .= " AND date_format(p.datep, '%Y') = " . $year; 220 $sql .= " AND p.fk_paiement = c.id "; 221 // $sql .= " AND date_format(p.datep, '%m%Y') = " . $month.$year; 222 $sql .= " ORDER BY p.datep ASC, pf.fk_paiement ASC"; 223 $result = $this->db->query($sql); 224 // print $sql ; 225 226 if ($result) 227 { 228 $lignes = $this->db->num_rows(); 229 $i = 0; 230 $var=True; 231 232 while ($i < $lignes) 233 { 234 $objp = $this->db->fetch_object($result); 235 $var=!$var; 236 237 $lines[$i][0] = $objp->facnumber; 238 $lines[$i][1] = strftime("%d %B %Y",$objp->dp); 239 $lines[$i][2] = $objp->paiement_type ; 240 $lines[$i][3] = $objp->num_paiement; 241 $lines[$i][4] = price($objp->paiement_amount); 242 $lines[$i][5] = price($objp->facture_amount); 243 $lines[$i][6] = price($objp->pf_amount); 244 $lines[$i][7] = price($objp->prowid); 245 $i++; 246 } 247 } 248 249 $pages = intval($lignes / $this->line_per_page); 250 251 if (($lignes % $this->line_per_page)>0) 252 { 253 $pages++; 254 } 255 256 if ($pages == 0) 257 { 258 // force à générer au moins une page si le rapport ne contient aucune ligne 259 $pages = 1; 260 } 261 /* 262 for ($i = 0 ; $i < $pages ; $i++) 263 { 264 $pdf->AddPage(); 265 $this->Header($pdf, $i+1, $pages); 266 $this->Body($pdf, $i+1, $lines); 267 } 268 */ 269 270 $pdf->AddPage(); 271 $this->Header($pdf, 1, $pages); 272 $this->Body($pdf, 1, $lines); 273 274 /* 275 * 276 */ 277 278 $pdf->Output($_file); 279 } 280 281 } 282 283 ?>
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 |
![]() |