00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024 include_once ("ac_common.php");
00025 html_page_start($_SESSION['g_theme'],"onLoad='window.focus();'");
00026 include_once ("postgres.php");
00027 include_once("jrn.php");
00028
00029 $rep=DbConnect();
00030 include_once ("class_user.php");
00031 $User=new cl_user($rep);
00032 $User->Check();
00033
00034 echo JS_SEARCH_POSTE;
00035
00036 if ( ! isset ( $_SESSION['g_dossier'] ) ) {
00037 echo "You must choose a Dossier ";
00038 exit -2;
00039 }
00040
00041 $c_comment="";
00042 $c_class="";
00043
00044 $condition="";
00045 $cn=DbConnect($_SESSION['g_dossier']);
00046 if ( isset($_POST['search']) ) {
00047 $c1=0;
00048 foreach( $HTTP_POST_VARS as $key=>$element){
00049 ${"$key"}=$element;
00050 }
00051 if ( strlen(trim($p_comment)) != 0 ) {
00052 $c_comment=" where upper(pcm_lib) like upper('%$p_comment%')";
00053 $c1=1;
00054 }
00055 if ( strlen(trim($p_class)) != 0 &&
00056 (string) $p_class == (int)(string) $p_class) {
00057 if ($c1==1)
00058 $clause=" and ";
00059 else
00060 $clause = " where ";
00061 $c_class=sprintf(" %s pcm_val::text like '%s%%'",$clause,$p_class);
00062
00063 }
00064
00065
00066 $condition=$c_comment.$c_class;
00067 }
00068 $url="";
00069
00070 if ( isset($_GET['filter'])) {
00071 $url="?filter=1";
00072
00073
00074 $SqlCred="";
00075
00076 $l_line=GetJrnProperty($cn,$_GET['p_jrn']);
00077 if ( strlen(trim ($l_line['jrn_def_class_cred']) ) > 0 ) {
00078 $valid_cred=split(" ",$l_line['jrn_def_class_cred']);
00079
00080
00081 foreach ( $valid_cred as $item_cred) {
00082 if ( strlen (trim($item_cred))) {
00083 echo_debug('poste_search.php',__LINE__,"l_line[jrn_def_class_cred] $l_line[jrn_def_class_cred] item_cred $item_cred");
00084 if ( strstr($item_cred,"*") == true ) {
00085 $item_cred=strtr($item_cred,"*","%");
00086 $Sql=" pcm_val like '$item_cred' or";
00087 } else {
00088 $Sql=" pcm_val = '$item_cred' or";
00089 }
00090 $SqlCred=$SqlCred.$Sql;
00091 }
00092 }
00093
00094 }
00095 if ( strlen(trim ($l_line['jrn_def_class_deb']) ) > 0 ) {
00096 $valid_deb=split(" ",$l_line['jrn_def_class_deb']);
00097
00098
00099 foreach ( $valid_deb as $item_deb) {
00100 if ( strlen (trim($item_deb))) {
00101 echo_debug('poste_search.php',__LINE__,"l_line[jrn_def_class_deb] $l_line[jrn_def_class_deb] item_deb $item_deb");
00102 if ( strstr($item_deb,"*") == true ) {
00103 $item_cred=strtr($item_deb,"*","%");
00104 $Sql=" pcm_val like '$item_deb' or";
00105 } else {
00106 $Sql=" pcm_val = '$item_deb' or";
00107 }
00108 $SqlCred=$SqlCred.$Sql;
00109 }
00110 }
00111
00112 }
00113 if ( $condition=="") {
00114 $condition .= ($SqlCred=="")?"":" where ".substr($SqlCred,0,strlen($SqlCred)-2);
00115 } else {
00116 $condition .= ($SqlCred=="")?"":" and ( ".substr($SqlCred,0,strlen($SqlCred)-2)." ) ";
00117 }
00118 }
00119 if ( isset($_GET['p_ctl'])) {
00120 $p_ctl=$_GET['p_ctl'];
00121 }
00122 if ( isset($_POST['p_ctl'])) {
00123 $p_ctl=$_POST['p_ctl'];
00124 }
00125
00126 echo_debug('poste_search.php',__LINE__,"condition = $condition");
00127
00128 echo '<FORM ACTION="poste_search.php'.$url.'" METHOD="POST">';
00129 if ( isset($p_ctl) ) {
00130 if ($p_ctl != 'not') echo '<INPUT TYPE="hidden" name="p_ctl" value="'.$p_ctl.'">';
00131 }
00132 echo '<TABLE>';
00133 echo '<TR>';
00134
00135 echo '<TD>Poste Comptable Commence par </TD>';
00136
00137 if ( ! isset ($p_class) ) $p_class="";
00138 $opt=" <INPUT TYPE=\"text\" value=\"$p_class\" name=\"st_with\">";
00139 echo '<TD> <INPUT TYPE="text" name="p_class" VALUE="'.$p_class.'"></TD>';
00140
00141 echo '<TD> Libellé </TD>';
00142 echo '<TD> contient </TD>';
00143 if ( ! isset ($p_comment) ) $p_comment="";
00144 echo '<TD> <INPUT TYPE="text" name="p_comment" VALUE="'.$p_comment.'"></TD></TR>';
00145 echo '</TABLE>';
00146 echo '<INPUT TYPE="submit" name="search" value="cherche">';
00147 echo '</FORM>';
00148
00149
00150 if ( isset($_POST['search']) or isset($_GET['filter']) ) {
00151 $Res=ExecSql($cn,"select * from tmp_pcmn $condition order by pcm_val::text");
00152
00153 $MaxLine=pg_NumRows($Res);
00154 if ( $MaxLine==0) {
00155 html_page_stop();
00156 return;
00157 }
00158 echo '<TABLE BORDER="0">';
00159 $l_id="";
00160
00161 for ( $i=0; $i < $MaxLine; $i++) {
00162 $l_line=pg_fetch_array($Res,$i);
00163 echo "<TR>";
00164
00165 if (isset($p_ctl) and $p_ctl != 'not' ){
00166 echo '<TD>';
00167 echo '<input type="checkbox" onClick="SetItChild(\''.$p_ctl.'\',\''.$l_line['pcm_val'].'\')">';
00168 echo '</td>';
00169 }
00170 echo '<TD>';
00171 echo $l_line['pcm_val'];
00172 echo '</TD>';
00173
00174 echo '<TD>';
00175 echo $l_line['pcm_lib'];
00176 echo '</TD>';
00177 echo "</TR>";
00178
00179 }
00180
00181 echo '</TABLE>';
00182 }
00183 echo '<INPUT TYPE="BUTTON" Value="Close" onClick=\'GetIt()\'>';
00184 html_page_stop();
00185 ?>