KoolReport's Forum

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

Make old reports work in dashboard #1880

Closed Eugene opened this topic on on Jan 29, 2021 - 18 comments

Eugene commented on Jan 29, 2021

Hi,

I have a lot of reports (koolreports :-) ) written on classic koolreport's structure like this

 SalesByCustomer.php
 SalesByCustomer.view.php
 index.php		

could you suggest the best way if I want to wrap my reports in your dashboard - create a structured menu and each my report add as an item of this or that menu item.

KoolReport commented on Jan 30, 2021

There is a possible way that you use CustomBoard. You create series of custom board, each customboard for each of your old report. Inside the view of custom board, you use iframe to load the old report. The only problem is how to make the iframe has full width and the the height is flexible. I think this is the quickest way.

Eugene commented on Jan 30, 2021

What is CustomBoard?

I am sorry could you provide more detailed instructions?

Eugene commented on Jan 30, 2021

Dear support I am stuck with it could you give some advices?

KoolReport commented on Jan 30, 2021

The example of CustomBoard is here. The HomeBoard is extended from CustomBoard. The CustomBoard will have a view which you can provide custom html/css or code.

Eugene commented on Jan 30, 2021

Look - I am a koolreport Pro subscriber starting 2018. Since that time I've created a lot of reports based on the classic structure.

I want to use your dashboard as a wrapper for my reports. I think I am not alone who want to do it. Your new dashboard product loses a lot of its appeal in my eyes if it's hard to use old reports with it. And I think this is true for most of your old users. A simple dashboard is a great idea but if I have to rewrite all my reports from the beginning to use them with the dashboard I will think 3 times before do it.

I am very sorry but your example does not explain how to move my classic reports to the dashboard. Ok. I can put custom html code to the CustomBoard (as I understood it is about my *.view.php files) but what to do with others?

So I am still confused about how to do it. Could you give a manual like do A, do B, do C ... to move to and use my classic reports with the dashboard?

KoolReport commented on Jan 31, 2021

Yes, I totally understand your need. I am sorry for giving you very general instruction. The hack way that I thought that will work is to use iframe within custom board to load old reports. But after consulting with Karl, he suggested that you should hold on moving old reports to dashboard as it is not designed yet to be compatible. Our dev.team will take your requirement for future improvement as we believe there will be the need for this from other customers as well. We thank you very much for your patience and we will keep you update on this.

Eugene commented on Jan 31, 2021

Thank you. I hope your dev.team can implement it asap. It could be a really great feature for users with old reports.

PS But anyway I gonna try to test your iframe approach. Finally, I understood what you mean :-))

KoolReport commented on Jan 31, 2021

I also have the same believe as you for users with old reports. Btw, I change your topic title for better description and mark your topic as suggestion. Thank you very much for your trust and your continuous supporting us through years. We are very appreciated! We promise to give you working solution on this.

Eugene commented on Jan 31, 2021

Thank you for your great product.

You know, I tried iframes... Generally, it works. Yes I have some height issues but I think I can resolve it

But there is also a security issue... my reports that are opened in the iframe can be opened directly without any permission controls... I am not too good in csrf tokens etc ... But I think if my reports are located at the same server (and I use iframe due to a forced reason only) maybe I can check something in the report files to avoid direct access. Could you suggest anything?

KoolReport commented on Feb 1, 2021

May I know in your authentication in your current system. How do you provide login and authenticate user and prevent unauthorized people from accessing reports?

Eugene commented on Feb 1, 2021

I use Userspice now. I just use it from the box so I don't know the mechanism. But If I keep it it will be requested the second authorization. So I thought that there is a way to get dashboard context and check the permission from the script I download in the iframe.

KoolReport commented on Feb 1, 2021

The simplest way I think of is that, inside the authenticate() of Login, (refer to Authentication#login). you do:

            ->authenticate(function($username,$password){
                //You can make database connection in here to authenticate $username or password
                //Return User class when it is authenticated

                if($username==="johndoe" && $password==="johndoe") {
                    //This is when your user is valid,
                    $_SESSION["login_id"] = 1; // it is up to you
                    return User::create()
                        ->name("John Doe")
                        ->id(1)
                        ->roles(["guest"]);
                }
                return null;
            });

The idea is that .. when user is authenticated succesfully, you assign $_SESSION["login_id"] to id of user who login. And then, inside the report page (loaded inside iframe) you check permission:


if(isset($_SESSION["login_id"]))
{
    $report = new YourReport;
    $report->run()->render();
} else
{
    echo "Unauthorized";
}

Hope that you get my idea.

Please let me know if my explanation is still unclear.

Eugene commented on Feb 1, 2021

Wow... Thank you. I will try and let you know about the results

KoolReport commented on Feb 1, 2021

Sure, there will be another step but let complete this first, I will guide you next.

Eugene commented on Feb 1, 2021

I have deleted my previous message.

I've added session_start(); in the beginning of the report page (loaded inside iframe) and your solution works!!!

KoolReport commented on Feb 2, 2021

That's great. The next step is when user logout, as you see when dashboard user logout, we need to clear the $_SESSION["login_id"]. We do it by following:

1) Create your own MyLogin page which inherited from our Login page and adding further actionLogout

class MyLogin extends \koolreport\dashboard\pages\Login
{
    protected function actionLogout($request, $response) {
        parent::actionLogout($request,$response);
        $_SESSION["login_id"] = null;
        // unset($_SESSION["login_id"]); // or this code
    }
}

2) Now in your App of dashboard, you use MyLogin instead of our Login inside login() method:

protected function login()
{
    return MyLogin::create()->authenticate(...);
}

So basically, when user hit logout, the session value will be removed and user could not access the report inside iframe directly.

Hope that helps.

Eugene commented on Feb 2, 2021

Thank you so much!

KoolReport commented on Feb 3, 2021

You are welcome :)

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
suggestion

Dashboard