altocompta/doc/developper/html/import__inc_8php-source.html
2006-07-12 21:24:48 +00:00

284 lines
33 KiB
HTML
Raw Blame History

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
<title>phpcompta: import_inc.php Source File</title>
<link href="doxygen.css" rel="stylesheet" type="text/css">
</head><body>
<!-- Generated by Doxygen 1.4.4 -->
<div class="qindex"><a class="qindex" href="index.html">Main&nbsp;Page</a> | <a class="qindex" href="namespaces.html">Namespace List</a> | <a class="qindex" href="hierarchy.html">Class&nbsp;Hierarchy</a> | <a class="qindex" href="annotated.html">Data&nbsp;Structures</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File&nbsp;List</a> | <a class="qindex" href="functions.html">Data&nbsp;Fields</a> | <a class="qindex" href="globals.html">Globals</a> | <a class="qindex" href="pages.html">Related&nbsp;Pages</a></div>
<div class="nav">
<a class="el" href="dir_000000.html">include</a></div>
<h1>import_inc.php</h1><a href="import__inc_8php.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 &lt;?
<a name="l00002"></a>00002 <span class="comment">/*</span>
<a name="l00003"></a>00003 <span class="comment"> * This file is part of PhpCompta.</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> * PhpCompta is free software; you can redistribute it and/or modify</span>
<a name="l00006"></a>00006 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00007"></a>00007 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00008"></a>00008 <span class="comment"> * (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment"> *</span>
<a name="l00010"></a>00010 <span class="comment"> * PhpCompta is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00013"></a>00013 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment"> *</span>
<a name="l00015"></a>00015 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00016"></a>00016 <span class="comment"> * along with PhpCompta; if not, write to the Free Software</span>
<a name="l00017"></a>00017 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00018"></a>00018 <span class="comment">*/</span>
<a name="l00019"></a>00019
<a name="l00020"></a>00020 <span class="comment">// Copyright Author Olivier Dzwoniarkiewicz</span>
<a name="l00021"></a>00021 <span class="comment">// Modified Dany De Bontridder ddebontridder@yahoo.fr</span>
<a name="l00022"></a>00022 <span class="comment">// $Revision$</span>
<a name="l00023"></a>00023 include_once(<span class="stringliteral">"jrn.php"</span>);
<a name="l00024"></a>00024 include_once(<span class="stringliteral">"preference.php"</span>);
<a name="l00025"></a>00025 include_once(<span class="stringliteral">"user_common.php"</span>);
<a name="l00026"></a>00026 require_once('class_user.php');
<a name="l00027"></a>00027 require_once('class_widget.php');
<a name="l00028"></a>00028 require_once('class_fiche.php');
<a name="l00043"></a><a class="code" href="import__inc_8php.html#a0">00043</a> function <a class="code" href="import__inc_8php.html#a0">ImportCSV</a>($p_cn,$file,$p_bq_account,$p_format_csv,$p_jrn)
<a name="l00044"></a>00044 {
<a name="l00045"></a>00045 <span class="keywordflow">if</span>(!$handle = fopen($file, <span class="stringliteral">"r"</span>)) {
<a name="l00046"></a>00046 <a class="code" href="impress__bilan_8php.html#a3">print</a> 'could not open file. quitting';
<a name="l00047"></a>00047 die;
<a name="l00048"></a>00048 }
<a name="l00049"></a>00049
<a name="l00050"></a>00050 <a class="code" href="postgres_8php.html#a14">StartSql</a>($p_cn);
<a name="l00051"></a>00051
<a name="l00052"></a>00052
<a name="l00053"></a>00053 <span class="comment">// include the right format for CSV --&gt; given by the &lt;form</span>
<a name="l00054"></a>00054 include($p_format_csv);
<a name="l00055"></a>00055
<a name="l00056"></a>00056
<a name="l00057"></a>00057 echo <span class="stringliteral">"Importation termin<69>e."</span>;
<a name="l00058"></a>00058
<a name="l00059"></a>00059 <span class="comment">// if importation succeeds then we can commit the change</span>
<a name="l00060"></a>00060 <a class="code" href="postgres_8php.html#a16">Commit</a>($p_cn);
<a name="l00061"></a>00061
<a name="l00062"></a>00062 }
<a name="l00066"></a><a class="code" href="import__inc_8php.html#a1">00066</a> function <a class="code" href="import__inc_8php.html#a1">UpdateCSV</a>($p_cn){
<a name="l00067"></a>00067 <a class="code" href="argenta__be_8inc_8php.html#a5">$code</a>=$_POST['code'];
<a name="l00068"></a>00068 <a class="code" href="admin__repo_8php.html#a13">$count</a>=$_POST['count'];
<a name="l00069"></a>00069 <a class="code" href="send__poste__pdf_8php.html#a2">$poste</a>=$_POST['<a class="code" href="classposte.html">poste</a>'.$count];
<a name="l00070"></a>00070 <a class="code" href="bank_8inc_8php.html#a20">$sql</a> = <span class="stringliteral">"update import_tmp set poste_comptable='"</span>.$poste.<span class="stringliteral">"' where code='"</span>.<a class="code" href="argenta__be_8inc_8php.html#a5">$code</a>.<span class="stringliteral">"'"</span>;
<a name="l00071"></a>00071 <a class="code" href="depense_8inc_8php.html#a4">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00072"></a>00072 }
<a name="l00073"></a>00073
<a name="l00074"></a>00074
<a name="l00075"></a>00075
<a name="l00076"></a>00076
<a name="l00084"></a><a class="code" href="import__inc_8php.html#a2">00084</a> function <a class="code" href="import__inc_8php.html#a2">ShowBox</a>($p_val,$counter,$p_form='form'){
<a name="l00085"></a>00085
<a name="l00086"></a>00086 <a class="code" href="admin_8inc_8php.html#a4">$w</a>=<span class="keyword">new</span> <a class="code" href="classwidget.html">widget</a>('js_search_only');
<a name="l00087"></a>00087 <a class="code" href="admin_8inc_8php.html#a4">$w</a>-&gt;name='<a class="code" href="classposte.html">poste</a>'.$counter;
<a name="l00088"></a>00088 <a class="code" href="admin_8inc_8php.html#a4">$w</a>-&gt;extra='cred';
<a name="l00089"></a>00089 <a class="code" href="admin_8inc_8php.html#a4">$w</a>-&gt;extra2=<a class="code" href="line__update_8php.html#a4">$p_val</a>['<a class="code" href="classjrn.html">jrn</a>'];
<a name="l00090"></a>00090 <a class="code" href="admin_8inc_8php.html#a4">$w</a>-&gt;label='';
<a name="l00091"></a>00091 <a class="code" href="admin_8inc_8php.html#a4">$w</a>-&gt;table=0;
<a name="l00092"></a>00092 <span class="keywordflow">if</span> ( $p_form == 'remove' )
<a name="l00093"></a>00093 <a class="code" href="admin_8inc_8php.html#a4">$w</a>-&gt;readonly=<span class="keyword">true</span>;
<a name="l00094"></a>00094
<a name="l00095"></a>00095 $s=<span class="keyword">new</span> <a class="code" href="classwidget.html">widget</a>('span');
<a name="l00096"></a>00096
<a name="l00097"></a>00097 <span class="keywordflow">if</span> ( isset($p_val['poste_comptable']))
<a name="l00098"></a>00098 {
<a name="l00099"></a>00099 <a class="code" href="admin_8inc_8php.html#a4">$w</a>-&gt;value=<a class="code" href="line__update_8php.html#a4">$p_val</a>['poste_comptable'];
<a name="l00100"></a>00100 <a class="code" href="impress__fiche_8php.html#a0">$cn</a>=<a class="code" href="postgres_8php.html#a1">DbConnect</a>($_SESSION['g_dossier']);
<a name="l00101"></a>00101 $f=<span class="keyword">new</span> <a class="code" href="user__impress_8php.html#a10">fiche</a>($cn);
<a name="l00102"></a>00102 $f-&gt;GetByQCode($p_val['poste_comptable']);
<a name="l00103"></a>00103 $s-&gt;value=$f-&gt;strAttribut(<a class="code" href="constant_8php.html#a56">ATTR_DEF_NAME</a>);
<a name="l00104"></a>00104 }
<a name="l00105"></a>00105 echo '&lt;input type=<span class="stringliteral">"hidden"</span> <a class="code" href="action_8inc_8php.html#a18">name</a>=<span class="stringliteral">"code"</span> <a class="code" href="action_8inc_8php.html#a19">value</a>=<span class="stringliteral">"'.$p_val['code'].'"</span>&gt;';
<a name="l00106"></a>00106 echo '&lt;input type=<span class="stringliteral">"hidden"</span> <a class="code" href="action_8inc_8php.html#a18">name</a>=<span class="stringliteral">"count"</span> <a class="code" href="action_8inc_8php.html#a19">value</a>=<span class="stringliteral">"'.$counter.'"</span>&gt;';
<a name="l00107"></a>00107 echo '&lt;<a class="code" href="balance_8php.html#a3">table</a> border=<span class="stringliteral">"1"</span> <a class="code" href="tva_8inc_8php.html#a17">width</a>=<span class="stringliteral">"500"</span>&gt;';
<a name="l00108"></a>00108 echo '&lt;tr&gt;&lt;td <a class="code" href="tva_8inc_8php.html#a17">width</a>=<span class="stringliteral">"200"</span>&gt;'.$p_val['code'].'&lt;/td&gt;&lt;td width=<span class="stringliteral">"200"</span>&gt;'.$p_val['date_exec'].'&lt;/td&gt;&lt;td width=<span class="stringliteral">"100"</span>&gt;'.$p_val['montant'].' EUR&lt;/td&gt;&lt;tr/&gt;';
<a name="l00109"></a>00109 echo '&lt;tr&gt;&lt;td height=<span class="stringliteral">"50"</span> colspan=<span class="stringliteral">"3"</span>&gt;'.$p_val['detail'].'&lt;/td&gt;&lt;tr/&gt;';
<a name="l00110"></a>00110 echo '&lt;tr&gt;&lt;td&gt;'.$w-&gt;IOValue().<span class="charliteral">' '</span>.$s-&gt;IOValue('<a class="code" href="classposte.html">poste</a>'.$counter.'_label').'&lt;/td&gt;';
<a name="l00111"></a>00111 echo <span class="stringliteral">"&lt;td&gt;n<EFBFBD> compte : "</span>.$p_val['num_compte'].<span class="stringliteral">"&lt;/td&gt;"</span>;
<a name="l00112"></a>00112 <span class="keywordflow">if</span> ( $p_form == 'form')
<a name="l00113"></a>00113 echo '&lt;td&gt;&lt;input type=<span class="stringliteral">"submit"</span> <a class="code" href="action_8inc_8php.html#a19">value</a>=<span class="stringliteral">"modifier"</span>&gt;&lt;/td&gt;&lt;tr/&gt;';
<a name="l00114"></a>00114 <span class="keywordflow">if</span> ($p_form == 'remove' )
<a name="l00115"></a>00115 echo '&lt;td&gt;&lt;input type=<span class="stringliteral">"submit"</span> <a class="code" href="action_8inc_8php.html#a19">value</a>=<span class="stringliteral">"enlever"</span>&gt;&lt;/td&gt;&lt;tr/&gt;';
<a name="l00116"></a>00116
<a name="l00117"></a>00117 echo '&lt;/<a class="code" href="balance_8php.html#a3">table</a>&gt;';
<a name="l00118"></a>00118
<a name="l00119"></a>00119 }
<a name="l00123"></a><a class="code" href="import__inc_8php.html#a3">00123</a> function <a class="code" href="import__inc_8php.html#a3">RemoveCSV</a>($cn)
<a name="l00124"></a>00124 {
<a name="l00125"></a>00125 var_dump($_POST);
<a name="l00126"></a>00126 <a class="code" href="bank_8inc_8php.html#a20">$sql</a>=<span class="stringliteral">"update import_tmp set poste_comptable=null where code='"</span>.$_POST['code'].<span class="stringliteral">"'"</span>;
<a name="l00127"></a>00127 <a class="code" href="postgres_8php.html#a2">ExecSql</a>($cn,$sql);
<a name="l00128"></a>00128 }
<a name="l00129"></a>00129
<a name="l00133"></a><a class="code" href="import__inc_8php.html#a4">00133</a> function <a class="code" href="import__inc_8php.html#a4">VerifImport</a>($p_cn){
<a name="l00134"></a>00134 <a class="code" href="bank_8inc_8php.html#a20">$sql</a> = <span class="stringliteral">"select * from import_tmp where poste_comptable='' or poste_comptable is null order by date_exec,code"</span>;
<a name="l00135"></a>00135 <a class="code" href="depense_8inc_8php.html#a4">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00136"></a>00136 <a class="code" href="fortis__be_8inc_8php.html#a9">$Num</a>=pg_NumRows($Res);
<a name="l00137"></a>00137 echo <a class="code" href="fortis__be_8inc_8php.html#a9">$Num</a>.<span class="stringliteral">" op<6F>rations <20> compl<70>ter.&lt;br/&gt;&lt;br/&gt;"</span>;
<a name="l00138"></a>00138 <a class="code" href="balance_8php.html#a12">$i</a>=1;
<a name="l00139"></a>00139 <span class="comment">// include javascript for popup </span>
<a name="l00140"></a>00140 echo <a class="code" href="constant_8php.html#a85">JS_SEARCH_CARD</a>;
<a name="l00141"></a>00141 <span class="keywordflow">while</span>(<a class="code" href="tva_8inc_8php.html#a10">$val</a> = pg_fetch_array($Res)){
<a name="l00142"></a>00142 echo '&lt;form <a class="code" href="pref_8inc_8php.html#a0">METHOD</a>=<span class="stringliteral">"POST"</span> <a class="code" href="classaction.html">action</a>=<span class="stringliteral">"import.php?action=verif"</span>&gt;';
<a name="l00143"></a>00143 <a class="code" href="import__inc_8php.html#a2">ShowBox</a>($val,$i);
<a name="l00144"></a>00144 echo '&lt;/form&gt;';
<a name="l00145"></a>00145 <a class="code" href="balance_8php.html#a12">$i</a>++;
<a name="l00146"></a>00146 }
<a name="l00147"></a>00147
<a name="l00148"></a>00148 }
<a name="l00154"></a><a class="code" href="import__inc_8php.html#a5">00154</a> function <a class="code" href="import__inc_8php.html#a5">ConfirmTransfert</a>($p_cn,$periode){
<a name="l00155"></a>00155 <a class="code" href="bank_8inc_8php.html#a20">$sql</a> = <span class="stringliteral">"select to_char(p_start,'DD-MM-YYYY') as p_start,to_char(p_end,'DD-MM-YYYY') as p_end"</span>.
<a name="l00156"></a>00156 <span class="stringliteral">" from parm_periode where p_id = '"</span>.$periode.<span class="stringliteral">"'"</span>;
<a name="l00157"></a>00157 <a class="code" href="depense_8inc_8php.html#a4">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00158"></a>00158 <a class="code" href="tva_8inc_8php.html#a10">$val</a> = pg_fetch_array($Res);
<a name="l00159"></a>00159 <span class="keywordflow">if</span> ( $val == <span class="keyword">false</span> )
<a name="l00160"></a>00160 {
<a name="l00161"></a>00161 echo <span class="stringliteral">"&lt;script&gt;"</span>.
<a name="l00162"></a>00162 <span class="stringliteral">"alert ('Vous devez selectionner votre p<>riode dans vos pr<70>f<EFBFBD>rences');"</span>.
<a name="l00163"></a>00163 <span class="stringliteral">"&lt;/script&gt;"</span>;
<a name="l00164"></a>00164 <a class="code" href="balance_8php.html#a0">exit</a>();
<a name="l00165"></a>00165 }
<a name="l00166"></a>00166 <a class="code" href="bilan_8php.html#a2">$start</a> =<span class="stringliteral">"to_date('"</span>.$val['p_start'].<span class="stringliteral">"','DD-MM-YYYY')"</span>;
<a name="l00167"></a>00167 <a class="code" href="bilan_8php.html#a3">$end</a> = <span class="stringliteral">"to_date('"</span>.$val['p_end'].<span class="stringliteral">"','DD-MM-YYYY')"</span>;
<a name="l00168"></a>00168
<a name="l00169"></a>00169 <a class="code" href="bank_8inc_8php.html#a20">$sql</a> = <span class="stringliteral">"select code,to_char(date_exec,'DD.MM.YYYY') as date_exec, "</span>.
<a name="l00170"></a>00170 <span class="stringliteral">" montant,num_compte,poste_comptable,bq_account,jrn,detail "</span>.
<a name="l00171"></a>00171 <span class="stringliteral">" from import_tmp where poste_comptable is not null and poste_comptable &lt;&gt; '' </span>
<a name="l00172"></a>00172 <span class="stringliteral"> and ok &lt;&gt; TRUE AND date_exec BETWEEN "</span>.$start.<span class="stringliteral">" and "</span>.<a class="code" href="bilan_8php.html#a3">$end</a>;
<a name="l00173"></a>00173
<a name="l00174"></a>00174
<a name="l00175"></a>00175
<a name="l00176"></a>00176 <a class="code" href="depense_8inc_8php.html#a4">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00177"></a>00177 <a class="code" href="fortis__be_8inc_8php.html#a9">$Num</a>=pg_NumRows($Res);
<a name="l00178"></a>00178 echo <a class="code" href="fortis__be_8inc_8php.html#a9">$Num</a>.<span class="stringliteral">" op<6F>rations <20> compl<70>ter.&lt;br/&gt;&lt;br/&gt;"</span>;
<a name="l00179"></a>00179 <span class="keywordflow">if</span> ( $Num == 0 ) <span class="keywordflow">return</span>;
<a name="l00180"></a>00180 <a class="code" href="balance_8php.html#a12">$i</a>=1;
<a name="l00181"></a>00181 <span class="keywordflow">while</span>(<a class="code" href="tva_8inc_8php.html#a10">$val</a> = pg_fetch_array($Res)){
<a name="l00182"></a>00182
<a name="l00183"></a>00183 echo '&lt;form method=<span class="stringliteral">"post"</span> <a class="code" href="classaction.html">action</a>=<span class="stringliteral">"import.php"</span>&gt;';
<a name="l00184"></a>00184 echo '&lt;input type=<span class="stringliteral">"hidden"</span> <a class="code" href="action_8inc_8php.html#a18">name</a>=<span class="stringliteral">"action"</span> <a class="code" href="action_8inc_8php.html#a19">value</a>=<span class="stringliteral">"remove"</span>&gt;';
<a name="l00185"></a>00185 <a class="code" href="import__inc_8php.html#a2">ShowBox</a>($val,$i,'remove');
<a name="l00186"></a>00186 echo '&lt;/form&gt;';
<a name="l00187"></a>00187 <a class="code" href="balance_8php.html#a12">$i</a>++;
<a name="l00188"></a>00188 }
<a name="l00189"></a>00189 echo '&lt;form method=<span class="stringliteral">"post"</span> <a class="code" href="classaction.html">action</a>=<span class="stringliteral">"import.php"</span>&gt;';
<a name="l00190"></a>00190 echo '&lt;input type=<span class="stringliteral">"hidden"</span> <a class="code" href="action_8inc_8php.html#a18">name</a>=<span class="stringliteral">"action"</span> <a class="code" href="action_8inc_8php.html#a19">value</a>=<span class="stringliteral">"transfer"</span>&gt;';
<a name="l00191"></a>00191 echo '&lt;input type=<span class="stringliteral">"submit"</span> <a class="code" href="action_8inc_8php.html#a18">name</a>=<span class="stringliteral">"sub"</span> <a class="code" href="action_8inc_8php.html#a19">value</a>=<span class="stringliteral">"Commencer le transfert"</span>&gt;';
<a name="l00192"></a>00192 echo '&lt;/form&gt;';
<a name="l00193"></a>00193
<a name="l00194"></a>00194 }
<a name="l00195"></a>00195
<a name="l00201"></a><a class="code" href="import__inc_8php.html#a6">00201</a> function <a class="code" href="import__inc_8php.html#a6">TransferCSV</a>($p_cn, $periode){
<a name="l00202"></a>00202 <span class="comment">//on obtient la p<>riode courante</span>
<a name="l00203"></a>00203 <a class="code" href="user__action__ach_8php.html#a9">$User</a>=<span class="keyword">new</span> <a class="code" href="classcl__user.html">cl_user</a>($p_cn);
<a name="l00204"></a>00204 $periode = <a class="code" href="user__action__ach_8php.html#a9">$User</a>-&gt;GetPeriode();
<a name="l00205"></a>00205 <span class="comment">// on trouve les dates fronti<74>res de cette p<>riode</span>
<a name="l00206"></a>00206 <a class="code" href="bank_8inc_8php.html#a20">$sql</a> = <span class="stringliteral">"select to_char(p_start,'DD-MM-YYYY') as p_start,to_char(p_end,'DD-MM-YYYY') as p_end"</span>.
<a name="l00207"></a>00207 <span class="stringliteral">" from parm_periode where p_id = '"</span>.$periode.<span class="stringliteral">"'"</span>;
<a name="l00208"></a>00208 <a class="code" href="depense_8inc_8php.html#a4">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00209"></a>00209 <a class="code" href="tva_8inc_8php.html#a10">$val</a> = pg_fetch_array($Res);
<a name="l00210"></a>00210 <span class="keywordflow">if</span> ( $val == <span class="keyword">false</span> )
<a name="l00211"></a>00211 {
<a name="l00212"></a>00212 echo <span class="stringliteral">"&lt;script&gt;"</span>.
<a name="l00213"></a>00213 <span class="stringliteral">"alert ('Vous devez selectionner votre p<>riode dans vos pr<70>f<EFBFBD>rences');"</span>.
<a name="l00214"></a>00214 <span class="stringliteral">"&lt;/script&gt;"</span>;
<a name="l00215"></a>00215 <a class="code" href="balance_8php.html#a0">exit</a>();
<a name="l00216"></a>00216 }
<a name="l00217"></a>00217 <a class="code" href="bilan_8php.html#a2">$start</a> =<span class="stringliteral">"to_date('"</span>.$val['p_start'].<span class="stringliteral">"','DD-MM-YYYY')"</span>;
<a name="l00218"></a>00218 <a class="code" href="bilan_8php.html#a3">$end</a> = <span class="stringliteral">"to_date('"</span>.$val['p_end'].<span class="stringliteral">"','DD-MM-YYYY')"</span>;
<a name="l00219"></a>00219 <span class="comment">// var_dump($val);</span>
<a name="l00220"></a>00220 <a class="code" href="bank_8inc_8php.html#a20">$sql</a> = <span class="stringliteral">"select code,to_char(date_exec,'DD.MM.YYYY') as date_exec, "</span>.
<a name="l00221"></a>00221 <span class="stringliteral">" montant,num_compte,poste_comptable,bq_account,jrn,detail "</span>.
<a name="l00222"></a>00222 <span class="stringliteral">" from import_tmp where poste_comptable is not null and poste_comptable &lt;&gt; '' </span>
<a name="l00223"></a>00223 <span class="stringliteral"> and ok &lt;&gt; TRUE AND date_exec BETWEEN "</span>.$start.<span class="stringliteral">" and "</span>.<a class="code" href="bilan_8php.html#a3">$end</a>;
<a name="l00224"></a>00224 <a class="code" href="depense_8inc_8php.html#a4">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00225"></a>00225 <span class="comment">//echo "boucle: ".sizeof($Res)."&lt;br/&gt;";</span>
<a name="l00226"></a>00226 <span class="comment">//while($val = pg_fetch_array($Res)){</span>
<a name="l00227"></a>00227 <a class="code" href="setup_8php.html#a11">$Max</a>=pg_NumRows($Res);
<a name="l00228"></a>00228 echo <a class="code" href="setup_8php.html#a11">$Max</a>.<span class="stringliteral">" op<6F>rations <20> transf<73>rer.&lt;br/&gt;"</span>;
<a name="l00229"></a>00229 <a class="code" href="postgres_8php.html#a14">StartSql</a>($p_cn);
<a name="l00230"></a>00230
<a name="l00231"></a>00231 <span class="keywordflow">for</span> ($i = 0;$i &lt; $Max;$i++) {
<a name="l00232"></a>00232 <a class="code" href="tva_8inc_8php.html#a10">$val</a>=pg_fetch_array($Res,$i);
<a name="l00233"></a>00233
<a name="l00234"></a>00234 <a class="code" href="argenta__be_8inc_8php.html#a5">$code</a>=<a class="code" href="tva_8inc_8php.html#a10">$val</a>['code']; <a class="code" href="argenta__be_8inc_8php.html#a3">$date_exec</a>=<a class="code" href="tva_8inc_8php.html#a10">$val</a>['date_exec']; <a class="code" href="argenta__be_8inc_8php.html#a6">$montant</a>=<a class="code" href="tva_8inc_8php.html#a10">$val</a>['montant']; <a class="code" href="argenta__be_8inc_8php.html#a1">$num_compte</a>=<a class="code" href="tva_8inc_8php.html#a10">$val</a>['num_compte'];
<a name="l00235"></a>00235 <a class="code" href="fortis__be_8inc_8php.html#a3">$poste_comptable</a>=<a class="code" href="tva_8inc_8php.html#a10">$val</a>['poste_comptable'];$bq_account=<a class="code" href="tva_8inc_8php.html#a10">$val</a>['bq_account'];
<a name="l00236"></a>00236 <a class="code" href="show__pj_8php.html#a6">$jrn</a>=<a class="code" href="tva_8inc_8php.html#a10">$val</a>['<a class="code" href="classjrn.html">jrn</a>']; <a class="code" href="argenta__be_8inc_8php.html#a9">$detail</a>=<a class="code" href="tva_8inc_8php.html#a10">$val</a>['detail'];
<a name="l00237"></a>00237
<a name="l00238"></a>00238 <span class="comment">// Retrieve the account thx the quick code </span>
<a name="l00239"></a>00239 $f=<span class="keyword">new</span> <a class="code" href="user__impress_8php.html#a10">fiche</a>($p_cn);
<a name="l00240"></a>00240 $f-&gt;GetByQCode($poste_comptable,<span class="keyword">false</span>);
<a name="l00241"></a>00241 <a class="code" href="fortis__be_8inc_8php.html#a3">$poste_comptable</a>=$f-&gt;strAttribut(<a class="code" href="constant_8php.html#a55">ATTR_DEF_ACCOUNT</a>);
<a name="l00242"></a>00242
<a name="l00243"></a>00243 <span class="comment">// V<>rification que le poste comptable trouv<75> existe</span>
<a name="l00244"></a>00244 <span class="keywordflow">if</span> ( $poste_comptable == '- <a class="code" href="constant_8php.html#a43">ERROR</a> -')
<a name="l00245"></a>00245 $test=0;
<a name="l00246"></a>00246 <span class="keywordflow">else</span>
<a name="l00247"></a>00247 {
<a name="l00248"></a>00248 $sqltest = <span class="stringliteral">"select * from tmp_pcmn WHERE pcm_val='"</span>.$poste_comptable.<span class="stringliteral">"'"</span>;
<a name="l00249"></a>00249
<a name="l00250"></a>00250 $Restest=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sqltest);
<a name="l00251"></a>00251 $test=pg_NumRows($Restest);
<a name="l00252"></a>00252 }
<a name="l00253"></a>00253
<a name="l00254"></a>00254 <span class="comment">// Test it</span>
<a name="l00255"></a>00255 <span class="keywordflow">if</span>($test == 0) {
<a name="l00256"></a>00256 $sqlupdate = <span class="stringliteral">"update import_tmp set poste_comptable=null, ok='f' WHERE code='"</span>.$code.<span class="stringliteral">"' AND num_compte='"</span>.<a class="code" href="argenta__be_8inc_8php.html#a1">$num_compte</a>.<span class="stringliteral">"' or num_compte is null"</span>;
<a name="l00257"></a>00257 $Resupdate=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sqlupdate);
<a name="l00258"></a>00258 echo <span class="stringliteral">"Poste comptable erronn<6E> pour l'op<6F>ration "</span>.$num_compte.<span class="stringliteral">"-"</span>.<a class="code" href="argenta__be_8inc_8php.html#a5">$code</a>.<span class="stringliteral">", r<>initialisation du poste comptable&lt;br/&gt;"</span>;
<a name="l00259"></a>00259 <span class="keywordflow">continue</span>;
<a name="l00260"></a>00260 }
<a name="l00261"></a>00261
<a name="l00262"></a>00262
<a name="l00263"></a>00263 <span class="comment">// Finances</span>
<a name="l00264"></a>00264
<a name="l00265"></a>00265 <a class="code" href="annulation_8php.html#a4">$seq</a>=<a class="code" href="postgres_8php.html#a13">NextSequence</a>($p_cn,'s_grpt');
<a name="l00266"></a>00266 $p_user = <a class="code" href="commercial_8php.html#a0">$_SESSION</a>['g_user'];
<a name="l00267"></a>00267
<a name="l00268"></a>00268 <a class="code" href="bank_8inc_8php.html#a29">$r</a>=<a class="code" href="user__common_8php.html#a4">InsertJrnx</a>($p_cn,<span class="stringliteral">"d"</span>,$p_user,$<a class="code" href="classjrn.html">jrn</a>,$bq_account,$date_exec,$montant,$seq,$periode);
<a name="l00269"></a>00269 <span class="keywordflow">if</span> ( $r == <span class="keyword">false</span>) { $Rollback($p_cn);<a class="code" href="balance_8php.html#a0">exit</a>(<span class="stringliteral">"error 'import_inc.php' __LINE__"</span>);}
<a name="l00270"></a>00270
<a name="l00271"></a>00271 <a class="code" href="bank_8inc_8php.html#a29">$r</a>=<a class="code" href="user__common_8php.html#a4">InsertJrnx</a>($p_cn,<span class="stringliteral">"c"</span>,$p_user,$<a class="code" href="classjrn.html">jrn</a>,$poste_comptable,$date_exec,$montant,$seq,$periode);
<a name="l00272"></a>00272 <span class="keywordflow">if</span> ( $r == <span class="keyword">false</span>) { $Rollback($p_cn);<a class="code" href="balance_8php.html#a0">exit</a>(<span class="stringliteral">"error 'import_inc.php' __LINE__"</span>);}
<a name="l00273"></a>00273
<a name="l00274"></a>00274 <span class="comment">//remove annoying double-quote</span>
<a name="l00275"></a>00275 <a class="code" href="argenta__be_8inc_8php.html#a1">$num_compte</a>=str_replace(<span class="charliteral">'"'</span>,'',$num_compte);
<a name="l00276"></a>00276 <a class="code" href="argenta__be_8inc_8php.html#a5">$code</a>=str_replace(<span class="charliteral">'\"'</span>,'',$code);
<a name="l00277"></a>00277 <span class="keywordflow">if</span> ( strlen(trim($num_compte)) == 0 )
<a name="l00278"></a>00278 <a class="code" href="argenta__be_8inc_8php.html#a1">$num_compte</a>=<a class="code" href="tva_8inc_8php.html#a10">$val</a>['detail'];
<a name="l00279"></a>00279
<a name="l00280"></a>00280 <a class="code" href="bank_8inc_8php.html#a29">$r</a>=<a class="code" href="user__common_8php.html#a5">InsertJrn</a>($p_cn,$date_exec,NULL,$<a class="code" href="classjrn.html">jrn</a>,$detail.$num_compte.<span class="stringliteral">" "</span>.$code,$montant,$seq,$periode);
<a name="l00281"></a>00281 <span class="keywordflow">if</span> ( $r == <span class="keyword">false</span> ) { <a class="code" href="postgres_8php.html#a17">Rollback</a>($p_cn); <a class="code" href="balance_8php.html#a0">exit</a>(<span class="stringliteral">" Error 'import_inc.php' __LINE__"</span>);}
<a name="l00282"></a>00282
<a name="l00283"></a>00283 <a class="code" href="jrn_8php.html#a14">SetInternalCode</a>($p_cn,$seq,$<a class="code" href="classjrn.html">jrn</a>);
<a name="l00284"></a>00284
<a name="l00285"></a>00285
<a name="l00286"></a>00286 echo <span class="stringliteral">"Tranfer de l'op<6F>ration "</span>.$code.<span class="stringliteral">" effectu<74>&lt;br/&gt;"</span>;
<a name="l00287"></a>00287 $sql2 = <span class="stringliteral">"update import_tmp set ok=TRUE where code='"</span>.$code.<span class="stringliteral">"'"</span>;
<a name="l00288"></a>00288 <a class="code" href="setup_8php.html#a12">$Res2</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql2);
<a name="l00289"></a>00289
<a name="l00290"></a>00290
<a name="l00291"></a>00291 }
<a name="l00292"></a>00292 <a class="code" href="postgres_8php.html#a16">Commit</a>($p_cn);
<a name="l00293"></a>00293
<a name="l00294"></a>00294 }
<a name="l00305"></a><a class="code" href="import__inc_8php.html#a7">00305</a> function <a class="code" href="import__inc_8php.html#a7">ShowFormTransfert</a>($p_cn){
<a name="l00306"></a>00306 <a class="code" href="admin_8inc_8php.html#a4">$w</a>=<span class="keyword">new</span> <a class="code" href="classwidget.html">widget</a>(<span class="stringliteral">"select"</span>);
<a name="l00307"></a>00307 echo '&lt;<a class="code" href="constant_8php.html#a7">FORM</a> <a class="code" href="pref_8inc_8php.html#a0">METHOD</a>=<span class="stringliteral">"POST"</span> <a class="code" href="classaction.html">action</a>=<span class="stringliteral">"import.php?action=import"</span> enctype=<span class="stringliteral">"multipart/form-data"</span>&gt;';
<a name="l00308"></a>00308 echo '&lt;INPUT TYPE=<span class="stringliteral">"file"</span> <a class="code" href="action_8inc_8php.html#a18">name</a>=<span class="stringliteral">"fupload"</span> <a class="code" href="tva_8inc_8php.html#a15">size</a>=<span class="stringliteral">"20"</span>&gt;&lt;br&gt;';
<a name="l00309"></a>00309 <span class="comment">// ask for the journal target </span>
<a name="l00310"></a>00310 <a class="code" href="show__pj_8php.html#a6">$jrn</a>=<a class="code" href="ac__common_8php.html#a12">make_array</a> ($p_cn,<span class="stringliteral">"select jrn_def_id,jrn_def_name from jrn_def where jrn_def_type='FIN';"</span>);
<a name="l00311"></a>00311 <a class="code" href="admin_8inc_8php.html#a4">$w</a>-&gt;label='Journal';
<a name="l00312"></a>00312 echo <a class="code" href="admin_8inc_8php.html#a4">$w</a>-&gt;label.<span class="stringliteral">" :"</span>.<a class="code" href="admin_8inc_8php.html#a4">$w</a>-&gt;IOValue('import_jrn',$<a class="code" href="classjrn.html">jrn</a>).<span class="stringliteral">"&lt;br&gt;"</span>;
<a name="l00313"></a>00313 <span class="comment">// choose the bank account</span>
<a name="l00314"></a>00314 $bq=<a class="code" href="ac__common_8php.html#a12">make_array</a>($p_cn,<span class="stringliteral">"select pcm_val,pcm_lib from tmp_pcmn where pcm_val like '550%'"</span>);
<a name="l00315"></a>00315 <a class="code" href="admin_8inc_8php.html#a4">$w</a>-&gt;label='Banque';
<a name="l00316"></a>00316 echo <span class="stringliteral">"Compte en banque :"</span>.$w-&gt;IOValue('import_bq',$bq).<span class="stringliteral">"&lt;br&gt;"</span>;
<a name="l00317"></a>00317 $format_csv=<a class="code" href="ac__common_8php.html#a12">make_array</a>($p_cn,<span class="stringliteral">"select include_file,name from format_csv_banque;"</span>);
<a name="l00318"></a>00318 <a class="code" href="admin_8inc_8php.html#a4">$w</a>-&gt;label=<span class="stringliteral">"Format import"</span>;
<a name="l00319"></a>00319 echo <a class="code" href="admin_8inc_8php.html#a4">$w</a>-&gt;label.$w-&gt;IOValue('format_csv',$format_csv).'&lt;br&gt;';
<a name="l00320"></a>00320 echo '&lt;INPUT TYPE=<span class="stringliteral">"SUBMIT"</span> Value=<span class="stringliteral">"Import fiche"</span>&gt;';
<a name="l00321"></a>00321 echo '&lt;/<a class="code" href="constant_8php.html#a7">FORM</a>&gt;';
<a name="l00322"></a>00322 }
<a name="l00323"></a>00323 ?&gt;
</pre></div></BODY>
</HTML>