Ignore:
Timestamp:
10/06/09 10:27:46 (15 years ago)
Author:
wmerlotto
Message:

Ticket #628 - Implementada a funcionalidade de adição no catálogo compartilhado.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/contactcenter/js/cc.js

    r1280 r1496  
    3838\***********************************************/ 
    3939 
     40var owners = new Array(); 
     41var flag_compartilhado = false; 
     42var qtd_compartilhado = 0; 
     43 
    4044var CC_visual = 'table'; 
    4145/* Cards Variables */ 
     
    172176        Element("cc_conn_type_sel").disabled = true; 
    173177        Element("cc_conn_type_sel").selectedIndex = 0; 
     178        Element("cc_contact_sharing").style.display = 'none'; 
     179} 
     180 
     181function openFullAddShared(){ 
     182        if (flag_compartilhado) 
     183        { 
     184                if(!fullAddWin && !is_ie) 
     185                        __f(); 
     186 
     187                resetFullAdd(); 
     188                populateFullAddConst(); 
     189                fullAddWin.open(); 
     190                tabs._showTab('cc_contact_tab_0'); 
     191                Element("cc_conn_type_1").checked = false; 
     192                Element("cc_conn_type_2").checked = false; 
     193                Element("cc_conn_type_sel").disabled = true; 
     194                Element("cc_conn_type_sel").selectedIndex = 0; 
     195                Element("cc_contact_sharing").align = 'center'; 
     196                Element("cc_contact_sharing").style.display = 'block'; 
     197                Element("cc_contact_shared_types").disabled = true; 
     198                populateSharingSelect(); 
     199        } else 
     200        { 
     201                if(qtd_compartilhado != 0) 
     202                { 
     203                        ccTree.select(0.2); 
     204                        ccTree.setCatalog(0.2); 
     205                        if(!fullAddWin && !is_ie) 
     206                                __f(); 
     207                        resetFullAdd(); 
     208                        populateFullAddConst(); 
     209                        fullAddWin.open(); 
     210                        tabs._showTab('cc_contact_tab_0'); 
     211                        Element("cc_conn_type_1").checked = false; 
     212                        Element("cc_conn_type_2").checked = false; 
     213                        Element("cc_conn_type_sel").disabled = true; 
     214                        Element("cc_conn_type_sel").selectedIndex = 0; 
     215                        Element("cc_contact_sharing").aling = 'center'; 
     216                        Element("cc_contact_sharing").style.display = 'block'; 
     217                        Element("cc_contact_shared_types").disabled = true; 
     218                        populateSharingSelect(); 
     219                } else 
     220                        showMessage(Element('cc_msg_err_shared').value); 
     221        } 
    174222} 
    175223 
     
    180228function newContact(){ 
    181229        openFullAdd(); 
     230} 
     231function newSharedContact(){ 
     232        openFullAddShared(); 
    182233} 
    183234/************ Edit Contact *************/ 
     
    202253        Updates all the constant fields in the 
    203254        full add window, like Prefixes, Suffixes, 
    204         Countries and Types 
     255        Countries, Types and Shared catalogs 
    205256*/ 
     257 
     258function populateSharingSelect() 
     259{ 
     260        var handler = function(responseText) 
     261        { 
     262                var data = unserialize(responseText); 
     263                var sharers = Element('cc_contact_shared_types'); 
     264 
     265                if (typeof(data) != 'object') 
     266                { 
     267                        showMessage(Element('cc_msg_err_contacting_server').value); 
     268                        return; 
     269                } 
     270                 
     271                if (typeof(data[3]) == 'object') 
     272                { 
     273                        sharers.disabled = false; 
     274                        var i = 1; 
     275                        if (data[6].length != 0) 
     276                        { 
     277                                for (var j in data[6]) 
     278                                { 
     279                                        sharers.options[i] = new Option(data[6][j]['cn'], j); 
     280                                        owners[i] = j; 
     281                                        i++; 
     282                                } 
     283                        } else 
     284                                sharers.disabled = true; 
     285                        return; 
     286                } else 
     287                { 
     288                        showMessage(Element('cc_msg_err_contacting_server').value); 
     289                        fullAddWin.close(); 
     290                        return; 
     291                } 
     292 
     293        }; 
     294        Connector.newRequest('populateSharingSelect', '../index.php?menuaction=contactcenter.ui_data.data_manager&method=get_cards_data', 'POST', handler); 
     295} 
     296 
    206297function populateFullAddConst() 
    207298{ 
     
    442533                CC_full_add_photo = true; 
    443534        } 
    444  
    445         setTimeout('postFullAddInfo()', 100); 
     535        if (Element('cc_contact_sharing').style.display == 'none') 
     536                setTimeout('postFullAddInfo()', 100); 
     537        else 
     538                setTimeout('postFullAddInfoShared()', 100); 
    446539} 
    447540 
     
    467560                updateCards(); 
    468561        }; 
    469  
    470562        Connector.newRequest('postFullAddInfo', CC_url+'post_full_add', 'POST', handler, getFullAddData()); 
     563} 
     564 
     565function postFullAddInfoShared() 
     566{ 
     567        var handler = function (responseText) 
     568        { 
     569                var data = unserialize(responseText); 
     570                if (typeof(data) != 'object') 
     571                { 
     572                        showMessage(Element('cc_msg_err_contacting_server').value); 
     573                        return; 
     574                } 
     575 
     576                if (data['status'] != 'ok') 
     577                { 
     578                        showMessage(data['msg']); 
     579                        return; 
     580                } 
     581 
     582                fullAddWin.close(); 
     583                updateCards(); 
     584        }; 
     585        Connector.newRequest('postFullAddInfoShared', CC_url+'post_full_add_shared', 'POST', handler, getFullAddData()); 
    471586} 
    472587 
     
    476591        var empty = true; 
    477592        var replacer = '__##AND##__'; 
    478          
     593 
    479594        data['commercialAnd'] = replacer; 
    480595         
     
    484599                data.length++; 
    485600        } 
    486  
     601         
     602        /* Owner do contato (Para o caso de adicao de contato compartilhado) */ 
     603        if (Element('cc_contact_sharing').style.display == 'block') 
     604        { 
     605                var index = Element('cc_contact_shared_types').selectedIndex; 
     606                data['owner'] = replaceComAnd(owners[index], replacer);  
     607                data.length++; 
     608        } 
     609         
    487610        /* Status: Full Added */ 
    488611        data['id_status'] = CC_STATUS_FULL_ADD; 
     
    580703        } 
    581704 
     705        var serial = serialize(data); 
    582706        return 'data=' + escape(serialize(data)); 
    583707} 
     
    585709function checkFullAdd() 
    586710{ 
     711 
     712        /* Checa se o listbox esta desativado ou é nulo, ou seja, não existe catálogos compartilhados com o user atual */ 
     713 
     714        if (!(Element('cc_contact_sharing').style.display == 'none' )) 
     715        { 
     716                if (Element('cc_contact_shared_types').disabled == true) 
     717                {        
     718                        showMessage('Nenhum catálogo compartilhado existente'); 
     719                        return false; 
     720                } 
     721                if (Element('cc_contact_shared_types').selectedIndex == 0) 
     722                { 
     723                        showMessage('Nenhum catálogo selecionado'); 
     724                        return false; 
     725                } 
     726        } 
     727         
    587728        /* Check Personal Data */ 
    588  
    589729        if (Element('cc_pd_given_names').value == '') 
    590730        { 
     
    16331773                return; 
    16341774        } 
    1635          
     1775 
    16361776        var handler = function (responseText) 
    16371777        { 
     
    19142054                                                                        Element(id+':'+data[2][k]).innerHTML = data[3][pos][k]; 
    19152055                                                                } 
    1916                                                                 if(data[3][pos][9]) 
    1917                                                                         Element(id+':'+data[2][k]).innerHTML += "<br><span style='margin-left:30px'><font size='-2' color='#808080'><i>"+data[3][pos][9]+"</i></font></span>";   
     2056                                                                if(data[3][pos][9]){ 
     2057                                                                        Element(id+':'+data[2][k]).innerHTML += "<br><span style='margin-left:30px'><font size='-2' color='#808080'><i>"+data[3][pos][9]+"</i></font></span>";  } 
    19182058                                                                break; 
    19192059                                                         
     
    23372477{ 
    23382478        var data  = new Array(); 
    2339  
     2479        flag_compartilhado = false; 
    23402480        if ( letter != CC_actual_letter ) 
    23412481        { 
     
    23602500                return; 
    23612501        } 
     2502 
    23622503 
    23632504        var handler = function (responseText) 
     
    23902531                if (typeof(data[3]) == 'object') 
    23912532                { 
     2533                        if (data[8] == 'bo_shared_people_manager') 
     2534                        { 
     2535                                flag_compartilhado = true; 
     2536                        } 
     2537                        else 
     2538                        { 
     2539                                flag_compartilhado = false; 
     2540                        } 
     2541                        qtd_compartilhado = data[9]; 
    23922542                        CC_npages = parseInt(data[0]); 
    23932543                        CC_actual_page = parseInt(data[1]);                      
Note: See TracChangeset for help on using the changeset viewer.