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

190 lines
18 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/html/fiche_search.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_000003.html">html</a></div>
<h1>fiche_search.php</h1><a href="fiche__search_8php.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 &lt;?
<a name="l00002"></a>00002 <span class="comment">/*</span>
<a name="l00003"></a>00003 <span class="comment"> * This file is part of PhpCompta.</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> * PhpCompta is free software; you can redistribute it and/or modify</span>
<a name="l00006"></a>00006 <span class="comment"> * it under the terms of the GNU General Public License as published by</span>
<a name="l00007"></a>00007 <span class="comment"> * the Free Software Foundation; either version 2 of the License, or</span>
<a name="l00008"></a>00008 <span class="comment"> * (at your option) any later version.</span>
<a name="l00009"></a>00009 <span class="comment"> *</span>
<a name="l00010"></a>00010 <span class="comment"> * PhpCompta is distributed in the hope that it will be useful,</span>
<a name="l00011"></a>00011 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00012"></a>00012 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the</span>
<a name="l00013"></a>00013 <span class="comment"> * GNU General Public License for more details.</span>
<a name="l00014"></a>00014 <span class="comment"> *</span>
<a name="l00015"></a>00015 <span class="comment"> * You should have received a copy of the GNU General Public License</span>
<a name="l00016"></a>00016 <span class="comment"> * along with PhpCompta; if not, write to the Free Software</span>
<a name="l00017"></a>00017 <span class="comment"> * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA</span>
<a name="l00018"></a>00018 <span class="comment">*/</span>
<a name="l00019"></a>00019 <span class="comment">// Copyright Author Dany De Bontridder ddebontridder@yahoo.fr</span>
<a name="l00020"></a>00020 <span class="comment">/* $Revision$ */</span>
<a name="l00025"></a>00025 include_once (<span class="stringliteral">"ac_common.php"</span>);
<a name="l00026"></a>00026 include_once (<span class="stringliteral">"poste.php"</span>);
<a name="l00027"></a>00027 include_once (<span class="stringliteral">"postgres.php"</span>);
<a name="l00028"></a>00028 include_once(<span class="stringliteral">"jrn.php"</span>);
<a name="l00029"></a>00029 <span class="comment">/* Admin. Dossier */</span>
<a name="l00030"></a><a class="code" href="fiche__search_8php.html#a0">00030</a> <a class="code" href="impress__poste_8php.html#a1">$rep</a>=<a class="code" href="postgres_8php.html#a1">DbConnect</a>();
<a name="l00031"></a>00031 include_once (<span class="stringliteral">"class_user.php"</span>);
<a name="l00032"></a><a class="code" href="fiche__search_8php.html#a1">00032</a> <a class="code" href="user__action__ach_8php.html#a9">$User</a>=<span class="keyword">new</span> <a class="code" href="classcl__user.html">cl_user</a>($rep);
<a name="l00033"></a>00033 <a class="code" href="user__action__ach_8php.html#a9">$User</a>-&gt;Check();
<a name="l00034"></a>00034
<a name="l00035"></a>00035 <span class="comment">//determine focus:</span>
<a name="l00036"></a>00036 <span class="keywordflow">if</span> ( isset ( $_POST['search']) )
<a name="l00037"></a>00037 {
<a name="l00038"></a>00038 <a class="code" href="ac__common_8php.html#a5">html_page_start</a>($User-&gt;theme,<span class="stringliteral">"onLoad=\"window.focus();SetFocus('select0',0)\""</span>);
<a name="l00039"></a>00039 } <span class="keywordflow">else</span>
<a name="l00040"></a>00040 {
<a name="l00041"></a>00041 <a class="code" href="ac__common_8php.html#a5">html_page_start</a>($User-&gt;theme,<span class="stringliteral">"onLoad=\"window.focus();SetFocus('fic_search',0)\""</span>);
<a name="l00042"></a>00042 }
<a name="l00043"></a>00043
<a name="l00044"></a>00044
<a name="l00045"></a>00045
<a name="l00046"></a>00046 <span class="keywordflow">if</span> ( ! isset ( $_SESSION['g_dossier'] ) ) {
<a name="l00047"></a>00047 echo <span class="stringliteral">"You must choose a Dossier "</span>;
<a name="l00048"></a>00048 <a class="code" href="balance_8php.html#a0">exit</a> -2;
<a name="l00049"></a>00049 }
<a name="l00050"></a>00050
<a name="l00051"></a>00051 include_once (<span class="stringliteral">"check_priv.php"</span>);
<a name="l00052"></a><a class="code" href="fiche__search_8php.html#a2">00052</a> <a class="code" href="impress__fiche_8php.html#a0">$cn</a>=<a class="code" href="postgres_8php.html#a1">DbConnect</a>($_SESSION['g_dossier']);
<a name="l00053"></a>00053 <span class="comment">// Get The priv on the selected folder</span>
<a name="l00054"></a>00054 <span class="keywordflow">if</span> ( $User-&gt;CheckAction($cn,<a class="code" href="constant_8php.html#a5">FICHE_READ</a>) == 0 ){
<a name="l00055"></a>00055 <span class="comment">/* Cannot Access */</span>
<a name="l00056"></a>00056 echo '&lt;h2 <span class="keyword">class</span>=<span class="stringliteral">"error"</span>&gt; Vous n\' avez pas acc<63>s&lt;/h2&gt;';
<a name="l00057"></a>00057 <span class="keywordflow">return</span>;
<a name="l00058"></a>00058 }
<a name="l00059"></a>00059
<a name="l00060"></a>00060 function get_list_fiche($p_cn,$get,$p_jrn)
<a name="l00061"></a>00061 {
<a name="l00062"></a>00062 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=<span class="stringliteral">"select $get as fiche from jrn_def where jrn_def_id=$p_jrn"</span>;
<a name="l00063"></a>00063 <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="l00064"></a>00064
<a name="l00065"></a>00065 <span class="comment">// fetch it</span>
<a name="l00066"></a><a class="code" href="fiche__search_8php.html#a3">00066</a> <a class="code" href="setup_8php.html#a11">$Max</a>=pg_NumRows($Res);
<a name="l00067"></a>00067 <span class="keywordflow">if</span> ( $Max==0) {
<a name="l00068"></a>00068 <a class="code" href="ac__common_8php.html#a11">echo_warning</a>(<span class="stringliteral">"No rows"</span>);
<a name="l00069"></a>00069 <a class="code" href="balance_8php.html#a0">exit</a>();
<a name="l00070"></a>00070 }
<a name="l00071"></a>00071 <span class="comment">// Normally Max must be == 1</span>
<a name="l00072"></a><a class="code" href="fiche__search_8php.html#a4">00072</a> <a class="code" href="fiche__new_8php.html#a7">$list</a>=pg_fetch_array($Res,0);
<a name="l00073"></a>00073 <span class="keywordflow">if</span> ( $list['<a class="code" href="classfiche.html">fiche</a>']==<span class="stringliteral">""</span>) {
<a name="l00074"></a>00074 <a class="code" href="ac__common_8php.html#a11">echo_warning</a>(<span class="stringliteral">"Journal mal param<61>tr<74>"</span>);
<a name="l00075"></a>00075 <a class="code" href="balance_8php.html#a0">exit</a>();
<a name="l00076"></a>00076 }
<a name="l00077"></a><a class="code" href="fiche__search_8php.html#a5">00077</a> <a class="code" href="fiche__search_8php.html#a5">$list_fiche</a>=<a class="code" href="fiche__new_8php.html#a7">$list</a>['<a class="code" href="classfiche.html">fiche</a>'];
<a name="l00078"></a>00078 <span class="keywordflow">return</span> <a class="code" href="fiche__search_8php.html#a5">$list_fiche</a>;
<a name="l00079"></a>00079 }
<a name="l00080"></a>00080 ?&gt;
<a name="l00081"></a>00081 &lt;script language=<span class="stringliteral">"javascript"</span>&gt;
<a name="l00082"></a>00082 function SetData (name_ctl,<a class="code" href="client_8inc_8php.html#a6">value</a>,value_2,value_3,value_4,value_5,value_6) {
<a name="l00083"></a>00083 <span class="keyword">self</span>.opener.SetData(name_ctl,<a class="code" href="client_8inc_8php.html#a6">value</a>,value_2,value_3,value_4,value_5,value_6);
<a name="l00084"></a>00084 window.close();
<a name="l00085"></a>00085 }
<a name="l00086"></a>00086 &lt;/script&gt;
<a name="l00087"></a>00087 &lt;?
<a name="l00088"></a>00088 <a class="code" href="impress__fiche_8php.html#a0">$cn</a>=<a class="code" href="postgres_8php.html#a1">DbConnect</a>($_SESSION['g_dossier']);
<a name="l00089"></a><a class="code" href="fiche__search_8php.html#a6">00089</a> <a class="code" href="user__action__ach_8php.html#a2">$r</a>=<span class="stringliteral">""</span>;
<a name="l00090"></a>00090
<a name="l00091"></a>00091 foreach ($HTTP_GET_VARS as $key=&gt;$element) {
<a name="l00092"></a>00092 <span class="comment">// The value are e_name e_type e_PHPSESSID</span>
<a name="l00093"></a>00093 ${<span class="stringliteral">"e_$key"</span>}=$element;
<a name="l00094"></a>00094 <a class="code" href="debug_8php.html#a0">echo_debug</a>('fiche_search.php',__LINE__,<span class="stringliteral">"e_$key =$element&lt;br&gt;"</span>);
<a name="l00095"></a>00095
<a name="l00096"></a>00096 }
<a name="l00097"></a><a class="code" href="fiche__search_8php.html#a7">00097</a> <a class="code" href="fiche__search_8php.html#a7">$e_fic_search</a>=(isset ($_POST['fic_search']))?$_POST['fic_search']:<span class="stringliteral">""</span>;
<a name="l00098"></a>00098
<a name="l00099"></a>00099 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;FORM METHOD=\"POST\" ACTION=\""</span>.$_SERVER['REQUEST_URI'].<span class="stringliteral">"\"&gt;"</span>;
<a name="l00100"></a>00100 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"Recherche : "</span>.'&lt;INPUT TYPE=<span class="stringliteral">"TEXT"</span> NAME=<span class="stringliteral">"fic_search"</span> VALUE=<span class="stringliteral">"'.$e_fic_search.'"</span>&gt;';
<a name="l00101"></a>00101 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.='&lt;INPUT TYPE=<span class="stringliteral">"submit"</span> <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"search"</span> <a class="code" href="client_8inc_8php.html#a6">value</a>=<span class="stringliteral">"Go"</span>&gt;';
<a name="l00102"></a>00102 <span class="comment">//$r.="&lt;/FORM&gt;";</span>
<a name="l00103"></a>00103 <a class="code" href="user__action__ach_8php.html#a2">$r</a>.=<span class="stringliteral">"&lt;div&gt;"</span>;
<a name="l00104"></a>00104 echo <a class="code" href="user__action__ach_8php.html#a2">$r</a>;
<a name="l00105"></a>00105 $r=<span class="stringliteral">""</span>;
<a name="l00106"></a>00106
<a name="l00107"></a>00107 <span class="comment">// Show result of the search </span>
<a name="l00108"></a>00108 <span class="keywordflow">if</span> ( isset ( $_POST['search']) ) {
<a name="l00109"></a>00109
<a name="l00110"></a>00110 <span class="comment">// Get the field from database</span>
<a name="l00111"></a>00111 <span class="keywordflow">if</span> ( $e_type == 'deb' ) {
<a name="l00112"></a>00112 $get='jrn_def_fiche_deb';
<a name="l00113"></a>00113 <a class="code" href="fiche__search_8php.html#a5">$list_fiche</a>=get_list_fiche($cn,$get,$_GET['p_jrn']);
<a name="l00114"></a><a class="code" href="fiche__search_8php.html#a8">00114</a> <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=<span class="stringliteral">"select * from vw_fiche_attr where fd_id in ( $list_fiche )"</span>;
<a name="l00115"></a>00115 }
<a name="l00116"></a>00116 <span class="keywordflow">if</span> ( $e_type == 'cred' ) {
<a name="l00117"></a>00117 $get='jrn_def_fiche_cred';
<a name="l00118"></a>00118 <a class="code" href="fiche__search_8php.html#a5">$list_fiche</a>=get_list_fiche($cn,$get,$_GET['p_jrn']);
<a name="l00119"></a>00119 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=<span class="stringliteral">"select * from vw_fiche_attr where fd_id in ( $list_fiche )"</span>;
<a name="l00120"></a>00120 }
<a name="l00121"></a>00121
<a name="l00122"></a>00122
<a name="l00123"></a>00123 <span class="comment">// if e_type contains a list of value</span>
<a name="l00124"></a>00124 <span class="keywordflow">if</span> ( $e_type != 'cred' and $e_type != 'deb') {
<a name="l00125"></a>00125 <a class="code" href="fiche__search_8php.html#a5">$list_fiche</a>=$e_type;
<a name="l00126"></a>00126 <a class="code" href="facture_8inc_8php.html#a1">$sql</a>=<span class="stringliteral">"select * from vw_fiche_attr where frd_id in ( $list_fiche )"</span>;
<a name="l00127"></a>00127 <span class="comment">// $sql="select * from vw_fiche_attr ";</span>
<a name="l00128"></a>00128 }
<a name="l00129"></a>00129 <span class="comment">// e_fic_search contains the pattern</span>
<a name="l00130"></a>00130
<a name="l00131"></a>00131 <span class="keywordflow">if</span> (strlen(trim($e_fic_search) ) == 0 ) {
<a name="l00132"></a>00132 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($cn,$sql);
<a name="l00133"></a>00133 } <span class="keywordflow">else</span> {
<a name="l00134"></a>00134 <a class="code" href="eub__be_8inc_8php.html#a5">$Res</a>=<a class="code" href="postgres_8php.html#a2">ExecSql</a>($cn,<span class="stringliteral">"$sql and upper(vw_name) like upper('%$e_fic_search%')"</span>);
<a name="l00135"></a>00135 }
<a name="l00136"></a>00136
<a name="l00137"></a>00137 <span class="comment">// Test whether rows are returned</span>
<a name="l00138"></a>00138 <span class="keywordflow">if</span> ( ($Max = pg_NumRows($Res) ) == 0 ) {
<a name="l00139"></a>00139 <a class="code" href="ac__common_8php.html#a11">echo_warning</a>(<span class="stringliteral">"Pas de fiche trouv<75>e"</span>);
<a name="l00140"></a>00140 <span class="keywordflow">return</span>;
<a name="l00141"></a>00141 }
<a name="l00142"></a>00142 <span class="comment">// Show the cards</span>
<a name="l00143"></a>00143 <span class="keywordflow">for</span> ( $i=0; $i &lt; $Max; $i++) {
<a name="l00144"></a>00144
<a name="l00145"></a>00145 <span class="comment">//set focus on first "Select" button.</span>
<a name="l00146"></a>00146
<a name="l00147"></a>00147 <a class="code" href="cbc__be_8inc_8php.html#a0">$row</a>=pg_fetch_array($Res,$i);
<a name="l00148"></a>00148 <span class="keywordflow">if</span> ( $i %2 == 0 )
<a name="l00149"></a>00149 $class=<span class="stringliteral">"even"</span>;
<a name="l00150"></a>00150 <span class="keywordflow">else</span>
<a name="l00151"></a>00151 $class=<span class="stringliteral">"odd"</span>;
<a name="l00152"></a>00152 $text=<a class="code" href="ac__common_8php.html#a9">FormatString</a>($row['vw_name']);
<a name="l00153"></a>00153 $r.=<span class="stringliteral">"&lt;span class=\"$class\"&gt;"</span>;
<a name="l00154"></a>00154 $r.=sprintf ('&lt;input <a class="code" href="client_8inc_8php.html#a5">name</a>=<span class="stringliteral">"%s"</span> type=<span class="stringliteral">"button"</span> onClick=<span class="stringliteral">"'."</span>SetData('%s<span class="charliteral">','</span>%s<span class="charliteral">','</span>%s<span class="charliteral">','</span>%s<span class="charliteral">','</span>%s<span class="charliteral">','</span>%s<span class="charliteral">','</span>%s')<span class="stringliteral">".'"</span> <a class="code" href="client_8inc_8php.html#a6">value</a>=<span class="stringliteral">"%s"</span>&gt;',
<a name="l00155"></a>00155 <span class="stringliteral">"select"</span> . $i,
<a name="l00156"></a>00156 $e_name,
<a name="l00157"></a>00157 $row['quick_code'] ,
<a name="l00158"></a>00158 $text,
<a name="l00159"></a>00159 $row['vw_sell'],
<a name="l00160"></a>00160 $row['vw_buy'],
<a name="l00161"></a>00161 $row['tva_id'],
<a name="l00162"></a>00162 $row['tva_label'] ,
<a name="l00163"></a>00163 $row['quick_code']
<a name="l00164"></a>00164 );
<a name="l00165"></a>00165 $r.=<span class="stringliteral">"&amp;nbsp;"</span>.$row['vw_name'];
<a name="l00166"></a>00166 <span class="keywordflow">if</span> ( $row['vw_addr'] !=<span class="stringliteral">""</span>)
<a name="l00167"></a>00167 $r.=<span class="stringliteral">"&lt;br&gt;&lt;font size=-1&gt;Adresse:&amp;nbsp;"</span>.$row['vw_addr'].<span class="stringliteral">"&amp;nbsp;"</span>.<a class="code" href="cbc__be_8inc_8php.html#a0">$row</a>['vw_cp'].<span class="stringliteral">"&lt;/font&gt;"</span>;
<a name="l00168"></a>00168 $r.=<span class="stringliteral">"&lt;/span&gt;"</span>;
<a name="l00169"></a>00169 }
<a name="l00170"></a>00170 }
<a name="l00171"></a>00171 $r.=<span class="stringliteral">"&lt;/div&gt;"</span>;
<a name="l00172"></a>00172 $r.=<span class="stringliteral">"&lt;/FORM&gt;"</span>;
<a name="l00173"></a>00173 echo $r;
<a name="l00174"></a>00174
<a name="l00175"></a>00175 ?&gt;
<a name="l00176"></a>00176
<a name="l00177"></a>00177 &lt;?
<a name="l00178"></a>00178
<a name="l00179"></a>00179 <a class="code" href="ac__common_8php.html#a6">html_page_stop</a>();
<a name="l00180"></a>00180 ?&gt;
</pre></div><hr size="1"><address style="align: right;"><small>Generated on Fri Jun 23 00:12:45 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>