KoolReport's Forum

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

Formating and duplicate issues #646

Open Daniel Amamoo-Otchere opened this topic on on Feb 4, 2019 - 5 comments

Daniel Amamoo-Otchere commented on Feb 4, 2019

Hello KoolReports team, I have a challenge I cannot seem to figure out where that error is coming from. Your assistance will be greatly appreciated.

I developed a receipt like template to display in a table. My database spits out a table layout already formatted as I want it. Having challenge with 1. The records come duplicated but in the database it is not duplicated

There is also an error which shows after the first layout load which is ">. I have checked my code but cannot find any missing tags as seen in the image.

The code spit out by the database is for each row :

<style>
table { font-family: arial, sans-serif; border-collapse: collapse; width: 100%;}
td, th {border: 1px solid #dddddd; text-align: left; padding: 8px;}
tr:nth-child(even) { background-color: #dddddd;}
</style>
<table >
		<tr>
		<td rowspan="3"><img src="thumb.jpg" style="width:100px;"></td>
		<td><b>UID :</b>ID-15188</td>
		<td><b>NAME :</b>GIFTY PEPRAH WADIE</td>
		<td><b>SEX : </b>Female</td>
		</tr>
		<tr>
		<td><b>DATE OF BIRTH :</b>12-06-1999</td>
		<td><b>COMMUNITY : </b>ODUASE I</td>
		<td><b>CONTACT NO. :</b>548744547</td>
		</tr>
		<tr>
		<td><b>CONTACT ADDRESS : </b>NO 4 LAGOS</td>
		<td><b>IDENTIFICATION :</b>NID 09184947595</td>
		<td><b>TRADITIONAL AUTHORITY : </b>YES</td>
		
		</tr>
	</table>

Now the code for the main file is :

<?php

require_once "../koolreport/autoload.php";

use \koolreport\KoolReport;

class StakeholderIndex extends KoolReport
{
  //use \koolreport\clients\Bootstrap;
    use \koolreport\inputs\Bindable;
  //  use \koolreport\inputs\POSTBinding;
//	use \koolreport\export\Exportable;

    protected function defaultParamValues()
    {
        return array(
          	"person_id"=>"3565"
        );
    }

    protected function bindParamsToInputs()
    {
        return array(
			 "person_id"
        );
    }

    public function settings()
    {
        $config = include "config.php";
        return array(
            "dataSources"=>array(
                "pace"=>$config["postdb"]
            ),
        );
    }   
    
    
    protected function setup()
    {
        $this->src('pace')
        ->query("
             SELECT 
			   header_display_tag
            FROM
                engagements.stakeholder_html_table
				where stakeholder_id=:pstakeholder 
                
        ")
        ->params(array(
            ":pstakeholder"=>$this->params["person_id"],
        ))
        ->pipe($this->dataStore("result"));

        $this->src("pace")->query("
            SELECT
            stakeholder_id,
                concat(uid_person,' ',name_persons) as name  
            FROM
                engagements.stakeholder 
            ORDER BY name_persons asc
             
        ")
        ->pipe($this->dataStore("IndexList"));
		
    } 

}
?>

Code for view.php

<?php 
    use \koolreport\widgets\koolphp\Table;
    use \koolreport\inputs\Select2;
   
?>
<!DOCTYPE >
<html>
    <head>
        <title>Index Report</title>

    </head>   
       <body style="margin:0.5in 1in 0.5in 1in">
        <link rel="stylesheet" href="../../../assets/bootstrap/css/bootstrap.min.css" />
        <link rel="stylesheet" href="../../../assets/bootstrap/css/bootstrap.theme.min.css" />   
    
            
            <form method="post" id="parameterForm">
  				 <div class="col-md-12 form-group">
				<?php
                     Select2::create(array(
                          "name"=>"person_id",
                            "dataStore"=>$this->dataStore("IndexList"),
                            "dataBind"=>array(
                             "text"=>"name",
                            "value"=>"stakeholder_id"								   
                            ),
                                "display"=>"horizontal"
                        ));
                   
                     ?>
				</div>
                <div class="form-group">
                    <button class="btn btn-primary">Submit</button>
                </div>
            </form>
            <div class="page-header" style="text-align:Left"><b><i>Index Report</i></b></div>
			   
            <?php
    
                Table::create(array(
                    "dataStore"=>$this->dataStore("result"),
                     "showHeader"=>false,
               "columns"=>array(
			   			"header_display_tag"
                    )
                ));
        
            ?>

           
		
    </body>
</html>

Daniel Amamoo-Otchere commented on Feb 5, 2019

Hello, Any help with this will be greatly appretiated.

KoolReport commented on Feb 5, 2019

You may inspect your html to see where the ''> come from. It seems to me that there was missing tags or missing < somewhere that break the table as well as showing above character.

Daniel Amamoo-Otchere commented on Feb 5, 2019

Hello, I have investigated but all my tags are closed.

When I inspected through the debugger I see that the table.js seem to generate it the following code. I have highlighted the problem area.

I generated my code in w3schools as well through the html validator but it did not give any error

</select>
<script type="text/javascript">
    $('#person_id').select2([]);
    </script>				</div>
                <div class="form-group">
                    <button class="btn btn-primary">Submit</button>
                </div>
            </form>
  
            <div class="koolphp-table " id="ktable5c59fc4dd67781">
	<table class='table'>
						<tbody>
						<tr row-index='0'>
											__<td row-value="<table>__
 		<caption><h2>STAKEHOLDER INDEX REPORTS</h2></caption>
	 <thead>
		<tr>
		<td rowspan="3"><img src="http://XXX//thumb.jpg"style="width:100px;"/></td>
		<td colspan="3"><b>UID  :</b>ID-10998</td>
		<td colspan="4"><b>NAME :</b>SAM  OFORI BONNEY</td>
		<td colspan="3"><b>SEX  :</b>Male</td>
		</tr>
		<tr>
		<td colspan="3"><b>DATE OF BIRTH :</b>1959-01-01</td>
		<td colspan="4"><b>COMMUNITY     :</b>APRISUA</td>
		<td colspan="3"><b>CONTACT NO.   :</b>024-6470341</td>
		</tr>
		<tr>
		<td colspan="3"><b>CONTACT ADDRESS :</b></td>
		<td colspan="4"><b>IDENTIFICATION  :</b>10177255(FC)</td>
		<td colspan="3"><b>TRAD. AUTHORITY :</b>N/A</td>
		</tr>
	 </thead>
	   <tbody>
 <tr>
    <th>PROJECT</th>
    <th>PARCEL NO.</th>
    <th>CHIT NO.</th>
    <th>DATE SURV.</th>
    <th>LAND STATUS</th>
    <th>COMMUNITY</th>
    <th>FARM AMT.(GHS)</th>  
    <th>DLU AMT.(GHS)</th> 
    <th>BACK PAY AMT.(GHS)</th>
    <th>TOTAL AMT.(GHS)</th>     
</tr><tr><td>Mining Area Boundary Line Cutting</td>
		<td>31019</td>
		<td>EP00024</td>
		<td>2007-01-08</td>
		<td>Cultivated</td>
		<td>ASENSO</td>
		<td>8399.33</td>
		<td>2075.55</td>
		<td>0</td>
		<td>10474.88</td>		  
		</tr>
		<tr><td>Mining Area Boundary Line Cutting</td>
		<td>SH1214</td>
		<td>EP00052</td>
		<td>2007-01-08</td>
		<td></td>
		<td>BIBINIKROM</td>
		<td>11645.65</td>
		<td>3420.38</td>
		<td>0</td>
		<td>15066.03</td>		  
		</tr>
		<tr><td>Mining Area Boundary Line Cutting</td>
		<td>SH1047</td>
		<td>EP00030</td>
		<td>2007-01-08</td>
		<td></td>
		<td>BIBINIKROM</td>
		<td>1041.25</td>
		<td>71.89</td>
		<td>0</td>
		<td>1113.14</td>		  
		</tr>
		
		</tbody></table>__"  >__
								<table>
KoolReport commented on Feb 6, 2019

I understand the issue you, you do this:

On the query for result, you do:

             SELECT 
			   header_display_tag, "" as blank
            FROM
                engagements.stakeholder_html_table
				where stakeholder_id=:pstakeholder 

On the Table widget, you do:

                Table::create(array(
                    "dataStore"=>$this->dataStore("result"),
                     "showHeader"=>false,
                     "columns"=>array(
                        "blank"=>array(
                            "name"=>"Display",
                            "formatValue"=>function($value,$row)
                            {
                                return $row["header_display_tag"];
                            }
                        )
                    )
                ));

From my personal point of view, you should not store html inside database because it will make your database larger and later it is really hard for you to change the template. If I do, I will store only essential data such as id, name. You could store it in the form of json also fine, later you can parse it and fill into template at php level. This way is more flexible as we try to separate data layer and presentation layer.

Daniel Amamoo-Otchere commented on Feb 6, 2019

Many thanks it worked quite well. I am not storing html in the database, It is from a query. I am not sure how to generate the same formated report in koolreport. Unless you can show me how so I do not have to do it as a view in the system.

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

Excel