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