/contactcenter/js/cc.js
JavaScript | 3165 lines | 2478 code | 451 blank | 236 comment | 536 complexity | 9fb245c147be0855330935dc4aa3dc0f MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, BSD-2-Clause, BSD-3-Clause, AGPL-3.0
Large files files are truncated, but you can click here to view the full file
- /******************************************************************************\
- * eGroupWare - Contacts Center *
- * http://www.egroupware.org *
- * Written by: *
- * - Raphael Derosso Pereira <raphaelpereira@users.sourceforge.net> *
- * - Jonas Goes <jqhcb@users.sourceforge.net> *
- * sponsored by Thyamad - http://www.thyamad.com *
- * ------------------------------------------------------------------------- *
- * This program is free software; you can redistribute it and/or modify it *
- * under the terms of the GNU General Public License as published by the *
- * Free Software Foundation; either version 2 of the License, or (at your *
- * option) any later version. *
- \******************************************************************************/
- /***********************************************\
- * TODO *
- \***********************************************/
- /*
- * function setHeightSpace ()
- *
- */
- /***********************************************\
- * CONSTANTS *
- \***********************************************/
- var CC_STATUS_FULL_ADD = 2;
- var CC_STATUS_QUICK_ADD = 1;
- var CC_card_image_width = 245;
- var CC_card_image_height = 130;
- var CC_card_extra = 16;
- /***********************************************\
- * GLOBALS VARIABLES *
- \***********************************************/
- var owners = new Array();
- var flag_compartilhado = false;
- var qtd_compartilhado = 0;
- var CC_visual = 'table';
- /* Cards Variables */
- var CC_actual_letter = 'a';
- var CC_last_letter = 'a';
- var CC_actual_page = 1;
- var CC_npages = 0;
- var CC_max_cards = new Array();
- var CC_conn_count=0;
- var CC_old_icon_w = 0;
- var CC_old_icon_h = 0;
- /* Tabs Variables */
- var CC_last_tab = 0;
- /* Pseudo-Semafores */
- var CC_tree_available = false;
- var CC_full_add_const = false;
- var CC_full_add_photo = false;
- var CC_last_height = window.innerHeight;
- var CC_last_width = window.innerWidth;
- /* Contact Full Info */
- var CC_contact_full_info;
- var CC_br_index;
- /* Addresses Variables */
- var CC_addr_last_selected = 0;
- /* Connections Variables */
- var CC_conn_last_selected = 0;
- var not_informed_text;
- /* Grupos inicialmente selecionados */
- var CC_initial_selected_grps = new Array();
- /***********************************************\
- * FULL ADD/EDIT FUNCTIONS *
- \***********************************************/
- function createPhotoFrame()
- {
- photo_frame = document.createElement('iframe');
- document.body.appendChild(photo_frame);
- if (is_ie)
- {
- photo_form = photo_frame.contentWindow.document.createElement('form');
- photo_input = photo_frame.contentWindow.document.createElement('input');
- }
- else
- {
- photo_form = photo_frame.contentDocument.createElement('form');
- photo_input = photo_frame.contentDocument.createElement('input');
- }
- photo_frame.id = 'cc_photo_frame';
- photo_frame.style.position = 'absolute';
- //photo_frame.style.visibility = 'hidden';
- photo_frame.style.top = '600px';
- photo_frame.style.left = '0px';
- photo_form.id = 'cc_photo_form';
- photo_form.method = 'POST';
- photo_form.enctype = 'multipart/form-data';
- photo_input.id = 'cc_photo_input';
- photo_input.type = 'file';
- if (is_ie)
- {
- photo_frame.contentWindow.document.body.appendChild(photo_form);
- }
- else
- {
- photo_frame.contentDocument.body.appendChild(photo_form);
- }
- photo_form.appendChild(photo_input);
- }
- /********* Full Add Auxiliar Functions ****************/
- function selectOption (id, option)
- {
- var obj = Element(id);
- var max = obj.options.length;
- if (option == undefined)
- {
- obj.selectedIndex = 0;
- }
- else
- {
- for (var i = 0; i < max; i++)
- {
- if (obj.options[i].value == option)
- {
- obj.selectedIndex = i;
- break;
- }
- }
- }
- }
- function selectRadio (id, index)
- {
- var obj = Element(id);
- var max = obj.options.length;
- for (var i = 0; i < max; i++)
- {
- i == index ? obj.options[i].checked = true : obj.options[i].checked = false;
- }
- }
- function clearSelectBox(obj, startIndex)
- {
- var nOptions = obj.options.length;
- for (var i = nOptions - 1; i >= startIndex; i--)
- {
- obj.removeChild(obj.options[i]);
- }
- }
- /********** Open/Close FullAdd *************/
- function openFullAdd(){
- // Build the FullAdd Window.
- if(!fullAddWin && !is_ie)
- __f();
- resetFullAdd();
- populateFullAddConst();
- fullAddWin.open();
- tabs._showTab('cc_contact_tab_0');
- Element('cc_full_add_window_clientArea').style.background = '#EEE';
- Element("cc_conn_type_1").checked = false;
- Element("cc_conn_type_2").checked = false;
- Element("cc_conn_type_sel").disabled = true;
- Element("cc_conn_type_sel").selectedIndex = 0;
- Element("cc_contact_sharing").style.display = 'none';
- }
- function openFullAddShared(){
- if (flag_compartilhado)
- {
- if(!fullAddWin && !is_ie)
- __f();
- resetFullAdd();
- populateFullAddConst();
- fullAddWin.open();
- tabs._showTab('cc_contact_tab_0');
- Element("cc_conn_type_1").checked = false;
- Element("cc_conn_type_2").checked = false;
- Element("cc_conn_type_sel").disabled = true;
- Element("cc_conn_type_sel").selectedIndex = 0;
- Element("cc_contact_sharing").align = 'center';
- Element("cc_contact_sharing").style.display = 'block';
- Element("cc_contact_shared_types").disabled = true;
- populateSharingSelect();
- } else
- {
- if(qtd_compartilhado != 0)
- {
- ccTree.select(0.2);
- ccTree.setCatalog(0.2);
- if(!fullAddWin && !is_ie)
- __f();
- resetFullAdd();
- populateFullAddConst();
- fullAddWin.open();
-
- tabs._showTab('cc_contact_tab_0');
- Element("cc_conn_type_1").checked = false;
- Element("cc_conn_type_2").checked = false;
- Element("cc_conn_type_sel").disabled = true;
- Element("cc_conn_type_sel").selectedIndex = 0;
- Element("cc_contact_sharing").aling = 'center';
- Element("cc_contact_sharing").style.display = 'block';
- Element("cc_contact_shared_types").disabled = true;
- populateSharingSelect();
- } else
- showMessage(Element('cc_msg_err_shared').value);
- }
- if(Element('cc_full_add_window_clientArea'))
- Element('cc_full_add_window_clientArea').style.background = '#EEE';
- }
- function closeFullAdd(){
- fullAddWin.close();
- }
- /******** Contact details ***********/
- function openContactDetails(id){
- // Build the ContactDetails Window.
- if((typeof(contactdetailsWin) == 'undefined') && !is_ie)
- __cdWin();
- contactdetailsWin.open();
-
- populateContactDetails(id);
- }
- function populateContactDetails(id)
- {
- var handler = function(responseText)
- {
- var fieldsDiv = Element('id_cc_contact_details_fields');
- var data = unserialize(responseText);
- //alert(responseText);
- fieldsDiv.innerHTML = "";
- if (data && data.length > 0)
- {
- //fieldsDiv.innerHTML = "";
- var table = document.createElement("table");
- table.border=0;
- //table.style.borderBottom = '1px solid #999';
- //table.cellSpacing = '0';
- table.width = '480px';
- var attr_name_size = '50%';
- var attr_value_size = '50%';
- for(i = 0; i < data.length; i++)
- {
- var row = table.insertRow(i);
- if ((i % 2) == 0)
- row.setAttribute('class', 'row_off');
- else
- row.setAttribute('class', 'row_on');
- //row.style.borderBottom = '1px solid #999';
- attr_name = row.insertCell(0);
- attr_value = row.insertCell(1);
- attr_name.style.width = attr_name_size;
- attr_value.style.width = attr_value_size;
- attr_name.innerHTML = data[i]['name'];
- if (data[i]['type'] == 'text')
- attr_value.innerHTML = data[i]['value'];
- else
- {
- var multivalue_div = document.createElement("div");
- multivalue_div.style.overflow = 'auto';
- multivalue_div.style.height = '100px';
- multivalue_div.style.border = '1px solid #999';
- //multivalue_div.style.backgroundColor = 'transparent';
- for (j = 0; j < data[i]['value'].length; j++)
- {
- multivalue_div.appendChild(document.createTextNode(data[i]['value'][j]));
- multivalue_div.appendChild(document.createElement("br"));
- }
- attr_value.appendChild(multivalue_div);
- }
- }
- fieldsDiv.appendChild(table);
- }
- else
- fieldsDiv.innerHTML = Element('cc_contact_details_no_fields').value;
- };
- Connector.newRequest('populateContactDetails', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_contact_details&id=' + id, 'GET', handler);
- }
- function closeContactDetails(){
- contactdetailsWin.close();
- }
- /********** New Contact *************/
- function newContact(){
- openFullAdd();
- }
- function newSharedContact(){
- openFullAddShared();
- }
- /************ Edit Contact *************/
- function editContact (id){
- openFullAdd();
- populateFullEdit(id,'bo_people_catalog');
- }
- function editSharedContact (id){
- openFullAdd();
- populateFullEdit(id,'bo_shared_people_manager');
- }
- /************ Edit Group *************/
- function editGroup(id){
- populateEditGroup(id);
- ccAddGroup.window.open();
- }
- function editSharedGroup(id,shared){
- populateEditSharedGroup(id, shared);
- }
- /*
- Updates all the constant fields in the
- full add window, like Prefixes, Suffixes,
- Countries and Types
- */
- function populateSharingSelect()
- {
- var handler = function(responseText)
- {
- var data = unserialize(responseText);
- var sharers = Element('cc_contact_shared_types');
- if (typeof(data) != 'object')
- {
- showMessage(Element('cc_msg_err_contacting_server').value);
- fullAddWin.close();
- return;
- }else{
- sharers.disabled = false;
- j = 1;
- for (var i in data)
- {
- sharers.options[j] = new Option(data[i]['cn'], i);
- owners[j] = i;
- j++;
- }
- return;
- }
- };
- Connector.newRequest('populateSharingSelect', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_list_owners_perms_add', 'POST', handler);
- }
- function populateFullAddConst()
- {
- CC_full_add_const = false;
- setTimeout('populateFullAddConstAsync()', 10);
- }
- function populateFullAddConstAsync()
- {
- var handler = function(responseText)
- {
- //Element('cc_debug').innerHTML = responseText;
- var data = unserialize(responseText);
- var i = 1;
- var j;
- if (typeof(data) != 'object')
- {
- showMessage(Element('cc_msg_err_contacting_server').value);
- return;
- }
- /* Populate Prefixes */
- for (j in data[0])
- {
- Element('cc_pd_prefix').options[i] = new Option(data[0][j], j);
- i++;
- }
- /* Populate Suffixes */
- i = 1;
- for (j in data[1])
- {
- Element('cc_pd_suffix').options[i] = new Option(data[1][j], j);
- i++;
- }
- /* Populate Addresses Types */
- i = 1;
- for (j in data[2])
- {
- Element('cc_addr_types').options[i] = new Option(data[2][j], j);
- i++;
- }
- /* Populate Countries */
- i = 1;
- for (j in data[3])
- {
- Element('cc_addr_countries').options[i] = new Option(data[3][j], j);
- if (j == 'BR' || j == 'br')
- {
- CC_br_index = i;
- }
- i++;
- }
- /* Populate Connection Types */
- /*
- * Cуdigo nгo funcional com o expresso.
- */
- /*i = 1;
- for (j in data[4])
- {
- Element('cc_conn_type').options[i] = new Option(data[4][j], j);
- i++;
- }*/
-
- /* Populate Relations Types */
- /*
- * Cуdigo conflitante com a modificaзгo de seleзгo de grupos durante
- * a criaзгo de um novo contato. Tambйm foi verificado que este cуdigo nгo
- * й funcional.
- */
- /*
- i = 0;
- for (j in data[5])
- {
- Element('cc_rels_type').options[i] = new Option(data[5][j], j);
- i++;
- }*/
-
- /* Populate available groups */
- i = 0;
- var grupos = data[5];
- for (var grupo in grupos)
- {
- Element('id_grps_available').options[i] = new Option(grupos[grupo]['title'], grupos[grupo]['id_group']);
- i++;
- }
- CC_full_add_const = true;
- };
- Connector.newRequest('populateFullAddConst', CC_url+'get_contact_full_add_const', 'GET', handler);
- }
- /*
- * Funзгo que faz a seleзгo do grupo.
- * Autor: Luiz Carlos Viana Melo - Prognus
- */
- function selectGroup()
- {
- grps_avail = Element('id_grps_available');
- grps_selec = Element('id_grps_selected');
-
- for (i = 0; i < grps_avail.length; i++)
- {
- if (grps_avail.options[i].selected) {
- isSelected = false;
- for(var j = 0;j < grps_selec.options.length; j++) {
- if(grps_selec.options[j].value === grps_avail.options[i].value){
- isSelected = true;
- break;
- }
- }
- if(!isSelected){
- option = document.createElement('option');
- option.value = grps_avail.options[i].value;
- option.text = grps_avail.options[i].text;
- option.selected = false;
- grps_selec.options[grps_selec.options.length] = option;
-
- }
-
- }
- }
-
- for (j =0; j < grps_avail.options.length; j++)
- grps_avail.options[j].selected = false;
- }
- /*
- * Funзгo que remove um grupo selecionado.
- * Autor: Luiz Carlos Viana Melo - Prognus
- */
- function deselectGroup()
- {
- grps_selec = Element('id_grps_selected');
- for(var i = 0;i < grps_selec.options.length; i++)
- if(grps_selec.options[i].selected)
- grps_selec.options[i--] = null;
- }
- function populateFullEdit (id,catalog)
- {
- var handler = function(responseText)
- {
- //Element('cc_debug').innerHTML = responseText;
- var data = unserialize(responseText);
- if (typeof(data) != 'object' || data['result'] != 'ok')
- {
- showMessage(Element('cc_msg_err_contacting_server').value);
- return;
- }
- resetFullAdd();
- CC_contact_full_info = data;
- Element('cc_full_add_contact_id').value = data['cc_full_add_contact_id'];
- populatePersonalData(data['personal']);
- populateContactGroups(data['groups']);
- //populateRelations(data['relations']);
- };
- Connector.newRequest('populateFullEdit', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_full_data&id=' + id + "&catalog="+catalog, 'GET', handler);
- }
- /*
- * Funзгo que preenche a lista de grupos a qual o contato pertence.
- * Autor: Luiz Carlos Viana Melo - Prognus
- */
- function populateContactGroups(groupsData)
- {
- groups_selected = Element('id_grps_selected');
- var i = 0;
- CC_initial_selected_grps = new Array();
- for (var group in groupsData)
- {
- var id_group = groupsData[group]['id_group'];
- option = document.createElement('option');
- option.value = id_group;
- option.text = groupsData[group]['title'];
- option.selected = false;
- groups_selected.options[i++] = option;
- CC_initial_selected_grps[id_group] = new Array();
- CC_initial_selected_grps[id_group]['id_group'] = id_group;
- CC_initial_selected_grps[id_group]['title'] = groupsData[group]['title'];
- CC_initial_selected_grps[id_group]['short_name'] = groupsData[group]['short_name'];
- }
- }
- function populateEditGroup (id)
- {
- populateEditSharedGroup(id,false);
- }
- function populateEditSharedGroup(id,shared) {
- var handler = function(responseText)
- {
- var data = unserialize(responseText);
- Element('group_id').value = data['id_group'];
- var options_contact_list = Element('span_contact_list');
- var select_contact_list = '<select id="contact_list" multiple name="contact_list[]" style="width:280px" size="10">';
- select_contact_list += data['contact_list'] + "</select>";
- options_contact_list.innerHTML = select_contact_list;
-
- if(data['id_group']) {
- Element('title').value = data['title'];
- if(data['contact_in_list']) {
- for(i = 0; i < data['contact_in_list'].length; i++) {
- option = document.createElement('option');
- option.value = data['contact_in_list'][i]['id_connection'];
- option.text = data['contact_in_list'][i]['names_ordered']+' ('+data['contact_in_list'][i]['connection_value']+')';
- Element('contact_in_list').options[Element('contact_in_list').options.length] = option;
- }
- }
-
- Element('title').value = data['title'];
- }
-
- if (typeof(data) != 'object' || data['result'] != 'ok')
- {
- showMessage(Element('cc_msg_err_contacting_server').value);
- return;
- }
- ccAddGroup.setSelectedSourceLevel(ccTree.actualLevel);
- ccAddGroup.openEditWindow();
- };
-
- id = typeof(id) == 'undefined' ? id = 0 : id;
-
- ccAddGroup.clear(true);
- if(!shared)
- Connector.newRequest('populateEditGroup', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_group&id='+id, 'GET', handler);
- else
- Connector.newRequest('populateEditGroup', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_group&id='+id+'&shared_from='+shared, 'GET', handler);
- }
- function resetFullAdd()
- {
- /* Groups */
- gprs_selected = Element('id_grps_selected');
- if(gprs_selected != null){
- for (j =0; j < gprs_selected.options.length; j++) {
- gprs_selected.options[j].selected = false;
- gprs_selected.options[j--] = null;
- }
- }
- /* Clear information container */
- CC_contact_full_info = new Array();
- /* Clear Fields */
- Element('cc_full_add_form_personal').reset();
- Element('cc_full_add_form_addrs').reset();
- if(Element('cc_contact_type').value=='advanced')
- Element('cc_full_add_form_corporative').reset();
- /* Personal Data */
- Element('cc_full_add_contact_id').value = null;
- Element('cc_pd_photo').src = 'templates/default/images/photo.png';
- /* Addresses */
- resetAddressFields();
- /* Connections */
- CC_conn_last_selected = '_NONE_';
- Element("cc_phone_default").options.selectedIndex = '-1';
- Element("cc_email_default").options.selectedIndex = '-1';
- Element("div_cc_conn_is_default").style.display = 'none';
- clearConn();
- }
- function postFullAdd()
- {
- if (!checkFullAdd())
- {
- return false;
- }
- //Force emails to Lower Case
- txtField0 = Element("cc_conn_value_0");
- if (txtField0 != null && (txtField0.value.length > 0)) {
- txtField0.value = txtField0.value.toLowerCase();
- }
- txtField1 = Element("cc_conn_value_1");
- if (txtField1 != null && (txtField1.value.length > 0)) {
- txtField1.value = txtField1.value.toLowerCase();
- }
- /* First thing: Send Photo */
- if (Element('cc_pd_select_photo').value != '' && !is_ie)
- {
- var nodes;
- var form, frame, old_frame;
- CC_full_add_photo = false;
- old_frame = Element('cc_photo_frame');
- if (!old_frame)
- {
- frame = document.createElement('iframe');
- }
- else
- {
- frame = old_frame;
- }
- frame.id = 'cc_photo_frame';
- frame.style.visibility = 'hidden';
- frame.style.top = '0px';
- frame.style.left = '0';
- frame.style.position = 'absolute';
- document.body.appendChild(frame);
- form = frame.contentDocument.createElement('form');
- var id_contact = Element('cc_full_add_contact_id').value;
- form.id = 'cc_form_photo';
- form.method = 'POST';
- form.enctype = 'multipart/form-data';
- 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 : '');
- var input_clone = Element('cc_pd_select_photo').cloneNode(false);
- form.appendChild(input_clone);
- frame.contentDocument.body.appendChild(form);
- form.submit();
- CC_full_add_photo = true;
- }
- else if (Element('cc_pd_select_photo_t').value != '' && is_ie)
- {
- CC_full_add_photo = false;
- var frame = Element('cc_photo_frame');
- var form = frame.contentWindow.document.all['cc_photo_form'];
- var id_contact = Element('cc_full_add_contact_id').value;
- 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 : '');
- form.submit();
- setTimeout('Element(\'cc_photo_frame\').src = \'cc_photo_frame.html\'', 1000);
- CC_full_add_photo = true;
- }
- if (Element('cc_contact_sharing').style.display == 'none')
- setTimeout('postFullAddInfo()', 100);
- else
- setTimeout('postFullAddInfoShared()', 100);
- updateCards();
- }
- function postFullAddInfo()
- {
- var handler = function (responseText)
- {
- var data = unserialize(responseText);
- if (typeof(data) != 'object')
- {
- showMessage(Element('cc_msg_err_contacting_server').value);
- return;
- }
- if (data['status'] != 'ok')
- {
- showMessage(data['msg']);
- return;
- }
- fullAddWin.close();
- updateCards();
- };
- Connector.newRequest('postFullAddInfo', CC_url+'post_full_add', 'POST', handler, getFullAddData());
- }
- function postFullAddInfoShared()
- {
- var handler = function (responseText)
- {
- var data = unserialize(responseText);
- if (typeof(data) != 'object')
- {
- showMessage(Element('cc_msg_err_contacting_server').value);
- return;
- }
- if (data['status'] != 'ok')
- {
- showMessage(data['msg']);
- return;
- }
- fullAddWin.close();
- updateCards();
- };
- Connector.newRequest('postFullAddInfoShared', CC_url+'post_full_add_shared', 'POST', handler, getFullAddData());
- }
- function getFullAddData()
- {
- var data = new Array();
- var empty = true;
- var replacer = '__##AND##__';
- data['commercialAnd'] = replacer;
- if (Element('cc_full_add_contact_id').value != '' && Element('cc_full_add_contact_id').value != 'null')
- {
- data['id_contact'] = replaceComAnd(Element('cc_full_add_contact_id').value, replacer);
- data.length++;
- }
- /* Owner do contato (Para o caso de adicao de contato compartilhado) */
- if (Element('cc_contact_sharing').style.display == 'block')
- {
- var index = Element('cc_contact_shared_types').selectedIndex;
- data['owner'] = replaceComAnd(owners[index], replacer);
- data.length++;
- }
- /* Status: Full Added */
- data['id_status'] = CC_STATUS_FULL_ADD;
- /* Personal Data */
- data['alias'] = replaceComAnd(Element('cc_pd_alias').value, replacer);
- data['id_prefix'] = replaceComAnd(Element('cc_pd_prefix').value, replacer);
- data['given_names'] = replaceComAnd(Element('cc_pd_given_names').value, replacer);
- data['family_names'] = replaceComAnd(Element('cc_pd_family_names').value, replacer);
- data['names_ordered'] = replaceComAnd(data['given_names']+" "+data['family_names'], replacer);
- data['id_suffix'] = replaceComAnd(Element('cc_pd_suffix').value, replacer);;
- data['birthdate_0'] = replaceComAnd(Element('cc_pd_birthdate_0').value, replacer);
- data['birthdate_1'] = replaceComAnd(Element('cc_pd_birthdate_1').value, replacer);
- data['birthdate_2'] = replaceComAnd(Element('cc_pd_birthdate_2').value, replacer);
- // data['sex'] = Element('cc_pd_sex').value == 1 ? 'M' : Element('cc_pd_sex').value == 2 ? 'F' : null;
- data['pgp_key'] = replaceComAnd(Element('cc_pd_gpg_finger_print').value, replacer);
- data['notes'] = replaceComAnd(Element('cc_pd_notes').value, replacer);
- data.length += 14;
- //corporative
- if (document.getElementById('cc_contact_type').value == 'advanced') {
- data['corporate_name'] = replaceComAnd(document.getElementById('cc_name_corporate').value, replacer);
- data['job_title'] = replaceComAnd(document.getElementById('cc_job_title').value, replacer);
- data['department'] = replaceComAnd(document.getElementById('cc_department').value, replacer);
- data['web_page'] = replaceComAnd(document.getElementById('cc_web_page').value, replacer);
- data.length += 18;
- }
- /* Addresses */
- saveAddressFields();
- data['addresses'] = CC_contact_full_info['addresses'];
- /* Connection */
- saveConnFields();
- if (CC_contact_full_info['connections'])
- {
- var connNumber = 0;
- for (var type in CC_contact_full_info['connections'])
- {
- if (type == 'length')
- {
- continue;
- }
- if (typeof(data['connections']) != 'object')
- {
- data['connections'] = new Array();
- }
- for (var i in CC_contact_full_info['connections'][type])
- {
- if (i == 'length')
- {
- continue;
- }
- if (typeof(data['connections']['connection'+connNumber]) != 'object')
- {
- data['connections']['connection'+connNumber] = new Array(5);
- }
- data['connections']['connection'+connNumber]['id_connection'] = CC_contact_full_info['connections'][type][i]['id'];
- data['connections']['connection'+connNumber]['id_typeof_connection'] = type;
- data['connections']['connection'+connNumber]['connection_name'] = CC_contact_full_info['connections'][type][i]['name'];
- data['connections']['connection'+connNumber]['connection_value'] = CC_contact_full_info['connections'][type][i]['value'];
- if(Element("cc_"+(type == 1 ? 'email' : 'phone')+"_default").value) {
- if(Element("cc_"+(type == 1 ? 'email' : 'phone')+"_default").value == CC_contact_full_info['connections'][type][i]['name']){
- data['connections']['connection'+connNumber]['connection_is_default'] = 'TRUE';
- }
- else
- data['connections']['connection'+connNumber]['connection_is_default'] = 'FALSE';
- }
- // data['connections']['connection'+connNumber].length = 5;
- empty = false;
- connNumber++;
- data['connections'].length++;
- }
- }
- if (!empty)
- {
- data.length++;
- empty = true;
- }
- }
- if (CC_contact_full_info['removed_conns'])
- {
- empty = false;
- if (typeof(data['connections']) != 'object')
- {
- data['connections'] = new Array();
- data.length++;
- }
- data['connections']['removed_conns'] = CC_contact_full_info['removed_conns'];
- data['connections'].length++;
- }
- data['groups'] = getAddedRemovedGroups();
-
- var serial = serialize(data);
- return 'data=' + escape(serialize(data));
- }
- /*
- * Funзгo que retorna os grupos que foram anteriormente selecionados, adicionados ou removidos pelo
- * usuбrio. O formato retornado й um array contendo:
- * ['previous_selected'] {
- * [id_group] {
- * 'id_group' => o ID do grupo
- * 'title' => o tнtulo do grupo
- * }
- * ['added'] {
- * [id_group] {
- * 'id_group' => o ID do grupo
- * 'title' => o tнtulo do grupo
- * }
- * },
- * ['removed'] {
- * [id_group] {
- * 'id_group' => o ID do grupo
- * 'title' => o tнtulo do grupo
- * }
- * }
- * Autor: Luiz Carlos Viana Melo - Prognus
- */
- function getAddedRemovedGroups()
- {
- var selected_groups = getSelectedGroups();
- var added_groups = diffContactIDArray(selected_groups, CC_initial_selected_grps);
- var removed_groups = diffContactIDArray(CC_initial_selected_grps, selected_groups);
- var groups = new Array();
- groups['previous_selected'] = CC_initial_selected_grps;
- groups['added'] = added_groups;
- groups['removed'] = removed_groups;
- return groups;
- }
- /*
- * Funзгo que retorna os grupos que foram selecionados pelo usuбrio. O formato retornado й:
- * [id_group] {
- * 'id_group' => o ID do grupo
- * 'title' => o tнtulo do grupo
- * }
- * Autor: Luiz Carlos Viana Melo - Prognus
- */
- function getSelectedGroups()
- {
- var gprs_selected = Element('id_grps_selected');
- var data = new Array();
- if(gprs_selected != null){
- for(i = 0; i < gprs_selected.options.length; i++)
- {
- var id_group = gprs_selected.options[i].value;
- data[id_group] = new Array();
- data[id_group]['id_group'] = id_group;
- data[id_group]['title'] = gprs_selected.options[i].text;
- }
- }
- return data;
- }
- /*
- * Funзгo que retorna a diferenзa entre 2 arrays com ID dos contatos.
- * Autor: Luiz Carlos Viana Melo - Prognus
- */
- function diffContactIDArray(array1, array2)
- {
- var diff = new Array();
- for (var group in array1)
- {
- if (!array2[group])
- diff.push(array1[group]);
- }
- return diff;
- }
- function checkFullAdd()
- {
- /* Checa se o listbox esta desativado ou й nulo, ou seja, nгo existe catбlogos compartilhados com o user atual */
- if (!(Element('cc_contact_sharing').style.display == 'none' ))
- {
- if (Element('cc_contact_shared_types').disabled == true)
- {
- showMessage('Nenhum catбlogo compartilhado existente');
- return false;
- }
- if (Element('cc_contact_shared_types').selectedIndex == 0)
- {
- showMessage('Nenhum catбlogo selecionado');
- return false;
- }
- }
- /* Check Personal Data */
- if ($.trim(Element('cc_pd_given_names').value) == '')
- {
- showMessage(Element('cc_msg_err_empty_field').value + " => " + Element('cc_pd_given_names').name);
- return false;
- }
- /* Check Addresses */
- /* Check Connections */
- saveConnFields();
- var comp = /^[a-zA-Z\d(-)\.@_ -]{0,200}$/;
- haveConnections = false;
- if (CC_contact_full_info['connections']){
- for (var type in CC_contact_full_info['connections']){
- haveConnections = true;
- var reEmail = /^[a-zA-Z0-9][_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]{1,})*$/;
- for (var i in CC_contact_full_info['connections'][type]){
- if(type == 1){
- if(!reEmail.test(CC_contact_full_info['connections'][type][i]['value'])){
- showMessage('Endereзo para conexгo de ' + CC_contact_full_info['connections'][type][i]['name'] + ', nгo й vбlido');
- return false;
- }
- }
- else{
- if((CC_contact_full_info['connections'][type][i]['value'].length < 4) ||
- (!comp.test(CC_contact_full_info['connections'][type][i]['value']))){
- showMessage('Endereзo para conexгo de ' + CC_contact_full_info['connections'][type][i]['name'] + ', nгo й vбlido');
- return false;
- }
- }
- }
- var _options_default = Element("cc_"+(type == 1 ? 'email' : 'phone')+"_default");
- if(_options_default.value == '-1') {
- alert(get_lang("It is necessary to choose a ") + (type == 1 ? 'Email' : get_lang('Phone ')) + get_lang('default!'));
- return false;
- }
- }
- }
- /* Check Relations */
- return true;
- }
- /********* Personal Data Functions *********/
- /*
- * data[0] => cc_pd_select_photo
- * data[1] => cc_pd_alias
- * data[2] => cc_pd_given_names
- * data[3] => cc_pd_family_names
- * data[4] => cc_pd_full_name
- * data[5] => cc_pd_suffix
- * data[6] => cc_pd_birthdate
- * data[7] => cc_pd_sex SELECT
- * data[8] => cc_pd_prefix
- * data[9] => cc_pd_gpg_finger_print
- * data[10] => cc_pd_notes
- */
- function populatePersonalData (data)
- {
- for (i in data)
- {
- switch(i)
- {
- case 'cc_pd_suffix':
- case 'cc_pd_sex':
- case 'cc_pd_prefix':
- selectOption(i, data[i]);
- break;
- case 'cc_pd_photo':
- if (data[i])
- {
- //Codigo para exibicao da imagem do contato no IE
- //Douglas Lopes Gomes - Prognus Software Livre
- if (Element(i)[1] && Element(i)[1].src){ //Se o navegador йo IE
- Element(i)[1].src = data[i] + '&'+ Math.random();
- } else { //Se o navegador nгo й o IE
- Element(i).src = data[i] + '&'+ Math.random();
- }
- }
- break;
- default:
- Element(i).value = data[i] == undefined ? '' : unescape(data[i]);
- }
- }
- return;
- }
- /********* End Personal Data Functions *********/
- /********* Addresses Functions *********/
- function resetAddressFields()
- {
- Element('cc_addr_types').selectedIndex = 0;
- Element('cc_addr_countries').selectedIndex = 0;
- Element('cc_addr_countries').disabled = true;
- Element('cc_addr_states').selectedIndex = 0;
- Element('cc_addr_states').disabled = true;
- Element('cc_addr_states_new').disabled = true;
- Element('cc_addr_states_new').readonly = true;
- Element('cc_addr_states_new').value = '';
- Element('cc_addr_cities').selectedIndex = 0;
- Element('cc_addr_cities').disabled = true;
- Element('cc_addr_cities_new').disabled = true;
- Element('cc_addr_cities_new').readonly = true;
- Element('cc_addr_cities_new').value = '';
- Element('cc_addr_id').value = '';
- resetAddrFillingFields();
- }
- function resetAddrFillingFields()
- {
- Element('cc_addr_1').value = '';
- Element('cc_addr_2').value = '';
- Element('cc_addr_other').value = '';
- Element('cc_addr_complement').value = '';
- Element('cc_addr_postal_code').value = '';
- Element('cc_addr_po_box').value = '';
- Element('cc_addr_is_default').checked = false;
- }
- function disableAddrFillingFields()
- {
- Element('cc_addr_1').readonly = true;
- Element('cc_addr_1').disabled = true;
- Element('cc_addr_2').readonly = true;
- Element('cc_addr_2').disabled = true;
- Element('cc_addr_other').readonly = true;
- Element('cc_addr_other').disabled = true;
- Element('cc_addr_complement').readonly = true;
- Element('cc_addr_complement').disabled = true;
- Element('cc_addr_postal_code').readonly = true;
- Element('cc_addr_postal_code').disabled = true;
- Element('cc_addr_po_box').readonly = true;
- Element('cc_addr_po_box').disabled = true;
- Element('cc_addr_is_default').readonly = true;
- Element('cc_addr_is_default').disabled = true;
- }
- function updateAddressFields()
- {
- var type = Element('cc_addr_types');
- var oldSelected = type.value;
- saveAddressFields();
- if (oldSelected == '_NONE_')
- {
- resetAddressFields();
- return true;
- }
- CC_addr_last_selected = type.selectedIndex;
- Element('cc_addr_countries').disabled = false;
- var data = CC_contact_full_info['addresses'];
- var addrIndex = 'address'+Element('cc_addr_types').value;
- if (typeof(data) != 'object' || typeof(data[addrIndex]) != 'object')
- {
- resetAddressFields();
- Element('cc_addr_countries').disabled = false;
- Element('cc_addr_countries').selectedIndex = CC_br_index;
- type.value = oldSelected;
- updateAddrStates();
- return true;
- }
- var addrTypeID = Element('cc_addr_types').value;
- data = CC_contact_full_info['addresses'][addrIndex];
- Element('cc_addr_id').value = data['id_address'] ? data['id_address'] : '';
- Element('cc_addr_1').value = data['address1'] ? data['address1'] : '';
- Element('cc_addr_2').value = data['address2'] ? data['address2'] : '';
- Element('cc_addr_complement').value = data['complement'] ? data['complement'] : '';
- Element('cc_addr_other').value = data['address_other'] ? data['address_other'] : '';
- Element('cc_addr_postal_code').value = data['postal_code'] ? data['postal_code'] : '';
- Element('cc_addr_po_box').value = data['po_box'] ? data['po_box'] : '';
- Element('cc_addr_is_default').checked = data['address_is_default'] == '1' ? true: false;
- Element('cc_addr_countries').value = data['id_country'];
- updateAddrStates();
- }
- function updateAddrStates()
- {
- var states = Element('cc_addr_states');
- if (Element('cc_addr_countries').value == '_NONE_')
- {
- states.disabled = true;
- states.selectedIndex = 0;
- clearSelectBox(states, 4);
- updateAddrCities();
- return;
- }
- updateAddrFillingFields();
- populateStates();
- }
- function populateStates()
- {
- var states = Element('cc_addr_states');
- var cities = Element('cc_addr_cities');
- var handler = function (responseText)
- {
- var data = unserialize(responseText);
- clearSelectBox(states, 1);
- if (typeof(data) != 'object')
- {
- showMessage(Element('cc_msg_err_contacting_server').value);
- return;
- }
- if (data['status'] == 'empty')
- {
- states.disabled = true;
- cities.disabled = true;
- states.selectedIndex = 0;
- cities.selectedIndex = 0;
- return;
- }
- else if (data['status'] != 'ok')
- {
- showMessage(data['msg']);
- states.disabled = true;
- states.selectedIndex = 0;
- updateAddrCities();
- return;
- }
- states.disabled = false;
- var i = 1;
- /*
- for (var j in data['data'])
- {
- states.options[i] = new Option(data['data'][j], j);
- if(i == 1) data['data'] = data['data'].sort();
- i++;
- }*/
- jQuery.each(data['data'],function(index,value){
- if (value != undefined){
- states.options[i] = new Option(value, index);
- if(i == 1) data['data'] = data['data'].sort();
- i++;
- }
- });
- states.disabled = false;
- states.selectedIndex = 0;
- data = CC_contact_full_info['addresses'];
- var addrIndex = 'address'+Element('cc_addr_types').value;
- if (data && data[addrIndex])
- {
- states.value = data[addrIndex]['id_state'];
- if (states.value == '_NEW_')
- {
- if (CC_contact_full_info['addresses']['new_states'][addrIndex])
- {
- Element('cc_addr_states_new').value = CC_contact_full_info['addresses']['new_states'][addrIndex];
- }
- updateAddrNewStateOnMouseOut();
- }
- updateAddrCities();
- }
- };
- Connector.newRequest('populateStates', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_states&country='+Element('cc_addr_countries').value, 'GET', handler);
- }
- function updateAddrCities()
- {
- var states = Element('cc_addr_states');
- var cities = Element('cc_addr_cities');
- var newState = Element('cc_addr_states_new');
- var requestStr;
- switch (states.value)
- {
- case '_NONE_':
- newState.readonly = true;
- newState.disabled = true;
- newState.value = '';
- cities.disabled = true;
- cities.selectedIndex = 0;
- updateAddrFillingFields();
- return;
- case '_NEW_':
- newState.readonly = false;
- newState.disabled = false;
- updateAddrNewStateOnMouseOut();
- cities.disabled = false;
- clearSelectBox(cities, 3);
- cities.selectedIndex = 1;
- updateAddrFillingFields();
- return;
- case '_SEP_': return;
- case '_NOSTATE_':
- clearSelectBox(cities, 3);
- cities.disabled = false;
- cities.selectedIndex = 0;
- requestStr = 'country='+Element('cc_addr_countries').value;
- break;
- default:
- requestStr = 'country='+Element('cc_addr_countries').value+'&state='+states.value;
- }
- newState.readonly = true;
- newState.disabled = true;
- newState.value = '';
- populateCities(requestStr);
- }
- function populateCities(requestStr)
- {
- var cities = Element('cc_addr_cities');
- var handler = function (responseText)
- {
- var data = unserialize(responseText);
- clearSelectBox(cities, 1);
- if (typeof(data) != 'object')
- {
- showMessage(Element('cc_msg_err_contacting_server').value);
- return;
- }
- if (data['status'] == 'empty')
- {
- cities.disabled = true;
- cities.selectedIndex = 0;
- return;
- }
- else if (data['status'] != 'ok')
- {
- showMessage(data['msg']);
- cities.disabled = true;
- cities.selectedIndex = 0;
- updateAddrFillingFields();
- return;
- }
- cities.disabled = false;
- var i = 1;
- /*
- for (var j in data['data'])
- {
- cities.options[i] = new Option(data['data'][j], j);
- i++;
- }*/
- jQuery.each(data['data'],function(index,value){
- if (value != undefined){
- cities.options[i] = new Option(value,index);
- i++;
- }
- });
- cities.disabled = false;
- cities.selectedIndex = 0;
- data = CC_contact_full_info['addresses'];
- var addrIndex = 'address'+Element('cc_addr_types').value;
- if (data && data[addrIndex])
- {
- cities.value = data[addrIndex]['id_city'];
- if (cities.value == '_NEW_')
- {
- if (CC_contact_full_info['addresses']['new_cities'][addrIndex])
- {
- Element('cc_addr_cities_new').value = CC_contact_full_info['addresses']['new_cities'][addrIndex];
- }
- updateAddrNewCityOnMouseOut();
- }
- }
- };
- Connector.newRequest('populateCities', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_cities&'+requestStr, 'GET', handler);
- }
- function updateAddrNewStateOnMouseOver ()
- {
- if (Element('cc_addr_states_new').value == Element('cc_msg_type_state').value && Element('cc_addr_states').selectedIndex == 1)
- {
- Element('cc_addr_states_new').value = '';
- }
- }
- function updateAddrNewStateOnMouseOut ()
- {
- if (Element('cc_addr_states_new').value.length == 0 && Element('cc_addr_states').selectedIndex == 1)
- {
- Element('cc_addr_states_new').value = Element('cc_msg_type_state').value;
- }
- }
- function updateAddrFillingFields()
- {
- var countries = Element('cc_addr_countries');
- var cities = Element('cc_addr_cities');
- var newCity = Element('cc_addr_cities_new');
- if (countries.value == '_NONE_')
- {
- newCity.readonly = true;
- newCity.disabled = true;
- newCity.value = '';
- disableAddrFillingFields();
- return;
- }
- Element('cc_addr_1').readonly = false;
- Element('cc_addr_1').disabled = false;
- Element('cc_addr_2').readonly = false;
- Element('cc_addr_2').disabled = false;
- Element('cc_addr_other').readonly = false;
- Element('cc_addr_other').disabled = false;
- Element('cc_addr_complement').readonly = false;
- Element('cc_addr_complement').disabled = false;
- Element('cc_addr_postal_code').readonly = false;
- Element('cc_addr_postal_code').disabled = false;
- Element('cc_addr_po_box').readonly = false;
- Element('cc_addr_po_box').disabled = false;
- Element('cc_addr_is_default').readonly = false;
- Element('cc_addr_is_default').disabled = false;
- switch (cities.value)
- {
- case '_NONE_':
- newCity.readonly = true;
- newCity.disabled = true;
- newCity.value = '';
- //resetAddrFillingFields();
- return;
- case '_NEW_':
- newCity.readonly = false;
- newCity.disabled = false;
- updateAddrNewCityOnMouseOut();
- break;
- case '_SEP_': return;
- default:
- newCity.readonly = true;
- newCity.disabled = true;
- newCity.value = '';
- }
- }
- function updateAddrNewCityOnMouseOver ()
- {
- if (Element('cc_addr_cities_new').value == Element('cc_msg_type_city').value && Element('cc_addr_cities').selectedIndex == 1)
- {
- Element('cc_addr_cities_new').value = '';
- }
- }
- function updateAddrNewCityOnMouseOut ()
- {
- if (Element('cc_addr_cities_new').value.length == 0 && Element('cc_addr_cities').selectedIndex == 1)
- {
- Element('cc_addr_cities_new').value = Element('cc_msg_type_city').value;
- }
- }
- function saveAddressFields ()
- {
- var lastIndex = CC_addr_last_selected;
- if (lastIndex == 0)
- {
- return true;
- }
- var addrFields = new Array('cc_addr_1',
- 'cc_addr_2',
- 'cc_addr_complement',
- 'cc_addr_other',
- 'cc_addr_postal_code',
- 'cc_addr_po_box',
- 'cc_addr_countries',
- 'cc_addr_states',
- 'cc_addr_cities');
- var empty = true;
- for (var i = 0; i < 8; i++)
- {
- var field = Element(addrFields[i]);
- if (field.value && field.value != '_NONE_' && field.value != '_SEP_')
- {
- empty = false;
- }
- }
- if (empty)
- {
- return true;
- }
- if (!CC_contact_full_info['addresses'])
- {
- CC_contact_full_info['addresses'] = new Array();
- }
- var addrInfo = CC_contact_full_info['addresses']['address'+Element('cc_addr_types').options[lastIndex].value];
- if (!addrInfo)
- {
- addrInfo = new Array();
- }
- addrInfo['id_address'] = Element('cc_addr_id').value;
- switch(Element('cc_addr_countries').value)
- {
- case '_SEP_':
- case '_NONE_':
- addrInfo['id_country'] = false;
- break;
- default:
- addrInfo['id_country'] = Element('cc_addr_countries').value;
- }
- switch(Element('cc_addr_states').value)
- {
- case '_SEP_':
- case '_NONE_':
- case '_NEW_':
- case '_NOSTATE_':
- addrInfo['id_state'] = false;
- break;
- default:
- addrInfo['id_state'] = Element('cc_addr_states').value;
- }
- switch(Element('cc_addr_cities').value)
- {
- case '_SEP_':
- case '_NONE_':
- case '_NEW_':
- addrInfo['id_city'] = false;
- break;
- default:
- addrInfo['id_city'] = Element('cc_addr_cities').value;
- }
- addrInfo['id_typeof_address'] = Element('cc_addr_types').options[lastIndex].value;
- addrInfo['address1'] = Element('cc_addr_1').value ? Element('cc_addr_1').value : false;
- addrInfo['address2'] = Element('cc_addr_2').value ? Element('cc_addr_2').value : false;
- addrInfo['complement'] = Element('cc_addr_complement').value ? Element('cc_addr_complement').value : false;
- addrInfo['address_other'] = Element('cc_addr_other').value ? Element('cc_addr_other').value : false;
- addrInfo['postal_code'] = Element('cc_addr_postal_code').value ? Element('cc_addr_postal_code').value : false;
- addrInfo['po_box'] = Element('cc_addr_po_box').value ? Element('cc_addr_po_box').value : false;
- addrInfo['address_is_default'] = Element('cc_addr_is_default').checked ? '1' : '0';
- CC_contact_full_info['addresses']['address'+Element('cc_addr_types').options[lastIndex].value] = addrInfo;
- if (Element('cc_addr_cities').value == '_NEW_' &&
- Element('cc_msg_type_city').value != Element('cc_addr_cities_new').value &&
- Element('cc_addr_cities_new').value != '')
- {
- var addrRootInfo = CC_contact_full_info['addresses']['new_cities'];
- if (!addrRootInfo)
- {
- addrRootInfo = new Array();
- }
- var i = addrRootInfo.length;
- addrRootInfo[addrInfo['id_typeof_address']] = new Array();
- addrRootInfo[addrInfo['id_typeof_address']]['id_country'] = Element('cc_addr_countries').value;
- addrRootInfo[addrInfo['id_typeof_address']]['id_state'] = Element('cc_addr_states').value.charAt(0) != '_' ? Element('cc_addr_states').value : null;
- addrRootInfo[addrInfo['id_typeof_address']]['city_name'] = Element('cc_addr_cities_new').value;
- CC_contact_full_info['addresses']['new_cities'] = addrRootInfo;
- }
- if (Element('cc_addr_states').value == '_NEW_' &&
- Element('cc_msg_type_state').value != Element('cc_addr_states_new').value &&
- Element('cc_addr_states_new').value != '')
- {
- var addrRootInfo = CC_contact_full_info['addresses']['new_states'];
- if (!addrRootInfo)
- {
- addrRootInfo = new Array();
- }
- var i = addrRootInfo.length;
- addrRootInfo[addrInfo['id_typeof_address']] = new Array();
- addrRootInfo[addrInfo['id_typeof_address']]['id_country'] = Element('cc_addr_countries').value;
- addrRootInfo[addrInfo['id_typeof_address']]['state_name'] = Element('cc_addr_states_new').value;
- CC_contact_full_info['addresses']['new_states'] = addrRootInfo;
- }
- return true;
- }
- /********* End Addresses Functions *********/
- /********* Begin Connections Functions ************/
- function connGetHTMLLine ()
- {
- var _label = (CC_contact_full_info['connections']
- && typeof(CC_contact_full_info['connections'][CC_conn_last_selected])!= 'undefined'
- && typeof(CC_contact_full_info['connections'][CC_conn_last_selected][CC_conn_count]) != 'undefined'
- ? CC_contact_full_info['connections'][CC_conn_last_selected][CC_conn_count]['name']
- : Element("cc_conn_type_sel").value);
- var cc_conn_default = Element("cc_phone_default").style.display == '' ? Element("cc_phone_default") : Element("cc_email_default");
- cc_conn_default.disabled = false;
- var idx_conn = 0;
- for(idx_conn; idx_conn < cc_conn_default.options.length; idx_conn++)
- if(cc_conn_default.options[idx_conn].value == _label)
- break;
- if(idx_conn == cc_conn_default.options.length)
- cc_conn_default.options[idx_conn] = new Option (_label,_label, false,false);
- if (!document.all)
- {
- if (Element("cc_conn_type_1").checked)
- {
- 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>'+
- //'<td style="width: 30px;" align="right"><input name="cc_conn_is_default" id="cc_conn_is_default_'+ CC_conn_count +'" type="radio"></td>'+
- '<td style="width: 10px;" align="right"><input id="cc_conn_name_'+CC_conn_count+'" type="hidden"><td style="width: 100px; padding-left: 55px;" align="left"><span style="width: 150px;" id="cc_conn_label_'+CC_conn_count+'">'+_label+':'+'</span></td>' +
- '<td align="left"><input id="cc_conn_value_'+ CC_conn_count +'" style="width: 150px; text-transform:lowercase;" maxlength="100" type="text"> ' +
- '<img align="top" alt="X" title="X" src="templates/default/images/x.png" style="width:18px; height:18px; cursor:pointer;" onclick="javascript:removeConnField(\'cc_conn_tr_' + CC_conn_count + '\')"/></td>';
- }
- else if (Element("cc_conn_type_2").checked)
- {
- 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>'+
- //'<td style="width: 30px;" align="right"><input name="cc_conn_is_default" id="cc_conn_is_default_'+ CC_conn_count +'" type="radio"></td>'+
- '<td style="width: 10px;" align="right"><input id="cc_conn_name_'+CC_conn_count+'" type="hidden"><td style="width: 100px; padding-left: 55px;" align="left"><span style="width: 150px;" id="cc_conn_label_'+CC_conn_count+'">'+_label+':'+'</span></td>' +
- '<td align="left"><input id="cc_conn_value_'+ CC_conn_count +'" style="width: 150px; text-transform:lowercase;" maxlength="30" type="text" onkeyup="formatPhone(this);"> ' +
- '<img align="top" alt="X" title="X" src="templates/default/images/x.png" style="width:18px; height:18px; cursor:pointer;" onclick="javascript:removeConnField(\'cc_conn_tr_' + CC_conn_count + '\')"/></td>';
- }
- }
- else
- {
- var tds = new Array();
- var inputs = new Array();
- var img = document.createElement('img');
- for (var i = 0; i < 4; i++)
- {
- tds[i] = document.createElement('td');
- }
- tds[0].style.position = 'absolute';
- tds[0].style.visibility = 'hidden';
- tds[0].style.zIndex = '-1';
- var remove_id = 'cc_conn_tr_'+CC_conn_count;
- img.alt = 'X';
- img.src = 'templates/default/images/x.png';
- img.style.width = '18px';
- img.style.height = '18px';
- img.style.cursor = 'pointer';
- img.align = 'top';
- img.onclick = function(e){ removeConnField(remove_id);};
- for (var i = 0; i < 3; i++)
- {
- inputs[i] = document.createElement('input');
- }
- inputs[0].id = 'cc_conn_id_'+CC_conn_count;
- inputs[0].type = 'hidden';
- inputs[0].value = '_NEW_';
- inputs[1].id = 'cc_conn_name_'+CC_conn_count;
- inputs[1].type = 'hidden';
- inputs[2].id = 'cc_conn_value_'+CC_conn_count;
- inputs[2].type = 'text';
- inputs[2].style.width = '150px';
- var _span = document.createElement("SPAN");
- _span.style.width = "100px";
- _span.id = "cc_conn_label_"+CC_conn_count;
- _span.innerHTML = _label + ':';
- tds[0].appendChild(inputs[0]);
- tds[1].width = '40px';
- tds[1].appendChild(inputs[1]);
- tds[1].align = 'left';
- tds[1].style.padding = "0px 0px 0px 75px";
- tds[1].appendChild(_span);
- tds[2].appendChild(inputs[2]);
- tds[2].align = 'left';
- tds[2].innerHTML +=" ";
- tds[2].appendChild(img);
- return tds;
- }
- }
- function connAddNewLine ()
- {
- var _emptyLine = (!CC_contact_full_info['connections']
- || typeof(CC_contact_full_info['connections'][CC_conn_last_selected]) == 'undefined'
- || typeof(CC_contact_full_info['connections'][CC_conn_last_selected][CC_conn_count]) == 'undefined');
- if(_emptyLine) {
- if(Element("cc_conn_type_sel").value == '-1'){
- return false;
- }
- for(k = 0; k < CC_conn_count; k++) {
- if(Element("cc_conn_name_"+k) && Element("cc_conn_name_"+k).value != "" && Element("cc_conn_name_"+k).value == Element("cc_conn_type_sel").value) {
- alert(get_lang('You already have an entry for the type "') + Element("cc_conn_type_sel").value+'"!');
- Element("cc_conn_type_sel").options.selectedIndex = 0;
- return false;
- }
- }
- }
- if (!document.all)
- {
- var obj = addHTMLCode('cc_conn', 'cc_conn…
Large files files are truncated, but you can click here to view the full file