[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"; |
---|
| 37 | cmb.style.width = "585px"; |
---|
| 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 != '') |
---|
| 136 | Op.text += ' (tel: ' + data[i].phone + ')'; |
---|
| 137 | Op.value = '"' + data[i].cn + '" ' + '<' + data[i].mail + '>'; |
---|
| 138 | cmb.options.add(Op); |
---|
| 139 | } |
---|
| 140 | cmb.options[0].selected = true; |
---|
| 141 | _this.showWindow(el); |
---|
| 142 | } |
---|
| 143 | |
---|
| 144 | emQuickCatalogSearch.prototype.showWindow = function (div) |
---|
| 145 | { |
---|
| 146 | if(! div) { |
---|
| 147 | alert(get_lang('The list has no participant.')); |
---|
| 148 | return; |
---|
| 149 | } |
---|
| 150 | |
---|
| 151 | if(! this.arrayWin[div.id]) { |
---|
| 152 | div.style.width = "600px"; |
---|
[95] | 153 | div.style.height = "230px"; |
---|
[2] | 154 | var title = get_lang('The results were found in the Global Catalog')+':'; |
---|
| 155 | var wHeight = div.offsetHeight + "px"; |
---|
| 156 | var wWidth = div.offsetWidth + "px"; |
---|
| 157 | div.style.width = div.offsetWidth - 5; |
---|
| 158 | |
---|
| 159 | win = new dJSWin({ |
---|
| 160 | id: 'QuickCatalogSearch_'+div.id, |
---|
| 161 | content_id: div.id, |
---|
| 162 | width: wWidth, |
---|
| 163 | height: wHeight, |
---|
| 164 | title_color: '#3978d6', |
---|
| 165 | bg_color: '#eee', |
---|
| 166 | title: title, |
---|
| 167 | title_text_color: 'white', |
---|
| 168 | button_x_img: '../phpgwapi/images/winclose.gif', |
---|
| 169 | border: true }); |
---|
| 170 | |
---|
| 171 | this.arrayWin[div.id] = win; |
---|
| 172 | win.draw(); |
---|
| 173 | } |
---|
| 174 | else { |
---|
| 175 | win = this.arrayWin[div.id]; |
---|
| 176 | } |
---|
| 177 | //document.getElementById('QuickCatalogSearch_window_QuickCatalogSearch').style.display = ""; |
---|
| 178 | win.open(); |
---|
| 179 | document.getElementById('select_QuickCatalogSearch').focus(); |
---|
| 180 | } |
---|
| 181 | |
---|
| 182 | emQuickCatalogSearch.prototype.transfer_result = function (field, ID, begin, end){ |
---|
| 183 | cm = document.getElementById('select_QuickCatalogSearch'); |
---|
| 184 | option_selected = cm.options[cm.selectedIndex].value + ", "; |
---|
| 185 | emailList = document.getElementById(field + "_" + ID).value; |
---|
| 186 | |
---|
| 187 | new_emailList = emailList.substring(0, begin) + option_selected + emailList.substring((parseInt(end) + 2), emailList.length); |
---|
| 188 | document.getElementById(field + "_" + ID).value = new_emailList; |
---|
| 189 | document.getElementById(field + "_" + ID).focus(); |
---|
| 190 | |
---|
| 191 | //document.getElementById('QuickCatalogSearch_window_QuickCatalogSearch').style.display = "none"; |
---|
| 192 | this.arrayWin['window_QuickCatalogSearch'].close(); |
---|
| 193 | } |
---|
| 194 | |
---|
| 195 | emQuickCatalogSearch.prototype.close_QuickSearch_window = function (field, ID){ |
---|
| 196 | //document.getElementById('QuickCatalogSearch_window_QuickCatalogSearch').style.display = "none"; |
---|
| 197 | document.getElementById(field + "_" + ID).focus(); |
---|
| 198 | this.arrayWin['window_QuickCatalogSearch'].close(); |
---|
| 199 | } |
---|
| 200 | |
---|
| 201 | emQuickCatalogSearch.prototype.close_window = function(id) { |
---|
| 202 | this.arrayWin[id].close(); |
---|
| 203 | var group_values = Element('list_values'); |
---|
| 204 | var user_values = Element('user_values'); |
---|
| 205 | } |
---|
| 206 | emQuickCatalogSearch.prototype.showCatalogList = function (border_id){ |
---|
| 207 | var el = Element('catalog_list'); |
---|
| 208 | |
---|
| 209 | if(el) { |
---|
| 210 | Element('border_id').value = border_id; |
---|
| 211 | win = this.arrayWin[el.id]; |
---|
| 212 | win.open(); |
---|
| 213 | return; |
---|
| 214 | } |
---|
| 215 | var border_input = document.createElement("INPUT"); |
---|
| 216 | border_input.type = 'hidden'; |
---|
| 217 | border_input.id = 'border_id'; |
---|
| 218 | border_input.value = border_id; |
---|
| 219 | document.body.appendChild(border_input); |
---|
| 220 | el = document.createElement("DIV"); |
---|
| 221 | el.id = 'catalog_list'; |
---|
| 222 | document.body.appendChild(el); |
---|
| 223 | el.style.visibility = "hidden"; |
---|
| 224 | el.style.position = "absolute"; |
---|
| 225 | el.style.width = "495px"; |
---|
| 226 | el.style.height = is_ie ? "360px" : "375px"; |
---|
| 227 | el.style.left = "0px"; |
---|
| 228 | el.style.top = "0px"; |
---|
| 229 | el.innerHTML = "<table border='0' cellpading='0' cellspacing='0' width='100%'>"+ |
---|
| 230 | "<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>"+ |
---|
| 231 | "<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>"+ |
---|
| 232 | '</table>'+ |
---|
| 233 | '<div id="tab1" align="center"><br>'+ |
---|
| 234 | '<table border="0" cellpading="0" cellspacing="0">'+ |
---|
| 235 | '<tr><td>'+get_lang("Select an organization and click on button <b>Search</b>")+' :</td></tr>'+ |
---|
| 236 | '<tr><td><select id="select_organization" name="select_organization"></select> '+ |
---|
| 237 | '<input type="text" id="search_for" name="search_for" value="" size="17" maxlength="20"/> <input type="button" onclick="QuickCatalogSearch.searchCatalogList(true)" class="button" value="'+get_lang('Search')+'"> <input type="button" onclick="QuickCatalogSearch.searchCatalogList(false)" class="button" value="'+get_lang('List All')+'"></td></tr>'+ |
---|
| 238 | '<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')+' '+ |
---|
| 239 | '<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>'+ |
---|
| 240 | '<tr><td>'+ |
---|
| 241 | '<span id="list_span"><select multiple style="display:none;width:400px" size="14" id="list_values"></select></span>'+ |
---|
| 242 | '<span id="user_span"><select multiple style="width:400px" size="14" id="user_values"></select></span>'+ |
---|
| 243 | '</td></tr>'+ |
---|
| 244 | '<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\')"> '+ |
---|
| 245 | '<input type="button" class="button" value="'+get_lang('CC')+'" onClick="javascript:QuickCatalogSearch.addContacts(\'cc\')"> '+ |
---|
| 246 | '<input type="button" class="button" value="'+get_lang('CCo')+'" onClick="javascript:QuickCatalogSearch.addContacts(\'cco\')">'+ |
---|
| 247 | '</center></td></tr><tr><td nowrap><center><input type="button" value="'+get_lang('Close')+'" onClick="javascript:QuickCatalogSearch.close_window(\'catalog_list\')"></center></td></tr>'+ |
---|
| 248 | '</table>'+ |
---|
| 249 | '</div>'+ |
---|
| 250 | '<div style="display:none" id="tab2" align="center">'+ |
---|
| 251 | '<br><br><br>'+ |
---|
| 252 | '<table border="0" cellpading="0" cellspacing="0">'+ |
---|
[53] | 253 | '<tr><td>'+get_lang("Select the type of contact that you want to view")+' :</td></tr>'+ |
---|
[118] | 254 | '<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] | 255 | '<tr><td>'+ |
---|
| 256 | '<span id="personal_span"><select multiple style="width:400px" size="14" id="list_personal"></select></span>'+ |
---|
| 257 | '<span id="groups_span"><select multiple style="display:none;width:400px" size="14" id="list_groups"></select></span>'+ |
---|
| 258 | '</td></tr>'+ |
---|
| 259 | '<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\')"> '+ |
---|
| 260 | '<input type="button" class="button" value="'+get_lang('CC')+'" onClick="javascript:QuickCatalogSearch.addContacts(\'cc1\')"> '+ |
---|
| 261 | '<input type="button" class="button" value="'+get_lang('CCo')+'" onClick="javascript:QuickCatalogSearch.addContacts(\'cco1\')">'+ |
---|
| 262 | '</center></td></tr><tr><td nowrap><center><input type="button" value="'+get_lang('Close')+'" onClick="javascript:QuickCatalogSearch.close_window(\'catalog_list\')"></center></td></tr>'+ |
---|
| 263 | '</table>'+ |
---|
| 264 | '</div>'; |
---|
| 265 | |
---|
| 266 | var title = get_lang('Search in the Global Catalog'); |
---|
| 267 | var wHeight = el.offsetHeight - (is_ie ? 10 : 0) + "px"; |
---|
| 268 | var wWidth = el.offsetWidth + "px"; |
---|
| 269 | el.style.width = el.offsetWidth; |
---|
| 270 | |
---|
| 271 | Element('search_for').onkeypress = function (e) { |
---|
| 272 | if ((is_ie && (window.event.keyCode == 13)) || (!is_ie && e.keyCode == 13)) { |
---|
| 273 | QuickCatalogSearch.searchCatalogList(true); |
---|
| 274 | } |
---|
| 275 | }; |
---|
| 276 | |
---|
| 277 | win = new dJSWin({ |
---|
| 278 | id: 'win_'+el.id, |
---|
| 279 | content_id: el.id, |
---|
| 280 | width: wWidth, |
---|
| 281 | height: wHeight, |
---|
| 282 | title_color: '#3978d6', |
---|
| 283 | bg_color: '#eee', |
---|
| 284 | title: title, |
---|
| 285 | title_text_color: 'white', |
---|
| 286 | button_x_img: '../phpgwapi/images/winclose.gif', |
---|
| 287 | border: true }); |
---|
| 288 | |
---|
| 289 | this.arrayWin[el.id] = win; |
---|
| 290 | win.draw(); |
---|
| 291 | win.open(); |
---|
| 292 | |
---|
| 293 | var handler_organizations = function(data){ |
---|
| 294 | var user_organization = Element('user_organization').value; |
---|
| 295 | |
---|
| 296 | for(i = 0; i < data.length; i++) { |
---|
| 297 | Element('select_organization').options[i] = new Option(data[i],data[i]); |
---|
| 298 | if(user_organization.toUpperCase() == data[i].toUpperCase()) |
---|
| 299 | Element('select_organization').options[i].selected = true; |
---|
| 300 | } |
---|
| 301 | } |
---|
| 302 | cExecute ("$this.ldap_functions.get_organizations&referral=true", handler_organizations); |
---|
| 303 | |
---|
| 304 | var handler_cc_contacts= function(data){ |
---|
[128] | 305 | if(data && data.length > 0){ |
---|
[2] | 306 | var aux = data.split(","); |
---|
| 307 | for(var i=0; i< aux.length; i++){ |
---|
| 308 | QuickCatalogSearch.cc_contacts[QuickCatalogSearch.cc_contacts.length] = aux[i]; |
---|
| 309 | } |
---|
| 310 | } |
---|
| 311 | } |
---|
| 312 | cExecute("$this.db_functions.get_cc_contacts",handler_cc_contacts); |
---|
| 313 | |
---|
| 314 | var handler_cc_groups = function(data){ |
---|
[128] | 315 | if(data && data.length > 0){ |
---|
[2] | 316 | var aux = data.split(","); |
---|
| 317 | for(var i=0; i < data.length; i++){ |
---|
| 318 | QuickCatalogSearch.cc_groups[QuickCatalogSearch.cc_groups.length] = aux[i]; |
---|
| 319 | } |
---|
| 320 | } |
---|
| 321 | } |
---|
| 322 | cExecute("$this.db_functions.get_cc_groups",handler_cc_groups); |
---|
| 323 | |
---|
| 324 | } |
---|
| 325 | |
---|
| 326 | emQuickCatalogSearch.prototype.select_div = function(element){ |
---|
| 327 | if(element == 'tab1'){ |
---|
| 328 | Element('tab1').style.display = ''; |
---|
| 329 | Element('tab2').style.display = 'none'; |
---|
| 330 | Element('td1').style.background = '#eee'; |
---|
| 331 | Element('td2').style.background = '#cecece'; |
---|
| 332 | } |
---|
| 333 | if(element == 'tab2'){ |
---|
| 334 | Element('tab1').style.display = 'none'; |
---|
| 335 | Element('tab2').style.display = ''; |
---|
| 336 | Element('td1').style.background = '#cecece'; |
---|
| 337 | Element('td2').style.background = '#eee'; |
---|
| 338 | |
---|
| 339 | } |
---|
| 340 | } |
---|
| 341 | |
---|
| 342 | emQuickCatalogSearch.prototype.load_catalog = function(){ |
---|
| 343 | |
---|
| 344 | var _this = this; |
---|
| 345 | var content = new Array; |
---|
| 346 | var select = Element('list_personal').style.display == 'none'? Element('list_groups'): Element('list_personal'); |
---|
| 347 | |
---|
| 348 | if(Element('list_personal').style.display == 'none'){ |
---|
| 349 | content = _this.cc_groups; |
---|
| 350 | }else{ |
---|
| 351 | content = _this.cc_contacts; |
---|
| 352 | } |
---|
| 353 | if(select.options.length > 0){ |
---|
| 354 | for(var i=0; i < select.options.length; i++){ |
---|
| 355 | select.options[i] = null; |
---|
| 356 | i--; |
---|
| 357 | } |
---|
| 358 | } |
---|
| 359 | for(var i=0; i < content.length; i++){ |
---|
| 360 | if(content[i] != undefined){ |
---|
| 361 | var aux = content[i].split(";"); |
---|
| 362 | var opt = new Option(aux[0] + ' (' + aux[1] + ')','"' + aux[0] + '" ' + '<' + aux[1] + '>',false,false); |
---|
| 363 | select[select.length] = opt; |
---|
| 364 | } |
---|
| 365 | } |
---|
| 366 | content.splice(0,(content.lenght)); |
---|
| 367 | } |
---|
| 368 | |
---|
| 369 | emQuickCatalogSearch.prototype.changeOptions = function(type){ |
---|
| 370 | |
---|
| 371 | switch(type){ |
---|
| 372 | case 'u': |
---|
| 373 | Element('list_values').style.display = 'none'; |
---|
| 374 | Element('user_values').style.display = ''; |
---|
| 375 | break; |
---|
| 376 | |
---|
| 377 | case 'l': |
---|
| 378 | Element('user_values').style.display = 'none'; |
---|
| 379 | Element('list_values').style.display = ''; |
---|
| 380 | break; |
---|
| 381 | |
---|
| 382 | case 'p': |
---|
| 383 | Element('list_personal').style.display = ''; |
---|
| 384 | Element('list_groups').style.display = 'none' |
---|
| 385 | QuickCatalogSearch.load_catalog(); |
---|
| 386 | break; |
---|
| 387 | |
---|
| 388 | case 'g': |
---|
| 389 | Element('list_personal').style.display = 'none'; |
---|
| 390 | Element('list_groups').style.display = '' |
---|
| 391 | QuickCatalogSearch.load_catalog(); |
---|
| 392 | break; |
---|
| 393 | } |
---|
| 394 | |
---|
| 395 | } |
---|
| 396 | |
---|
| 397 | emQuickCatalogSearch.prototype.addContacts = function(field) { |
---|
| 398 | |
---|
| 399 | var border_id = Element('border_id').value; |
---|
| 400 | var select = Element('user_values').style.display == 'none' ? Element('list_values') : Element('user_values'); |
---|
| 401 | if(field == "to1" || field == "cc1" || field == "cco1"){ |
---|
| 402 | field = field.substr(0,field.length - 1); |
---|
| 403 | var select = Element('list_personal').style.display == 'none' ? Element('list_groups') : Element('list_personal'); |
---|
| 404 | } |
---|
| 405 | var fieldOpener = Element(field+"_"+border_id); |
---|
| 406 | var not_selected = true; |
---|
| 407 | for (i = 0 ; i < select.length ; i++) { |
---|
| 408 | if (select.options[i].selected && select.options[i].value != '-1') { |
---|
| 409 | if(fieldOpener.value.length > 0 && (fieldOpener.value.lastIndexOf(',') != (fieldOpener.value.length -1))){ |
---|
| 410 | fieldOpener.value += ","; |
---|
| 411 | } |
---|
| 412 | fieldOpener.value += select.options[i].value + ","; |
---|
| 413 | not_selected = false; |
---|
| 414 | select.options[i].selected = false; |
---|
| 415 | } |
---|
| 416 | } |
---|
| 417 | |
---|
| 418 | if(not_selected) |
---|
| 419 | return false; |
---|
| 420 | |
---|
| 421 | if(field != 'to'){ |
---|
| 422 | a_link = Element("a_"+field+"_link_"+border_id); |
---|
| 423 | if(a_link) |
---|
| 424 | a_link.onclick(); |
---|
| 425 | } |
---|
| 426 | } |
---|
| 427 | |
---|
| 428 | emQuickCatalogSearch.prototype.searchCatalogList = function (itemSearch){ |
---|
| 429 | |
---|
| 430 | if(itemSearch && Element('search_for').value.length == 0){ |
---|
| 431 | alert(get_lang('No data to search')); |
---|
| 432 | Element('search_for').focus(); |
---|
| 433 | return false; |
---|
| 434 | } |
---|
| 435 | var organization = Element('select_organization').value; |
---|
| 436 | var search = itemSearch ? Element('search_for').value : ''; |
---|
| 437 | var max_result = 2000; |
---|
| 438 | |
---|
| 439 | var handler_searchResults = function(data){ |
---|
| 440 | |
---|
| 441 | Element('msg_search').style.visibility = 'hidden'; |
---|
| 442 | if(data.error){ |
---|
| 443 | alert(get_lang('More than %1 results. Please, try to refine your search.',max_result)); |
---|
| 444 | return false; |
---|
| 445 | } |
---|
| 446 | |
---|
| 447 | var group = Element('list_span'); |
---|
| 448 | var user = Element('user_span'); |
---|
| 449 | if(is_ie){ |
---|
| 450 | group.innerHTML = ''; |
---|
| 451 | user.innerHTML = ''; |
---|
| 452 | } |
---|
| 453 | else { |
---|
| 454 | group = Element('list_values'); |
---|
| 455 | user = Element('user_values'); |
---|
| 456 | for(var i = 0;i < group.options.length; i++) |
---|
| 457 | group.options[i--] = null; |
---|
| 458 | for(var i = 0;i < user.options.length; i++) |
---|
| 459 | user.options[i--] = null; |
---|
| 460 | } |
---|
| 461 | |
---|
| 462 | var arr = new Array(max_result); |
---|
| 463 | var display = Element('type').value == 'l'? 'display:none;' : ''; |
---|
| 464 | |
---|
| 465 | for(i = 0; data.groups && i < data.groups.length; i++) { |
---|
| 466 | if(is_ie) |
---|
| 467 | arr[i] = '<option value="'+'"'+data.groups[i].name+'" <'+data.groups[i].email+'>">'+data.groups[i].name+' ('+data.groups[i].email+')'+'</option>'; |
---|
| 468 | else |
---|
| 469 | group.options[i] = new Option(data.groups[i].name+' ('+data.groups[i].email+')','"'+data.groups[i].name+'" <'+data.groups[i].email+'>'); |
---|
| 470 | } |
---|
| 471 | |
---|
| 472 | if(is_ie) |
---|
| 473 | group.innerHTML = '<select multiple style="'+display+'width:400px" size="14" id="list_values">'+ arr.join() +'</select>'; |
---|
| 474 | |
---|
| 475 | arr = new Array(max_result); |
---|
| 476 | display = display ? "" : "display:none;"; |
---|
| 477 | |
---|
| 478 | for(i = 0; data.users && i < data.users.length; i++) { |
---|
| 479 | if(is_ie) |
---|
| 480 | arr[i] = '<option value="'+'"'+data.users[i].name+'" <'+data.users[i].email+'>">'+data.users[i].name+' ('+data.users[i].email+')'+'</option>'; |
---|
| 481 | else |
---|
| 482 | user.options[i] = new Option(data.users[i].name+' ('+data.users[i].email+')','"'+data.users[i].name+'" <'+data.users[i].email+'>'); |
---|
| 483 | } |
---|
| 484 | |
---|
| 485 | if(is_ie) |
---|
| 486 | user.innerHTML = '<select multiple style="'+display+'width:400px" size="14" id="user_values">'+ arr.join() +'</select>'; |
---|
| 487 | } |
---|
| 488 | |
---|
| 489 | Element('msg_search').style.visibility = 'visible'; |
---|
| 490 | cExecute ("$this.ldap_functions.catalogsearch&max_result="+max_result+"&organization="+organization+"&search_for="+search, handler_searchResults); |
---|
| 491 | } |
---|
| 492 | |
---|
| 493 | |
---|
| 494 | /* Build the Object */ |
---|
| 495 | var QuickCatalogSearch; |
---|
| 496 | QuickCatalogSearch = new emQuickCatalogSearch(); |
---|