Bulk Print to pdf custom module

Hey Guys,

I’ve created a custom module in wich Certificates for participants for a training are created.
I managed to add the option to print a certificate to pdf, and it works perfect.

The next step is to add the Print to pdf button to Bulk Action menu like in the leads module. So I can print multiple certificates at ones.
I couldn’t find a good walktrough.

Can someone provide that for me?

(sorry if my English is bad, I’m Dutch)

Thanks,

Tom

I have a couple of gists for a similar thing

https://gist.github.com/pgorod/5de7c6f8d37413654b16e06668d7e1b1
https://gist.github.com/pgorod/c838f258fadf9528b61183e763e978a8

This will teach you how to add List view action items (the bulk actions menu). Then you can go look for the way it is done in the Leads module, and try to copy it to your custom module.

If you get a nice clean solution please post it here for others! Thanks.

@TomvtZand - I’m just about to start looking into doing this. Did you figure out a solution for it?

Thanks

Urbanite

I’ve figured out a method of doing this by reverse engineering the Contact module… I’ve posted a blog on my website detailing it here.

https://harveyit.co.uk/projects-and-guides/suitecrm-a-pdf-guide

Configure a module for printing bulk PDFs

Follow steps 1, 3 and 4 from the previous steps for creating a single PDF function in your module.

  1. Create a views.list.php with the following
require_once('include/MVC/View/views/view.list.php');

require_once('modules/[CUSTOM MODULE NAME]/[CUSTOM MODULE NAME]ListViewSmarty.php');

 

class [CUSTOM MODULE NAME]ViewList extends ViewList

{

    /**

     * @see ViewList::preDisplay()

     */

    public function preDisplay(){

        require_once('modules/AOS_PDF_Templates/formLetter.php');

        formLetter::LVPopupHtml('[CUSTOM MODULE NAME]');

        parent::preDisplay();

 

        $this->lv = new [CUSTOM MODULE NAME]ListViewSmarty();

    }

}
  1. Create a [modulename]ListViewSmarty.php with the following

require_once('include/ListView/ListViewSmarty.php');

require_once('modules/AOS_PDF_Templates/formLetter.php');

 

 

class [CUSTOM MODULE NAME]ListViewSmarty extends ListViewSmarty {

 

        function __construct(){

 

                parent::__construct();

                $this->targetList = true;

 

        }

 

    /**

     * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead

     */

    function [CUSTOM MODULE NAME]ListViewSmarty(){

        $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);

        }

        self::__construct();

    }

 

 

    /**

     *

     * @param file $file Template file to use

     * @param array $data from ListViewData

     * @param string $htmlVar the corresponding html public in xtpl per row

     * @return bool|void

     */

    public function process($file, $data, $htmlVar)

    {

        $configurator = new Configurator();

        if ($configurator->isConfirmOptInEnabled()) {

            $this->actionsMenuExtraItems[] = $this->buildSendConfirmOptInEmailToPersonAndCompany();

        }

 

        $ret = parent::process($file, $data, $htmlVar);

 

        if (!ACLController::checkAccess($this->seed->module_dir, 'export', true) || !$this->export) {

            $this->ss->assign('exportLink', $this->buildExportLink());

        }

 

        return $ret;

    }

 

    function buildExportLink($id = 'export_link'){

                global $app_strings;

                global $sugar_config;

 

                $script = "";

                if(ACLController::checkAccess($this->seed->module_dir,'export',true)) {

                        if($this->export) {

                                $script = parent::buildExportLink($id);

                        }

                }

 

            $script .= "

                    " onclick=\"return sListView.send_form(true, 'jjwg_Maps', " .

                    "'index.php?entryPoint=jjwg_Maps&display_module={$_REQUEST['module']}', " .

                    "'{$app_strings['LBL_LISTVIEW_NO_SELECTED']}')\">{$app_strings['LBL_MAP']}";

 

                return formLetter::LVSmarty().$script;

        }

 

}
3 Likes

Followed instructions, but after “quick repair and rebuild” i get next:

SuiteCRM latest version.
What i did
/custom/modules/sl_ap_B2C_order/views/view.list.php (with <?php at the begining):

    require_once('include/MVC/View/views/view.list.php');
    require_once('modules/sl_ap_B2C_order/sl_ap_B2C_orderListViewSmarty.php');
    class sl_ap_B2C_orderViewList extends ViewList
    {
    /**
     * @see ViewList::preDisplay()
     */
    public function preDisplay()
    {
        require_once('modules/AOS_PDF_Templates/formLetter.php');
        formLetter::LVPopupHtml('sl_ap_B2C_order');
        parent::preDisplay();

        $this->lv = new ContactsListViewSmarty();
    }
    }

/custom/modules/sl_ap_B2C_order/sl_ap_B2C_orderListViewSmarty.php (with <?php at the begining):

	require_once('include/ListView/ListViewSmarty.php');
	require_once('modules/AOS_PDF_Templates/formLetter.php');


	class sl_ap_B2C_orderListViewSmarty extends ListViewSmarty
	{
	    public function __construct()
	    {
	        parent::__construct();
	        $this->targetList = true;
	    }

	    /**
	     * @deprecated deprecated since version 7.6, PHP4 Style Constructors are deprecated and will be remove in 7.8, please update your code, use __construct instead
	     */
	    public function sl_ap_B2C_orderListViewSmarty()
	    {
	        $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);
	        }
	        self::__construct();
	    }


	    /**
	     *
	     * @param file $file Template file to use
	     * @param array $data from ListViewData
	     * @param string $htmlVar the corresponding html public in xtpl per row
	     * @return bool|void
	     */
	    public function process($file, $data, $htmlVar)
	    {
	        $configurator = new Configurator();
	        if ($configurator->isConfirmOptInEnabled()) {
	            $this->actionsMenuExtraItems[] = $this->buildSendConfirmOptInEmailToPersonAndCompany();
	        }

	        $ret = parent::process($file, $data, $htmlVar);

	        if (!ACLController::checkAccess($this->seed->module_dir, 'export', true) || !$this->export) {
	            $this->ss->assign('exportLink', $this->buildExportLink());
	        }

	        return $ret;
	    }

	    public function buildExportLink($id = 'export_link')
	    {
	        global $app_strings;
	        global $sugar_config;

	        $script = "";
	        if (ACLController::checkAccess($this->seed->module_dir, 'export', true)) {
	            if ($this->export) {
	                $script = parent::buildExportLink($id);
	            }
	        }

	        $script .= "<a href='javascript:void(0)' id='map_listview_top' " .
	                    " onclick=\"return sListView.send_form(true, 'jjwg_Maps', " .
	                    "'index.php?entryPoint=jjwg_Maps&display_module={$_REQUEST['module']}', " .
	                    "'{$app_strings['LBL_LISTVIEW_NO_SELECTED']}')\">{$app_strings['LBL_MAP']}</a>";

	        return formLetter::LVSmarty().$script;
	    }
	}

Please help

You probably have a PHP FATAL (or PARSE) error, check your PHP log (the one defined in your php.ini, error_log entry).

There are no PHP errors

You need to go looking for clues…

php_errors.log
suitecrm.log
browser’s developer console
Apache logs

look at the timestamps and try to see errors that come at the moment when you get that message on screen

Fixed it! Just need to add “custom” in this line before /modules
require_once('custom/modules/sl_ap_B2C_order/sl_ap_B2C_orderListViewSmarty.php');

1 Like

I can assure you that your PHP log was telling you that.

Make sure you have your options set correctly in php.ini:

error_log points to a filename
error_reporting selects which kinds of messages are output

Hi @TomvtZand

There has been a discussion happened on this topic earlier. You can check it out. It might be valuable for you.

Click Here: PDF invoice bulk downloading

Everything exports from list view to pdf fine. But every time when I run bulk export to PDF in list view of Custom module, in Notes module new notes are created for every single item from Custom module I exported… :thinking:
How to fix it?!

Hello. Any suggestions?

Interesting to know. I’m waiting for this answer too.

@urbanite your steps are missing 3 and 4.

Sorry I know this is old thread, so let me know if making a new one would be better but i hope someone can help me.

i have followed the above and have sucsessfully made the bulk Print to PDF button in the quotes module. however when it generate the PDF everything works fine accept the data within the Product Line which just appear as the placeholder

please help