Ignore:
Timestamp:
04/11/11 11:47:31 (13 years ago)
Author:
rafaelraymundo
Message:

Ticket #1593 - Criação de grupos usando contatos apartir do catalogo geral.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.0.1/contactcenter/js/ccAddGroup.js

    r3348 r3970  
    213213        cAddGroup.prototype.addUser = function(){ 
    214214 
    215                 select = Element("contact_list"); 
    216                 select_in = this.contact_in_list;                                                                
     215                var select = Element("contact_list"); 
     216                var select_in = this.contact_in_list; 
    217217                 
    218218                for (i = 0 ; i < select.length ; i++) {                          
     
    245245        }        
    246246 
     247        cAddGroup.prototype.setSelectedSourceLevel = function(sourceLevel) 
     248        { 
     249            var ccAGSourceSelect = Element('ccAGSourceSelect'); 
     250            var selectedLevel = ''; 
     251            for (i = 0; i < ccAGSourceSelect.length; i++) 
     252            { 
     253                if (ccAGSourceSelect[i].selected == true) 
     254                { 
     255                    selectedLevel = ccAGSourceSelect[i].value; 
     256                } 
     257            } 
     258 
     259            if (selectedLevel != sourceLevel) 
     260            { 
     261                for (i = 0; i < ccAGSourceSelect.length; i++) 
     262                { 
     263                    if (ccAGSourceSelect[i].value == sourceLevel) 
     264                    { 
     265                        ccAGSourceSelect[i].selected = true; 
     266                    } 
     267                } 
     268            } 
     269            this.setCatalog(); 
     270        } 
     271 
     272        cAddGroup.prototype.loadPersonalContacts = function(){ 
     273            handler = function(data) 
     274            { 
     275                if (data) 
     276                { 
     277                    data = unserialize(data); 
     278                    if (data.result == 'ok') 
     279                    { 
     280                        var options_contact_list = Element('span_contact_list'); 
     281                        var select_contact_list = '<select id="contact_list" multiple name="contact_list[]" style="width:280px" size="10">'; 
     282                        select_contact_list += data['contact_list'] + "</select>"; 
     283                        options_contact_list.innerHTML = select_contact_list; 
     284                    } 
     285                    return; 
     286                } 
     287 
     288                alert(get_lang('Erro ao carregar contatos pessoais.')); 
     289 
     290 
     291            } 
     292 
     293            Connector.newRequest('cAddGroup.loadPersonalContacts', CC_url+'get_group', 'GET', handler); 
     294 
     295        } 
     296 
     297        cAddGroup.prototype.clearSourceList = function(){ 
     298            var contact_list = Element("contact_list"); 
     299            var options = contact_list.options; 
     300            for (j =0; j < options.length; j++) { 
     301                contact_list.options[j].selected = false; 
     302                contact_list.options[j--] = null; 
     303            } 
     304        } 
     305 
     306        // usar ui_data.get_cards_data('all', 1); 
     307        cAddGroup.prototype.search = function(){ 
     308 
     309            var type = Element('cc_type_contact').value; 
     310 
     311            var data = new Array(); 
     312            data['fields'] = new Array(); 
     313 
     314            // never search groups 
     315            data['fields']['id']     = 'contact.id_contact'; 
     316            data['fields']['search'] = 'contact.names_ordered'; 
     317 
     318            var ccAGSearchTerm = Element('ccAGSearchTerm'); 
     319 
     320            data['search_for'] = ccAGSearchTerm.value; 
     321            data['ccAddGroup'] = true; 
     322 
     323            var invalidChars = /[\%\?]/; 
     324            if(invalidChars.test(data['search_for']) || invalidChars.test(data['search_for_area'])){ 
     325                showMessage(Element('cc_msg_err_invalid_serch').value); 
     326                return; 
     327            } 
     328 
     329            var search_for = data['search_for'].split(' '); 
     330            var greaterThan4 = false; 
     331            var use_length = v_min; 
     332 
     333            if (search_for.length == 1) 
     334            { 
     335                if (search_for[0].length == 0) 
     336                { 
     337                    search_for[0] = "*"; 
     338                    data['search_for'] = "*"; 
     339                    use_length = 1; 
     340                } 
     341            } 
     342 
     343            for (i = 0; i < search_for.length; i++) 
     344            { 
     345                if (search_for[i].length >= use_length) 
     346                { 
     347                    greaterThan4 = true; 
     348                } 
     349            } 
     350 
     351            if (!greaterThan4){ 
     352                alert("Favor fazer a consulta com pelo menos " + v_min + " caracteres!"); 
     353                return; 
     354            } 
     355 
     356            var handler = function(data) 
     357            { 
     358                data = unserialize(data); 
     359 
     360                if( !data ) 
     361                    return false; 
     362                ccAddGroup.clearSourceList(); 
     363                ccAGSearchTerm.value = ''; 
     364                if (typeof(data) != 'object') 
     365                { 
     366                    showMessage(Element('cc_msg_err_contacting_server').value); 
     367                    return false; 
     368                } 
     369 
     370                if (data[3].length > 300) 
     371                { 
     372                    alert("Mais de 300 resultados foram retornados! \n Favor refinar sua busca."); 
     373 
     374                    return false; 
     375                } 
     376 
     377                var contact_list = Element('contact_list'); 
     378                for (var i=0; i < data[3].length; i++) 
     379                { 
     380 
     381                   var item = data[3][i]; 
     382                   var id = 'ldap:'+data[11]+':'+item[6]; 
     383                   var option = document.createElement('OPTION'); 
     384                   option.value = id; 
     385                   option.text = item[1]+' ('+item[4]+')'; 
     386                   contact_list.options[contact_list.options.length] = option; 
     387                } 
     388 
     389            } 
     390 
     391            Connector.newRequest('ccAGSearch', CC_url+'search&data='+serialize(data), 'GET', handler); 
     392 
     393        } 
     394 
     395        cAddGroup.prototype.setCatalog = function(){ 
     396            var select = Element('ccAGSourceSelect'); 
     397            var catalogLevel = '0.0'; 
     398            for (i = 0 ; i < select.length ; i++) { 
     399                if (select.options[i].selected) 
     400                { 
     401                    catalogLevel = select.options[i].value; 
     402                    break; 
     403                } 
     404 
     405            } 
     406            ccTree.select(catalogLevel); 
     407 
     408            if (catalogLevel == '0.0') 
     409            { 
     410                ccAddGroup.loadPersonalContacts(); 
     411            } 
     412            else 
     413                { 
     414                   ccAddGroup.clearSourceList(); 
     415                } 
     416 
     417            //eval(refresh); 
     418 
     419        } 
     420         
    247421        /* Build the Object */ 
    248422        var ccAddGroup ; 
Note: See TracChangeset for help on using the changeset viewer.