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

1153 lines
117 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/fiche_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">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>fiche_inc.php</h1><a href="fiche__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 Dany De Bontridder ddebontridder@yahoo.fr</span>
<a name="l00021"></a>00021 <span class="comment">// $Revision$</span>
<a name="l00038"></a><a class="code" href="fiche__inc_8php.html#a0">00038</a> <span class="comment"></span>function <a class="code" href="fiche__inc_8php.html#a0">AddFiche</a>($p_cn,$p_type,$p_array) {
<a name="l00039"></a>00039 <span class="comment">// TODO ADD ROLLBACK !!!</span>
<a name="l00040"></a>00040 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">" AddFiche($p_cn,$p_type,$p_array) "</span>);
<a name="l00041"></a>00041 <span class="comment">// Push the array in element starting with p</span>
<a name="l00042"></a>00042 <span class="comment">//</span>
<a name="l00043"></a>00043 foreach ($p_array as $key=&gt;$element){
<a name="l00044"></a>00044 ${<span class="stringliteral">"p_$key"</span>}=$element;
<a name="l00045"></a>00045 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">"p_$key=$element;"</span>);
<a name="l00046"></a>00046 }
<a name="l00047"></a>00047 <span class="comment">// First verify that the name is not null</span>
<a name="l00048"></a>00048 <span class="comment">// av_text.ATTR_DEF_NAME</span>
<a name="l00049"></a>00049 <span class="keywordflow">if</span> ( strlen(trim($p_av_text0 )) ==0 )
<a name="l00050"></a>00050 <span class="keywordflow">return</span>;
<a name="l00051"></a>00051
<a name="l00052"></a>00052 <span class="comment">// First Get the attr of the fiche</span>
<a name="l00053"></a>00053 $field=<a class="code" href="fiche__inc_8php.html#a20">Get_attr_def</a>($p_cn,$p_fd_id);
<a name="l00054"></a>00054
<a name="l00055"></a>00055 <a class="code" href="setup_8php.html#a4">$flag</a>=1;
<a name="l00056"></a>00056
<a name="l00057"></a>00057 <span class="comment">// Create the Fiche</span>
<a name="l00058"></a>00058 <a class="code" href="eub__be_8inc_8php.html#a4">$Sql</a>=<span class="stringliteral">"insert into fiche (fd_id) values ("</span>.$p_fd_id.<span class="stringliteral">")"</span>;
<a name="l00059"></a>00059 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$Sql);
<a name="l00060"></a>00060
<a name="l00061"></a>00061 <span class="comment">// Get is f_id (sequence)</span>
<a name="l00062"></a>00062 $l_f_id=<a class="code" href="postgres_8php.html#a12">GetSequence</a>($p_cn,'s_fiche');
<a name="l00063"></a>00063
<a name="l00064"></a>00064 <span class="comment">// Should we Create accounts for each cards</span>
<a name="l00065"></a>00065 $create=<a class="code" href="fiche__inc_8php.html#a21">GetCreateAccount</a>($p_cn,$p_fd_id);
<a name="l00066"></a>00066
<a name="l00067"></a>00067
<a name="l00068"></a>00068 <span class="comment">// Is a account given ?</span>
<a name="l00069"></a>00069 <span class="keywordflow">for</span> ( $i = 0; $i &lt; $p_inc;$i++) {
<a name="l00070"></a>00070 <span class="comment">//Except for the class base</span>
<a name="l00071"></a>00071 <span class="keywordflow">if</span> ( ${<span class="stringliteral">"p_ad_id$i"</span>} == <a class="code" href="constant_8php.html#a48">ATTR_DEF_ACCOUNT</a> ) {
<a name="l00072"></a>00072 <span class="keywordflow">if</span> (strlen (trim(${<span class="stringliteral">"p_av_text$i"</span>})) == 0 or
<a name="l00073"></a>00073 <a class="code" href="ac__common_8php.html#a2">isNumber</a>(${<span class="stringliteral">"p_av_text$i"</span>}) == 0 )
<a name="l00074"></a>00074 {
<a name="l00075"></a>00075 <span class="keywordflow">break</span>;
<a name="l00076"></a>00076 }
<a name="l00077"></a>00077 <span class="comment">// if account already exist do nothing in tmp_pcmn otherwise add it</span>
<a name="l00078"></a>00078 <span class="keywordflow">if</span> (<a class="code" href="postgres_8php.html#a10">CountSql</a>($p_cn,<span class="stringliteral">"select pcm_val from tmp_pcmn where pcm_val="</span>.${<span class="stringliteral">"p_av_text$i"</span>}) == 0 )
<a name="l00079"></a>00079 {
<a name="l00080"></a>00080 $len=strlen(${<span class="stringliteral">"p_av_text$i"</span>})-1;
<a name="l00081"></a>00081 <span class="comment">// Mother account</span>
<a name="l00082"></a>00082 <a class="code" href="line__update_8php.html#a6">$p_parent</a>=substr(${<span class="stringliteral">"p_av_text$i"</span>},0,$len);
<a name="l00083"></a>00083 <span class="keywordflow">while</span> (<a class="code" href="postgres_8php.html#a10">CountSql</a>($p_cn,<span class="stringliteral">"select pcm_val from tmp_pcmn where pcm_val=$p_parent"</span>) == 0 and
<a name="l00084"></a>00084 $len &gt; 0 ) {
<a name="l00085"></a>00085 $len--;
<a name="l00086"></a>00086 <a class="code" href="line__update_8php.html#a6">$p_parent</a>=substr(${<span class="stringliteral">"p_av_text$i"</span>},0,$len);
<a name="l00087"></a>00087 }
<a name="l00088"></a>00088 <span class="comment">// If no parent found</span>
<a name="l00089"></a>00089 <span class="keywordflow">if</span> ( $len &lt;= 0 ) {
<a name="l00090"></a>00090 <a class="code" href="ac__common_8php.html#a0">echo_error</a> (<span class="stringliteral">"No parent found"</span>);
<a name="l00091"></a>00091 <a class="code" href="balance_8php.html#a0">exit</a>(<span class="stringliteral">"No parent found for "</span>.${<span class="stringliteral">"p_av_text$i"</span>});
<a name="l00092"></a>00092
<a name="l00093"></a>00093 } <span class="comment">// if $len == 0</span>
<a name="l00094"></a>00094 $lib=<a class="code" href="ac__common_8php.html#a9">FormatString</a>($p_av_text0);
<a name="l00095"></a>00095 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=sprintf(<span class="stringliteral">"insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent) </span>
<a name="l00096"></a>00096 <span class="stringliteral"> values (%s,'%s',%d)"</span>,
<a name="l00097"></a>00097 ${<span class="stringliteral">"p_av_text$i"</span>},
<a name="l00098"></a>00098 $lib,
<a name="l00099"></a>00099 $p_parent);
<a name="l00100"></a>00100
<a name="l00101"></a>00101 <span class="comment">// Add if into tmp_pcmn</span>
<a name="l00102"></a>00102 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$Sql);
<a name="l00103"></a>00103 }
<a name="l00104"></a>00104 <span class="comment">// Add it the jnt table</span>
<a name="l00105"></a>00105 <span class="comment">// 5 is always for the account post</span>
<a name="l00106"></a>00106 <a class="code" href="eub__be_8inc_8php.html#a4">$Sql</a>=sprintf(<span class="stringliteral">"insert into jnt_fic_att_value (f_id,ad_id) values (%d,%d)"</span>,
<a name="l00107"></a>00107 $l_f_id,<a class="code" href="constant_8php.html#a48">ATTR_DEF_ACCOUNT</a>);
<a name="l00108"></a>00108 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$Sql);
<a name="l00109"></a>00109
<a name="l00110"></a>00110 <span class="comment">// Get the jft_id sequence (s_jnt_fic_att_value)</span>
<a name="l00111"></a>00111 $l_jft_id=<a class="code" href="postgres_8php.html#a12">GetSequence</a>($p_cn,'s_jnt_fic_att_value');
<a name="l00112"></a>00112
<a name="l00113"></a>00113
<a name="l00114"></a>00114 <span class="comment">// Add it the attr_value table</span>
<a name="l00115"></a>00115 <a class="code" href="eub__be_8inc_8php.html#a4">$Sql</a>=sprintf(<span class="stringliteral">"insert into attr_value(jft_id,av_text) values (%d,'%s')"</span>,
<a name="l00116"></a>00116 $l_jft_id,${<span class="stringliteral">"p_av_text$i"</span>});
<a name="l00117"></a>00117 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$Sql);
<a name="l00118"></a>00118 <span class="comment">// If create == 0 we don't create automatically an account</span>
<a name="l00119"></a>00119 $create=0;
<a name="l00120"></a>00120 }
<a name="l00121"></a>00121
<a name="l00122"></a>00122 } <span class="comment">// for $i...</span>
<a name="l00123"></a>00123
<a name="l00124"></a>00124 <a class="code" href="debug_8php.html#a0">echo_debug</a> ( <span class="stringliteral">" create = $create "</span>);
<a name="l00125"></a>00125 <span class="keywordflow">if</span> ( $create == 1 ) {
<a name="l00126"></a>00126 <span class="comment">// We create an account for each</span>
<a name="l00127"></a>00127 <span class="comment">// Get The Class Base</span>
<a name="l00128"></a>00128 $base=<a class="code" href="fiche__inc_8php.html#a2">GetBaseFiche</a>($p_cn,$p_type);
<a name="l00129"></a>00129
<a name="l00130"></a>00130 <span class="comment">// If a specific post account is needed created it</span>
<a name="l00131"></a>00131
<a name="l00132"></a>00132 <span class="keywordflow">if</span> ( $base !=null ) {
<a name="l00133"></a>00133 <span class="comment">// if the class base is not null, create it in the tmp_pcmn</span>
<a name="l00134"></a>00134 <a class="code" href="jrn__add_8php.html#a17">$num</a>=<a class="code" href="fiche__inc_8php.html#a5">GetNextFiche</a>($p_cn,$base);
<a name="l00135"></a>00135
<a name="l00136"></a>00136 $lib=<a class="code" href="ac__common_8php.html#a9">FormatString</a>($p_av_text0);
<a name="l00137"></a>00137 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=sprintf(<span class="stringliteral">"insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent) </span>
<a name="l00138"></a>00138 <span class="stringliteral"> values (%s,'%s',%d)"</span>,
<a name="l00139"></a>00139 $num,
<a name="l00140"></a>00140 $lib,
<a name="l00141"></a>00141 $base);
<a name="l00142"></a>00142 <a class="code" href="debug_8php.html#a0">echo_debug</a>($sql);
<a name="l00143"></a>00143 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00144"></a>00144 <span class="comment">// Add it the jnt table</span>
<a name="l00145"></a>00145 <span class="comment">// 5 is always for the account post</span>
<a name="l00146"></a>00146 <a class="code" href="eub__be_8inc_8php.html#a4">$Sql</a>=sprintf(<span class="stringliteral">"insert into jnt_fic_att_value (f_id,ad_id) values (%d,%d)"</span>,
<a name="l00147"></a>00147 $l_f_id,<a class="code" href="constant_8php.html#a48">ATTR_DEF_ACCOUNT</a>);
<a name="l00148"></a>00148 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$Sql);
<a name="l00149"></a>00149
<a name="l00150"></a>00150 <span class="comment">// Get the jft_id sequence (s_jnt_fic_att_value)</span>
<a name="l00151"></a>00151 $l_jft_id=<a class="code" href="postgres_8php.html#a12">GetSequence</a>($p_cn,'s_jnt_fic_att_value');
<a name="l00152"></a>00152
<a name="l00153"></a>00153
<a name="l00154"></a>00154 <span class="comment">// Add it the attr_value table</span>
<a name="l00155"></a>00155 <a class="code" href="eub__be_8inc_8php.html#a4">$Sql</a>=sprintf(<span class="stringliteral">"insert into attr_value(jft_id,av_text) values (%d,'%s')"</span>,
<a name="l00156"></a>00156 $l_jft_id,$num);
<a name="l00157"></a>00157 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$Sql);
<a name="l00158"></a>00158 }
<a name="l00159"></a>00159 }<span class="comment">// end create accounts for each cards</span>
<a name="l00160"></a>00160
<a name="l00161"></a>00161
<a name="l00162"></a>00162 <span class="comment">// Add the others attribut in jnt_fic_att_value and after in attr_value</span>
<a name="l00163"></a>00163 <span class="keywordflow">for</span> ( $i = 0; $i &lt; $p_inc;$i++) {
<a name="l00164"></a>00164 <span class="comment">//Except for the class base</span>
<a name="l00165"></a>00165 <span class="keywordflow">if</span> ( ${<span class="stringliteral">"p_ad_id$i"</span>} == <a class="code" href="constant_8php.html#a48">ATTR_DEF_ACCOUNT</a> ) <span class="keywordflow">continue</span>;
<a name="l00166"></a>00166
<a name="l00167"></a>00167 <span class="comment">// Special treatment for QuickCode</span>
<a name="l00168"></a>00168 <span class="keywordflow">if</span> ( ${<span class="stringliteral">"p_ad_id$i"</span>} == <a class="code" href="constant_8php.html#a71">ATTR_DEF_QUICKCODE</a> ) {
<a name="l00169"></a>00169 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=sprintf(<span class="stringliteral">"select insert_quick_code(%d,'%s')"</span>,
<a name="l00170"></a>00170 $l_f_id,<a class="code" href="ac__common_8php.html#a9">FormatString</a>(${<span class="stringliteral">"p_av_text$i"</span>}));
<a name="l00171"></a>00171 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00172"></a>00172 <span class="keywordflow">continue</span>;
<a name="l00173"></a>00173 }
<a name="l00174"></a>00174 <span class="comment">// Add it the jnt table</span>
<a name="l00175"></a>00175 <a class="code" href="eub__be_8inc_8php.html#a4">$Sql</a>=sprintf(<span class="stringliteral">"insert into jnt_fic_att_value (f_id,ad_id) values (%d,%d)"</span>,
<a name="l00176"></a>00176 $l_f_id,${<span class="stringliteral">"p_ad_id$i"</span>});
<a name="l00177"></a>00177 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$Sql);
<a name="l00178"></a>00178
<a name="l00179"></a>00179 <span class="comment">// Get the jft_id sequence (s_jnt_fic_att_value)</span>
<a name="l00180"></a>00180 $l_jft_id=<a class="code" href="postgres_8php.html#a12">GetSequence</a>($p_cn,'s_jnt_fic_att_value');
<a name="l00181"></a>00181
<a name="l00182"></a>00182 <span class="comment">// test the vat rate</span>
<a name="l00183"></a>00183 <span class="keywordflow">if</span> ( ${<span class="stringliteral">"p_ad_id$i"</span>} == <a class="code" href="constant_8php.html#a52">ATTR_DEF_TVA</a> ) {
<a name="l00184"></a>00184 <span class="comment">// is a rate given </span>
<a name="l00185"></a>00185 <span class="keywordflow">if</span> ( strlen(trim(${<span class="stringliteral">"p_av_text$i"</span>})) != 0 and
<a name="l00186"></a>00186 <a class="code" href="ac__common_8php.html#a2">isNumber</a>(${<span class="stringliteral">"p_av_text$i"</span>}) == 1) {
<a name="l00187"></a>00187 <span class="comment">// is a valid rate ?</span>
<a name="l00188"></a>00188 <span class="keywordflow">if</span> ( <a class="code" href="postgres_8php.html#a10">CountSql</a>($p_cn,<span class="stringliteral">"select * from tva_rate where tva_id='"</span>.${<span class="stringliteral">"p_av_text$i"</span>}.<span class="stringliteral">"'"</span>) == 0 ) {
<a name="l00189"></a>00189 <span class="comment">// the rate doesn't exist</span>
<a name="l00190"></a>00190 ${<span class="stringliteral">"p_av_text$i"</span>}=1;
<a name="l00191"></a>00191 <span class="comment">// warning</span>
<a name="l00192"></a>00192 <a class="code" href="ac__common_8php.html#a0">echo_error</a>('invalid rate') ;
<a name="l00193"></a>00193 echo '&lt;script&gt;
<a name="l00194"></a>00194 alert(<span class="stringliteral">"Attention tva invalid, valeur par d<>faut =1 "</span>);
<a name="l00195"></a>00195 &lt;/script&gt;';
<a name="l00196"></a>00196
<a name="l00197"></a>00197 }
<a name="l00198"></a>00198 }<span class="comment">// if a rate is given</span>
<a name="l00199"></a>00199 }
<a name="l00200"></a>00200 $text=<a class="code" href="ac__common_8php.html#a9">FormatString</a>(${<span class="stringliteral">"p_av_text$i"</span>});
<a name="l00201"></a>00201 <span class="comment">// Add it the attr_value table</span>
<a name="l00202"></a>00202 <a class="code" href="eub__be_8inc_8php.html#a4">$Sql</a>=sprintf(<span class="stringliteral">"insert into attr_value(jft_id,av_text) values (%d,'%s')"</span>,
<a name="l00203"></a>00203 $l_jft_id,$text);
<a name="l00204"></a>00204 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$Sql);
<a name="l00205"></a>00205
<a name="l00206"></a>00206 }
<a name="l00207"></a>00207
<a name="l00208"></a>00208 }
<a name="l00225"></a><a class="code" href="fiche__inc_8php.html#a1">00225</a> function <a class="code" href="fiche__inc_8php.html#a1">EncodeFiche</a>($p_cn,$p_type,$p_array=null) {
<a name="l00226"></a>00226 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">"function EncodeFiche($p_cn,$p_type) "</span>);
<a name="l00227"></a>00227
<a name="l00228"></a>00228 $ch_col=<span class="stringliteral">"&lt;/TD&gt;&lt;TD&gt;"</span>;
<a name="l00229"></a>00229 $ch_li='&lt;/TR&gt;&lt;TR&gt;';
<a name="l00230"></a>00230 echo '&lt;<a class="code" href="constant_8php.html#a7">FORM</a> <a class="code" href="classaction.html">action</a>=<span class="stringliteral">"fiche.php"</span> method=<span class="stringliteral">"post"</span> <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"fiche"</span>&gt;';
<a name="l00231"></a>00231 echo '&lt;INPUT TYPE=<span class="stringliteral">"HIDDEN"</span> <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"fiche"</span> <a class="code" href="client_8inc_8php.html#a6">value</a>=<span class="stringliteral">"'.$p_type.'"</span>&gt;';
<a name="l00232"></a>00232 $l_sessid=$_REQUEST['PHPSESSID'];
<a name="l00233"></a>00233
<a name="l00234"></a>00234 echo <a class="code" href="constant_8php.html#a73">JS_SHOW_TVA</a>;
<a name="l00235"></a>00235 echo <a class="code" href="constant_8php.html#a72">JS_SEARCH_POSTE</a>;
<a name="l00236"></a>00236 echo <span class="stringliteral">"&lt;TABLE&gt;"</span>;
<a name="l00237"></a>00237 <span class="keywordflow">if</span> ($p_array == null) {
<a name="l00238"></a>00238 <span class="comment">// Array is null so we display a blank form</span>
<a name="l00239"></a>00239 <span class="comment">// echo '&lt;H2 class="info"&gt;'.getFicheName($p_cn,$p_type).'&lt;/H2&gt;';</span>
<a name="l00240"></a>00240 echo '&lt;H2 <span class="keyword">class</span>=<span class="stringliteral">"info"</span>&gt;New &lt;/H2&gt;';
<a name="l00241"></a>00241 $p_f_id=<span class="stringliteral">""</span>;
<a name="l00242"></a>00242 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">"Array is null"</span>);
<a name="l00243"></a>00243 <span class="comment">// Find all the attribute of the existing cards</span>
<a name="l00244"></a>00244 <span class="comment">// --&gt; Get_attr_def </span>
<a name="l00245"></a>00245 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=<span class="stringliteral">"select frd_id,ad_id,ad_text from fiche_def join jnt_fic_attr using (fd_id)</span>
<a name="l00246"></a>00246 <span class="stringliteral"> join attr_def using (ad_id) where fd_id="</span>.$p_type.<span class="stringliteral">" order by ad_id"</span>;
<a name="l00247"></a>00247
<a name="l00248"></a>00248 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00249"></a>00249 <a class="code" href="setup_8php.html#a11">$Max</a>=pg_NumRows($Res);
<a name="l00250"></a>00250 <span class="comment">// Put the card modele id (fiche_def.fd_id)</span>
<a name="l00251"></a>00251 echo '&lt;INPUT TYPE=<span class="stringliteral">"HIDDEN"</span> <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"fd_id"</span> <a class="code" href="client_8inc_8php.html#a6">value</a>=<span class="stringliteral">"'.$p_type.'"</span>&gt;';
<a name="l00252"></a>00252 <span class="keywordflow">for</span> ($i=0;$i &lt; $Max;$i++) {
<a name="l00253"></a>00253 <a class="code" href="jrn__detail_8php.html#a11">$l_line</a>=pg_fetch_array($Res,$i);
<a name="l00254"></a>00254
<a name="l00255"></a>00255 <span class="comment">// The number of the attribute</span>
<a name="l00256"></a>00256 $Hid=sprintf('&lt;INPUT TYPE=<span class="stringliteral">"HIDDEN"</span> <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"ad_id%d"</span> <a class="code" href="client_8inc_8php.html#a6">value</a>=<span class="stringliteral">"%s"</span>&gt;',
<a name="l00257"></a>00257 $i,$l_line['ad_id']);
<a name="l00258"></a>00258
<a name="l00259"></a>00259 $but_search_poste=<span class="stringliteral">""</span>;
<a name="l00260"></a>00260 <span class="comment">// Javascript for searching the account</span>
<a name="l00261"></a>00261 <span class="keywordflow">if</span> ( $l_line ['ad_id'] == <a class="code" href="constant_8php.html#a48">ATTR_DEF_ACCOUNT</a> ) {
<a name="l00262"></a>00262 $ctl_name=<span class="stringliteral">"av_text$i"</span>;
<a name="l00263"></a>00263 $but_search_poste='&lt;INPUT TYPE=<span class="stringliteral">"BUTTON"</span> VALUE=<span class="stringliteral">"Cherche"</span> OnClick=<span class="stringliteral">"SearchPoste(\''.$l_sessid.'\',\''.$ctl_name.'\')"</span>&gt;';
<a name="l00264"></a>00264 }
<a name="l00265"></a>00265 <span class="comment">// Javascript for showing the tva</span>
<a name="l00266"></a>00266 <span class="keywordflow">if</span> ( $l_line ['ad_id'] == <a class="code" href="constant_8php.html#a52">ATTR_DEF_TVA</a> ) {
<a name="l00267"></a>00267 $but_search_poste='&lt;INPUT TYPE=<span class="stringliteral">"BUTTON"</span> VALUE=<span class="stringliteral">"Montre"</span> OnClick=<span class="stringliteral">"ShowTva(\''.$l_sessid.'\', \'av_text'.$i.'\')"</span>&gt;';
<a name="l00268"></a>00268 }
<a name="l00269"></a>00269 <span class="comment">// content of the attribute</span>
<a name="l00270"></a>00270 printf ('&lt;TR&gt;&lt;TD&gt; %s &lt;/TD&gt;&lt;TD&gt;&lt;INPUT TYPE=<span class="stringliteral">"TEXT"</span> NAME=<span class="stringliteral">"av_text%d"</span>&gt;%s %s&lt;/TD&gt;&lt;/TR&gt;',
<a name="l00271"></a>00271 $l_line['ad_text'], $i,$Hid,$but_search_poste);
<a name="l00272"></a>00272 }
<a name="l00273"></a>00273 echo '&lt;/TR&gt;';
<a name="l00274"></a>00274 echo '&lt;/TABLE&gt;';
<a name="l00275"></a>00275 echo '&lt;INPUT TYPE=<span class="stringliteral">"HIDDEN"</span> <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"inc"</span> <a class="code" href="client_8inc_8php.html#a6">value</a>=<span class="stringliteral">"'.$Max.'"</span>&gt;';
<a name="l00276"></a>00276 echo '&lt;INPUT TYPE=<span class="stringliteral">"SUBMIT"</span> <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"add_fiche"</span> <a class="code" href="client_8inc_8php.html#a6">value</a>=<span class="stringliteral">"ajoute"</span>&gt;';
<a name="l00277"></a>00277 echo '&lt;/<a class="code" href="constant_8php.html#a7">FORM</a>&gt;';
<a name="l00278"></a>00278 }<span class="keywordflow">else</span> {
<a name="l00279"></a>00279 <span class="comment">// Array is not null so we have to find the card's data from the database</span>
<a name="l00280"></a>00280 <span class="comment">// and display them</span>
<a name="l00281"></a>00281
<a name="l00282"></a>00282 <span class="comment">// Display the card name</span>
<a name="l00283"></a>00283 <a class="code" href="pref_8inc_8php.html#a6">$label</a>=<a class="code" href="fiche__inc_8php.html#a15">getFicheNameById</a>($p_cn,$p_type);
<a name="l00284"></a>00284 echo '&lt;H2 <span class="keyword">class</span>=<span class="stringliteral">"info"</span>&gt;'.$label.'&lt;/H2&gt;';
<a name="l00285"></a>00285
<a name="l00286"></a>00286 <span class="comment">// Find all the data related to the card</span>
<a name="l00287"></a>00287 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=<span class="stringliteral">"select av_text,ad_id,ad_text,jft_id from attr_value</span>
<a name="l00288"></a>00288 <span class="stringliteral"> natural join attr_def </span>
<a name="l00289"></a>00289 <span class="stringliteral"> natural join jnt_fic_att_value </span>
<a name="l00290"></a>00290 <span class="stringliteral"> natural join fiche where f_id=$p_type order by ad_id"</span>;
<a name="l00291"></a>00291
<a name="l00292"></a>00292 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00293"></a>00293 <a class="code" href="setup_8php.html#a11">$Max</a>=pg_NumRows($Res);
<a name="l00294"></a>00294 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">"Max ==== $Max"</span>);
<a name="l00295"></a>00295
<a name="l00296"></a>00296 echo '&lt;INPUT TYPE=<span class="stringliteral">"HIDDEN"</span> <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"f_id"</span> <a class="code" href="client_8inc_8php.html#a6">value</a>=<span class="stringliteral">"'.$p_type.'"</span>&gt;';
<a name="l00297"></a>00297 echo '&lt;INPUT TYPE=<span class="stringliteral">"HIDDEN"</span> <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"f_label"</span> <a class="code" href="client_8inc_8php.html#a6">value</a>=<span class="stringliteral">"'.$label.'"</span>&gt;';
<a name="l00298"></a>00298 echo '&lt;INPUT TYPE=<span class="stringliteral">"HIDDEN"</span> <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"max"</span> <a class="code" href="client_8inc_8php.html#a6">value</a>=<span class="stringliteral">"'.$Max.'"</span>&gt;';
<a name="l00299"></a>00299
<a name="l00300"></a>00300 <span class="keywordflow">for</span> ($i=0;$i &lt; $Max;$i++) {
<a name="l00301"></a>00301 <span class="comment">// fetch the data</span>
<a name="l00302"></a>00302 <a class="code" href="jrn__detail_8php.html#a11">$l_line</a>=pg_fetch_array($Res,$i);
<a name="l00303"></a>00303
<a name="l00304"></a>00304 <span class="comment">// Put also the class in a special variable</span>
<a name="l00305"></a>00305 <span class="comment">// useful when we want to update the PCMN</span>
<a name="l00306"></a>00306
<a name="l00307"></a>00307 $but_search_poste=<span class="stringliteral">""</span>;
<a name="l00308"></a>00308 <span class="keywordflow">if</span> ( $l_line['ad_id'] == <a class="code" href="constant_8php.html#a48">ATTR_DEF_ACCOUNT</a> ) {
<a name="l00309"></a>00309 printf('&lt;INPUT TYPE=<span class="stringliteral">"HIDDEN"</span> <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"class"</span> <a class="code" href="client_8inc_8php.html#a6">value</a>=<span class="stringliteral">"%s"</span>&gt;',
<a name="l00310"></a>00310 $l_line['av_text']);
<a name="l00311"></a>00311 <span class="comment">// Javascript for searching the account</span>
<a name="l00312"></a>00312 $ctl_name=<span class="stringliteral">"av_text$i"</span>;
<a name="l00313"></a>00313 $but_search_poste='&lt;INPUT TYPE=<span class="stringliteral">"BUTTON"</span> VALUE=<span class="stringliteral">"Cherche"</span> OnClick=<span class="stringliteral">"SearchPoste(\''.$l_sessid.'\',\''.$ctl_name.'\')"</span>&gt;';
<a name="l00314"></a>00314 }
<a name="l00315"></a>00315
<a name="l00316"></a>00316 <span class="comment">// Javascript for showing the tva</span>
<a name="l00317"></a>00317 <span class="keywordflow">if</span> ( $l_line ['ad_id'] == <a class="code" href="constant_8php.html#a52">ATTR_DEF_TVA</a> ) {
<a name="l00318"></a>00318 $but_search_poste='&lt;INPUT TYPE=<span class="stringliteral">"BUTTON"</span> VALUE=<span class="stringliteral">"Montre"</span> OnClick=<span class="stringliteral">"ShowTva(\''.$l_sessid.'\',\'av_text'.$i.'\')"</span>&gt;';
<a name="l00319"></a>00319 }
<a name="l00320"></a>00320
<a name="l00321"></a>00321 <span class="comment">// hide ad_id</span>
<a name="l00322"></a>00322 $ad=sprintf('&lt;input type=<span class="stringliteral">"hidden"</span> <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"ad_id%d"</span> <a class="code" href="client_8inc_8php.html#a6">value</a>=<span class="stringliteral">"%s"</span>&gt;',
<a name="l00323"></a>00323 $l_line['ad_id'],$l_line['av_text']);
<a name="l00324"></a>00324
<a name="l00325"></a>00325 <span class="comment">// in hidden we put the jft_id</span>
<a name="l00326"></a>00326 $Hid=sprintf('&lt;INPUT TYPE=<span class="stringliteral">"HIDDEN"</span> <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"jft_id%d"</span> <a class="code" href="client_8inc_8php.html#a6">value</a>=<span class="stringliteral">"%s"</span>&gt;',
<a name="l00327"></a>00327 $i,$l_line['jft_id']);
<a name="l00328"></a>00328 printf ('&lt;TR&gt;&lt;TD&gt; %s &lt;/TD&gt;&lt;TD&gt;&lt;INPUT TYPE=<span class="stringliteral">"TEXT"</span> NAME=<span class="stringliteral">"av_text%d"</span> VALUE=<span class="stringliteral">"%s"</span>&gt;%s %s %s&lt;/TD&gt;&lt;/TR&gt;',
<a name="l00329"></a>00329 $l_line['ad_text'], $i, $l_line['av_text'],$Hid,$but_search_poste,$ad);
<a name="l00330"></a>00330
<a name="l00331"></a>00331 }
<a name="l00332"></a>00332 echo '&lt;/TR&gt;';
<a name="l00333"></a>00333 echo '&lt;/TABLE&gt;';
<a name="l00334"></a>00334 echo '&lt;INPUT TYPE=<span class="stringliteral">"SUBMIT"</span> <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"update_fiche"</span> <a class="code" href="client_8inc_8php.html#a6">value</a>=<span class="stringliteral">"Mis <20> jour"</span>&gt;';
<a name="l00335"></a>00335 echo '&lt;/<a class="code" href="constant_8php.html#a7">FORM</a>&gt;';
<a name="l00336"></a>00336 }
<a name="l00337"></a>00337 }
<a name="l00338"></a>00338
<a name="l00352"></a><a class="code" href="fiche__inc_8php.html#a2">00352</a> function <a class="code" href="fiche__inc_8php.html#a2">GetBaseFiche</a>($p_cn,$p_type) {
<a name="l00353"></a>00353 $base=null;
<a name="l00354"></a>00354 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"select fd_class_base from fiche_def where fd_id="</span>.$p_type);
<a name="l00355"></a>00355 <span class="keywordflow">if</span> ( pg_NumRows($Res) == 0 ) <span class="keywordflow">return</span> null;
<a name="l00356"></a>00356 $base=pg_fetch_array($Res,0);
<a name="l00357"></a>00357 <span class="keywordflow">return</span> $base['fd_class_base'];
<a name="l00358"></a>00358 }
<a name="l00359"></a>00359
<a name="l00374"></a><a class="code" href="fiche__inc_8php.html#a3">00374</a> function <a class="code" href="fiche__inc_8php.html#a3">GetBaseFicheDefault</a>($p_cn,$p_type) {
<a name="l00375"></a>00375 $base=null;
<a name="l00376"></a>00376 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"select frd_class_base from fiche_def_ref where frd_id="</span>.$p_type);
<a name="l00377"></a>00377 <span class="keywordflow">if</span> ( pg_NumRows($Res) == 0 ) <span class="keywordflow">return</span> null;
<a name="l00378"></a>00378 $base=pg_fetch_array($Res,0);
<a name="l00379"></a>00379 <span class="keywordflow">return</span> $base['<a class="code" href="fiche__def_8inc_8php.html#a3">frd_class_base</a>'];
<a name="l00380"></a>00380 }
<a name="l00394"></a><a class="code" href="fiche__inc_8php.html#a4">00394</a> function <a class="code" href="fiche__inc_8php.html#a4">ViewFiche</a>($p_cn,$p_type) {
<a name="l00395"></a>00395 require_once(<span class="stringliteral">"user_common.php"</span>);
<a name="l00396"></a>00396 echo '&lt;H2 <span class="keyword">class</span>=<span class="stringliteral">"info"</span>&gt;'.getFicheDefName($p_cn,$p_type).'&lt;/H2&gt;';
<a name="l00397"></a>00397
<a name="l00398"></a>00398 <a class="code" href="facture_8inc_8php.html#a12">$step</a>=<a class="code" href="commercial_8php.html#a0">$_SESSION</a>['g_pagesize'];
<a name="l00399"></a>00399 <a class="code" href="jrn__search_8php.html#a16">$sql_limit</a>=<span class="stringliteral">""</span>;
<a name="l00400"></a>00400 <a class="code" href="jrn__search_8php.html#a17">$sql_offset</a>=<span class="stringliteral">""</span>;
<a name="l00401"></a>00401 <span class="keywordflow">if</span> ( $step != -1 ) {
<a name="l00402"></a>00402 <a class="code" href="facture_8inc_8php.html#a13">$page</a>=(isset($_GET['page']))?$_GET['page']:1;
<a name="l00403"></a>00403 <a class="code" href="facture_8inc_8php.html#a14">$offset</a>=(isset($_GET['offset']))?$_GET['offset']:0;
<a name="l00404"></a>00404 $max_line=<a class="code" href="postgres_8php.html#a10">CountSql</a>($p_cn,<span class="stringliteral">"select f_id,av_text from </span>
<a name="l00405"></a>00405 <span class="stringliteral"> fiche join jnt_fic_att_value using (f_id) </span>
<a name="l00406"></a>00406 <span class="stringliteral"> join attr_value using (jft_id)</span>
<a name="l00407"></a>00407 <span class="stringliteral"> where fd_id='"</span>.$p_type.<span class="stringliteral">"' and ad_id="</span>.<a class="code" href="constant_8php.html#a49">ATTR_DEF_NAME</a>.<span class="stringliteral">" order by f_id"</span>);
<a name="l00408"></a>00408 <a class="code" href="jrn__search_8php.html#a16">$sql_limit</a>=<span class="stringliteral">" limit "</span>.$step;
<a name="l00409"></a>00409 <a class="code" href="jrn__search_8php.html#a17">$sql_offset</a>=<span class="stringliteral">" offset "</span>.$offset;
<a name="l00410"></a>00410 <a class="code" href="facture_8inc_8php.html#a16">$bar</a>=<a class="code" href="user__common_8php.html#a16">jrn_navigation_bar</a>($offset,$max_line,$step,$page);
<a name="l00411"></a>00411 }
<a name="l00412"></a>00412
<a name="l00413"></a>00413 <span class="comment">// Get all name the cards of the select category</span>
<a name="l00414"></a>00414 <span class="comment">// 1 for attr_def.ad_id is always the name</span>
<a name="l00415"></a>00415 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"select f_id,av_text,j_qcode from </span>
<a name="l00416"></a>00416 <span class="stringliteral"> fiche join jnt_fic_att_value using (f_id) </span>
<a name="l00417"></a>00417 <span class="stringliteral"> join attr_value using (jft_id)</span>
<a name="l00418"></a>00418 <span class="stringliteral"> left outer join vw_poste_qcode using(f_id)</span>
<a name="l00419"></a>00419 <span class="stringliteral"> where fd_id='"</span>.$p_type.
<a name="l00420"></a>00420 <span class="stringliteral">"' and ad_id="</span>.ATTR_DEF_NAME.<span class="stringliteral">" order by f_id $sql_offset $sql_limit "</span>);
<a name="l00421"></a>00421 <a class="code" href="setup_8php.html#a11">$Max</a>=pg_NumRows($Res);
<a name="l00422"></a>00422 echo <a class="code" href="facture_8inc_8php.html#a16">$bar</a>;
<a name="l00423"></a>00423
<a name="l00424"></a>00424 <span class="keywordflow">for</span> ( $i = 0; $i &lt; $Max; $i++) {
<a name="l00425"></a>00425 <a class="code" href="jrn__detail_8php.html#a11">$l_line</a>=pg_fetch_array($Res,$i);
<a name="l00426"></a>00426 $div=<span class="stringliteral">"&lt;DIV&gt;"</span>;
<a name="l00427"></a>00427 $span_mod='&lt;span <span class="keyword">class</span>=<span class="stringliteral">"mtitle"</span>&gt;&lt;A <span class="keyword">class</span>=<span class="stringliteral">"mtitle2"</span> href=<span class="stringliteral">"fiche.php?action=detail&amp;fiche_id='.$l_line['f_id'].'"</span>&gt; Modifie&lt;/A&gt;&lt;/SPAN&gt;';
<a name="l00428"></a>00428 $span_del='&lt;span <span class="keyword">class</span>=<span class="stringliteral">"mtitle2"</span> ALIGN=<span class="stringliteral">"left"</span>&gt;'.
<a name="l00429"></a>00429 '&lt;A <span class="keyword">class</span>=<span class="stringliteral">"mtitle2"</span> href=<span class="stringliteral">"fiche.php?f_fd_id='.$p_type.'&amp;action=delete&amp;fiche_id='.$l_line['f_id'].</span>
<a name="l00430"></a>00430 <span class="stringliteral"> '"</span>&gt; <span class="keyword">delete</span>&lt;/A&gt;&lt;/SPAN&gt;';
<a name="l00431"></a>00431 $span_id='&lt;SPAN style=<span class="stringliteral">"background-color:lightgrey;"</span>&gt;'.$l_line['j_qcode'].<span class="stringliteral">"&lt;/SPAN&gt;"</span>;
<a name="l00432"></a>00432 <span class="keywordflow">if</span> ( $i %2 == 0 )
<a name="l00433"></a>00433 $div='&lt;DIV style=<span class="stringliteral">"background-color:#DDE6FF;"</span>&gt;';
<a name="l00434"></a>00434 echo $div.$span_del.'&amp;nbsp;<span class="charliteral">'.'</span>&amp;nbsp;<span class="charliteral">'.'</span>&amp;nbsp;<span class="charliteral">'.'</span>&amp;nbsp;<span class="charliteral">'.'</span>&amp;nbsp;<span class="charliteral">'.'</span>&amp;nbsp;'.
<a name="l00435"></a>00435 $span_mod.<span class="stringliteral">"&amp;nbsp;"</span>.<span class="stringliteral">"&amp;nbsp;"</span>.<span class="stringliteral">"&amp;nbsp;"</span>.$span_id.<span class="stringliteral">"&amp;nbsp;"</span>.<span class="stringliteral">"&amp;nbsp;"</span>.<span class="stringliteral">"&amp;nbsp;"</span>.<a class="code" href="jrn__detail_8php.html#a11">$l_line</a>['av_text'].<span class="stringliteral">"&lt;/DIV&gt;"</span>;
<a name="l00436"></a>00436 }
<a name="l00437"></a>00437 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">"fiche.php"</span>&gt;';
<a name="l00438"></a>00438 echo '&lt;INPUT TYPE=<span class="stringliteral">"HIDDEN"</span> <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"fiche"</span> <a class="code" href="client_8inc_8php.html#a6">value</a>=<span class="stringliteral">"'.$p_type.'"</span>&gt;';
<a name="l00439"></a>00439 echo '&lt;INPUT TYPE=<span class="stringliteral">"SUBMIT"</span> <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"add"</span> Value=<span class="stringliteral">"Ajout fiche"</span>&gt;';
<a name="l00440"></a>00440 echo '&lt;/<a class="code" href="constant_8php.html#a7">FORM</a>&gt;';
<a name="l00441"></a>00441 echo $bar;
<a name="l00442"></a>00442
<a name="l00443"></a>00443 }
<a name="l00458"></a><a class="code" href="fiche__inc_8php.html#a5">00458</a> function <a class="code" href="fiche__inc_8php.html#a5">GetNextFiche</a>($p_cn,$p_base) {
<a name="l00459"></a>00459 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"select max(pcm_val) as maxcode from tmp_pcmn where pcm_val_parent = $p_base"</span>);
<a name="l00460"></a>00460 <a class="code" href="setup_8php.html#a11">$Max</a>=pg_NumRows($Res);
<a name="l00461"></a>00461 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">"$Max=pg_NumRows"</span>);
<a name="l00462"></a>00462 <a class="code" href="jrn__detail_8php.html#a11">$l_line</a>=pg_fetch_array($Res,0);
<a name="l00463"></a>00463 <a class="code" href="class__operation_8php.html#a4">$ret</a>=<a class="code" href="jrn__detail_8php.html#a11">$l_line</a>['maxcode'];
<a name="l00464"></a>00464 <span class="keywordflow">if</span> ( $ret == <span class="stringliteral">""</span> ) {
<a name="l00465"></a>00465 <a class="code" href="class__operation_8php.html#a4">$ret</a>=sprintf(<span class="stringliteral">"%d%04d"</span>,$p_base,0);
<a name="l00466"></a>00466 <span class="keywordflow">return</span> <a class="code" href="class__operation_8php.html#a4">$ret</a>+1;
<a name="l00467"></a>00467
<a name="l00468"></a>00468 }
<a name="l00469"></a>00469
<a name="l00470"></a>00470 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">"ret $ret"</span>);
<a name="l00471"></a>00471 <span class="keywordflow">return</span> <a class="code" href="class__operation_8php.html#a4">$ret</a>+1;
<a name="l00472"></a>00472 }
<a name="l00488"></a><a class="code" href="fiche__inc_8php.html#a6">00488</a> function <a class="code" href="fiche__inc_8php.html#a6">ViewFicheDetail</a>($p_cn,$p_id) {
<a name="l00489"></a>00489
<a name="l00490"></a>00490 <span class="comment">// Retrieve the fiche_def.fd_id of the card</span>
<a name="l00491"></a>00491 $fd_id=<a class="code" href="fiche__inc_8php.html#a23">GetFicheDef</a>($p_cn,$p_id);
<a name="l00492"></a>00492
<a name="l00493"></a>00493 <span class="comment">//Update the default attribute of a card if is model has changed</span>
<a name="l00494"></a>00494 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=<span class="stringliteral">"insert into jnt_fic_att_value (f_id,ad_id) </span>
<a name="l00495"></a>00495 <span class="stringliteral"> select $p_id, ad_id </span>
<a name="l00496"></a>00496 <span class="stringliteral"> from jnt_fic_attr </span>
<a name="l00497"></a>00497 <span class="stringliteral"> where fd_id=$fd_id and </span>
<a name="l00498"></a>00498 <span class="stringliteral"> ad_id not in (select ad_id from jnt_fic_att_value where</span>
<a name="l00499"></a>00499 <span class="stringliteral"> f_id=$p_id)"</span>;
<a name="l00500"></a>00500
<a name="l00501"></a>00501 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00502"></a>00502
<a name="l00503"></a>00503 <span class="comment">// add a empty string to attr_value</span>
<a name="l00504"></a>00504 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=<span class="stringliteral">"insert into attr_value select jft_id,'' from jnt_fic_att_value</span>
<a name="l00505"></a>00505 <span class="stringliteral"> where f_id=$p_id and jft_id not in (select jft_id from attr_value natural join jnt_fic_att_value where </span>
<a name="l00506"></a>00506 <span class="stringliteral"> f_id = $p_id)"</span>;
<a name="l00507"></a>00507 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00508"></a>00508
<a name="l00509"></a>00509 <a class="code" href="fiche__inc_8php.html#a1">EncodeFiche</a> ($p_cn,$p_id,1);
<a name="l00510"></a>00510 }
<a name="l00526"></a><a class="code" href="fiche__inc_8php.html#a7">00526</a> function <a class="code" href="fiche__inc_8php.html#a7">UpdateFiche</a>($p_cn,$p_array) {
<a name="l00527"></a>00527
<a name="l00528"></a>00528 <a class="code" href="debug_8php.html#a0">echo_debug</a> ('fiche_inc.php',__LINE__,<span class="stringliteral">"UpdateFiche"</span>);
<a name="l00529"></a>00529 $tva_error=<span class="keyword">false</span>;
<a name="l00530"></a>00530 foreach ( $p_array as $key=&gt; $element) {
<a name="l00531"></a>00531 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">"UF $key =&gt; $element"</span>);
<a name="l00532"></a>00532 ${<span class="stringliteral">"$key"</span>}=$element;
<a name="l00533"></a>00533 <span class="comment">// Get the name</span>
<a name="l00534"></a>00534 <span class="keywordflow">if</span> ( $key == <span class="stringliteral">"ad_id"</span>.<a class="code" href="constant_8php.html#a49">ATTR_DEF_NAME</a> ) {
<a name="l00535"></a>00535 <a class="code" href="pref_8inc_8php.html#a6">$label</a>=$element;
<a name="l00536"></a>00536 <span class="keywordflow">if</span> (strlen(trim($<a class="code" href="balance_8php.html#a5">label</a>))== 0 )
<a name="l00537"></a>00537 <span class="keywordflow">return</span>;
<a name="l00538"></a>00538 }
<a name="l00539"></a>00539 <span class="comment">// Get the class base</span>
<a name="l00540"></a>00540 <span class="keywordflow">if</span> ( $key==<span class="stringliteral">"ad_id"</span>.<a class="code" href="constant_8php.html#a48">ATTR_DEF_ACCOUNT</a>) {
<a name="l00541"></a>00541 $class=$element;
<a name="l00542"></a>00542 }
<a name="l00543"></a>00543 <span class="comment">// Get the vat and</span>
<a name="l00544"></a>00544 <span class="comment">// test the vat rate</span>
<a name="l00545"></a>00545 <span class="keywordflow">if</span> ( $key == 'ad_id'.<a class="code" href="constant_8php.html#a52">ATTR_DEF_TVA</a> ) {
<a name="l00546"></a>00546 <span class="comment">// is a valid rate ?</span>
<a name="l00547"></a>00547 <span class="keywordflow">if</span> ( strlen(trim($element)) == 0 ) <span class="keywordflow">continue</span>;
<a name="l00548"></a>00548 <span class="keywordflow">if</span> ( <a class="code" href="postgres_8php.html#a10">CountSql</a>($p_cn,<span class="stringliteral">"select * from tva_rate where tva_id='"</span>.$element.<span class="stringliteral">"'"</span>) == 0 ) {
<a name="l00549"></a>00549 <span class="comment">// warning</span>
<a name="l00550"></a>00550 <a class="code" href="ac__common_8php.html#a0">echo_error</a>('invalid rate') ;
<a name="l00551"></a>00551 echo '&lt;script&gt;
<a name="l00552"></a>00552 alert(<span class="stringliteral">"Attention tva invalid remis <20> sa valeur par d<>faut "</span>);
<a name="l00553"></a>00553 &lt;/script&gt;';
<a name="l00554"></a>00554 $tva_error=<span class="keyword">true</span>;
<a name="l00555"></a>00555 }
<a name="l00556"></a>00556 }
<a name="l00557"></a>00557 }
<a name="l00558"></a>00558 <span class="comment">// If each card has it own account must also update the tmp_pcm table</span>
<a name="l00559"></a>00559 <span class="comment">//</span>
<a name="l00560"></a>00560 $fd_ref=<a class="code" href="fiche__inc_8php.html#a22">GetFicheDefRef</a>($p_cn,$<a class="code" href="classfiche.html">fiche</a>);
<a name="l00561"></a>00561 <span class="comment">// Update all the others data</span>
<a name="l00562"></a>00562 <span class="keywordflow">for</span> ( $i =0 ; $i &lt; $max ; $i++) {
<a name="l00563"></a>00563 <span class="comment">// Format text</span>
<a name="l00564"></a>00564 $text=<a class="code" href="ac__common_8php.html#a9">FormatString</a>( ${<span class="stringliteral">"av_text$i"</span>});
<a name="l00565"></a>00565 <span class="comment">// Check if we don't try to update a QUICK CODE</span>
<a name="l00566"></a>00566 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"select ad_id from jnt_fic_att_value where jft_id="</span>.${<span class="stringliteral">"jft_id$i"</span>});
<a name="l00567"></a>00567 <a class="code" href="balance_8php.html#a9">$a</a>=pg_fetch_array($Res,0);
<a name="l00568"></a>00568 <span class="keywordflow">if</span> ( $a['ad_id'] != <a class="code" href="constant_8php.html#a71">ATTR_DEF_QUICKCODE</a>)
<a name="l00569"></a>00569 {
<a name="l00570"></a>00570 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=sprintf(<span class="stringliteral">"update attr_value set av_text='%s' where jft_id=%d"</span>,
<a name="l00571"></a>00571 $text,
<a name="l00572"></a>00572 ${<span class="stringliteral">"jft_id$i"</span>});
<a name="l00573"></a>00573 }
<a name="l00574"></a>00574 <span class="keywordflow">else</span>
<a name="l00575"></a>00575 {
<a name="l00576"></a>00576 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=sprintf(<span class="stringliteral">"select update_quick_code(%d,'%s')"</span>,
<a name="l00577"></a>00577 ${<span class="stringliteral">"jft_id$i"</span>},
<a name="l00578"></a>00578 $text);
<a name="l00579"></a>00579 }
<a name="l00580"></a>00580 <span class="comment">// Execute SQL</span>
<a name="l00581"></a>00581 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00582"></a>00582 }
<a name="l00583"></a>00583 <span class="comment">// Update tva to his default value</span>
<a name="l00584"></a>00584 <span class="keywordflow">if</span> ( $tva_error == <span class="keyword">true</span> ) {
<a name="l00585"></a>00585 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=<span class="stringliteral">"update attr_value set av_text=1 where jft_id = ( select jft_id from jnt_fic_att_value </span>
<a name="l00586"></a>00586 <span class="stringliteral"> natural join fiche natural join attr_def </span>
<a name="l00587"></a>00587 <span class="stringliteral"> where ad_id="</span>.ATTR_DEF_TVA.<span class="stringliteral">" and f_id=$fiche)"</span>;
<a name="l00588"></a>00588 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00589"></a>00589 }
<a name="l00590"></a>00590
<a name="l00591"></a>00591 <span class="comment">// Update the PCMN if needed</span>
<a name="l00592"></a>00592 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=<span class="stringliteral">"select av_text from attr_value natural join jnt_fic_att_value</span>
<a name="l00593"></a>00593 <span class="stringliteral"> where f_id=$fiche and ad_id="</span>.ATTR_DEF_ACCOUNT;
<a name="l00594"></a>00594 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00595"></a>00595
<a name="l00596"></a>00596 <span class="keywordflow">if</span> ( pg_NumRows($Res) != 0 ) {
<a name="l00597"></a>00597 <span class="comment">// it means that a account exists</span>
<a name="l00598"></a>00598 <span class="comment">// Retrieve the name and the ad_id 5</span>
<a name="l00599"></a>00599 $f=pg_fetch_array($Res,0);
<a name="l00600"></a>00600 $class_old=$f['av_text'];
<a name="l00601"></a>00601
<a name="l00602"></a>00602 <span class="comment">// if the class changed</span>
<a name="l00603"></a>00603 <span class="keywordflow">if</span> ( $<span class="keyword">class</span> != $class_old and $<span class="keyword">class</span> != <span class="stringliteral">""</span> ) {
<a name="l00604"></a>00604 <span class="keywordflow">if</span> ( <a class="code" href="postgres_8php.html#a10">CountSql</a>($p_cn,<span class="stringliteral">"select * from jrnx where j_poste=$class"</span>) or
<a name="l00605"></a>00605 <a class="code" href="postgres_8php.html#a10">CountSql</a>($p_cn,<span class="stringliteral">"select * from jrnx where j_poste=$class_old"</span> ))
<a name="l00606"></a>00606 {
<a name="l00607"></a>00607 <span class="comment">// No change if the account is already used </span>
<a name="l00608"></a>00608 <a class="code" href="ac__common_8php.html#a0">echo_error</a>(<span class="stringliteral">"Not possible to change the account, already used"</span>);
<a name="l00609"></a>00609 } <span class="keywordflow">else</span> {
<a name="l00610"></a>00610 <span class="keywordflow">if</span> ( <a class="code" href="postgres_8php.html#a10">CountSql</a>($p_cn,<span class="stringliteral">"select * from tmp_pcmn where pcm_val="</span>.$<span class="keyword">class</span>) ==0)
<a name="l00611"></a>00611 <span class="comment">// we have to insert </span>
<a name="l00612"></a>00612 {
<a name="l00613"></a>00613 <span class="comment">// First we must use a parent</span>
<a name="l00614"></a>00614 $parent=<a class="code" href="fiche__inc_8php.html#a28">GetParent</a>($p_cn,$<span class="keyword">class</span>);
<a name="l00615"></a>00615 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,
<a name="l00616"></a>00616 <span class="stringliteral">"insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent) </span>
<a name="l00617"></a>00617 <span class="stringliteral"> values ($class,'$f_label',$parent)"</span>);
<a name="l00618"></a>00618 }
<a name="l00619"></a>00619 }
<a name="l00620"></a>00620 $class=$class_old;
<a name="l00621"></a>00621 } <span class="keywordflow">else</span> <span class="comment">// $class=""</span>
<a name="l00622"></a>00622 {
<a name="l00623"></a>00623
<a name="l00624"></a>00624 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">"new account "</span>);
<a name="l00625"></a>00625 $class=$class_old;
<a name="l00626"></a>00626 <span class="keywordflow">if</span> ( <a class="code" href="postgres_8php.html#a10">CountSql</a>($p_cn,<span class="stringliteral">"select * from tmp_pcmn where pcm_val="</span>.$<span class="keyword">class</span>) == 0 ) {
<a name="l00627"></a>00627 <span class="comment">// First we must use a parent</span>
<a name="l00628"></a>00628 $parent=<a class="code" href="fiche__inc_8php.html#a28">GetParent</a>($p_cn,$<span class="keyword">class</span>);
<a name="l00629"></a>00629 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,
<a name="l00630"></a>00630 <span class="stringliteral">"insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent) </span>
<a name="l00631"></a>00631 <span class="stringliteral"> values ($class,'$f_label',$parent)"</span>);
<a name="l00632"></a>00632 }
<a name="l00633"></a>00633 }
<a name="l00634"></a>00634
<a name="l00635"></a>00635
<a name="l00636"></a>00636 <span class="comment">// Change the name in TMP_PCMN</span>
<a name="l00637"></a>00637 <span class="comment">// Get the new name</span>
<a name="l00638"></a>00638 $f_label=<a class="code" href="ac__common_8php.html#a9">FormatString</a>($f_label);
<a name="l00639"></a>00639 <a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"update tmp_pcmn set pcm_lib='"</span>.$f_label.<span class="stringliteral">"' where pcm_val="</span>.$<span class="keyword">class</span>);
<a name="l00640"></a>00640
<a name="l00641"></a>00641
<a name="l00642"></a>00642 }
<a name="l00643"></a>00643 <span class="comment">// Update of TMP_PCMN if a class base is given (ad_id=5)</span>
<a name="l00644"></a>00644
<a name="l00645"></a>00645
<a name="l00646"></a>00646
<a name="l00647"></a>00647 }
<a name="l00660"></a><a class="code" href="fiche__inc_8php.html#a8">00660</a> function <a class="code" href="fiche__inc_8php.html#a8">EncodeModele</a>($p_js)
<a name="l00661"></a>00661 {
<a name="l00662"></a>00662 echo '&lt;H2 CLASS=<span class="stringliteral">"info"</span>&gt; Ajout d\'un mod<6F>le&lt;/H2&gt;';
<a name="l00663"></a>00663 echo '&lt;<a class="code" href="constant_8php.html#a7">FORM</a> ACTION=<span class="stringliteral">"fiche.php"</span> <a class="code" href="pref_8inc_8php.html#a0">METHOD</a>=<span class="stringliteral">"post"</span>&gt;';
<a name="l00664"></a>00664 echo '&lt;BR&gt;Libell<EFBFBD> &lt;INPUT TYPE=<span class="stringliteral">"TEXT"</span> NAME=<span class="stringliteral">"nom_mod"</span>&gt;';
<a name="l00665"></a>00665 echo '&lt;BR&gt;Classe de base &lt;INPUT TYPE=<span class="stringliteral">"TEXT"</span> NAME=<span class="stringliteral">"class_base"</span>&gt;';
<a name="l00666"></a>00666 echo $p_js;
<a name="l00667"></a>00667 echo '&lt;INPUT TYPE=<span class="stringliteral">"HIDDEN"</span> NAME=<span class="stringliteral">"inc"</span> VALUE=<span class="stringliteral">"1"</span>&gt;';
<a name="l00668"></a>00668 echo '&lt;BR&gt;&lt;INPUT TYPE=<span class="stringliteral">"SUBMIT"</span> <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"record_model"</span> VALUE=<span class="stringliteral">"Ajoute mod<6F>le"</span>&gt;';
<a name="l00669"></a>00669 echo '&lt;/<a class="code" href="constant_8php.html#a7">FORM</a>&gt;';
<a name="l00670"></a>00670 }
<a name="l00686"></a><a class="code" href="fiche__inc_8php.html#a9">00686</a> function <a class="code" href="fiche__inc_8php.html#a9">DefModele</a> ($p_cn,$p_js,$p_array=null,$p_ligne=1)
<a name="l00687"></a>00687 {
<a name="l00688"></a>00688 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">"DefModele ($p_array,$p_ligne=1) "</span>);
<a name="l00689"></a>00689
<a name="l00690"></a>00690 <span class="comment">// Creating form</span>
<a name="l00691"></a>00691 $display='&lt;<a class="code" href="constant_8php.html#a7">FORM</a> ACTION=<span class="stringliteral">"fiche.php"</span> <a class="code" href="pref_8inc_8php.html#a0">METHOD</a>=<span class="stringliteral">"POST"</span>&gt;';
<a name="l00692"></a>00692
<a name="l00693"></a>00693 <span class="comment">// Number of line of the card</span>
<a name="l00694"></a>00694 $display.='&lt;INPUT TYPE=<span class="stringliteral">"HIDDEN"</span> NAME=<span class="stringliteral">"INC"</span> VALUE=<span class="stringliteral">"'.$p_ligne.'"</span>&gt;';
<a name="l00695"></a>00695
<a name="l00696"></a>00696 <span class="comment">// Table of input</span>
<a name="l00697"></a>00697 $display.='&lt;TABLE BORDER=<span class="stringliteral">"0"</span> CELLSPACING=<span class="stringliteral">"0"</span>&gt;';
<a name="l00698"></a>00698
<a name="l00699"></a>00699
<a name="l00700"></a>00700 <span class="comment">//Name of the CARD (fiche_def.fd_label)</span>
<a name="l00701"></a>00701 $display.='&lt;TR&gt;&lt;TD&gt; Cat<61>gorie de <a class="code" href="classfiche.html">fiche</a> &lt;/TD&gt;';
<a name="l00702"></a>00702 $display.='&lt;TD&gt;&lt;INPUT TYPE=<span class="stringliteral">"INPUT"</span> NAME=<span class="stringliteral">"nom_mod"</span>&gt;';
<a name="l00703"></a>00703 $display.='&lt;/TD&gt;&lt;/TR&gt;';
<a name="l00704"></a>00704
<a name="l00705"></a>00705 <span class="comment">// Class base fiche_def.fd_class_base (optional)</span>
<a name="l00706"></a>00706 $display.='&lt;TR&gt;&lt;TD&gt; Classe de base &lt;/TD&gt;';
<a name="l00707"></a>00707 $display.='&lt;TD&gt;&lt;INPUT TYPE=<span class="stringliteral">"INPUT"</span> NAME=<span class="stringliteral">"class_base"</span>&gt; '.$p_js;
<a name="l00708"></a>00708 $display.='&lt;/TD&gt;&lt;/TR&gt;';
<a name="l00709"></a>00709 <span class="comment">// Checkbox for the creation of a post</span>
<a name="l00710"></a>00710 $display.='&lt;TR&gt;&lt;TD&gt; &lt;INPUT TYPE=<span class="stringliteral">"CHECKBOX"</span> NAME=<span class="stringliteral">"create"</span> UNCHECKED&gt;Create accounts <span class="keywordflow">for</span> each&lt;/TD&gt;&lt;/TR&gt;';
<a name="l00711"></a>00711
<a name="l00712"></a>00712 <span class="comment">//display the different template</span>
<a name="l00713"></a>00713 $ref=<a class="code" href="fiche__inc_8php.html#a18">Get_fiche_def_ref</a>($p_cn);
<a name="l00714"></a>00714
<a name="l00715"></a>00715 <span class="comment">// check if $ref is an array </span>
<a name="l00716"></a>00716 <span class="comment">// and display the choice</span>
<a name="l00717"></a>00717
<a name="l00718"></a>00718 <span class="comment">// select by default the first choice</span>
<a name="l00719"></a>00719 <a class="code" href="fortis__be_8inc_8php.html#a2">$check</a>=<span class="stringliteral">"CHECKED"</span>;
<a name="l00720"></a>00720 <span class="keywordflow">if</span> ( <span class="keyword">sizeof</span>($ref) ) {
<a name="l00721"></a>00721 foreach ($ref as $i=&gt;$v) {
<a name="l00722"></a>00722 $display.='&lt;TR&gt;&lt;TD COLSPAN=<span class="stringliteral">"2"</span>&gt;';
<a name="l00723"></a>00723
<a name="l00724"></a>00724 $display.='&lt;INPUT TYPE=<span class="stringliteral">"RADIO"</span> NAME=<span class="stringliteral">"FICHE_REF"</span> VALUE=<span class="stringliteral">"'.$v['id'].'"</span>'.$check.<span class="charliteral">'&gt;'</span>;
<a name="l00725"></a>00725 $display.=$v['text'];
<a name="l00726"></a>00726 <span class="comment">// if a class base exist in fiche_def_ref, we display it</span>
<a name="l00727"></a>00727 <span class="keywordflow">if</span> ( <span class="keyword">sizeof</span> ($v['<span class="keyword">class</span>']) != 0 )
<a name="l00728"></a>00728 $display.=<span class="stringliteral">"&amp;nbsp;&amp;nbsp&lt;I&gt;Class base = "</span>.$v['<span class="keyword">class</span>'].<span class="stringliteral">"&lt;/I&gt;"</span>;
<a name="l00729"></a>00729 $display.=<span class="stringliteral">"&lt;/TD&gt;&lt;/TR&gt;"</span>;
<a name="l00730"></a>00730 <a class="code" href="fortis__be_8inc_8php.html#a2">$check</a>=<span class="stringliteral">""</span>;
<a name="l00731"></a>00731 }
<a name="l00732"></a>00732
<a name="l00733"></a>00733 }
<a name="l00734"></a>00734 <span class="comment">// closing the form</span>
<a name="l00735"></a>00735 $display.='&lt;/TABLE&gt;';
<a name="l00736"></a>00736 $display.='&lt;INPUT TYPE=<span class="stringliteral">"SUBMIT"</span> NAME=<span class="stringliteral">"add_modele"</span> VALUE=<span class="stringliteral">"Sauve"</span>&gt;';
<a name="l00737"></a>00737 $display.='&lt;/<a class="code" href="constant_8php.html#a7">FORM</a>&gt;';
<a name="l00738"></a>00738
<a name="l00739"></a>00739 <span class="comment">// display it</span>
<a name="l00740"></a>00740 echo $display;
<a name="l00741"></a>00741
<a name="l00742"></a>00742 }
<a name="l00758"></a><a class="code" href="fiche__inc_8php.html#a10">00758</a> function <a class="code" href="fiche__inc_8php.html#a10">AddModele</a>($p_cn,$p_array) {
<a name="l00759"></a>00759 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">"AddModele"</span>);
<a name="l00760"></a>00760 <span class="comment">// Show what we receive for debug purpose only</span>
<a name="l00761"></a>00761 <span class="comment">//</span>
<a name="l00762"></a>00762 foreach ( $p_array as $key=&gt;$element ) {
<a name="l00763"></a>00763 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">"p_$key $element"</span>);
<a name="l00764"></a>00764 ${<span class="stringliteral">"p_$key"</span>}=$element;
<a name="l00765"></a>00765 }
<a name="l00766"></a>00766 <span class="comment">// Format correctly the name of the cat. of card</span>
<a name="l00767"></a>00767 $p_nom_mod=<a class="code" href="ac__common_8php.html#a9">FormatString</a>($p_nom_mod);
<a name="l00768"></a>00768 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">"Adding $p_nom_mod"</span>);
<a name="l00769"></a>00769 <span class="comment">// Format the p_class_base </span>
<a name="l00770"></a>00770 <span class="comment">// must be an integer</span>
<a name="l00771"></a>00771 <span class="keywordflow">if</span> ( <a class="code" href="ac__common_8php.html#a2">isNumber</a>($p_class_base) == 0 &amp;&amp; <a class="code" href="ac__common_8php.html#a9">FormatString</a>($p_class_base) != null ) {
<a name="l00772"></a>00772 <a class="code" href="ac__common_8php.html#a0">echo_error</a> ('p_class_base is NOT a number');
<a name="l00773"></a>00773 }
<a name="l00774"></a>00774 <span class="keywordflow">if</span> ( strlen(trim($p_nom_mod)) == 0 )
<a name="l00775"></a>00775 <span class="keywordflow">return</span>;
<a name="l00776"></a>00776
<a name="l00777"></a>00777 <span class="comment">// $p_FICHE_REF cannot be null !!! (== fiche_def_ref.frd_id</span>
<a name="l00778"></a>00778 <span class="keywordflow">if</span> (! isset ($p_FICHE_REF) or strlen($p_FICHE_REF) == 0 ) {
<a name="l00779"></a>00779 <a class="code" href="ac__common_8php.html#a0">echo_error</a> (<span class="stringliteral">"AddModele : fiche_ref MUST NOT be null or empty"</span>);
<a name="l00780"></a>00780 <span class="keywordflow">return</span>;
<a name="l00781"></a>00781 }
<a name="l00782"></a>00782 <span class="comment">// build the sql request for fiche_def</span>
<a name="l00783"></a>00783 <span class="comment">// and insert into fiche_def</span>
<a name="l00784"></a>00784 <span class="comment">// if p_class_base is null get the default class base from</span>
<a name="l00785"></a>00785 <span class="comment">// fiche_def_ref</span>
<a name="l00786"></a>00786 <span class="keywordflow">if</span> ( <a class="code" href="ac__common_8php.html#a9">FormatString</a>($p_class_base) == null )
<a name="l00787"></a>00787 { <span class="comment">// p_class is null</span>
<a name="l00788"></a>00788 <span class="comment">// So we take the default one</span>
<a name="l00789"></a>00789 $p_class_base=<a class="code" href="fiche__inc_8php.html#a3">GetBaseFicheDefault</a>($p_cn,$p_FICHE_REF);
<a name="l00790"></a>00790 }
<a name="l00791"></a>00791 <span class="comment">// Set the value of fiche_def.fd_create_account</span>
<a name="l00792"></a>00792 <span class="keywordflow">if</span> ( isset($p_create))
<a name="l00793"></a>00793 $p_create='<span class="keyword">true</span>';
<a name="l00794"></a>00794 <span class="keywordflow">else</span>
<a name="l00795"></a>00795 $p_create='<span class="keyword">false</span>';
<a name="l00796"></a>00796
<a name="l00797"></a>00797 <span class="comment">// Class is valid ?</span>
<a name="l00798"></a>00798 <span class="keywordflow">if</span> ( <a class="code" href="ac__common_8php.html#a9">FormatString</a>($p_class_base) != null) {
<a name="l00799"></a>00799
<a name="l00800"></a>00800 <span class="comment">// p_class is a valid number</span>
<a name="l00801"></a>00801 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=sprintf(<span class="stringliteral">"insert into fiche_def(fd_label,fd_class_base,frd_id,fd_create_account) </span>
<a name="l00802"></a>00802 <span class="stringliteral"> values ('%s',%s,%d,'%s')"</span>,
<a name="l00803"></a>00803 $p_nom_mod,$p_class_base,$p_FICHE_REF,$p_create);
<a name="l00804"></a>00804 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00805"></a>00805
<a name="l00806"></a>00806 <span class="comment">// p_class must be added to tmp_pcmn </span>
<a name="l00807"></a>00807 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=sprintf(<span class="stringliteral">"select account_add(%d,'%s')"</span>,
<a name="l00808"></a>00808 $p_class_base,$p_nom_mod);
<a name="l00809"></a>00809
<a name="l00810"></a>00810 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00811"></a>00811
<a name="l00812"></a>00812 <span class="comment">// Get the fd_id</span>
<a name="l00813"></a>00813 $fd_id=<a class="code" href="postgres_8php.html#a12">GetSequence</a>($p_cn,'s_fdef');
<a name="l00814"></a>00814
<a name="l00815"></a>00815 <span class="comment">// Add the class_base if needed</span>
<a name="l00816"></a>00816
<a name="l00817"></a>00817 <span class="keywordflow">if</span> ( $p_create=='<span class="keyword">true</span>' ) {
<a name="l00818"></a>00818 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=sprintf(<span class="stringliteral">"insert into jnt_fic_attr(fd_id,ad_id) </span>
<a name="l00819"></a>00819 <span class="stringliteral"> values (%d,%d)"</span>,$fd_id,<a class="code" href="constant_8php.html#a48">ATTR_DEF_ACCOUNT</a>);
<a name="l00820"></a>00820 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00821"></a>00821 }
<a name="l00822"></a>00822 } <span class="keywordflow">else</span> {
<a name="l00823"></a>00823 <span class="comment">//There is no class base not even as default</span>
<a name="l00824"></a>00824 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=sprintf(<span class="stringliteral">"insert into fiche_def(fd_label,frd_id,fd_create_account) values ('%s',%d,'%s')"</span>,
<a name="l00825"></a>00825 $p_nom_mod,$p_FICHE_REF,$p_create);
<a name="l00826"></a>00826
<a name="l00827"></a>00827 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00828"></a>00828
<a name="l00829"></a>00829 <span class="comment">// Get the fd_id</span>
<a name="l00830"></a>00830 $fd_id=<a class="code" href="postgres_8php.html#a12">GetSequence</a>($p_cn,'s_fdef');
<a name="l00831"></a>00831
<a name="l00832"></a>00832 }
<a name="l00833"></a>00833
<a name="l00834"></a>00834 <span class="comment">// Get the default attr_def from attr_min</span>
<a name="l00835"></a>00835 $def_attr=<a class="code" href="fiche__inc_8php.html#a19">Get_attr_min</a>($p_cn,$p_FICHE_REF);
<a name="l00836"></a>00836
<a name="l00837"></a>00837 <span class="comment">//if defaut attr not null </span>
<a name="l00838"></a>00838 <span class="comment">// build the sql insert for the table attr_def</span>
<a name="l00839"></a>00839 <span class="keywordflow">if</span> (<span class="keyword">sizeof</span>($def_attr) != 0 ) {
<a name="l00840"></a>00840 <span class="comment">// insert all the mandatory fields into jnt_fiche_attr</span>
<a name="l00841"></a>00841 foreach ( $def_attr as $i=&gt;$v) {
<a name="l00842"></a>00842 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=sprintf(<span class="stringliteral">"insert into jnt_fic_Attr(fd_id,ad_id)</span>
<a name="l00843"></a>00843 <span class="stringliteral"> values (%d,%s)"</span>,
<a name="l00844"></a>00844 $fd_id,$v['ad_id']);
<a name="l00845"></a>00845 <a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l00846"></a>00846 }
<a name="l00847"></a>00847 }
<a name="l00848"></a>00848
<a name="l00849"></a>00849
<a name="l00850"></a>00850 }
<a name="l00866"></a><a class="code" href="fiche__inc_8php.html#a11">00866</a> function <a class="code" href="fiche__inc_8php.html#a11">UpdateModele</a>($p_cn,$p_fiche) {
<a name="l00867"></a>00867
<a name="l00868"></a>00868 <a class="code" href="recherche_8php.html#a4">$array</a>=<a class="code" href="fiche__inc_8php.html#a12">GetDataModele</a>($p_cn,$p_fiche);
<a name="l00869"></a>00869 <span class="keywordflow">if</span> ($array==null) {
<a name="l00870"></a>00870 <a class="code" href="ac__common_8php.html#a0">echo_error</a> (<span class="stringliteral">"fiche_inc:UpdateModele Fiche non trouv<75>e"</span>);
<a name="l00871"></a>00871 <span class="keywordflow">return</span>;
<a name="l00872"></a>00872 }
<a name="l00873"></a>00873 echo '&lt;H2 <span class="keyword">class</span>=<span class="stringliteral">"info"</span>&gt;'.getFicheDefName($p_cn,$p_fiche).'&lt;/H2&gt;';
<a name="l00874"></a>00874 foreach ( $array as $key=&gt;$element) <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">"$key =&gt; $element"</span>);
<a name="l00875"></a>00875 <a class="code" href="fiche__inc_8php.html#a27">DisplayDetailModele</a>($p_cn,$array,$array['ligne']);
<a name="l00876"></a>00876
<a name="l00877"></a>00877 }
<a name="l00892"></a><a class="code" href="fiche__inc_8php.html#a12">00892</a> function <a class="code" href="fiche__inc_8php.html#a12">GetDataModele</a>($p_cn,$p_fiche) {
<a name="l00893"></a>00893 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"select fd_class_base,ad_id,ad_text from </span>
<a name="l00894"></a>00894 <span class="stringliteral"> fiche_def</span>
<a name="l00895"></a>00895 <span class="stringliteral"> natural join jnt_fic_attr</span>
<a name="l00896"></a>00896 <span class="stringliteral"> natural join attr_def</span>
<a name="l00897"></a>00897 <span class="stringliteral"> where</span>
<a name="l00898"></a>00898 <span class="stringliteral"> fd_id=$p_fiche"</span>);
<a name="l00899"></a>00899 <a class="code" href="setup_8php.html#a11">$Max</a>=pg_NumRows($Res) ;
<a name="l00900"></a>00900 <span class="keywordflow">if</span> ($Max==0) <span class="keywordflow">return</span> null;
<a name="l00901"></a>00901
<a name="l00902"></a>00902 <span class="comment">// store the data in an array</span>
<a name="l00903"></a>00903 <span class="keywordflow">for</span> ($i=0; $i &lt; $Max;$i++) {
<a name="l00904"></a>00904 $line=pg_fetch_array($Res,$i);
<a name="l00905"></a>00905 <span class="keywordflow">if</span> ($i == 0 ) {
<a name="l00906"></a>00906 <a class="code" href="recherche_8php.html#a4">$array</a>['<a class="code" href="balance_8php.html#a5">label</a>']=GetFicheDefName($p_cn,$p_fiche);
<a name="l00907"></a>00907 <a class="code" href="recherche_8php.html#a4">$array</a>['class_base']=$line['fd_class_base'];
<a name="l00908"></a>00908 <a class="code" href="recherche_8php.html#a4">$array</a>['fd_id']=$p_fiche;
<a name="l00909"></a>00909 }<span class="comment">//if $i == 0</span>
<a name="l00910"></a>00910
<a name="l00911"></a>00911 <span class="comment">//Label</span>
<a name="l00912"></a>00912 $text=sprintf(<span class="stringliteral">"ad_id%d"</span>,$i);
<a name="l00913"></a>00913 <a class="code" href="recherche_8php.html#a4">$array</a>[$text]=$line['ad_id'];
<a name="l00914"></a>00914 <span class="comment">//isd_id</span>
<a name="l00915"></a>00915 $text=sprintf(<span class="stringliteral">"ad_text%d"</span>,$i);
<a name="l00916"></a>00916 <a class="code" href="recherche_8php.html#a4">$array</a>[$text]=$line['ad_text'];
<a name="l00917"></a>00917
<a name="l00918"></a>00918 }<span class="comment">//for</span>
<a name="l00919"></a>00919 <a class="code" href="recherche_8php.html#a4">$array</a>['ligne']=<a class="code" href="setup_8php.html#a11">$Max</a>;
<a name="l00920"></a>00920 <span class="keywordflow">return</span> <a class="code" href="recherche_8php.html#a4">$array</a>;
<a name="l00921"></a>00921 }
<a name="l00935"></a><a class="code" href="fiche__inc_8php.html#a13">00935</a> function <a class="code" href="fiche__inc_8php.html#a13">Remove</a> ($p_cn, $p_fid) {
<a name="l00936"></a>00936 <span class="keywordflow">if</span> ( ! isset ($p_cn) ||
<a name="l00937"></a>00937 ! isset ($p_fid) ) {
<a name="l00938"></a>00938 <a class="code" href="ac__common_8php.html#a0">echo_error</a> (<span class="stringliteral">"Remove Missing Parameter p_cn = $p_cn p_fid=$p_fid"</span>);
<a name="l00939"></a>00939 <span class="keywordflow">return</span>;
<a name="l00940"></a>00940 }
<a name="l00941"></a>00941 <span class="comment">// if the card has its own account in PCMN</span>
<a name="l00942"></a>00942 <span class="comment">// Get the fiche_def.fd_id from fiche.f_id</span>
<a name="l00943"></a>00943 $fd_id=<a class="code" href="fiche__inc_8php.html#a23">GetFicheDef</a>($p_cn,$p_fid);
<a name="l00944"></a>00944 <span class="keywordflow">if</span> ( <a class="code" href="fiche__inc_8php.html#a21">GetCreateAccount</a>($p_cn,$fd_id) == 1 ) {
<a name="l00945"></a>00945 <span class="comment">// Retrieve the class </span>
<a name="l00946"></a>00946 $class=<a class="code" href="fiche__inc_8php.html#a24">GetClass</a>($p_cn,$p_fid);
<a name="l00947"></a>00947
<a name="l00948"></a>00948 <span class="comment">// if class is not NULL and if we use it before, we can't remove it</span>
<a name="l00949"></a>00949 <span class="keywordflow">if</span> (<a class="code" href="ac__common_8php.html#a9">FormatString</a>($<span class="keyword">class</span>) != null &amp;&amp;
<a name="l00950"></a>00950 <a class="code" href="postgres_8php.html#a10">CountSql</a>($p_cn,<span class="stringliteral">"select * from jrnx where j_poste=$class"</span>) != 0 ) {
<a name="l00951"></a>00951 echo <span class="stringliteral">"&lt;SCRIPT&gt; alert('Impossible ce poste est utilis<69> dans un journal'); &lt;/SCRIPT&gt;"</span>;
<a name="l00952"></a>00952 <span class="keywordflow">return</span>;
<a name="l00953"></a>00953 } <span class="keywordflow">else</span> {
<a name="l00954"></a>00954 <span class="comment">// Remove in PCMN</span>
<a name="l00955"></a>00955 <span class="keywordflow">if</span> ( trim(strlen($<span class="keyword">class</span>)) != 0 and <a class="code" href="ac__common_8php.html#a2">isNumber</a>($<span class="keyword">class</span>) == 1)
<a name="l00956"></a>00956 <a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"delete from tmp_pcmn where pcm_val="</span>.$<span class="keyword">class</span>);
<a name="l00957"></a>00957 }
<a name="l00958"></a>00958
<a name="l00959"></a>00959 }
<a name="l00960"></a>00960 <span class="comment">// Remove from attr_value</span>
<a name="l00961"></a>00961 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"delete from attr_value </span>
<a name="l00962"></a>00962 <span class="stringliteral"> where jft_id in (select jft_id </span>
<a name="l00963"></a>00963 <span class="stringliteral"> from jnt_fic_att_value </span>
<a name="l00964"></a>00964 <span class="stringliteral"> natural join fiche where f_id=$p_fid)"</span>);
<a name="l00965"></a>00965 <span class="comment">// Remove from jnt_fic_att_value</span>
<a name="l00966"></a>00966 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"delete from jnt_fic_att_value where f_id=$p_fid"</span>);
<a name="l00967"></a>00967
<a name="l00968"></a>00968 <span class="comment">// Remove from fiche</span>
<a name="l00969"></a>00969 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"delete from fiche where f_id=$p_fid"</span>);
<a name="l00970"></a>00970
<a name="l00971"></a>00971 }
<a name="l00985"></a><a class="code" href="fiche__inc_8php.html#a14">00985</a> function <a class="code" href="fiche__inc_8php.html#a14">getFicheName</a>($p_cn,$p_id) {
<a name="l00986"></a>00986 <span class="comment">// Retrieve the attribute with the ad_id 1</span>
<a name="l00987"></a>00987 <span class="comment">// 1 is always the name</span>
<a name="l00988"></a>00988
<a name="l00989"></a>00989 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"select vw_name from </span>
<a name="l00990"></a>00990 <span class="stringliteral"> vw_fiche_attr where quick_code='$p_id'"</span>);
<a name="l00991"></a>00991 <span class="keywordflow">if</span> ( pg_NumRows($Res) == 0 ) <span class="keywordflow">return</span> <span class="stringliteral">"Unknown"</span>;
<a name="l00992"></a>00992 $st=pg_fetch_array($Res,0);
<a name="l00993"></a>00993 <span class="keywordflow">return</span> $st['vw_name'];
<a name="l00994"></a>00994 }
<a name="l01007"></a><a class="code" href="fiche__inc_8php.html#a15">01007</a> function <a class="code" href="fiche__inc_8php.html#a15">getFicheNameById</a>($p_cn,$p_id) {
<a name="l01008"></a>01008 <span class="comment">// Retrieve the attribute with the ad_id 1</span>
<a name="l01009"></a>01009 <span class="comment">// 1 is always the name</span>
<a name="l01010"></a>01010 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"select av_text from</span>
<a name="l01011"></a>01011 <span class="stringliteral"> attr_value</span>
<a name="l01012"></a>01012 <span class="stringliteral"> natural join jnt_fic_att_value</span>
<a name="l01013"></a>01013 <span class="stringliteral"> natural join fiche</span>
<a name="l01014"></a>01014 <span class="stringliteral"> where</span>
<a name="l01015"></a>01015 <span class="stringliteral"> f_id=$p_id and</span>
<a name="l01016"></a>01016 <span class="stringliteral"> ad_id="</span>.<a class="code" href="constant_8php.html#a49">ATTR_DEF_NAME</a>);
<a name="l01017"></a>01017
<a name="l01018"></a>01018 <span class="keywordflow">if</span> ( pg_NumRows($Res) == 0 ) <span class="keywordflow">return</span> <span class="stringliteral">"Unknown"</span>;
<a name="l01019"></a>01019 $st=pg_fetch_array($Res,0);
<a name="l01020"></a>01020 <span class="keywordflow">return</span> $st['av_text'];
<a name="l01021"></a>01021 }
<a name="l01022"></a>01022
<a name="l01035"></a><a class="code" href="fiche__inc_8php.html#a16">01035</a> function <a class="code" href="fiche__inc_8php.html#a16">getFicheDefName</a>($p_cn,$p_id) {
<a name="l01036"></a>01036 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"select fd_label from fiche_def where fd_id=$p_id"</span>);
<a name="l01037"></a>01037 <span class="keywordflow">if</span> ( pg_NumRows($Res) == 0 ) <span class="keywordflow">return</span> <span class="stringliteral">"Unknown"</span>;
<a name="l01038"></a>01038 $st=pg_fetch_array($Res,0);
<a name="l01039"></a>01039 <span class="keywordflow">return</span> $st['fd_label'];
<a name="l01040"></a>01040 }
<a name="l01041"></a>01041
<a name="l01054"></a><a class="code" href="fiche__inc_8php.html#a17">01054</a> function <a class="code" href="fiche__inc_8php.html#a17">GetFicheJrn</a>($p_cn,$p_jrn,$p_type)
<a name="l01055"></a>01055 {
<a name="l01056"></a>01056 $get=<span class="stringliteral">""</span>;
<a name="l01057"></a>01057 <span class="keywordflow">if</span> ( $p_type == 'deb' ) {
<a name="l01058"></a>01058 $get='jrn_def_fiche_deb';
<a name="l01059"></a>01059 }
<a name="l01060"></a>01060 <span class="keywordflow">if</span> ( $p_type == 'cred' ) {
<a name="l01061"></a>01061 $get='jrn_def_fiche_cred';
<a name="l01062"></a>01062 }
<a name="l01063"></a>01063 <span class="keywordflow">if</span> ( $get == <span class="stringliteral">""</span> ) {
<a name="l01064"></a>01064 <a class="code" href="ac__common_8php.html#a0">echo_error</a>(<span class="stringliteral">"Invalid p_type function GetFicheJrn($p_cn,$p_jrn,$p_type)"</span>);
<a name="l01065"></a>01065 <a class="code" href="balance_8php.html#a0">exit</a> -1;
<a name="l01066"></a>01066 }
<a name="l01067"></a>01067 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"select $get as fiche from jrn_def where jrn_def_id=$p_jrn"</span>);
<a name="l01068"></a>01068 <a class="code" href="setup_8php.html#a11">$Max</a>=pg_NumRows($Res);
<a name="l01069"></a>01069 <span class="keywordflow">if</span> ( $Max==0) {
<a name="l01070"></a>01070 <a class="code" href="ac__common_8php.html#a11">echo_warning</a>(<span class="stringliteral">"No rows"</span>);
<a name="l01071"></a>01071 <span class="keywordflow">return</span> null;
<a name="l01072"></a>01072 }
<a name="l01073"></a>01073 <span class="comment">// Normally Max must be == 1</span>
<a name="l01074"></a>01074 <a class="code" href="fiche__new_8php.html#a7">$list</a>=pg_fetch_array($Res,0);
<a name="l01075"></a>01075 <span class="keywordflow">if</span> ( $list['<a class="code" href="classfiche.html">fiche</a>']==<span class="stringliteral">""</span>) {
<a name="l01076"></a>01076 <a class="code" href="ac__common_8php.html#a11">echo_warning</a>(<span class="stringliteral">"No fiche"</span>);
<a name="l01077"></a>01077 <span class="keywordflow">return</span> null;
<a name="l01078"></a>01078 }
<a name="l01079"></a>01079
<a name="l01080"></a>01080 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=<span class="stringliteral">"select f_id,av_text as f_label </span>
<a name="l01081"></a>01081 <span class="stringliteral"> from fiche natural join jnt_fic_att_value</span>
<a name="l01082"></a>01082 <span class="stringliteral"> natural join attr_def</span>
<a name="l01083"></a>01083 <span class="stringliteral"> natural join attr_value</span>
<a name="l01084"></a>01084 <span class="stringliteral"> natural join fiche_def</span>
<a name="l01085"></a>01085 <span class="stringliteral"> where ad_id=1 and</span>
<a name="l01086"></a>01086 <span class="stringliteral"> fd_id in ("</span>.$list['<a class="code" href="classfiche.html">fiche</a>'].<span class="stringliteral">") order by f_label"</span>;
<a name="l01087"></a>01087
<a name="l01088"></a>01088 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l01089"></a>01089 <a class="code" href="setup_8php.html#a11">$Max</a>=pg_NumRows($Res);
<a name="l01090"></a>01090 <span class="keywordflow">if</span> ($Max==0 ) <span class="keywordflow">return</span> null;
<a name="l01091"></a>01091 <span class="comment">// Get The result and put it into an array</span>
<a name="l01092"></a>01092 <span class="keywordflow">for</span> ($i=0;$i&lt;$Max;$i++) {
<a name="l01093"></a>01093 $line=pg_fetch_array($Res,$i);
<a name="l01094"></a>01094 $f_id=$line['<a class="code" href="facture_8inc_8php.html#a18">f_id</a>'];
<a name="l01095"></a>01095 $f_label=$line['f_label'];
<a name="l01096"></a>01096 <a class="code" href="balance_8php.html#a9">$a</a>[<a class="code" href="balance_8php.html#a11">$i</a>]=array($<a class="code" href="facture_8inc_8php.html#a18">f_id</a>,$f_label);
<a name="l01097"></a>01097 }
<a name="l01098"></a>01098 <span class="keywordflow">return</span> <a class="code" href="balance_8php.html#a9">$a</a>;
<a name="l01099"></a>01099 }
<a name="l01112"></a><a class="code" href="fiche__inc_8php.html#a18">01112</a> function <a class="code" href="fiche__inc_8php.html#a18">Get_fiche_def_ref</a>($p_cn)
<a name="l01113"></a>01113 {
<a name="l01114"></a>01114 <span class="comment">// get all the data from fiche_def_ref</span>
<a name="l01115"></a>01115 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn, <span class="stringliteral">"select frd_id,frd_text,frd_class_base </span>
<a name="l01116"></a>01116 <span class="stringliteral"> from fiche_def_ref</span>
<a name="l01117"></a>01117 <span class="stringliteral"> order by frd_text"</span>);
<a name="l01118"></a>01118
<a name="l01119"></a>01119 <span class="comment">// check if the result is valid</span>
<a name="l01120"></a>01120 <a class="code" href="setup_8php.html#a11">$Max</a>=pg_NumRows($Res);
<a name="l01121"></a>01121 <span class="keywordflow">if</span> ( $Max == 0) <span class="keywordflow">return</span> null;
<a name="l01122"></a>01122
<a name="l01123"></a>01123 <span class="comment">// store the result in a array</span>
<a name="l01124"></a>01124 <span class="keywordflow">for</span> ($i=0;$i&lt;$Max;$i++) {
<a name="l01125"></a>01125 $f=pg_fetch_array($Res,$i);
<a name="l01126"></a>01126 <a class="code" href="recherche_8php.html#a4">$array</a>[<a class="code" href="balance_8php.html#a11">$i</a>]['<span class="keywordtype">id</span>']=$f['<a class="code" href="fiche__def_8inc_8php.html#a1">frd_id</a>'];
<a name="l01127"></a>01127 <a class="code" href="recherche_8php.html#a4">$array</a>[<a class="code" href="balance_8php.html#a11">$i</a>]['text']=$f['<a class="code" href="fiche__def_8inc_8php.html#a2">frd_text</a>'];
<a name="l01128"></a>01128 <a class="code" href="recherche_8php.html#a4">$array</a>[<a class="code" href="balance_8php.html#a11">$i</a>]['<span class="keyword">class</span>']=$f['<a class="code" href="fiche__def_8inc_8php.html#a3">frd_class_base</a>'];
<a name="l01129"></a>01129 }
<a name="l01130"></a>01130
<a name="l01131"></a>01131 <span class="comment">// return result</span>
<a name="l01132"></a>01132 <span class="keywordflow">return</span> <a class="code" href="recherche_8php.html#a4">$array</a>;
<a name="l01133"></a>01133 }
<a name="l01146"></a><a class="code" href="fiche__inc_8php.html#a19">01146</a> function <a class="code" href="fiche__inc_8php.html#a19">Get_attr_min</a>($p_cn,$p_fiche_def_ref) {
<a name="l01147"></a>01147 <span class="comment">// find the min attr for the fiche_def_ref</span>
<a name="l01148"></a>01148 <a class="code" href="eub__be_8inc_8php.html#a4">$Sql</a>=<span class="stringliteral">"select ad_id,ad_text from attr_min natural join attr_def </span>
<a name="l01149"></a>01149 <span class="stringliteral"> natural join fiche_def_ref</span>
<a name="l01150"></a>01150 <span class="stringliteral"> where</span>
<a name="l01151"></a>01151 <span class="stringliteral"> frd_id= $p_fiche_def_ref"</span>;
<a name="l01152"></a>01152 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$Sql);
<a name="l01153"></a>01153 <a class="code" href="fortis__be_8inc_8php.html#a9">$Num</a>=pg_NumRows($Res);
<a name="l01154"></a>01154
<a name="l01155"></a>01155 <span class="comment">// test the number of returned rows</span>
<a name="l01156"></a>01156 <span class="keywordflow">if</span> ($Num == 0 ) <span class="keywordflow">return</span> null;
<a name="l01157"></a>01157
<a name="l01158"></a>01158 <span class="comment">// Get Results &amp; Store them in a array</span>
<a name="l01159"></a>01159 <span class="keywordflow">for</span> ($i=0;$i&lt;$Num;$i++) {
<a name="l01160"></a>01160 $f=pg_fetch_array($Res,$i);
<a name="l01161"></a>01161 <a class="code" href="recherche_8php.html#a4">$array</a>[<a class="code" href="balance_8php.html#a11">$i</a>]['ad_id']=$f['ad_id'];
<a name="l01162"></a>01162 <a class="code" href="recherche_8php.html#a4">$array</a>[<a class="code" href="balance_8php.html#a11">$i</a>]['ad_text']=$f['ad_text'];
<a name="l01163"></a>01163 }
<a name="l01164"></a>01164 <span class="keywordflow">return</span> <a class="code" href="recherche_8php.html#a4">$array</a>;
<a name="l01165"></a>01165 }
<a name="l01178"></a><a class="code" href="fiche__inc_8php.html#a20">01178</a> function <a class="code" href="fiche__inc_8php.html#a20">Get_attr_def</a>($p_cn,$p_fiche_def) {
<a name="l01179"></a>01179 <span class="comment">// find the min attr for the fiche_def_ref</span>
<a name="l01180"></a>01180 <a class="code" href="eub__be_8inc_8php.html#a4">$Sql</a>=<span class="stringliteral">"select ad_id,ad_text from attr_def </span>
<a name="l01181"></a>01181 <span class="stringliteral"> natural join jnt_fic_attr</span>
<a name="l01182"></a>01182 <span class="stringliteral"> natural join fiche_def</span>
<a name="l01183"></a>01183 <span class="stringliteral"> where</span>
<a name="l01184"></a>01184 <span class="stringliteral"> fd_id= $p_fiche_def order by ad_id"</span>;
<a name="l01185"></a>01185 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$Sql);
<a name="l01186"></a>01186 <a class="code" href="fortis__be_8inc_8php.html#a9">$Num</a>=pg_NumRows($Res);
<a name="l01187"></a>01187
<a name="l01188"></a>01188 <span class="comment">// test the number of returned rows</span>
<a name="l01189"></a>01189 <span class="keywordflow">if</span> ($Num == 0 ) <span class="keywordflow">return</span> null;
<a name="l01190"></a>01190
<a name="l01191"></a>01191 <span class="comment">// Get Results &amp; Store them in a array</span>
<a name="l01192"></a>01192 <span class="keywordflow">for</span> ($i=0;$i&lt;$Num;$i++) {
<a name="l01193"></a>01193 $f=pg_fetch_array($Res,$i);
<a name="l01194"></a>01194 <a class="code" href="recherche_8php.html#a4">$array</a>[<a class="code" href="balance_8php.html#a11">$i</a>]['ad_id']=$f['ad_id'];
<a name="l01195"></a>01195 <a class="code" href="recherche_8php.html#a4">$array</a>[<a class="code" href="balance_8php.html#a11">$i</a>]['ad_text']=$f['ad_text'];
<a name="l01196"></a>01196 }
<a name="l01197"></a>01197 <span class="keywordflow">return</span> <a class="code" href="recherche_8php.html#a4">$array</a>;
<a name="l01198"></a>01198 }
<a name="l01211"></a><a class="code" href="fiche__inc_8php.html#a21">01211</a> function <a class="code" href="fiche__inc_8php.html#a21">GetCreateAccount</a>($p_cn,$p_fiche_def) {
<a name="l01212"></a>01212 <span class="comment">// find the min attr for the fiche_def_ref</span>
<a name="l01213"></a>01213 <a class="code" href="eub__be_8inc_8php.html#a4">$Sql</a>=<span class="stringliteral">"select fd_create_account</span>
<a name="l01214"></a>01214 <span class="stringliteral"> from fiche_def</span>
<a name="l01215"></a>01215 <span class="stringliteral"> where</span>
<a name="l01216"></a>01216 <span class="stringliteral"> fd_id= $p_fiche_def"</span>;
<a name="l01217"></a>01217 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$Sql);
<a name="l01218"></a>01218 <a class="code" href="fortis__be_8inc_8php.html#a9">$Num</a>=pg_NumRows($Res);
<a name="l01219"></a>01219
<a name="l01220"></a>01220 <span class="comment">// test the number of returned rows</span>
<a name="l01221"></a>01221 <span class="keywordflow">if</span> ($Num == 0 ) <span class="keywordflow">return</span> 0;
<a name="l01222"></a>01222
<a name="l01223"></a>01223
<a name="l01224"></a>01224 <span class="keywordflow">for</span> ($i=0;$i&lt;$Num;$i++) {
<a name="l01225"></a>01225 $f=pg_fetch_array($Res,$i);
<a name="l01226"></a>01226 <a class="code" href="debug_8php.html#a0">echo_debug</a> (<span class="stringliteral">"fd_create_account == "</span>.$f['fd_create_account']);
<a name="l01227"></a>01227 <span class="keywordflow">if</span> ( $f['fd_create_account']==<span class="charliteral">'t'</span>) {
<a name="l01228"></a>01228 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">"fd_create_account return 1"</span>);
<a name="l01229"></a>01229 <span class="keywordflow">return</span> 1;
<a name="l01230"></a>01230 }
<a name="l01231"></a>01231 }
<a name="l01232"></a>01232 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">"fd_create_account return 0"</span>);
<a name="l01233"></a>01233 <span class="keywordflow">return</span> 0;
<a name="l01234"></a>01234 }
<a name="l01248"></a><a class="code" href="fiche__inc_8php.html#a22">01248</a> function <a class="code" href="fiche__inc_8php.html#a22">GetFicheDefRef</a>($p_cn,$p_f_id)
<a name="l01249"></a>01249 {
<a name="l01250"></a>01250 <span class="comment">// Sql stmt</span>
<a name="l01251"></a>01251 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=<span class="stringliteral">"select frd_id from fiche_def join fiche using (fd_id) </span>
<a name="l01252"></a>01252 <span class="stringliteral"> where f_id=$p_f_id"</span>;
<a name="l01253"></a>01253 <span class="comment">// Execute it</span>
<a name="l01254"></a>01254 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l01255"></a>01255
<a name="l01256"></a>01256 <span class="comment">// nothing is found</span>
<a name="l01257"></a>01257 <span class="keywordflow">if</span> ( pg_NumRows($Res) == 0 ) <span class="keywordflow">return</span> null;
<a name="l01258"></a>01258
<a name="l01259"></a>01259 <span class="comment">// Fetch the data</span>
<a name="l01260"></a>01260 $f=pg_fetch_array($Res,0);
<a name="l01261"></a>01261
<a name="l01262"></a>01262 <span class="comment">// return the value</span>
<a name="l01263"></a>01263 <span class="keywordflow">return</span> $f['<a class="code" href="fiche__def_8inc_8php.html#a1">frd_id</a>'];
<a name="l01264"></a>01264
<a name="l01265"></a>01265 }
<a name="l01279"></a><a class="code" href="fiche__inc_8php.html#a23">01279</a> function <a class="code" href="fiche__inc_8php.html#a23">GetFicheDef</a>($p_cn,$p_f_id)
<a name="l01280"></a>01280 {
<a name="l01281"></a>01281 <span class="comment">// Sql stmt</span>
<a name="l01282"></a>01282 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=<span class="stringliteral">"select fd_id from fiche_def join fiche using (fd_id) </span>
<a name="l01283"></a>01283 <span class="stringliteral"> where f_id=$p_f_id"</span>;
<a name="l01284"></a>01284 <span class="comment">// Execute it</span>
<a name="l01285"></a>01285 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l01286"></a>01286
<a name="l01287"></a>01287 <span class="comment">// nothing is found</span>
<a name="l01288"></a>01288 <span class="keywordflow">if</span> ( pg_NumRows($Res) == 0 ) <span class="keywordflow">return</span> null;
<a name="l01289"></a>01289
<a name="l01290"></a>01290 <span class="comment">// Fetch the data</span>
<a name="l01291"></a>01291 $f=pg_fetch_array($Res,0);
<a name="l01292"></a>01292
<a name="l01293"></a>01293 <span class="comment">// return the value</span>
<a name="l01294"></a>01294 <span class="keywordflow">return</span> $f['fd_id'];
<a name="l01295"></a>01295
<a name="l01296"></a>01296 }
<a name="l01297"></a>01297
<a name="l01310"></a><a class="code" href="fiche__inc_8php.html#a24">01310</a> function <a class="code" href="fiche__inc_8php.html#a24">GetClass</a>($p_cn,$p_fid) {
<a name="l01311"></a>01311 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">"GetClass($p_fid)"</span>);
<a name="l01312"></a>01312
<a name="l01313"></a>01313 <span class="comment">// the account class is in the av_text with the ad_id=5 in </span>
<a name="l01314"></a>01314 <span class="comment">// attr_Def</span>
<a name="l01315"></a>01315 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=<span class="stringliteral">"select av_text from attr_value </span>
<a name="l01316"></a>01316 <span class="stringliteral"> natural join jnt_fic_att_value</span>
<a name="l01317"></a>01317 <span class="stringliteral"> natural join attr_def </span>
<a name="l01318"></a>01318 <span class="stringliteral"> where</span>
<a name="l01319"></a>01319 <span class="stringliteral"> ad_id="</span>.ATTR_DEF_ACCOUNT.<span class="stringliteral">" and f_id=$p_fid"</span>;
<a name="l01320"></a>01320 <span class="comment">// Exec</span>
<a name="l01321"></a>01321 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l01322"></a>01322 <span class="keywordflow">if</span> (pg_NumRows($Res) == 0 ) <span class="keywordflow">return</span> null;
<a name="l01323"></a>01323
<a name="l01324"></a>01324 <span class="comment">// Fetch the data and return it</span>
<a name="l01325"></a>01325 $f=pg_fetch_array($Res,0);
<a name="l01326"></a>01326 <span class="keywordflow">return</span> $f['av_text'];
<a name="l01327"></a>01327 }
<a name="l01340"></a><a class="code" href="fiche__inc_8php.html#a25">01340</a> function <a class="code" href="fiche__inc_8php.html#a25">InsertModeleLine</a>($p_cn,$p_fid,$p_adid)
<a name="l01341"></a>01341 {
<a name="l01342"></a>01342 <span class="comment">// Insert a new attribute for the model</span>
<a name="l01343"></a>01343 <span class="comment">// it means insert a row in jnt_fic_attr</span>
<a name="l01344"></a>01344 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=sprintf(<span class="stringliteral">"insert into jnt_fic_attr (fd_id,ad_id) values (%d,%d)"</span>,
<a name="l01345"></a>01345 $p_fid,$p_adid);
<a name="l01346"></a>01346 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l01347"></a>01347
<a name="l01348"></a>01348 }
<a name="l01361"></a><a class="code" href="fiche__inc_8php.html#a26">01361</a> function <a class="code" href="fiche__inc_8php.html#a26">SaveModeleName</a>($p_cn,$p_fid,$p_label)
<a name="l01362"></a>01362 {
<a name="l01363"></a>01363 <span class="comment">// Insert a new attribute for the model</span>
<a name="l01364"></a>01364 <span class="comment">// it means insert a row in jnt_fic_attr</span>
<a name="l01365"></a>01365 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=sprintf(<span class="stringliteral">"update fiche_def set fd_label='%s' where </span>
<a name="l01366"></a>01366 <span class="stringliteral"> fd_id=%d"</span>,
<a name="l01367"></a>01367 $p_label,$p_fid);
<a name="l01368"></a>01368 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l01369"></a>01369
<a name="l01370"></a>01370 }
<a name="l01371"></a>01371
<a name="l01387"></a><a class="code" href="fiche__inc_8php.html#a27">01387</a> function <a class="code" href="fiche__inc_8php.html#a27">DisplayDetailModele</a>($p_cn,$p_array,$MaxLine)
<a name="l01388"></a>01388 {
<a name="l01389"></a>01389 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">"DisplayDetailModele"</span>);
<a name="l01390"></a>01390
<a name="l01391"></a>01391 foreach ($p_array as $v=&gt;$i) {
<a name="l01392"></a>01392 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_inc.php',__LINE__,<span class="stringliteral">"v == $v i==$i"</span>);
<a name="l01393"></a>01393 ${<span class="stringliteral">"$v"</span>}=<a class="code" href="balance_8php.html#a11">$i</a>;
<a name="l01394"></a>01394 }
<a name="l01395"></a>01395 echo '&lt;<a class="code" href="constant_8php.html#a7">FORM</a> <a class="code" href="classaction.html">action</a>=<span class="stringliteral">"fiche.php"</span> method=<span class="stringliteral">"get"</span>&gt;';
<a name="l01396"></a>01396 echo '&lt;INPUT TYPE=<span class="stringliteral">"HIDDEN"</span> NAME=<span class="stringliteral">"fd_id"</span> VALUE=<span class="stringliteral">"'.$fd_id.'"</span>&gt;';
<a name="l01397"></a>01397
<a name="l01398"></a>01398 printf(<span class="stringliteral">"&lt;TABLE&gt;"</span>);
<a name="l01399"></a>01399 <span class="comment">// Display each attribute</span>
<a name="l01400"></a>01400 <span class="keywordflow">for</span> ($i=0;$i&lt;$MaxLine;$i++) {
<a name="l01401"></a>01401 echo '&lt;TR&gt;&lt;td&gt;';
<a name="l01402"></a>01402 <span class="comment">// Can change the name</span>
<a name="l01403"></a>01403 <span class="keywordflow">if</span> ( ${<span class="stringliteral">"ad_id$i"</span>} == <a class="code" href="constant_8php.html#a49">ATTR_DEF_NAME</a> ) {
<a name="l01404"></a>01404 printf('Label&lt;/TD&gt;&lt;TD&gt;&lt;INPUT TYPE=<span class="stringliteral">"TEXT"</span> NAME=<span class="stringliteral">"label"</span> VALUE=<span class="stringliteral">"%s"</span>&gt;',
<a name="l01405"></a>01405 $<a class="code" href="balance_8php.html#a5">label</a>);
<a name="l01406"></a>01406 printf('&lt;/td&gt;&lt;TD&gt;&lt;input type=<span class="stringliteral">"submit"</span> NAME=<span class="stringliteral">"change_name"</span> <a class="code" href="client_8inc_8php.html#a6">value</a>=<span class="stringliteral">"Change Nom"</span>&gt;');
<a name="l01407"></a>01407 } <span class="keywordflow">else</span> {
<a name="l01408"></a>01408 <span class="comment">// The attr.</span>
<a name="l01409"></a>01409 printf('%s ',
<a name="l01410"></a>01410 ${<span class="stringliteral">"ad_text$i"</span>});
<a name="l01411"></a>01411 }
<a name="l01412"></a>01412 echo '&lt;/td&gt;&lt;/tr&gt;';
<a name="l01413"></a>01413 }
<a name="l01414"></a>01414
<a name="l01415"></a>01415 <span class="comment">// Show the possible attribute which are not already attribute of the model</span>
<a name="l01416"></a>01416 <span class="comment">// of card</span>
<a name="l01417"></a>01417 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"select ad_id,ad_text from attr_def </span>
<a name="l01418"></a>01418 <span class="stringliteral"> where ad_id not in (select ad_id from fiche_def natural join jnt_fic_attr</span>
<a name="l01419"></a>01419 <span class="stringliteral"> where fd_id=$fd_id)"</span>);
<a name="l01420"></a>01420 <a class="code" href="setup_8php.html#a14">$M</a>=pg_NumRows($Res);
<a name="l01421"></a>01421
<a name="l01422"></a>01422 <span class="comment">// Show the unused attribute</span>
<a name="l01423"></a>01423 echo '&lt;TR&gt; &lt;TD&gt;';
<a name="l01424"></a>01424 echo '&lt;SELECT NAME=<span class="stringliteral">"ad_id"</span>&gt;';
<a name="l01425"></a>01425 <span class="keywordflow">for</span> ($i=0;$i&lt;$M;$i++) {
<a name="l01426"></a>01426 <a class="code" href="facture_8inc_8php.html#a15">$l</a>=pg_fetch_array($Res,$i);
<a name="l01427"></a>01427 printf('&lt;OPTION VALUE=<span class="stringliteral">"%s"</span>&gt; %s',
<a name="l01428"></a>01428 $l['ad_id'],$l['ad_text']);
<a name="l01429"></a>01429 }
<a name="l01430"></a>01430 echo '&lt;/SELECT&gt;';
<a name="l01431"></a>01431 echo '&lt;/TD&gt;&lt;TD&gt; &lt;INPUT TYPE=<span class="stringliteral">"SUBMIT"</span> Value=<span class="stringliteral">"Add that line"</span> NAME=<span class="stringliteral">"add_ligne"</span>&gt;&lt;/TD&gt;&lt;/TR&gt;';
<a name="l01432"></a>01432 printf(<span class="stringliteral">"&lt;/TABLE&gt;"</span>);
<a name="l01433"></a>01433 echo '&lt;/<a class="code" href="constant_8php.html#a7">FORM</a>&gt;';
<a name="l01434"></a>01434 }
<a name="l01447"></a><a class="code" href="fiche__inc_8php.html#a28">01447</a> function <a class="code" href="fiche__inc_8php.html#a28">GetParent</a>($p_cn,$p_val)
<a name="l01448"></a>01448 {
<a name="l01449"></a>01449 $len=strlen($p_val)-1;
<a name="l01450"></a>01450 <span class="keywordflow">for</span> ($i=$len-1;$i&gt;0;$i--) {
<a name="l01451"></a>01451 <a class="code" href="balance_8php.html#a9">$a</a>=substr($p_val,0,$i);
<a name="l01452"></a>01452 <a class="code" href="debug_8php.html#a0">echo_debug</a> (<span class="stringliteral">"parent == $a len =1"</span>);
<a name="l01453"></a>01453 <span class="keywordflow">if</span> (<a class="code" href="postgres_8php.html#a10">CountSql</a>($p_cn,<span class="stringliteral">"select pcm_val from tmp_pcmn where pcm_val=$a"</span>) == 1)
<a name="l01454"></a>01454 <span class="keywordflow">return</span> <a class="code" href="balance_8php.html#a9">$a</a>;
<a name="l01455"></a>01455 }
<a name="l01456"></a>01456 }
<a name="l01471"></a><a class="code" href="fiche__inc_8php.html#a29">01471</a> function <a class="code" href="fiche__inc_8php.html#a29">getFicheAttribut</a>($p_cn,$p_id,$p_attr=<span class="stringliteral">""</span>) {
<a name="l01472"></a>01472 <span class="comment">// Retrieve the attribute with the ad_id 1</span>
<a name="l01473"></a>01473 <span class="comment">// 1 is always the name</span>
<a name="l01474"></a>01474
<a name="l01475"></a>01475 <span class="keywordflow">if</span> ( $p_attr != <span class="stringliteral">""</span>) {
<a name="l01476"></a>01476 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"select av_text from </span>
<a name="l01477"></a>01477 <span class="stringliteral"> attr_value</span>
<a name="l01478"></a>01478 <span class="stringliteral"> natural join jnt_fic_att_value </span>
<a name="l01479"></a>01479 <span class="stringliteral"> natural join fiche </span>
<a name="l01480"></a>01480 <span class="stringliteral"> where</span>
<a name="l01481"></a>01481 <span class="stringliteral"> ad_id=$p_attr </span>
<a name="l01482"></a>01482 <span class="stringliteral"> and f_id=(select f_id from vw_poste_qcode where j_qcode='$p_id') "</span>);
<a name="l01483"></a>01483 <span class="keywordflow">if</span> ( pg_NumRows($Res) == 0 ) <span class="keywordflow">return</span> NULL;
<a name="l01484"></a>01484 $st=pg_fetch_array($Res,0);
<a name="l01485"></a>01485 <span class="keywordflow">return</span> $st['av_text'];
<a name="l01486"></a>01486 } <span class="keywordflow">else</span> {
<a name="l01487"></a>01487 <span class="comment">// Get attribut from the view</span>
<a name="l01488"></a>01488 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"select * from vw_fiche_attr where quick_code='$p_id'"</span>);
<a name="l01489"></a>01489 <span class="keywordflow">if</span> ( pg_NumRows($Res) == 0 ) <span class="keywordflow">return</span> null;
<a name="l01490"></a>01490 $st=pg_fetch_array($Res,0);
<a name="l01491"></a>01491 <span class="keywordflow">return</span> $st;
<a name="l01492"></a>01492 }
<a name="l01493"></a>01493 }
<a name="l01494"></a>01494
<a name="l01511"></a><a class="code" href="fiche__inc_8php.html#a30">01511</a> function <a class="code" href="fiche__inc_8php.html#a30">IsFicheOfJrn</a>($p_cn,$p_jrn,$p_fiche,$p_type=<span class="stringliteral">""</span>)
<a name="l01512"></a>01512 {
<a name="l01513"></a>01513 $get=<span class="stringliteral">""</span>;
<a name="l01514"></a>01514 <span class="keywordflow">if</span> ( $p_type == 'deb' ) {
<a name="l01515"></a>01515 $get='jrn_def_fiche_deb';
<a name="l01516"></a>01516 }
<a name="l01517"></a>01517 <span class="keywordflow">if</span> ( $p_type == 'cred' ) {
<a name="l01518"></a>01518 $get='jrn_def_fiche_cred';
<a name="l01519"></a>01519 }
<a name="l01520"></a>01520 <span class="keywordflow">if</span> ( $get != <span class="stringliteral">""</span> ) {
<a name="l01521"></a>01521 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">"select $get as fiche from jrn_def where jrn_def_id=$p_jrn"</span>);
<a name="l01522"></a>01522 } <span class="keywordflow">else</span> {
<a name="l01523"></a>01523 <span class="comment">// Get all the fiche type (deb and cred)</span>
<a name="l01524"></a>01524 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,<span class="stringliteral">" select jrn_def_fiche_cred as fiche </span>
<a name="l01525"></a>01525 <span class="stringliteral"> from jrn_def where jrn_def_id=$p_jrn</span>
<a name="l01526"></a>01526 <span class="stringliteral"> union</span>
<a name="l01527"></a>01527 <span class="stringliteral"> select jrn_def_fiche_deb </span>
<a name="l01528"></a>01528 <span class="stringliteral"> from jrn_def where jrn_def_id=$p_jrn"</span>
<a name="l01529"></a>01529 );
<a name="l01530"></a>01530 }
<a name="l01531"></a>01531 <a class="code" href="setup_8php.html#a11">$Max</a>=pg_NumRows($Res);
<a name="l01532"></a>01532 <span class="keywordflow">if</span> ( $Max==0) {
<a name="l01533"></a>01533 <a class="code" href="ac__common_8php.html#a11">echo_warning</a>(<span class="stringliteral">"No rows"</span>);
<a name="l01534"></a>01534 <span class="keywordflow">return</span> null;
<a name="l01535"></a>01535 }
<a name="l01536"></a>01536 <span class="comment">// Normally Max must be == 1</span>
<a name="l01537"></a>01537 <a class="code" href="fiche__new_8php.html#a7">$list</a>=pg_fetch_array($Res,0);
<a name="l01538"></a>01538 <span class="keywordflow">if</span> ( $list['<a class="code" href="classfiche.html">fiche</a>']==<span class="stringliteral">""</span>) {
<a name="l01539"></a>01539 <a class="code" href="ac__common_8php.html#a11">echo_warning</a>(<span class="stringliteral">"No fiche"</span>);
<a name="l01540"></a>01540 <span class="keywordflow">return</span> null;
<a name="l01541"></a>01541 }
<a name="l01542"></a>01542
<a name="l01543"></a>01543 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=<span class="stringliteral">"select *</span>
<a name="l01544"></a>01544 <span class="stringliteral"> from vw_fiche_attr</span>
<a name="l01545"></a>01545 <span class="stringliteral"> where </span>
<a name="l01546"></a>01546 <span class="stringliteral"> fd_id in ("</span>.$list['<a class="code" href="classfiche.html">fiche</a>'].<span class="stringliteral">") and quick_code='$p_fiche'"</span>;
<a name="l01547"></a>01547
<a name="l01548"></a>01548 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($p_cn,$sql);
<a name="l01549"></a>01549 <a class="code" href="setup_8php.html#a11">$Max</a>=pg_NumRows($Res);
<a name="l01550"></a>01550 <span class="keywordflow">if</span> ($Max==0 )
<a name="l01551"></a>01551 <span class="keywordflow">return</span> 0;
<a name="l01552"></a>01552 <span class="keywordflow">else</span>
<a name="l01553"></a>01553 <span class="keywordflow">return</span> 1;
<a name="l01554"></a>01554 }
<a name="l01555"></a>01555 ?&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>