[903] | 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')+'"> </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 | Element('select_organization').disabled=false; |
---|
| 376 | Element('search_for').value=""; |
---|
| 377 | Element('search_for').disabled=false; |
---|
| 378 | while(Element('select_organization').options.length > 0) { |
---|
| 379 | Element('select_organization').remove(0); |
---|
| 380 | } |
---|
| 381 | var handler_org = function(data){ |
---|
| 382 | Element('select_organization').options[0] = new Option(get_lang('all'),'all'); |
---|
| 383 | if(data == "unavalible") |
---|
| 384 | { |
---|
| 385 | Element('select_organization').disabled=true; |
---|
| 386 | Element('search_for').value="Catalog temporaly unavalible, please try later"; |
---|
| 387 | Element('search_for').disabled=true; |
---|
| 388 | |
---|
| 389 | }else{ |
---|
| 390 | if (data != null){ |
---|
| 391 | var user_organization = Element('user_organization').value; |
---|
| 392 | for(x = 0; x < data.length; x++) { |
---|
| 393 | Element('select_organization').options[x+1] = new Option(data[x].toUpperCase(),data[x]); |
---|
| 394 | if(user_organization.toUpperCase() == data[x].toUpperCase()) |
---|
| 395 | Element('select_organization').options[x+1].selected = true; |
---|
| 396 | } |
---|
| 397 | } |
---|
| 398 | } |
---|
| 399 | } |
---|
| 400 | |
---|
| 401 | cExecute ("$this.ldap_functions.get_organizations&referral=false&catalog="+Element('select_catalog').value, handler_org); |
---|
| 402 | } |
---|
| 403 | |
---|
| 404 | emQuickCatalogSearch.prototype.changeOptions = function(type){ |
---|
| 405 | |
---|
| 406 | switch(type){ |
---|
| 407 | case 'u': |
---|
| 408 | Element('list_values').style.display = 'none'; |
---|
| 409 | Element('user_values').style.display = ''; |
---|
| 410 | break; |
---|
| 411 | |
---|
| 412 | case 'l': |
---|
| 413 | Element('user_values').style.display = 'none'; |
---|
| 414 | Element('list_values').style.display = ''; |
---|
| 415 | break; |
---|
| 416 | |
---|
| 417 | case 'p': |
---|
| 418 | Element('list_personal').style.display = ''; |
---|
| 419 | Element('list_groups').style.display = 'none' |
---|
| 420 | QuickCatalogSearch.load_catalog(); |
---|
| 421 | break; |
---|
| 422 | |
---|
| 423 | case 'g': |
---|
| 424 | Element('list_personal').style.display = 'none'; |
---|
| 425 | Element('list_groups').style.display = '' |
---|
| 426 | QuickCatalogSearch.load_catalog(); |
---|
| 427 | break; |
---|
| 428 | } |
---|
| 429 | |
---|
| 430 | } |
---|
| 431 | |
---|
| 432 | emQuickCatalogSearch.prototype.addContacts = function(field) { |
---|
| 433 | |
---|
| 434 | var border_id = Element('border_id').value; |
---|
| 435 | var select = Element('user_values').style.display == 'none' ? Element('list_values') : Element('user_values'); |
---|
| 436 | if(field == "to1" || field == "cc1" || field == "cco1"){ |
---|
| 437 | field = field.substr(0,field.length - 1); |
---|
| 438 | var select = Element('list_personal').style.display == 'none' ? Element('list_groups') : Element('list_personal'); |
---|
| 439 | } |
---|
| 440 | var fieldOpener = Element(field+"_"+border_id); |
---|
| 441 | var not_selected = true; |
---|
| 442 | for (i = 0 ; i < select.length ; i++) { |
---|
| 443 | if (select.options[i].selected && select.options[i].value != '-1') { |
---|
| 444 | if(fieldOpener.value.length > 0 && (fieldOpener.value.lastIndexOf(',') != (fieldOpener.value.length -1))){ |
---|
| 445 | fieldOpener.value += ","; |
---|
| 446 | } |
---|
| 447 | fieldOpener.value += select.options[i].value + ","; |
---|
| 448 | not_selected = false; |
---|
| 449 | select.options[i].selected = false; |
---|
| 450 | } |
---|
| 451 | } |
---|
| 452 | |
---|
| 453 | if(not_selected) |
---|
| 454 | return false; |
---|
| 455 | |
---|
| 456 | if(field != 'to'){ |
---|
| 457 | a_link = Element("a_"+field+"_link_"+border_id); |
---|
| 458 | if(a_link) |
---|
| 459 | a_link.onclick(); |
---|
| 460 | } |
---|
| 461 | } |
---|
| 462 | |
---|
| 463 | emQuickCatalogSearch.prototype.searchCatalogList = function (itemSearch){ |
---|
| 464 | |
---|
| 465 | if(itemSearch && Element('search_for').value.length < 4){ |
---|
| 466 | alert(get_lang('your search argument must be longer than 4 characters.')); |
---|
| 467 | Element('search_for').focus(); |
---|
| 468 | return false; |
---|
| 469 | } |
---|
| 470 | var organization = Element('select_organization').value; |
---|
| 471 | var search = itemSearch ? Element('search_for').value : ''; |
---|
| 472 | var catalog = Element('select_catalog').value; |
---|
| 473 | var max_result = 300; |
---|
| 474 | |
---|
| 475 | var handler_searchResults = function(data){ |
---|
| 476 | Element('msg_search').style.visibility = 'hidden'; |
---|
| 477 | if(data.error){ |
---|
| 478 | alert(get_lang('More than %1 results. Please, try to refine your search.',max_result)); |
---|
| 479 | return false; |
---|
| 480 | }else if(data.users.length == 0 && data.groups.length == 0){ |
---|
| 481 | alert(get_lang('None result was found.')); |
---|
| 482 | } |
---|
| 483 | |
---|
| 484 | |
---|
| 485 | var group = Element('list_span'); |
---|
| 486 | var user = Element('user_span'); |
---|
| 487 | if(is_ie){ |
---|
| 488 | group.innerHTML = ''; |
---|
| 489 | user.innerHTML = ''; |
---|
| 490 | } |
---|
| 491 | else { |
---|
| 492 | group = Element('list_values'); |
---|
| 493 | user = Element('user_values'); |
---|
| 494 | for(var i = 0;i < group.options.length; i++) |
---|
| 495 | group.options[i--] = null; |
---|
| 496 | for(var i = 0;i < user.options.length; i++) |
---|
| 497 | user.options[i--] = null; |
---|
| 498 | } |
---|
| 499 | |
---|
| 500 | var arr = new Array(max_result); |
---|
| 501 | |
---|
| 502 | for(i = 0; data.groups && i < data.groups.length; i++) { |
---|
| 503 | // Maneiras diferentes de se montar uma tag OPTION, pois no IE o objeto Option é muito lento. |
---|
| 504 | if(is_ie) |
---|
| 505 | arr[i] = '<option value="'+'"'+data.groups[i].name+'" <'+data.groups[i].email+'>">'+data.groups[i].name+' ('+data.groups[i].email+')'+'</option>'; |
---|
| 506 | else |
---|
| 507 | group.options[i] = new Option(data.groups[i].name+' ('+data.groups[i].email+')','"'+data.groups[i].name+'" <'+data.groups[i].email+'>'); |
---|
| 508 | } |
---|
| 509 | |
---|
| 510 | |
---|
| 511 | if(is_ie) |
---|
| 512 | group.innerHTML = '<select multiple style="display:none;width:580px" size="14" id="list_values">'+ arr.join() +'</select>'; |
---|
| 513 | |
---|
| 514 | arr = new Array(max_result); |
---|
| 515 | |
---|
| 516 | for(i = 0; data.users && i < data.users.length; i++) { |
---|
| 517 | /*******************************************************************************************/ |
---|
| 518 | /* O resultado pratico do bloco de codigo a seguir eh a exibicao dos valores em tela, |
---|
| 519 | ja que vai verificar se o departamento e o email estao vazios ou nulos e a partir dai o |
---|
| 520 | resultado apresentado em tela sera exibido de maneira mais apresentavel; |
---|
| 521 | */ |
---|
| 522 | //verifica se departamento eh null ou nao; |
---|
| 523 | var department = data.users[i].department ? " - " + data.users[i].department : ""; |
---|
| 524 | //verifica se email eh null ou nao; |
---|
| 525 | var email = data.users[i].email ? data.users[i].email : ""; |
---|
| 526 | |
---|
| 527 | // Maneiras diferentes de se montar uma tag OPTION, pois no IE o objeto Option é muito lento. |
---|
| 528 | if(is_ie) |
---|
| 529 | arr[i] = '<option value="'+'"'+data.users[i].name+'" <'+email+'>">'+data.users[i].name+' ('+email+')'+department+'</option>'; |
---|
| 530 | else { |
---|
| 531 | 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; |
---|
| 532 | } |
---|
| 533 | } |
---|
| 534 | |
---|
| 535 | if(is_ie) |
---|
| 536 | user.innerHTML = '<select multiple style="width:580px" size="14" id="user_values">'+ arr.join() +'</select>'; |
---|
| 537 | |
---|
| 538 | // Display entries found. |
---|
| 539 | var type = (data.groups.length > 0 && data.users.length == 0) ? 'l' : 'u'; |
---|
| 540 | Element("type_"+type).checked = true; |
---|
| 541 | QuickCatalogSearch.changeOptions(type); |
---|
| 542 | } |
---|
| 543 | |
---|
| 544 | Element('msg_search').style.visibility = 'visible'; |
---|
| 545 | cExecute ("$this.ldap_functions.catalogsearch&max_result="+max_result+"&organization="+organization+"&search_for="+search+"&catalog="+catalog, handler_searchResults); |
---|
| 546 | } |
---|
| 547 | |
---|
| 548 | |
---|
| 549 | /* Build the Object */ |
---|
| 550 | var QuickCatalogSearch; |
---|
| 551 | QuickCatalogSearch = new emQuickCatalogSearch(); |
---|