[ Index ] |
|
Code source de Dolibarr 2.0.1 |
1 <?PHP 2 /* Copyright (C) 2004-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 * 18 * $Id: compta.export.class.php,v 1.11 2005/07/10 20:26:11 eldy Exp $ 19 * $Source: /cvsroot/dolibarr/dolibarr/htdocs/compta/export/modules/compta.export.class.php,v $ 20 */ 21 22 /** 23 \file htdocs/compta/export/modules/compta.export.class.php 24 \ingroup compta 25 \brief Fichier de la classe d'export compta 26 \version $Revision: 1.11 $ 27 */ 28 29 30 /** 31 \class ComptaExport 32 \brief Classe permettant les exports comptables 33 */ 34 35 class ComptaExport 36 { 37 38 /** 39 \brief Constructeur de la class 40 \param DB Object de base de données 41 \param USER Object utilisateur 42 \param classe Nom de la classe utilisée pour formater les rapports 43 */ 44 function ComptaExport ($DB, $USER, $classe) 45 { 46 $this->db = $DB; 47 $this->user = $USER; 48 $this->classe_export = $classe; 49 $this->error_message = ''; 50 } 51 52 53 /** 54 \brief Lecture des factures dans la base 55 \param id Id ligne 56 */ 57 function ReadLines($id=0) 58 { 59 dolibarr_syslog("ComptaExport::ReadLines id=".$id); 60 61 $error = 0; 62 63 $sql = "SELECT f.rowid as facid, f.facnumber, ".$this->db->pdate("f.datef")." as datef"; 64 $sql .= " , f.total_ttc, f.tva "; 65 $sql .= " ,s.nom, s.code_compta"; 66 $sql .= " , l.price, l.tva_taux"; 67 $sql .= " , c.numero, f.increment"; 68 $sql .= " , l.rowid as lrowid"; 69 70 $sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l"; 71 $sql .= " , ".MAIN_DB_PREFIX."facture as f"; 72 $sql .= " , ".MAIN_DB_PREFIX."societe as s"; 73 $sql .= " , ".MAIN_DB_PREFIX."compta_compte_generaux as c"; 74 75 $sql .= " WHERE f.rowid = l.fk_facture "; 76 $sql .= " AND s.idp = f.fk_soc"; 77 $sql .= " AND f.fk_statut = 1 "; 78 79 $sql .= " AND l.fk_code_ventilation <> 0 "; 80 81 $sql .= " AND l.fk_export_compta = ".$id; 82 83 $sql .= " AND c.rowid = l.fk_code_ventilation"; 84 85 $sql .= " ORDER BY f.rowid ASC, l.fk_code_ventilation ASC"; 86 87 88 $resql = $this->db->query($sql); 89 90 if ($resql) 91 { 92 $num = $this->db->num_rows($resql); 93 $i = 0; 94 $this->linec = array(); 95 96 while ($i < $num) 97 { 98 $obj = $this->db->fetch_object($resql); 99 100 $this->linec[$i][0] = $obj->datef; 101 $this->linec[$i][1] = $obj->facid; 102 $this->linec[$i][2] = $obj->code_compta; 103 $this->linec[$i][3] = $obj->nom; 104 $this->linec[$i][4] = $obj->numero; 105 $this->linec[$i][5] = $obj->facnumber; 106 $this->linec[$i][6] = $obj->tva; 107 $this->linec[$i][7] = $obj->total_ttc; 108 $this->linec[$i][8] = $obj->price; 109 $this->linec[$i][9] = $obj->increment; 110 $this->linec[$i][10] = $obj->lrowid; 111 112 if ($obj->code_compta == '') 113 { 114 $this->error_message .= "Code compta non valide pour $obj->nom<br>"; 115 $error++; 116 } 117 118 $i++; 119 } 120 $this->db->free($resql); 121 } 122 123 return $error; 124 } 125 126 /** 127 \brief Lecture des paiements dans la base 128 \param id Id ligne 129 */ 130 131 function ReadLinesPayment($id=0) 132 { 133 dolibarr_syslog("ComptaExport::ReadLinesPayment id=".$id); 134 $error = 0; 135 136 $sql = "SELECT p.rowid as paymentid, f.facnumber"; 137 $sql .= " ,".$this->db->pdate("p.datep")." as datep"; 138 $sql .= " , pf.amount"; 139 $sql .= " , s.nom, s.code_compta"; 140 $sql .= " , cp.libelle, f.increment"; 141 142 $sql .= " FROM ".MAIN_DB_PREFIX."paiement as p"; 143 $sql .= " , ".MAIN_DB_PREFIX."paiement_facture as pf"; 144 $sql .= " , ".MAIN_DB_PREFIX."c_paiement as cp"; 145 $sql .= " , ".MAIN_DB_PREFIX."facture as f"; 146 $sql .= " , ".MAIN_DB_PREFIX."societe as s"; 147 148 $sql .= " WHERE p.fk_export_compta = ".$id; 149 $sql .= " AND p.rowid = pf.fk_paiement"; 150 $sql .= " AND cp.id = p.fk_paiement"; 151 $sql .= " AND f.rowid = pf.fk_facture"; 152 $sql .= " AND f.fk_soc = s.idp"; 153 $sql .= " AND p.statut = 1 "; 154 155 $sql .= " ORDER BY f.rowid ASC, p.rowid ASC"; 156 157 $resql = $this->db->query($sql); 158 159 if ($resql) 160 { 161 $num = $this->db->num_rows($resql); 162 $i = 0; 163 $this->linep = array(); 164 165 while ($i < $num) 166 { 167 $obj = $this->db->fetch_object($resql); 168 169 $this->linep[$i][0] = $obj->datep; 170 $this->linep[$i][1] = $obj->paymentid; 171 $this->linep[$i][2] = $obj->code_compta; 172 $this->linep[$i][3] = $obj->nom; 173 $this->linep[$i][4] = $obj->facnumber; 174 $this->linep[$i][5] = $obj->amount; 175 $this->linep[$i][6] = $obj->libelle; 176 177 if (strlen(trim( $obj->increment)) > 0) 178 { 179 $this->linep[$i][7] = $obj->increment; 180 } 181 else 182 { 183 $this->linep[$i][7] = $obj->facnumber; 184 } 185 186 $i++; 187 } 188 189 $this->db->free($resql); 190 191 } 192 else 193 { 194 $error++; 195 } 196 197 return $error; 198 } 199 200 /** 201 \brief Créé le fichier d'export 202 */ 203 204 function Export($id=0) 205 { 206 $error = 0; 207 208 dolibarr_syslog("ComptaExport::Export"); 209 210 $error += $this->ReadLines($id); 211 $error += $this->ReadLinesPayment($id); 212 213 dolibarr_syslog("ComptaExport::Export Lignes de factures : ".sizeof($this->linec)); 214 dolibarr_syslog("ComptaExport::Export Lignes de paiements : ".sizeof($this->linep)); 215 216 if (!$error && (sizeof($this->linec) > 0 || sizeof($this->linep) > 0)) 217 { 218 include_once DOL_DOCUMENT_ROOT.'/compta/export/modules/compta.export.'.strtolower($this->classe_export).'.class.php'; 219 220 $objexport_name = "ComptaExport".$this->classe_export; 221 222 $objexport = new $objexport_name($this->db, $this->user); 223 224 $objexport->Export($this->linec, $this->linep, $id); 225 226 $this->id = $objexport->id; 227 $this->ref = $objexport->ref; 228 } 229 } 230 231 }
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 |
![]() |