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