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

  • 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.

  • Although, It is working on my local server but whenever i am trying to upload the package into other server it's showing the below error :  

    Files/custom/modules/Reports/sugarpdf/sugarpdf.reports.php
    Code attempted to call blacklisted function "getimagesize" on line 67
    Code attempted to call blacklisted function "getimagesize" on line 72
    Code attempted to call blacklisted function "getimagesize" on line 75

    How can i get rid from this. Please help!

  •  yea unfortunately, getimagesize is blacklisted. We could raise a Sugar ticket to allow custom class names for Sugar PDF, since we don't actually intend to use getimagesize here, we are only trying to extend the preDisplay method.

    The patch is simple, in : include/Sugarpdf/SugarpdfFactory.php->buildFromFile methed, they just have to use SugarAutoLoader::customClass instead of forcing the class to be 

    $class = ucfirst($module).'Sugarpdf'.ucfirst($type);

    What is the usual procedure to request such changes ?

    But for your change ,

    1. You don't have to export sugarpdf.reports.php since there is no change and we cannot override that file.

    2. For the summary pdf: you can change the code to use imagesx and imagesy instead of getimagesize.

    Eg: Change the following lines from:

    if (file_exists($imageFile) && getimagesize($imageFile) > 0) {
    $this->AddPage();
    list($width, $height) = getimagesize($imageFile);

    to something like:

    if (file_exists($imageFile) && verify_uploaded_image($imageFile)) {
    $this->AddPage();

    $chartImageResource = imagecreatefrompng($imageFile);
    $width = imagesx($chartImageResource);
    $height = imagesy($chartImageResource);
    imagedestroy($chartImageResource);

     
     
  • Thanks. I will try and let you know .

  • Your solution is working fine with getimagesize function but now it's showing the below error : 

    File Issues
    Files/custom/modules/Reports/sugarpdf/sugarpdf.summary.php
    Invalid usage of a function file_exists()
    Files/custom/modules/Reports/sugarpdf/sugarpdf.summary_combo.php
    Invalid usage of a function file_exists()

  • Yes, I got the exact alternative of file_exists(). It's Working for me. Thanks for you help Slight smile

1 2