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

argenta_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.5 $ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00025 //-----------------------------------------------------
00026 // Bank Argenta 
00027 //-----------------------------------------------------
00028 $line=1;
00029 
00030 while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) {
00031         $num = count($data);
00032 
00033         for ($c=0; $c < $num; $c++) {
00034           if ( $line==1) {
00035             $row=split(';',$data[$c]);
00036             $num_compte=$row[1];
00037           }
00038           
00039           if ( $line == 2 )
00040             continue;
00041 //-----------------------------------------------------
00042 // Parsing CSV comes here
00043 //-----------------------------------------------------
00044           $row=split(';',$data[$c]);
00045           echo_debug('argenta',__LINE__,'$row = '.var_export($row,true));
00046           echo_debug('argenta',__LINE__,'sizeof($row)'.sizeof($row));
00047           if ( sizeof ($row) < 9 )
00048             continue;
00049 
00050 
00051           $date_exec=$row[5];
00052           $date_val=$row[5];
00053           $code=$row[1]."/".$row[0];
00054           // remove first the thousand sep.
00055           $montant=str_replace('.','',$row[3]);
00056           // replace the coma by a period
00057           $montant=str_replace(',','.',$montant);
00058           // remove the sign
00059           $montant=str_replace('+','',$montant);
00060           $devise=$row[4];
00061           $compte_ordre=$row[6];
00062           $detail='virement du compte:'.$compte_ordre.trim($row[2]).' '.trim($row[7]).' '.trim($row[8]).' '.trim($row[9]);
00063 
00064 //----------------------------------------------------
00065 // Skip dubbel
00066 //----------------------------------------------------
00067 if ( CountSql($p_cn,"select * from import_tmp where code='$code' and num_compte='$num_compte' limit 2") != 0 )
00068 {
00069         /* Skip it it already encoded */
00070         echo "Doublon éliminé ".$detail;
00071         echo "<br>";
00072         continue;
00073 }
00074 echo "Ajout de $detail";
00075 echo "<br>";
00076 
00077 //-----------------------------------------------------
00078 // insert into import_tmp
00079 //-----------------------------------------------------
00080                         $Sql="insert into import_tmp (code,
00081                                 date_exec ,
00082                                 date_valeur,
00083                                 montant,
00084                                 devise,
00085                                 compte_ordre,
00086                                 num_compte,
00087                                 detail,
00088                                 bq_account ,
00089                                 jrn,
00090                                 status)
00091                         values ('$code',
00092                                 to_date('$date_exec','DD-MM-YYYY'),
00093                                 to_date('$date_exec','DD-MM-YYYY'),
00094                                 $montant,
00095                                 '$devise',
00096                                 '".addslashes($compte_ordre)."',        
00097                                 '".$num_compte."',
00098                                 '".addslashes($detail)."        ',
00099                                 '$p_bq_account',
00100                                 $p_jrn,
00101                                 'n')";
00102                         if ( ExecSql($p_cn,$Sql) == false )
00103                           {
00104                             Rollback($p_cn); break;
00105                           }
00106                 } // for ($c=0;$c<$num;$c++)
00107                $line++;
00108 } // file is read
00109 
00110 fclose($handle);
00111 
00112 ?>