Ignore:
Timestamp:
09/06/10 16:19:03 (14 years ago)
Author:
rodsouza
Message:

Ticket #884 - Adicionando novos campos a exportação de contato no padrão ExpressoLivre?

Location:
branches/2.2/contactcenter/inc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2/contactcenter/inc/class.so_group.inc.php

    r1280 r3215  
    110110                function selectAllContacts( $field = false ,$shared_from=null) 
    111111                { 
    112                         if($shared_from==null) {                 
    113                                 $query = 'select C.id_connection, A.id_contact, A.names_ordered, C.connection_value , B.id_typeof_contact_connection from phpgw_cc_contact A,'. 
    114                                 'phpgw_cc_contact_conns B, phpgw_cc_connections C where '. 
    115                                 'A.id_contact = B.id_contact and B.id_connection = C.id_connection and '. 
    116                                 'A.id_owner ='.$this->owner.' and C.connection_is_default = true '; 
     112                        if ( $shared_from == NULL ) 
     113                        { 
     114                                $query = "select" 
     115                                                . " phpgw_cc_connections.id_connection," 
     116                                                . " phpgw_cc_contact.id_contact," 
     117                                                . " phpgw_cc_contact.names_ordered," 
     118                                                . " phpgw_cc_contact.alias," 
     119                                                . " phpgw_cc_connections.connection_value ," 
     120                                                . " phpgw_cc_contact_conns.id_typeof_contact_connection," 
     121                                                . " phpgw_cc_addresses.address1," 
     122                                                . " phpgw_cc_addresses.complement," 
     123                                                . " phpgw_cc_addresses.postal_code," 
     124                                                . " phpgw_cc_city.city_name," 
     125                                                . " phpgw_cc_state.state_name," 
     126                                                . " phpgw_cc_addresses.id_country"; 
     127 
     128                                $query .= " from" 
     129                                                . " phpgw_cc_contact" 
     130                                                . " inner join phpgw_cc_contact_conns on ( phpgw_cc_contact.id_contact = phpgw_cc_contact_conns.id_contact )" 
     131                                                . " inner join phpgw_cc_connections on ( phpgw_cc_contact_conns.id_connection = phpgw_cc_connections.id_connection )" 
     132                                                . " left join phpgw_cc_contact_addrs on ( phpgw_cc_contact.id_contact = phpgw_cc_contact_addrs.id_contact )" 
     133                                                . " left join phpgw_cc_addresses on ( phpgw_cc_contact_addrs.id_address = phpgw_cc_addresses.id_address )" 
     134                                                . " left join phpgw_cc_city on ( phpgw_cc_addresses.id_city = phpgw_cc_city.id_city )" 
     135                                                . " left join phpgw_cc_state on ( phpgw_cc_addresses.id_state = phpgw_cc_state.id_state)"; 
     136 
     137                                $query .= " where" 
     138                                                . " phpgw_cc_contact.id_owner = {$this->owner}" 
     139                                                . " and phpgw_cc_connections.connection_is_default = true"; 
     140 
    117141                        } 
    118142                        else { 
     
    121145                                                          B.acl_appname = \'contactcenter\' and B.acl_rights & 1 <> 0  
    122146                                                          and A.id_typeof_contact_relation=1 and A.id_contact = '.$shared_from.' and A.id_related='.$this->owner; 
    123                                  
     147 
    124148                                $query = 'select C.id_connection, A.id_contact, A.names_ordered, C.connection_value , B.id_typeof_contact_connection from phpgw_cc_contact A,'. 
    125149                                'phpgw_cc_contact_conns B, phpgw_cc_connections C where '. 
     
    130154 
    131155                        if ( $field == 'only_email' ) 
    132                                 $query .= 'and B.id_typeof_contact_connection = 1 '; 
    133  
    134                         $query .= ' order by A.names_ordered,C.connection_value'; 
    135  
    136                                          
    137                         if (!$this->db->query($query)) 
    138                         { 
    139                                 exit ('Query failed! File: '.__FILE__.' on line'.__LINE__); 
    140                         } 
    141                           
     156                                $query .= 'and phpgw_cc_contact_conns.id_typeof_contact_connection = 1 '; 
     157 
     158                        $query .= ' order by phpgw_cc_contact.names_ordered, phpgw_cc_connections.connection_value'; 
     159 
     160                        if (!$this->db->query($query)) 
     161                        { 
     162                                exit ('Query failed! File: '.__FILE__.' on line'.__LINE__); 
     163                        } 
     164 
    142165                        $return = array(); 
    143                          
     166 
    144167                        while($this->db->next_record()) 
    145168                        { 
    146169                                $return[] = $this->db->row();  
    147170                        } 
    148                          
    149                         if(!count($return)) 
    150                                 return $return;                          
    151                         // Essa iteração transforma uma esturuta com contatos redundantes e separados por email ou tel. 
    152                         // em outra com apenas 1 elemento pra cada contato 
    153                         foreach($return as $i => $object){ 
    154                                 if ($object['id_typeof_contact_connection'] == 1){ 
    155                                         $all_contacts[$object['id_contact']]['connection_value'] = $object['connection_value']; 
    156                     $all_contacts[$object['id_contact']]['names_ordered'] = $object['names_ordered']; 
    157                     $all_contacts[$object['id_contact']]['id_contact'] = $object['id_contact']; 
    158                     $all_contacts[$object['id_contact']]['id_connection'] = $object['id_connection']; 
     171 
     172                        if( ! count( $return ) ) 
     173                                return $return; 
     174 
     175                        foreach( $return as $i => $object ) 
     176                        { 
     177                                switch( $object[ 'id_typeof_contact_connection' ] ) 
     178                                { 
     179                                        case 1 : 
     180                                                $all_contacts[ $object[ 'id_contact' ] ][ 'connection_value' ] = $object[ 'connection_value' ]; 
     181                                                break; 
     182                                        case 2 : 
     183                                                $all_contacts[ $object[ 'id_contact' ] ][ 'phone' ] = $object[ 'connection_value' ]; 
     184                                                break; 
    159185                                } 
    160                                 else  
    161                                         if ($object['id_typeof_contact_connection'] == 2){ 
    162                                                 $all_contacts[$object['id_contact']]['phone'] = $object['connection_value']; 
    163                                                 $all_contacts[$object['id_contact']]['names_ordered'] = $object['names_ordered']; 
    164                                                 $all_contacts[$object['id_contact']]['id_contact'] = $object['id_contact']; 
    165                                                 $all_contacts[$object['id_contact']]['id_connection'] = $object['id_connection']; 
    166                                         } 
    167                         } 
    168                          
     186 
     187                                $all_contacts[ $object[ 'id_contact' ] ][ 'names_ordered' ] = $object[ 'names_ordered' ]; 
     188                                $all_contacts[ $object[ 'id_contact' ] ][ 'id_contact' ]    = $object[ 'id_contact' ]; 
     189                                $all_contacts[ $object[ 'id_contact' ] ][ 'id_connection' ] = $object[ 'id_connection' ]; 
     190                                $all_contacts[ $object[ 'id_contact' ] ][ 'alias' ]         = $object[ 'alias' ]; 
     191                                $all_contacts[ $object[ 'id_contact' ] ][ 'address1' ]      = $object[ 'address1' ]; 
     192                                $all_contacts[ $object[ 'id_contact' ] ][ 'complement' ]    = $object[ 'complement' ]; 
     193                                $all_contacts[ $object[ 'id_contact' ] ][ 'postal_code' ]   = $object[ 'postal_code' ]; 
     194                                $all_contacts[ $object[ 'id_contact' ] ][ 'city_name' ]     = $object[ 'city_name' ]; 
     195                                $all_contacts[ $object[ 'id_contact' ] ][ 'state_name' ]    = $object[ 'state_name' ]; 
     196                                $all_contacts[ $object[ 'id_contact' ] ][ 'id_country' ]    = $object[ 'id_country' ]; 
     197                        } 
     198 
    169199                        return array_values($all_contacts); 
    170                 }                
    171                  
     200                } 
     201 
    172202                function verifyContact($email) 
    173203                { 
  • branches/2.2/contactcenter/inc/class.ui_data.inc.php

    r3211 r3215  
    34043404                                echo null; 
    34053405 
    3406 /**rev 104**/ 
    3407                         // Essa iteraᅵᅵo transforma uma esturuta com contatos redundantes e separados por email ou tel. 
    3408                         // em outra com apenas 1 elemento pra cada contato 
    3409         /*              $i=0; 
    3410                         foreach($contacts as $object){ 
    3411                                 $i=($object['id_contact'] - 1); 
    3412                                 $all_contacts[$i]['name']=$object['names_ordered']; 
    3413                                 if ($object['id_typeof_contact_connection'] == 1) 
    3414                                         $all_contacts[$i]['email']=$object['connection_value']; 
    3415                                 else 
    3416                                         $all_contacts[$i]['phone']=$object['connection_value']; 
    3417                         } 
    3418         */ 
    3419 /*****/ 
    3420  
    34213406                        switch($typeExport) { 
    34223407 
    34233408                                case 'outlook_en': 
    34243409                                        $streamBuffer = "Name;E-mail Address;Notes;Mobile Phone;Pager;Company;". 
    3425 /**rev 104**/ 
    3426         /*                                              "Job Title;Home Phone;Home Fax;Business Phone;Business Fax\r\n"; 
    3427                                         foreach($all_contacts as $index => $object){ 
    3428                                                 $streamBuffer.= $object['name'].";".$object['email'].";;;;;;".$object['phone'].";;;\r\n"; 
    3429                                         } 
    3430         */ 
    3431                                                         "Job Title;Home Phone;Home Fax;Business Phone;Business Fax\r\n";                                                         
     3410                                        "Job Title;Home Phone;Home Fax;Business Phone;Business Fax\r\n";                                                         
     3411 
    34323412                                        foreach($contacts as $index => $object){ 
    34333413                                                $streamBuffer.= $object['names_ordered'].";".$object['connection_value'].";;;;;;".$object['phone'].";;;\r\n"; 
    34343414                                        } 
    3435 /*****/ 
    3436                                 break; 
     3415                                        break; 
    34373416 
    34383417                                case 'outlook_pt-BR': 
     
    34433422                                        "CEP do endereï¿œo comercial;Estado do endereï¿œo comercial;". 
    34443423                                        "Paï¿œs/regiï¿œo do endereï¿œo comercial;Telefone comercial;Empresa;Cargo\r\n"; 
    3445 /**rev 104**/ 
    3446                                 //      foreach($all_contacts as $index => $object){ 
    3447                                 //              $streamBuffer.= $object['name'].";".$object['email'].";;;;;;".$object['phone'].";;;;;;;;\r\n"; 
     3424 
    34483425                                        foreach($contacts as $index => $object){ 
    34493426                                                $streamBuffer.= $object['names_ordered'].";".$object['connection_value'].";;;;;;".$object['phone'].";;;;;;;;\r\n"; 
    3450 /******/ 
    34513427                                        } 
    34523428                                break; 
     
    34723448                                        "\"Sexo\"\r\n"; 
    34733449 
    3474 /**rev 104**/ 
    3475                                         //foreach($all_contacts as $index => $object){ 
    3476                                         //      $streamBuffer.= ",\"".$object['name']."\",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,".$object['phone'].",,,,,,,,,,,,\"".$object['email']."\",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n"; 
    34773450                                        foreach($contacts as $index => $object){ 
    34783451                                                $streamBuffer.= ",\"".$object['names_ordered']."\",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,".$object['phone'].",,,,,,,,,,,,\"".$object['connection_value']."\",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n"; 
    3479 /******/ 
    34803452                                        } 
    34813453                                break; 
     
    34933465                                        "Office Location,Organizational ID Number,PO Box,Priority,Private,Profession,Referred By,Sensitivity,Spouse,User 1,User 2,User 3,User 4,Web Page\r\n"; 
    34943466 
    3495 /**rev 104**/ 
    3496                                         //foreach($all_contacts as $index => $object){ 
    3497                                         //      $streamBuffer.= ",".$object['name'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,".$object['phone'].",,,,,,,,,,,,".$object['email'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n"; 
    34983467                                        foreach($contacts as $index => $object){ 
    34993468                                                $streamBuffer.= ",".$object['names_ordered'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,".$object['phone'].",,,,,,,,,,,,".$object['connection_value'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n"; 
    3500 /*******/ 
    35013469                                        } 
    35023470                                break; 
     
    35053473                                        $streamBuffer = "\n"; 
    35063474 
    3507 /**rev 104**/ 
    3508                                         //foreach($all_contacts as $index => $object){ 
    3509                                         //      $streamBuffer.= ",,".$object['name'].",,".$object['email'].",,".$object['phone'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n"; 
    35103475                                        foreach($contacts as $index => $object){ 
    35113476                                                $streamBuffer.= ",,".$object['names_ordered'].",,".$object['connection_value'].",,".$object['phone'].",,,,,,,,,,,,,,,,,,,,,,,,,,,,,,\r\n"; 
    3512  
    3513 /******/ 
    35143477                                        } 
    35153478                                break; 
    35163479 
    35173480                                case 'expresso': 
    3518                                         $streamBuffer = "Nome,Email,Telefone\r\n"; 
    3519  
    3520 /**rev 104**/ 
    3521                                         //foreach($all_contacts as $index => $object){ 
    3522                                         //      $streamBuffer.= $object['name'].",".$object['email'].",".$object['phone']."\r\n"; 
     3481                                        $streamBuffer = "Nome,Apelido,Email,Telefone,Endereço,Complemento,CEP,Cidade,Estado,País\r\n"; 
     3482 
    35233483                                        foreach($contacts as $index => $object){ 
    3524                                                 $streamBuffer.= $object['names_ordered'].",".$object['connection_value'].",".$object['phone']."\r\n"; 
    3525   
    3526 /******/ 
     3484                                                $streamBuffer .= $object[ 'names_ordered'] . "," 
     3485                                                        . $object[ 'alias' ] . "," 
     3486                                                        . $object[ 'connection_value' ] . "," 
     3487                                                        . $object[ 'phone' ] . "," 
     3488                                                        . $object[ 'address1' ] . "," 
     3489                                                        . $object[ 'complement' ] . "," 
     3490                                                        . $object[ 'postal_code' ] . "," 
     3491                                                        . $object[ 'city_name' ] . "," 
     3492                                                        . $object[ 'state_name' ] . "," 
     3493                                                        . $object[ 'id_country' ] . "\r\n"; 
    35273494                                        } 
    35283495                                break; 
Note: See TracChangeset for help on using the changeset viewer.