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