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