Adding Print PDF To Custom Module
Adding Print PDF To Custom Module
1 ) First We need to add your custom module in to *Type drop down of PDF template module
This We can do it by going to Admin > Drop Down Editor, We need to search for
pdf_template_type_dom drop down list and add -> option
Item name [ your custom directory name ] : To find the proper name path, FTP into the SuiteCRM server
and go to modules and use the exact name used on your module file
Save it .
2 ) After this We need Print as pdf option in our details view page of custom module
array (
'buttons' =>
array (
0 => 'EDIT',
1 => 'DUPLICATE',
2 => 'DELETE',
3 => 'FIND_DUPLICATES',
// add option like this (may vary slightly but function is the same, if list is different exclude “4 =>”)
4 => array ( 'customCode' => '<input type="button" class="button" onClick="showPopup(\'pdf\');"
value="{$MOD.LBL_PRINT_AS_PDF}">',
),
save it and check if you are not able to see the option. <-optional but recommended to make sure
everything is good at this point.
Save it.
and check [ now option will be there ]( if option is still not there than delete cache and check )
custom/modules/<your module>/views/view.detail.php
You will replace existing module name with the module you are editing in a few spots:
<?php
if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
require_once('include/MVC/View/views/view.detail.php');
function CasesViewDetail(){
parent::ViewDetail();
}
function display(){
$this->populateInvoiceTemplates();
$this->displayPopupHtml();
parent::display();
}
function populateInvoiceTemplates(){
global $app_list_strings;
$res = $this->bean->db->query($sql);
$app_list_strings['template_ddown_c_list'] = array();
while($row = $this->bean->db->fetchByAssoc($res)){
$app_list_strings['template_ddown_c_list'][$row['id']] = $row['name'];
}
}
Replace the within the code, all within the first 30 line, the highlighted module names above with the
module you want to add.
After you are finished go to Admin > Repair > Quick Repair and Rebuild and let finish
Final step is to create a PDF Template for the desired module. Then test by creating or editing a record
and use the edit > Print PDF function.
Note: If any directory of file does not exist within the “custom” add the proper directories and file where
needed. Do not edit files outside of the “custom” directory because edits outside of this, are not upgrade
safe.