Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 require_once '../include/constant.php';
00029 require_once('class_database.php');
00030 require_once('class_dossier.php');
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045 $jrn= ( ! isset($_REQUEST['j']))?-1:$_REQUEST['j'];
00046 $filter_card="";
00047 $cn=new Database(dossier::id());
00048 $d=$_REQUEST['e'];
00049 $filter_card='';
00050
00051 require_once('class_user.php');
00052 global $g_user;
00053 $g_user=new User($cn);
00054 $g_user->check();
00055 $g_user->check_dossier(dossier::id());
00056
00057 if ( $d == 'all')
00058 {
00059 $filter_card='';
00060 }
00061 else if (strpos($d,'sql]')==true)
00062 {
00063 $filter_card= str_replace('[sql]', " and ", $d);
00064 } else
00065 $filter_card="and fd_id in ($d)";
00066
00067 if ( $jrn != -1 )
00068 {
00069 switch ($d)
00070 {
00071 case 'cred':
00072 $filter_jrn=$cn->make_list("select jrn_def_fiche_cred from jrn_def where jrn_def_id=$1",array($jrn));
00073 $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false ';
00074 break;
00075 case 'deb':
00076 $filter_jrn=$cn->make_list("select jrn_def_fiche_deb from jrn_def where jrn_def_id=$1",array($jrn));
00077 $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false ';
00078 break;
00079 case 'filter':
00080 $get_cred='jrn_def_fiche_cred';
00081 $get_deb='jrn_def_fiche_deb';
00082 $deb=$cn->get_value("select $get_deb from jrn_def where jrn_def_id=$1",array($jrn));
00083 $cred=$cn->get_value("select $get_cred from jrn_def where jrn_def_id=$1",array($jrn));
00084
00085 $filter_jrn="";
00086
00087 if ($deb!=='' && $cred!='')
00088 $filter_jrn =$deb.','.$cred;
00089 elseif($deb != '')
00090 $filter_jrn=$deb;
00091 elseif($cred != '')
00092 $filter_jrn=$cred;
00093
00094 $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false ';
00095
00096 break;
00097
00098 }
00099 }
00100 else
00101 {
00102 if (isset($_REQUEST['type']))
00103 {
00104 if ($_REQUEST['type']=='gl' || $_REQUEST['type']=='') $filter_card='';
00105 else
00106 {
00107 $get_cred='jrn_def_fiche_cred';
00108 $get_deb='jrn_def_fiche_deb';
00109
00110 $filter_jrn=$cn->make_list("select $get_cred||','||$get_deb as fiche from jrn_def where jrn_def_type=$1",array($_REQUEST['type']));
00111 $filter_card=($filter_jrn != "")?" and fd_id in ($filter_jrn)":' and false ';
00112
00113 }
00114 }
00115 }
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125 $sql_str="select distinct f_id from fiche join fiche_detail using (f_id) where ad_id in (9,1,23) and ad_value ilike '%'||$1||'%' ".$filter_card.' limit 12';
00126
00127 $sql=$cn->get_array($sql_str ,array($_REQUEST['FID']));
00128
00129 if (sizeof($sql) != 0 )
00130 {
00131 echo "<ul>";
00132 $sql_get=$cn->prepare('get_name',"select ad_value from fiche_detail where f_id = $1 and ad_id=$2");
00133
00134 for ($i =0;$i<12 && $i < count($sql) ;$i++)
00135 {
00136 $name='';
00137 $quick_code='';
00138 $desc='';
00139
00140 $sql_name=$cn->execute('get_name',array($sql[$i]['f_id'],1));
00141 if ( Database::num_row($sql_name) == 1) $name=Database::fetch_result($sql_name,0,0);
00142
00143 $sql_name=$cn->execute('get_name',array($sql[$i]['f_id'],9));
00144 if ( Database::num_row($sql_name) == 1) $desc=Database::fetch_result($sql_name,0,0);
00145
00146 $sql_name=$cn->execute('get_name',array($sql[$i]['f_id'],23));
00147 if (Database::num_row($sql_name) == 1) $quick_code=Database::fetch_result($sql_name,0,0);
00148
00149
00150
00151 $name=str_ireplace($_REQUEST['FID'],'<em>'.$_REQUEST['FID'].'</em>',h($name));
00152 $qcode=str_ireplace($_REQUEST['FID'],'<em>'.$_REQUEST['FID'].'</em>',h($quick_code));
00153 $desc=str_ireplace($_REQUEST['FID'],'<em>'.$_REQUEST['FID'].'</em>',h($desc));
00154 printf('<li id="%s">%s <span class="informal"> %s %s</span></li>',
00155 $quick_code,
00156 $quick_code,
00157 $name,
00158 $desc
00159 );
00160 }
00161 echo '</ul>';
00162 if (count($sql) > 12)
00163 {
00164 printf ('<i>...'._('Résultat limité à 12').' ...</i>');
00165 }
00166 }
00167 else
00168 {
00169 echo "<ul><li>"._("Non trouvé")."</li></ul>";
00170 }
00171 ?>