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

cbc_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
00025 //-----------------------------------------------------
00026 // Bank CBC 
00027 //-----------------------------------------------------
00028 $row=1;
00029 StartSql($p_cn);
00030 while (($data = fgetcsv($handle, 2000,'!@')) !== FALSE) {
00031         $num = count($data);
00032         echo_debug('cbc_be',__LINE__,$num);
00033         echo_debug('cbc_be',__LINE__,var_export($data,true));
00034         for ($c=0; $c < $num; $c++) {
00035 //-----------------------------------------------------
00036 // Parsing CSV comes here
00037 //-----------------------------------------------------
00038           $row=split(';',$data[$c]);
00039           echo_debug('cbc_be',__LINE__,'$row = '.var_export($row,true));
00040           echo_debug('cbc_be',__LINE__,'sizeof($row)'.sizeof($row));
00041           if ( sizeof ($row) < 13 )
00042             continue;
00043 
00044           $num_compte=$row[0];
00045           $date_exec=$row[3];
00046           $date_val=$row[4];
00047           // remove first the thousand sep.
00048           $montant=str_replace('.','',$row[6]);
00049           // replace the coma by a period
00050           $montant=str_replace(',','.',$montant);
00051           // remove the sign
00052           $montant=str_replace('+','',$montant);
00053           $devise=$row[1];
00054           $compte_ordre=$row[0];
00055           $detail=trim($row[7]).' '.trim($row[8]).' '.trim($row[9]).' '.trim($row[10]);
00056           if (  ereg('[0-9]{3}-[0-9]{7}-[0-9]{2}',$row[7],$r) )
00057             {
00058               $compte_ordre=$r[0];
00059             }
00060 //-----------------------------------------------------
00061 // insert into import_tmp
00062 //-----------------------------------------------------
00063                         $Sql="insert into import_tmp (code,
00064                                 date_exec ,
00065                                 date_valeur,
00066                                 montant,
00067                                 devise,
00068                                 compte_ordre,
00069                                 detail,
00070                                 bq_account ,
00071                                 jrn,
00072                                 status)
00073                         values (nextval('s_cbc'),
00074                                 to_date('$date_exec','YYYYMMDD'),
00075                                 to_date('$date_exec','YYYYMMDD'),
00076                                 $montant,
00077                                 '$devise',
00078                                 '".addslashes($compte_ordre)."',        
00079                                 '".addslashes($detail).$num_compte."    ',
00080                                 '$p_bq_account',
00081                                 $p_jrn,
00082                                 'n')";
00083                         if ( ExecSql($p_cn,$Sql) == false )
00084                           {
00085                             Rollback($p_cn);
00086                             break;
00087                           }
00088                 } // for ($c=0;$c<$num;$c++)
00089                 $row++;
00090 } // file is read
00091 fclose($handle);
00092 echo "Encore rien désolé";
00093 ?>