Make a quick vote 🗳 ️How do you refer to SuiteCRM extensions: add-ons or plug-ins? Click here to have your say 👈

Add pdf print option

Hi everyone,

I would like to insert the Print Pdf option in the Events module but the changes applied in the detailviewdefs.php and view.detail.php files of the custom folder did not work.

I followed the guidelines found on suitecrm. com

Have any of you encountered the same problem as me?

Hey! It may help if you where to share the exact instructions you where following?, Could you also elaborate on how it doesn’t work? What happens instead, why should happen, etc?

Hi,
I followed this guide

EDIT: updated link

1 Like

Could I be a pain and ask if possible you link to a non direct download link? Thanks :+1::+1:

Could you also let us know what is wrong? How doesn’t it work? Did you run a repair and rebuild?

1 Like

Hi,
I followed the guide shown here:

Unfortunately the button does not appear in the drop-down menu of the module. I also performed the repair

Thanks for your support

  1. Agregar el nombre del módulo a la lista desplegable pdf_template_type_dom que se encuentra en Dropdown Editor.
  • Pasa saber el nombre exacto del modulo se puede remitir a la ruta: /var/www/html/custom/modules/Your_module_name
  1. Modificamos el archivo detailviewdefs.php el cual se encuentra en: /var/www/html/custom/modules/Your_module_name/metadata a ese archivo debemos agregar la línea 4 => :
'form' => 
      array (
        'buttons' => 
        array (
          0 => 'EDIT',
          1 => 'DUPLICATE',
          2 => 'DELETE',
          3 => 'FIND_DUPLICATES',
          4 => 
          array (
            'customCode' => '<input type="button" class="button" onClick="showPopup(\'pdf\');"
	  value="{$MOD.LBL_PRINT_AS_PDF}">',
          ),
        ),
      ),

Nota: si no tiene las opciones:

          0 => 'EDIT',
          1 => 'DUPLICATE',
          2 => 'DELETE',
          3 => 'FIND_DUPLICATES',

Solo agregue la línea 4 =>

4 => 
          array (
            'customCode' => '<input type="button" class="button" onClick="showPopup(\'pdf\');"
	  value="{$MOD.LBL_PRINT_AS_PDF}">',
          ),
  1. Debemos modificar el archivo con el lenguaje que están usando, si usan ingles y español, agregar la línea en ambas partes, para ello se van a la ruta:

/var/www/html/custom/modules/Your_module_name/language

  • Modifican el archivo en_us.lang.php
$mod_strings = array ( 'LBL_PRINT_AS_PDF' => 'print PDF',); 
  • Si “$mod_strings = array ( ya existe, solo agreguen:
'LBL_PRINT_AS_PDF' => 'print PDF',

Ejemplo:

<?php
// created: 2021-06-03 21:00:36
$mod_strings = array (
  'LBL_PRINT_AS_PDF' => 'Print PDF',
);
  1. Ahora deben crear el archivo view.detail.php en la ruta:

/var/www/html/custom/modules/Your_module_name/views

Les dejo tal cual como lo tengo, donde vean el nombre Your_module_name, es donde deben ingresar el nombre exacto de su modulo:

<?php
if (!defined('sugarEntry') || !sugarEntry) {
    die('Not A Valid Entry Point');
}

//require_once('include/MVC/View/views/view.detail.php');

class **Your_module_name**ViewDetail extends ViewDetail
{
    public $bean;

    public function __construct()
    {
        parent::__construct();
    }

    public function **Your_module_name**ViewDetail()
    {
        $deprecatedMessage = 'PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code';
        if (isset($GLOBALS['log'])) {
            $GLOBALS['log']->deprecated($deprecatedMessage);
        } else {
            trigger_error($deprecatedMessage, E_USER_DEPRECATED);
        }
        $this->__construct();
    }


    public function display()
    {
        $this->populateQuoteTemplates();
        $this->displayPopupHtml();
        parent::display();
    }

    protected function populateQuoteTemplates()
    {
        global $app_list_strings;

        $sql = "SELECT id, name FROM aos_pdf_templates WHERE deleted=0 AND type='**Your_module_name**' AND active = 1";

        $res = $this->bean->db->query($sql);

        $app_list_strings['template_ddown_c_list'] = array();
        while ($row = $this->bean->db->fetchByAssoc($res)) {
            if ($row['id']) {
                $app_list_strings['template_ddown_c_list'][$row['id']] = $row['name'];
            }
        }
    }

    protected function displayPopupHtml()
    {
        global $app_list_strings, $app_strings, $mod_strings;
        $templatesList = array_keys($app_list_strings['template_ddown_c_list']);
        $template = new Sugar_Smarty();
        $template->assign('APP_LIST_STRINGS', $app_list_strings);
        $template->assign('APP', $app_strings);
        $template->assign('MOD', $mod_strings);
        $template->assign('FOCUS', $this->bean);
        $template->assign('TEMPLATES', $templatesList);

        if ($templatesList) {
            $template->assign('TOTAL_TEMPLATES', count($templatesList));
            foreach ($templatesList as $t => $templatesListItem) {
                $templatesList[$t] = str_replace('^', '', $templatesListItem);
            }
            echo $template->fetch('modules/AOS_Quotes/templates/showPopupWithTemplates.tpl');
        } else {
            echo $template->fetch('modules/AOS_Quotes/templates/showPopupWithOutTemplates.tpl');
        }
    }
}
  1. Cuando terminen solo vayan a Administrator > Repair > Quick Repair and Rebuild y esperan a que terminen.

Deben crear el PDF y asignarle el modulo al que quieren imprimir, para que de esa manera aparezcan los campos, y los puedan llamar en cada sección.

Espero que les pueda funcionar y me disculpo por lo extenso.

2 Likes

Hi @ChesteRGotH, welcome to the Community! :tada:

Thanks for sharing your solution!

Do you know how to so this for version 8?