KoolReport's Forum

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

Error in src/widgets/koolphp/Table.tpl.php #562

Open Alex Chartier opened this topic on on Dec 16, 2018 - 4 comments

Alex Chartier commented on Dec 16, 2018

When there is no data in a dataStore this file is throwing a warning that var $i is undefined at line 140. In the previous foreach $i is declared as the key value for each array row. Line 140 wants to render a RowGroup at $i+1 however line 140 is outside of the foreach and if $this->dataStore is empty $i is never instantiated.

Commenting line 140 out does not seem to cause any ill effects on a table rendering but I assume it must be there for a reason. Initializing $i before the foreach would also solve the problem but what should it be initialized to?

I leave it to you to determine the correct course of action.

KoolReport commented on Dec 17, 2018

We will investigate this issue and come back to you soon

KoolReport commented on Dec 17, 2018

Updated from our dev.team: The issue has been solved. Thank you for spotting the issue.

Below is the fix:

        <tbody>
            <?php
            foreach($this->dataStore as $i=>$row)
            {
                $rowStyle = "";
                if($this->paging)
                {
                    if($i<$this->paging["pageIndex"]*$this->paging["pageSize"] || $i>=($this->paging["pageIndex"]+1)*$this->paging["pageSize"])
                    {
                        $rowStyle.="display:none;";
                    }
                }			
                $this->renderRowGroup($groups,$i,count($showColumnKeys));
            ?>
            <tr ri='<?php echo $i; ?>'<?php echo ($rowStyle!="")?" style='$rowStyle'":""; ?><?php if($trClass){echo " class='".((gettype($trClass)=="string")?$trClass:$trClass($row))."'";} ?>>
                <?php
                foreach($showColumnKeys as $cKey)
                {
                    $cssStyle = Utility::get($meta["columns"][$cKey],"cssStyle",null);
                    $tdStyle = is_string($cssStyle)?$cssStyle:Utility::get($cssStyle,"td");
                    ?>
                        <td rv="<?php echo ($cKey!=="#")?$row[$cKey]:($i+$meta["columns"][$cKey]["start"]);?>" <?php echo ($tdStyle)?"style='$tdStyle'":""; ?> <?php if($tdClass){echo " class='".((gettype($tdClass)=="string")?$tdClass:$tdClass($row,$cKey))."'";} ?>>
                            <?php echo Table::formatValue(($cKey!=="#")?$row[$cKey]:($i+$meta["columns"][$cKey]["start"]),$meta["columns"][$cKey],$row);?>
                        </td>
                    <?php
                }
                ?>
            </tr>
            <?php
            }
            ?>
            <?php
            if ($this->dataStore->countData()>0) {
                $this->renderRowGroup($groups, $i+1, count($showColumnKeys));
            } else {
            ?>
                <tr><td colspan="<?php echo count($showColumnKeys); ?>" align="center"><?php echo $this->translate("No data available in table"); ?></td></tr>
            <?php	
            }
            ?>
        </tbody>
Alex Chartier commented on Dec 17, 2018

Hi, I am now getting a fatal error for Class Utility not found. If I then add a use \koolreport\core\Utility; to the top of this file I then get a Class Table not found.

Something not right.

Alex Chartier commented on Dec 17, 2018

Never mind. It wasn't clear in your posting above with the code that this was a segment of the file that needed replacing, not the whole file. It should be OK now.

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
bug
solved

None