1 | <?php |
---|
2 | // +-------------------------------------------------+ |
---|
3 | // © 2002-2004 PMB Services / www.sigb.net pmb@sigb.net et contributeurs (voir www.sigb.net) |
---|
4 | // +-------------------------------------------------+ |
---|
5 | // $Id: ajax_selector.php,v 1.59 2015-04-03 11:16:23 jpermanne Exp $ |
---|
6 | |
---|
7 | $base_path="."; |
---|
8 | $base_noheader=1; |
---|
9 | $base_nobody=1; |
---|
10 | //$base_nocheck=1; |
---|
11 | |
---|
12 | |
---|
13 | require_once("includes/init.inc.php"); |
---|
14 | require_once("$class_path/marc_table.class.php"); |
---|
15 | require_once("$class_path/analyse_query.class.php"); |
---|
16 | |
---|
17 | header("Content-Type: text/html; charset=$charset"); |
---|
18 | $start=stripslashes($datas); |
---|
19 | $start = str_replace("*","%",$start); |
---|
20 | $insert_between_separator = ""; |
---|
21 | |
---|
22 | switch($completion): |
---|
23 | case 'categories': |
---|
24 | /* Pas utilisé en gestion Matthieu 02/08/2012 */ |
---|
25 | $array_selector=array(); |
---|
26 | require_once("$class_path/thesaurus.class.php"); |
---|
27 | require_once("$class_path/categories.class.php"); |
---|
28 | if ($thesaurus_mode_pmb==1) $id_thes=-1; |
---|
29 | else $id_thes=$thesaurus_defaut; |
---|
30 | |
---|
31 | $aq=new analyse_query($start); |
---|
32 | |
---|
33 | $members_catdef = $aq->get_query_members("catdef", "catdef.libelle_categorie", "catdef.index_categorie", "catdef.num_noeud"); |
---|
34 | $members_catlg = $aq->get_query_members("catlg", "catlg.libelle_categorie", "catlg.index_categorie", "catlg.num_noeud"); |
---|
35 | |
---|
36 | $requete_langue="select catlg.num_noeud as categ_id, noeuds.num_parent as categ_parent, noeuds.num_renvoi_voir as categ_see, noeuds.num_thesaurus, catlg.langue as langue, |
---|
37 | catlg.libelle_categorie as categ_libelle,catlg.index_categorie as index_categorie, catlg.note_application as categ_comment, |
---|
38 | (".$members_catlg["select"].") as pert from thesaurus left join noeuds on thesaurus.id_thesaurus = noeuds.num_thesaurus left join categories as catlg on noeuds.id_noeud = catlg.num_noeud |
---|
39 | and catlg.langue = '".$lang."' where catlg.libelle_categorie like '".addslashes($start)."%' and catlg.libelle_categorie not like '~%'"; |
---|
40 | |
---|
41 | $requete_defaut="select catdef.num_noeud as categ_id, noeuds.num_parent as categ_parent, noeuds.num_renvoi_voir as categ_see, noeuds.num_thesaurus, catdef.langue as langue, |
---|
42 | catdef.libelle_categorie as categ_libelle,catdef.index_categorie as index_categorie, catdef.note_application as categ_comment, |
---|
43 | (".$members_catdef["select"].") as pert from thesaurus left join noeuds on thesaurus.id_thesaurus = noeuds.num_thesaurus left join categories as catdef on noeuds.id_noeud = catdef.num_noeud |
---|
44 | and catdef.langue = thesaurus.langue_defaut where catdef.libelle_categorie like '".addslashes($start)."%' and catdef.libelle_categorie not like '~%'"; |
---|
45 | |
---|
46 | $requete="select * from (".$requete_langue." union ".$requete_defaut.") as sub1 group by categ_id order by pert desc,num_thesaurus, categ_libelle limit 20"; |
---|
47 | |
---|
48 | $res = @pmb_mysql_query($requete, $dbh) or die(pmb_mysql_error()."<br />$requete"); |
---|
49 | while(($categ=pmb_mysql_fetch_object($res))) { |
---|
50 | $display_temp = "" ; |
---|
51 | $lib_simple=""; |
---|
52 | $tab_lib_categ=""; |
---|
53 | $temp = new categories($categ->categ_id, $categ->langue); |
---|
54 | if ($id_thes == -1) { |
---|
55 | $thes = new thesaurus($categ->num_thesaurus); |
---|
56 | $display_temp = htmlentities('['.$thes->libelle_thesaurus.'] ',ENT_QUOTES, $charset); |
---|
57 | } |
---|
58 | $id_categ_retenue = $categ->categ_id ; |
---|
59 | if($categ->categ_see) { |
---|
60 | $id_categ_retenue = $categ->categ_see ; |
---|
61 | $temp = new categories($categ->categ_see, $categ->langue); |
---|
62 | $display_temp.= $categ->categ_libelle." -> "; |
---|
63 | $lib_simple = $temp->libelle_categorie; |
---|
64 | if ($thesaurus_categories_show_only_last) $display_temp.= $temp->libelle_categorie; |
---|
65 | else $display_temp.= categories::listAncestorNames($categ->categ_see, $categ->langue); |
---|
66 | $display_temp.= "@"; |
---|
67 | } else { |
---|
68 | $lib_simple = $categ->categ_libelle; |
---|
69 | if ($thesaurus_categories_show_only_last) $display_temp.= $categ->categ_libelle; |
---|
70 | else $display_temp.= categories::listAncestorNames($categ->categ_id, $categ->langue); |
---|
71 | } |
---|
72 | |
---|
73 | $tab_lib_categ[$display_temp] = $lib_simple; |
---|
74 | $array_selector[$id_categ_retenue] = $display_temp; |
---|
75 | } // fin while |
---|
76 | $origine = "ARRAY" ; |
---|
77 | break; |
---|
78 | case 'categories_mul': |
---|
79 | $array_selector=array(); |
---|
80 | require_once("$class_path/thesaurus.class.php"); |
---|
81 | require_once("$class_path/categories.class.php"); |
---|
82 | if ($thesaurus_mode_pmb==1){ |
---|
83 | $id_thes=-1; |
---|
84 | }else{ |
---|
85 | $id_thes=$thesaurus_defaut; |
---|
86 | } |
---|
87 | if($att_id_filter!=0){ //forcage sur un thésaurus en particulié |
---|
88 | $id_thes=$att_id_filter; |
---|
89 | $linkfield=$att_id_filter; |
---|
90 | } |
---|
91 | |
---|
92 | if(preg_match("#^f_categ_id#",$autfield)){//Permet de savoir si l'on vient du formulaire de notice ou de recherche |
---|
93 | $from="notice";//Affichage complet du chemin de la catégorie |
---|
94 | }else{ |
---|
95 | $from="search";//Affichage que de la catégorie |
---|
96 | } |
---|
97 | $aq=new analyse_query($start); |
---|
98 | $members_catdef = $aq->get_query_members("catdef", "catdef.libelle_categorie", "catdef.index_categorie", "catdef.num_noeud"); |
---|
99 | $members_catlg = $aq->get_query_members("catlg", "catlg.libelle_categorie", "catlg.index_categorie", "catlg.num_noeud"); |
---|
100 | |
---|
101 | $thesaurus_requette=''; |
---|
102 | $thes_unique=0; |
---|
103 | if($thesaurus_mode_pmb==0){ |
---|
104 | $thesaurus_requette= " id_thesaurus='$thesaurus_defaut' and "; |
---|
105 | $thes_unique=$thesaurus_defaut; |
---|
106 | }elseif($linkfield){ |
---|
107 | if(!preg_match("#,#i",$linkfield)){ |
---|
108 | $thesaurus_requette= " id_thesaurus='$linkfield' and "; |
---|
109 | $thes_unique=$linkfield; |
---|
110 | }else{ |
---|
111 | $thesaurus_requette= " id_thesaurus in ($linkfield) and "; |
---|
112 | } |
---|
113 | } |
---|
114 | |
---|
115 | $requete_langue="select catlg.num_noeud as categ_id, noeuds.num_parent as categ_parent, noeuds.num_renvoi_voir as categ_see, noeuds.num_thesaurus, catlg.langue as langue, |
---|
116 | catlg.libelle_categorie as categ_libelle,catlg.index_categorie as index_categorie, catlg.note_application as categ_comment, noeuds.not_use_in_indexation as not_use_in_indexation, |
---|
117 | (".$members_catlg["select"].") as pert from thesaurus left join noeuds on thesaurus.id_thesaurus = noeuds.num_thesaurus left join categories as catlg on noeuds.id_noeud = catlg.num_noeud |
---|
118 | and catlg.langue = '".$lang."' where $thesaurus_requette catlg.libelle_categorie like '".addslashes($start)."%' and catlg.libelle_categorie not like '~%'"; |
---|
119 | |
---|
120 | $requete_defaut="select catdef.num_noeud as categ_id, noeuds.num_parent as categ_parent, noeuds.num_renvoi_voir as categ_see, noeuds.num_thesaurus, catdef.langue as langue, |
---|
121 | catdef.libelle_categorie as categ_libelle,catdef.index_categorie as index_categorie, catdef.note_application as categ_comment, noeuds.not_use_in_indexation as not_use_in_indexation, |
---|
122 | (".$members_catdef["select"].") as pert from thesaurus left join noeuds on thesaurus.id_thesaurus = noeuds.num_thesaurus left join categories as catdef on noeuds.id_noeud = catdef.num_noeud |
---|
123 | and catdef.langue = thesaurus.langue_defaut where $thesaurus_requette catdef.libelle_categorie like '".addslashes($start)."%' and catdef.libelle_categorie not like '~%'"; |
---|
124 | |
---|
125 | $requete="select * from (".$requete_langue." union ".$requete_defaut.") as sub1 group by categ_id order by pert desc,num_thesaurus, index_categorie limit 20"; |
---|
126 | |
---|
127 | $res = @pmb_mysql_query($requete, $dbh) or die(pmb_mysql_error()."<br />$requete"); |
---|
128 | while(($categ=pmb_mysql_fetch_object($res))) { |
---|
129 | $display_temp = "" ; |
---|
130 | $lib_simple=""; |
---|
131 | $tab_lib_categ=""; |
---|
132 | $temp = new categories($categ->categ_id, $categ->langue); |
---|
133 | if ($id_thes == -1) {//Si mode multi-thésaurus |
---|
134 | $thes = new thesaurus($categ->num_thesaurus); |
---|
135 | if($from == "notice"){//Si saisi de notice |
---|
136 | $lib_simple = htmlentities('['.$thes->libelle_thesaurus.'] ',ENT_QUOTES, $charset); |
---|
137 | } |
---|
138 | } |
---|
139 | |
---|
140 | $id_categ_retenue = $categ->categ_id ; |
---|
141 | //Catégorie à ne pas utiliser en indexation |
---|
142 | $not_use_in_indexation=$categ->not_use_in_indexation; |
---|
143 | if($categ->categ_see) { |
---|
144 | $id_categ_retenue = $categ->categ_see ; |
---|
145 | //Catégorie à ne pas utiliser en indexation |
---|
146 | $category=new category($id_categ_retenue); |
---|
147 | $not_use_in_indexation=$category->not_use_in_indexation; |
---|
148 | |
---|
149 | $temp = new categories($categ->categ_see, $categ->langue); |
---|
150 | $display_temp= $categ->categ_libelle." -> "; |
---|
151 | $chemin=categories::listAncestorNames($categ->categ_see, $categ->langue); |
---|
152 | if ($thesaurus_categories_show_only_last){ |
---|
153 | $display_temp.= $temp->libelle_categorie; |
---|
154 | $lib_simple.= $temp->libelle_categorie; |
---|
155 | }else{ |
---|
156 | $display_temp.=$chemin; |
---|
157 | if($from == "notice"){ |
---|
158 | $lib_simple.= $chemin; |
---|
159 | }else{ |
---|
160 | $lib_simple.= $temp->libelle_categorie; |
---|
161 | } |
---|
162 | } |
---|
163 | $display_temp.= "@"; |
---|
164 | } else { |
---|
165 | $chemin=categories::listAncestorNames($categ->categ_id, $categ->langue); |
---|
166 | if ($thesaurus_categories_show_only_last){ |
---|
167 | $display_temp.= $categ->categ_libelle; |
---|
168 | $lib_simple.= $categ->categ_libelle; |
---|
169 | }else{ |
---|
170 | $display_temp.= $chemin; |
---|
171 | if($from == "notice"){ |
---|
172 | $lib_simple.= $chemin; |
---|
173 | }else{ |
---|
174 | $lib_simple.= $categ->categ_libelle; |
---|
175 | } |
---|
176 | } |
---|
177 | } |
---|
178 | |
---|
179 | if(!$not_use_in_indexation && !preg_match("#:~|^~#i",$chemin)){ |
---|
180 | $tab_lib_categ[$display_temp] = $lib_simple; |
---|
181 | $array_selector[$id_categ_retenue] = $tab_lib_categ; |
---|
182 | if(!$thes_unique){ |
---|
183 | $array_prefix[$id_categ_retenue] = array( |
---|
184 | 'id' => $categ->num_thesaurus, |
---|
185 | 'libelle' => htmlentities('['.$thes->libelle_thesaurus.'] ',ENT_QUOTES, $charset) |
---|
186 | ); |
---|
187 | }else{ |
---|
188 | $array_prefix[$id_categ_retenue] = array( |
---|
189 | 'id' => $categ->num_thesaurus, |
---|
190 | 'libelle' => "" |
---|
191 | ); |
---|
192 | } |
---|
193 | |
---|
194 | } |
---|
195 | } // fin while |
---|
196 | $origine = "ARRAY" ; |
---|
197 | break; |
---|
198 | case 'authors': |
---|
199 | if ($autexclude) $restrict = " AND author_id not in ($autexclude) "; |
---|
200 | $requete="select if(author_date!='',concat(if(author_rejete is not null and author_rejete!='',concat(author_name,', ',author_rejete),author_name),' (',author_date,')'),if(author_rejete is not null and author_rejete!='',concat(author_name,', ',author_rejete),author_name)) as author,author_id from authors where if(author_rejete is not null and author_rejete!='',concat(author_name,', ',author_rejete),author_name) like '".addslashes($start)."%' $restrict order by 1 limit 20"; |
---|
201 | $origine = "SQL" ; |
---|
202 | break; |
---|
203 | case 'authors_person': |
---|
204 | if ($autexclude) $restrict = " AND author_id not in ($autexclude) "; |
---|
205 | $requete="select if(author_date!='',concat(if(author_rejete is not null and author_rejete!='',concat(author_name,', ',author_rejete),author_name),' (',author_date,')'),if(author_rejete is not null and author_rejete!='',concat(author_name,', ',author_rejete),author_name)) as author,author_id from authors where author_type='70' and if(author_rejete is not null and author_rejete!='',concat(author_name,', ',author_rejete),author_name) like '".addslashes($start)."%' $restrict order by 1 limit 20"; |
---|
206 | $origine = "SQL" ; |
---|
207 | break; |
---|
208 | case 'congres_name': |
---|
209 | if ($autexclude) $restrict = " AND author_id not in ($autexclude) "; |
---|
210 | $requete="select distinct author_name from authors where author_type='72' and author_name like '".addslashes($start)."%' $restrict order by 1 limit 20"; |
---|
211 | $origine = "SQL" ; |
---|
212 | break; |
---|
213 | case 'collectivite_name': |
---|
214 | if ($autexclude) $restrict = " AND author_id not in ($autexclude) "; |
---|
215 | $requete="select distinct author_name from authors where author_type='71' and author_name like '".addslashes($start)."%' $restrict order by 1 limit 20"; |
---|
216 | $origine = "SQL" ; |
---|
217 | break; |
---|
218 | case 'publishers': |
---|
219 | if ($autexclude) $restrict = " AND ed_id not in ($autexclude) "; |
---|
220 | $requete="select concat( |
---|
221 | ed_name, |
---|
222 | if((ed_ville is not null and ed_ville!='') or (ed_pays is not null and ed_pays!=''),' (',''), |
---|
223 | if(ed_ville is not null and ed_ville!='',ed_ville,''), |
---|
224 | if(ed_ville is not null and ed_ville!='' and ed_pays is not null and ed_pays!='',' - ',''), |
---|
225 | if(ed_pays is not null and ed_pays!='',ed_pays,''), |
---|
226 | if((ed_ville is not null and ed_ville!='') or (ed_pays is not null and ed_pays!=''),')','') |
---|
227 | ) as ed,ed_id from publishers where concat( |
---|
228 | ed_name, |
---|
229 | if((ed_ville is not null and ed_ville!='') or (ed_pays is not null and ed_pays!=''),' (',''), |
---|
230 | if(ed_ville is not null and ed_ville!='',ed_ville,''), |
---|
231 | if(ed_ville is not null and ed_ville!='' and ed_pays is not null and ed_pays!='',' - ',''), |
---|
232 | if(ed_pays is not null and ed_pays!='',ed_pays,''), |
---|
233 | if((ed_ville is not null and ed_ville!='') or (ed_pays is not null and ed_pays!=''),')','') |
---|
234 | ) like '".addslashes($start)."%' $restrict order by 1 limit 20"; |
---|
235 | $origine = "SQL" ; |
---|
236 | break; |
---|
237 | case 'titre_uniforme': |
---|
238 | if ($autexclude) $restrict = " AND tu_id not in ($autexclude) "; |
---|
239 | $requete="select tu_name as titre_uniforme,tu_id from titres_uniformes where tu_name like '".addslashes($start)."%' $restrict order by 1 limit 20"; |
---|
240 | $origine = "SQL" ; |
---|
241 | break; |
---|
242 | case 'collections': |
---|
243 | if ($autexclude) $restrict = " AND collection_id not in ($autexclude) "; |
---|
244 | if ($linkfield) $restrict .= " AND collection_parent ='$linkfield' "; |
---|
245 | $requete="select if(collection_issn is not null and collection_issn!='',concat(collection_name,', ',collection_issn),collection_name) as coll,collection_id from collections where if(collection_issn is not null and collection_issn!='',concat(collection_name,', ',collection_issn),collection_name) like '".addslashes($start)."%' $restrict order by index_coll limit 20"; |
---|
246 | $origine = "SQL" ; |
---|
247 | break; |
---|
248 | case 'subcollections': |
---|
249 | if ($autexclude) $restrict = " AND sub_coll_id not in ($autexclude) "; |
---|
250 | if ($linkfield) $restrict .= " AND sub_coll_parent ='$linkfield' "; |
---|
251 | $requete="select if(sub_coll_issn is not null and sub_coll_issn!='',concat(sub_coll_name,', ',sub_coll_issn),sub_coll_name) as subcoll,sub_coll_id from sub_collections where if(sub_coll_issn is not null and sub_coll_issn!='',concat(sub_coll_name,', ',sub_coll_issn),sub_coll_name) like '".addslashes($start)."%' $restrict order by 1 limit 20"; |
---|
252 | $origine = "SQL" ; |
---|
253 | break; |
---|
254 | case 'indexint': |
---|
255 | if ($autexclude) $restrict = " AND indexint_id not in ($autexclude) "; |
---|
256 | if ($thesaurus_classement_mode_pmb != 0) { //classement indexation décimale autorisé en parametrage |
---|
257 | $requete="select if(indexint_comment is not null and indexint_comment!='',concat('[',name_pclass,'] ',indexint_name,' - ',indexint_comment), |
---|
258 | concat('[',name_pclass,'] ',indexint_name)) as indexint,indexint_id |
---|
259 | from indexint,pclassement |
---|
260 | where if(name_pclass is not null and indexint_comment is not null and indexint_comment!='',concat(indexint_name,' - ',indexint_comment),indexint_name) like '".addslashes($start)."%' $restrict |
---|
261 | and id_pclass = num_pclass |
---|
262 | and typedoc like '%$typdoc%' |
---|
263 | order by indexint_name, name_pclass limit 20"; |
---|
264 | } |
---|
265 | else |
---|
266 | $requete="select if(indexint_comment is not null and indexint_comment!='',concat(indexint_name,' - ',indexint_comment),indexint_name) as indexint,indexint_id from indexint |
---|
267 | where if(indexint_comment is not null and indexint_comment!='',concat(indexint_name,' - ',indexint_comment),indexint_name) like '".addslashes($start)."%' $restrict and num_pclass = '$thesaurus_classement_defaut' order by 1 limit 20"; |
---|
268 | $origine = "SQL" ; |
---|
269 | break; |
---|
270 | case 'indexint_mul': |
---|
271 | if ($autexclude) $restrict = " AND indexint_id not in ($autexclude) "; |
---|
272 | if ($thesaurus_classement_mode_pmb != 0) { //classement indexation décimale autorisé en parametrage |
---|
273 | $requete="select if(indexint_comment is not null and indexint_comment!='',concat('[',name_pclass,'] ',indexint_name,' - ',indexint_comment), |
---|
274 | concat('[',name_pclass,'] ',indexint_name)) as indexint,indexint_id, concat( indexint_name,' ',indexint_comment) as indexsimple |
---|
275 | from indexint,pclassement |
---|
276 | where if(name_pclass is not null and indexint_comment is not null and indexint_comment!='',concat(indexint_name,' - ',indexint_comment),indexint_name) like '".addslashes($start)."%' $restrict |
---|
277 | and id_pclass = num_pclass |
---|
278 | and typedoc like '%$typdoc%' |
---|
279 | order by indexint_name, name_pclass limit 20"; |
---|
280 | } |
---|
281 | else |
---|
282 | $requete="select if(indexint_comment is not null and indexint_comment!='',concat(indexint_name,' - ',indexint_comment),indexint_name) as indexint,indexint_id, concat( indexint_name,' ',indexint_comment) as indexsimple from indexint |
---|
283 | where if(indexint_comment is not null and indexint_comment!='',concat(indexint_name,' - ',indexint_comment),indexint_name) like '".addslashes($start)."%' $restrict and num_pclass = '$thesaurus_classement_defaut' order by 1 limit 20"; |
---|
284 | $origine = "SQL" ; |
---|
285 | break; |
---|
286 | case 'notice': |
---|
287 | require_once('./includes/isbn.inc.php'); |
---|
288 | if ($autexclude) $restrict = " AND notice_id not in ($autexclude) "; |
---|
289 | $requete = "select if(serie_name is not null,if(tnvol is not null,concat(serie_name,', ',tnvol,'. ',tit1),concat(serie_name,'. ',tit1)),tit1), notice_id from notices left join series on serie_id=tparent_id where (index_sew like ' ".addslashes(strip_empty_words($start))."%' or TRIM(index_wew) like '".addslashes($start)."%' or tit1 like '".addslashes($start)."%' or (code like '".traite_code_isbn(addslashes($start))."'"; |
---|
290 | if (isISBN(traite_code_isbn($start))) { |
---|
291 | if (strlen(traite_code_isbn($start))==13) |
---|
292 | $requete.=" or code like '".formatISBN(traite_code_isbn($start),13)."'"; |
---|
293 | else $requete.=" or code like '".formatISBN(traite_code_isbn($start),10)."'"; |
---|
294 | } |
---|
295 | $requete.=")) $restrict order by index_serie, tnvol, index_sew , code limit 20 "; |
---|
296 | $origine = "SQL" ; |
---|
297 | break; |
---|
298 | case 'serie': |
---|
299 | if ($autexclude) $restrict = " AND serie_id not in ($autexclude) "; |
---|
300 | $requete="select serie_name,serie_id from series where serie_name like '".addslashes($start)."%' $restrict order by 1 limit 20"; |
---|
301 | $origine = "SQL" ; |
---|
302 | break; |
---|
303 | case 'fonction': |
---|
304 | // récupération des codes de fonction |
---|
305 | if (!count($s_func )) { |
---|
306 | $s_func = new marc_list('function'); |
---|
307 | } |
---|
308 | $origine = "TABLEAU" ; |
---|
309 | break; |
---|
310 | case 'langue': |
---|
311 | // récupération des codes de langue |
---|
312 | if (!count($s_func )) { |
---|
313 | $s_func = new marc_list('lang'); |
---|
314 | } |
---|
315 | $origine = "TABLEAU" ; |
---|
316 | break; |
---|
317 | case 'synonyms': |
---|
318 | $array_selector=array(); |
---|
319 | //recherche des mots |
---|
320 | $rqt="select id_mot, mot from mots left join linked_mots on (num_mot=id_mot) where mot like '".addslashes($start)."%' and id_mot not in (select num_mot from linked_mots where linked_mots.num_linked_mot=0) group by id_mot"; |
---|
321 | $execute_query=pmb_mysql_query($rqt); |
---|
322 | while ($r=pmb_mysql_fetch_object($execute_query)) { |
---|
323 | $array_selector[$r->id_mot]=$r->mot; |
---|
324 | } |
---|
325 | pmb_mysql_free_result($execute_query); |
---|
326 | if (count($array_selector)) { |
---|
327 | //dédoublonnage du tableau final |
---|
328 | $array_selector=array_unique($array_selector); |
---|
329 | //tri alphanumérique du tableau |
---|
330 | asort($array_selector); |
---|
331 | } |
---|
332 | $origine = "ARRAY" ; |
---|
333 | break; |
---|
334 | case 'tags': |
---|
335 | require_once("$class_path/tags.class.php"); |
---|
336 | $tags = new tags(); |
---|
337 | $array_selector = $tags->get_array($start,$pos_cursor); |
---|
338 | $taille_search = $tags->get_taille_search(); |
---|
339 | $origine = "ARRAY"; |
---|
340 | break; |
---|
341 | case 'perio': |
---|
342 | $requete = "select tit1, notice_id from notices where niveau_biblio='s' and niveau_hierar='1' and tit1 like '".addslashes($start)."%' order by 1 limit 20"; |
---|
343 | $origine = "SQL"; |
---|
344 | break; |
---|
345 | case 'bull': |
---|
346 | $link_bull = " and bulletin_notice ='".$linkfield."'"; |
---|
347 | $requete = "select bulletin_numero, bulletin_id from bulletins where (bulletin_numero like '".addslashes($start)."%' or bulletin_titre like '".addslashes($start)."%') $link_bull order by 1 limit 20"; |
---|
348 | $origine = "SQL"; |
---|
349 | break; |
---|
350 | case 'expl_cote': |
---|
351 | if($pmb_prefill_cote_ajax){ |
---|
352 | include("./catalog/expl/ajax/$pmb_prefill_cote_ajax"); |
---|
353 | $array_selector = calculer_cote($start); |
---|
354 | $origine = "ARRAY"; |
---|
355 | } |
---|
356 | break; |
---|
357 | case 'fournisseur': |
---|
358 | $requete = "select raison_sociale as lib,id_entite as id from entites where type_entite='0' "; |
---|
359 | if ($linkfield) $requete.= "and num_bibli='".$linkfield."' "; |
---|
360 | $requete.= "and raison_sociale like '".addslashes($start)."%' order by 1 limit 20"; |
---|
361 | $origine = "SQL"; |
---|
362 | break; |
---|
363 | case 'origine': |
---|
364 | $requete = "select concat(nom,' ',prenom) as lib, concat(userid,',0') as id from users where nom like '".addslashes($start)."%' "; |
---|
365 | $requete.= "union select concat(empr_nom,' ',empr_prenom), concat(id_empr,',1') from empr where empr_nom like '".addslashes($start)."%' "; |
---|
366 | $requete.= "order by 1 limit 20"; |
---|
367 | $origine = "SQL"; |
---|
368 | break; |
---|
369 | case 'rubrique': |
---|
370 | $requete = "select concat('[',budgets.libelle,']',rubriques.libelle) as lib, id_rubrique as id, rubriques.libelle as lib2 from rubriques join budgets on num_budget=id_budget where autorisations like ' %".SESSuserid."% ' "; |
---|
371 | if ($linkfield) $requete.= "and num_exercice='".$linkfield."' "; |
---|
372 | $requete.= "and rubriques.libelle like '".addslashes($start)."%' "; |
---|
373 | $requete.= "order by lib limit 20"; |
---|
374 | $origine="SQL"; |
---|
375 | break; |
---|
376 | case 'rubriques': |
---|
377 | // $param1 : id_entite |
---|
378 | // $param2 : id_exercice |
---|
379 | require_once($class_path.'/rubriques.class.php'); |
---|
380 | $array_selector=array(); |
---|
381 | $requete = "select budgets.libelle as lib_bud, rubriques.* from budgets, rubriques left join rubriques as rubriques2 on rubriques.id_rubrique=rubriques2.num_parent "; |
---|
382 | $requete.= "where budgets.statut = '1' and budgets.num_entite = '".$param1."' and budgets.num_exercice = '".$param2."' and rubriques.num_budget = budgets.id_budget and rubriques2.num_parent is NULL "; |
---|
383 | $requete.= "and rubriques.autorisations like(' %".SESSuserid."% ') "; |
---|
384 | $requete.= "and rubriques.libelle like '".addslashes($start)."%' "; |
---|
385 | $requete.= "order by budgets.libelle, rubriques.id_rubrique "; |
---|
386 | $res=pmb_mysql_query($requete); |
---|
387 | while($row = pmb_mysql_fetch_object($res)) { |
---|
388 | $tab_rub = rubriques::listAncetres($row->id_rubrique, true); |
---|
389 | $lib_rub = ''; |
---|
390 | foreach ($tab_rub as $dummykey=>$value) { |
---|
391 | $lib_rub.= htmlentities($value[1], ENT_QUOTES, $charset); |
---|
392 | if($value[0] != $row->id_rubrique) $lib_rub.= ":"; |
---|
393 | } |
---|
394 | $array_selector[$row->id_rubrique]=htmlentities($row->lib_bud, ENT_QUOTES, $charset).":".$lib_rub; |
---|
395 | } |
---|
396 | $origine="ARRAY"; |
---|
397 | break; |
---|
398 | case 'perso_notices': |
---|
399 | require_once($class_path.'/parametres_perso.class.php'); |
---|
400 | $p_perso = new parametres_perso('notices'); |
---|
401 | $array_selector=$p_perso->get_ajax_list($persofield,$start); |
---|
402 | $origine='ARRAY'; |
---|
403 | break; |
---|
404 | case 'perso_expl': |
---|
405 | require_once($class_path.'/parametres_perso.class.php'); |
---|
406 | $p_perso = new parametres_perso('notices'); |
---|
407 | $array_selector=$p_perso->get_ajax_list($persofield,$start); |
---|
408 | $origine='ARRAY'; |
---|
409 | break; |
---|
410 | case 'perso_empr': |
---|
411 | require_once($class_path.'/parametres_perso.class.php'); |
---|
412 | $p_perso = new parametres_perso('notices'); |
---|
413 | $array_selector=$p_perso->get_ajax_list($persofield,$start); |
---|
414 | $origine='ARRAY'; |
---|
415 | break; |
---|
416 | case 'perso_gestfic0': |
---|
417 | require_once($class_path.'/parametres_perso.class.php'); |
---|
418 | $p_perso = new parametres_perso('notices'); |
---|
419 | $array_selector=$p_perso->get_ajax_list($persofield,$start); |
---|
420 | $origine='ARRAY'; |
---|
421 | break; |
---|
422 | case 'perso_collstate': |
---|
423 | require_once($class_path.'/parametres_perso.class.php'); |
---|
424 | $p_perso = new parametres_perso('notices'); |
---|
425 | $array_selector=$p_perso->get_ajax_list($persofield,$start); |
---|
426 | $origine='ARRAY'; |
---|
427 | break; |
---|
428 | case 'types_produits': |
---|
429 | // $param1 : id_fournisseur |
---|
430 | $array_selector=array(); |
---|
431 | require_once($class_path.'/types_produits.class.php'); |
---|
432 | require_once($class_path.'/tva_achats.class.php'); |
---|
433 | require_once($class_path.'/offres_remises.class.php'); |
---|
434 | $q = types_produits::listTypes(); |
---|
435 | $res = pmb_mysql_query($q, $dbh); |
---|
436 | while($row=pmb_mysql_fetch_object($res)) { |
---|
437 | $typ = $row->id_produit; |
---|
438 | $lib_typ = $row->libelle; |
---|
439 | $taux_tva = new tva_achats($row->num_tva_achat); |
---|
440 | $lib_tva = htmlentities($taux_tva->taux_tva, ENT_QUOTES, $charset); |
---|
441 | $offre = new offres_remises($linkfield, $row->id_produit); |
---|
442 | if ($offre->remise) { |
---|
443 | $lib_rem = htmlentities($offre->remise, ENT_QUOTES, $charset); |
---|
444 | } else $lib_rem = '0'; |
---|
445 | $array_selector[$typ.','.$lib_rem.','.$lib_tva]=htmlentities($lib_typ, ENT_QUOTES, $charset); |
---|
446 | } |
---|
447 | $origine="ARRAY"; |
---|
448 | break; |
---|
449 | case 'fournisseurs': |
---|
450 | // $param1 : id_bibli |
---|
451 | $array_selector=array(); |
---|
452 | require_once($class_path.'/entites.class.php'); |
---|
453 | $requete = "select raison_sociale, id_entite from entites where type_entite='0' "; |
---|
454 | $requete.= "and num_bibli='".$param1."' "; |
---|
455 | $requete.= "and raison_sociale like '".addslashes($start)."%' order by 1"; |
---|
456 | $res = pmb_mysql_query($requete, $dbh); |
---|
457 | while(($row=pmb_mysql_fetch_object($res))) { |
---|
458 | $adresse=""; |
---|
459 | $idAdresse=0; |
---|
460 | $coord = entites::get_coordonnees($row->id_entite, '1'); |
---|
461 | if (pmb_mysql_num_rows($coord) != 0) { |
---|
462 | $coord = pmb_mysql_fetch_object($coord); |
---|
463 | $idAdresse=$coord->id_contact; |
---|
464 | if($coord->libelle != '') $adresse = htmlentities($coord->libelle, ENT_QUOTES, $charset)."\n"; |
---|
465 | if($coord->contact !='') $adresse.= htmlentities($coord->contact, ENT_QUOTES, $charset)."\n"; |
---|
466 | if($coord->adr1 != '') $adresse.= htmlentities($coord->adr1, ENT_QUOTES, $charset)."\n"; |
---|
467 | if($coord->adr2 != '') $adresse.= htmlentities($coord->adr2, ENT_QUOTES, $charset)."\n"; |
---|
468 | if($coord->cp !='') $adresse.= htmlentities($coord->cp, ENT_QUOTES, $charset).' '; |
---|
469 | if($coord->ville != '') $adresse.= htmlentities($coord->ville, ENT_QUOTES, $charset); |
---|
470 | } |
---|
471 | $array_selector[$row->id_entite.','.$idAdresse.','.$adresse]=htmlentities($row->raison_sociale, ENT_QUOTES, $charset); |
---|
472 | } |
---|
473 | $origine="ARRAY"; |
---|
474 | break; |
---|
475 | case 'onto': |
---|
476 | if(!is_object($autoloader)){ |
---|
477 | require_once($class_path."/autoloader.class.php"); |
---|
478 | $autoloader = new autoloader(); |
---|
479 | } |
---|
480 | $autoloader->add_register("onto_class",true); |
---|
481 | $onto_store_config = array( |
---|
482 | /* db */ |
---|
483 | 'db_name' => DATA_BASE, |
---|
484 | 'db_user' => USER_NAME, |
---|
485 | 'db_pwd' => USER_PASS, |
---|
486 | 'db_host' => SQL_SERVER, |
---|
487 | /* store */ |
---|
488 | 'store_name' => 'ontology', |
---|
489 | /* stop after 100 errors */ |
---|
490 | 'max_errors' => 100, |
---|
491 | 'store_strip_mb_comp_str' => 0 |
---|
492 | ); |
---|
493 | $data_store_config = array( |
---|
494 | /* db */ |
---|
495 | 'db_name' => DATA_BASE, |
---|
496 | 'db_user' => USER_NAME, |
---|
497 | 'db_pwd' => USER_PASS, |
---|
498 | 'db_host' => SQL_SERVER, |
---|
499 | /* store */ |
---|
500 | 'store_name' => 'rdfstore', |
---|
501 | /* stop after 100 errors */ |
---|
502 | 'max_errors' => 100, |
---|
503 | 'store_strip_mb_comp_str' => 0 |
---|
504 | ); |
---|
505 | $tab_namespaces=array( |
---|
506 | "skos" => "http://www.w3.org/2004/02/skos/core#", |
---|
507 | "dc" => "http://purl.org/dc/elements/1.1", |
---|
508 | "dct" => "http://purl.org/dc/terms/", |
---|
509 | "owl" => "http://www.w3.org/2002/07/owl#", |
---|
510 | "rdf" => "http://www.w3.org/1999/02/22-rdf-syntax-ns#", |
---|
511 | "rdfs" => "http://www.w3.org/2000/01/rdf-schema#", |
---|
512 | "xsd" => "http://www.w3.org/2001/XMLSchema#", |
---|
513 | "pmb" => "http://www.pmbservices.fr/ontology#" |
---|
514 | ); |
---|
515 | $params=new onto_param( |
---|
516 | array( |
---|
517 | 'autexclude' => "", |
---|
518 | 'linkfield' => "", |
---|
519 | 'autfield' => "", |
---|
520 | 'typdoc' => "", |
---|
521 | 'att_id_filter' => "", |
---|
522 | 'listfield' => "", |
---|
523 | 'callback' => "", |
---|
524 | 'datas' => "", |
---|
525 | 'action'=>'ajax_selector' |
---|
526 | ) |
---|
527 | ); |
---|
528 | |
---|
529 | $onto_ui = new onto_ui($class_path."/rdf/skos_pmb.rdf", "arc2", $onto_store_config, "arc2", $data_store_config,$tab_namespaces,'http://www.w3.org/2004/02/skos/core#prefLabel',$params); |
---|
530 | $list_results = $onto_ui->proceed(); |
---|
531 | $array_prefix = $list_results['prefix']; |
---|
532 | $array_selector = $list_results['elements']; |
---|
533 | $origine='ONTO_ARRAY'; |
---|
534 | break; |
---|
535 | |
---|
536 | case 'instruments': |
---|
537 | // $param1 : id du pupitre préféré. si 0 on retourne tous les instruments |
---|
538 | // $param2 = 0: Instruments du pupitre préféré seulement |
---|
539 | // $param2 = 1: Instruments du pupitre préféré en premier, puis les autres |
---|
540 | if ($autexclude) $restrict = " AND id_instrument not in ($autexclude) "; |
---|
541 | if(strlen($start)==$pos_cursor){ |
---|
542 | $liste_mots=explode("/",$start); |
---|
543 | $start = array_pop($liste_mots); |
---|
544 | } else { |
---|
545 | $liste_mots = explode("/",substr($start,0,$pos_cursor)); |
---|
546 | $start = array_pop($liste_mots); |
---|
547 | } |
---|
548 | |
---|
549 | if ($param1 && !$param2){ // que ceux du pupitre |
---|
550 | $restrict .= " AND instrument_musicstand_num ='$param1' "; |
---|
551 | |
---|
552 | $requete=" |
---|
553 | select if(instrument_name is not null and instrument_name!='',concat(instrument_code,' - ',instrument_name),instrument_code) as instrument_lib, id_instrument, instrument_code from nomenclature_instruments |
---|
554 | where ( instrument_code like '".addslashes($start)."%' or instrument_name like '".addslashes($start)."%' ) $restrict order by 1 limit 20"; |
---|
555 | |
---|
556 | }elseif($param1 && $param2){// que ceux du pupitre en premier, puis les autres |
---|
557 | $restrict.= " AND instrument_musicstand_num ='$param1' "; |
---|
558 | $restrict2= $restrict." AND instrument_musicstand_num !='$param1' "; |
---|
559 | |
---|
560 | $requete="( |
---|
561 | select if(instrument_name is not null and instrument_name!='',concat(instrument_code,' - ',instrument_name),instrument_code) as instrument_lib, id_instrument, instrument_code from nomenclature_instruments |
---|
562 | where ( instrument_code like '".addslashes($start)."%' or instrument_name like '".addslashes($start)."%' ) $restrict order by 1 |
---|
563 | ) |
---|
564 | union ( |
---|
565 | select if(instrument_name is not null and instrument_name!='',concat(instrument_code,' - ',instrument_name),instrument_code) as instrument_lib, id_instrument, instrument_code from nomenclature_instruments |
---|
566 | where ( instrument_code like '".addslashes($start)."%' or instrument_name like '".addslashes($start)."%' ) $restrict2 order by 1 limit 20 |
---|
567 | ) |
---|
568 | "; |
---|
569 | }else{ // tous les instruments |
---|
570 | $requete=" |
---|
571 | select if(instrument_name is not null and instrument_name!='',concat(instrument_code,' - ',instrument_name),instrument_code) as instrument_lib, id_instrument, instrument_code from nomenclature_instruments |
---|
572 | where ( instrument_code like '".addslashes($start)."%' or instrument_name like '".addslashes($start)."%' ) $restrict order by 1 limit 20"; |
---|
573 | } |
---|
574 | $insert_between_separator = "/"; |
---|
575 | $origine = "SQL" ; |
---|
576 | break; |
---|
577 | case 'voices': |
---|
578 | if ($autexclude) $restrict = " AND id_voice not in ($autexclude) "; |
---|
579 | //On récupère toutes les voix |
---|
580 | $requete=" |
---|
581 | select if(voice_name is not null and voice_name!='',concat(voice_code,' - ',voice_name),voice_code) as voice_lib, id_voice, voice_code from nomenclature_voices |
---|
582 | where ( voice_code like '".addslashes($start)."%' or voice_name like '".addslashes($start)."%' ) $restrict order by 1 limit 20"; |
---|
583 | |
---|
584 | $insert_between_separator = "/"; |
---|
585 | $origine = "SQL" ; |
---|
586 | break; |
---|
587 | default: |
---|
588 | $p=explode('_', $completion); |
---|
589 | if(count ($p)){ |
---|
590 | switch ($p[0]){ |
---|
591 | case 'authperso': |
---|
592 | require_once($class_path.'/authperso.class.php'); |
---|
593 | $authperso = new authperso($p[1]); |
---|
594 | $array_selector=$authperso->get_ajax_list($start); |
---|
595 | $origine='ARRAY'; |
---|
596 | break; |
---|
597 | } |
---|
598 | } |
---|
599 | break; |
---|
600 | endswitch; |
---|
601 | |
---|
602 | |
---|
603 | switch ($origine): |
---|
604 | case 'SQL': |
---|
605 | $resultat=pmb_mysql_query($requete) or die(pmb_mysql_error()."<br />$requete") ; |
---|
606 | $i=1; |
---|
607 | while($r=@pmb_mysql_fetch_array($resultat)) { |
---|
608 | if($r[2]) |
---|
609 | echo "<div id='"."c".$id."_".$i."' style='display:none'>$r[2]</div>"; |
---|
610 | echo "<div id='l".$id."_".$i."'"; |
---|
611 | if ($autfield) echo " autid='".$r[1]."'"; |
---|
612 | echo " style='cursor:default;font-family:arial,helvetica;font-size:10px;width:100%' onClick='if(document.getElementById(\"c".$id."_".$i."\")) ajax_set_datas(\"c".$id."_".$i."\",\"$id\",\"$insert_between_separator\"); else ajax_set_datas(\"l".$id."_".$i."\",\"$id\",\"$insert_between_separator\");'>".$r[0]."</div>"; |
---|
613 | $i++; |
---|
614 | } |
---|
615 | break; |
---|
616 | case 'TABLEAU': |
---|
617 | $i=1; |
---|
618 | while(list($index, $value) = each($s_func->table)) { |
---|
619 | if (strtolower(substr($value,0,strlen($start)))==strtolower($start)) { |
---|
620 | echo "<div id='l".$id."_".$i."'"; |
---|
621 | if ($autfield) echo " autid='".$index."'"; |
---|
622 | echo " style='cursor:default;font-family:arial,helvetica;font-size:10px;width:100%' onClick='ajax_set_datas(\"l".$id."_".$i."\",\"$id\")'>".$value."</div>"; |
---|
623 | $i++; |
---|
624 | } |
---|
625 | } |
---|
626 | break; |
---|
627 | case 'ARRAY': |
---|
628 | if (is_array($array_selector) && count($array_selector)) { |
---|
629 | $i=1; |
---|
630 | while(list($index, $value) = each($array_selector)) { |
---|
631 | $lib_liste=""; |
---|
632 | $thesaurus_lib = $array_prefix[$index]['libelle']; |
---|
633 | $thesaurus_id = $array_prefix[$index]['id']; |
---|
634 | if(is_array($value)){ |
---|
635 | foreach($value as $k=>$v){ |
---|
636 | $lib_liste = $k; |
---|
637 | echo "<div id='"."c".$id."_".$i."' style='display:none' nbcar='$taille_search'>".$v."</div>"; |
---|
638 | } |
---|
639 | } else $lib_liste=$value; |
---|
640 | echo "<div id='l".$id."_".$i."'"; |
---|
641 | if ($autfield) echo " autid='".$index."'"; |
---|
642 | if ($thesaurus_id) echo " thesid='".$thesaurus_id."'"; |
---|
643 | echo " style='cursor:default;font-family:arial,helvetica;font-size:10px;width:100%' onClick='if(document.getElementById(\"c".$id."_".$i."\")) ajax_set_datas(\"c".$id."_".$i."\",\"$id\"); else ajax_set_datas(\"l".$id."_".$i."\",\"$id\");'>".trim($thesaurus_lib." ".$lib_liste)."</div>"; |
---|
644 | $i++; |
---|
645 | } |
---|
646 | } |
---|
647 | break; |
---|
648 | case 'ONTO_ARRAY': |
---|
649 | if (is_array($array_selector) && count($array_selector)) { |
---|
650 | $i=1; |
---|
651 | while(list($index, $value) = each($array_selector)) { |
---|
652 | $lib_liste=""; |
---|
653 | $type_label = $array_prefix[$index]['libelle']; |
---|
654 | $type_uri= $array_prefix[$index]['id']; |
---|
655 | if(!$type_uri) $type_uri = $att_id_filter; |
---|
656 | if(is_array($value)){ |
---|
657 | foreach($value as $k=>$v){ |
---|
658 | $lib_liste = $k; |
---|
659 | echo "<div id='"."c".$id."_".$i."' style='display:none' nbcar='$taille_search'>".$v."</div>"; |
---|
660 | } |
---|
661 | } else $lib_liste=$value; |
---|
662 | echo "<div id='l".$id."_".$i."'"; |
---|
663 | if ($autfield) echo " autid='".$index."'"; |
---|
664 | if ($type_uri) echo " typeuri='".$type_uri."'"; |
---|
665 | echo " style='cursor:default;font-family:arial,helvetica;font-size:10px;width:100%' onClick='if(document.getElementById(\"c".$id."_".$i."\")) ajax_set_datas(\"c".$id."_".$i."\",\"$id\"); else ajax_set_datas(\"l".$id."_".$i."\",\"$id\");'>".trim($type_label." ".$lib_liste)."</div>"; |
---|
666 | $i++; |
---|
667 | } |
---|
668 | } |
---|
669 | break; |
---|
670 | default: |
---|
671 | break; |
---|
672 | endswitch; |
---|
673 | |
---|
674 | |
---|