[2] | 1 | /******************************************************************************\ |
---|
| 2 | * eGroupWare - Contacts Center * |
---|
| 3 | * http://www.egroupware.org * |
---|
| 4 | * Written by: * |
---|
| 5 | * - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net> * |
---|
| 6 | * - Jonas Goes <jqhcb@users.sourceforge.net> * |
---|
| 7 | * sponsored by Thyamad - http://www.thyamad.com * |
---|
| 8 | * ------------------------------------------------------------------------- * |
---|
| 9 | * This program is free software; you can redistribute it and/or modify it * |
---|
| 10 | * under the terms of the GNU General Public License as published by the * |
---|
| 11 | * Free Software Foundation; either version 2 of the License, or (at your * |
---|
| 12 | * option) any later version. * |
---|
| 13 | \******************************************************************************/ |
---|
| 14 | |
---|
| 15 | /***********************************************\ |
---|
| 16 | * TODO * |
---|
| 17 | \***********************************************/ |
---|
| 18 | |
---|
| 19 | /* |
---|
| 20 | * function setHeightSpace () |
---|
| 21 | * |
---|
| 22 | */ |
---|
| 23 | |
---|
| 24 | /***********************************************\ |
---|
| 25 | * CONSTANTS * |
---|
| 26 | \***********************************************/ |
---|
| 27 | |
---|
| 28 | var CC_STATUS_FULL_ADD = 2; |
---|
| 29 | var CC_STATUS_QUICK_ADD = 1; |
---|
| 30 | |
---|
| 31 | var CC_card_image_width = 245; |
---|
| 32 | var CC_card_image_height = 130; |
---|
| 33 | var CC_card_extra = 16; |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | /***********************************************\ |
---|
| 37 | * GLOBALS VARIABLES * |
---|
| 38 | \***********************************************/ |
---|
| 39 | |
---|
[1496] | 40 | var owners = new Array(); |
---|
| 41 | var flag_compartilhado = false; |
---|
| 42 | var qtd_compartilhado = 0; |
---|
| 43 | |
---|
[2] | 44 | var CC_visual = 'table'; |
---|
| 45 | /* Cards Variables */ |
---|
| 46 | var CC_actual_letter = 'a'; |
---|
| 47 | var CC_last_letter = 'a'; |
---|
| 48 | var CC_actual_page = 1; |
---|
| 49 | var CC_npages = 0; |
---|
| 50 | var CC_max_cards = new Array(); |
---|
| 51 | var CC_conn_count=0; |
---|
| 52 | |
---|
| 53 | var CC_old_icon_w = 0; |
---|
| 54 | var CC_old_icon_h = 0; |
---|
| 55 | |
---|
| 56 | /* Tabs Variables */ |
---|
| 57 | var CC_last_tab = 0; |
---|
| 58 | |
---|
| 59 | /* Pseudo-Semafores */ |
---|
| 60 | var CC_tree_available = false; |
---|
| 61 | var CC_full_add_const = false; |
---|
| 62 | var CC_full_add_photo = false; |
---|
[1599] | 63 | |
---|
[2] | 64 | var CC_last_height = window.innerHeight; |
---|
| 65 | var CC_last_width = window.innerWidth; |
---|
| 66 | |
---|
| 67 | /* Contact Full Info */ |
---|
| 68 | var CC_contact_full_info; |
---|
| 69 | var CC_br_index; |
---|
| 70 | |
---|
| 71 | /* Addresses Variables */ |
---|
| 72 | var CC_addr_last_selected = 0; |
---|
| 73 | |
---|
| 74 | /* Connections Variables */ |
---|
| 75 | var CC_conn_last_selected = 0; |
---|
| 76 | |
---|
| 77 | /***********************************************\ |
---|
| 78 | * FULL ADD/EDIT FUNCTIONS * |
---|
| 79 | \***********************************************/ |
---|
| 80 | |
---|
| 81 | function createPhotoFrame() |
---|
| 82 | { |
---|
| 83 | photo_frame = document.createElement('iframe'); |
---|
| 84 | document.body.appendChild(photo_frame); |
---|
| 85 | |
---|
| 86 | if (is_ie) |
---|
| 87 | { |
---|
| 88 | photo_form = photo_frame.contentWindow.document.createElement('form'); |
---|
| 89 | photo_input = photo_frame.contentWindow.document.createElement('input'); |
---|
| 90 | } |
---|
| 91 | else |
---|
| 92 | { |
---|
| 93 | photo_form = photo_frame.contentDocument.createElement('form'); |
---|
| 94 | photo_input = photo_frame.contentDocument.createElement('input'); |
---|
| 95 | } |
---|
[1599] | 96 | |
---|
[2] | 97 | photo_frame.id = 'cc_photo_frame'; |
---|
| 98 | photo_frame.style.position = 'absolute'; |
---|
| 99 | //photo_frame.style.visibility = 'hidden'; |
---|
| 100 | photo_frame.style.top = '600px'; |
---|
| 101 | photo_frame.style.left = '0px'; |
---|
[1599] | 102 | |
---|
[2] | 103 | photo_form.id = 'cc_photo_form'; |
---|
| 104 | photo_form.method = 'POST'; |
---|
| 105 | photo_form.enctype = 'multipart/form-data'; |
---|
[1599] | 106 | |
---|
[2] | 107 | photo_input.id = 'cc_photo_input'; |
---|
| 108 | photo_input.type = 'file'; |
---|
[1599] | 109 | |
---|
[2] | 110 | if (is_ie) |
---|
| 111 | { |
---|
| 112 | photo_frame.contentWindow.document.body.appendChild(photo_form); |
---|
| 113 | } |
---|
| 114 | else |
---|
| 115 | { |
---|
| 116 | photo_frame.contentDocument.body.appendChild(photo_form); |
---|
| 117 | } |
---|
| 118 | photo_form.appendChild(photo_input); |
---|
[1599] | 119 | |
---|
[2] | 120 | } |
---|
| 121 | |
---|
| 122 | /********* Full Add Auxiliar Functions ****************/ |
---|
| 123 | function selectOption (id, option) |
---|
| 124 | { |
---|
| 125 | var obj = Element(id); |
---|
| 126 | var max = obj.options.length; |
---|
[1599] | 127 | |
---|
[2] | 128 | if (option == undefined) |
---|
| 129 | { |
---|
| 130 | obj.selectedIndex = 0; |
---|
| 131 | } |
---|
| 132 | else |
---|
| 133 | { |
---|
| 134 | for (var i = 0; i < max; i++) |
---|
| 135 | { |
---|
| 136 | if (obj.options[i].value == option) |
---|
| 137 | { |
---|
| 138 | obj.selectedIndex = i; |
---|
| 139 | break; |
---|
| 140 | } |
---|
| 141 | } |
---|
| 142 | } |
---|
| 143 | } |
---|
| 144 | |
---|
| 145 | function selectRadio (id, index) |
---|
| 146 | { |
---|
| 147 | var obj = Element(id); |
---|
| 148 | var max = obj.options.length; |
---|
| 149 | for (var i = 0; i < max; i++) |
---|
| 150 | { |
---|
| 151 | i == index ? obj.options[i].checked = true : obj.options[i].checked = false; |
---|
| 152 | } |
---|
| 153 | } |
---|
| 154 | |
---|
| 155 | function clearSelectBox(obj, startIndex) |
---|
| 156 | { |
---|
| 157 | var nOptions = obj.options.length; |
---|
| 158 | |
---|
| 159 | for (var i = nOptions - 1; i >= startIndex; i--) |
---|
| 160 | { |
---|
| 161 | obj.removeChild(obj.options[i]); |
---|
| 162 | } |
---|
| 163 | } |
---|
| 164 | /********** Open/Close FullAdd *************/ |
---|
| 165 | function openFullAdd(){ |
---|
| 166 | // Build the FullAdd Window. |
---|
[1599] | 167 | if(!fullAddWin && !is_ie) |
---|
[2] | 168 | __f(); |
---|
| 169 | |
---|
| 170 | resetFullAdd(); |
---|
| 171 | populateFullAddConst(); |
---|
| 172 | fullAddWin.open(); |
---|
| 173 | tabs._showTab('cc_contact_tab_0'); |
---|
[1599] | 174 | Element("cc_conn_type_1").checked = false; |
---|
[2] | 175 | Element("cc_conn_type_2").checked = false; |
---|
| 176 | Element("cc_conn_type_sel").disabled = true; |
---|
| 177 | Element("cc_conn_type_sel").selectedIndex = 0; |
---|
[1496] | 178 | Element("cc_contact_sharing").style.display = 'none'; |
---|
[2] | 179 | } |
---|
| 180 | |
---|
[1496] | 181 | function openFullAddShared(){ |
---|
| 182 | if (flag_compartilhado) |
---|
| 183 | { |
---|
| 184 | if(!fullAddWin && !is_ie) |
---|
| 185 | __f(); |
---|
| 186 | |
---|
| 187 | resetFullAdd(); |
---|
| 188 | populateFullAddConst(); |
---|
| 189 | fullAddWin.open(); |
---|
| 190 | tabs._showTab('cc_contact_tab_0'); |
---|
| 191 | Element("cc_conn_type_1").checked = false; |
---|
| 192 | Element("cc_conn_type_2").checked = false; |
---|
| 193 | Element("cc_conn_type_sel").disabled = true; |
---|
| 194 | Element("cc_conn_type_sel").selectedIndex = 0; |
---|
| 195 | Element("cc_contact_sharing").align = 'center'; |
---|
| 196 | Element("cc_contact_sharing").style.display = 'block'; |
---|
| 197 | Element("cc_contact_shared_types").disabled = true; |
---|
| 198 | populateSharingSelect(); |
---|
| 199 | } else |
---|
| 200 | { |
---|
| 201 | if(qtd_compartilhado != 0) |
---|
| 202 | { |
---|
| 203 | ccTree.select(0.2); |
---|
| 204 | ccTree.setCatalog(0.2); |
---|
| 205 | if(!fullAddWin && !is_ie) |
---|
| 206 | __f(); |
---|
| 207 | resetFullAdd(); |
---|
| 208 | populateFullAddConst(); |
---|
| 209 | fullAddWin.open(); |
---|
| 210 | tabs._showTab('cc_contact_tab_0'); |
---|
| 211 | Element("cc_conn_type_1").checked = false; |
---|
| 212 | Element("cc_conn_type_2").checked = false; |
---|
| 213 | Element("cc_conn_type_sel").disabled = true; |
---|
| 214 | Element("cc_conn_type_sel").selectedIndex = 0; |
---|
| 215 | Element("cc_contact_sharing").aling = 'center'; |
---|
| 216 | Element("cc_contact_sharing").style.display = 'block'; |
---|
| 217 | Element("cc_contact_shared_types").disabled = true; |
---|
| 218 | populateSharingSelect(); |
---|
| 219 | } else |
---|
| 220 | showMessage(Element('cc_msg_err_shared').value); |
---|
| 221 | } |
---|
| 222 | } |
---|
| 223 | |
---|
[2] | 224 | function closeFullAdd(){ |
---|
| 225 | fullAddWin.close(); |
---|
| 226 | } |
---|
| 227 | /********** New Contact *************/ |
---|
| 228 | function newContact(){ |
---|
| 229 | openFullAdd(); |
---|
| 230 | } |
---|
[1496] | 231 | function newSharedContact(){ |
---|
| 232 | openFullAddShared(); |
---|
| 233 | } |
---|
[2] | 234 | /************ Edit Contact *************/ |
---|
| 235 | function editContact (id){ |
---|
| 236 | openFullAdd(); |
---|
[503] | 237 | populateFullEdit(id,'bo_people_catalog'); |
---|
[2] | 238 | } |
---|
[503] | 239 | function editSharedContact (id){ |
---|
| 240 | openFullAdd(); |
---|
[752] | 241 | populateFullEdit(id,'bo_shared_people_manager'); |
---|
[503] | 242 | } |
---|
[2] | 243 | /************ Edit Group *************/ |
---|
| 244 | function editGroup(id){ |
---|
[1599] | 245 | populateEditGroup(id); |
---|
| 246 | ccAddGroup.window.open(); |
---|
[2] | 247 | } |
---|
[752] | 248 | |
---|
[1280] | 249 | function editSharedGroup(id,shared){ |
---|
| 250 | populateEditSharedGroup(id, shared); |
---|
[752] | 251 | } |
---|
| 252 | |
---|
[2] | 253 | /* |
---|
| 254 | Updates all the constant fields in the |
---|
| 255 | full add window, like Prefixes, Suffixes, |
---|
[1599] | 256 | Countries and Types |
---|
[2] | 257 | */ |
---|
[1496] | 258 | |
---|
| 259 | function populateSharingSelect() |
---|
| 260 | { |
---|
| 261 | var handler = function(responseText) |
---|
| 262 | { |
---|
[3335] | 263 | var data = unserialize(responseText); |
---|
| 264 | var sharers = Element('cc_contact_shared_types'); |
---|
[1496] | 265 | |
---|
| 266 | if (typeof(data) != 'object') |
---|
[3335] | 267 | { |
---|
| 268 | showMessage(Element('cc_msg_err_contacting_server').value); |
---|
| 269 | fullAddWin.close(); |
---|
| 270 | return; |
---|
| 271 | }else{ |
---|
| 272 | sharers.disabled = false; |
---|
| 273 | j = 1; |
---|
| 274 | for (var i in data) |
---|
[1496] | 275 | { |
---|
[3335] | 276 | sharers.options[j] = new Option(data[i]['cn'], i); |
---|
| 277 | owners[j] = i; |
---|
| 278 | j++; |
---|
[1496] | 279 | } |
---|
[3335] | 280 | return; |
---|
| 281 | } |
---|
[1496] | 282 | }; |
---|
[3335] | 283 | Connector.newRequest('populateSharingSelect', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_list_owners_perms_add', 'POST', handler); |
---|
[1496] | 284 | } |
---|
| 285 | |
---|
[2] | 286 | function populateFullAddConst() |
---|
| 287 | { |
---|
| 288 | CC_full_add_const = false; |
---|
[1599] | 289 | |
---|
[2] | 290 | setTimeout('populateFullAddConstAsync()', 10); |
---|
| 291 | } |
---|
| 292 | |
---|
| 293 | function populateFullAddConstAsync() |
---|
| 294 | { |
---|
| 295 | var handler = function(responseText) |
---|
| 296 | { |
---|
[1599] | 297 | //Element('cc_debug').innerHTML = responseText; |
---|
[2] | 298 | var data = unserialize(responseText); |
---|
| 299 | var i = 1; |
---|
| 300 | var j; |
---|
[1599] | 301 | |
---|
[2] | 302 | if (typeof(data) != 'object') |
---|
| 303 | { |
---|
| 304 | showMessage(Element('cc_msg_err_contacting_server').value); |
---|
| 305 | return; |
---|
| 306 | } |
---|
[1599] | 307 | |
---|
[2] | 308 | /* Populate Prefixes */ |
---|
| 309 | for (j in data[0]) |
---|
| 310 | { |
---|
| 311 | Element('cc_pd_prefix').options[i] = new Option(data[0][j], j); |
---|
| 312 | i++; |
---|
| 313 | } |
---|
[1599] | 314 | |
---|
[2] | 315 | /* Populate Suffixes */ |
---|
| 316 | i = 1; |
---|
| 317 | for (j in data[1]) |
---|
| 318 | { |
---|
| 319 | Element('cc_pd_suffix').options[i] = new Option(data[1][j], j); |
---|
| 320 | i++; |
---|
| 321 | } |
---|
| 322 | |
---|
| 323 | /* Populate Addresses Types */ |
---|
| 324 | i = 1; |
---|
| 325 | for (j in data[2]) |
---|
| 326 | { |
---|
| 327 | Element('cc_addr_types').options[i] = new Option(data[2][j], j); |
---|
| 328 | i++; |
---|
| 329 | } |
---|
| 330 | |
---|
| 331 | /* Populate Countries */ |
---|
| 332 | i = 1; |
---|
| 333 | for (j in data[3]) |
---|
| 334 | { |
---|
| 335 | Element('cc_addr_countries').options[i] = new Option(data[3][j], j); |
---|
[1599] | 336 | |
---|
[2] | 337 | if (j == 'BR' || j == 'br') |
---|
| 338 | { |
---|
| 339 | CC_br_index = i; |
---|
| 340 | } |
---|
[1599] | 341 | |
---|
[2] | 342 | i++; |
---|
| 343 | } |
---|
[1599] | 344 | |
---|
[2] | 345 | /* Populate Connection Types */ |
---|
| 346 | i = 1; |
---|
| 347 | for (j in data[4]) |
---|
| 348 | { |
---|
| 349 | Element('cc_conn_type').options[i] = new Option(data[4][j], j); |
---|
| 350 | i++; |
---|
| 351 | } |
---|
[1599] | 352 | |
---|
[2] | 353 | /* Populate Relations Types */ |
---|
| 354 | i = 0; |
---|
| 355 | for (j in data[5]) |
---|
| 356 | { |
---|
| 357 | Element('cc_rels_type').options[i] = new Option(data[5][j], j); |
---|
| 358 | i++; |
---|
| 359 | } |
---|
[1599] | 360 | |
---|
[2] | 361 | CC_full_add_const = true; |
---|
| 362 | |
---|
| 363 | }; |
---|
| 364 | |
---|
| 365 | Connector.newRequest('populateFullAddConst', CC_url+'get_contact_full_add_const', 'GET', handler); |
---|
| 366 | } |
---|
| 367 | |
---|
[503] | 368 | function populateFullEdit (id,catalog) |
---|
[2] | 369 | { |
---|
| 370 | var handler = function(responseText) |
---|
| 371 | { |
---|
| 372 | //Element('cc_debug').innerHTML = responseText; |
---|
| 373 | var data = unserialize(responseText); |
---|
| 374 | |
---|
| 375 | if (typeof(data) != 'object' || data['result'] != 'ok') |
---|
| 376 | { |
---|
| 377 | showMessage(Element('cc_msg_err_contacting_server').value); |
---|
| 378 | return; |
---|
| 379 | } |
---|
| 380 | |
---|
| 381 | resetFullAdd(); |
---|
| 382 | |
---|
| 383 | CC_contact_full_info = data; |
---|
| 384 | Element('cc_full_add_contact_id').value = data['cc_full_add_contact_id']; |
---|
| 385 | populatePersonalData(data['personal']); |
---|
| 386 | //populateRelations(data['relations']); |
---|
| 387 | }; |
---|
[503] | 388 | Connector.newRequest('populateFullEdit', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_full_data&id=' + id + "&catalog="+catalog, 'GET', handler); |
---|
[2] | 389 | } |
---|
| 390 | |
---|
| 391 | function populateEditGroup (id) |
---|
| 392 | { |
---|
[1280] | 393 | populateEditSharedGroup(id,false); |
---|
| 394 | } |
---|
| 395 | |
---|
| 396 | function populateEditSharedGroup(id,shared) { |
---|
[2] | 397 | var handler = function(responseText) |
---|
[285] | 398 | { |
---|
[294] | 399 | var data = unserialize(responseText); |
---|
| 400 | |
---|
[285] | 401 | Element('group_id').value = data['id_group']; |
---|
[294] | 402 | var options_contact_list = Element('span_contact_list'); |
---|
| 403 | var select_contact_list = '<select id="contact_list" multiple name="contact_list[]" style="width:280px" size="10">'; |
---|
| 404 | select_contact_list += data['contact_list'] + "</select>"; |
---|
| 405 | options_contact_list.innerHTML = select_contact_list; |
---|
[1599] | 406 | |
---|
| 407 | if(data['id_group']) { |
---|
| 408 | Element('title').value = data['title']; |
---|
[285] | 409 | if(data['contact_in_list']) { |
---|
| 410 | for(i = 0; i < data['contact_in_list'].length; i++) { |
---|
[2] | 411 | option = document.createElement('option'); |
---|
| 412 | option.value = data['contact_in_list'][i]['id_connection']; |
---|
[285] | 413 | option.text = data['contact_in_list'][i]['names_ordered']+' ('+data['contact_in_list'][i]['connection_value']+')'; |
---|
[2] | 414 | Element('contact_in_list').options[Element('contact_in_list').options.length] = option; |
---|
[1599] | 415 | } |
---|
| 416 | } |
---|
| 417 | |
---|
| 418 | Element('title').value = data['title']; |
---|
[2] | 419 | } |
---|
[285] | 420 | |
---|
[2] | 421 | if (typeof(data) != 'object' || data['result'] != 'ok') |
---|
| 422 | { |
---|
| 423 | showMessage(Element('cc_msg_err_contacting_server').value); |
---|
| 424 | return; |
---|
| 425 | } |
---|
[3970] | 426 | ccAddGroup.setSelectedSourceLevel(ccTree.actualLevel); |
---|
[294] | 427 | ccAddGroup.window.open(); |
---|
[2] | 428 | }; |
---|
[285] | 429 | |
---|
[2] | 430 | id = typeof(id) == 'undefined' ? id = 0 : id; |
---|
[285] | 431 | |
---|
[1599] | 432 | ccAddGroup.clear(true); |
---|
[1280] | 433 | if(!shared) |
---|
| 434 | Connector.newRequest('populateEditGroup', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_group&id='+id, 'GET', handler); |
---|
| 435 | else |
---|
| 436 | Connector.newRequest('populateEditGroup', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_group&id='+id+'&shared_from='+shared, 'GET', handler); |
---|
[2] | 437 | } |
---|
| 438 | |
---|
| 439 | |
---|
[1599] | 440 | |
---|
[2] | 441 | function resetFullAdd() |
---|
| 442 | { |
---|
| 443 | /* Clear information container */ |
---|
| 444 | CC_contact_full_info = new Array(); |
---|
| 445 | |
---|
| 446 | /* Clear Fields */ |
---|
| 447 | Element('cc_full_add_form_personal').reset(); |
---|
| 448 | Element('cc_full_add_form_addrs').reset(); |
---|
[1517] | 449 | if(Element('cc_contact_type').value=='advanced') |
---|
| 450 | Element('cc_full_add_form_corporative').reset(); |
---|
[2] | 451 | /* Personal Data */ |
---|
| 452 | Element('cc_full_add_contact_id').value = null; |
---|
| 453 | Element('cc_pd_photo').src = 'templates/default/images/photo.png'; |
---|
| 454 | |
---|
| 455 | /* Addresses */ |
---|
| 456 | resetAddressFields(); |
---|
| 457 | |
---|
| 458 | /* Connections */ |
---|
| 459 | CC_conn_last_selected = '_NONE_'; |
---|
| 460 | Element("cc_phone_default").options.selectedIndex = '-1'; |
---|
| 461 | Element("cc_email_default").options.selectedIndex = '-1'; |
---|
| 462 | Element("div_cc_conn_is_default").style.display = 'none'; |
---|
| 463 | clearConn(); |
---|
| 464 | } |
---|
| 465 | |
---|
| 466 | function postFullAdd() |
---|
| 467 | { |
---|
| 468 | if (!checkFullAdd()) |
---|
| 469 | { |
---|
| 470 | return false; |
---|
| 471 | } |
---|
[1599] | 472 | |
---|
[2] | 473 | /* First thing: Send Photo */ |
---|
| 474 | if (Element('cc_pd_select_photo').value != '' && !is_ie) |
---|
| 475 | { |
---|
| 476 | var nodes; |
---|
| 477 | var form, frame, old_frame; |
---|
| 478 | |
---|
| 479 | CC_full_add_photo = false; |
---|
| 480 | |
---|
| 481 | old_frame = Element('cc_photo_frame'); |
---|
| 482 | if (!old_frame) |
---|
| 483 | { |
---|
| 484 | frame = document.createElement('iframe'); |
---|
| 485 | } |
---|
| 486 | else |
---|
| 487 | { |
---|
| 488 | frame = old_frame; |
---|
| 489 | } |
---|
[1599] | 490 | |
---|
[2] | 491 | frame.id = 'cc_photo_frame'; |
---|
| 492 | frame.style.visibility = 'hidden'; |
---|
| 493 | frame.style.top = '0px'; |
---|
| 494 | frame.style.left = '0'; |
---|
| 495 | frame.style.position = 'absolute'; |
---|
| 496 | document.body.appendChild(frame); |
---|
| 497 | |
---|
| 498 | form = frame.contentDocument.createElement('form'); |
---|
[1599] | 499 | |
---|
[2] | 500 | var id_contact = Element('cc_full_add_contact_id').value; |
---|
| 501 | form.id = 'cc_form_photo'; |
---|
| 502 | form.method = 'POST'; |
---|
| 503 | form.enctype = 'multipart/form-data'; |
---|
| 504 | form.action = 'http://'+ document.domain + Element('cc_root_dir').value+'../index.php?menuaction=contactcenter.ui_data.data_manager&method=post_photo&id='+(id_contact != '' && id_contact != 'null' ? id_contact : ''); |
---|
[1599] | 505 | |
---|
[2] | 506 | var input_clone = Element('cc_pd_select_photo').cloneNode(false); |
---|
| 507 | form.appendChild(input_clone); |
---|
[1599] | 508 | |
---|
[2] | 509 | frame.contentDocument.body.appendChild(form); |
---|
| 510 | form.submit(); |
---|
| 511 | |
---|
| 512 | CC_full_add_photo = true; |
---|
| 513 | } |
---|
| 514 | else if (Element('cc_pd_select_photo_t').value != '' && is_ie) |
---|
| 515 | { |
---|
| 516 | CC_full_add_photo = false; |
---|
| 517 | |
---|
| 518 | var frame = Element('cc_photo_frame'); |
---|
| 519 | var form = frame.contentWindow.document.all['cc_photo_form']; |
---|
| 520 | var id_contact = Element('cc_full_add_contact_id').value; |
---|
| 521 | form.action = 'http://'+ document.domain + Element('cc_root_dir').value+'../index.php?menuaction=contactcenter.ui_data.data_manager&method=post_photo&id='+(id_contact != '' && id_contact != 'null' ? id_contact : ''); |
---|
| 522 | |
---|
| 523 | form.submit(); |
---|
| 524 | |
---|
| 525 | setTimeout('Element(\'cc_photo_frame\').src = \'cc_photo_frame.html\'', 1000); |
---|
| 526 | CC_full_add_photo = true; |
---|
| 527 | } |
---|
[1496] | 528 | if (Element('cc_contact_sharing').style.display == 'none') |
---|
[1599] | 529 | setTimeout('postFullAddInfo()', 100); |
---|
[1496] | 530 | else |
---|
| 531 | setTimeout('postFullAddInfoShared()', 100); |
---|
[2] | 532 | } |
---|
| 533 | |
---|
| 534 | function postFullAddInfo() |
---|
| 535 | { |
---|
| 536 | var handler = function (responseText) |
---|
| 537 | { |
---|
| 538 | var data = unserialize(responseText); |
---|
| 539 | |
---|
| 540 | if (typeof(data) != 'object') |
---|
| 541 | { |
---|
| 542 | showMessage(Element('cc_msg_err_contacting_server').value); |
---|
| 543 | return; |
---|
| 544 | } |
---|
| 545 | |
---|
| 546 | if (data['status'] != 'ok') |
---|
| 547 | { |
---|
| 548 | showMessage(data['msg']); |
---|
| 549 | return; |
---|
| 550 | } |
---|
| 551 | |
---|
| 552 | fullAddWin.close(); |
---|
| 553 | updateCards(); |
---|
| 554 | }; |
---|
[1599] | 555 | |
---|
[2] | 556 | Connector.newRequest('postFullAddInfo', CC_url+'post_full_add', 'POST', handler, getFullAddData()); |
---|
| 557 | } |
---|
| 558 | |
---|
[1496] | 559 | function postFullAddInfoShared() |
---|
| 560 | { |
---|
| 561 | var handler = function (responseText) |
---|
| 562 | { |
---|
| 563 | var data = unserialize(responseText); |
---|
| 564 | if (typeof(data) != 'object') |
---|
| 565 | { |
---|
| 566 | showMessage(Element('cc_msg_err_contacting_server').value); |
---|
| 567 | return; |
---|
| 568 | } |
---|
| 569 | |
---|
| 570 | if (data['status'] != 'ok') |
---|
| 571 | { |
---|
| 572 | showMessage(data['msg']); |
---|
| 573 | return; |
---|
| 574 | } |
---|
| 575 | |
---|
| 576 | fullAddWin.close(); |
---|
| 577 | updateCards(); |
---|
| 578 | }; |
---|
| 579 | Connector.newRequest('postFullAddInfoShared', CC_url+'post_full_add_shared', 'POST', handler, getFullAddData()); |
---|
| 580 | } |
---|
| 581 | |
---|
[2] | 582 | function getFullAddData() |
---|
| 583 | { |
---|
| 584 | var data = new Array(); |
---|
| 585 | var empty = true; |
---|
| 586 | var replacer = '__##AND##__'; |
---|
[1496] | 587 | |
---|
[2] | 588 | data['commercialAnd'] = replacer; |
---|
[1599] | 589 | |
---|
[2] | 590 | if (Element('cc_full_add_contact_id').value != '' && Element('cc_full_add_contact_id').value != 'null') |
---|
| 591 | { |
---|
| 592 | data['id_contact'] = replaceComAnd(Element('cc_full_add_contact_id').value, replacer); |
---|
| 593 | data.length++; |
---|
| 594 | } |
---|
[1599] | 595 | |
---|
[1496] | 596 | /* Owner do contato (Para o caso de adicao de contato compartilhado) */ |
---|
| 597 | if (Element('cc_contact_sharing').style.display == 'block') |
---|
| 598 | { |
---|
| 599 | var index = Element('cc_contact_shared_types').selectedIndex; |
---|
[1599] | 600 | data['owner'] = replaceComAnd(owners[index], replacer); |
---|
[1496] | 601 | data.length++; |
---|
| 602 | } |
---|
[1599] | 603 | |
---|
[2] | 604 | /* Status: Full Added */ |
---|
| 605 | data['id_status'] = CC_STATUS_FULL_ADD; |
---|
[1599] | 606 | |
---|
[2] | 607 | /* Personal Data */ |
---|
| 608 | data['alias'] = replaceComAnd(Element('cc_pd_alias').value, replacer); |
---|
| 609 | data['id_prefix'] = replaceComAnd(Element('cc_pd_prefix').value, replacer); |
---|
| 610 | data['given_names'] = replaceComAnd(Element('cc_pd_given_names').value, replacer); |
---|
| 611 | data['family_names'] = replaceComAnd(Element('cc_pd_family_names').value, replacer); |
---|
| 612 | data['names_ordered'] = replaceComAnd(data['given_names']+" "+data['family_names'], replacer); |
---|
| 613 | data['id_suffix'] = replaceComAnd(Element('cc_pd_suffix').value, replacer);; |
---|
| 614 | data['birthdate_0'] = replaceComAnd(Element('cc_pd_birthdate_0').value, replacer); |
---|
| 615 | data['birthdate_1'] = replaceComAnd(Element('cc_pd_birthdate_1').value, replacer); |
---|
| 616 | data['birthdate_2'] = replaceComAnd(Element('cc_pd_birthdate_2').value, replacer); |
---|
| 617 | // data['sex'] = Element('cc_pd_sex').value == 1 ? 'M' : Element('cc_pd_sex').value == 2 ? 'F' : null; |
---|
| 618 | data['pgp_key'] = replaceComAnd(Element('cc_pd_gpg_finger_print').value, replacer); |
---|
| 619 | data['notes'] = replaceComAnd(Element('cc_pd_notes').value, replacer); |
---|
| 620 | |
---|
| 621 | data.length += 14; |
---|
[1517] | 622 | //corporative |
---|
[3315] | 623 | |
---|
| 624 | if (document.getElementById('cc_contact_type').value == 'advanced') { |
---|
| 625 | data['corporate_name'] = replaceComAnd(document.getElementById('cc_name_corporate').value, replacer); |
---|
| 626 | data['job_title'] = replaceComAnd(document.getElementById('cc_job_title').value, replacer); |
---|
| 627 | data['department'] = replaceComAnd(document.getElementById('cc_department').value, replacer); |
---|
| 628 | data['web_page'] = replaceComAnd(document.getElementById('cc_web_page').value, replacer); |
---|
[1517] | 629 | data.length += 18; |
---|
| 630 | } |
---|
[2] | 631 | |
---|
| 632 | /* Addresses */ |
---|
| 633 | saveAddressFields(); |
---|
| 634 | data['addresses'] = CC_contact_full_info['addresses']; |
---|
| 635 | |
---|
| 636 | /* Connection */ |
---|
| 637 | saveConnFields(); |
---|
| 638 | |
---|
| 639 | if (CC_contact_full_info['connections']) |
---|
| 640 | { |
---|
| 641 | var connNumber = 0; |
---|
| 642 | for (var type in CC_contact_full_info['connections']) |
---|
| 643 | { |
---|
| 644 | if (type == 'length') |
---|
| 645 | { |
---|
| 646 | continue; |
---|
| 647 | } |
---|
| 648 | |
---|
| 649 | if (typeof(data['connections']) != 'object') |
---|
| 650 | { |
---|
| 651 | data['connections'] = new Array(); |
---|
| 652 | } |
---|
[1599] | 653 | |
---|
[2] | 654 | for (var i in CC_contact_full_info['connections'][type]) |
---|
| 655 | { |
---|
| 656 | if (i == 'length') |
---|
| 657 | { |
---|
| 658 | continue; |
---|
| 659 | } |
---|
| 660 | |
---|
| 661 | if (typeof(data['connections']['connection'+connNumber]) != 'object') |
---|
| 662 | { |
---|
| 663 | data['connections']['connection'+connNumber] = new Array(5); |
---|
| 664 | } |
---|
[1599] | 665 | |
---|
[2] | 666 | data['connections']['connection'+connNumber]['id_connection'] = CC_contact_full_info['connections'][type][i]['id']; |
---|
| 667 | data['connections']['connection'+connNumber]['id_typeof_connection'] = type; |
---|
| 668 | data['connections']['connection'+connNumber]['connection_name'] = CC_contact_full_info['connections'][type][i]['name']; |
---|
| 669 | data['connections']['connection'+connNumber]['connection_value'] = CC_contact_full_info['connections'][type][i]['value']; |
---|
| 670 | if(Element("cc_"+(type == 1 ? 'email' : 'phone')+"_default").value) { |
---|
| 671 | if(Element("cc_"+(type == 1 ? 'email' : 'phone')+"_default").value == CC_contact_full_info['connections'][type][i]['name']){ |
---|
| 672 | data['connections']['connection'+connNumber]['connection_is_default'] = 'TRUE'; |
---|
| 673 | } |
---|
[1599] | 674 | else |
---|
[2] | 675 | data['connections']['connection'+connNumber]['connection_is_default'] = 'FALSE'; |
---|
| 676 | } |
---|
| 677 | |
---|
| 678 | // data['connections']['connection'+connNumber].length = 5; |
---|
[1599] | 679 | |
---|
[2] | 680 | empty = false; |
---|
| 681 | connNumber++; |
---|
| 682 | data['connections'].length++; |
---|
| 683 | } |
---|
| 684 | |
---|
| 685 | } |
---|
[1599] | 686 | |
---|
[2] | 687 | if (!empty) |
---|
| 688 | { |
---|
| 689 | data.length++; |
---|
| 690 | empty = true; |
---|
| 691 | } |
---|
| 692 | } |
---|
[1599] | 693 | |
---|
[2] | 694 | if (CC_contact_full_info['removed_conns']) |
---|
| 695 | { |
---|
| 696 | empty = false; |
---|
[1599] | 697 | |
---|
[2] | 698 | if (typeof(data['connections']) != 'object') |
---|
| 699 | { |
---|
| 700 | data['connections'] = new Array(); |
---|
| 701 | data.length++; |
---|
| 702 | } |
---|
| 703 | |
---|
| 704 | data['connections']['removed_conns'] = CC_contact_full_info['removed_conns']; |
---|
| 705 | data['connections'].length++; |
---|
| 706 | } |
---|
| 707 | |
---|
[1496] | 708 | var serial = serialize(data); |
---|
[2] | 709 | return 'data=' + escape(serialize(data)); |
---|
| 710 | } |
---|
| 711 | |
---|
| 712 | function checkFullAdd() |
---|
| 713 | { |
---|
[1496] | 714 | |
---|
| 715 | /* Checa se o listbox esta desativado ou é nulo, ou seja, não existe catálogos compartilhados com o user atual */ |
---|
| 716 | |
---|
| 717 | if (!(Element('cc_contact_sharing').style.display == 'none' )) |
---|
| 718 | { |
---|
| 719 | if (Element('cc_contact_shared_types').disabled == true) |
---|
[1599] | 720 | { |
---|
[1496] | 721 | showMessage('Nenhum catálogo compartilhado existente'); |
---|
| 722 | return false; |
---|
| 723 | } |
---|
| 724 | if (Element('cc_contact_shared_types').selectedIndex == 0) |
---|
| 725 | { |
---|
| 726 | showMessage('Nenhum catálogo selecionado'); |
---|
| 727 | return false; |
---|
| 728 | } |
---|
| 729 | } |
---|
[1599] | 730 | |
---|
[2] | 731 | /* Check Personal Data */ |
---|
[1599] | 732 | |
---|
[2] | 733 | if (Element('cc_pd_given_names').value == '') |
---|
| 734 | { |
---|
| 735 | showMessage(Element('cc_msg_err_empty_field').value + " => " + Element('cc_pd_given_names').name); |
---|
| 736 | return false; |
---|
| 737 | } |
---|
| 738 | |
---|
| 739 | /* Check Addresses */ |
---|
| 740 | |
---|
| 741 | /* Check Connections */ |
---|
| 742 | |
---|
| 743 | saveConnFields(); |
---|
| 744 | |
---|
| 745 | var comp = /^[a-zA-Z\d(-)\.@_ -]{0,200}$/; |
---|
[1664] | 746 | haveConnections = false; |
---|
| 747 | if (CC_contact_full_info['connections']){ |
---|
| 748 | for (var type in CC_contact_full_info['connections']){ |
---|
| 749 | haveConnections = true; |
---|
| 750 | for (var i in CC_contact_full_info['connections'][type]){ |
---|
| 751 | if((CC_contact_full_info['connections'][type][i]['value'].length < 4) || |
---|
| 752 | (!comp.test(CC_contact_full_info['connections'][type][i]['value']))){ |
---|
| 753 | showMessage('Endereço para conexão de ' + CC_contact_full_info['connections'][type][i]['name'] + ', não é válido'); |
---|
| 754 | return false; |
---|
| 755 | } |
---|
| 756 | } |
---|
| 757 | var _options_default = Element("cc_"+(type == 1 ? 'email' : 'phone')+"_default"); |
---|
| 758 | if(_options_default.value == '-1') { |
---|
| 759 | alert("É necessário escolher um "+ (type == 1 ? 'E-mail' : 'Telefone')+" como padrão!"); |
---|
| 760 | return false; |
---|
| 761 | } |
---|
| 762 | } |
---|
| 763 | } |
---|
| 764 | if(!haveConnections){ |
---|
[1682] | 765 | showMessage(Element('cc_msg_tel_or_mail_required').value); |
---|
[1664] | 766 | return false; |
---|
| 767 | } |
---|
[1599] | 768 | |
---|
[1664] | 769 | /* Check Relations */ |
---|
[2] | 770 | |
---|
[1664] | 771 | return true; |
---|
[2] | 772 | |
---|
| 773 | } |
---|
| 774 | |
---|
| 775 | /********* Personal Data Functions *********/ |
---|
[1599] | 776 | /* |
---|
[2] | 777 | * data[0] => cc_pd_select_photo |
---|
| 778 | * data[1] => cc_pd_alias |
---|
| 779 | * data[2] => cc_pd_given_names |
---|
| 780 | * data[3] => cc_pd_family_names |
---|
| 781 | * data[4] => cc_pd_full_name |
---|
| 782 | * data[5] => cc_pd_suffix |
---|
| 783 | * data[6] => cc_pd_birthdate |
---|
| 784 | * data[7] => cc_pd_sex SELECT |
---|
| 785 | * data[8] => cc_pd_prefix |
---|
| 786 | * data[9] => cc_pd_gpg_finger_print |
---|
| 787 | * data[10] => cc_pd_notes |
---|
| 788 | */ |
---|
| 789 | |
---|
| 790 | function populatePersonalData (data) |
---|
| 791 | { |
---|
| 792 | for (i in data) |
---|
| 793 | { |
---|
| 794 | switch(i) |
---|
| 795 | { |
---|
| 796 | case 'cc_pd_suffix': |
---|
| 797 | case 'cc_pd_sex': |
---|
| 798 | case 'cc_pd_prefix': |
---|
| 799 | selectOption(i, data[i]); |
---|
| 800 | break; |
---|
| 801 | |
---|
| 802 | case 'cc_pd_photo': |
---|
| 803 | if (data[i]) |
---|
| 804 | { |
---|
| 805 | Element(i).src = data[i] + '&'+ Math.random(); |
---|
| 806 | } |
---|
| 807 | break; |
---|
| 808 | |
---|
| 809 | default: |
---|
[1650] | 810 | Element(i).value = data[i] == undefined ? '' : unescape(data[i]); |
---|
[2] | 811 | } |
---|
| 812 | } |
---|
| 813 | |
---|
| 814 | return; |
---|
| 815 | } |
---|
| 816 | |
---|
| 817 | /********* End Personal Data Functions *********/ |
---|
| 818 | |
---|
| 819 | |
---|
| 820 | /********* Addresses Functions *********/ |
---|
| 821 | function resetAddressFields() |
---|
| 822 | { |
---|
| 823 | Element('cc_addr_types').selectedIndex = 0; |
---|
[1599] | 824 | |
---|
[2] | 825 | Element('cc_addr_countries').selectedIndex = 0; |
---|
| 826 | Element('cc_addr_countries').disabled = true; |
---|
[1599] | 827 | |
---|
[2] | 828 | Element('cc_addr_states').selectedIndex = 0; |
---|
| 829 | Element('cc_addr_states').disabled = true; |
---|
| 830 | Element('cc_addr_states_new').disabled = true; |
---|
| 831 | Element('cc_addr_states_new').readonly = true; |
---|
| 832 | Element('cc_addr_states_new').value = ''; |
---|
| 833 | |
---|
| 834 | Element('cc_addr_cities').selectedIndex = 0; |
---|
| 835 | Element('cc_addr_cities').disabled = true; |
---|
| 836 | Element('cc_addr_cities_new').disabled = true; |
---|
| 837 | Element('cc_addr_cities_new').readonly = true; |
---|
| 838 | Element('cc_addr_cities_new').value = ''; |
---|
| 839 | |
---|
| 840 | Element('cc_addr_id').value = ''; |
---|
| 841 | |
---|
| 842 | resetAddrFillingFields(); |
---|
| 843 | } |
---|
| 844 | |
---|
| 845 | function resetAddrFillingFields() |
---|
| 846 | { |
---|
| 847 | Element('cc_addr_1').value = ''; |
---|
| 848 | Element('cc_addr_2').value = ''; |
---|
| 849 | Element('cc_addr_other').value = ''; |
---|
| 850 | Element('cc_addr_complement').value = ''; |
---|
| 851 | Element('cc_addr_postal_code').value = ''; |
---|
| 852 | Element('cc_addr_po_box').value = ''; |
---|
| 853 | Element('cc_addr_is_default').checked = false; |
---|
| 854 | } |
---|
| 855 | |
---|
| 856 | function disableAddrFillingFields() |
---|
| 857 | { |
---|
| 858 | Element('cc_addr_1').readonly = true; |
---|
| 859 | Element('cc_addr_1').disabled = true; |
---|
| 860 | Element('cc_addr_2').readonly = true; |
---|
| 861 | Element('cc_addr_2').disabled = true; |
---|
| 862 | Element('cc_addr_other').readonly = true; |
---|
| 863 | Element('cc_addr_other').disabled = true; |
---|
| 864 | Element('cc_addr_complement').readonly = true; |
---|
| 865 | Element('cc_addr_complement').disabled = true; |
---|
| 866 | Element('cc_addr_postal_code').readonly = true; |
---|
| 867 | Element('cc_addr_postal_code').disabled = true; |
---|
| 868 | Element('cc_addr_po_box').readonly = true; |
---|
| 869 | Element('cc_addr_po_box').disabled = true; |
---|
| 870 | Element('cc_addr_is_default').readonly = true; |
---|
| 871 | Element('cc_addr_is_default').disabled = true; |
---|
| 872 | } |
---|
| 873 | |
---|
| 874 | function updateAddressFields() |
---|
| 875 | { |
---|
| 876 | var type = Element('cc_addr_types'); |
---|
| 877 | var oldSelected = type.value; |
---|
[1599] | 878 | |
---|
[2] | 879 | saveAddressFields(); |
---|
[1599] | 880 | |
---|
[2] | 881 | if (oldSelected == '_NONE_') |
---|
| 882 | { |
---|
| 883 | resetAddressFields(); |
---|
| 884 | return true; |
---|
| 885 | } |
---|
[1599] | 886 | |
---|
[2] | 887 | CC_addr_last_selected = type.selectedIndex; |
---|
[1599] | 888 | |
---|
[2] | 889 | Element('cc_addr_countries').disabled = false; |
---|
[1599] | 890 | |
---|
[2] | 891 | var data = CC_contact_full_info['addresses']; |
---|
| 892 | var addrIndex = 'address'+Element('cc_addr_types').value; |
---|
[1599] | 893 | |
---|
| 894 | if (typeof(data) != 'object' || typeof(data[addrIndex]) != 'object') |
---|
[2] | 895 | { |
---|
| 896 | resetAddressFields(); |
---|
| 897 | Element('cc_addr_countries').disabled = false; |
---|
| 898 | Element('cc_addr_countries').selectedIndex = CC_br_index; |
---|
| 899 | type.value = oldSelected; |
---|
| 900 | updateAddrStates(); |
---|
| 901 | return true; |
---|
| 902 | } |
---|
[1599] | 903 | |
---|
[2] | 904 | var addrTypeID = Element('cc_addr_types').value; |
---|
[1599] | 905 | |
---|
[2] | 906 | data = CC_contact_full_info['addresses'][addrIndex]; |
---|
[1599] | 907 | |
---|
[2] | 908 | Element('cc_addr_id').value = data['id_address'] ? data['id_address'] : ''; |
---|
| 909 | Element('cc_addr_1').value = data['address1'] ? data['address1'] : ''; |
---|
| 910 | Element('cc_addr_2').value = data['address2'] ? data['address2'] : ''; |
---|
| 911 | Element('cc_addr_complement').value = data['complement'] ? data['complement'] : ''; |
---|
| 912 | Element('cc_addr_other').value = data['address_other'] ? data['address_other'] : ''; |
---|
| 913 | Element('cc_addr_postal_code').value = data['postal_code'] ? data['postal_code'] : ''; |
---|
| 914 | Element('cc_addr_po_box').value = data['po_box'] ? data['po_box'] : ''; |
---|
| 915 | Element('cc_addr_is_default').checked = data['address_is_default'] == '1' ? true: false; |
---|
| 916 | |
---|
| 917 | Element('cc_addr_countries').value = data['id_country']; |
---|
| 918 | updateAddrStates(); |
---|
| 919 | } |
---|
| 920 | |
---|
| 921 | function updateAddrStates() |
---|
| 922 | { |
---|
| 923 | var states = Element('cc_addr_states'); |
---|
| 924 | if (Element('cc_addr_countries').value == '_NONE_') |
---|
| 925 | { |
---|
| 926 | states.disabled = true; |
---|
| 927 | states.selectedIndex = 0; |
---|
| 928 | clearSelectBox(states, 4); |
---|
[1599] | 929 | updateAddrCities(); |
---|
[2] | 930 | return; |
---|
| 931 | } |
---|
| 932 | |
---|
| 933 | updateAddrFillingFields(); |
---|
| 934 | populateStates(); |
---|
| 935 | } |
---|
| 936 | |
---|
| 937 | function populateStates() |
---|
| 938 | { |
---|
| 939 | var states = Element('cc_addr_states'); |
---|
| 940 | var cities = Element('cc_addr_cities'); |
---|
| 941 | var handler = function (responseText) |
---|
| 942 | { |
---|
| 943 | var data = unserialize(responseText); |
---|
[1599] | 944 | |
---|
[2] | 945 | clearSelectBox(states, 1); |
---|
[1599] | 946 | |
---|
[2] | 947 | if (typeof(data) != 'object') |
---|
| 948 | { |
---|
| 949 | showMessage(Element('cc_msg_err_contacting_server').value); |
---|
[1599] | 950 | |
---|
[2] | 951 | return; |
---|
| 952 | } |
---|
| 953 | |
---|
| 954 | if (data['status'] == 'empty') |
---|
| 955 | { |
---|
| 956 | states.disabled = true; |
---|
[1599] | 957 | cities.disabled = true; |
---|
[2] | 958 | states.selectedIndex = 0; |
---|
| 959 | cities.selectedIndex = 0; |
---|
| 960 | return; |
---|
| 961 | } |
---|
| 962 | else if (data['status'] != 'ok') |
---|
| 963 | { |
---|
| 964 | showMessage(data['msg']); |
---|
| 965 | states.disabled = true; |
---|
| 966 | states.selectedIndex = 0; |
---|
| 967 | updateAddrCities(); |
---|
| 968 | return; |
---|
| 969 | } |
---|
| 970 | states.disabled = false; |
---|
| 971 | var i = 1; |
---|
| 972 | for (var j in data['data']) |
---|
| 973 | { |
---|
| 974 | states.options[i] = new Option(data['data'][j], j); |
---|
| 975 | i++; |
---|
| 976 | } |
---|
| 977 | |
---|
| 978 | states.disabled = false; |
---|
| 979 | states.selectedIndex = 0; |
---|
| 980 | |
---|
| 981 | data = CC_contact_full_info['addresses']; |
---|
| 982 | var addrIndex = 'address'+Element('cc_addr_types').value; |
---|
| 983 | if (data && data[addrIndex]) |
---|
| 984 | { |
---|
| 985 | states.value = data[addrIndex]['id_state']; |
---|
| 986 | if (states.value == '_NEW_') |
---|
| 987 | { |
---|
| 988 | if (CC_contact_full_info['addresses']['new_states'][addrIndex]) |
---|
| 989 | { |
---|
| 990 | Element('cc_addr_states_new').value = CC_contact_full_info['addresses']['new_states'][addrIndex]; |
---|
| 991 | } |
---|
| 992 | updateAddrNewStateOnMouseOut(); |
---|
| 993 | } |
---|
| 994 | updateAddrCities(); |
---|
| 995 | } |
---|
| 996 | }; |
---|
[1599] | 997 | |
---|
[2] | 998 | Connector.newRequest('populateStates', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_states&country='+Element('cc_addr_countries').value, 'GET', handler); |
---|
| 999 | } |
---|
| 1000 | |
---|
| 1001 | function updateAddrCities() |
---|
| 1002 | { |
---|
| 1003 | var states = Element('cc_addr_states'); |
---|
| 1004 | var cities = Element('cc_addr_cities'); |
---|
| 1005 | var newState = Element('cc_addr_states_new'); |
---|
| 1006 | var requestStr; |
---|
| 1007 | |
---|
| 1008 | switch (states.value) |
---|
| 1009 | { |
---|
| 1010 | case '_NONE_': |
---|
| 1011 | newState.readonly = true; |
---|
| 1012 | newState.disabled = true; |
---|
| 1013 | newState.value = ''; |
---|
| 1014 | |
---|
| 1015 | cities.disabled = true; |
---|
| 1016 | cities.selectedIndex = 0; |
---|
| 1017 | updateAddrFillingFields(); |
---|
| 1018 | return; |
---|
| 1019 | |
---|
| 1020 | case '_NEW_': |
---|
| 1021 | |
---|
| 1022 | newState.readonly = false; |
---|
| 1023 | newState.disabled = false; |
---|
| 1024 | updateAddrNewStateOnMouseOut(); |
---|
[1599] | 1025 | |
---|
[2] | 1026 | cities.disabled = false; |
---|
| 1027 | clearSelectBox(cities, 3); |
---|
| 1028 | cities.selectedIndex = 1; |
---|
| 1029 | updateAddrFillingFields(); |
---|
| 1030 | return; |
---|
| 1031 | |
---|
| 1032 | case '_SEP_': return; |
---|
| 1033 | |
---|
| 1034 | case '_NOSTATE_': |
---|
| 1035 | clearSelectBox(cities, 3); |
---|
[1599] | 1036 | |
---|
[2] | 1037 | cities.disabled = false; |
---|
| 1038 | cities.selectedIndex = 0; |
---|
[1599] | 1039 | |
---|
[2] | 1040 | requestStr = 'country='+Element('cc_addr_countries').value; |
---|
| 1041 | break; |
---|
[1599] | 1042 | |
---|
[2] | 1043 | default: |
---|
| 1044 | requestStr = 'country='+Element('cc_addr_countries').value+'&state='+states.value; |
---|
| 1045 | } |
---|
| 1046 | |
---|
| 1047 | newState.readonly = true; |
---|
| 1048 | newState.disabled = true; |
---|
| 1049 | newState.value = ''; |
---|
| 1050 | |
---|
| 1051 | populateCities(requestStr); |
---|
| 1052 | } |
---|
| 1053 | |
---|
| 1054 | function populateCities(requestStr) |
---|
| 1055 | { |
---|
| 1056 | var cities = Element('cc_addr_cities'); |
---|
[1599] | 1057 | |
---|
[2] | 1058 | var handler = function (responseText) |
---|
| 1059 | { |
---|
| 1060 | var data = unserialize(responseText); |
---|
[1599] | 1061 | |
---|
[2] | 1062 | clearSelectBox(cities, 1); |
---|
[1599] | 1063 | |
---|
[2] | 1064 | if (typeof(data) != 'object') |
---|
| 1065 | { |
---|
| 1066 | showMessage(Element('cc_msg_err_contacting_server').value); |
---|
[1599] | 1067 | |
---|
[2] | 1068 | return; |
---|
| 1069 | } |
---|
| 1070 | |
---|
| 1071 | if (data['status'] == 'empty') |
---|
| 1072 | { |
---|
| 1073 | cities.disabled = true; |
---|
| 1074 | cities.selectedIndex = 0; |
---|
| 1075 | return; |
---|
| 1076 | } |
---|
| 1077 | else if (data['status'] != 'ok') |
---|
| 1078 | { |
---|
| 1079 | showMessage(data['msg']); |
---|
| 1080 | cities.disabled = true; |
---|
| 1081 | cities.selectedIndex = 0; |
---|
| 1082 | updateAddrFillingFields(); |
---|
| 1083 | return; |
---|
| 1084 | } |
---|
| 1085 | cities.disabled = false; |
---|
| 1086 | var i = 1; |
---|
| 1087 | for (var j in data['data']) |
---|
| 1088 | { |
---|
| 1089 | cities.options[i] = new Option(data['data'][j], j); |
---|
| 1090 | i++; |
---|
| 1091 | } |
---|
| 1092 | |
---|
| 1093 | cities.disabled = false; |
---|
| 1094 | cities.selectedIndex = 0; |
---|
| 1095 | |
---|
| 1096 | data = CC_contact_full_info['addresses']; |
---|
| 1097 | var addrIndex = 'address'+Element('cc_addr_types').value; |
---|
| 1098 | if (data && data[addrIndex]) |
---|
| 1099 | { |
---|
| 1100 | cities.value = data[addrIndex]['id_city']; |
---|
| 1101 | |
---|
| 1102 | if (cities.value == '_NEW_') |
---|
| 1103 | { |
---|
| 1104 | if (CC_contact_full_info['addresses']['new_cities'][addrIndex]) |
---|
| 1105 | { |
---|
| 1106 | Element('cc_addr_cities_new').value = CC_contact_full_info['addresses']['new_cities'][addrIndex]; |
---|
| 1107 | } |
---|
| 1108 | updateAddrNewCityOnMouseOut(); |
---|
| 1109 | } |
---|
| 1110 | } |
---|
| 1111 | }; |
---|
[1599] | 1112 | |
---|
[2] | 1113 | Connector.newRequest('populateCities', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_cities&'+requestStr, 'GET', handler); |
---|
| 1114 | } |
---|
| 1115 | |
---|
| 1116 | function updateAddrNewStateOnMouseOver () |
---|
| 1117 | { |
---|
[1599] | 1118 | if (Element('cc_addr_states_new').value == Element('cc_msg_type_state').value && Element('cc_addr_states').selectedIndex == 1) |
---|
[2] | 1119 | { |
---|
| 1120 | Element('cc_addr_states_new').value = ''; |
---|
| 1121 | } |
---|
| 1122 | } |
---|
| 1123 | |
---|
| 1124 | function updateAddrNewStateOnMouseOut () |
---|
| 1125 | { |
---|
[1599] | 1126 | if (Element('cc_addr_states_new').value.length == 0 && Element('cc_addr_states').selectedIndex == 1) |
---|
[2] | 1127 | { |
---|
| 1128 | Element('cc_addr_states_new').value = Element('cc_msg_type_state').value; |
---|
| 1129 | } |
---|
| 1130 | } |
---|
| 1131 | |
---|
| 1132 | function updateAddrFillingFields() |
---|
| 1133 | { |
---|
| 1134 | var countries = Element('cc_addr_countries'); |
---|
| 1135 | var cities = Element('cc_addr_cities'); |
---|
| 1136 | var newCity = Element('cc_addr_cities_new'); |
---|
| 1137 | |
---|
| 1138 | if (countries.value == '_NONE_') |
---|
| 1139 | { |
---|
| 1140 | newCity.readonly = true; |
---|
| 1141 | newCity.disabled = true; |
---|
| 1142 | newCity.value = ''; |
---|
| 1143 | disableAddrFillingFields(); |
---|
| 1144 | return; |
---|
| 1145 | } |
---|
[1599] | 1146 | |
---|
[2] | 1147 | Element('cc_addr_1').readonly = false; |
---|
| 1148 | Element('cc_addr_1').disabled = false; |
---|
| 1149 | |
---|
| 1150 | Element('cc_addr_2').readonly = false; |
---|
| 1151 | Element('cc_addr_2').disabled = false; |
---|
| 1152 | |
---|
| 1153 | Element('cc_addr_other').readonly = false; |
---|
| 1154 | Element('cc_addr_other').disabled = false; |
---|
| 1155 | |
---|
| 1156 | Element('cc_addr_complement').readonly = false; |
---|
| 1157 | Element('cc_addr_complement').disabled = false; |
---|
| 1158 | |
---|
| 1159 | Element('cc_addr_postal_code').readonly = false; |
---|
| 1160 | Element('cc_addr_postal_code').disabled = false; |
---|
| 1161 | |
---|
| 1162 | Element('cc_addr_po_box').readonly = false; |
---|
| 1163 | Element('cc_addr_po_box').disabled = false; |
---|
| 1164 | |
---|
| 1165 | Element('cc_addr_is_default').readonly = false; |
---|
| 1166 | Element('cc_addr_is_default').disabled = false; |
---|
| 1167 | |
---|
| 1168 | switch (cities.value) |
---|
| 1169 | { |
---|
| 1170 | case '_NONE_': |
---|
| 1171 | newCity.readonly = true; |
---|
| 1172 | newCity.disabled = true; |
---|
| 1173 | newCity.value = ''; |
---|
| 1174 | |
---|
| 1175 | //resetAddrFillingFields(); |
---|
[1599] | 1176 | |
---|
[2] | 1177 | return; |
---|
| 1178 | |
---|
| 1179 | case '_NEW_': |
---|
| 1180 | |
---|
| 1181 | newCity.readonly = false; |
---|
| 1182 | newCity.disabled = false; |
---|
| 1183 | updateAddrNewCityOnMouseOut(); |
---|
[1599] | 1184 | |
---|
[2] | 1185 | break; |
---|
| 1186 | |
---|
| 1187 | case '_SEP_': return; |
---|
| 1188 | |
---|
| 1189 | default: |
---|
| 1190 | newCity.readonly = true; |
---|
| 1191 | newCity.disabled = true; |
---|
| 1192 | newCity.value = ''; |
---|
| 1193 | } |
---|
| 1194 | } |
---|
| 1195 | |
---|
| 1196 | function updateAddrNewCityOnMouseOver () |
---|
| 1197 | { |
---|
[1599] | 1198 | if (Element('cc_addr_cities_new').value == Element('cc_msg_type_city').value && Element('cc_addr_cities').selectedIndex == 1) |
---|
[2] | 1199 | { |
---|
| 1200 | Element('cc_addr_cities_new').value = ''; |
---|
| 1201 | } |
---|
| 1202 | } |
---|
| 1203 | |
---|
| 1204 | function updateAddrNewCityOnMouseOut () |
---|
| 1205 | { |
---|
[1599] | 1206 | if (Element('cc_addr_cities_new').value.length == 0 && Element('cc_addr_cities').selectedIndex == 1) |
---|
[2] | 1207 | { |
---|
| 1208 | Element('cc_addr_cities_new').value = Element('cc_msg_type_city').value; |
---|
| 1209 | } |
---|
| 1210 | } |
---|
| 1211 | |
---|
| 1212 | function saveAddressFields () |
---|
| 1213 | { |
---|
| 1214 | var lastIndex = CC_addr_last_selected; |
---|
| 1215 | |
---|
| 1216 | if (lastIndex == 0) |
---|
| 1217 | { |
---|
| 1218 | return true; |
---|
| 1219 | } |
---|
[1599] | 1220 | |
---|
| 1221 | var addrFields = new Array('cc_addr_1', |
---|
| 1222 | 'cc_addr_2', |
---|
| 1223 | 'cc_addr_complement', |
---|
[2] | 1224 | 'cc_addr_other', |
---|
[1599] | 1225 | 'cc_addr_postal_code', |
---|
[2] | 1226 | 'cc_addr_po_box', |
---|
| 1227 | 'cc_addr_countries', |
---|
| 1228 | 'cc_addr_states', |
---|
| 1229 | 'cc_addr_cities'); |
---|
| 1230 | |
---|
| 1231 | var empty = true; |
---|
[1599] | 1232 | |
---|
[2] | 1233 | for (var i = 0; i < 8; i++) |
---|
| 1234 | { |
---|
| 1235 | var field = Element(addrFields[i]); |
---|
| 1236 | if (field.value && field.value != '_NONE_' && field.value != '_SEP_') |
---|
| 1237 | { |
---|
| 1238 | empty = false; |
---|
| 1239 | } |
---|
| 1240 | } |
---|
[1599] | 1241 | |
---|
[2] | 1242 | if (empty) |
---|
| 1243 | { |
---|
| 1244 | return true; |
---|
| 1245 | } |
---|
| 1246 | |
---|
| 1247 | if (!CC_contact_full_info['addresses']) |
---|
| 1248 | { |
---|
| 1249 | CC_contact_full_info['addresses'] = new Array(); |
---|
| 1250 | } |
---|
| 1251 | |
---|
| 1252 | var addrInfo = CC_contact_full_info['addresses']['address'+Element('cc_addr_types').options[lastIndex].value]; |
---|
| 1253 | |
---|
| 1254 | if (!addrInfo) |
---|
| 1255 | { |
---|
| 1256 | addrInfo = new Array(); |
---|
| 1257 | } |
---|
| 1258 | |
---|
| 1259 | addrInfo['id_address'] = Element('cc_addr_id').value; |
---|
| 1260 | |
---|
| 1261 | switch(Element('cc_addr_countries').value) |
---|
| 1262 | { |
---|
| 1263 | case '_SEP_': |
---|
| 1264 | case '_NONE_': |
---|
| 1265 | addrInfo['id_country'] = false; |
---|
| 1266 | break; |
---|
| 1267 | |
---|
| 1268 | default: |
---|
| 1269 | addrInfo['id_country'] = Element('cc_addr_countries').value; |
---|
[1599] | 1270 | |
---|
[2] | 1271 | } |
---|
| 1272 | |
---|
| 1273 | switch(Element('cc_addr_states').value) |
---|
| 1274 | { |
---|
| 1275 | case '_SEP_': |
---|
| 1276 | case '_NONE_': |
---|
| 1277 | case '_NEW_': |
---|
| 1278 | case '_NOSTATE_': |
---|
| 1279 | addrInfo['id_state'] = false; |
---|
| 1280 | break; |
---|
| 1281 | |
---|
| 1282 | default: |
---|
| 1283 | addrInfo['id_state'] = Element('cc_addr_states').value; |
---|
[1599] | 1284 | |
---|
[2] | 1285 | } |
---|
| 1286 | |
---|
| 1287 | switch(Element('cc_addr_cities').value) |
---|
| 1288 | { |
---|
| 1289 | case '_SEP_': |
---|
| 1290 | case '_NONE_': |
---|
| 1291 | case '_NEW_': |
---|
| 1292 | addrInfo['id_city'] = false; |
---|
| 1293 | break; |
---|
| 1294 | |
---|
| 1295 | default: |
---|
| 1296 | addrInfo['id_city'] = Element('cc_addr_cities').value; |
---|
| 1297 | |
---|
[1599] | 1298 | } |
---|
| 1299 | |
---|
[2] | 1300 | addrInfo['id_typeof_address'] = Element('cc_addr_types').options[lastIndex].value; |
---|
| 1301 | addrInfo['address1'] = Element('cc_addr_1').value ? Element('cc_addr_1').value : false; |
---|
| 1302 | addrInfo['address2'] = Element('cc_addr_2').value ? Element('cc_addr_2').value : false; |
---|
| 1303 | addrInfo['complement'] = Element('cc_addr_complement').value ? Element('cc_addr_complement').value : false; |
---|
| 1304 | addrInfo['address_other'] = Element('cc_addr_other').value ? Element('cc_addr_other').value : false; |
---|
| 1305 | addrInfo['postal_code'] = Element('cc_addr_postal_code').value ? Element('cc_addr_postal_code').value : false; |
---|
| 1306 | addrInfo['po_box'] = Element('cc_addr_po_box').value ? Element('cc_addr_po_box').value : false; |
---|
| 1307 | addrInfo['address_is_default'] = Element('cc_addr_is_default').checked ? '1' : '0'; |
---|
| 1308 | |
---|
| 1309 | CC_contact_full_info['addresses']['address'+Element('cc_addr_types').options[lastIndex].value] = addrInfo; |
---|
| 1310 | |
---|
[1599] | 1311 | if (Element('cc_addr_cities').value == '_NEW_' && |
---|
[2] | 1312 | Element('cc_msg_type_city').value != Element('cc_addr_cities_new').value && |
---|
| 1313 | Element('cc_addr_cities_new').value != '') |
---|
| 1314 | { |
---|
| 1315 | var addrRootInfo = CC_contact_full_info['addresses']['new_cities']; |
---|
[1599] | 1316 | |
---|
[2] | 1317 | if (!addrRootInfo) |
---|
| 1318 | { |
---|
| 1319 | addrRootInfo = new Array(); |
---|
| 1320 | } |
---|
[1599] | 1321 | |
---|
[2] | 1322 | var i = addrRootInfo.length; |
---|
| 1323 | addrRootInfo[addrInfo['id_typeof_address']] = new Array(); |
---|
| 1324 | addrRootInfo[addrInfo['id_typeof_address']]['id_country'] = Element('cc_addr_countries').value; |
---|
| 1325 | addrRootInfo[addrInfo['id_typeof_address']]['id_state'] = Element('cc_addr_states').value.charAt(0) != '_' ? Element('cc_addr_states').value : null; |
---|
| 1326 | addrRootInfo[addrInfo['id_typeof_address']]['city_name'] = Element('cc_addr_cities_new').value; |
---|
| 1327 | CC_contact_full_info['addresses']['new_cities'] = addrRootInfo; |
---|
| 1328 | } |
---|
| 1329 | |
---|
[1599] | 1330 | if (Element('cc_addr_states').value == '_NEW_' && |
---|
| 1331 | Element('cc_msg_type_state').value != Element('cc_addr_states_new').value && |
---|
[2] | 1332 | Element('cc_addr_states_new').value != '') |
---|
| 1333 | { |
---|
| 1334 | var addrRootInfo = CC_contact_full_info['addresses']['new_states']; |
---|
[1599] | 1335 | |
---|
[2] | 1336 | if (!addrRootInfo) |
---|
| 1337 | { |
---|
| 1338 | addrRootInfo = new Array(); |
---|
| 1339 | } |
---|
[1599] | 1340 | |
---|
[2] | 1341 | var i = addrRootInfo.length; |
---|
| 1342 | addrRootInfo[addrInfo['id_typeof_address']] = new Array(); |
---|
| 1343 | addrRootInfo[addrInfo['id_typeof_address']]['id_country'] = Element('cc_addr_countries').value; |
---|
| 1344 | addrRootInfo[addrInfo['id_typeof_address']]['state_name'] = Element('cc_addr_states_new').value; |
---|
| 1345 | CC_contact_full_info['addresses']['new_states'] = addrRootInfo; |
---|
| 1346 | } |
---|
| 1347 | |
---|
| 1348 | return true; |
---|
| 1349 | } |
---|
| 1350 | |
---|
| 1351 | |
---|
| 1352 | /********* End Addresses Functions *********/ |
---|
| 1353 | |
---|
| 1354 | |
---|
| 1355 | |
---|
| 1356 | /********* Begin Connections Functions ************/ |
---|
| 1357 | function connGetHTMLLine () |
---|
| 1358 | { |
---|
| 1359 | var _label = (CC_contact_full_info['connections'] |
---|
| 1360 | && typeof(CC_contact_full_info['connections'][CC_conn_last_selected])!= 'undefined' |
---|
| 1361 | && typeof(CC_contact_full_info['connections'][CC_conn_last_selected][CC_conn_count]) != 'undefined' |
---|
| 1362 | ? CC_contact_full_info['connections'][CC_conn_last_selected][CC_conn_count]['name'] |
---|
| 1363 | : Element("cc_conn_type_sel").value); |
---|
| 1364 | |
---|
| 1365 | var cc_conn_default = Element("cc_phone_default").style.display == '' ? Element("cc_phone_default") : Element("cc_email_default"); |
---|
| 1366 | cc_conn_default.disabled = false; |
---|
| 1367 | var idx_conn = 0; |
---|
| 1368 | for(idx_conn; idx_conn < cc_conn_default.options.length; idx_conn++) |
---|
| 1369 | if(cc_conn_default.options[idx_conn].value == _label) |
---|
[1599] | 1370 | break; |
---|
| 1371 | |
---|
[2] | 1372 | if(idx_conn == cc_conn_default.options.length) |
---|
| 1373 | cc_conn_default.options[idx_conn] = new Option (_label,_label, false,false); |
---|
[1599] | 1374 | |
---|
[2] | 1375 | if (!document.all) |
---|
| 1376 | { |
---|
[1599] | 1377 | if (Element("cc_conn_type_1").checked) |
---|
| 1378 | { |
---|
| 1379 | return '<td style="position: absolute; left: 0; top: 0; z-index: -1; visibility: hidden"><input id="cc_conn_id_' + CC_conn_count + '" type="hidden" value="_NEW_"><input id="cc_conn_is_default_' + CC_conn_count + '" type="hidden" value="false"></td>'+ |
---|
| 1380 | //'<td style="width: 30px;" align="right"><input name="cc_conn_is_default" id="cc_conn_is_default_'+ CC_conn_count +'" type="radio"></td>'+ |
---|
| 1381 | '<td style="width: 10px;" align="right"><input id="cc_conn_name_'+CC_conn_count+'" type="hidden"><td style="width: 100px;" align="right"><span style="width: 150px;" id="cc_conn_label_'+CC_conn_count+'">'+_label+'</span></td>' + |
---|
| 1382 | '<td align="left"><input id="cc_conn_value_'+ CC_conn_count +'" style="width: 150px;" maxlength="100" type="text"> ' + |
---|
| 1383 | '<img align="top" alt="X" src="templates/default/images/x.png" style="width:18px; height:18px" onclick="javascript:removeConnField(\'cc_conn_tr_' + CC_conn_count + '\')"></td>'; |
---|
| 1384 | } |
---|
| 1385 | else if (Element("cc_conn_type_2").checked) |
---|
| 1386 | { |
---|
| 1387 | return '<td style="position: absolute; left: 0; top: 0; z-index: -1; visibility: hidden"><input id="cc_conn_id_' + CC_conn_count + '" type="hidden" value="_NEW_"><input id="cc_conn_is_default_' + CC_conn_count + '" type="hidden" value="false"></td>'+ |
---|
| 1388 | //'<td style="width: 30px;" align="right"><input name="cc_conn_is_default" id="cc_conn_is_default_'+ CC_conn_count +'" type="radio"></td>'+ |
---|
| 1389 | '<td style="width: 10px;" align="right"><input id="cc_conn_name_'+CC_conn_count+'" type="hidden"><td style="width: 100px;" align="right"><span style="width: 150px;" id="cc_conn_label_'+CC_conn_count+'">'+_label+'</span></td>' + |
---|
[1612] | 1390 | '<td align="left"><input id="cc_conn_value_'+ CC_conn_count +'" style="width: 150px;" maxlength="30" type="text" onkeyup="formatPhone(this)"> ' + |
---|
[1599] | 1391 | '<img align="top" alt="X" src="templates/default/images/x.png" style="width:18px; height:18px" onclick="javascript:removeConnField(\'cc_conn_tr_' + CC_conn_count + '\')"></td>'; |
---|
| 1392 | } |
---|
[2] | 1393 | } |
---|
| 1394 | else |
---|
| 1395 | { |
---|
| 1396 | var tds = new Array(); |
---|
| 1397 | var inputs = new Array(); |
---|
| 1398 | var img = document.createElement('img'); |
---|
| 1399 | |
---|
| 1400 | for (var i = 0; i < 4; i++) |
---|
| 1401 | { |
---|
| 1402 | tds[i] = document.createElement('td'); |
---|
| 1403 | } |
---|
| 1404 | |
---|
| 1405 | tds[0].style.position = 'absolute'; |
---|
| 1406 | tds[0].style.visibility = 'hidden'; |
---|
| 1407 | tds[0].style.zIndex = '-1'; |
---|
| 1408 | |
---|
| 1409 | var remove_id = 'cc_conn_tr_'+CC_conn_count; |
---|
| 1410 | img.alt = 'X'; |
---|
| 1411 | img.src = 'templates/default/images/x.png'; |
---|
| 1412 | img.style.width = '18px'; |
---|
| 1413 | img.style.height = '18px'; |
---|
| 1414 | img.align = 'top'; |
---|
| 1415 | img.onclick = function(e){ removeConnField(remove_id);}; |
---|
[1599] | 1416 | |
---|
[2] | 1417 | for (var i = 0; i < 3; i++) |
---|
| 1418 | { |
---|
| 1419 | inputs[i] = document.createElement('input'); |
---|
| 1420 | } |
---|
| 1421 | |
---|
| 1422 | inputs[0].id = 'cc_conn_id_'+CC_conn_count; |
---|
| 1423 | inputs[0].type = 'hidden'; |
---|
| 1424 | inputs[0].value = '_NEW_'; |
---|
| 1425 | |
---|
| 1426 | inputs[1].id = 'cc_conn_name_'+CC_conn_count; |
---|
[1599] | 1427 | inputs[1].type = 'hidden'; |
---|
[2] | 1428 | |
---|
| 1429 | inputs[2].id = 'cc_conn_value_'+CC_conn_count; |
---|
| 1430 | inputs[2].type = 'text'; |
---|
| 1431 | inputs[2].style.width = '150px'; |
---|
| 1432 | |
---|
| 1433 | var _span = document.createElement("SPAN"); |
---|
| 1434 | _span.style.width = "150px"; |
---|
| 1435 | _span.id = "cc_conn_label_"+CC_conn_count; |
---|
| 1436 | _span.innerHTML = _label; |
---|
| 1437 | tds[0].appendChild(inputs[0]); |
---|
| 1438 | tds[1].appendChild(inputs[1]); |
---|
| 1439 | tds[1].align = 'right'; |
---|
| 1440 | tds[1].appendChild(_span); |
---|
| 1441 | tds[2].appendChild(inputs[2]); |
---|
| 1442 | tds[2].align = 'left'; |
---|
| 1443 | tds[2].innerHTML +=" "; |
---|
| 1444 | tds[2].appendChild(img); |
---|
| 1445 | |
---|
| 1446 | return tds; |
---|
| 1447 | } |
---|
| 1448 | } |
---|
| 1449 | |
---|
| 1450 | function connAddNewLine () |
---|
| 1451 | { |
---|
| 1452 | |
---|
| 1453 | var _emptyLine = (!CC_contact_full_info['connections'] |
---|
| 1454 | || typeof(CC_contact_full_info['connections'][CC_conn_last_selected]) == 'undefined' |
---|
| 1455 | || typeof(CC_contact_full_info['connections'][CC_conn_last_selected][CC_conn_count]) == 'undefined'); |
---|
[1599] | 1456 | |
---|
| 1457 | if(_emptyLine) { |
---|
| 1458 | |
---|
[2] | 1459 | if(Element("cc_conn_type_sel").value == '-1'){ |
---|
[1599] | 1460 | return false; |
---|
[2] | 1461 | } |
---|
[1599] | 1462 | |
---|
[2] | 1463 | for(k = 0; k < CC_conn_count; k++) { |
---|
| 1464 | if(Element("cc_conn_name_"+k) && Element("cc_conn_name_"+k).value != "" && Element("cc_conn_name_"+k).value == Element("cc_conn_type_sel").value) { |
---|
[285] | 1465 | alert('Você já possui uma entrada para o tipo "'+Element("cc_conn_type_sel").value+'"!'); |
---|
[1599] | 1466 | Element("cc_conn_type_sel").options.selectedIndex = 0; |
---|
[2] | 1467 | return false; |
---|
| 1468 | } |
---|
| 1469 | } |
---|
[1599] | 1470 | } |
---|
[2] | 1471 | if (!document.all) |
---|
| 1472 | { |
---|
| 1473 | var obj = addHTMLCode('cc_conn', 'cc_conn_tr_'+CC_conn_count, connGetHTMLLine(),'tr'); |
---|
| 1474 | } |
---|
| 1475 | else |
---|
| 1476 | { |
---|
| 1477 | var tds = connGetHTMLLine(); |
---|
| 1478 | var tr = document.createElement('tr'); |
---|
| 1479 | var tbody = Element('cc_conn'); |
---|
| 1480 | |
---|
| 1481 | tr.id = 'cc_conn_tr_'+CC_conn_count; |
---|
| 1482 | tbody.appendChild(tr); |
---|
| 1483 | |
---|
| 1484 | for (var i = 0; i < 4; i++) |
---|
| 1485 | { |
---|
| 1486 | tr.appendChild(tds[i]); |
---|
| 1487 | } |
---|
| 1488 | } |
---|
| 1489 | Element("cc_conn_name_"+CC_conn_count).value = Element("cc_conn_type_sel").value; |
---|
| 1490 | Element("cc_conn_type_sel").options.selectedIndex = 0; |
---|
| 1491 | CC_conn_count++; |
---|
| 1492 | |
---|
| 1493 | return CC_conn_count; |
---|
| 1494 | } |
---|
| 1495 | |
---|
| 1496 | function connRemoveLine(id) |
---|
[1599] | 1497 | { |
---|
[2] | 1498 | var p = Element(id).parentNode; |
---|
| 1499 | var cc_conn_default = Element("cc_phone_default").style.display == '' ? Element("cc_phone_default") : Element("cc_email_default"); |
---|
| 1500 | var _label = Element("cc_conn_label_"+(id.substring(11,13))).innerHTML; |
---|
| 1501 | for(var i = 0;i < cc_conn_default.options.length; i++) { |
---|
| 1502 | if(cc_conn_default.options[i].value == _label) { |
---|
| 1503 | cc_conn_default.options[i] = null; |
---|
| 1504 | break; |
---|
| 1505 | } |
---|
| 1506 | } |
---|
| 1507 | if(cc_conn_default.options.length == 1) |
---|
| 1508 | cc_conn_default.disabled = true; |
---|
| 1509 | |
---|
| 1510 | removeHTMLCode(id); |
---|
| 1511 | |
---|
| 1512 | return; |
---|
| 1513 | connRefreshClass(p.childNodes); |
---|
| 1514 | } |
---|
| 1515 | |
---|
| 1516 | function connRefreshClass(Nodes) |
---|
| 1517 | { |
---|
| 1518 | for (var i = 2; i < Nodes.length; i++) |
---|
| 1519 | { |
---|
| 1520 | Nodes.item(i).className = i % 2 ? 'row_on' : 'row_off'; |
---|
| 1521 | } |
---|
| 1522 | } |
---|
| 1523 | |
---|
| 1524 | function clearConn() |
---|
| 1525 | { |
---|
| 1526 | var connParent = Element('cc_conn').childNodes; |
---|
| 1527 | var i; |
---|
| 1528 | |
---|
| 1529 | for (i = connParent.length - 1; i >= 0; i--) |
---|
| 1530 | { |
---|
| 1531 | if (connParent[i].id) |
---|
| 1532 | { |
---|
| 1533 | connRemoveLine(connParent[i].id); |
---|
| 1534 | } |
---|
| 1535 | } |
---|
[1599] | 1536 | |
---|
[2] | 1537 | CC_conn_count = 0; |
---|
| 1538 | } |
---|
| 1539 | |
---|
| 1540 | function removeConnField(id) |
---|
| 1541 | { |
---|
| 1542 | var count = id.substring(id.lastIndexOf('_')+1); |
---|
| 1543 | if (Element('cc_conn_id_'+count).value != '_NEW_') |
---|
| 1544 | { |
---|
| 1545 | if (typeof(CC_contact_full_info['removed_conns']) != 'object') |
---|
| 1546 | { |
---|
| 1547 | CC_contact_full_info['removed_conns'] = new Array(); |
---|
| 1548 | } |
---|
| 1549 | |
---|
| 1550 | CC_contact_full_info['removed_conns'][CC_contact_full_info['removed_conns'].length] = Element('cc_conn_id_'+count).value; |
---|
| 1551 | } |
---|
| 1552 | |
---|
| 1553 | connRemoveLine(id); |
---|
| 1554 | } |
---|
| 1555 | |
---|
| 1556 | function updateConnFields() |
---|
| 1557 | { |
---|
[1599] | 1558 | |
---|
[2] | 1559 | var connID; |
---|
| 1560 | var i; |
---|
| 1561 | var cc_conn_type_sel = Element("cc_conn_type_sel"); |
---|
| 1562 | var cc_phone_default = Element("cc_phone_default"); |
---|
| 1563 | var cc_email_default = Element("cc_email_default"); |
---|
| 1564 | var div_cc_conn_is_default = Element("div_cc_conn_is_default"); |
---|
| 1565 | var cc_conn_is_default = ''; |
---|
| 1566 | var selected_index = ''; |
---|
[1599] | 1567 | |
---|
[2] | 1568 | cc_conn_type_sel.disabled = false; |
---|
| 1569 | div_cc_conn_is_default.style.display = ""; |
---|
[1599] | 1570 | |
---|
[2] | 1571 | for(var i = 0;i < cc_conn_type_sel.options.length; i++) |
---|
[1599] | 1572 | cc_conn_type_sel.options[i--] = null; |
---|
| 1573 | |
---|
[2] | 1574 | if(Element('cc_conn_type_1').checked) { |
---|
[285] | 1575 | var lang_new_email = Element('cc_msg_new_email').value; |
---|
| 1576 | var lang_main = Element('cc_msg_main').value; |
---|
[1599] | 1577 | var lang_alternative = Element('cc_msg_alternative').value; |
---|
| 1578 | cc_conn_type_sel[0] = new Option(lang_new_email,'-1'); |
---|
[285] | 1579 | cc_conn_type_sel[1] = new Option(lang_main,lang_main); |
---|
[1599] | 1580 | cc_conn_type_sel[2] = new Option(lang_alternative,lang_alternative); |
---|
[2] | 1581 | connID = 1; |
---|
| 1582 | selected_index = cc_email_default.options.selectedIndex; |
---|
| 1583 | for(var i = 0;i < cc_email_default.options.length; i++) { |
---|
| 1584 | cc_email_default.options[i--] = null; |
---|
| 1585 | } |
---|
| 1586 | |
---|
[285] | 1587 | var lang_select_email = Element('cc_msg_select_email').value; |
---|
[1599] | 1588 | cc_email_default.options[0] = new Option(lang_select_email,'-1'); |
---|
[2] | 1589 | cc_phone_default.style.display = 'none'; |
---|
[1599] | 1590 | cc_email_default.style.display = ''; |
---|
[2] | 1591 | cc_conn_is_default = cc_email_default; |
---|
| 1592 | } |
---|
| 1593 | else if(Element('cc_conn_type_2').checked) { |
---|
[285] | 1594 | var lang_new_telephone = Element('cc_msg_new_phone').value; |
---|
| 1595 | var lang_home = Element('cc_msg_home').value; |
---|
| 1596 | var lang_cellphone = Element('cc_msg_cellphone').value; |
---|
| 1597 | var lang_work = Element('cc_msg_work').value; |
---|
| 1598 | var lang_fax = Element('cc_msg_fax').value; |
---|
| 1599 | var lang_pager = Element('cc_msg_pager').value; |
---|
[1517] | 1600 | var lang_corporative_cellphone = Element('cc_msg_corporative_cellphone').value; |
---|
| 1601 | var lang_corporative_fax = Element('cc_msg_corporative_fax').value; |
---|
| 1602 | var lang_corporative_pager = Element('cc_msg_corporative_pager').value; |
---|
[1599] | 1603 | |
---|
| 1604 | cc_conn_type_sel[0] = new Option(lang_new_telephone,'-1'); |
---|
[285] | 1605 | cc_conn_type_sel[1] = new Option(lang_home,lang_home); |
---|
[1599] | 1606 | cc_conn_type_sel[2] = new Option(lang_cellphone,lang_cellphone); |
---|
[285] | 1607 | cc_conn_type_sel[3] = new Option(lang_work,lang_work); |
---|
| 1608 | cc_conn_type_sel[4] = new Option(lang_fax,lang_fax); |
---|
[1517] | 1609 | if (document.getElementById('cc_contact_type').value == 'advanced') { |
---|
| 1610 | cc_conn_type_sel[5] = new Option(lang_pager, lang_pager); |
---|
| 1611 | cc_conn_type_sel[6] = new Option(lang_corporative_cellphone, lang_corporative_cellphone); |
---|
| 1612 | cc_conn_type_sel[7] = new Option(lang_corporative_fax, lang_corporative_fax); |
---|
| 1613 | cc_conn_type_sel[8] = new Option(lang_corporative_pager, lang_corporative_pager); |
---|
| 1614 | } |
---|
[1599] | 1615 | |
---|
[2] | 1616 | connID = 2; |
---|
| 1617 | selected_index = cc_phone_default.options.selectedIndex; |
---|
| 1618 | for(var i = 0;i < cc_phone_default.options.length; i++) { |
---|
| 1619 | cc_phone_default.options[i--] = null; |
---|
| 1620 | } |
---|
| 1621 | |
---|
[1599] | 1622 | var lang_choose_phone = Element('cc_msg_choose_phone').value; |
---|
[285] | 1623 | cc_phone_default.options[0] = new Option(lang_choose_phone,'-1'); |
---|
[2] | 1624 | cc_email_default.style.display = 'none'; |
---|
| 1625 | cc_phone_default.style.display = ''; |
---|
| 1626 | cc_conn_is_default = cc_phone_default; |
---|
| 1627 | } |
---|
[1599] | 1628 | |
---|
[2] | 1629 | Element("cc_conn_type_sel").options.selectedIndex = 0; |
---|
| 1630 | /* First save the data */ |
---|
| 1631 | saveConnFields(); |
---|
| 1632 | |
---|
| 1633 | CC_conn_last_selected = connID; |
---|
[1599] | 1634 | |
---|
[2] | 1635 | clearConn(); |
---|
[1599] | 1636 | |
---|
[2] | 1637 | if (connID == '_NONE_') |
---|
| 1638 | { cc_conn_is_default.disabled = true; |
---|
| 1639 | return; |
---|
| 1640 | } |
---|
[1599] | 1641 | |
---|
[2] | 1642 | /* If no data already available, return */ |
---|
| 1643 | if (!CC_contact_full_info['connections']) |
---|
| 1644 | { |
---|
| 1645 | cc_conn_is_default.disabled = true; |
---|
| 1646 | return; |
---|
| 1647 | } |
---|
| 1648 | cc_conn_is_default.disabled = (!CC_contact_full_info['connections'][connID] || CC_contact_full_info['connections'][connID].length == 0); |
---|
| 1649 | /* Put the information that's already available */ |
---|
| 1650 | for (i in CC_contact_full_info['connections'][connID]) |
---|
| 1651 | { |
---|
| 1652 | var num = connAddNewLine(); |
---|
| 1653 | Element('cc_conn_id_'+i).value = CC_contact_full_info['connections'][connID][i]['id']; |
---|
| 1654 | Element('cc_conn_name_'+i).value = CC_contact_full_info['connections'][connID][i]['name']; |
---|
| 1655 | Element('cc_conn_value_'+i).value = CC_contact_full_info['connections'][connID][i]['value']; |
---|
| 1656 | |
---|
| 1657 | if(!selected_index || (selected_index == '-1' && CC_contact_full_info['connections'][connID][i]['is_default'])){ |
---|
| 1658 | for(var j = 0;j < cc_conn_is_default.options.length; j++){ |
---|
| 1659 | if(cc_conn_is_default.options[j].value == CC_contact_full_info['connections'][connID][i]['name']) { |
---|
| 1660 | selected_index = j; |
---|
| 1661 | break; |
---|
| 1662 | } |
---|
| 1663 | } |
---|
| 1664 | } |
---|
[1599] | 1665 | } |
---|
[2] | 1666 | if(cc_conn_is_default.options.length > selected_index) |
---|
| 1667 | cc_conn_is_default.options.selectedIndex = (selected_index == "-1" ? 0 : selected_index); |
---|
| 1668 | } |
---|
| 1669 | |
---|
| 1670 | function saveConnFields() |
---|
| 1671 | { |
---|
| 1672 | if (CC_conn_last_selected != 0 && CC_conn_last_selected != '_NONE_') |
---|
| 1673 | { |
---|
| 1674 | var nodes = Element('cc_conn').childNodes; |
---|
| 1675 | var k = 0; |
---|
| 1676 | |
---|
| 1677 | if (typeof(CC_contact_full_info['connections']) != 'object' || CC_contact_full_info['connections'] == null) |
---|
| 1678 | { |
---|
| 1679 | CC_contact_full_info['connections'] = new Array(); |
---|
| 1680 | CC_contact_full_info['connections'][CC_conn_last_selected] = new Array(); |
---|
| 1681 | } |
---|
| 1682 | else if (typeof(CC_contact_full_info['connections'][CC_conn_last_selected]) != 'object') |
---|
| 1683 | { |
---|
| 1684 | CC_contact_full_info['connections'][CC_conn_last_selected] = new Array(); |
---|
| 1685 | } |
---|
[1599] | 1686 | else |
---|
[2] | 1687 | { |
---|
| 1688 | delete CC_contact_full_info['connections'][CC_conn_last_selected]; |
---|
| 1689 | CC_contact_full_info['connections'][CC_conn_last_selected] = new Array(); |
---|
| 1690 | } |
---|
| 1691 | |
---|
| 1692 | for (var i = 0; i < nodes.length; i++) |
---|
| 1693 | { |
---|
| 1694 | if (nodes[i].id) |
---|
| 1695 | { |
---|
| 1696 | var subNodes = nodes[i].childNodes; |
---|
| 1697 | var found = false; |
---|
[1599] | 1698 | |
---|
[2] | 1699 | for (var j = 0; j < subNodes.length; j++) |
---|
| 1700 | { |
---|
[1599] | 1701 | if (subNodes[j].childNodes.length > 0 && |
---|
[2] | 1702 | subNodes[j].childNodes[0].id) |
---|
| 1703 | { |
---|
| 1704 | /* Check for the Connection Info array */ |
---|
| 1705 | if (typeof(CC_contact_full_info['connections'][CC_conn_last_selected][k]) != 'object') |
---|
| 1706 | { |
---|
| 1707 | CC_contact_full_info['connections'][CC_conn_last_selected][k] = new Array(); |
---|
| 1708 | } |
---|
[1599] | 1709 | |
---|
[2] | 1710 | if (subNodes[j].childNodes[0].id.indexOf('cc_conn_name') != -1) |
---|
| 1711 | { |
---|
| 1712 | if (subNodes[j].childNodes[0].value) |
---|
| 1713 | { |
---|
| 1714 | CC_contact_full_info['connections'][CC_conn_last_selected][k]['name'] = subNodes[j].childNodes[0].value; |
---|
| 1715 | } |
---|
| 1716 | else |
---|
| 1717 | { |
---|
| 1718 | CC_contact_full_info['connections'][CC_conn_last_selected][k]['name'] = ''; |
---|
| 1719 | } |
---|
| 1720 | } |
---|
| 1721 | else if (subNodes[j].childNodes[0].id.indexOf('cc_conn_value') != -1) |
---|
| 1722 | { |
---|
| 1723 | if (subNodes[j].childNodes[0].value) |
---|
| 1724 | { |
---|
| 1725 | CC_contact_full_info['connections'][CC_conn_last_selected][k]['value'] = subNodes[j].childNodes[0].value; |
---|
| 1726 | } |
---|
| 1727 | else |
---|
| 1728 | { |
---|
[1599] | 1729 | CC_contact_full_info['connections'][CC_conn_last_selected][k]['value'] = ''; |
---|
[2] | 1730 | } |
---|
| 1731 | } |
---|
| 1732 | else if (subNodes[j].childNodes[0].id.indexOf('cc_conn_id') != -1) |
---|
| 1733 | { |
---|
| 1734 | CC_contact_full_info['connections'][CC_conn_last_selected][k]['id'] = subNodes[j].childNodes[0].value; |
---|
| 1735 | } |
---|
| 1736 | |
---|
| 1737 | found = true; |
---|
| 1738 | } |
---|
| 1739 | } |
---|
[1599] | 1740 | |
---|
[2] | 1741 | if (found) |
---|
| 1742 | { |
---|
| 1743 | k++; |
---|
| 1744 | } |
---|
| 1745 | } |
---|
| 1746 | } |
---|
| 1747 | |
---|
| 1748 | if (CC_contact_full_info['connections'].length == 0) |
---|
| 1749 | { |
---|
| 1750 | delete CC_contact_full_info['connections']; |
---|
| 1751 | } |
---|
| 1752 | |
---|
| 1753 | if (CC_contact_full_info['connections'][CC_conn_last_selected].length == 0) |
---|
| 1754 | { |
---|
| 1755 | delete CC_contact_full_info['connections'][CC_conn_last_selected]; |
---|
| 1756 | } |
---|
[1599] | 1757 | |
---|
[2] | 1758 | } |
---|
| 1759 | |
---|
| 1760 | return; |
---|
| 1761 | } |
---|
| 1762 | |
---|
| 1763 | /***********************************************\ |
---|
| 1764 | * VIEW CARDS FUNCTIONS * |
---|
| 1765 | \***********************************************/ |
---|
| 1766 | function removeAllEntries() |
---|
| 1767 | { |
---|
| 1768 | var handler = function (responseText) |
---|
| 1769 | { |
---|
| 1770 | var data = unserialize(responseText); |
---|
| 1771 | if (typeof(data) != 'object') { |
---|
| 1772 | showMessage(Element('cc_msg_err_contacting_server').value); |
---|
| 1773 | return; |
---|
| 1774 | } |
---|
| 1775 | if (data['status'] != 'ok') { |
---|
| 1776 | showMessage(data['msg']); |
---|
| 1777 | return; |
---|
| 1778 | } |
---|
| 1779 | setTimeout('updateCards()',80); |
---|
| 1780 | }; |
---|
| 1781 | var number = randomString().toLowerCase(); |
---|
| 1782 | var result = ''; |
---|
[1599] | 1783 | |
---|
[2] | 1784 | if(!is_ie) |
---|
[285] | 1785 | result = prompt("Essa operação removerá TODOS os seus \ncontatos pessoais, e NÃO PODERÁ ser \ndesfeita. Digite o código abaixo:\n\tCódigo de confirmação: "+number); |
---|
[2] | 1786 | else |
---|
[285] | 1787 | result = prompt("Essa operação removerá TODOS os seus contatos pessoais, e NÃO PODERÁ ser desfeita. Digite o seguinte código de confirmação: "+number,""); |
---|
[2] | 1788 | |
---|
| 1789 | if(result) { |
---|
| 1790 | if(result.toLowerCase() == number) |
---|
| 1791 | Connector.newRequest('removeAllEntries', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=remove_all_entries', 'GET', handler); |
---|
| 1792 | else |
---|
[285] | 1793 | alert('Código Incorreto'); |
---|
[1599] | 1794 | } |
---|
[2] | 1795 | } |
---|
| 1796 | |
---|
| 1797 | function removeEntry(id, type) |
---|
| 1798 | { |
---|
| 1799 | var question = showMessage(type == 'groups' ? Element('cc_msg_group_remove_confirm').value: Element('cc_msg_card_remove_confirm').value, 'confirm'); |
---|
| 1800 | |
---|
| 1801 | if (!question) |
---|
| 1802 | { |
---|
| 1803 | return; |
---|
| 1804 | } |
---|
[1496] | 1805 | |
---|
[2] | 1806 | var handler = function (responseText) |
---|
| 1807 | { |
---|
| 1808 | var data = unserialize(responseText); |
---|
| 1809 | |
---|
| 1810 | if (typeof(data) != 'object') |
---|
| 1811 | { |
---|
| 1812 | showMessage(Element('cc_msg_err_contacting_server').value); |
---|
| 1813 | return; |
---|
| 1814 | } |
---|
[1599] | 1815 | |
---|
[2] | 1816 | if (data['status'] != 'ok') |
---|
| 1817 | { |
---|
| 1818 | showMessage(data['msg']); |
---|
| 1819 | return; |
---|
| 1820 | } |
---|
[1599] | 1821 | |
---|
[2] | 1822 | setTimeout('updateCards()',80);; |
---|
| 1823 | }; |
---|
[1599] | 1824 | |
---|
[2] | 1825 | typeArg = (type == 'groups' ? 'group' : 'entry'); |
---|
[1599] | 1826 | |
---|
[2] | 1827 | Connector.newRequest('removeEntry', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=remove_'+typeArg+'&remove=' + id, 'GET', handler); |
---|
| 1828 | } |
---|
| 1829 | |
---|
| 1830 | function updateCards() |
---|
| 1831 | { |
---|
| 1832 | setHeightSpace(); |
---|
| 1833 | setMaxCards(getMaxCards()); |
---|
| 1834 | showCards(getActualLetter(), getActualPage()); |
---|
| 1835 | } |
---|
| 1836 | |
---|
| 1837 | |
---|
| 1838 | window.onresize = function () |
---|
| 1839 | { |
---|
| 1840 | updateCards(); |
---|
| 1841 | } |
---|
| 1842 | |
---|
| 1843 | |
---|
| 1844 | function setHeightSpace () |
---|
| 1845 | { |
---|
| 1846 | /* |
---|
| 1847 | var w_height = 0; |
---|
| 1848 | var w_extra = 200; |
---|
[1599] | 1849 | |
---|
[2] | 1850 | if (document.body.clientHeight) |
---|
| 1851 | { |
---|
| 1852 | w_height = parseInt(document.body.clientHeight); |
---|
| 1853 | } |
---|
| 1854 | else |
---|
| 1855 | { |
---|
| 1856 | w_height = 500; |
---|
| 1857 | } |
---|
| 1858 | if (w_height < 500) |
---|
| 1859 | { |
---|
| 1860 | w_height = 500; |
---|
| 1861 | } |
---|
| 1862 | Element('cc_card_space').style.height = (w_height - w_extra) + 'px'; |
---|
| 1863 | */ |
---|
| 1864 | } |
---|
| 1865 | |
---|
| 1866 | function selectLetter (letter_id) |
---|
| 1867 | { |
---|
| 1868 | for (var i = 0; i < 28; i++) |
---|
| 1869 | { |
---|
| 1870 | if ( i == letter_id ) |
---|
| 1871 | { |
---|
| 1872 | Element('cc_letter_' + i).className = 'letter_box_active'; |
---|
| 1873 | } |
---|
| 1874 | else |
---|
| 1875 | { |
---|
| 1876 | Element('cc_letter_' + i).className = 'letter_box'; |
---|
| 1877 | } |
---|
| 1878 | } |
---|
| 1879 | } |
---|
| 1880 | |
---|
[284] | 1881 | function clearLetterSelection() |
---|
| 1882 | { |
---|
| 1883 | for (var i = 0; i < 28; i++) |
---|
| 1884 | { |
---|
| 1885 | Element('cc_letter_' + i).className = 'letter_box'; |
---|
| 1886 | } |
---|
| 1887 | } |
---|
[1599] | 1888 | |
---|
[2] | 1889 | function getActualPage () |
---|
| 1890 | { |
---|
| 1891 | return CC_actual_page; |
---|
| 1892 | } |
---|
| 1893 | |
---|
| 1894 | function getActualLetter () |
---|
| 1895 | { |
---|
| 1896 | return CC_actual_letter; |
---|
| 1897 | } |
---|
| 1898 | |
---|
| 1899 | function getFirstPage () |
---|
| 1900 | { |
---|
| 1901 | return 1; |
---|
| 1902 | } |
---|
| 1903 | |
---|
| 1904 | function getPreviousPage () |
---|
| 1905 | { |
---|
| 1906 | if ( CC_actual_page > 1 ) |
---|
| 1907 | { |
---|
| 1908 | return CC_actual_page - 1; |
---|
| 1909 | } |
---|
| 1910 | else |
---|
| 1911 | { |
---|
| 1912 | return 1; |
---|
| 1913 | } |
---|
| 1914 | } |
---|
| 1915 | |
---|
| 1916 | function getNextPage () |
---|
| 1917 | { |
---|
| 1918 | if ( CC_actual_page < CC_npages ) |
---|
| 1919 | { |
---|
| 1920 | return CC_actual_page + 1; |
---|
| 1921 | } |
---|
| 1922 | else |
---|
| 1923 | { |
---|
| 1924 | return CC_npages; |
---|
| 1925 | } |
---|
| 1926 | } |
---|
| 1927 | |
---|
| 1928 | function getLastPage () |
---|
| 1929 | { |
---|
| 1930 | return CC_npages; |
---|
| 1931 | } |
---|
| 1932 | |
---|
| 1933 | function setPages (npages, actual_page, showing_page) |
---|
| 1934 | { |
---|
| 1935 | var html_pages = ''; |
---|
| 1936 | var n_lines = 0; |
---|
| 1937 | var page_count = 0; |
---|
| 1938 | |
---|
| 1939 | if (CC_npages == 0) |
---|
| 1940 | { |
---|
| 1941 | html_pages = ''; |
---|
| 1942 | } |
---|
| 1943 | else |
---|
| 1944 | { |
---|
| 1945 | var page = 1; |
---|
| 1946 | if (showing_page > 10 || (!showing_page && actual_page > 10)) |
---|
| 1947 | { |
---|
| 1948 | var final_page = showing_page? showing_page-11 : actual_page-11; |
---|
| 1949 | if (final_page < 1) |
---|
| 1950 | { |
---|
| 1951 | final_page = 1; |
---|
| 1952 | } |
---|
[1599] | 1953 | |
---|
[2] | 1954 | html_pages += '<a href="javascript:setPages('+npages+', '+ actual_page +', '+ final_page +')">...</a> '; |
---|
| 1955 | |
---|
| 1956 | page = showing_page ? showing_page : actual_page; |
---|
| 1957 | } |
---|
[1599] | 1958 | |
---|
[2] | 1959 | for (; page <= npages; page++) |
---|
| 1960 | { |
---|
| 1961 | if (page_count > 10) |
---|
| 1962 | { |
---|
| 1963 | html_pages += '<a href="javascript:setPages('+npages+', '+ actual_page +', '+ page +');">...</a>'; |
---|
| 1964 | break; |
---|
| 1965 | } |
---|
| 1966 | if ( page == actual_page ) |
---|
| 1967 | { |
---|
| 1968 | html_pages += '<b>'+page+'</b>'; |
---|
| 1969 | } |
---|
| 1970 | else |
---|
| 1971 | { |
---|
| 1972 | html_pages += '<a href="javascript:showCards(\'' + CC_actual_letter + '\',' + page + ')">' + page + '</a>'; |
---|
| 1973 | } |
---|
| 1974 | html_pages += ' '; |
---|
| 1975 | page_count++; |
---|
| 1976 | } |
---|
| 1977 | } |
---|
| 1978 | |
---|
| 1979 | if (actual_page <= 1) |
---|
| 1980 | { |
---|
| 1981 | Element('cc_panel_arrow_first').onclick = ''; |
---|
| 1982 | Element('cc_panel_arrow_previous').onclick = ''; |
---|
| 1983 | Element('cc_panel_arrow_first').style.cursor = 'auto'; |
---|
| 1984 | Element('cc_panel_arrow_previous').style.cursor = 'auto'; |
---|
| 1985 | } |
---|
| 1986 | else |
---|
| 1987 | { |
---|
| 1988 | Element('cc_panel_arrow_first').onclick = function (event) { showCards(getActualLetter(), getFirstPage()); }; |
---|
| 1989 | Element('cc_panel_arrow_previous').onclick = function (event) { showCards(getActualLetter(), getPreviousPage()); }; |
---|
| 1990 | if (is_mozilla) |
---|
| 1991 | { |
---|
| 1992 | Element('cc_panel_arrow_first').style.cursor = 'pointer'; |
---|
| 1993 | Element('cc_panel_arrow_previous').style.cursor = 'pointer'; |
---|
| 1994 | } |
---|
| 1995 | Element('cc_panel_arrow_first').style.cursor = 'hand'; |
---|
| 1996 | Element('cc_panel_arrow_previous').style.cursor = 'hand'; |
---|
| 1997 | } |
---|
| 1998 | |
---|
| 1999 | if (actual_page == CC_npages) |
---|
| 2000 | { |
---|
| 2001 | Element('cc_panel_arrow_next').onclick = ''; |
---|
| 2002 | Element('cc_panel_arrow_last').onclick = ''; |
---|
| 2003 | Element('cc_panel_arrow_next').style.cursor = 'auto'; |
---|
| 2004 | Element('cc_panel_arrow_last').style.cursor = 'auto'; |
---|
| 2005 | } |
---|
| 2006 | else |
---|
| 2007 | { |
---|
| 2008 | Element('cc_panel_arrow_next').onclick = function (event) { showCards(getActualLetter(), getNextPage()); }; |
---|
| 2009 | Element('cc_panel_arrow_last').onclick = function (event) { showCards(getActualLetter(), getLastPage()); }; |
---|
| 2010 | if (is_mozilla) |
---|
| 2011 | { |
---|
| 2012 | Element('cc_panel_arrow_next').style.cursor = 'pointer'; |
---|
| 2013 | Element('cc_panel_arrow_last').style.cursor = 'pointer'; |
---|
| 2014 | } |
---|
| 2015 | Element('cc_panel_arrow_next').style.cursor = 'hand'; |
---|
| 2016 | Element('cc_panel_arrow_last').style.cursor = 'hand'; |
---|
| 2017 | } |
---|
[1599] | 2018 | |
---|
[2] | 2019 | Element('cc_panel_pages').innerHTML = html_pages; |
---|
| 2020 | } |
---|
| 2021 | |
---|
| 2022 | function populateCards(data, type) |
---|
| 2023 | { |
---|
[285] | 2024 | if (data[3].length >= 100 ) |
---|
| 2025 | { |
---|
| 2026 | alert("Critério de pesquisa muito abrangente, achados " + data[3].length + " resultados"); |
---|
| 2027 | for (i = 0; i < (Math.sqrt(data[3].length)-1); i++) |
---|
| 2028 | for (j = 0; j < 3; j++) |
---|
| 2029 | document.getElementById("cc_card:"+j+":"+i).innerHTML = ''; |
---|
[1599] | 2030 | return false; |
---|
[285] | 2031 | } |
---|
[1599] | 2032 | |
---|
| 2033 | if(type == 'groups' || type =='shared_groups') |
---|
[752] | 2034 | return populateGroupsInCards(data,type); |
---|
[1599] | 2035 | |
---|
[2] | 2036 | var pos = 0; |
---|
| 2037 | var ncards = data[3].length; |
---|
[1599] | 2038 | |
---|
[2] | 2039 | if (typeof(data[3]) == 'object' && ncards > 0) |
---|
| 2040 | { |
---|
| 2041 | for (var i = 0; i < CC_max_cards[1]; i++) |
---|
| 2042 | { |
---|
| 2043 | for (var j = 0; j < CC_max_cards[0]; j++) |
---|
| 2044 | { |
---|
| 2045 | id = 'cc_card:'+j+':'+i; |
---|
[1599] | 2046 | |
---|
[2] | 2047 | for (var k = 0; k < data[2].length; k++) |
---|
| 2048 | { |
---|
[285] | 2049 | if(!(ccTree.catalog_perms & 2)) |
---|
| 2050 | { |
---|
| 2051 | switch(data[2][k]) |
---|
| 2052 | { |
---|
| 2053 | case 'cc_mail' : |
---|
[2] | 2054 | |
---|
[285] | 2055 | if(data[3][pos][k] === 'none') |
---|
| 2056 | data[3][pos][k] = ' '; |
---|
| 2057 | break; |
---|
| 2058 | case 'cc_phone' : |
---|
| 2059 | |
---|
| 2060 | if(data[3][pos][k] === 'none') |
---|
| 2061 | data[3][pos][k] = ' '; |
---|
| 2062 | break; |
---|
| 2063 | } |
---|
[1599] | 2064 | |
---|
[285] | 2065 | } |
---|
[1599] | 2066 | |
---|
| 2067 | |
---|
[285] | 2068 | /*if(data[2][k] == 'cc_mail' && data[3][pos][k] == 'none' && !(ccTree.catalog_perms & 2) ) { |
---|
[2] | 2069 | Element(id).style.display = 'none'; |
---|
| 2070 | continue; |
---|
[285] | 2071 | }*/ |
---|
[1599] | 2072 | |
---|
[2] | 2073 | if(data[3][pos][k] != 'none') |
---|
| 2074 | { |
---|
[1650] | 2075 | data[3][pos][k] = unescape(data[3][pos][k]); |
---|
[2] | 2076 | switch (data[2][k]) |
---|
| 2077 | { |
---|
| 2078 | case 'cc_name': |
---|
| 2079 | if (data[3][pos][k].length > 50) |
---|
| 2080 | { |
---|
| 2081 | Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 50); |
---|
| 2082 | Element(id+':'+data[2][k]).title = data[3][pos][k]; |
---|
| 2083 | } |
---|
| 2084 | else |
---|
| 2085 | { |
---|
| 2086 | Element(id+':'+data[2][k]).innerHTML = data[3][pos][k]; |
---|
| 2087 | } |
---|
[1599] | 2088 | if(data[3][pos][12]) |
---|
| 2089 | Element(id+':'+data[2][k]).innerHTML += "<br><span style='margin-left:30px'><font size='-2' color='#808080'><i>"+data[3][pos][12]+"</i></font></span>"; |
---|
[2] | 2090 | break; |
---|
[1599] | 2091 | |
---|
[2] | 2092 | case 'cc_mail': |
---|
| 2093 | if (data[3][pos][k].length > (CC_visual == 'table' ? 50 : 20)) |
---|
| 2094 | { |
---|
| 2095 | Element(id+':'+data[2][k]).innerHTML = data[5] + data[3][pos][k] + '\')">'+ adjustString(data[3][pos][k], (CC_visual == 'table' ? 50 : 20))+'</span>'; |
---|
| 2096 | Element(id+':'+data[2][k]).title = data[3][pos][k]; |
---|
| 2097 | } |
---|
| 2098 | else |
---|
| 2099 | { |
---|
[1599] | 2100 | Element(id+':'+data[2][k]).innerHTML = data[5] + data[3][pos][k] + '\')">'+ data[3][pos][k]+'</span>'; |
---|
[2] | 2101 | } |
---|
| 2102 | break; |
---|
[1599] | 2103 | |
---|
[2] | 2104 | case 'cc_phone': |
---|
| 2105 | if (data[3][pos][k].length > 20) |
---|
| 2106 | { |
---|
| 2107 | Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20); |
---|
| 2108 | Element(id+':'+data[2][k]).title = data[3][pos][k]; |
---|
| 2109 | } |
---|
| 2110 | else |
---|
| 2111 | { |
---|
| 2112 | Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20); |
---|
| 2113 | } |
---|
[1613] | 2114 | Element(id+':cc_phone').innerHTML = (data[3][pos][k].length < 23) ? data[3][pos][k]:data[3][pos][k].substr(0,22)+"<br>"+data[3][pos][k].substr(22,data[3][pos][k].length); |
---|
[2] | 2115 | break; |
---|
| 2116 | |
---|
| 2117 | case 'cc_title': |
---|
| 2118 | if (data[3][pos][k].length > 15) |
---|
| 2119 | { |
---|
| 2120 | Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 15); |
---|
| 2121 | Element(id+':'+data[2][k]).title = data[3][pos][k]; |
---|
| 2122 | } |
---|
| 2123 | else |
---|
| 2124 | { |
---|
| 2125 | Element(id+':'+data[2][k]).innerHTML = data[3][pos][k]; |
---|
| 2126 | } |
---|
| 2127 | break; |
---|
| 2128 | |
---|
| 2129 | case 'cc_id': |
---|
| 2130 | var id_contact = data[3][pos][k]; |
---|
| 2131 | Element(id+':'+data[2][k]).value = data[3][pos][k]; |
---|
[12] | 2132 | Element(id+':cc_photo').src = '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_photo' + (data[4][pos] != 0 ? '&id='+data[3][pos][k] : ''); |
---|
[2] | 2133 | if(ccTree.catalog_perms == 1) |
---|
[285] | 2134 | Element(id+':cc_icon_data').innerHTML = '<span title="'+Element('cc_msg_copy_to_catalog').value+'" id="' + id + ':ccQuickAdd" onmouseout="window.status=\'\';" onclick="ccQuickAddContact.showList(\''+ Element(id+':cc_id').value + '\');return true;" style="cursor: pointer; cursor: hand; z-index: 1"><img src="templates/default/images/address-conduit-16.png" align="center"></span>'; |
---|
[2] | 2135 | break; |
---|
| 2136 | |
---|
| 2137 | case 'cc_forwarding_address': |
---|
[880] | 2138 | var account_type = data[3][pos][k]; |
---|
[1599] | 2139 | |
---|
[880] | 2140 | if( !account_type) |
---|
[2] | 2141 | break; |
---|
[4275] | 2142 | else |
---|
[4305] | 2143 | if (account_type == 'list' || account_type == 'group') |
---|
[4275] | 2144 | icon = '<img src="templates/default/images/people-mini.png" align="center">'; |
---|
| 2145 | else |
---|
| 2146 | icon = ''; |
---|
| 2147 | |
---|
| 2148 | Element(id+':cc_icon_group').innerHTML = '<span title="'+Element('cc_participants').value+'" onmouseout="window.status=\'\';" onclick="ccListParticipants.showList(\''+ Element(id+':cc_id').value + '\',null,null,null,\''+account_type+'\');return true;" style="cursor: pointer; cursor: hand; z-index: 1">'+icon+' </span>'; |
---|
| 2149 | break; |
---|
[1599] | 2150 | |
---|
[2] | 2151 | |
---|
[1599] | 2152 | //Para tratar tamanho do campo "celular" do empregado |
---|
| 2153 | case 'cc_mobile': |
---|
| 2154 | if (data[3][pos][k].length > 20) |
---|
| 2155 | { |
---|
| 2156 | Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20); |
---|
| 2157 | Element(id+':'+data[2][k]).title = data[3][pos][k]; |
---|
| 2158 | } |
---|
| 2159 | else |
---|
| 2160 | { |
---|
| 2161 | Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20); |
---|
| 2162 | } |
---|
| 2163 | Element(id+':cc_mobile').innerHTML = data[3][pos][k]; |
---|
| 2164 | break; |
---|
| 2165 | |
---|
| 2166 | //Para tratar tamanho do campo "matricula" do empregado |
---|
| 2167 | case 'cc_empNumber': |
---|
| 2168 | if (data[3][pos][k].length > 20) |
---|
| 2169 | { |
---|
| 2170 | Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20); |
---|
| 2171 | Element(id+':'+data[2][k]).title = data[3][pos][k]; |
---|
| 2172 | } |
---|
| 2173 | else |
---|
| 2174 | { |
---|
| 2175 | Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 20); |
---|
| 2176 | } |
---|
| 2177 | Element(id+':cc_empNumber').innerHTML = data[3][pos][k]; |
---|
| 2178 | break; |
---|
| 2179 | |
---|
| 2180 | //Para tratar tamanho do campo "departamento" do empregado |
---|
| 2181 | case 'cc_department': |
---|
| 2182 | if (data[3][pos][k].length > 15) |
---|
| 2183 | { |
---|
| 2184 | Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 15); |
---|
| 2185 | Element(id+':'+data[2][k]).title = data[3][pos][k]; |
---|
| 2186 | } |
---|
| 2187 | else |
---|
| 2188 | { |
---|
| 2189 | Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 15); |
---|
| 2190 | } |
---|
| 2191 | Element(id+':cc_department').innerHTML = data[3][pos][k]; |
---|
| 2192 | break; |
---|
| 2193 | |
---|
[2] | 2194 | default: |
---|
| 2195 | if (data[3][pos][k].length > 10) |
---|
| 2196 | { |
---|
| 2197 | Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 10); |
---|
| 2198 | Element(id+':'+data[2][k]).title = data[3][pos][k]; |
---|
| 2199 | } |
---|
| 2200 | else |
---|
| 2201 | { |
---|
[1599] | 2202 | if (Element(id+':'+data[2][k]) == null) alert('É nulo'); |
---|
[2] | 2203 | Element(id+':'+data[2][k]).innerHTML = data[3][pos][k]; |
---|
| 2204 | } |
---|
| 2205 | } |
---|
| 2206 | } |
---|
[1599] | 2207 | } |
---|
| 2208 | |
---|
[752] | 2209 | if (type == "shared_contacts") { |
---|
[1599] | 2210 | if (data[3][pos][11] & 4) |
---|
[503] | 2211 | eval("document.getElementById(id + ':cc_card_edit').onclick = function(){editSharedContact(Element('"+id+"' + ':cc_id').value);};"); |
---|
| 2212 | else |
---|
| 2213 | document.getElementById(id + ':cc_card_edit').onclick = function(){ |
---|
| 2214 | alert(Element('cc_msg_not_allowed').value); |
---|
| 2215 | }; |
---|
[1599] | 2216 | if (data[3][pos][11] & 8) |
---|
[503] | 2217 | eval("document.getElementById(id + ':cc_card_remove').onclick = function(){removeEntry(Element('" + id + "' + ':cc_id').value);};"); |
---|
| 2218 | else |
---|
| 2219 | document.getElementById(id + ':cc_card_remove').onclick = function(){ |
---|
| 2220 | alert(Element('cc_msg_not_allowed').value); |
---|
| 2221 | }; |
---|
| 2222 | } |
---|
[1599] | 2223 | |
---|
[2] | 2224 | if (--ncards == 0) |
---|
| 2225 | { |
---|
| 2226 | j = CC_max_cards[0]; |
---|
| 2227 | i = CC_max_cards[1]; |
---|
| 2228 | } |
---|
[1599] | 2229 | |
---|
[2] | 2230 | pos++; |
---|
| 2231 | } |
---|
| 2232 | } |
---|
| 2233 | } |
---|
| 2234 | } |
---|
| 2235 | |
---|
[752] | 2236 | function populateGroupsInCards(data,type) |
---|
[1599] | 2237 | { |
---|
[2] | 2238 | var pos = 0; |
---|
[1599] | 2239 | var contacts = data[5]; |
---|
[2] | 2240 | var ncards = data[3].length; |
---|
[1599] | 2241 | |
---|
[2] | 2242 | if (typeof(data[3]) == 'object' && ncards > 0) |
---|
| 2243 | { |
---|
| 2244 | for (var i = 0; i < CC_max_cards[1]; i++) |
---|
| 2245 | { |
---|
| 2246 | for (var j = 0; j < CC_max_cards[0]; j++) |
---|
| 2247 | { |
---|
| 2248 | id = 'cc_card:'+j+':'+i; |
---|
[1599] | 2249 | |
---|
[2] | 2250 | for (var k = 0; k < data[2].length; k++) |
---|
| 2251 | { |
---|
[1599] | 2252 | |
---|
[2] | 2253 | if(data[3][pos][k] != 'none') |
---|
[1599] | 2254 | { |
---|
| 2255 | |
---|
[2] | 2256 | switch (data[2][k]) |
---|
[1599] | 2257 | { |
---|
[2] | 2258 | case 'cc_title': |
---|
| 2259 | if (data[3][pos][k].length > 50) |
---|
| 2260 | { |
---|
| 2261 | Element(id+':'+data[2][k]).innerHTML = adjustString(data[3][pos][k], 50); |
---|
| 2262 | Element(id+':'+data[2][k]).title = data[3][pos][k]; |
---|
| 2263 | } |
---|
| 2264 | else |
---|
| 2265 | { |
---|
| 2266 | Element(id+':'+data[2][k]).innerHTML = data[3][pos][k]; |
---|
| 2267 | } |
---|
[752] | 2268 | if(data[3][pos][5]) |
---|
| 2269 | Element(id+':'+data[2][k]).innerHTML += "<br><span style='margin-left:30px'><font size='-2' color='#808080'><i>"+data[3][pos][5]+"</i></font></span>"; |
---|
[2] | 2270 | break; |
---|
[1599] | 2271 | |
---|
[2] | 2272 | case 'cc_short_name': |
---|
| 2273 | if (data[3][pos][k].length > (CC_visual == 'table' ? 50 : 20)) |
---|
| 2274 | { |
---|
[752] | 2275 | Element(id+':'+data[2][k]).innerHTML = data[5] + ''+data[3][pos][k]+'::'+data[3][pos][6] +'\')">'+adjustString(data[3][pos][k], (CC_visual == 'table' ? 50 : 20))+'</span>'; |
---|
[2] | 2276 | Element(id+':'+data[2][k]).title = data[3][pos][k]; |
---|
| 2277 | } |
---|
| 2278 | else |
---|
| 2279 | { |
---|
[752] | 2280 | Element(id+':'+data[2][k]).innerHTML = data[5] + ''+data[3][pos][k]+(data[3][pos][6] ? '::'+data[3][pos][6] : "") + '\')">'+data[3][pos][k]+'</span>'; |
---|
[2] | 2281 | } |
---|
| 2282 | break; |
---|
[1599] | 2283 | |
---|
[2] | 2284 | case 'cc_contacts': |
---|
| 2285 | |
---|
| 2286 | var id_group = data[3][pos][k-1]; |
---|
| 2287 | var title = data[3][pos][k-3]; |
---|
| 2288 | contacts = data[3][pos][k]; |
---|
| 2289 | var contact = ""; |
---|
| 2290 | var email = ""; |
---|
| 2291 | |
---|
[1599] | 2292 | for (var d = 0; d < contacts.length; d++) { |
---|
[2] | 2293 | contact += contacts[d]['names_ordered']+ ","; |
---|
| 2294 | email += contacts[d]['connection_value']+","; |
---|
| 2295 | } |
---|
[1599] | 2296 | |
---|
[2] | 2297 | Element(id+':cc_participantes').innerHTML = '<span title="Ver Participantes" id="' + id + ':ccQuickAdd" onmouseout="window.status=\'\';" onclick="ccListParticipants.showList(\''+ Element(id+':cc_id').value+'value\', \''+contact+'\', \''+email+'\', \''+title+'\', \''+id_group+'\');return true;" style="cursor: pointer; cursor: hand; z-index: 1"><img title="Ver participantes" align="center" src="templates/default/images/people-mini.png">  </span>'; |
---|
[1599] | 2298 | |
---|
[2] | 2299 | break; |
---|
[1599] | 2300 | |
---|
[2] | 2301 | case 'cc_id': |
---|
| 2302 | var id_contact = data[3][pos][k]; |
---|
| 2303 | Element(id+':'+data[2][k]).value = data[3][pos][k]; |
---|
[1599] | 2304 | |
---|
[2] | 2305 | break; |
---|
[1599] | 2306 | |
---|
[2] | 2307 | } |
---|
| 2308 | } |
---|
| 2309 | } |
---|
[1599] | 2310 | |
---|
[752] | 2311 | if (type == "shared_groups") { |
---|
[1280] | 2312 | |
---|
[752] | 2313 | if (data[3][pos][4] & 4) |
---|
[1280] | 2314 | eval("document.getElementById(id + ':cc_card_edit').onclick = function(){editSharedGroup(Element('"+id+"' + ':cc_id').value,"+data[3][pos][7]+");};"); |
---|
| 2315 | else |
---|
| 2316 | document.getElementById(id + ':cc_card_edit').onclick = function(){ alert(Element('cc_msg_not_allowed').value); }; |
---|
| 2317 | |
---|
[752] | 2318 | if (data[3][pos][4] & 8) |
---|
| 2319 | eval("document.getElementById(id + ':cc_card_remove').onclick = function(){removeEntry(Element('" + id + "' + ':cc_id').value,'groups');};"); |
---|
| 2320 | else |
---|
| 2321 | document.getElementById(id + ':cc_card_remove').onclick = function(){ |
---|
| 2322 | alert(Element('cc_msg_not_allowed').value); |
---|
| 2323 | }; |
---|
| 2324 | } |
---|
[1599] | 2325 | |
---|
[2] | 2326 | if (--ncards == 0) |
---|
| 2327 | { |
---|
| 2328 | j = CC_max_cards[0]; |
---|
| 2329 | i = CC_max_cards[1]; |
---|
| 2330 | } |
---|
[1599] | 2331 | |
---|
[2] | 2332 | pos++; |
---|
| 2333 | } |
---|
| 2334 | } |
---|
| 2335 | } |
---|
| 2336 | } |
---|
| 2337 | |
---|
| 2338 | function adjustString (str, max_chars) |
---|
| 2339 | { |
---|
| 2340 | if (str.length > max_chars) |
---|
| 2341 | { |
---|
| 2342 | return str.substr(0,max_chars) + '...'; |
---|
| 2343 | } |
---|
| 2344 | else |
---|
| 2345 | { |
---|
| 2346 | return str; |
---|
| 2347 | } |
---|
| 2348 | } |
---|
| 2349 | |
---|
| 2350 | function setMaxCards (maxcards) |
---|
| 2351 | { |
---|
| 2352 | CC_max_cards = maxcards; |
---|
| 2353 | ncards = maxcards[0] * maxcards[1]; |
---|
| 2354 | |
---|
| 2355 | var handler = function (responseText) |
---|
| 2356 | { |
---|
| 2357 | showMessage('ok'); |
---|
| 2358 | }; |
---|
| 2359 | |
---|
[1599] | 2360 | Connector.newRequest('setMaxCards', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=set_n_cards&ncards=' + ncards, 'GET'); |
---|
[2] | 2361 | } |
---|
| 2362 | |
---|
| 2363 | function getMaxCards () |
---|
| 2364 | { |
---|
| 2365 | var coord = new Array(); |
---|
[1599] | 2366 | |
---|
[2] | 2367 | card_space_width = parseInt(Element('cc_main').offsetWidth) - parseInt(Element('cc_left').offsetWidth) - parseInt(CC_card_extra); |
---|
| 2368 | card_space_height = parseInt(Element('cc_card_space').offsetHeight) - parseInt(CC_card_extra); |
---|
[1599] | 2369 | |
---|
[2] | 2370 | card_width = CC_card_image_width + CC_card_extra; |
---|
| 2371 | card_height = CC_card_image_height + CC_card_extra; |
---|
| 2372 | |
---|
| 2373 | ncols = parseInt(card_space_width / card_width); |
---|
| 2374 | nlines = parseInt(card_space_height / card_height); |
---|
[1599] | 2375 | |
---|
[2] | 2376 | coord[0] = ncols; |
---|
| 2377 | coord[1] = 10; |
---|
| 2378 | |
---|
| 2379 | return coord; |
---|
| 2380 | } |
---|
| 2381 | |
---|
| 2382 | function getCardHTML (id, type) |
---|
| 2383 | { |
---|
[752] | 2384 | if(type == 'groups' || type == 'shared_groups') { |
---|
[503] | 2385 | html_card = '<td id="' + id + '" style="width: ' + CC_card_image_width + 'px; height: ' + CC_card_image_height + '">' + |
---|
[1599] | 2386 | '<div style="border: 0px solid #999; position: relative;">' + |
---|
[503] | 2387 | '<img src="templates/default/images/card.png" border="0" width="' + CC_card_image_width +'" height="' + CC_card_image_height + '"i ondblclick="editContact(Element(\'' + id + ':cc_id\').value);">' + |
---|
| 2388 | '<img title="'+Element('cc_msg_group_edit').value+'" id="' + id + ':cc_card_edit" style="position: absolute; top: 35px; left: 222px; width: 18px; height: 18px; cursor: pointer; cursor: hand; z-index: 1" onclick="editGroup(Element(\'' + id + ':cc_id\').value);" onmouseover="resizeIcon(\''+id+':cc_card_edit\',0)" onmouseout="resizeIcon(\''+id+':cc_card_edit\',1)" src="templates/default/images/cc_card_edit.png">' + |
---|
[1599] | 2389 | '<img title="'+Element('cc_msg_group_remove').value+'" id="' + id + ':cc_card_remove" style="position: absolute; top: 78px; left: 223px; width: 15px; height: 14px; cursor: pointer; cursor: hand; z-index: 1" onclick="removeEntry(Element(\'' + id + ':cc_id\').value,\'groups\');" onmouseover="resizeIcon(\''+id+':cc_card_remove\',0)" onmouseout="resizeIcon(\''+id+':cc_card_remove\',1)" src="templates/default/images/cc_x.png">' + |
---|
[503] | 2390 | '<span id="' + id + ':cc_title" style="position: absolute; top: 30px; left: 75px; width: 135px; border: 0px solid #999; font-weight: bold; font-size: 10px; text-align: center; height: 10px;" onmouseover="//Element(\''+id+':cc_name_full\').style.visibility=\'visible\'" onmouseout="//Element(\''+id+':cc_name_full\').style.visibility=\'hidden\'"></span>' + |
---|
| 2391 | '<span id="' + id + ':cc_participantes" style="cursor: pointer; cursor: hand; z-index: 1;position: absolute; top: 15px; left: 15px"></span>' + |
---|
[752] | 2392 | '<span onMouseOver="this.title = \''+Element('cc_send_mail').value+'\'" id="' + id + ':cc_short_name" style="position: absolute; top: 105px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' + |
---|
[503] | 2393 | '<input id="' + id + ':cc_id" type="hidden">' + |
---|
| 2394 | '</div>' + '</td>'; |
---|
[1599] | 2395 | |
---|
[503] | 2396 | } |
---|
| 2397 | else { |
---|
[2] | 2398 | html_card = '<td id="' + id + '" style="width: ' + CC_card_image_width + 'px; height: ' + CC_card_image_height + '">' + |
---|
| 2399 | '<div style="border: 0px solid #999; position: relative;">' + |
---|
[1599] | 2400 | '<img src="templates/default/images/card.png" border="0" width="' + CC_card_image_width +'" height="' + CC_card_image_height + '"i ondblclick="editContact(Element(\'' + id + ':cc_id\').value);">' + |
---|
[2] | 2401 | ( ccTree.catalog_perms == 1 ? |
---|
| 2402 | '<span id="' + id + ':cc_icon_data" style="position: absolute; top: 35px; left: 222px; width: 18px; height: 18px; cursor: pointer; cursor: hand; z-index: 1"></span>':'') + |
---|
| 2403 | (ccTree.catalog_perms & 2 ? |
---|
| 2404 | '<img title="'+Element('cc_msg_card_edit').value+'" id="' + id + ':cc_card_edit" style="position: absolute; top: 35px; left: 222px; width: 18px; height: 18px; cursor: pointer; cursor: hand; z-index: 1" onclick="editContact(Element(\'' + id + ':cc_id\').value);" onmouseover="resizeIcon(\''+id+':cc_card_edit\',0)" onmouseout="resizeIcon(\''+id+':cc_card_edit\',1)" src="templates/default/images/cc_card_edit.png">' + |
---|
| 2405 | '<img title="'+Element('cc_msg_card_remove').value+'" id="' + id + ':cc_card_remove" style="position: absolute; top: 78px; left: 223px; width: 15px; height: 14px; cursor: pointer; cursor: hand; z-index: 1" onclick="removeEntry(Element(\'' + id + ':cc_id\').value);" onmouseover="resizeIcon(\''+id+':cc_card_remove\',0)" onmouseout="resizeIcon(\''+id+':cc_card_remove\',1)" src="templates/default/images/cc_x.png">' : '') + |
---|
[1599] | 2406 | '<img id="' + id + ':cc_photo" style="position: absolute; top: 15px; left: 7px;" src="" border="0" ondblclick="editContact(Element(\'' + id + ':cc_id\').value);">' + |
---|
[2] | 2407 | '<span id="' + id + ':cc_company" style="position: absolute; top: 5px; left: 75px; width: 135px; border: 0px solid #999; font-weight: bold; font-size: 14px; text-align: center; height: 10px;" onmouseover="//Element(\''+id+':cc_company_full\').style.visibility=\'visible\'" onmouseout="//Element(\''+id+':cc_company_full\').style.visibility=\'hidden\'"></span>' + |
---|
[1599] | 2408 | '<span style="cursor: pointer; cursor: hand; z-index: 1;position: absolute; top: 100px; left: 35px" valign="bottom" id="' + id + ':cc_icon_group"> </span>'+ |
---|
| 2409 | //Para exibir a matricula do empregado nos cartoes |
---|
| 2410 | '<span id="' + id + ':cc_empNumber" style="position: absolute; top: 15px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 9px; text-align: center; height: 10px;"></span>' + |
---|
| 2411 | '<span id="' + id + ':cc_name" style="position: absolute; top: 30px; left: 75px; width: 135px; border: 0px solid #999; font-weight: bold; font-size: 10px; text-align: center; height: 10px;" onmouseover="//Element(\''+id+':cc_name_full\').style.visibility=\'visible\'" onmouseout="//Element(\''+id+':cc_name_full\').style.visibility=\'hidden\'"></span>' + |
---|
| 2412 | '<span id="' + id + ':cc_title" style="position: absolute; top: 50px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 12px; text-align: center; height: 10px;"></span>' + |
---|
| 2413 | //Para exibir o setor/lotacao do empregado nos cartoes |
---|
| 2414 | '<span id="' + id + ':cc_department" style="position: absolute; top: 60px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' + |
---|
| 2415 | '<span id="' + id + ':cc_phone" style="position: absolute; top: 75px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' + |
---|
| 2416 | //Para exibir o celular empresarial do empregado na tabela |
---|
| 2417 | '<span id="' + id + ':cc_mobile" style="position: absolute; top: 90px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' + |
---|
| 2418 | '<span id="' + id + ':cc_mail" style="position: absolute; top: 105px; left: 75px; width: 135px; border: 0px solid #999; font-weight: normal; font-size: 10px; text-align: center; height: 10px;"></span>' + |
---|
| 2419 | '<span id="' + id + ':cc_alias" style="position: absolute; top: 95px; left: 10px; width: 60px; border: 0px solid #999; font-weight: normal; font-size: 9px; text-align: center; height: 10px;"></span>' + |
---|
[2] | 2420 | '<input id="' + id + ':cc_id" type="hidden">' + |
---|
| 2421 | '</div>' + '</td>'; |
---|
| 2422 | } |
---|
| 2423 | |
---|
| 2424 | return html_card; |
---|
| 2425 | } |
---|
| 2426 | |
---|
| 2427 | function getTableHTML (id, type) |
---|
| 2428 | { |
---|
| 2429 | var bg = ""; |
---|
| 2430 | if(!is_ie) |
---|
| 2431 | bg = "this.style.background=\'\'"; |
---|
| 2432 | else |
---|
| 2433 | bg = "this.style.background=\'#EEEEEE\'"; |
---|
[752] | 2434 | if(type == 'groups' || type == 'shared_groups') { |
---|
[503] | 2435 | html_card = '<tr width="40%" id="' + id + '" onmouseout="'+bg+'" onmouseover="this.style.background=\'LIGHTYELLOW\'" bgcolor="EEEEEE"><td width="auto" style="font-weight: normal; font-size: 10px; text-align: left; height: 10px;">' + |
---|
| 2436 | '<span id="' + id + ':cc_participantes" style="cursor: pointer; cursor: hand; z-index: 1"></span>' + |
---|
| 2437 | '<span id="' + id + ':cc_title"></span></td>' + |
---|
[752] | 2438 | '<td width="40%" style="solid #999; font-weight: normal; font-size: 10px; text-align: left; height: 10px"><span onMouseOver="this.title = \''+Element('cc_send_mail').value+'\'" id="' + id + ':cc_short_name"></span></td>' + |
---|
[503] | 2439 | '<td align="left" width="55px">'+ |
---|
| 2440 | '<img title="'+Element('cc_msg_group_edit').value+'" id="' + id + ':cc_card_edit" style=" cursor: pointer; cursor: hand; z-index: 1;width: 18px; height: 18px;" onclick="editGroup(Element(\'' + id + ':cc_id\').value);" src="templates/default/images/cc_card_edit.png">' + |
---|
| 2441 | ' | '+ |
---|
| 2442 | '<img title="'+Element('cc_msg_group_remove').value+'" id="' + id + ':cc_card_remove" style="width: 15px; height: 14px; cursor: pointer; cursor: hand; z-index: 1" onclick="removeEntry(Element(\'' + id + ':cc_id\').value,\'groups\');" src="templates/default/images/cc_x.png">' + |
---|
[1599] | 2443 | '<input id="' + id + ':cc_id" type="hidden">'+ |
---|
[503] | 2444 | '</td></tr>'; |
---|
[1599] | 2445 | } |
---|
| 2446 | else { |
---|
| 2447 | html_card = '<tr style="height:20px" id="' + id + '" onmouseout="'+bg+'" onmouseover="this.style.background=\'LIGHTYELLOW\'" bgcolor="EEEEEE">' + |
---|
| 2448 | //Para exibir a matricula do empregado na tabela |
---|
[3796] | 2449 | (preferences.empNumShow && ccTree.catalog_perms == 1 ? '<td align="center" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_empNumber"></span></td>' : '') + |
---|
[1599] | 2450 | '<td width="auto" style="font-weight: normal; font-size: 10px; text-align: left; height: 10px;"><span valign="bottom" id="' + id + ':cc_icon_group"> </span><span id="' + id + ':cc_name"></span></td>' + |
---|
| 2451 | '<td style="solid #999; font-weight: normal; font-size: 10px; text-align: left; height: 10px"><span onMouseOver="this.title = \''+Element('cc_send_mail').value+' => '+'\'+document.getElementById(\''+id + ':cc_name\').innerHTML" id="' + id + ':cc_mail"></span></td>' + |
---|
| 2452 | '<td align="center" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_phone"></span></td>' + |
---|
| 2453 | //Para exibir o celular empresarial do empregado na tabela |
---|
[3796] | 2454 | (preferences.cellShow && ccTree.catalog_perms == 1 ? '<td align="center" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_mobile"></span></td>' : '') + |
---|
[1599] | 2455 | //Para exibir o setor/lotacao do empregado na tabela |
---|
[3796] | 2456 | (preferences.departmentShow && ccTree.catalog_perms == 1 ? '<td align="center" nowrap><span style="solid #999; font-weight: normal; font-size: 10px;height: 10px" id="' + id + ':cc_department"></span></td>' : '') + |
---|
[2] | 2457 | ( ccTree.catalog_perms == 1 ? |
---|
[3796] | 2458 | '<td align="left"><span valign="bottom" id="' + id + ':cc_icon_data"></span></td>':'') + |
---|
| 2459 | (ccTree.catalog_perms & 2 ? |
---|
[2] | 2460 | '<td align="left" >'+ |
---|
| 2461 | '<img title="'+Element('cc_msg_card_edit').value+'" id="' + id + ':cc_card_edit" style=" cursor: pointer; cursor: hand; z-index: 1;width: 18px; height: 18px;" onclick="editContact(Element(\'' + id + ':cc_id\').value);" src="templates/default/images/cc_card_edit.png">' + |
---|
| 2462 | ' | '+ |
---|
| 2463 | '<img title="'+Element('cc_msg_card_remove').value+'" id="' + id + ':cc_card_remove" style="width: 15px; height: 14px; cursor: pointer; cursor: hand; z-index: 1" onclick="removeEntry(Element(\'' + id + ':cc_id\').value);" src="templates/default/images/cc_x.png">' : '') + |
---|
| 2464 | '<input id="' + id + ':cc_id" type="hidden">'+ |
---|
[284] | 2465 | '<input type="hidden" id="' + id + ':cc_photo">' + |
---|
| 2466 | '<span id="' + id + ':cc_title" style="display:none"></span>' + |
---|
| 2467 | '<span id="' + id + ':cc_alias" style="display:none"></span>' + |
---|
[285] | 2468 | // Esse campo é necessário se o contato possui dados no campo cc_company |
---|
[284] | 2469 | '<span id="' + id + ':cc_company" style="display:none"></span>' + |
---|
[2] | 2470 | '</td></tr>'; |
---|
| 2471 | } |
---|
| 2472 | |
---|
| 2473 | return html_card; |
---|
| 2474 | } |
---|
| 2475 | |
---|
| 2476 | function drawTable(ncards, type) |
---|
| 2477 | { |
---|
| 2478 | var pos; |
---|
[1599] | 2479 | |
---|
[2] | 2480 | html_cards = '<div id="divScrollMain" style="overflow:auto;z-index:1"><table width="100%" border="0" cellpadding="0" cellspacing="3">'; |
---|
[1599] | 2481 | |
---|
[2] | 2482 | if (ncards > 0) |
---|
| 2483 | { |
---|
| 2484 | |
---|
| 2485 | for (var i = 0; i < CC_max_cards[1]; i++) |
---|
| 2486 | { |
---|
| 2487 | html_cards += ''; |
---|
| 2488 | for (var j = 0; j < CC_max_cards[0]; j++) |
---|
| 2489 | { |
---|
| 2490 | html_cards += getTableHTML('cc_card:' + j + ':' + i, type); |
---|
| 2491 | if (--ncards == 0) |
---|
| 2492 | { |
---|
| 2493 | j = CC_max_cards[0]; |
---|
| 2494 | i = CC_max_cards[1]; |
---|
| 2495 | } |
---|
| 2496 | } |
---|
| 2497 | html_cards += ''; |
---|
| 2498 | } |
---|
[752] | 2499 | if((ccTree.catalog_perms & 2) && type != 'groups' && type !='shared_contacts' && type !='shared_groups') |
---|
[2] | 2500 | html_cards += '<tr><td colspan=4 align="right"><button id="cc_button_tools" value="" type="button" onclick="javascript:removeAllEntries()">Remover Todos</button></td></tr>'; |
---|
[1599] | 2501 | } |
---|
[2] | 2502 | else if (CC_max_cards != 0) |
---|
| 2503 | { |
---|
| 2504 | html_cards += '<tr><td align="center">' + Element('cc_msg_no_cards').value + '</td></tr>'; |
---|
| 2505 | } |
---|
| 2506 | else |
---|
| 2507 | { |
---|
| 2508 | html_cards += '<tr><td align="center">' + Element('cc_msg_err_no_room').value + '</td></tr>'; |
---|
| 2509 | } |
---|
| 2510 | |
---|
| 2511 | html_cards += '</table></div>'; |
---|
| 2512 | |
---|
| 2513 | Element('cc_card_space').innerHTML = html_cards; |
---|
| 2514 | } |
---|
| 2515 | |
---|
| 2516 | function drawCards(ncards, type) |
---|
| 2517 | { |
---|
| 2518 | var pos; |
---|
| 2519 | html_cards = '<div id="divScrollMain" style="overflow:auto;z-index:1">'; |
---|
| 2520 | html_cards += '<table border="0" cellpadding="0" cellspacing="' + CC_card_extra + '">'; |
---|
[1599] | 2521 | |
---|
[2] | 2522 | if (ncards > 0) |
---|
| 2523 | { |
---|
| 2524 | for (var i = 0; i < CC_max_cards[1]; i++) |
---|
| 2525 | { |
---|
| 2526 | html_cards += '<tr>'; |
---|
| 2527 | for (var j = 0; j < CC_max_cards[0]; j++) |
---|
| 2528 | { |
---|
| 2529 | html_cards += getCardHTML('cc_card:' + j + ':' + i, type); |
---|
| 2530 | if (--ncards == 0) |
---|
| 2531 | { |
---|
| 2532 | j = CC_max_cards[0]; |
---|
| 2533 | i = CC_max_cards[1]; |
---|
| 2534 | } |
---|
| 2535 | } |
---|
| 2536 | html_cards += '</tr>'; |
---|
| 2537 | } |
---|
[752] | 2538 | if((ccTree.catalog_perms & 2) && type != 'groups' && type !='shared_contacts' && type !='shared_groups') |
---|
[2] | 2539 | html_cards += '<tr><td colspan=3 align="right"><button id="cc_button_tools" value="" type="button" onclick="javascript:removeAllEntries()">Remover Todos</button></td></tr>'; |
---|
[1599] | 2540 | } |
---|
[2] | 2541 | else if (CC_max_cards != 0) |
---|
| 2542 | { |
---|
| 2543 | html_cards += '<tr><td>' + Element('cc_msg_no_cards').value + '</td></tr>'; |
---|
| 2544 | } |
---|
| 2545 | else |
---|
| 2546 | { |
---|
| 2547 | html_cards += '<tr><td>' + Element('cc_msg_err_no_room').value + '</td></tr>'; |
---|
| 2548 | } |
---|
| 2549 | |
---|
| 2550 | html_cards += '</table></div>'; |
---|
| 2551 | |
---|
| 2552 | Element('cc_card_space').innerHTML = html_cards; |
---|
| 2553 | } |
---|
| 2554 | |
---|
| 2555 | function showCards (letter,page, ids) |
---|
| 2556 | { |
---|
| 2557 | var data = new Array(); |
---|
[1496] | 2558 | flag_compartilhado = false; |
---|
[2] | 2559 | if ( letter != CC_actual_letter ) |
---|
| 2560 | { |
---|
| 2561 | CC_actual_page = '1'; |
---|
| 2562 | } |
---|
| 2563 | else |
---|
| 2564 | { |
---|
| 2565 | CC_actual_page = page; |
---|
| 2566 | } |
---|
| 2567 | |
---|
| 2568 | CC_actual_letter = letter; |
---|
| 2569 | |
---|
| 2570 | if (CC_max_cards[0] == 0) |
---|
| 2571 | { |
---|
| 2572 | |
---|
| 2573 | if(CC_visual == 'cards') |
---|
| 2574 | drawCards(0); |
---|
| 2575 | else if(CC_visual == 'table') |
---|
| 2576 | drawTable(0); |
---|
[1599] | 2577 | |
---|
[2] | 2578 | setPages(0,0); |
---|
| 2579 | return; |
---|
| 2580 | } |
---|
| 2581 | |
---|
| 2582 | var handler = function (responseText) |
---|
| 2583 | { |
---|
| 2584 | var data = new Array(); |
---|
| 2585 | data = unserialize(responseText); |
---|
| 2586 | if (data[0] == '0') |
---|
[1599] | 2587 | { |
---|
| 2588 | Element('cc_type_contact').value = data[1]; |
---|
[2] | 2589 | CC_npages = 0; |
---|
| 2590 | CC_actual_page = 1; |
---|
| 2591 | if(CC_visual == 'cards') |
---|
| 2592 | drawCards(0); |
---|
| 2593 | else if(CC_visual == 'table') |
---|
| 2594 | drawTable(0); |
---|
| 2595 | setPages(0,0); |
---|
| 2596 | return; |
---|
| 2597 | } |
---|
| 2598 | else |
---|
| 2599 | Element('cc_type_contact').value = data[10]; |
---|
[1599] | 2600 | |
---|
| 2601 | // Element('cc_debug').innerHTML = responseText; |
---|
| 2602 | |
---|
[2] | 2603 | if (typeof(data) != 'object') |
---|
| 2604 | { |
---|
| 2605 | showMessage(Element('cc_msg_err_contacting_server').value); |
---|
| 2606 | return; |
---|
| 2607 | } |
---|
[1599] | 2608 | |
---|
[2] | 2609 | if (typeof(data[3]) == 'object') |
---|
| 2610 | { |
---|
[1496] | 2611 | if (data[8] == 'bo_shared_people_manager') |
---|
| 2612 | { |
---|
| 2613 | flag_compartilhado = true; |
---|
| 2614 | } |
---|
| 2615 | else |
---|
| 2616 | { |
---|
| 2617 | flag_compartilhado = false; |
---|
| 2618 | } |
---|
| 2619 | qtd_compartilhado = data[9]; |
---|
[2] | 2620 | CC_npages = parseInt(data[0]); |
---|
[1599] | 2621 | CC_actual_page = parseInt(data[1]); |
---|
[2] | 2622 | if(CC_visual == 'cards') |
---|
| 2623 | drawCards(data[3].length, data[10]); |
---|
| 2624 | else if(CC_visual == 'table') |
---|
| 2625 | drawTable(data[3].length, data[10]); |
---|
| 2626 | resizeWindow(); |
---|
| 2627 | populateCards(data, data[10]); |
---|
| 2628 | setPages(data[0], data[1]); |
---|
[1599] | 2629 | |
---|
[2] | 2630 | } |
---|
[1599] | 2631 | else if (data['error']) |
---|
| 2632 | { |
---|
| 2633 | showMessage(data['error']); |
---|
| 2634 | } |
---|
[2] | 2635 | else |
---|
| 2636 | { |
---|
| 2637 | showMessage(Element('cc_msg_err_contacting_server').value); |
---|
| 2638 | return; |
---|
| 2639 | } |
---|
| 2640 | }; |
---|
| 2641 | |
---|
| 2642 | var info = "letter="+letter+"&page="+CC_actual_page+"&ids="+ids; |
---|
| 2643 | Connector.newRequest('showCards', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_cards_data', 'POST', handler, info); |
---|
| 2644 | } |
---|
| 2645 | |
---|
[1599] | 2646 | |
---|
[284] | 2647 | function clearCards() |
---|
| 2648 | { |
---|
| 2649 | clearLetterSelection(); |
---|
| 2650 | setHeightSpace(); |
---|
| 2651 | setMaxCards(getMaxCards()); |
---|
| 2652 | |
---|
| 2653 | if(CC_visual == 'cards') |
---|
| 2654 | drawCards(0); |
---|
| 2655 | else if(CC_visual == 'table') |
---|
| 2656 | drawTable(0); |
---|
| 2657 | |
---|
| 2658 | setPages(0,0); |
---|
| 2659 | return; |
---|
| 2660 | } |
---|
| 2661 | |
---|
[2] | 2662 | /***********************************************\ |
---|
| 2663 | * COMMON ENTRY FUNCTIONS * |
---|
| 2664 | \***********************************************/ |
---|
| 2665 | |
---|
| 2666 | function ccChangeVisualization(type) |
---|
| 2667 | { |
---|
| 2668 | var table_h = Element('cc_panel_table'); |
---|
| 2669 | var cards_h = Element('cc_panel_cards'); |
---|
[1599] | 2670 | |
---|
[2] | 2671 | switch (type) |
---|
| 2672 | { |
---|
| 2673 | case 'cards': |
---|
| 2674 | cards_h.style.display = 'none'; |
---|
| 2675 | table_h.style.display = 'inline'; |
---|
| 2676 | break; |
---|
| 2677 | |
---|
| 2678 | case 'table': |
---|
| 2679 | table_h.style.display = 'none'; |
---|
| 2680 | cards_h.style.display = 'inline'; |
---|
| 2681 | break; |
---|
| 2682 | } |
---|
[1599] | 2683 | |
---|
[2] | 2684 | CC_visual = type; |
---|
| 2685 | showCards(getActualLetter(), getActualPage()); |
---|
| 2686 | } |
---|
| 2687 | |
---|
[1599] | 2688 | function ccSearchUpdate() |
---|
| 2689 | { |
---|
| 2690 | Element('cc_panel_letters').style.display = 'none'; |
---|
| 2691 | Element('cc_panel_search').style.display = 'inline'; |
---|
| 2692 | |
---|
| 2693 | if(CC_visual == 'cards') |
---|
| 2694 | drawCards(0); |
---|
| 2695 | else if(CC_visual == 'table') |
---|
| 2696 | drawTable(0); |
---|
| 2697 | |
---|
| 2698 | if (CC_actual_letter != 'search') |
---|
| 2699 | { |
---|
| 2700 | CC_last_letter = CC_actual_letter; |
---|
| 2701 | } |
---|
| 2702 | } |
---|
| 2703 | |
---|
[2] | 2704 | function ccSearchHidePanel() |
---|
| 2705 | { |
---|
| 2706 | Element('cc_panel_search').style.display = 'none'; |
---|
| 2707 | Element('cc_panel_letters').style.display = 'inline'; |
---|
| 2708 | if (CC_actual_letter == 'search') |
---|
| 2709 | { |
---|
| 2710 | CC_actual_letter = CC_last_letter; |
---|
| 2711 | } |
---|
| 2712 | } |
---|
| 2713 | |
---|
| 2714 | function ccSearchHide() |
---|
| 2715 | { |
---|
| 2716 | Element('cc_panel_search').style.display = 'none'; |
---|
| 2717 | Element('cc_panel_letters').style.display = 'inline'; |
---|
[284] | 2718 | clearCards(); |
---|
[2] | 2719 | } |
---|
| 2720 | |
---|
| 2721 | /***********************************************\ |
---|
| 2722 | * QUICK ADD FUNCTIONS * |
---|
| 2723 | \***********************************************/ |
---|
| 2724 | |
---|
| 2725 | |
---|
| 2726 | function resetQuickAdd () |
---|
| 2727 | { |
---|
| 2728 | Element('cc_qa_alias').value = ''; |
---|
| 2729 | Element('cc_qa_given_names').value = ''; |
---|
| 2730 | Element('cc_qa_family_names').value = ''; |
---|
| 2731 | Element('cc_qa_phone').value = ''; |
---|
| 2732 | Element('cc_qa_email').value = ''; |
---|
| 2733 | } |
---|
| 2734 | |
---|
| 2735 | function getQuickAdd () |
---|
| 2736 | { |
---|
| 2737 | var data = new Array(); |
---|
| 2738 | data[0] = Element('cc_qa_alias').value; |
---|
| 2739 | data[1] = Element('cc_qa_given_names').value; |
---|
| 2740 | data[2] = Element('cc_qa_family_names').value; |
---|
| 2741 | data[3] = Element('cc_qa_phone').value; |
---|
| 2742 | data[4] = Element('cc_qa_email').value; |
---|
[1599] | 2743 | |
---|
[2] | 2744 | return data; |
---|
| 2745 | } |
---|
| 2746 | |
---|
| 2747 | function sendQuickAdd () |
---|
| 2748 | { |
---|
| 2749 | var data = getQuickAdd(); |
---|
[1599] | 2750 | |
---|
[2] | 2751 | var str = serialize(data); |
---|
| 2752 | |
---|
| 2753 | if (!str) |
---|
| 2754 | { |
---|
| 2755 | return false; |
---|
| 2756 | } |
---|
| 2757 | |
---|
| 2758 | var handler = function (responseText) |
---|
| 2759 | { |
---|
| 2760 | setTimeout('updateCards()',100);; |
---|
| 2761 | } |
---|
| 2762 | |
---|
| 2763 | resetQuickAdd(); |
---|
| 2764 | |
---|
| 2765 | Connector.newRequest('quickAdd', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=quick_add', 'POST', handler, 'add='+escape(str)); |
---|
| 2766 | } |
---|
[284] | 2767 | |
---|
[1599] | 2768 | |
---|
[284] | 2769 | function connectVoip (phoneUser, typePhone){ |
---|
| 2770 | var handler_voip = function (responseText){ |
---|
| 2771 | if(!responseText) { |
---|
| 2772 | alert("Erro conectando servidor VoIP."); |
---|
| 2773 | } |
---|
| 2774 | else{ |
---|
[1599] | 2775 | data = unserialize(responseText); |
---|
[284] | 2776 | alert("Requisitando chamada para o ramal: "+data); |
---|
[1599] | 2777 | } |
---|
[284] | 2778 | } |
---|
| 2779 | Connector.newRequest('voip', "../../expressoMail1_2/controller.php?action=expressoMail1_2.functions.callVoipconnect&to="+phoneUser+"&typePhone="+typePhone, 'POST', handler_voip); |
---|
| 2780 | } |
---|