AnsweredAssumed Answered

Clickable record Name in PDF Report

Question asked by Francesca Shiekh on Nov 8, 2019

Our users want Clickable Names in the PDF Reports that are emailed to them, that is not currently possible without overriding the PDF generation.

 

I was able to get the Name of the first record to be a beautiful clickable URL, but not the rest, and I cannot understand why it's working for one but not the others.

 

in 

custom/modules/Reports/sugarpdf/sugarpdf.listview.php

 

I override the ReportsSugarpdfListview so that if you include both the ID and the Name field in a rows and columns report the code here will replace the Name with the HTML needed to make that Name into a proper link and will remove the display of the ID from the report PDF.

 

It works great for the first row.

 

If you remove line 37 you will see that the Name is replaced with the proper URL for each of the lines. 

Then why is the first one the only one with an active URL?

I have verified that the Sugarpdf::writeCellTable sets the ishtml for each line.

 

I am very confused... am I misunderstanding the options ishtml?

I need some help from the experts... André Lopes  any thoughts?

 

<?php

class ReportsSugarpdfListview extends ReportsSugarpdfReports
{
    function display(){
$GLOBALS['log']->fatal("CUSTOM");
        global $report_modules, $app_list_strings;
        global $mod_strings, $locale;
        global $sugar_config; //custom WR
        $this->bean->run_query();

        $this->AddPage();

        $item = array();
        $header_row = $this->bean->get_header_row('display_columns', false, false, true);
        $count = 0;

        while($row = $this->bean->get_next_row('result', 'display_columns', false, true)) {
            for($i= 0 ; $i < sizeof($header_row); $i++) {
                $label = $header_row[$i];
                $value = '';
                if (isset($row['cells'][$i])) {
                    $value = $row['cells'][$i];
                }
                $item[$count][$label] = $value;
            }
            //custom WR
            if(!empty($item[$count]['Name']) && !empty($item[$count]['ID'])){
                //add URL
                $url = '<a href="' . $sugar_config['site_url']. '/index.php#' . $this->bean->module . '/' . $item[$count]['ID'] . '">' . $item[$count]['Name'] . '</a>';
                $item[$count]['Name'] = array('value' => $url,
                                             'options'=> array('ishtml'=>true));
                unset($item[$count]['ID']);
            }
            //end custom
            $count++;
        }
        $this->writeCellTable($item, $this->options);
    }
}

Outcomes