Results 1 to 2 of 2

Thread: Auxilio ao Editar Modula para Carta

  1. #1
    vbraraujo is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    20

    Exclamation Auxilio ao Editar Modula para Carta

    Caros Amigos,

    Uso o SugarCRM CE 5.5, e encontrei no forum do sugar o módulo em anexo. Ele adiciona um botão no modulo de contatos, similar ao vCard, denominado "Letter".

    Ao clicar ele gera um arquivo .doc com endereço, saudação, nome do contato e profissão.

    Tudo que eu preciso é saber como formatar os dados contidos nesse arquivo .doc, para que contenha um padrão diferente, com formatação e campos distintos.

    Alguém tem idéia do que posso fazer?

    Desde já agradeço,
    VictorBruno

    P.S: Este é o link para o tópico no qual o módulo foi postado: http://www.sugarcrm.com/forums/showt...ghlight=letter
    Attached Files Attached Files

  2. #2
    vbraraujo is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    20

    Exclamation Re: Auxilio ao Editar Modula para Carta

    Realmente preciso de ajuda.

    Abaixo segue o conteúdo do arquivo que gera o .doc

    Consigo editar a formatação usando argumentos em html, mas não consigo incluir as variáveis dentro deste texto.

    Não entendo como elas são puxadas do modulo contatos e incluídas neste arquivo nem como posso usá-las no meio do texto em html.

    Na função "toString", acrescentei meu texto por meio de um print. No arquivo original havia o uso do $content.=$this->displayProperty, o qual eu deixei comentado.

    Atenciosamente,
    VictorBruno



    PHP Code:
    <?php
     
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    require_once(
    'include/vCard.php');

    if(isset(
    $_SESSION['authenticated_user_language']) && $_SESSION['authenticated_user_language'] != ''){
        
    $current_language $_SESSION['authenticated_user_language'];
    }
    else{
        
    $current_language $sugar_config['default_language'];
    }

    //set module and application string arrays based upon selected language
    $app_strings return_application_language($current_language);
    $app_list_strings return_app_list_strings_language($current_language);

    class 
    qMerge_c extends vCard{
        
            function 
    loadContact($contactid$module='Contacts') {
            global 
    $app_list_strings;

            require_once(
    $GLOBALS['beanFiles'][$GLOBALS['beanList'][$module]]);
            
    $contact = new $GLOBALS['beanList'][$module]();
            
    $contact->retrieve($contactid);
            
            
    // cn: bug 8504 - CF/LB break Outlook's vCard import
            
    $bad = array("\n""\r");
            
    $good = array("=0A""=0D");
            
    $encoding '';
            
    /*if(strpos($contact->primary_address_street, "\n") || strpos($contact->primary_address_street, "\r")) {
                $contact->primary_address_street = str_replace($bad, $good, $contact->primary_address_street);
                $encoding = 'QUOTED-PRINTABLE';
            }
            */
            
            
    $this->setName(from_html($contact->first_name), from_html($contact->last_name), $app_list_strings['salutation_dom'][from_html($contact->salutation)]);
            if ( isset(
    $contact->birthdate) )
                
    $this->setBirthDate(from_html($contact->birthdate));
            
    $this->setPhoneNumber(from_html($contact->phone_fax), 'FAX');
            
    $this->setPhoneNumber(from_html($contact->phone_home), 'HOME');
            
    $this->setPhoneNumber(from_html($contact->phone_mobile), 'CELL');
            
    $this->setPhoneNumber(from_html($contact->phone_work), 'WORK');
            
    $this->setEmail(from_html($contact->email1));
            
    $this->setAddress(from_html($contact->primary_address_street), from_html($contact->primary_address_city), from_html($contact->primary_address_state), from_html($contact->primary_address_postalcode), from_html($contact->primary_address_country), 'WORK'$encoding);
            if ( isset(
    $contact->account_name) )
                
    $this->setORG(from_html($contact->account_name), from_html($contact->department));
            else
                
    $this->setORG(''from_html($contact->department));
            
    $this->setTitle($contact->title);
        }
        
        
        function 
    saveqMerge_c(){
            global 
    $locale;
            
            
    $content $this->toString();
            
    header("Content-Disposition: attachment; filename={$this->name}.doc");
            
    //header("Content-Type: text; charset=".$locale->getExportCharset());
            
    header("Content-Type: application/msword; charset=".$locale->getExportCharset());
            
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" );
            
    header("Last-Modified: " gmdate("D, d M Y H:i:s") . " GMT" );
            
    header("Cache-Control: max-age=0");
            
    header("Pragma: public");
            
    header("Content-Length: ".strlen($content));

            print 
    $locale->translateCharset($content'UTF-8'$locale->getExportCharset());
        }
        
        function 
    displayProperty($prop){
           if (
    $this->getProperty($prop))
                return 
    $content.=$this->getProperty($prop);
           else
                return 
    '';
        }
        
        function 
    setORG($org$dep){
            
    $this->setProperty("ORG","$org" );    
        }
        
        function 
    setName($first_name$last_name$prefix$cpf_c){
            
    $this->name strtr($first_name.'_'.$last_name' ' '_');
            
    $this->setProperty('N',trim($first_name.' ' $last_name ));
            
    $this->setProperty('FN',trim("$prefix $first_name $last_name $cpf_c")); 
            
    $this->setProperty('EC',trim("$prefix $first_name $last_name $cpf_c"));
            
    $this->setProperty('SAL',"Caro " trim("$first_name $last_name ,") );
        }
        
        function 
    toString(){
            
        
    //$content.=$this->displayProperty('FN') . ", ";
        //$content.=$this->displayProperty('EC') . ", ";
            //$content.=$this->displayProperty('TITLE') . ", ";
            //$content.=$this->displayProperty('ADR;WORK') . "\n\n";
                
            
    print "
    <html>
    <head>
    </head>
    <table class=MsoTableGrid border=1 cellspacing=0 cellpadding=0 width=662
     style='width:496.15pt;margin-left:-30.05pt;border-collapse:collapse;
     border:none'>


    </table>

    </div>

    </body>
    </html>

    "
    ;
     


            return 
    $content;
        }
        
        function 
    setAddress($address$city$state,$postal$country$type$encoding=''){
            if(!empty(
    $encoding)) {
                
    $encoding ";ENCODING={$encoding}";
            }
            if (
    $country=="USA" || $country="United States" || $country="United States of America")
               
    $this->setProperty("ADR;$type$encoding","$address\n$city, $state  $postal" ); 
            else    
                
    $this->setProperty("ADR;$type$encoding","$address\n$city, $state  $postal\n$country" );    
        }
    }  

    $q = new qMerge_c();

    if(isset(
    $_REQUEST['merge_module'])) {
        
    $module clean_string($_REQUEST['merge_module']);
        
    $q->loadContact($_REQUEST['qmerge_c_id'], $module);
        
    $q->saveqMerge_c();
    }
        


    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Duplicados al editar
    By vmnsugarcrm in forum Español
    Replies: 3
    Last Post: 2011-02-08, 01:40 PM
  2. Problemas para migrar sugar para outro servidor
    By guilhermepimenta in forum Portugese
    Replies: 2
    Last Post: 2008-04-30, 11:42 AM
  3. Module builder url auxilio
    By guindan in forum Español
    Replies: 0
    Last Post: 2007-03-30, 10:49 PM
  4. Problemas para editar oportunidades e projetos
    By rep6ohms in forum Portugese
    Replies: 1
    Last Post: 2006-06-14, 08:40 PM
  5. Editar subpanels
    By samile in forum Español
    Replies: 0
    Last Post: 2005-10-28, 06:46 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •