How to overwrite the core file to remove the timezone from the print to pdf file, How can we do this through the customization?

How to overwrite the core file to remove the timezone from the print to pdf file, How can we do this through the customization?

Path: sugar\modules\Reports\sugarpdf\sugarpdf.reports.php

Code :  $this->SetHeaderData(PDF_SMALL_HEADER_LOGO, PDF_SMALL_HEADER_LOGO_WIDTH, $this->bean->name, $timedate->getNow(true)"));

$timedate->getNow(true) instead of this we need to replace "date("D M j G:i:s")

Parents
  • Hi ,

    Though it is not possible to edit the sugarpdf.reports.php, it is actually being extended by other sub-classes, which is the one you have to override. But - the only downside is that, you have to copy the whole file into your custom folder and customize it. 

    For example, for Summary report, the PDF file used is modules/Reports/sugarpdf/sugarpdf.summary.php, which extends sugarpdf.reports.php. So in order to override the report, you can copy the file from modules folder into custom/modules/Reports/sugarpdf/sugarpdf.summary.php and modify the preDisplay section to set the header that you need, eg:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    <?php
    class ReportsSugarpdfSummary extends ReportsSugarpdfReports
    {
    function preDisplay()
    {
    parent::preDisplay();
    //Set PDF document properties
    if ($this->bean->name == "untitled") {
    $this->SetHeaderData(PDF_SMALL_HEADER_LOGO, PDF_SMALL_HEADER_LOGO_WIDTH, $app_list_strings['moduleList'][$this->bean->module], date("D M j G:i:s"));
    } else {
    $this->SetHeaderData(PDF_SMALL_HEADER_LOGO, PDF_SMALL_HEADER_LOGO_WIDTH, $this->bean->name, date("D M j G:i:s"));
    }
    }
    function display()
    {
    // ... Copy and paste the code from modules/Reports/sugarpdf/sugarpdf.summary.php
    }
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    But - there is a downside to this method. Sugar currently doesn't accept custom class names, so you have to copy the entire file (with the same ClassName) from modules/Reports folder into the custom folder - which adds additional work of merge/update during Sugar Upgrades. 

Reply
  • Hi ,

    Though it is not possible to edit the sugarpdf.reports.php, it is actually being extended by other sub-classes, which is the one you have to override. But - the only downside is that, you have to copy the whole file into your custom folder and customize it. 

    For example, for Summary report, the PDF file used is modules/Reports/sugarpdf/sugarpdf.summary.php, which extends sugarpdf.reports.php. So in order to override the report, you can copy the file from modules folder into custom/modules/Reports/sugarpdf/sugarpdf.summary.php and modify the preDisplay section to set the header that you need, eg:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    <?php
    class ReportsSugarpdfSummary extends ReportsSugarpdfReports
    {
    function preDisplay()
    {
    parent::preDisplay();
    //Set PDF document properties
    if ($this->bean->name == "untitled") {
    $this->SetHeaderData(PDF_SMALL_HEADER_LOGO, PDF_SMALL_HEADER_LOGO_WIDTH, $app_list_strings['moduleList'][$this->bean->module], date("D M j G:i:s"));
    } else {
    $this->SetHeaderData(PDF_SMALL_HEADER_LOGO, PDF_SMALL_HEADER_LOGO_WIDTH, $this->bean->name, date("D M j G:i:s"));
    }
    }
    function display()
    {
    // ... Copy and paste the code from modules/Reports/sugarpdf/sugarpdf.summary.php
    }
    }
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    But - there is a downside to this method. Sugar currently doesn't accept custom class names, so you have to copy the entire file (with the same ClassName) from modules/Reports folder into the custom folder - which adds additional work of merge/update during Sugar Upgrades. 

Children