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

Revision 3628, 4.7 KB checked in by rafaelraymundo, 13 years ago (diff)

Ticket #1361 - Limitar Pesquisa de Nome na Avançada ContactCenter?

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        data['search_for'] = Element('ccSearchInp0').value;
83
84        var invalidChars = /[\%\?]/;
85        if(invalidChars.test(data['search_for']) || invalidChars.test(data['search_for_area'])){
86                showMessage(Element('cc_msg_err_invalid_serch').value);
87                return;
88        }
89
90        var search_for = data['search_for'].split(' ');
91        var greaterThanMin = false;
92        var use_length = v_min;
93
94        for (i = 0; i < search_for.length; i++)
95        {
96                if (search_for[i].length >= use_length)
97                {
98                        greaterThanMin = true;
99                }
100        }
101
102        if (!greaterThanMin){
103                alert("Favor fazer a consulta com pelo menos " + v_min + " caracteres!");
104                return;
105        }
106
107        if (type=='groups') {
108                data['fields']['id']     = 'group.id_group';                   
109                data['fields']['search'] = 'group.title';
110        }               
111        else {                 
112                data['fields']['id']     = 'contact.id_contact';               
113                data['fields']['search'] = 'contact.names_ordered';                                     
114        }
115        //data['search_for'] = Element('ccSearchInp0').value;
116        data['full_search'] = new Array();
117       
118        data['full_search']['corporate'] = Element('ccSearchInp1').disabled?'':Element('ccSearchInp1').value;
119        data['full_search']['mail'] = Element('ccSearchInp2').value ;
120        data['full_search']['phone'] = Element('ccSearchInp3').value ;
121        var handler = function(responseText) {
122                ccSearch.mount_handler(responseText);
123                _this.close();         
124        }
125        Connector.newRequest('fullSearch',CC_url+'search&data='+serialize(data), 'GET',handler);
126}
127
128ccFullSearch.prototype.close = function() {
129                this.win.close();
130}
131
132ccFullSearch.prototype.clean = function() {
133        for (i=0; i<this.fields.length; i++) {
134                Element('ccSearchInp'+i).value = '';
135        }
136}
137
138var ccFullSearchVar = new ccFullSearch();
Note: See TracBrowser for help on using the repository browser.