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

fortis_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 // Fortis Bank
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                         
00039                         list($code, $date_exec, $date_valeur, $montant, $devise, $compte_ordre, $detail, $num_compte) = split(";", $data[$c]);
00040                         echo "line : $row > ".$data[$c]."<hr>";
00041                 
00042                         //corrige un bug de date
00043                         $date_exec = str_replace(chr(34),"", $date_exec);
00044                         
00045                         // Si LTXXXXX ou LT XXXXX dans le détail
00046                         if ((ereg ("LT+([0-9]{5})", $detail, $regs)) || (ereg ("LT+[ ]+([0-9]{5})", $detail, $regs))) {
00047                                 $iduser = $regs[1];
00048                         }
00049                         
00050                         // Si 00000XXXXXXX
00051                         if (ereg ("[0-9]{12}", $detail, $regs)){
00052                                 if($regs[0] != "000000000000") {
00053                                         $id = substr($regs[0], 5, 5);
00054                                         $check = substr($regs[0], 10, 2);
00055                                         if (($id % 97) == $check) $iduser = $id;
00056                                 }
00057                         }
00058                         
00059                         if($iduser != "" ) $poste_comptable = "400".$iduser;
00060                         else $poste_comptable = "";
00061                         
00062                         list($jour,$mois,$annee) = explode("/", $date_exec);  $date_exec = $annee."-".$mois."-".$jour;
00063                         list($jour,$mois,$annee) = explode("/", $date_valeur);  $date_valeur = $annee."-".$mois."-".$jour;
00064                         
00065                         $montant = str_replace(",", ".", $montant);
00066                         $montant = str_replace("+", "", $montant);
00067                         $montant = str_replace("\"", "", $montant);
00068                         
00069                         $detail=str_replace("\"","",$detail);
00070                 
00071                         $sql = "select * from import_tmp 
00072                                         where 
00073                                         code='".$code."' and 
00074                                         num_compte='".$num_compte."'";
00075                         $Res=ExecSql($p_cn,$sql);
00076                         $Num=pg_NumRows($Res);
00077                         
00078                         if($Num > 0) {
00079                                 echo "Op&eacute;ration FORTIS ".$code." d&eacute;j&eagrave; import&eacute;e.<br/>";
00080                         } else {
00081                         //      $Sql="insert into import_tmp values ('$code','$date_exec','$date_valeur','$montant','$devise','".addslashes($compte_ordre)."','".addslashes($detail)."','$num_compte','$poste_comptable')";
00082                                 $Sql="insert into import_tmp (code ,
00083                                         date_exec ,
00084                                         date_valeur,
00085                                         montant,
00086                                         devise,
00087                                         compte_ordre,
00088                                         detail,
00089                                         num_compte,
00090                                         bq_account ,
00091                                         jrn,
00092                                         status)
00093                                 values ('$code',
00094                                         '$date_exec',
00095                                         '$date_exec',
00096                                         '$montant',
00097                                         '$devise',
00098                                         '".addslashes($compte_ordre)."',        
00099                                         '".addslashes($detail)."',
00100                                         '$num_compte',
00101                                         $p_bq_account,
00102                                         $p_jrn,
00103                                         'n')";
00104                         
00105                                 $Res=ExecSql($p_cn,$Sql);
00106                         }
00107                 }
00108 
00109                 } // for ($c=0;$c<$num;$c++)
00110                 $row++;
00111 } // file is read
00112 fclose($handle);
00113 ?>