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")

  • Hi

    May be you need to change your PHP ini file, in the timezone config section.
    You can overwrite the config file, there is a config file inside SugarCRM core and it is editable (config_override.php) this if your site is an OnSite version.
    Or you can check your OS timezone configuration.
    The function getNow() I think gives you the current and the system time and there are many ways of format that date.
    If you want hide the printed date in the pdf file or modify the config, I hope this be useful for you:
    support.sugarcrm.com/.../

    Regards.

  • We are looking to overwrite the file sugar\modules\Reports\sugarpdf\sugarpdf.reports.php via custom directory , but unfortunately it's not working for us.

  • Unfortunately it is not possible to override such file, once this very class is extended by all PDF Report classes.

    But you can extend the sub classes in order to override the method preDisplay, where you are able to redefine setHeaderData accordingly.

    André Lopes
    Lampada Global
    Skype: andre.lampada
  • 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. 

  • Thanks for your help. I will  try to implement by this way. 

  • I have tried by the same way but it's not working for me. 

  • , can you share the file and it's location? I can take a quick peek and see what's happening. 

  • File Path: custom/modules/Reports/sugarpdf/sugarpdf.summary.php

    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"));
    //$this->SetHeaderData(PDF_SMALL_HEADER_LOGO, PDF_SMALL_HEADER_LOGO_WIDTH, $app_list_strings['moduleList'][$this->bean->module]);
    } else {
    $this->SetHeaderData(PDF_SMALL_HEADER_LOGO, PDF_SMALL_HEADER_LOGO_WIDTH, $this->bean->name, date("D M j G:i:s"));//$timedate->getNow(true)
    //$this->SetHeaderData(PDF_SMALL_HEADER_LOGO, PDF_SMALL_HEADER_LOGO_WIDTH, $this->bean->name);//$timedate->getNow(true)
    }
    }
    function display()
    {
    global $locale;
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • I have also tried by copy the sugarpdf.reports.php to custom/modules/Reports/sugarpdf/sugarpdf.reports.php

  • The file and location looks correct to me. This raises a couple of questions:

    1. Did you do a quick repair before running the export?

    2. The override was only for the PDF Summary, so did you actually export a summary report? If not, can you give details on what kind of report you're trying to export? If you are trying to export a rows/columns report or a matrix report, it comes from a different file. You will have to extend the corresponding file:

    sugarpdf.detail_and_total.php
    sugarpdf.listview.php
    sugarpdf.reports.php
    sugarpdf.summary.php
    sugarpdf.summary_combo.php
    sugarpdf.total.php

    I have exactly the same file as you locally and I was able to see the difference in the summary report.

    Before:

    PDF

    After:

    PDF

1 2