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