[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?PHP 2 /* Copyright (C) 2005 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: ComptaJournalPaiement.class.php,v 1.5 2005/04/11 16:13:54 rodolphe Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/export/ComptaJournalPaiement.class.php,v $ 21 * 22 */ 23 24 require_once(DOL_DOCUMENT_ROOT.'/compta/export/ComptaJournalPdf.class.php'); 25 26 class ComptaJournalPaiement { 27 28 function ComptaJournalPaiement ($db=0) 29 { 30 $this->db = $db; 31 } 32 33 34 function GeneratePdf($user, $excid, $excref) 35 { 36 $date = strftime("%Y%m",time()); 37 38 $dir = DOL_DATA_ROOT."/compta/export/"; 39 $file = $dir . "JournalPaiement".$excref . ".pdf"; 40 41 $grand_total_debit = 0; 42 $grand_total_credit = 0; 43 44 if (file_exists($dir)) 45 { 46 $this->pdf = new ComptaJournalPdf('P','mm','A4'); 47 48 $this->pdf->AliasNbPages(); 49 50 $this->pdf->Open(); 51 $this->pdf->AddPage(); 52 53 $this->tab_top = 90; 54 $this->tab_height = 90; 55 56 $this->pdf->SetTitle("Journal des paiements"); 57 $this->pdf->SetCreator("Dolibarr ".DOL_VERSION); 58 $this->pdf->SetAuthor($user->fullname); 59 60 $this->pdf->SetMargins(10, 10, 10); 61 $this->pdf->SetAutoPageBreak(1,10); 62 63 /* 64 * 65 */ 66 67 $this->pdf->SetFillColor(220,220,220); 68 69 $this->pdf->SetFont('Arial','', 9); 70 71 $this->pdf->SetXY (10, 10 ); 72 $nexY = $this->pdf->GetY(); 73 74 $sql = "SELECT p.rowid,".$this->db->pdate("p.datep")." as dp, p.statut"; 75 $sql .= ", pf.amount"; 76 $sql .= ", c.libelle, p.num_paiement"; 77 $sql .= ", f.facnumber, f.increment"; 78 $sql .= " , s.nom"; 79 $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p"; 80 $sql .= " , ".MAIN_DB_PREFIX."c_paiement as c"; 81 $sql .= " , ".MAIN_DB_PREFIX."paiement_facture as pf"; 82 $sql .= " , ".MAIN_DB_PREFIX."facture as f"; 83 $sql .= " , ".MAIN_DB_PREFIX."societe as s"; 84 $sql .= " WHERE p.fk_paiement = c.id"; 85 $sql .= " AND pf.fk_paiement = p.rowid"; 86 $sql .= " AND f.fk_soc = s.idp"; 87 $sql .= " AND p.statut = 1 "; 88 $sql .= " AND pf.fk_facture = f.rowid"; 89 $sql .= " AND p.fk_export_compta = ".$excid; 90 91 $sql .= " ORDER BY date_format(p.datep,'%Y%m%d') ASC, s.nom ASC"; 92 93 $oldate = ''; 94 95 $resql = $this->db->query($sql); 96 97 if ($resql) 98 { 99 $num = $this->db->num_rows($resql); 100 $i = 0; 101 $var = True; 102 $journ = 'CE'; 103 $this->hligne = 5; 104 105 while ($i < $num) 106 { 107 $obj = $this->db->fetch_object($resql); 108 109 if ($oldate <> strftime("%d%m%Y",$obj->dp)) 110 { 111 112 if ($oldate <> '') 113 { 114 $this->pdf->SetFont('Arial','B',9); 115 116 $this->pdf->cell(143,$this->hligne,''); 117 118 $this->pdf->cell(16,$this->hligne,'Total : ',0,0,'R'); 119 $this->pdf->cell(18,$this->hligne,$total_debit,0,0,'R'); 120 $this->pdf->cell(18,$this->hligne,$total_credit,0,0,'R'); 121 $this->pdf->ln(); 122 } 123 124 $journal = "Journal $journ du ".strftime('%A, %e %B %G',$obj->dp); 125 $total_credit = 0 ; 126 $total_debit = 0 ; 127 $this->pdf->SetFont('Arial','B',10); 128 129 $this->pdf->cell(10,$this->hligne,"$journal"); 130 $this->pdf->ln(); 131 132 $this->pdf->SetFont('Arial','',9); 133 134 $this->pdf->cell(16,$this->hligne,'Date'); 135 136 $this->pdf->cell(20,$this->hligne,'N Facture'); 137 138 $this->pdf->cell(20,$this->hligne,'Tiers'); 139 140 $this->pdf->cell(87,$this->hligne,'Libellé'); 141 142 $this->pdf->cell(16,$this->hligne,'Echeance',0,0,'R'); 143 144 $this->pdf->cell(18,$this->hligne,'Débit',0,0,'R'); 145 146 $this->pdf->cell(18,$this->hligne,'Crédit',0,0,'R'); 147 $this->pdf->ln(); 148 149 $oldate = strftime("%d%m%Y",$obj->dp); 150 } 151 152 /* 153 * 154 */ 155 $socnom = $obj->nom; 156 $libelle = $obj->libelle; 157 158 if (strlen($obj->nom) > 31) 159 { 160 $socnom = substr($obj->nom, 0 , 31); 161 } 162 163 $this->pdf->SetFont('Arial','',9); 164 165 if ($obj->amount >= 0) 166 { 167 $credit = ''; 168 $debit = abs($obj->amount); 169 $total_debit = $total_debit + $debit; 170 $grand_total_debit = $grand_total_debit + $debit; 171 } 172 else 173 { 174 $credit = abs($obj->amount); 175 $debit = ''; 176 $total_credit = $total_credit + $credit; 177 $grand_total_credit = $grand_total_credit + $credit; 178 $libelle = "Rejet Prélèvement"; 179 } 180 181 $s = $socnom . ' '.$libelle; 182 183 $facnumber = $obj->facnumber; 184 if (strlen(trim($obj->increment)) > 0) 185 { 186 $facnumber = $obj->increment; 187 } 188 189 190 $this->_print_ligne($obj->dp, $facnumber, '41100000', $s, $credit, $debit); 191 192 if ($obj->amount >= 0) 193 { 194 $credit = abs($obj->amount); 195 $debit = ''; 196 $total_credit = $total_credit + $credit; 197 $grand_total_credit = $grand_total_credit + $credit; 198 } 199 else 200 { 201 $credit = ''; 202 $debit = abs($obj->amount); 203 $total_debit = $total_debit + $debit; 204 $grand_total_debit = $grand_total_debit + $debit; 205 } 206 207 208 $s = $socnom . ' '.$libelle; 209 $this->_print_ligne($obj->dp, $facnumber, '5122000', $s, $credit, $debit); 210 211 $i++; 212 } 213 214 $this->pdf->SetFont('Arial','B',9); 215 216 $this->pdf->cell(143,$this->hligne,''); 217 218 $this->pdf->cell(16,$this->hligne,'Total : ',0,0,'R'); 219 $this->pdf->cell(18,$this->hligne,$total_debit,0,0,'R'); 220 $this->pdf->cell(18,$this->hligne,$total_credit,0,0,'R'); 221 $this->pdf->ln(); 222 /* 223 * 224 */ 225 $this->pdf->cell(143,$this->hligne,''); 226 227 $this->pdf->cell(16,$this->hligne,'Grand Total : ',0,0,'R'); 228 $this->pdf->cell(18,$this->hligne,$grand_total_debit,0,0,'R'); 229 $this->pdf->cell(18,$this->hligne,$grand_total_credit,0,0,'R'); 230 $this->pdf->ln(); 231 232 /* 233 * 234 * 235 */ 236 237 $this->pdf->Close(); 238 239 $this->pdf->Output($file); 240 241 242 return 1; 243 } 244 else 245 { 246 $this->error=""; 247 return 0; 248 } 249 } 250 else 251 { 252 $this->error="Erreur: FAC_OUTPUTDIR non défini !"; 253 return 0; 254 } 255 } 256 /* 257 * 258 * 259 * 260 */ 261 Function _print_ligne($a, $b, $c, $d, $e, $f) 262 { 263 264 $this->pdf->cell(16,$this->hligne, strftime('%d%m%y',$a)); 265 $this->pdf->cell(20,$this->hligne, $b); 266 $this->pdf->cell(20,$this->hligne, $c); 267 $this->pdf->cell(87,$this->hligne, $d); 268 $this->pdf->cell(16,$this->hligne, strftime('%d%m%y',$a),0,0,'R'); 269 $this->pdf->cell(18,$this->hligne, $e,0,0,'R'); 270 $this->pdf->cell(18,$this->hligne, $f,0,0,'R'); 271 $this->pdf->ln(); 272 273 } 274 } 275 276 ?>
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 |
![]() |