PageRenderTime 63ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 1ms

/contactcenter/js/cc.js

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