KoolReport's Forum

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

Sometimes the report doesn't load (on first try) #2193

Open Richb201 opened this topic on on Jul 8, 2021 - 13 comments

Richb201 commented on Jul 8, 2021

I am continuing this thread in another post since I can't find the first. I have a certain widget (table) that doesn't populate sometimes. I have noted that when this happens and I press refresh on the browser, the data then appears correctly.

Can you tell me what happens when the refresh button in the browser is pressed? I suspect that no new code is running, right? It almost seems as though Koolreport is rendering the charts too slowly for the browser?

This is repeatable. How does the browser know that the rendering is done?

Sebastian Morales commented on Jul 9, 2021

Pls show us the code setup for your widget's datasource so we get an idea of your report structure. Tks,

Richb201 commented on Jul 9, 2021

I broke the report into two reports that get run separately. When I first run the nexus report for whatever taxyear, it seems to work fine. But when I try to change the taxyear by choosing a different year and then pressing "change taxyear", the screen does blink (like it is refreshing) but doesn't seem to fill in the table. But now if then press the browser refresh, it populates fine. Here is the form code to change the tax year:

<?php
if (isset($_POST['taxyear']))
    $_SESSION['last_TY']=$_POST['taxyear'];
?>
<?php
echo "<br><br><br><br><br><br><h3>Nexus Report for:  ".$_SESSION['campaign']." for tax year ended ".$_SESSION['last_TY'];
?>

Here is the section I am talking about

When I first try to run the report from the main menu, the .view runs and the results are OK. But when I change the taxyear (from the code above), the .view runs again. The same code runs again, but with a different taxyear. Here is the code:

Table::create(array(
        "dataStore"=>$this->dataStore("BPlt_BC")->filter("taxyear","=",$_SESSION['last_TY']),
        "showFooter"=>true,
        "grouping"=>array(
            "item"=>array(
                "calculate"=>array(
                    "{sumAmount}"=>array("sum","dollarsPerBC"),
                ),
                "cssStyle"=>"text-align:right",
                "bottom"=>"<td colspan='6 style='text-align: right'><b>Total qualified wages for : {item}</b></td><td style='text-align: right'><b>{sumAmount}</b></td><br>",

            ),
        ),

        "showFooter"=>"bottom",
        "columns"=>array(
            "item"=>array("label"=>"Business Component"),
            "employee",
            "employee_email",
            "title",
            "role",
            "qualified_dollars"=>array(
                "label"=>"Qualified Wages",
                "cssStyle"=>"text-align:right",
            ),


            "dollarsPerBC"=>array(
                "label"=>"dollars",
                "cssStyle"=>"text-align:right",
                "prefix"=>"$",
                "footer"=>"sum",
                "footerText"=>"<b>Total Qualified Wages for all Business Components:</b> @value")

        ),

        "cssClass"=>array(
            "table"=>"table table-bordered",
            "tr"=>"row-css-class",
            "th"=>"header-css-class",
            "td"=>"cell-css-class",
            "tf"=>"footer-cell-css-class",
        )
    )
);

But this time the new table does not get populated. But if I press the Browser refresh I get this popup:

and if I hit "continue", the .view runs again, and now the table is fully populated. So something about pressing the browser refresh makes it work! So how do I get the "form resubmission" to fire wo user intervention?

Richb201 commented on Jul 10, 2021

I have pretty much concluded that when I change the taxyear with the pull down (as per your advice, btw), I am not also submitting the form. If there is no resubmission, then the report and the .view is not running. Thus is the issue. I know this because if I press F5 it works fine. How can I fix this?

A while back I asked you how to tell if the koolreport cache is off? Can you confirm that if there is no mention of cache on my .view that cache is not active?

I have also found some stackoverflow comments that I should turn off browser cache on my report with Php header commands. Will this maybe work? But I am worried because I need the .view (and the setup?) To run again with the new filter.

cfsinc commented on Jul 11, 2021

You need to keep your browser in incognito mode when you are testing. If you dont, changes may not always show correctly. You could have an issue and not know it. Even with page refresh.

I have had zero caching issues with the framework and I am pulling 10s of thousands of records and a couple of dozen separate mysql queries on each report. There is little way to get to the bottom of a problem like this without running your entire code to find what was done wrong. you have to segment every step.

Anyways if your not testing in incognito mode you could introduce problems many steps back and not know.

Richb201 commented on Jul 11, 2021

I can do that. I am testing the server on my laptop. I am running my browser and accessing by typing localhost. So I am thinking that only the client (browser) will be running in incognito. My server is running under Ubuntu in a few Docker containers.. Any implications by using incognito for the browser? The reason I am doing this under Docker (what a pain this has been) is so that when I run the Docker containers on AWS it will work exactly the same as the server running under docker on my laptop. Am I missing something?

Sebastian Morales commented on Jul 13, 2021

Pls post the code where you pipe data to your $this->dataStore("BPlt_BC"). Tks,

Richb201 commented on Jul 13, 2021

OK. this is from the setup{}


        $sql = "SELECT *
        FROM  BC_PR_list_temp as BPlt
       WHERE BPlt.taxyear='$taxyear' AND item!='' AND type='BC'";

        $this->src('substantiator')
            ->query($sql)
            ->pipe($this->dataStore("BPlt_BC"));

        $sql = "SELECT *
        FROM  BC_PR_list_temp as BPlt
       WHERE BPlt.taxyear='$taxyear' AND item!='' AND type='PR'";

        $this->src('substantiator')
            ->query($sql)
            ->pipe($this->dataStore("BPlt_PR"));


        $sql = "SELECT *
        FROM  substantially_all_render_temp2 as sart2
       WHERE sart2.taxyear='$taxyear' AND BC!=''AND PR=''
       GROUP BY sart2.BC";

        $this->src('substantiator')
            ->query($sql)
            ->pipe($this->dataStore("sart2_BC"));

        $sql = "SELECT *
        FROM substantially_all_render_temp2 as sart2
       WHERE sart2.taxyear='$taxyear' AND PR!=''AND BC=''
       GROUP BY sart2.PR";

        $this->src('substantiator')
            ->query($sql)
            ->pipe($this->dataStore("sart2_PR"));
    }

Richb201 commented on Jul 13, 2021

cfsinc, I loaded the browser in incognito mode and I get the same issue. What is weird about my app is that to change the "taxyear" of the report, I use this code in the viewfile:

<form method="post">

    <?php
    $taxyear=$_SESSION['last_TY'];
\koolreport\inputs\Select::create(array(
    "name"=>"taxyear",
    "data"=>$_SESSION['TY'],
    "defaultOption"=>array($taxyear=>$_SESSION['last_TY']),
));
    ?>
    <button type="submit"><< change tax year</button>
</form>

The problem is that this won't work unless I hard refresh with F5. Pressing just SUBMIT won't do it! How can I force a hard refresh?

Richb201 commented on Jul 13, 2021

Somehow this just started working without the resubmit. I have no idea why? I have tried so many things that I lost count.

Sebastian Morales commented on Jul 14, 2021

Is this setup in your nexus report and the web view your nexus report's view? If there's still any problem pls post the whole picture of your reports.

Particularly, to debug the problem pls add and echo command for your sql query like this:

        $sql = "SELECT *
        FROM  BC_PR_list_temp as BPlt
       WHERE BPlt.taxyear='$taxyear' AND item!='' AND type='BC'";
        echo "sql=$sql <br>";

When you click submit the sql should be echoed. Then copy and paste it to your database interface and execute the sql to see where the problem is. Rgds,

cfsinc commented on Jul 14, 2021

Rich that incognito mode was for constant testing. When you are not in that mode and make php changes much of the time the page can be cached. I was not expecting it to fix this issues but you will see issue immediately if you always test in that mode. If I dont use it things get me sometimes.

Richb201 commented on Jul 14, 2021

Sebastion, the original design had everything in one report called MyReport. I copied the Nexus report from it to a separate report so I could concentrate on it. The original MyReport is still intact and accessible from my main menu.

There is one part of the Nexus report that is still not working, but I am pretty sure that it is an sql query error that I can solve since it consistently doesn't work.

Richb201 commented on Jul 14, 2021

This is what seemed to fix it (the header line). Now when I change the taxyear, the screen blinks twice, and all seems to be AOK.

<?php
if (isset($_POST['taxyear'])) {
    $_SESSION['last_TY'] = $_POST['taxyear'];//update the laST YEAR
    header("Refresh:0");   <<<<<<<<<<<<<<<<<<here!
}
?>

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

None