Main Page | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

ing_be.inc.php

Go to the documentation of this file.
00001 <?
00002 /*
00003  *   This file is part of PhpCompta.
00004  *
00005  *   PhpCompta is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   PhpCompta is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with PhpCompta; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 /* $Revision: 1.9 $ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00021 // Author Olivier Dzwoniarkiewicz
00026 //-----------------------------------------------------
00027 // Bank ING
00028 //-----------------------------------------------------
00029 $row=1;
00030 while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) {
00031         $num = count($data);
00032         for ($c=0; $c < $num; $c++) {
00033         
00034         // first line is skipped
00035         if ( $row > 1 ) {
00036                 
00037                 $code=""; $date_exec=""; $date_valeur=""; $montant=""; $devise=""; $compte_ordre=""; $detail=""; $num_compte=""; $iduser="";
00038                 list($num_compte, $code, $date_exec, $date_valeur, $montant, $devise, $montant2, $devise2, $rubriques, $detail, $zzz, $zzz, $date_comptable) = split(";", $data[$c]);
00039                 
00040                 # Bug CSV ING : "424 au lieu de 424
00041                 $code = str_replace("\"", "", $code);   
00042                 
00043                 # Bug CSV ING : espace après la date
00044                 $date_exec = str_replace(" ", "", $date_exec);
00045                 $date_valeur = str_replace(" ", "", $date_valeur);
00046                 $date_exec = str_replace("\"", "", $date_exec);
00047                 $date_valeur = str_replace("\"", "", $date_valeur);
00048                 $montant = str_replace("\"", "", $montant);
00049                 if ((ereg ("([0-9]{3})-([0-9]{7})-([0-9]{2})", $num_compte, $regs))){
00050                         $num_compte = $regs[0];
00051                 }
00052                 
00053                 // Si LTXXXXX ou LT XXXXX dans le détail
00054                 if ((ereg ("LT+([0-9]{5})", $detail, $regs)) || (ereg ("LT+[ ]+([0-9]{5})", $detail, $regs))) {
00055                         $iduser = $regs[1];
00056                 }
00057                 
00058                 // Si XXXXXXXXXXXX
00059                 if (ereg ("[0-9]{12}", $detail, $regs)){
00060                         if($regs[0] != "000000000000") {
00061                                 $id = substr($regs[0], 2, 5);
00062                                 $longchiffre = substr($regs[0], 0, 10);
00063                                 $check = substr($regs[0], 10, 2);
00064                                 if (($longchiffre % 97) == $check) $iduser = $id;
00065                         }
00066                 }
00067                 
00068                 if($iduser != "" ) $poste_comptable = "400".$iduser;
00069                 else $poste_comptable = "";
00070                 
00071                 list($jour,$mois,$annee) = explode("/", $date_valeur);  $date_valeur = $annee."-".$mois."-".$jour;
00072                 list($jour,$mois,$annee) = explode("/", $date_exec);  $date_exec = $annee."-".$mois."-".$jour;
00073                 
00074                 $montant = str_replace(",", ".", $montant);
00075                 $montant = str_replace("+", "", $montant);
00076                 
00077                 if($code < 10) $code = "000".$code;
00078                 if($code >= 10 and $code < 100) $code = "00".$code;
00079                 if($code >= 100) $code = "0".$code;
00080                 
00081                 $code = $annee."-".$code;
00082                 
00083                 $sql = "select * from import_tmp where code='".$code."' and num_compte='".$num_compte."'";
00084                 $Res=ExecSql($p_cn,$sql);
00085                 $Num=pg_NumRows($Res);
00086                 
00087                 if($Num > 0) {
00088                         echo "Op&eacute;ration FORTIS ".$code." d&eacute;j&eagrave; import&eacute;e.<br/>";
00089                 } else {
00090                         //echo $code." ".$date_exec." ".$date_valeur." ".$montant." ".$devise." ".$compte_ordre." detail ".$num_compte." <b>".$poste_comptable."</b><br/>";
00091                         //$Sql="insert into import_tmp values ('$code','$date_exec','$date_valeur','$montant','$devise','".addslashes($compte_ordre)."','".addslashes($detail)."','$num_compte','$poste_comptable')";
00092                         $Sql="insert into import_tmp (code,
00093                                 date_exec ,
00094                                 date_valeur,
00095                                 montant,
00096                                 devise,
00097                                 compte_ordre,
00098                                 detail,
00099                                 bq_account ,
00100                                 jrn,
00101                                 status)
00102                         values ('$code',
00103                                 '$date_exec',
00104                                 '$date_exec',
00105                                 $montant,
00106                                 '$devise',
00107                                 '".addslashes($compte_ordre)."',        
00108                                 '".addslashes($detail).$num_compte."    ',
00109                                 '$p_bq_account',
00110                                 $p_jrn,
00111                                 'n')";
00112         echo $sql;
00113                         $Res=ExecSql($p_cn,$Sql);
00114                 }
00115         }
00116 
00117                 } // for ($c=0;$c<$num;$c++)
00118                 $row++;
00119 } // file is read
00120 fclose($handle);
00121 ?>