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