[ 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: ComptaJournalVente.class.php,v 1.6 2005/04/11 16:13:25 rodolphe Exp $ 20 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/export/ComptaJournalVente.class.php,v $ 21 * 22 */ 23 24 require_once(DOL_DOCUMENT_ROOT.'/compta/export/ComptaJournalPdf.class.php'); 25 26 class ComptaJournalVente { 27 28 function ComptaJournalVente ($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 . "JournalVente".$excref . ".pdf"; 40 41 if (file_exists($dir)) 42 { 43 $pdf = new ComptaJournalPdf('P','mm','A4'); 44 $pdf->AliasNbPages(); 45 46 $pdf->Open(); 47 $pdf->AddPage(); 48 49 $this->tab_top = 90; 50 $this->tab_height = 90; 51 52 $pdf->SetTitle("Journal des ventes"); 53 $pdf->SetCreator("Dolibarr ".DOL_VERSION); 54 $pdf->SetAuthor($user->fullname); 55 56 $pdf->SetMargins(10, 10, 10); 57 $pdf->SetAutoPageBreak(1,10); 58 59 /* 60 * 61 */ 62 63 $pdf->SetFillColor(220,220,220); 64 65 $pdf->SetFont('Arial','', 9); 66 67 $pdf->SetXY (10, 10 ); 68 $nexY = $pdf->GetY(); 69 70 $sql = "SELECT f.rowid as facid, f.facnumber, ".$this->db->pdate("f.datef")." as dp"; 71 $sql .= " , f.total_ttc as amount, f.tva "; 72 $sql .= " ,s.nom, s.code_compta"; 73 $sql .= " , l.price, l.tva_taux"; 74 $sql .= " , c.numero, f.increment"; 75 $sql .= " , l.rowid as lrowid"; 76 77 $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l"; 78 $sql .= " , ".MAIN_DB_PREFIX."facture as f"; 79 $sql .= " , ".MAIN_DB_PREFIX."societe as s"; 80 $sql .= " , ".MAIN_DB_PREFIX."compta_compte_generaux as c"; 81 82 $sql .= " WHERE f.rowid = l.fk_facture "; 83 $sql .= " AND s.idp = f.fk_soc"; 84 $sql .= " AND f.fk_statut = 1 "; 85 $sql .= " AND l.fk_code_ventilation <> 0 "; 86 $sql .= " AND l.fk_export_compta <> 0"; 87 $sql .= " AND c.rowid = l.fk_code_ventilation"; 88 89 $sql .= " AND l.fk_export_compta = ".$excid; 90 91 $sql .= " ORDER BY date_format(f.datef,'%Y%m%d') ASC, f.rowid, l.rowid"; 92 93 $oldate = ''; 94 $oldfac = ''; 95 96 $resql = $this->db->query($sql); 97 98 if ($resql) 99 { 100 $num = $this->db->num_rows($resql); 101 $i = 0; 102 $var = True; 103 $journ = 'VI'; 104 $hligne = 5; 105 106 $wc = array(0,14,6,16,16,90,16,12,4,16); 107 108 while ($i < $num) 109 { 110 $obj = $this->db->fetch_object($resql); 111 112 if ($oldate <> strftime("%d%m%Y",$obj->dp)) 113 { 114 115 $journal = "Journal $journ du ".strftime('%A, %e %B %G',$obj->dp); 116 $total_credit = 0 ; 117 $total_debit = 0 ; 118 $pdf->SetFont('Arial','B',10); 119 120 $pdf->cell(10,$hligne,"$journal"); 121 $pdf->ln(); 122 123 $pdf->SetFont('Arial','',9); 124 125 $pdf->cell($wc[1],$hligne,'Date'); 126 $pdf->cell($wc[2],$hligne,''); 127 $pdf->cell($wc[3],$hligne,'Compte'); 128 $pdf->cell($wc[4],$hligne,'Tiers'); 129 $pdf->cell($wc[5],$hligne,'Libellé'); 130 $pdf->cell($wc[6],$hligne,'Facture'); 131 $pdf->cell($wc[7],$hligne,'Montant',0,0,'R'); 132 $pdf->cell($wc[8],$hligne,''); 133 $pdf->cell($wc[9],$hligne,'Echeance',0,0,'R'); 134 135 $pdf->ln(); 136 137 $oldate = strftime("%d%m%Y",$obj->dp); 138 } 139 140 /* 141 * 142 */ 143 $socnom = $obj->nom; 144 $libelle = "Facture"; 145 $amount = abs($obj->amount); 146 $price = abs(price($obj->price)); 147 $tva = abs($obj->tva); 148 149 $facnumber = $obj->facnumber; 150 if (strlen(trim($obj->increment)) > 0) 151 { 152 $facnumber = $obj->increment; 153 } 154 155 if (strlen($obj->nom) > 31) 156 { 157 $socnom = substr($obj->nom, 0 , 31); 158 } 159 160 $pdf->SetFont('Arial','',9); 161 162 if ($obj->amount >= 0) 163 { 164 $d = "D"; 165 $c = "C"; 166 167 $credit = ''; 168 $debit = $amount; 169 $total_debit = $total_debit + $debit; 170 $grand_total_debit = $grand_total_debit + $debit; 171 172 } 173 else 174 { 175 $d = "C"; 176 $c = "D"; 177 178 $credit = $amount; 179 $debit = ''; 180 $total_credit = $total_credit + $credit; 181 $grand_total_credit = $grand_total_credit + $credit; 182 } 183 184 if ($oldfac <> $obj->facid) 185 { 186 $oldfac = $obj->facid; 187 188 $pdf->cell($wc[1],$hligne,strftime('%d%m%y',$obj->dp)); 189 $pdf->cell($wc[2],$hligne,'VI'); 190 $pdf->cell($wc[3],$hligne,'41100000'); 191 $pdf->cell($wc[4],$hligne,$obj->code_compta); 192 $pdf->cell($wc[5],$hligne,$socnom .' '.$libelle); 193 $pdf->cell($wc[6],$hligne,$facnumber); 194 $pdf->cell($wc[7],$hligne,$amount,0,0,'R'); 195 $pdf->cell($wc[8],$hligne,$d); 196 $pdf->cell($wc[9],$hligne,strftime('%d%m%y',$obj->dp),0,0,'R'); 197 $pdf->ln(); 198 199 $pdf->cell($wc[1],$hligne,strftime('%d%m%y',$obj->dp)); 200 $pdf->cell($wc[2],$hligne,'VI'); 201 $pdf->cell($wc[3],$hligne,'4457119'); 202 $pdf->cell($wc[4],$hligne,''); 203 $pdf->cell($wc[5],$hligne,$socnom .' '.$libelle); 204 $pdf->cell($wc[6],$hligne,$facnumber); 205 $pdf->cell($wc[7],$hligne,$tva,0,0,'R'); 206 $pdf->cell($wc[8],$hligne,$c); 207 $pdf->cell($wc[9],$hligne,strftime('%d%m%y',$obj->dp),0,0,'R'); 208 $pdf->ln(); 209 } 210 211 $pdf->cell($wc[1],$hligne,strftime('%d%m%y',$obj->dp)); 212 $pdf->cell($wc[2],$hligne,'VI'); 213 $pdf->cell($wc[3],$hligne,$obj->numero); 214 $pdf->cell($wc[4],$hligne,''); 215 $pdf->cell($wc[5],$hligne,$socnom .' '.$libelle); 216 $pdf->cell($wc[6],$hligne,$facnumber); 217 $pdf->cell($wc[7],$hligne,$price,0,0,'R'); 218 $pdf->cell($wc[8],$hligne,$c); 219 $pdf->cell($wc[9],$hligne,strftime('%d%m%y',$obj->dp),0,0,'R'); 220 $pdf->ln(); 221 222 $i++; 223 } 224 225 /* 226 * 227 * 228 */ 229 230 $pdf->Close(); 231 232 $pdf->Output($file); 233 234 $result = 0; 235 } 236 else 237 { 238 $result -1; 239 } 240 } 241 else 242 { 243 $result = -2; 244 } 245 246 return $result; 247 248 } 249 /* 250 * 251 * 252 */ 253 } 254 255 ?>
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 |
![]() |