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