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