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