altocompta/doc/developper/html/user__form__fin_8php-source.html

382 lines
41 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: /home/dany/developpement/phpcompta-dev/phpcompta/include/user_form_fin.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">developpement</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_000001.html">phpcompta-dev</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_000002.html">phpcompta</a>&nbsp;&raquo&nbsp;<a class="el" href="dir_000006.html">include</a></div>
<h1>user_form_fin.php</h1><a href="user__form__fin_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 <span class="comment">/* $Revision$ */</span>
<a name="l00020"></a>00020 <span class="comment">// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr</span>
<a name="l00021"></a>00021 require_once(<span class="stringliteral">"class_widget.php"</span>);
<a name="l00022"></a>00022 require_once(<span class="stringliteral">"constant.php"</span>);
<a name="l00023"></a>00023 require_once(<span class="stringliteral">"preference.php"</span>);
<a name="l00024"></a>00024 require_once(<span class="stringliteral">"fiche_inc.php"</span>);
<a name="l00025"></a>00025 require_once(<span class="stringliteral">"user_common.php"</span>);
<a name="l00043"></a><a class="code" href="user__form__fin_8php.html#a0">00043</a> function <a class="code" href="user__form__ach_8php.html#a1">form_verify_input</a>($p_cn,$p_jrn,$p_periode,$p_array,$p_number)
<a name="l00044"></a>00044 {
<a name="l00045"></a>00045 foreach ($p_array as $<a class="code" href="client_8inc_8php.html#a5">name</a>=&gt;$content) {
<a name="l00046"></a>00046 ${<span class="stringliteral">"$name"</span>}=$content;
<a name="l00047"></a>00047 }
<a name="l00048"></a>00048 <span class="comment">// Verify the date</span>
<a name="l00049"></a>00049 <span class="keywordflow">if</span> ( <a class="code" href="ac__common_8php.html#a3">isDate</a>($e_date) == null ) {
<a name="l00050"></a>00050 <a class="code" href="ac__common_8php.html#a0">echo_error</a>(<span class="stringliteral">"Invalid date $e_date"</span>);
<a name="l00051"></a>00051 <a class="code" href="debug_8php.html#a0">echo_debug</a>('user_form_fin.php',__LINE__,<span class="stringliteral">"Invalid date $e_date"</span>);
<a name="l00052"></a>00052 echo <span class="stringliteral">"&lt;SCRIPT&gt; alert('INVALID DATE $e_date !!!!');&lt;/SCRIPT&gt;"</span>;
<a name="l00053"></a>00053 <span class="keywordflow">return</span> null;
<a name="l00054"></a>00054 }
<a name="l00055"></a>00055
<a name="l00056"></a>00056
<a name="l00057"></a>00057 <span class="comment">// Check if the fiche is in the jrn</span>
<a name="l00058"></a>00058 <span class="keywordflow">if</span> (<a class="code" href="fiche__inc_8php.html#a30">IsFicheOfJrn</a>($p_cn , $p_jrn, $e_bank_account,'deb') == 0 )
<a name="l00059"></a>00059 {
<a name="l00060"></a>00060 $msg=<span class="stringliteral">"Mauvais compte en banque"</span>;
<a name="l00061"></a>00061 <a class="code" href="ac__common_8php.html#a0">echo_error</a>($msg);<a class="code" href="debug_8php.html#a0">echo_debug</a>('user_form_fin.php',__LINE__,$msg);
<a name="l00062"></a>00062 echo <span class="stringliteral">"&lt;SCRIPT&gt;alert('$msg');&lt;/SCRIPT&gt;"</span>;
<a name="l00063"></a>00063 <span class="keywordflow">return</span> null;
<a name="l00064"></a>00064 }
<a name="l00065"></a>00065
<a name="l00066"></a>00066 <span class="comment">// check if all e_march are in fiche</span>
<a name="l00067"></a>00067 <span class="keywordflow">for</span> ($i=0;$i&lt;$p_number;$i++) {
<a name="l00068"></a>00068 <span class="keywordflow">if</span> ( trim(${<span class="stringliteral">"e_other$i"</span>}) == <span class="stringliteral">""</span> ) {
<a name="l00069"></a>00069 <span class="comment">// nothing to do</span>
<a name="l00070"></a>00070 <span class="keywordflow">continue</span>;
<a name="l00071"></a>00071 }
<a name="l00072"></a>00072 <span class="comment">// Check amount</span>
<a name="l00073"></a>00073 <span class="keywordflow">if</span> ( <a class="code" href="ac__common_8php.html#a2">isNumber</a>(${<span class="stringliteral">"e_other"</span>.$i.<span class="stringliteral">"_amount"</span>}) == 0) {
<a name="l00074"></a>00074 $msg=<span class="stringliteral">"Montant invalide !!! "</span>;
<a name="l00075"></a>00075 <a class="code" href="ac__common_8php.html#a0">echo_error</a>($msg); <a class="code" href="debug_8php.html#a0">echo_debug</a>('user_form_fin.php',__LINE__,$msg);
<a name="l00076"></a>00076 echo <span class="stringliteral">"&lt;SCRIPT&gt;alert('$msg');&lt;/SCRIPT&gt;"</span>;
<a name="l00077"></a>00077 <span class="keywordflow">return</span> null;
<a name="l00078"></a>00078 }
<a name="l00079"></a>00079 <span class="comment">// Check </span>
<a name="l00080"></a>00080 <span class="keywordflow">if</span> ( isFicheOfJrn($p_cn,$p_jrn,${<span class="stringliteral">"e_other$i"</span>},'cred') == 0 ) {
<a name="l00081"></a>00081 $msg=<span class="stringliteral">"Fiche inexistante !!! "</span>;
<a name="l00082"></a>00082 <a class="code" href="ac__common_8php.html#a0">echo_error</a>($msg);<a class="code" href="debug_8php.html#a0">echo_debug</a>('user_form_fin.php',__LINE__,$msg);
<a name="l00083"></a>00083 echo <span class="stringliteral">"&lt;SCRIPT&gt;alert('$msg');&lt;/SCRIPT&gt;"</span>;
<a name="l00084"></a>00084 <span class="keywordflow">return</span> null;
<a name="l00085"></a>00085 }
<a name="l00086"></a>00086 <span class="comment">// check if the ATTR_DEF_ACCOUNT is set</span>
<a name="l00087"></a>00087 <a class="code" href="send__poste__pdf_8php.html#a2">$poste</a>=GetFicheAttribut($p_cn,${<span class="stringliteral">"e_other$i"</span>},<a class="code" href="constant_8php.html#a48">ATTR_DEF_ACCOUNT</a>);
<a name="l00088"></a>00088 <span class="keywordflow">if</span> ( $<a class="code" href="classposte.html">poste</a> == null )
<a name="l00089"></a>00089 {
<a name="l00090"></a>00090 $msg=<span class="stringliteral">"La fiche "</span>.${<span class="stringliteral">"e_other$i"</span>}.<span class="stringliteral">" n\'a pas de poste comptable"</span>;
<a name="l00091"></a>00091 <a class="code" href="ac__common_8php.html#a0">echo_error</a>($msg); <a class="code" href="debug_8php.html#a0">echo_debug</a>('user_form_fin.php',__LINE__,$msg);
<a name="l00092"></a>00092 echo <span class="stringliteral">"&lt;SCRIPT&gt;alert('$msg');&lt;/SCRIPT&gt;"</span>;
<a name="l00093"></a>00093 <span class="keywordflow">return</span> null;
<a name="l00094"></a>00094
<a name="l00095"></a>00095 }
<a name="l00096"></a>00096 <span class="keywordflow">if</span> ( strlen(trim($<a class="code" href="classposte.html">poste</a>))==0 )
<a name="l00097"></a>00097 {
<a name="l00098"></a>00098 $msg=<span class="stringliteral">"La fiche "</span>.${<span class="stringliteral">"e_other$i"</span>}.<span class="stringliteral">" n\'a pas de poste comptable"</span>;
<a name="l00099"></a>00099 <a class="code" href="ac__common_8php.html#a0">echo_error</a>($msg); <a class="code" href="debug_8php.html#a0">echo_debug</a>('user_form_fin.php',__LINE__,$msg);
<a name="l00100"></a>00100 echo <span class="stringliteral">"&lt;SCRIPT&gt;alert('$msg');&lt;/SCRIPT&gt;"</span>;
<a name="l00101"></a>00101 }
<a name="l00102"></a>00102
<a name="l00103"></a>00103 }
<a name="l00104"></a>00104 <span class="comment">// Verify the userperiode</span>
<a name="l00105"></a>00105
<a name="l00106"></a>00106 <span class="comment">// p_periode contient la periode par default</span>
<a name="l00107"></a>00107 list ($l_date_start,$l_date_end)=<a class="code" href="preference_8php.html#a2">GetPeriode</a>($p_cn,$p_periode);
<a name="l00108"></a>00108
<a name="l00109"></a>00109 <span class="comment">// Date dans la periode active</span>
<a name="l00110"></a>00110 <a class="code" href="debug_8php.html#a0">echo_debug</a> ('user_form_fin',__LINE__,<span class="stringliteral">"date start periode $l_date_start date fin periode $l_date_end date demande $e_date"</span>);
<a name="l00111"></a>00111 <span class="keywordflow">if</span> ( <a class="code" href="ac__common_8php.html#a1">cmpDate</a>($e_date,$l_date_start)&lt;0 ||
<a name="l00112"></a>00112 <a class="code" href="ac__common_8php.html#a1">cmpDate</a>($e_date,$l_date_end)&gt;0 )
<a name="l00113"></a>00113 {
<a name="l00114"></a>00114 $msg=<span class="stringliteral">"Not in the active periode please change your preference"</span>;
<a name="l00115"></a>00115 <a class="code" href="ac__common_8php.html#a0">echo_error</a>($msg); <a class="code" href="ac__common_8php.html#a0">echo_error</a>($msg);
<a name="l00116"></a>00116 echo <span class="stringliteral">"&lt;SCRIPT&gt;alert('$msg');&lt;/SCRIPT&gt;"</span>;
<a name="l00117"></a>00117 <span class="keywordflow">return</span> null;
<a name="l00118"></a>00118 }
<a name="l00119"></a>00119 <span class="comment">// Periode ferm<72> </span>
<a name="l00120"></a>00120 <span class="keywordflow">if</span> ( <a class="code" href="preference_8php.html#a3">PeriodeClosed</a> ($p_cn,$p_periode)==<span class="charliteral">'t'</span> )
<a name="l00121"></a>00121 {
<a name="l00122"></a>00122 $msg=<span class="stringliteral">"This periode is closed please change your preference"</span>;
<a name="l00123"></a>00123 <a class="code" href="ac__common_8php.html#a0">echo_error</a>($msg); <a class="code" href="ac__common_8php.html#a0">echo_error</a>($msg);
<a name="l00124"></a>00124 echo <span class="stringliteral">"&lt;SCRIPT&gt;alert('$msg');&lt;/SCRIPT&gt;"</span>;
<a name="l00125"></a>00125 <span class="keywordflow">return</span> null;
<a name="l00126"></a>00126 }
<a name="l00127"></a>00127 <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00128"></a>00128 }
<a name="l00129"></a>00129
<a name="l00130"></a>00130
<a name="l00147"></a><a class="code" href="user__form__fin_8php.html#a1">00147</a> function <a class="code" href="user__form__fin_8php.html#a1">FormFin</a>($p_cn,$p_jrn,$p_periode,$p_submit,$p_array=null,$pview_only=<span class="keyword">true</span>,$p_item=4,$p_save=<span class="keyword">false</span>)
<a name="l00148"></a>00148 {
<a name="l00149"></a>00149 include_once(<span class="stringliteral">"poste.php"</span>);
<a name="l00150"></a>00150 <span class="keywordflow">if</span> ( $p_array != null ) {
<a name="l00151"></a>00151 <span class="comment">// array contains old value</span>
<a name="l00152"></a>00152 foreach ( $p_array as $a=&gt;$v) {
<a name="l00153"></a>00153 ${<span class="stringliteral">"$a"</span>}=$v;
<a name="l00154"></a>00154 }
<a name="l00155"></a>00155 }
<a name="l00156"></a>00156 <span class="comment">// The date</span>
<a name="l00157"></a>00157 list ($l_date_start,$l_date_end)=<a class="code" href="preference_8php.html#a2">GetPeriode</a>($p_cn,$p_periode);
<a name="l00158"></a>00158 <a class="code" href="setup_8php.html#a4">$flag</a>=(isset($e_date))?1:0;
<a name="l00159"></a>00159 $e_date=( ! isset($e_date) ) ? substr($l_date_start,2,8):$e_date;
<a name="l00160"></a>00160
<a name="l00161"></a>00161 <span class="comment">// Verify if valid date</span>
<a name="l00162"></a>00162 <span class="keywordflow">if</span> ($flag ==1 and <a class="code" href="user__common_8php.html#a9">VerifyOperationDate</a>($p_cn,$p_periode,$e_date) == null) {
<a name="l00163"></a>00163 $e_date=substr($l_date_start,2,8);
<a name="l00164"></a>00164 }
<a name="l00165"></a>00165
<a name="l00166"></a>00166
<a name="l00167"></a>00167 $e_comment=(isset($e_comment))?$e_comment:<span class="stringliteral">""</span>;
<a name="l00168"></a>00168
<a name="l00169"></a>00169 <a class="code" href="user__action__ach_8php.html#a2">$r</a>=<span class="stringliteral">""</span>;
<a name="l00170"></a>00170 <span class="keywordflow">if</span> ( $pview_only == <span class="keyword">false</span>) {
<a name="l00171"></a>00171 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<a class="code" href="constant_8php.html#a78">JS_SEARCH_CARD</a>;
<a name="l00172"></a>00172 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<a class="code" href="constant_8php.html#a79">JS_CONCERNED_OP</a>;
<a name="l00173"></a>00173 }
<a name="l00174"></a>00174
<a name="l00175"></a>00175 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;FORM NAME=\"form_detail\" enctype=\"multipart/form-data\" ACTION=\"user_jrn.php?action=new&amp;p_jrn=$p_jrn\" METHOD=\"POST\"&gt;"</span>;
<a name="l00176"></a>00176 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.='&lt;TABLE&gt;';
<a name="l00177"></a>00177 $Date=<span class="keyword">new</span> <a class="code" href="classwidget.html">widget</a>(<span class="stringliteral">"text"</span>);
<a name="l00178"></a>00178 $Date-&gt;SetReadOnly($pview_only);
<a name="l00179"></a>00179 $Date-&gt;table=1;
<a name="l00180"></a>00180 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;tr&gt;"</span>;
<a name="l00181"></a>00181 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=$Date-&gt;IOValue(<span class="stringliteral">"e_date"</span>,$e_date,<span class="stringliteral">"Date"</span>);
<a name="l00182"></a>00182 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;/tr&gt;"</span>;
<a name="l00183"></a>00183
<a name="l00184"></a>00184
<a name="l00185"></a>00185 include_once(<span class="stringliteral">"fiche_inc.php"</span>);
<a name="l00186"></a>00186 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.='&lt;INPUT TYPE=<span class="stringliteral">"HIDDEN"</span> <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"nb_item"</span> <a class="code" href="client_8inc_8php.html#a6">value</a>=<span class="stringliteral">"'.$p_item.'"</span>&gt;';
<a name="l00187"></a>00187
<a name="l00188"></a>00188 <span class="comment">// bank_account operation</span>
<a name="l00189"></a>00189 <span class="comment">// Save old value and set a new one</span>
<a name="l00190"></a>00190 $e_bank_account=( isset ($e_bank_account) )?$e_bank_account:<span class="stringliteral">""</span>;
<a name="l00191"></a>00191 $e_bank_account_label=<span class="stringliteral">""</span>;
<a name="l00192"></a>00192
<a name="l00193"></a>00193 <span class="comment">// retrieve e_bank_account_label</span>
<a name="l00194"></a>00194 <span class="keywordflow">if</span> ( $e_bank_account != <span class="stringliteral">""</span> ) {
<a name="l00195"></a>00195 $a_client=GetFicheAttribut($p_cn,$e_bank_account);
<a name="l00196"></a>00196 <span class="keywordflow">if</span> ( $a_client != null)
<a name="l00197"></a>00197 $e_bank_account_label=$a_client['vw_name'].<span class="stringliteral">" adresse "</span>.$a_client['vw_addr'].<span class="stringliteral">" "</span>.$a_client['vw_cp'];
<a name="l00198"></a>00198 }
<a name="l00199"></a>00199 <span class="comment">// search widget</span>
<a name="l00200"></a>00200 $W1=<span class="keyword">new</span> <a class="code" href="classwidget.html">widget</a>(<span class="stringliteral">"js_search"</span>);
<a name="l00201"></a>00201 $W1-&gt;readonly=$pview_only;
<a name="l00202"></a>00202 $W1-&gt;label=<span class="stringliteral">"Banque"</span>;
<a name="l00203"></a>00203 $W1-&gt;name=<span class="stringliteral">"e_bank_account"</span>;
<a name="l00204"></a>00204 $W1-&gt;value=$e_bank_account;
<a name="l00205"></a>00205 $W1-&gt;extra=<a class="code" href="constant_8php.html#a65">FICHE_TYPE_FIN</a>; <span class="comment">// credits</span>
<a name="l00206"></a>00206 $W1-&gt;extra2=<a class="code" href="modify__op_8php.html#a2">$p_jrn</a>;
<a name="l00207"></a>00207 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;TR&gt;"</span>.$W1-&gt;IOValue().<span class="stringliteral">"&lt;/TD&gt;"</span>;
<a name="l00208"></a>00208
<a name="l00209"></a>00209 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;/TABLE&gt;"</span>;
<a name="l00210"></a>00210
<a name="l00211"></a>00211 $Span=<span class="keyword">new</span> <a class="code" href="classwidget.html">widget</a> (<span class="stringliteral">"span"</span>);
<a name="l00212"></a>00212 $Span-&gt;SetReadOnly($pview_only);
<a name="l00213"></a>00213 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;TD&gt;"</span>.$Span-&gt;IOValue(<span class="stringliteral">"e_bank_account_label"</span>,$e_bank_account_label).<span class="stringliteral">"&lt;/TD&gt;"</span>;
<a name="l00214"></a>00214
<a name="l00215"></a>00215
<a name="l00216"></a>00216 <span class="comment">// ComputeBanqueSaldo</span>
<a name="l00217"></a>00217 <span class="comment">// </span>
<a name="l00218"></a>00218 <span class="keywordflow">if</span> ( $pview_only == <span class="keyword">true</span> ) {
<a name="l00219"></a>00219 <a class="code" href="impress__fiche_8php.html#a13">$solde</a>=<a class="code" href="poste_8php.html#a3">GetSolde</a>($p_cn,GetFicheAttribut($p_cn,$e_bank_account,<a class="code" href="constant_8php.html#a48">ATTR_DEF_ACCOUNT</a>));
<a name="l00220"></a>00220 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">" &lt;b&gt; Solde = "</span>.$solde.<span class="stringliteral">" &lt;/b&gt;"</span>;
<a name="l00221"></a>00221 $new_solde=<a class="code" href="impress__fiche_8php.html#a13">$solde</a>;
<a name="l00222"></a>00222 }
<a name="l00223"></a>00223
<a name="l00224"></a>00224 <span class="comment">// Start the div for item to move money</span>
<a name="l00225"></a>00225 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;DIV&gt;"</span>;
<a name="l00226"></a>00226 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.='&lt;H2 <span class="keyword">class</span>=<span class="stringliteral">"info"</span>&gt;Actions&lt;/H2&gt;';
<a name="l00227"></a>00227 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.='&lt;TABLE&gt;';
<a name="l00228"></a>00228 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;TR&gt;"</span>;
<a name="l00229"></a>00229 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;th&gt;&lt;/TH&gt;"</span>;
<a name="l00230"></a>00230 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;th&gt;code&lt;/TH&gt;"</span>;
<a name="l00231"></a>00231 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;th&gt;D&amp;eacute;nomination&lt;/TH&gt;"</span>;
<a name="l00232"></a>00232 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;th&gt;Description&lt;/TH&gt;"</span>;
<a name="l00233"></a>00233 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;th&gt;Montant&lt;/TH&gt;"</span>;
<a name="l00234"></a>00234 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.='&lt;th colspan=<span class="stringliteral">"2"</span>&gt; Op. Concern&amp;eacute;&lt;/th&gt;';
<a name="l00235"></a>00235 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;/TR&gt;"</span>;
<a name="l00236"></a>00236 <span class="comment">// Parse each " tiers" </span>
<a name="l00237"></a>00237 <span class="keywordflow">for</span> ($i=0; $i &lt; $p_item; $i++) {
<a name="l00238"></a>00238 $tiers=(isset(${<span class="stringliteral">"e_other"</span>.$i}))?${<span class="stringliteral">"e_other"</span>.$i}:<span class="stringliteral">""</span>;
<a name="l00239"></a>00239 $tiers_label=<span class="stringliteral">""</span>;
<a name="l00240"></a>00240 $tiers_amount=(isset(${<span class="stringliteral">"e_other$i"</span>.<span class="stringliteral">"_amount"</span>}))?${<span class="stringliteral">"e_other$i"</span>.<span class="stringliteral">"_amount"</span>}:0;
<a name="l00241"></a>00241
<a name="l00242"></a>00242 $tiers_comment=(isset (${<span class="stringliteral">"e_other$i"</span>.<span class="stringliteral">"_comment"</span>}))?${<span class="stringliteral">"e_other$i"</span>.<span class="stringliteral">"_comment"</span>}:<span class="stringliteral">""</span>;
<a name="l00243"></a>00243 <span class="comment">// If $tiers has a value</span>
<a name="l00244"></a>00244 <span class="keywordflow">if</span> ( $tiers != <span class="stringliteral">""</span> )
<a name="l00245"></a>00245 {
<a name="l00246"></a>00246 <span class="comment">// retrieve the tva label and name</span>
<a name="l00247"></a>00247 $a_fiche=GetFicheAttribut($p_cn, $tiers);
<a name="l00248"></a>00248 <span class="keywordflow">if</span> ( $a_fiche != null ) {
<a name="l00249"></a>00249 $tiers_label=$a_fiche['vw_name'];
<a name="l00250"></a>00250 }
<a name="l00251"></a>00251 }
<a name="l00252"></a>00252 ${<span class="stringliteral">"e_other$i"</span>.<span class="stringliteral">"_amount"</span>}=(isset (${<span class="stringliteral">"e_other$i"</span>.<span class="stringliteral">"_amount"</span>}))?${<span class="stringliteral">"e_other$i"</span>.<span class="stringliteral">"_amount"</span>}:0;
<a name="l00253"></a>00253
<a name="l00254"></a>00254 $W1=<span class="keyword">new</span> <a class="code" href="classwidget.html">widget</a>(<span class="stringliteral">"js_search"</span>);
<a name="l00255"></a>00255 $W1-&gt;label=<span class="stringliteral">""</span>;
<a name="l00256"></a>00256 $W1-&gt;name=<span class="stringliteral">"e_other"</span>.$i;
<a name="l00257"></a>00257 $W1-&gt;value=$tiers;
<a name="l00258"></a>00258 $W1-&gt;extra='cred'; <span class="comment">// credits</span>
<a name="l00259"></a>00259 $W1-&gt;extra2=<a class="code" href="modify__op_8php.html#a2">$p_jrn</a>;
<a name="l00260"></a>00260 $W1-&gt;readonly=$pview_only;
<a name="l00261"></a>00261 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;TR&gt;"</span>.$W1-&gt;IOValue().<span class="stringliteral">"&lt;/TD&gt;"</span>;
<a name="l00262"></a>00262 <span class="comment">// label</span>
<a name="l00263"></a>00263 $other=<span class="keyword">new</span> <a class="code" href="classwidget.html">widget</a>(<span class="stringliteral">"span"</span>);
<a name="l00264"></a>00264 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;TD&gt;"</span>;
<a name="l00265"></a>00265 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=$other-&gt;IOValue(<span class="stringliteral">"e_other$i"</span>.<span class="stringliteral">"_label"</span>, $tiers_label);
<a name="l00266"></a>00266 <span class="comment">// Comment</span>
<a name="l00267"></a>00267 $wComment=<span class="keyword">new</span> <a class="code" href="classwidget.html">widget</a>(<span class="stringliteral">"text"</span>);
<a name="l00268"></a>00268 $wComment-&gt;table=1;
<a name="l00269"></a>00269 $wComment-&gt;SetReadOnly($pview_only);
<a name="l00270"></a>00270 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=$wComment-&gt;IOValue(<span class="stringliteral">"e_other$i"</span>.<span class="stringliteral">"_comment"</span>,$tiers_comment);
<a name="l00271"></a>00271 <span class="comment">// amount</span>
<a name="l00272"></a>00272 $wAmount=<span class="keyword">new</span> <a class="code" href="classwidget.html">widget</a>(<span class="stringliteral">"text"</span>);
<a name="l00273"></a>00273 $wAmount-&gt;table=1;
<a name="l00274"></a>00274 $wAmount-&gt;size=7;
<a name="l00275"></a>00275 $wAmount-&gt;SetReadOnly($pview_only);
<a name="l00276"></a>00276 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=$wAmount-&gt;IOValue(<span class="stringliteral">"e_other$i"</span>.<span class="stringliteral">"_amount"</span>,$tiers_amount);
<a name="l00277"></a>00277 <span class="comment">// concerned</span>
<a name="l00278"></a>00278 ${<span class="stringliteral">"e_concerned"</span>.$i}=(isset(${<span class="stringliteral">"e_concerned"</span>.$i}))?${<span class="stringliteral">"e_concerned"</span>.$i}:<span class="stringliteral">""</span>;
<a name="l00279"></a>00279 $wConcerned=<span class="keyword">new</span> <a class="code" href="classwidget.html">widget</a>(<span class="stringliteral">"js_concerned"</span>);
<a name="l00280"></a>00280 $wConcerned-&gt;SetReadOnly($pview_only);
<a name="l00281"></a>00281 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=$wConcerned-&gt;IOValue(<span class="stringliteral">"e_concerned"</span>.$i,${<span class="stringliteral">"e_concerned"</span>.$i});
<a name="l00282"></a>00282 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.='&lt;/TR&gt;';
<a name="l00283"></a>00283 <span class="comment">// if not recorded the new amount must be recalculate</span>
<a name="l00284"></a>00284 <span class="comment">// if recorded the old amount is recalculated</span>
<a name="l00285"></a>00285 <span class="keywordflow">if</span> ( $pview_only == <span class="keyword">true</span>)
<a name="l00286"></a>00286 $new_solde=($p_save==<span class="keyword">false</span>)?$new_solde+$tiers_amount:$new_solde-$tiers_amount;
<a name="l00287"></a>00287 }
<a name="l00288"></a>00288
<a name="l00289"></a>00289 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;/TABLE&gt;"</span>;
<a name="l00290"></a>00290
<a name="l00291"></a>00291 <span class="keywordflow">if</span> ( $pview_only==<span class="keyword">true</span> &amp;&amp; $p_save==<span class="keyword">false</span>) {
<a name="l00292"></a>00292 <span class="comment">// check for upload piece</span>
<a name="l00293"></a>00293 <a class="code" href="show__document__modele_8php.html#a6">$file</a>=<span class="keyword">new</span> <a class="code" href="classwidget.html">widget</a>(<span class="stringliteral">"file"</span>);
<a name="l00294"></a>00294 <a class="code" href="show__document__modele_8php.html#a6">$file</a>-&gt;table=1;
<a name="l00295"></a>00295 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;hr&gt;"</span>;
<a name="l00296"></a>00296 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.= <span class="stringliteral">"&lt;table&gt;"</span>;
<a name="l00297"></a>00297 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;TR&gt;"</span>.$file-&gt;IOValue(<span class="stringliteral">"pj"</span>,<span class="stringliteral">""</span>,<span class="stringliteral">"Pi&amp;egrave;ce justificative"</span>).<span class="stringliteral">"&lt;/TR&gt;"</span>;
<a name="l00298"></a>00298 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;/table&gt;"</span>;
<a name="l00299"></a>00299 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;hr&gt;"</span>;
<a name="l00300"></a>00300 }
<a name="l00301"></a>00301 <span class="comment">// Set correctly the REQUEST param for jrn_type </span>
<a name="l00302"></a>00302 <a class="code" href="poste_8inc_8php.html#a8">$h</a>=<span class="keyword">new</span> <a class="code" href="classwidget.html">widget</a>('hidden');
<a name="l00303"></a>00303 <a class="code" href="poste_8inc_8php.html#a8">$h</a>-&gt;name='jrn_type';
<a name="l00304"></a>00304 <a class="code" href="poste_8inc_8php.html#a8">$h</a>-&gt;value=$_REQUEST['jrn_type'];
<a name="l00305"></a>00305 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<a class="code" href="poste_8inc_8php.html#a8">$h</a>-&gt;IOValue();
<a name="l00306"></a>00306
<a name="l00307"></a>00307 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=$p_submit;
<a name="l00308"></a>00308 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;/DIV&gt;"</span>;
<a name="l00309"></a>00309 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;/FORM&gt;"</span>;
<a name="l00310"></a>00310
<a name="l00311"></a>00311 <span class="comment">// if view_only is true</span>
<a name="l00312"></a>00312 <span class="comment">//Put the new saldo here (old saldo - operation)</span>
<a name="l00313"></a>00313 <span class="keywordflow">if</span> ( $pview_only==<span class="keyword">true</span>) {
<a name="l00314"></a>00314 <span class="comment">// if not recorded the new amount must be recalculate</span>
<a name="l00315"></a>00315 <span class="keywordflow">if</span> ( $p_save == <span class="keyword">false</span>) {
<a name="l00316"></a>00316 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">" &lt;b&gt; Ancien Solde = "</span>.$solde.<span class="stringliteral">" &lt;/b&gt;&lt;br&gt;"</span>;
<a name="l00317"></a>00317 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">" &lt;b&gt; Nouveau Solde = "</span>.$new_solde.<span class="stringliteral">" &lt;/b&gt;&lt;br&gt;"</span>;
<a name="l00318"></a>00318 }
<a name="l00319"></a>00319 <span class="comment">// if recorded the old amount is recalculated</span>
<a name="l00320"></a>00320 <span class="keywordflow">if</span> ($p_save == <span class="keyword">true</span> ) {
<a name="l00321"></a>00321 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">" &lt;b&gt; Ancien Solde = "</span>.$new_solde.<span class="stringliteral">" &lt;/b&gt;&lt;br&gt;"</span>;
<a name="l00322"></a>00322 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">" &lt;b&gt; Nouveau Solde = "</span>.$solde.<span class="stringliteral">" &lt;/b&gt;&lt;br&gt;"</span>;
<a name="l00323"></a>00323 }
<a name="l00324"></a>00324 }
<a name="l00325"></a>00325
<a name="l00326"></a>00326 <span class="keywordflow">return</span> <a class="code" href="user__action__ach_8php.html#a2">$r</a>;
<a name="l00327"></a>00327
<a name="l00328"></a>00328
<a name="l00329"></a>00329 }
<a name="l00330"></a>00330
<a name="l00349"></a><a class="code" href="user__form__fin_8php.html#a2">00349</a> function <a class="code" href="user__form__fin_8php.html#a2">RecordFin</a>($p_cn,$p_array,$p_user,$p_jrn) {
<a name="l00350"></a>00350 <a class="code" href="debug_8php.html#a0">echo_debug</a>('user_form_fin.php',__LINE__,<span class="stringliteral">"RecordFin"</span>);
<a name="l00351"></a>00351 foreach ( $p_array as $v =&gt; $e)
<a name="l00352"></a>00352 {
<a name="l00353"></a>00353 ${<span class="stringliteral">"$v"</span>}=<a class="code" href="impress__fiche_8php.html#a10">$e</a>;
<a name="l00354"></a>00354 }
<a name="l00355"></a>00355 <span class="comment">// Get the default period</span>
<a name="l00356"></a>00356 $periode=$p_user-&gt;GetPeriode();
<a name="l00357"></a>00357
<a name="l00358"></a>00358 <span class="comment">// Test if the data are correct</span>
<a name="l00359"></a>00359 <span class="comment">// Verify the date</span>
<a name="l00360"></a>00360 <span class="keywordflow">if</span> ( <a class="code" href="ac__common_8php.html#a3">isDate</a>($e_date) == null ) {
<a name="l00361"></a>00361 <a class="code" href="ac__common_8php.html#a0">echo_error</a>(<span class="stringliteral">"Invalid date $e_date"</span>);
<a name="l00362"></a>00362 <a class="code" href="debug_8php.html#a0">echo_debug</a>('user_form_fin.php',__LINE__,<span class="stringliteral">"Invalid date $e_date"</span>);
<a name="l00363"></a>00363 echo <span class="stringliteral">"&lt;SCRIPT&gt; alert('INVALID DATE $e_date !!!!');&lt;/SCRIPT&gt;"</span>;
<a name="l00364"></a>00364 <span class="keywordflow">return</span> null;
<a name="l00365"></a>00365 }
<a name="l00366"></a>00366
<a name="l00367"></a>00367 <span class="comment">// Debit = banque</span>
<a name="l00368"></a>00368 $poste_bq=GetFicheAttribut($p_cn,$e_bank_account,<a class="code" href="constant_8php.html#a48">ATTR_DEF_ACCOUNT</a>);
<a name="l00369"></a>00369 <a class="code" href="postgres_8php.html#a14">StartSql</a>($p_cn);
<a name="l00370"></a>00370 <a class="code" href="print__invoice_8php.html#a1">$amount</a>=0.0;
<a name="l00371"></a>00371 <span class="comment">// Credit = goods </span>
<a name="l00372"></a>00372 <span class="keywordflow">for</span> ( $i = 0; $i &lt; $nb_item;$i++) {
<a name="l00373"></a>00373 <span class="comment">// if tiers is set and amount != 0 insert it into the database </span>
<a name="l00374"></a>00374 <span class="comment">// and quit the loop ?</span>
<a name="l00375"></a>00375 <span class="keywordflow">if</span> ( ${<span class="stringliteral">"e_other$i"</span>.<span class="stringliteral">"_amount"</span>} == 0 ) <span class="keywordflow">continue</span>;
<a name="l00376"></a>00376 <a class="code" href="send__poste__pdf_8php.html#a2">$poste</a>=GetFicheAttribut($p_cn,${<span class="stringliteral">"e_other$i"</span>},<a class="code" href="constant_8php.html#a48">ATTR_DEF_ACCOUNT</a>);
<a name="l00377"></a>00377
<a name="l00378"></a>00378 <a class="code" href="print__invoice_8php.html#a1">$amount</a>+=${<span class="stringliteral">"e_other$i"</span>.<span class="stringliteral">"_amount"</span>};
<a name="l00379"></a>00379 <span class="comment">// Record a line for the bank</span>
<a name="l00380"></a>00380
<a name="l00381"></a>00381 <span class="comment">// Compute the j_grpt</span>
<a name="l00382"></a>00382 <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="l00383"></a>00383
<a name="l00384"></a>00384 <span class="keywordflow">if</span> ( <a class="code" href="user__common_8php.html#a4">InsertJrnx</a>($p_cn,<span class="charliteral">'d'</span>,$p_user-&gt;id,$p_jrn,$poste_bq,$e_date,round(${<span class="stringliteral">"e_other$i"</span>.<span class="stringliteral">"_amount"</span>},2),$seq,$periode) == <span class="keyword">false</span> ) {
<a name="l00385"></a>00385 $Rollback($p_cn);<a class="code" href="balance_8php.html#a0">exit</a>(<span class="stringliteral">"error 'user_form_fin.php' __LINE__"</span>);
<a name="l00386"></a>00386 }
<a name="l00387"></a>00387
<a name="l00388"></a>00388
<a name="l00389"></a>00389 <span class="comment">// Record a line for the other account</span>
<a name="l00390"></a>00390 <span class="keywordflow">if</span> ( ($j_id=<a class="code" href="user__common_8php.html#a4">InsertJrnx</a>($p_cn,<span class="charliteral">'c'</span>,$p_user-&gt;id,$p_jrn,$<a class="code" href="classposte.html">poste</a>,$e_date,round(${<span class="stringliteral">"e_other$i"</span>.<span class="stringliteral">"_amount"</span>},2),$seq,$periode)) == <span class="keyword">false</span> )
<a name="l00391"></a>00391 { $Rollback($p_cn);<a class="code" href="balance_8php.html#a0">exit</a>(<span class="stringliteral">"error 'user_form_fin.php' __LINE__"</span>);}
<a name="l00392"></a>00392
<a name="l00393"></a>00393 <a class="code" href="debug_8php.html#a0">echo_debug</a>('user_form_fin.php',__LINE__,<span class="stringliteral">" $j_id=InsertJrnx($p_cn,'d',$p_user,$p_jrn,$poste,$e_date,"</span>.${<span class="stringliteral">"e_other$i"</span>}.<span class="stringliteral">"_amount"</span>.<span class="stringliteral">",$seq,$periode);"</span>);
<a name="l00394"></a>00394
<a name="l00395"></a>00395 <span class="keywordflow">if</span> ( ($jr_id=<a class="code" href="user__common_8php.html#a5">InsertJrn</a>($p_cn,$e_date,'',$p_jrn,<a class="code" href="ac__common_8php.html#a9">FormatString</a>(${<span class="stringliteral">"e_other$i"</span>.<span class="stringliteral">"_comment"</span>}),
<a name="l00396"></a>00396 round(${<span class="stringliteral">"e_other$i"</span>.<span class="stringliteral">"_amount"</span>},2),$seq,$periode))==<span class="keyword">false</span>) {
<a name="l00397"></a>00397 $<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 'user_form_fin.php' __LINE__"</span>);}
<a name="l00398"></a>00398
<a name="l00399"></a>00399 <span class="keywordflow">if</span> ( <a class="code" href="ac__common_8php.html#a2">isNumber</a>(${<span class="stringliteral">"e_concerned"</span>.$i}) == 1 ) {
<a name="l00400"></a>00400
<a name="l00401"></a>00401 <a class="code" href="user__common_8php.html#a10">InsertRapt</a>($p_cn,$jr_id,${<span class="stringliteral">"e_concerned$i"</span>});
<a name="l00402"></a>00402 }
<a name="l00403"></a>00403
<a name="l00404"></a>00404
<a name="l00405"></a>00405 <span class="comment">// Set Internal code and Comment</span>
<a name="l00406"></a>00406 $internal_code=<a class="code" href="jrn_8php.html#a14">SetInternalCode</a>($p_cn,$seq,$p_jrn);
<a name="l00407"></a>00407 $comment=$internal_code.<span class="stringliteral">" client : "</span>.GetFicheName($p_cn,$e_bank_account);
<a name="l00408"></a>00408 <span class="keywordflow">if</span> ( <a class="code" href="ac__common_8php.html#a9">FormatString</a>(${<span class="stringliteral">"e_other$i"</span>.<span class="stringliteral">"_comment"</span>}) == null ) {
<a name="l00409"></a>00409 <span class="comment">// Update comment if comment is blank</span>
<a name="l00410"></a>00410 $Res=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"update jrn set jr_comment='"</span>.$comment.<span class="stringliteral">"' where jr_grpt_id="</span>.$seq);
<a name="l00411"></a>00411 }
<a name="l00412"></a>00412
<a name="l00413"></a>00413 } <span class="comment">// for nbitem</span>
<a name="l00414"></a>00414 <span class="keywordflow">if</span> ( isset ($_FILES))
<a name="l00415"></a>00415 <a class="code" href="postgres_8php.html#a24">save_upload_document</a>($p_cn,$seq);
<a name="l00416"></a>00416
<a name="l00417"></a>00417 <a class="code" href="postgres_8php.html#a16">Commit</a>($p_cn);
<a name="l00418"></a>00418 }
<a name="l00419"></a>00419 ?&gt;
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri Jun 23 00:12:46 2006 for phpcompta by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.4.4 </small></address>
</body>
</html>