00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00025
00026
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
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
00048 $montant=str_replace('.','',$row[6]);
00049
00050 $montant=str_replace(',','.',$montant);
00051
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
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 }
00089 $row++;
00090 }
00091 fclose($handle);
00092 echo "Encore rien désolé";
00093 ?>