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