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