Go to the source code of this file.
Functions | |
ImportCSV ($p_cn, $file, $p_bq_account, $p_format_csv, $p_jrn) | |
Parse the file and insert the record into the table import_tmp. Insert in a temporary table, if no confirmation is given then the data are removed otherwise records are inserted into import_tmp. Following the choosen bank a different file is included to to parse the CSV, take the cbc_be.inc.php as template. | |
UpdateCSV ($p_cn) | |
Update import_tmp with the bank account. | |
ShowBox ($p_val, $counter, $p_cn, $p_form='form') | |
This function show a record from the table import_tmp, the tag for the form are not included in the function and must set in the calling proc. | |
RemoveCSV ($cn) | |
Remove the record from the transfert list, the data are in $_POST import_tmp.status is set to n for new. | |
VerifImport ($p_cn) | |
Verify the import. | |
ConfirmTransfert ($p_cn, $periode) | |
ConfirmCSV shows the operation which are going to be transfered. | |
TransferCSV ($p_cn, $periode) | |
Transfert data into the ledger set the column import_tmp.status to w (wait) if the account is not correct otherwise transfert it to the ledger and set the column import_tmp.status to t (transfert). | |
ShowFormTransfert ($p_cn) | |
ShowForm for getting data about the bank transfert in cvs. | |
DropRecord ($p_cn, $p_code) | |
RemoveRow put a flag delete on a row of the table import_tmp (import_tmp.status). |
|
ConfirmCSV shows the operation which are going to be transfered.
Definition at line 159 of file import_inc.php. References $end, $i, $Num, $Res, $sql, $start, $val, ExecSql(), exit, name, ShowBox(), and value. 00159 { 00160 $sql = "select to_char(p_start,'DD-MM-YYYY') as p_start,to_char(p_end,'DD-MM-YYYY') as p_end". 00161 " from parm_periode where p_id = '".$periode."'"; 00162 $Res=ExecSql($p_cn,$sql); 00163 $val = pg_fetch_array($Res); 00164 if ( $val == false ) 00165 { 00166 echo "<script>". 00167 "alert ('Vous devez selectionner votre période dans vos préférences');". 00168 "</script>"; 00169 exit(); 00170 } 00171 $start ="to_date('".$val['p_start']."','DD-MM-YYYY')"; 00172 $end = "to_date('".$val['p_end']."','DD-MM-YYYY')"; 00173 00174 $sql = "select code,to_char(date_exec,'DD.MM.YYYY') as date_exec, ". 00175 " montant,num_compte,poste_comptable,bq_account,jrn,detail ". 00176 " from import_tmp where 00177 status = 'w' AND date_exec BETWEEN ".$start." and ".$end; 00178 00179 00180 00181 $Res=ExecSql($p_cn,$sql); 00182 $Num=pg_NumRows($Res); 00183 echo $Num." opérations à transfèrer.<br/><br/>"; 00184 if ( $Num == 0 ) return; 00185 $i=1; 00186 while($val = pg_fetch_array($Res)){ 00187 00188 echo '<form method="post" action="import.php">'; 00189 echo '<input type="hidden" name="action" value="remove">'; 00190 ShowBox($val,$i,$p_cn,'remove'); 00191 echo '</form>'; 00192 $i++; 00193 } 00194 echo '<form method="post" action="import.php">'; 00195 echo '<input type="hidden" name="action" value="transfer">'; 00196 echo '<input type="submit" name="sub" value="Commencer le transfert">'; 00197 echo '</form>'; 00198 00199 }
|
|
RemoveRow put a flag delete on a row of the table import_tmp (import_tmp.status).
Definition at line 337 of file import_inc.php. References ExecSql(). 00338 { 00339 ExecSql($p_cn,"update import_tmp set status='d' where code='".$p_code."'"); 00340 }
|
|
Parse the file and insert the record into the table import_tmp. Insert in a temporary table, if no confirmation is given then the data are removed otherwise records are inserted into import_tmp. Following the choosen bank a different file is included to to parse the CSV, take the cbc_be.inc.php as template.
Definition at line 43 of file import_inc.php. References Commit(), print, and StartSql(). 00044 { 00045 if(!$handle = fopen($file, "r")) { 00046 print 'could not open file. quitting'; 00047 die; 00048 } 00049 00050 StartSql($p_cn); 00051 00052 00053 // include the right format for CSV --> given by the <form 00054 include($p_format_csv); 00055 00056 00057 echo "Importation terminée."; 00058 00059 // if importation succeeds then we can commit the change 00060 Commit($p_cn); 00061 00062 }
|
|
Remove the record from the transfert list, the data are in $_POST import_tmp.status is set to n for new.
Definition at line 128 of file import_inc.php. References $sql, and ExecSql(). 00129 { 00130 $sql="update import_tmp set poste_comptable=null,status='n' where code='".$_POST['code']."'"; 00131 ExecSql($cn,$sql); 00132 }
|
|
This function show a record from the table import_tmp, the tag for the form are not included in the function and must set in the calling proc.
Definition at line 85 of file import_inc.php. References $cn, $p_val, $w, DbConnect(), fiche, name, table, value, and width. Referenced by ConfirmTransfert(), and VerifImport(). 00085 { 00086 00087 $w=new widget('js_search_only'); 00088 $w->name='poste'.$counter; 00089 $w->extra='cred'; 00090 $w->extra2=$p_val['jrn']; 00091 $w->label=''; 00092 $w->table=0; 00093 if ( $p_form == 'remove' ) 00094 $w->readonly=true; 00095 00096 $s=new widget('span'); 00097 00098 if ( isset($p_val['poste_comptable'])) 00099 { 00100 $w->value=$p_val['poste_comptable']; 00101 $cn=DbConnect($_SESSION['g_dossier']); 00102 $f=new fiche($p_cn); 00103 $f->GetByQCode($p_val['poste_comptable']); 00104 $s->value=$f->strAttribut(ATTR_DEF_NAME); 00105 } 00106 echo '<input type="hidden" name="code" value="'.$p_val['code'].'">'; 00107 echo '<input type="hidden" name="count" value="'.$counter.'">'; 00108 echo '<table border="1" width="500">'; 00109 echo '<tr><td width="200">'.$p_val['code'].'</td><td width="200">'.$p_val['date_exec'].'</td><td width="100">'.$p_val['montant'].' EUR</td><tr/>'; 00110 echo "<tr><td> Journal : ".GetJrnName($p_cn,$p_val['jrn'])."</TD><TD>poste comptable Destination : ".$p_val['bq_account']."</td><tr>"; 00111 echo '<tr><td height="50" colspan="3">'.$p_val['detail'].'</td><tr/>'; 00112 echo '<tr><td>'.$w->IOValue().' '.$s->IOValue('poste'.$counter.'_label').'</td>'; 00113 echo "<td>n° compte : ".$p_val['num_compte']."</td>"; 00114 if ( $p_form == 'form') { 00115 echo '<td><input type="submit" value="Modifier">'; 00116 echo '<input type="submit" name="trashit" value="Effacer.."></td><tr/>'; 00117 } 00118 if ($p_form == 'remove' ) 00119 echo '<td><input type="submit" value="Enlever"></td><tr/>'; 00120 00121 echo '</table>'; 00122 00123 }
|
|
ShowForm for getting data about the bank transfert in cvs.
Definition at line 313 of file import_inc.php. References $jrn, $w, make_array(), METHOD, name, and size. 00313 { 00314 $w=new widget("select"); 00315 echo '<FORM METHOD="POST" action="import.php?action=import" enctype="multipart/form-data">'; 00316 echo '<INPUT TYPE="file" name="fupload" size="20"><br>'; 00317 // ask for the journal target 00318 $jrn=make_array ($p_cn,"select jrn_def_id,jrn_def_name from jrn_def where jrn_def_type='FIN';"); 00319 $w->label='Journal'; 00320 echo $w->label." :".$w->IOValue('import_jrn',$jrn)."<br>"; 00321 // choose the bank account 00322 $bq=make_array($p_cn,"select pcm_val,pcm_lib from tmp_pcmn where pcm_val like '550%'"); 00323 $w->label='Banque'; 00324 echo "Compte en banque :".$w->IOValue('import_bq',$bq)."<br>"; 00325 $format_csv=make_array($p_cn,"select include_file,name from format_csv_banque;"); 00326 $w->label="Format import"; 00327 echo $w->label.$w->IOValue('format_csv',$format_csv).'<br>'; 00328 echo '<INPUT TYPE="SUBMIT" Value="Import fiche">'; 00329 echo '</FORM>'; 00330 }
|
|
Transfert data into the ledger set the column import_tmp.status to w (wait) if the account is not correct otherwise transfert it to the ledger and set the column import_tmp.status to t (transfert).
Definition at line 209 of file import_inc.php. References $_SESSION, $code, $date_exec, $detail, $end, $jrn, $Max, $montant, $num_compte, $poste_comptable, $r, $Res, $Res2, $seq, $sql, $start, $User, $val, Commit(), ExecSql(), exit, fiche, InsertJrn(), InsertJrnx(), NextSequence(), Rollback(), SetInternalCode(), and StartSql(). 00209 { 00210 //on obtient la période courante 00211 $User=new cl_user($p_cn); 00212 $periode = $User->GetPeriode(); 00213 // on trouve les dates frontières de cette période 00214 $sql = "select to_char(p_start,'DD-MM-YYYY') as p_start,to_char(p_end,'DD-MM-YYYY') as p_end". 00215 " from parm_periode where p_id = '".$periode."'"; 00216 $Res=ExecSql($p_cn,$sql); 00217 $val = pg_fetch_array($Res); 00218 if ( $val == false ) 00219 { 00220 echo "<script>". 00221 "alert ('Vous devez selectionner votre période dans vos préférences');". 00222 "</script>"; 00223 exit(); 00224 } 00225 $start ="to_date('".$val['p_start']."','DD-MM-YYYY')"; 00226 $end = "to_date('".$val['p_end']."','DD-MM-YYYY')"; 00227 // var_dump($val); 00228 $sql = "select code,to_char(date_exec,'DD.MM.YYYY') as date_exec, ". 00229 " montant,num_compte,poste_comptable,bq_account,jrn,detail ". 00230 " from import_tmp where ". 00231 " status= 'w' AND date_exec BETWEEN ".$start." and ".$end; 00232 $Res=ExecSql($p_cn,$sql); 00233 //echo "boucle: ".sizeof($Res)."<br/>"; 00234 //while($val = pg_fetch_array($Res)){ 00235 $Max=pg_NumRows($Res); 00236 echo $Max." opérations à transférer.<br/>"; 00237 StartSql($p_cn); 00238 00239 for ($i = 0;$i < $Max;$i++) { 00240 $val=pg_fetch_array($Res,$i); 00241 00242 $code=$val['code']; $date_exec=$val['date_exec']; $montant=$val['montant']; $num_compte=$val['num_compte']; 00243 $poste_comptable=$val['poste_comptable'];$bq_account=$val['bq_account']; 00244 $jrn=$val['jrn']; $detail=$val['detail']; 00245 00246 // Retrieve the account thx the quick code 00247 $f=new fiche($p_cn); 00248 $f->GetByQCode($poste_comptable,false); 00249 $poste_comptable=$f->strAttribut(ATTR_DEF_ACCOUNT); 00250 00251 // Vérification que le poste comptable trouvé existe 00252 if ( $poste_comptable == '- ERROR -') 00253 $test=0; 00254 else 00255 { 00256 $sqltest = "select * from tmp_pcmn WHERE pcm_val='".$poste_comptable."'"; 00257 00258 $Restest=ExecSql($p_cn,$sqltest); 00259 $test=pg_NumRows($Restest); 00260 } 00261 00262 // Test it 00263 if($test == 0) { 00264 $sqlupdate = "update import_tmp set status='n' WHERE code='".$code."' AND num_compte='".$num_compte."' or num_compte is null"; 00265 $Resupdate=ExecSql($p_cn,$sqlupdate); 00266 echo "Poste comptable erronné pour l'opération ".$num_compte."-".$code.", réinitialisation du poste comptable<br/>"; 00267 continue; 00268 } 00269 00270 00271 // Finances 00272 00273 $seq=NextSequence($p_cn,'s_grpt'); 00274 $p_user = $_SESSION['g_user']; 00275 00276 $r=InsertJrnx($p_cn,"d",$p_user,$jrn,$bq_account,$date_exec,$montant,$seq,$periode); 00277 if ( $r == false) { $Rollback($p_cn);exit("error 'import_inc.php' __LINE__");} 00278 00279 $r=InsertJrnx($p_cn,"c",$p_user,$jrn,$poste_comptable,$date_exec,$montant,$seq,$periode); 00280 if ( $r == false) { $Rollback($p_cn);exit("error 'import_inc.php' __LINE__");} 00281 00282 //remove annoying double-quote 00283 $num_compte=str_replace('"','',$num_compte); 00284 $code=str_replace('\"','',$code); 00285 if ( strlen(trim($num_compte)) == 0 ) 00286 $num_compte=$val['detail']; 00287 00288 $r=InsertJrn($p_cn,$date_exec,NULL,$jrn,$detail.$num_compte." ".$code,$montant,$seq,$periode); 00289 if ( $r == false ) { Rollback($p_cn); exit(" Error 'import_inc.php' __LINE__");} 00290 00291 SetInternalCode($p_cn,$seq,$jrn); 00292 00293 00294 echo "Tranfer de l'opération ".$code." effectué<br/>"; 00295 $sql2 = "update import_tmp set status='t' where code='".$code."'"; 00296 $Res2=ExecSql($p_cn,$sql2); 00297 00298 00299 } 00300 Commit($p_cn); 00301 00302 }
|
|
Update import_tmp with the bank account.
Definition at line 66 of file import_inc.php. References $code, $count, $poste, $Res, $sql, and ExecSql(). 00066 { 00067 $code=$_POST['code']; 00068 $count=$_POST['count']; 00069 $poste=$_POST['poste'.$count]; 00070 $sql = "update import_tmp set poste_comptable='".$poste."' ,status='w' where code='".$code."'"; 00071 $Res=ExecSql($p_cn,$sql); 00072 }
|
|
Verify the import.
Definition at line 137 of file import_inc.php. References $i, $Num, $Res, $sql, $val, ExecSql(), METHOD, and ShowBox(). 00137 { 00138 $sql = "select * from import_tmp where status='n' ". 00139 " order by date_exec,code"; 00140 $Res=ExecSql($p_cn,$sql); 00141 $Num=pg_NumRows($Res); 00142 echo $Num." opérations à complèter.<br/><br/>"; 00143 $i=1; 00144 // include javascript for popup 00145 echo JS_SEARCH_CARD; 00146 while($val = pg_fetch_array($Res)){ 00147 echo '<form METHOD="POST" action="import.php?action=verif">'; 00148 ShowBox($val,$i,$p_cn,'form'); 00149 echo '</form>'; 00150 $i++; 00151 } 00152 00153 }
|