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