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