KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Emailing reports #475

Open Keith Burke opened this topic on on Sep 20, 2018 - 5 comments

Keith Burke commented on Sep 20, 2018

Hi,

I've been using your KoolReports for a few months now. We are getting some really nice complicated data out of them.

I'm wondering, is it possible to email report output to some individuals, either full blown reports or instant, single pages?

I know that I can export to PDF etc but I'm looking for some automated solution as management want a set of reports emailed weekly so it doesn't make sense to do it manually. It would also be nicer if it was a nice HTML email rather than a PHP attachment.

I have my cronjobs, I have my email subsystem [based on phpMailer]. I'm just not sure how to capture the output of the reports.

[I'm still trying to find time to evaluate KoolPHP UI. It looks fantastic.]

Keith Burke commented on Sep 20, 2018

Sorted and just found out about output buffering :)


        ob_start();
        include 'reports/reportToEmail.php';
        $report = ob_get_clean();

Then just append the contents of $report to the email body. Nice. Haven't tried it with a full blown koolReport yet but works well with an Instant report.

Robert commented on Sep 20, 2018

Hi, you may do like this

$report = new MyReport;
$content = $report->run()->render(true); // With true parameter there, report will return string instead of render

By this way, you dont have to use ob_start(). The report return straight html for you to use as email content.

Keith Burke commented on Sep 20, 2018

Oooo. Nice. I'll try that now.

Keith Burke commented on Sep 28, 2018

So continuing on with this thing of making reports emailable..... I'm running into issues where relative URL's are used internally. For example, jquery.js, datatables.js Is there any way that there could be a toggle to input TLD absolute URL's? It's not a huge thing but it would be very nice to be able to email reports.

The data gets sent fine in the email but looks like plain ascii text as there is no formatting or bootstrap.

KoolReport commented on Sep 28, 2018

The report can be configured so that those jquery.js or datatables.js can be access publicly, here is the way:

function settings()
{
    return array(
        "datasources"=>array(
            ...
        )
        "assets"=>array(
            "path"=>"../../assets",
            "url"=>"https://domain.com/assets"
        )
    )
}

Basically you can controls where those resources will be copied to (path) and how to accessed it (url).

However, there are some issues with email:

  1. Javascript can not run in email for security reason.
  2. HTML/CSS processor is not up to date, for example CSS3 may not work.
  3. The css are considered as external resources and may not be loaded by default by email viewer for privacy. The only solution is to embedded css to email content.

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

DataGrid