1 | function emQuickCatalogSearch () |
---|
2 | { |
---|
3 | this.arrayWin = new Array(); |
---|
4 | this.el; |
---|
5 | this.cc_contacts = new Array(); |
---|
6 | this.cc_groups = new Array(); |
---|
7 | } |
---|
8 | |
---|
9 | emQuickCatalogSearch.prototype.showList = function(data, begin, end){ |
---|
10 | id = '1'; |
---|
11 | _this = this; |
---|
12 | var el = document.createElement("DIV"); |
---|
13 | el.style.visibility = "hidden"; |
---|
14 | el.style.position = "absolute"; |
---|
15 | el.style.left = "0px"; |
---|
16 | el.style.top = "0px"; |
---|
17 | el.style.width = "0px"; |
---|
18 | el.style.height = "0px"; |
---|
19 | el.id = 'window_QuickCatalogSearch'; |
---|
20 | document.body.appendChild(el); |
---|
21 | el.innerHTML = ""; |
---|
22 | |
---|
23 | if (document.getElementById('select_QuickCatalogSearch') == null){ |
---|
24 | |
---|
25 | var title_innerHTML = get_lang('Select a name') + ':'; |
---|
26 | if (data.quickSearch_only_in_userSector) |
---|
27 | title_innerHTML += "<font color='BLACK' nowrap> ("+get_lang('Showing only the results found in your organization')+".)</font>" |
---|
28 | |
---|
29 | var title = document.createElement("SPAM"); |
---|
30 | title.id = 'window_QuickCatalogSearch_title'; |
---|
31 | title.innerHTML = " <b><font color='BLUE' nowrap>"+title_innerHTML+"</font></b><br> "; |
---|
32 | el.appendChild(title); |
---|
33 | |
---|
34 | var cmb = document.createElement("SELECT"); |
---|
35 | cmb.id = "select_QuickCatalogSearch"; |
---|
36 | cmb.style.width = "685px"; |
---|
37 | cmb.size = "12"; |
---|
38 | cmb.onkeypress = function (e) |
---|
39 | { |
---|
40 | if (is_ie) |
---|
41 | { |
---|
42 | if ((window.event.keyCode) == 13) |
---|
43 | { |
---|
44 | QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end); |
---|
45 | } |
---|
46 | else if ((window.event.keyCode) == 27) |
---|
47 | { |
---|
48 | QuickCatalogSearch.close_QuickSearch_window(data.field, data.ID); |
---|
49 | } |
---|
50 | } |
---|
51 | else |
---|
52 | { |
---|
53 | if ((e.keyCode) == 13) |
---|
54 | { |
---|
55 | QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end); |
---|
56 | } |
---|
57 | else if ((e.keyCode) == 27) |
---|
58 | { |
---|
59 | QuickCatalogSearch.close_QuickSearch_window(data.field, data.ID); |
---|
60 | } |
---|
61 | } |
---|
62 | }; |
---|
63 | el.appendChild(cmb); |
---|
64 | |
---|
65 | var space = document.createElement('SPAN'); |
---|
66 | space.innerHTML = "<BR> "; |
---|
67 | el.appendChild(space); |
---|
68 | |
---|
69 | var butt = document.createElement('BUTTON'); |
---|
70 | var buttext = document.createTextNode('OK'); |
---|
71 | butt.id = "QuickCatalogSearch_button_ok"; |
---|
72 | butt.appendChild(buttext); |
---|
73 | butt.onclick = function () {QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end);}; |
---|
74 | el.appendChild(butt); |
---|
75 | |
---|
76 | var space = document.createElement('SPAN'); |
---|
77 | space.innerHTML = " "; |
---|
78 | el.appendChild(space); |
---|
79 | |
---|
80 | var butt = document.createElement('BUTTON'); |
---|
81 | butt.id = "QuickCatalogSearch_button_close"; |
---|
82 | var buttext = document.createTextNode(get_lang('Close')); |
---|
83 | butt.appendChild(buttext); |
---|
84 | butt.onclick = function () {QuickCatalogSearch.close_QuickSearch_window(data.field, data.ID);}; |
---|
85 | el.appendChild(butt); |
---|
86 | } |
---|
87 | else{ |
---|
88 | var title_innerHTML = get_lang('Select a name') + ':'; |
---|
89 | if (data.quickSearch_only_in_userSector) |
---|
90 | title_innerHTML += "<font color='BLACK' nowrap> ("+get_lang('Showing only the results found in your organization')+".)</font>" |
---|
91 | |
---|
92 | var title = Element('window_QuickCatalogSearch_title'); |
---|
93 | title.innerHTML = " <b><font color='BLUE' nowrap>"+title_innerHTML+"</font></b><br> "; |
---|
94 | |
---|
95 | var cmb = document.getElementById('select_QuickCatalogSearch'); |
---|
96 | cmb.onkeypress = function (e) |
---|
97 | { |
---|
98 | if (is_ie) |
---|
99 | { |
---|
100 | if ((window.event.keyCode) == 13) |
---|
101 | { |
---|
102 | QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end); |
---|
103 | } |
---|
104 | else if ((window.event.keyCode) == 27) |
---|
105 | { |
---|
106 | QuickCatalogSearch.close_QuickSearch_window(data.field, data.ID); |
---|
107 | } |
---|
108 | } |
---|
109 | else |
---|
110 | { |
---|
111 | if ((e.keyCode) == 13) |
---|
112 | { |
---|
113 | QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end); |
---|
114 | } |
---|
115 | else if ((e.keyCode) == 27) |
---|
116 | { |
---|
117 | QuickCatalogSearch.close_QuickSearch_window(data.field, data.ID); |
---|
118 | } |
---|
119 | } |
---|
120 | }; |
---|
121 | |
---|
122 | for (i=0; i<cmb.length; i++) |
---|
123 | cmb.options[i--] = null; |
---|
124 | |
---|
125 | var butt_ok = document.getElementById("QuickCatalogSearch_button_ok"); |
---|
126 | var butt_close = document.getElementById("QuickCatalogSearch_button_close"); |
---|
127 | butt_ok.onclick = function () {QuickCatalogSearch.transfer_result(data.field, data.ID, begin, end);}; |
---|
128 | butt_close.onclick = function () {QuickCatalogSearch.close_QuickSearch_window(data.field, data.ID);}; |
---|
129 | } |
---|
130 | |
---|
131 | for (i=0; i<data.length; i++){ |
---|
132 | var Op = document.createElement("OPTION"); |
---|
133 | Op.text = data[i].cn + ' (' + data[i].mail + ')'; |
---|
134 | if (data[i].phone != '') |
---|
135 | Op.text += ' - ' + data[i].phone; |
---|
136 | if (data[i].ou != '') |
---|
137 | Op.text += ' - ' + data[i].ou; // adicionado "data[i].ou" para exibir setor (F9) |
---|
138 | Op.value = '"' + data[i].cn + '" ' + '<' + data[i].mail + '>'; |
---|
139 | cmb.options.add(Op); |
---|
140 | } |
---|
141 | cmb.options[0].selected = true; |
---|
142 | _this.showWindow(el); |
---|
143 | } |
---|
144 | |
---|
145 | emQuickCatalogSearch.prototype.showWindow = function (div) |
---|
146 | { |
---|
147 | if(! div) { |
---|
148 | alert(get_lang('The list has no participant.')); |
---|
149 | return; |
---|
150 | } |
---|
151 | |
---|
152 | if(! this.arrayWin[div.id]) { |
---|
153 | div.style.width = "700px"; |
---|
154 | div.style.height = "230px"; |
---|
155 | var title = get_lang('The results were found in the Global Catalog')+':'; |
---|
156 | var wHeight = div.offsetHeight + "px"; |
---|
157 | var wWidth = div.offsetWidth + "px"; |
---|
158 | div.style.width = div.offsetWidth - 5; |
---|
159 | |
---|
160 | win = new dJSWin({ |
---|
161 | id: 'QuickCatalogSearch_'+div.id, |
---|
162 | content_id: div.id, |
---|
163 | width: wWidth, |
---|
164 | height: wHeight, |
---|
165 | title_color: '#3978d6', |
---|
166 | bg_color: '#eee', |
---|
167 | title: title, |
---|
168 | title_text_color: 'white', |
---|
169 | button_x_img: '../phpgwapi/images/winclose.gif', |
---|
170 | border: true }); |
---|
171 | |
---|
172 | this.arrayWin[div.id] = win; |
---|
173 | win.draw(); |
---|
174 | } |
---|
175 | else { |
---|
176 | win = this.arrayWin[div.id]; |
---|
177 | } |
---|
178 | //document.getElementById('QuickCatalogSearch_window_QuickCatalogSearch').style.display = ""; |
---|
179 | win.open(); |
---|
180 | document.getElementById('select_QuickCatalogSearch').focus(); |
---|
181 | } |
---|
182 | |
---|
183 | emQuickCatalogSearch.prototype.transfer_result = function (field, ID, begin, end){ |
---|
184 | cm = document.getElementById('select_QuickCatalogSearch'); |
---|
185 | option_selected = cm.options[cm.selectedIndex].value + ", "; |
---|
186 | emailList = document.getElementById(field + "_" + ID).value; |
---|
187 | |
---|
188 | new_emailList = emailList.substring(0, begin) + option_selected + emailList.substring((parseInt(end) + 2), emailList.length); |
---|
189 | document.getElementById(field + "_" + ID).value = new_emailList; |
---|
190 | document.getElementById(field + "_" + ID).focus(); |
---|
191 | |
---|
192 | //document.getElementById('QuickCatalogSearch_window_QuickCatalogSearch').style.display = "none"; |
---|
193 | this.arrayWin['window_QuickCatalogSearch'].close(); |
---|
194 | } |
---|
195 | |
---|
196 | emQuickCatalogSearch.prototype.close_QuickSearch_window = function (field, ID){ |
---|
197 | //document.getElementById('QuickCatalogSearch_window_QuickCatalogSearch').style.display = "none"; |
---|
198 | document.getElementById(field + "_" + ID).focus(); |
---|
199 | this.arrayWin['window_QuickCatalogSearch'].close(); |
---|
200 | } |
---|
201 | |
---|
202 | emQuickCatalogSearch.prototype.close_window = function(id) { |
---|
203 | this.arrayWin[id].close(); |
---|
204 | var group_values = Element('list_values'); |
---|
205 | var user_values = Element('user_values'); |
---|
206 | } |
---|
207 | emQuickCatalogSearch.prototype.showCatalogList = function (border_id){ |
---|
208 | var el = Element('catalog_list'); |
---|
209 | |
---|
210 | if(el) { |
---|
211 | Element('border_id').value = border_id; |
---|
212 | win = this.arrayWin[el.id]; |
---|
213 | win.open(); |
---|
214 | return; |
---|
215 | } |
---|
216 | var border_input = document.createElement("INPUT"); |
---|
217 | border_input.type = 'hidden'; |
---|
218 | border_input.id = 'border_id'; |
---|
219 | border_input.value = border_id; |
---|
220 | document.body.appendChild(border_input); |
---|
221 | el = document.createElement("DIV"); |
---|
222 | el.id = 'catalog_list'; |
---|
223 | document.body.appendChild(el); |
---|
224 | el.style.visibility = "hidden"; |
---|
225 | el.style.position = "absolute"; |
---|
226 | el.style.width = "700px"; |
---|
227 | el.style.height = is_ie ? "360px" : "375px"; |
---|
228 | el.style.left = "0px"; |
---|
229 | el.style.top = "0px"; |
---|
230 | el.innerHTML = "<table border='0' cellpading='0' cellspacing='0' width='100%'>"+ |
---|
231 | "<tr><td id='td1' style='cursor:pointer' align='center' onclick='QuickCatalogSearch.select_div(\"tab1\")'><a href='#' class='catalog' onclick='QuickCatalogSearch.select_div(\"tab1\");'>"+get_lang('Global Catalog')+"</a></td>"+ |
---|
232 | "<td id='td2' style='background:#cecece;cursor:pointer' onclick='QuickCatalogSearch.select_div(\"tab2\")' align='center'><a href='#' class='catalog' onclick='QuickCatalogSearch.select_div(\"tab2\");'>"+get_lang('Personal Catalog')+"</a></td></tr>"+ |
---|
233 | '</table>'+ |
---|
234 | '<div id="tab1" align="center"><br>'+ |
---|
235 | '<table border="0" cellpading="0" cellspacing="0">'+ |
---|
236 | '<tr><td>'+get_lang("Select an organization and click on button <b>Search</b>")+' :</td></tr>'+ |
---|
237 | '<tr><td><select style="display:none;width:150px" id="select_catalog" name="select_catalog" onchange="javascript:QuickCatalogSearch.update_organizations();"></select> '+ |
---|
238 | '<select id="select_organization" style="width:150px" name="select_organization"></select> '+ |
---|
239 | '<input type="text" id="search_for" name="search_for" value="" size="30" maxlength="30"/> <input type="button" onclick="QuickCatalogSearch.searchCatalogList(true)" class="button" value="'+get_lang('Search')+'"> <input style="display:visible" type="button" onclick="QuickCatalogSearch.searchCatalogList(false)" class="button" value="'+get_lang('List All')+'"></td></tr>'+ |
---|
240 | '<tr><td><input onclick="javascript:QuickCatalogSearch.changeOptions(this.value)" id="type_l" type="radio" name="type" value="l"/>'+get_lang('Public Lists')+' <input type="radio" id="type_u" name="type" value="u" onclick="javascript:QuickCatalogSearch.changeOptions(this.value)" checked/>'+get_lang('Users')+' '+ |
---|
241 | '<span style="visibility:hidden;background:#cc4444" id=msg_search> <font face="Verdana" size="1" color="WHITE">'+get_lang('Search in Catalog')+'...</font> </span></td></tr>'+ |
---|
242 | '<tr><td>'+ |
---|
243 | '<span id="list_span"><select multiple style="display:none;width:580px" size="14" id="list_values"></select></span>'+ |
---|
244 | '<span id="user_span"><select multiple style="width:580px" size="14" id="user_values"></select></span>'+ |
---|
245 | '</td></tr>'+ |
---|
246 | '<tr><td nowrap><center>'+get_lang('Click here to add into the fields')+': <input type="button" class="button" value="'+get_lang('TO')+'" onClick="javascript:QuickCatalogSearch.addContacts(\'to\')"> '+ |
---|
247 | '<input type="button" class="button" value="'+get_lang('CC')+'" onClick="javascript:QuickCatalogSearch.addContacts(\'cc\')"> '+ |
---|
248 | '<input type="button" class="button" value="'+get_lang('CCo')+'" onClick="javascript:QuickCatalogSearch.addContacts(\'cco\')">'+ |
---|
249 | '</center></td></tr><tr><td nowrap><center><input type="button" value="'+get_lang('Close')+'" onClick="javascript:QuickCatalogSearch.close_window(\'catalog_list\')"></center></td></tr>'+ |
---|
250 | '</table>'+ |
---|
251 | '</div>'+ |
---|
252 | '<div style="display:none" id="tab2" align="center">'+ |
---|
253 | '<br><br><br>'+ |
---|
254 | '<table border="0" cellpading="0" cellspacing="0">'+ |
---|
255 | '<tr><td>'+get_lang("Select the type of contact that you want to view")+' :</td></tr>'+ |
---|
256 | '<tr><td><input onclick="javascript:QuickCatalogSearch.changeOptions(this.value)" type="radio" name="type" value="p"/>' + get_lang('People') + ' <input type="radio" name="type" value="g" onclick="javascript:QuickCatalogSearch.changeOptions(this.value)"/>' + get_lang('Groups') + ' '+ |
---|
257 | '<tr><td>'+ |
---|
258 | '<span id="personal_span"><select multiple style="width:580px" size="14" id="list_personal"></select></span>'+ |
---|
259 | '<span id="groups_span"><select multiple style="display:none;width:580px" size="14" id="list_groups"></select></span>'+ |
---|
260 | '</td></tr>'+ |
---|
261 | '<tr><td nowrap><center>'+get_lang('Click here to add into the fields')+': <input type="button" class="button" value="'+get_lang('TO')+'" onClick="javascript:QuickCatalogSearch.addContacts(\'to1\')"> '+ |
---|
262 | '<input type="button" class="button" value="'+get_lang('CC')+'" onClick="javascript:QuickCatalogSearch.addContacts(\'cc1\')"> '+ |
---|
263 | '<input type="button" class="button" value="'+get_lang('CCo')+'" onClick="javascript:QuickCatalogSearch.addContacts(\'cco1\')">'+ |
---|
264 | '</center></td></tr><tr><td nowrap><center><input type="button" value="'+get_lang('Close')+'" onClick="javascript:QuickCatalogSearch.close_window(\'catalog_list\')"></center></td></tr>'+ |
---|
265 | '</table>'+ |
---|
266 | '</div>'; |
---|
267 | |
---|
268 | var title = get_lang('Search in the Global Catalog'); |
---|
269 | var wHeight = el.offsetHeight - (is_ie ? 10 : 0) + "px"; |
---|
270 | var wWidth = el.offsetWidth + "px"; |
---|
271 | el.style.width = el.offsetWidth; |
---|
272 | |
---|
273 | Element('search_for').onkeypress = function (e) { |
---|
274 | if ((is_ie && (window.event.keyCode == 13)) || (!is_ie && e.keyCode == 13)) { |
---|
275 | QuickCatalogSearch.searchCatalogList(true); |
---|
276 | } |
---|
277 | }; |
---|
278 | |
---|
279 | win = new dJSWin({ |
---|
280 | id: 'win_'+el.id, |
---|
281 | content_id: el.id, |
---|
282 | width: wWidth, |
---|
283 | height: wHeight, |
---|
284 | title_color: '#3978d6', |
---|
285 | bg_color: '#eee', |
---|
286 | title: title, |
---|
287 | title_text_color: 'white', |
---|
288 | button_x_img: '../phpgwapi/images/winclose.gif', |
---|
289 | border: true }); |
---|
290 | |
---|
291 | this.arrayWin[el.id] = win; |
---|
292 | win.draw(); |
---|
293 | win.open(); |
---|
294 | |
---|
295 | var handler_catalogs = function(data){ |
---|
296 | var user_catalog = get_lang("Global Catalog"); |
---|
297 | if(data.length > 1) { |
---|
298 | Element('select_catalog').style.display = ''; |
---|
299 | for(i = 0; i < data.length; i++) { |
---|
300 | Element('select_catalog').options[i] = new Option(data[i],i); |
---|
301 | if(user_catalog.toUpperCase() == data[i].toUpperCase()) |
---|
302 | Element('select_catalog').options[i].selected = true; |
---|
303 | } |
---|
304 | } |
---|
305 | } |
---|
306 | cExecute ("$this.ldap_functions.get_catalogs", handler_catalogs); |
---|
307 | |
---|
308 | this.update_organizations(); |
---|
309 | var handler_cc_contacts= function(data){ |
---|
310 | if(data && data.length > 0){ |
---|
311 | var aux = data.split(","); |
---|
312 | for(var i=0; i< aux.length; i++){ |
---|
313 | QuickCatalogSearch.cc_contacts[QuickCatalogSearch.cc_contacts.length] = aux[i]; |
---|
314 | } |
---|
315 | } |
---|
316 | } |
---|
317 | cExecute("$this.db_functions.get_cc_contacts",handler_cc_contacts); |
---|
318 | |
---|
319 | var handler_cc_groups = function(data){ |
---|
320 | if(data && data.length > 0){ |
---|
321 | var aux = data.split(","); |
---|
322 | for(var i=0; i < data.length; i++){ |
---|
323 | QuickCatalogSearch.cc_groups[QuickCatalogSearch.cc_groups.length] = aux[i]; |
---|
324 | } |
---|
325 | } |
---|
326 | } |
---|
327 | cExecute("$this.db_functions.get_cc_groups",handler_cc_groups); |
---|
328 | |
---|
329 | } |
---|
330 | |
---|
331 | emQuickCatalogSearch.prototype.select_div = function(element){ |
---|
332 | if(element == 'tab1'){ |
---|
333 | Element('tab1').style.display = ''; |
---|
334 | Element('tab2').style.display = 'none'; |
---|
335 | Element('td1').style.background = '#eee'; |
---|
336 | Element('td2').style.background = '#cecece'; |
---|
337 | } |
---|
338 | if(element == 'tab2'){ |
---|
339 | Element('tab1').style.display = 'none'; |
---|
340 | Element('tab2').style.display = ''; |
---|
341 | Element('td1').style.background = '#cecece'; |
---|
342 | Element('td2').style.background = '#eee'; |
---|
343 | |
---|
344 | } |
---|
345 | } |
---|
346 | |
---|
347 | emQuickCatalogSearch.prototype.load_catalog = function(){ |
---|
348 | |
---|
349 | var _this = this; |
---|
350 | var content = new Array; |
---|
351 | var select = Element('list_personal').style.display == 'none'? Element('list_groups'): Element('list_personal'); |
---|
352 | |
---|
353 | if(Element('list_personal').style.display == 'none'){ |
---|
354 | content = _this.cc_groups; |
---|
355 | }else{ |
---|
356 | content = _this.cc_contacts; |
---|
357 | } |
---|
358 | if(select.options.length > 0){ |
---|
359 | for(var i=0; i < select.options.length; i++){ |
---|
360 | select.options[i] = null; |
---|
361 | i--; |
---|
362 | } |
---|
363 | } |
---|
364 | for(var i=0; i < content.length; i++){ |
---|
365 | if(content[i] != undefined){ |
---|
366 | var aux = content[i].split(";"); |
---|
367 | var opt = new Option(aux[0] + ' (' + aux[1] + ')','"' + aux[0] + '" ' + '<' + aux[1] + '>',false,false); |
---|
368 | select[select.length] = opt; |
---|
369 | } |
---|
370 | } |
---|
371 | content.splice(0,(content.lenght)); |
---|
372 | } |
---|
373 | |
---|
374 | emQuickCatalogSearch.prototype.update_organizations = function(){ |
---|
375 | while(Element('select_organization').options.length > 0) { |
---|
376 | Element('select_organization').remove(0); |
---|
377 | } |
---|
378 | var handler_org = function(data){ |
---|
379 | Element('select_organization').options[0] = new Option(get_lang('all'),'all'); |
---|
380 | if (data != null){ |
---|
381 | var user_organization = Element('user_organization').value; |
---|
382 | for(x = 0; x < data.length; x++) { |
---|
383 | Element('select_organization').options[x+1] = new Option(data[x].toUpperCase(),data[x]); |
---|
384 | if(user_organization.toUpperCase() == data[x].toUpperCase()) |
---|
385 | Element('select_organization').options[x+1].selected = true; |
---|
386 | } |
---|
387 | } |
---|
388 | } |
---|
389 | cExecute ("$this.ldap_functions.get_organizations&referral=false&catalog="+Element('select_catalog').value, handler_org); |
---|
390 | } |
---|
391 | |
---|
392 | emQuickCatalogSearch.prototype.changeOptions = function(type){ |
---|
393 | |
---|
394 | switch(type){ |
---|
395 | case 'u': |
---|
396 | Element('list_values').style.display = 'none'; |
---|
397 | Element('user_values').style.display = ''; |
---|
398 | break; |
---|
399 | |
---|
400 | case 'l': |
---|
401 | Element('user_values').style.display = 'none'; |
---|
402 | Element('list_values').style.display = ''; |
---|
403 | break; |
---|
404 | |
---|
405 | case 'p': |
---|
406 | Element('list_personal').style.display = ''; |
---|
407 | Element('list_groups').style.display = 'none' |
---|
408 | QuickCatalogSearch.load_catalog(); |
---|
409 | break; |
---|
410 | |
---|
411 | case 'g': |
---|
412 | Element('list_personal').style.display = 'none'; |
---|
413 | Element('list_groups').style.display = '' |
---|
414 | QuickCatalogSearch.load_catalog(); |
---|
415 | break; |
---|
416 | } |
---|
417 | |
---|
418 | } |
---|
419 | |
---|
420 | emQuickCatalogSearch.prototype.addContacts = function(field) { |
---|
421 | |
---|
422 | var border_id = Element('border_id').value; |
---|
423 | var select = Element('user_values').style.display == 'none' ? Element('list_values') : Element('user_values'); |
---|
424 | if(field == "to1" || field == "cc1" || field == "cco1"){ |
---|
425 | field = field.substr(0,field.length - 1); |
---|
426 | var select = Element('list_personal').style.display == 'none' ? Element('list_groups') : Element('list_personal'); |
---|
427 | } |
---|
428 | var fieldOpener = Element(field+"_"+border_id); |
---|
429 | var not_selected = true; |
---|
430 | for (i = 0 ; i < select.length ; i++) { |
---|
431 | if (select.options[i].selected && select.options[i].value != '-1') { |
---|
432 | if(fieldOpener.value.length > 0 && (fieldOpener.value.lastIndexOf(',') != (fieldOpener.value.length -1))){ |
---|
433 | fieldOpener.value += ","; |
---|
434 | } |
---|
435 | fieldOpener.value += select.options[i].value + ","; |
---|
436 | not_selected = false; |
---|
437 | select.options[i].selected = false; |
---|
438 | } |
---|
439 | } |
---|
440 | |
---|
441 | if(not_selected) |
---|
442 | return false; |
---|
443 | |
---|
444 | if(field != 'to'){ |
---|
445 | a_link = Element("a_"+field+"_link_"+border_id); |
---|
446 | if(a_link) |
---|
447 | a_link.onclick(); |
---|
448 | } |
---|
449 | } |
---|
450 | |
---|
451 | emQuickCatalogSearch.prototype.searchCatalogList = function (itemSearch){ |
---|
452 | |
---|
453 | if(itemSearch && Element('search_for').value.length < 4){ |
---|
454 | alert(get_lang('your search argument must be longer than 4 characters.')); |
---|
455 | Element('search_for').focus(); |
---|
456 | return false; |
---|
457 | } |
---|
458 | var organization = Element('select_organization').value; |
---|
459 | var search = itemSearch ? Element('search_for').value : ''; |
---|
460 | var catalog = Element('select_catalog').value; |
---|
461 | var max_result = 400; |
---|
462 | |
---|
463 | var handler_searchResults = function(data){ |
---|
464 | Element('msg_search').style.visibility = 'hidden'; |
---|
465 | if(data.error){ |
---|
466 | alert(get_lang('More than %1 results. Please, try to refine your search.',max_result)); |
---|
467 | return false; |
---|
468 | }else if(data.users.length == 0 && data.groups.length == 0){ |
---|
469 | alert(get_lang('None result was found.')); |
---|
470 | } |
---|
471 | |
---|
472 | |
---|
473 | var group = Element('list_span'); |
---|
474 | var user = Element('user_span'); |
---|
475 | if(is_ie){ |
---|
476 | group.innerHTML = ''; |
---|
477 | user.innerHTML = ''; |
---|
478 | } |
---|
479 | else { |
---|
480 | group = Element('list_values'); |
---|
481 | user = Element('user_values'); |
---|
482 | for(var i = 0;i < group.options.length; i++) |
---|
483 | group.options[i--] = null; |
---|
484 | for(var i = 0;i < user.options.length; i++) |
---|
485 | user.options[i--] = null; |
---|
486 | } |
---|
487 | |
---|
488 | var arr = new Array(max_result); |
---|
489 | |
---|
490 | for(i = 0; data.groups && i < data.groups.length; i++) { |
---|
491 | // Maneiras diferentes de se montar uma tag OPTION, pois no IE o objeto Option é muito lento. |
---|
492 | if(is_ie) |
---|
493 | arr[i] = '<option value="'+'"'+data.groups[i].name+'" <'+data.groups[i].email+'>">'+data.groups[i].name+' ('+data.groups[i].email+')'+'</option>'; |
---|
494 | else |
---|
495 | group.options[i] = new Option(data.groups[i].name+' ('+data.groups[i].email+')','"'+data.groups[i].name+'" <'+data.groups[i].email+'>'); |
---|
496 | } |
---|
497 | |
---|
498 | |
---|
499 | if(is_ie) |
---|
500 | group.innerHTML = '<select multiple style="display:none;width:580px" size="14" id="list_values">'+ arr.join() +'</select>'; |
---|
501 | |
---|
502 | arr = new Array(max_result); |
---|
503 | |
---|
504 | for(i = 0; data.users && i < data.users.length; i++) { |
---|
505 | /*******************************************************************************************/ |
---|
506 | /* O resultado pratico do bloco de codigo a seguir eh a exibicao dos valores em tela, |
---|
507 | ja que vai verificar se o departamento e o email estao vazios ou nulos e a partir dai o |
---|
508 | resultado apresentado em tela sera exibido de maneira mais apresentavel; |
---|
509 | */ |
---|
510 | //verifica se departamento eh null ou nao; |
---|
511 | var department = data.users[i].department ? " - " + data.users[i].department : ""; |
---|
512 | //verifica se email eh null ou nao; |
---|
513 | var email = data.users[i].email ? data.users[i].email : ""; |
---|
514 | |
---|
515 | // Maneiras diferentes de se montar uma tag OPTION, pois no IE o objeto Option é muito lento. |
---|
516 | if(is_ie) |
---|
517 | arr[i] = '<option value="'+'"'+data.users[i].name+'" <'+email+'>">'+data.users[i].name+' ('+email+')'+department+'</option>'; |
---|
518 | else { |
---|
519 | user.options[i] = new Option(data.users[i].name+' ('+email+')'+department,'"'+data.users[i].name+'" <'+email+'>'); // incluido data.users[i].department para exibir setor na opcao "Pesquisar" do email; |
---|
520 | } |
---|
521 | } |
---|
522 | |
---|
523 | if(is_ie) |
---|
524 | user.innerHTML = '<select multiple style="width:580px" size="14" id="user_values">'+ arr.join() +'</select>'; |
---|
525 | |
---|
526 | // Display entries found. |
---|
527 | var type = (data.groups.length > 0 && data.users.length == 0) ? 'l' : 'u'; |
---|
528 | Element("type_"+type).checked = true; |
---|
529 | QuickCatalogSearch.changeOptions(type); |
---|
530 | } |
---|
531 | |
---|
532 | Element('msg_search').style.visibility = 'visible'; |
---|
533 | cExecute ("$this.ldap_functions.catalogsearch&max_result="+max_result+"&organization="+organization+"&search_for="+search+"&catalog="+catalog, handler_searchResults); |
---|
534 | } |
---|
535 | |
---|
536 | |
---|
537 | /* Build the Object */ |
---|
538 | var QuickCatalogSearch; |
---|
539 | QuickCatalogSearch = new emQuickCatalogSearch(); |
---|