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. 

  • 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

  • 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

  • Yes we did quick repair before running the export.

  • Ah okay, looks like you're export summation+details, so the file you have to override is sugarpdf.summary_combo.php . sugarpdf.summary.php is just plain Summation report.

    You can see in the right top corner of the report, which mentions the "Report Type".


    Here are the 4 report types and their corresponding PDF generation files:

    Report Type PDF Template File
    Rows & Columns sugarpdf.listview.php
    Summation sugarpdf.summary.php
    Summation with Details sugarpdf.summary_combo.php
    Matrix sugarpdf.summary.php

  •   Thank you so much. It's Working for me.

Reply Children
No Data