00001 <?
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00025 include_once ("ac_common.php");
00026 include_once ("poste.php");
00027 include_once ("postgres.php");
00028 include_once("jrn.php");
00029
00030 $rep=DbConnect();
00031 include_once ("class_user.php");
00032 $User=new cl_user($rep);
00033 $User->Check();
00034
00035
00036 if ( isset ( $_POST['search']) )
00037 {
00038 html_page_start($User->theme,"onLoad=\"window.focus();SetFocus('select0',0)\"");
00039 } else
00040 {
00041 html_page_start($User->theme,"onLoad=\"window.focus();SetFocus('fic_search',0)\"");
00042 }
00043
00044
00045
00046 if ( ! isset ( $_SESSION['g_dossier'] ) ) {
00047 echo "You must choose a Dossier ";
00048 exit -2;
00049 }
00050
00051 include_once ("check_priv.php");
00052 $cn=DbConnect($_SESSION['g_dossier']);
00053
00054 if ( $User->CheckAction($cn,FICHE_READ) == 0 ){
00055
00056 echo '<h2 class="error"> Vous n\' avez pas accès</h2>';
00057 return;
00058 }
00059
00060 function get_list_fiche($p_cn,$get,$p_jrn)
00061 {
00062 $sql="select $get as fiche from jrn_def where jrn_def_id=$p_jrn";
00063 $Res=ExecSql($p_cn,$sql);
00064
00065
00066 $Max=pg_NumRows($Res);
00067 if ( $Max==0) {
00068 echo_warning("No rows");
00069 exit();
00070 }
00071
00072 $list=pg_fetch_array($Res,0);
00073 if ( $list['fiche']=="") {
00074 echo_warning("Journal mal paramètré");
00075 exit();
00076 }
00077 $list_fiche=$list['fiche'];
00078 return $list_fiche;
00079 }
00080 ?>
00081 <script language="javascript">
00082 function SetData (name_ctl,value,value_2,value_3,value_4,value_5,value_6) {
00083 self.opener.SetData(name_ctl,value,value_2,value_3,value_4,value_5,value_6);
00084 window.close();
00085 }
00086 </script>
00087 <?
00088 $cn=DbConnect($_SESSION['g_dossier']);
00089 $r="";
00090
00091 foreach ($HTTP_GET_VARS as $key=>$element) {
00092
00093 ${"e_$key"}=$element;
00094 echo_debug('fiche_search.php',__LINE__,"e_$key =$element<br>");
00095
00096 }
00097 $e_fic_search=(isset ($_POST['fic_search']))?$_POST['fic_search']:"";
00098
00099 $r.="<FORM METHOD=\"POST\" ACTION=\"".$_SERVER['REQUEST_URI']."\">";
00100 $r.="Recherche : ".'<INPUT TYPE="TEXT" NAME="fic_search" VALUE="'.$e_fic_search.'">';
00101 $r.='<INPUT TYPE="submit" name="search" value="Go">';
00102
00103 $r.="<div>";
00104 echo $r;
00105 $r="";
00106
00107
00108 if ( isset ( $_POST['search']) ) {
00109
00110
00111 if ( $e_type == 'deb' ) {
00112 $get='jrn_def_fiche_deb';
00113 $list_fiche=get_list_fiche($cn,$get,$_GET['p_jrn']);
00114 $sql="select * from vw_fiche_attr where fd_id in ( $list_fiche )";
00115 }
00116 elseif ( $e_type == 'cred' ) {
00117 $get='jrn_def_fiche_cred';
00118 $list_fiche=get_list_fiche($cn,$get,$_GET['p_jrn']);
00119 $sql="select * from vw_fiche_attr where fd_id in ( $list_fiche )";
00120 }
00124 elseif ( $e_type == 'all' ) {
00125 $sql="select * from vw_fiche_attr where true";
00126 }
00127
00128 else{
00129 $list_fiche=$e_type;
00130 $sql="select * from vw_fiche_attr where frd_id in ( $list_fiche )";
00131
00132 }
00133
00134
00135 if (strlen(trim($e_fic_search) ) == 0 ) {
00136 $Res=ExecSql($cn,$sql);
00137 } else {
00138 $Res=ExecSql($cn,"$sql and upper(vw_name) like upper('%$e_fic_search%')");
00139 }
00140
00141
00142 if ( ($Max = pg_NumRows($Res) ) == 0 ) {
00143 echo_warning("Pas de fiche trouvée");
00144 return;
00145 }
00146
00147 for ( $i=0; $i < $Max; $i++) {
00148
00149
00150
00151 $row=pg_fetch_array($Res,$i);
00152
00153 if (trim($row['quick_code']) == "")
00154 continue;
00155
00156
00157 if ( $i %2 == 0 )
00158 $class="even";
00159 else
00160 $class="odd";
00161 $text=FormatString($row['vw_name']);
00162 $r.="<span class=\"$class\">";
00163 $qcode= $row['quick_code'] ;
00164
00165 $r.=sprintf ('<input name="%s" type="button" onClick="'."SetData('%s','%s','%s','%s','%s','%s','%s')".'" value="%s">',
00166 "select" . $i,
00167 $e_name,
00168 $row['quick_code'] ,
00169 $text,
00170 $row['vw_sell'],
00171 $row['vw_buy'],
00172 $row['tva_id'],
00173 $row['tva_label'] ,
00174 $qcode
00175 );
00176 $r.=" ".$row['vw_name'];
00177 if ( $row['vw_addr'] !="")
00178 $r.="<br><font size=-1>Adresse: ".$row['vw_addr']." ".$row['vw_cp']."</font>";
00179 $r.="</span>";
00180 }
00181 }
00182 $r.="</div>";
00183 $r.="</FORM>";
00184 echo $r;
00185
00186 ?>
00187
00188 <?
00189
00190 html_page_stop();
00191 ?>