source: branches/2.2/contactcenter/js/cc_full_search.js @ 3282

Revision 3282, 4.1 KB checked in by eduardoalex, 14 years ago (diff)

Ticket #1251 - Commit principal com adição da melhoria no módulo

Line 
1/**
2 * @author diogenes
3 */
4function ccFullSearch() {
5        var win;
6        var fields = null;
7}
8       
9ccFullSearch.prototype.showForm = function() {
10        div = document.getElementById('cc_searchDiv');
11        if(this.fields==null)
12                this.fields = new Array(Element('cc_qa_given_names').value, Element('cc_corporate').value+":", Element('cc_qa_email').value, Element('cc_qa_phone').value);
13        if(div)
14                this.showWindow(div);
15        else {
16               
17                var el = document.createElement("DIV");                                                                 
18                el.style.visibility = "hidden";                                                                 
19                el.style.position = "absolute";
20                el.style.left = "0px";
21                el.style.top = "0px";
22                el.style.width = "0px";
23                wHeight = Element('ccQAWinHeight').value;
24                el.style.height = wHeight + 'px';
25                el.className = "div_cc_rectQuickAddContact";
26                el.id = 'cc_searchDiv';
27                document.body.appendChild(el);                                                                                                                         
28                el.innerHTML = "";                                                             
29
30                var fieldsTop = 10;
31                var fieldsSpace = 30;
32                for (i=0; i<this.fields.length; i++) {
33                        el.innerHTML += '<span id="ccSearchSpan' + i + '" style="position: absolute; top: ' +  (fieldsTop+i*fieldsSpace) + 'px; left: 5px; width: 100px; text-align: right; border: 0px solid #999;">' + this.fields[i] + '</span>';                   
34                        el.innerHTML += '<input id="ccSearchInp' + i + '" type="text" maxlength="30" style="position: absolute; top: ' + (fieldsTop + i * fieldsSpace) + 'px; left: 110px; width: 135px;">';
35                }
36                el.innerHTML +='<div id="ccSearchFunctions" style="border: 0px solid black; width: 220px; height: 20px">' +
37                        '<input title="' + Element('cc_panel_search_text').value + '"  type="button" onclick="ccFullSearchVar.go();" style="position: absolute; top: ' + (fieldsTop+i*fieldsSpace) + 'px; left: 35px; width: 60px" value="'+Element('cc_panel_search_text').value+'"/>' +
38                        '<input title="' + Element('cc_msg_clean').value + '" type="button" onclick="ccFullSearchVar.clean();" value="' + Element('cc_msg_clean').value + '" style="position: absolute; top: ' + (fieldsTop+i*fieldsSpace) + 'px; left: 100px; width: 60px" />' +
39                        '<input title="' + Element('cc_qa_close').value + '" type="button" onclick="ccFullSearchVar.close();" value="' + Element('cc_qa_close').value + '" style="position: absolute; top: ' + (fieldsTop+i*fieldsSpace) + 'px; left: 165px; width: 60px" />' +
40                        '</div>';
41                el.innerHTML += "<br>";
42
43                this.showWindow(el);
44        }
45               
46}
47
48ccFullSearch.prototype.showWindow = function (div)
49{               
50        if(! this.win) {
51                win = new dJSWin({                     
52                        id: 'ccSearch_'+div.id,
53                        content_id: div.id,
54                        width: '255px',
55                        height: wHeight+'px',
56                        title_color: '#3978d6',
57                        bg_color: '#eee',
58                        title: Element('cc_cs_title').value,                                           
59                        title_text_color: 'white',
60                        button_x_img: Element('cc_phpgw_img_dir').value+'/winclose.gif',
61                        border: true });
62               
63                this.win = win;
64                win.draw();                     
65        }
66        if((ccTree.actualCatalog=='bo_people_catalog') ||
67                (ccTree.actualCatalog=='bo_shared_people_manager')) //Habilita empresa apenas para catálogos que não sejam do ldap.
68                Element('ccSearchInp1').disabled = false;
69        else
70                Element('ccSearchInp1').disabled = true;
71        this.win.open();
72}
73
74ccFullSearch.prototype.go = function () {
75
76        var _this = this;
77        var data = new Array();
78        var type = Element('cc_type_contact').value;
79       
80        data['fields'] = new Array();
81       
82        if (type=='groups') {
83                data['fields']['id']     = 'group.id_group';                   
84                data['fields']['search'] = 'group.title';
85        }               
86        else {                 
87                data['fields']['id']     = 'contact.id_contact';               
88                data['fields']['search'] = 'contact.names_ordered';                                     
89        }
90        data['search_for'] = Element('ccSearchInp0').value;
91        data['full_search'] = new Array();
92       
93        data['full_search']['corporate'] = Element('ccSearchInp1').disabled?'':Element('ccSearchInp1').value;
94        data['full_search']['mail'] = Element('ccSearchInp2').value ;
95        data['full_search']['phone'] = Element('ccSearchInp3').value ;
96        var handler = function(responseText) {
97                ccSearch.mount_handler(responseText);
98                _this.close();         
99        }
100        Connector.newRequest('fullSearch',CC_url+'search&data='+serialize(data), 'GET',handler);
101}
102
103ccFullSearch.prototype.close = function() {
104                this.win.close();
105}
106
107ccFullSearch.prototype.clean = function() {
108        for (i=0; i<this.fields.length; i++) {
109                Element('ccSearchInp'+i).value = '';
110        }
111}
112
113var ccFullSearchVar = new ccFullSearch();
Note: See TracBrowser for help on using the repository browser.