From f5c5e3cfc176609fee286ab52c849350d69288e8 Mon Sep 17 00:00:00 2001 From: sparkyx Date: Tue, 13 Apr 2004 12:36:04 +0000 Subject: [PATCH] Set filter for ODS --- html/poste_search.php | 57 ++++++++++++++++++++++++++++++++++++++++--- include/constant.php | 4 +++ 2 files changed, 58 insertions(+), 3 deletions(-) diff --git a/html/poste_search.php b/html/poste_search.php index 4204b9f57..5a352e7c5 100644 --- a/html/poste_search.php +++ b/html/poste_search.php @@ -22,6 +22,7 @@ include_once ("ac_common.php"); html_page_start($g_UserProperty['use_theme']); include_once ("postgres.php"); +include_once("jrn.php"); /* Admin. Dossier */ CheckUser(); //echo ''; @@ -29,7 +30,6 @@ echo JS_SEARCH_POSTE; if ( ! isset ( $g_dossier ) ) { echo "You must choose a Dossier "; - phpinfo(); exit -2; } @@ -61,7 +61,57 @@ if ( isset($_POST['search']) ) { $condition=$c_comment.$c_class; } +$url=""; +// Filter ??? +if ( isset($_GET['filter'])) { + $url="?filter=1"; + // There is a filter, the value of the filter is the journal id, we + // have to find what account are available + $SqlCred=""; + // Load the property + $l_line=GetJrnProperty($cn,$g_jrn); + if ( strlen(trim ($l_line['jrn_def_class_cred']) ) > 0 ) { + $valid_cred=split(" ",$l_line['jrn_def_class_cred']); + // Creation query + foreach ( $valid_cred as $item_cred) { + if ( strlen (trim($item_cred))) { + echo_debug("l_line[jrn_def_class_cred] $l_line[jrn_def_class_cred] item_cred $item_cred"); + if ( strstr($item_cred,"*") == true ) { + $item_cred=strtr($item_cred,"*","%"); + $Sql=" pcm_val like '$item_cred' or"; + } else { + $Sql=" pcm_val = '$item_cred' or"; + } + $SqlCred=$SqlCred.$Sql; + } + }//foreach + + } + if ( strlen(trim ($l_line['jrn_def_class_deb']) ) > 0 ) { + $valid_deb=split(" ",$l_line['jrn_def_class_deb']); + + // Creation query + foreach ( $valid_deb as $item_deb) { + if ( strlen (trim($item_deb))) { + echo_debug("l_line[jrn_def_class_deb] $l_line[jrn_def_class_deb] item_deb $item_deb"); + if ( strstr($item_deb,"*") == true ) { + $item_cred=strtr($item_deb,"*","%"); + $Sql=" pcm_val like '$item_deb' or"; + } else { + $Sql=" pcm_val = '$item_deb' or"; + } + $SqlCred=$SqlCred.$Sql; + } + }//foreach + + } + if ( $condition=="") { + $condition .= ($SqlCred=="")?"":" where ".substr($SqlCred,0,strlen($SqlCred)-2); + } else { + $condition .= ($SqlCred=="")?"":" and ( ".substr($SqlCred,0,strlen($SqlCred)-2)." ) "; + } +}// if (isset($_GET['filter'])) if ( isset($_GET['p_ctl'])) { $p_ctl=$_GET['p_ctl']; } @@ -70,7 +120,8 @@ if ( isset($_POST['p_ctl'])) { } echo_debug("condition = $condition"); -echo '
'; + +echo ''; if ( isset($p_ctl) ) { if ($p_ctl != 'not') echo ''; } @@ -92,7 +143,7 @@ echo ''; echo '
'; // if request search -if ( isset($_POST['search']) ) { +if ( isset($_POST['search']) or isset($_GET['filter']) ) { $Res=ExecSql($cn,"select * from tmp_pcmn $condition order by pcm_val::text"); $MaxLine=pg_NumRows($Res); diff --git a/include/constant.php b/include/constant.php index 85ca84e13..5ebbd4580 100644 --- a/include/constant.php +++ b/include/constant.php @@ -103,6 +103,10 @@ define ("FICHE_TYPE_ADM_TAX",14); define ("JS_SEARCH_POSTE","