KoolReport's Forum

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

Single Page report, need to exclude KoolReport assets #413

Open Dan Smith opened this topic on on Aug 13, 2018 - 2 comments

Dan Smith commented on Aug 13, 2018

Hi, first attempt at using KoolReport and in truth it's really simple to use, however I have an issue which I'm sure everyone has overcome previously.

I'm embedding my KoolReport page within standard header and footer includes and therefore am trying to turn off the KoolReport CSS/assets.

Looking at https://www.koolreport.com/packages/instant it says how to turn off the assets folder, though in practice this doesn't seem to work in my code hence it results in my page displaying between the header and footer of my page though with the KoolReport styling

My code is below, can anyone please point to what I'm doing wrong, or am I just misunderstanding this functionality?

Thanks in advance!

<?php
require_once('fn.php');
require_once "reports/koolreport/autoload.php";

use \koolreport\widgets\koolphp\Table;
use \koolreport\inputs\Select2;
use \koolreport\inputs\DateTimePicker;
use \koolreport\instant\Widget;
class MyReport extends \koolreport\KoolReport
{
    use \koolreport\instant\SinglePage;
    use \koolreport\clients\Bootstrap;
	use \koolreport\inputs\Bindable;
    use \koolreport\inputs\POSTBinding;
    function settings()
    {
        return array(
            "dataSources"=>array(
				"tag"=>array(
					"connectionString"=>"mysql:host=localhost;dbname=".$GLOBALS['dbname'],
					"username"=>$GLOBALS['dbuser'],
					"password"=>$GLOBALS['dbpass'],
					"charset"=>"utf8"
				),  
            ),
        );
    }
    function bindParamsToInputs()
    {
        return array(
            "lender",
        );
    }
    function setup()
    {
		$this->src('tag')
        ->query("
            SELECT distinct(amLender)
            FROM tblInitial
			where amLender is not null
            ORDER BY amLender asc;
        ")
        ->pipe($this->dataStore("lender"));

		$this->src('tag')
        ->query("select amLender, amProductCode, amAmount, amFees_Proc, amFees_Adviser, (amFees_Proc+amFees_Adviser) as 'Sub Total', iIntroducerFee,  (amFees_Proc+amFees_Adviser-iIntroducerFee) as Total from tblInitial where amLender=:lender and amLender is not null group by amLender order by amLender asc; ")->params(array(":lender"=>$this->params["lender"]
        ))->pipe($this->dataStore('mydata'));
    }
}

$report = new MyReport;
$report->start();
?>

<?php 
include_once('header.php');
?>

				<section role="main" class="content-body">
					<header class="page-header">
						<h2>Lender Income Report</h2>
					</header>
					<!-- start: page -->
    

		<form method="post">
		<div class='row'>
			<div class='form-group'>
				<label class='col-sm-2 control-label'>Lender</label>	
				<div class="col-md-6 form-group">
					<?php
					Select2::create(array(
						"name"=>"lender",
						"dataStore"=>$report->dataStore("lender"),
						"defaultOption"=>array("--"=>""),
						"dataBind"=>"amLender",
						"attributes"=>array(
							"class"=>"form-control",
						)
					));
					?>
				</div>	
				<div class='col-sm-2'><button class="btn btn-primary">Run Report</button></div>
			</div>	
		</div>			
		</form>
		<br><hr><br>			
		<div class='row'><div class='col-sm-12'>		
        <?php
        Widget::create(Table::class,array(
            "dataSource"=>$report->dataStore('mydata'),"showFooter"=>"bottom",
			"columns"=>array(
				"amLender"=>array("label"=>"Lender Name"),
				"amProductCode"=>array("label"=>"Product Code"),
				"amAmount"=>array("label"=>"Loan Amount","type"=>"number","prefix"=>"£","footer"=>"sum","footerText"=>"<b>@value</b>"),
				"amFees_Proc"=>array("label"=>"Proc Fee", "type"=>"number","prefix"=>"£","cssStyle"=>"text-align:right","footer"=>"sum","footerText"=>"<b>@value</b>"),
				"amFees_Adviser"=>array("label"=>"Adviser Fee", "type"=>"number","prefix"=>"£","cssStyle"=>"text-align:right","footer"=>"sum","footerText"=>"<b>@value</b>"),
				"Sub Total"=>array("label"=>"Sub-Total", "type"=>"number","prefix"=>"£","cssStyle"=>"text-align:right","footer"=>"sum","footerText"=>"<b>@value</b>"),
				"iIntroducerFee"=>array("label"=>"Introducer Fee", "type"=>"number","prefix"=>"£","cssStyle"=>"text-align:right","footer"=>"sum","footerText"=>"<b>@value</b>"),
				"Total"=>array("label"=>"Total", "type"=>"number","prefix"=>"£","cssStyle"=>"text-align:right","footer"=>"sum","footerText"=>"<b>@value</b>")
			)
        ),false);
        ?>
		</div></div>		
<?php include_once('footer.php');?>


<?php $report->end(); ?>
Dan Smith commented on Aug 13, 2018

ok, so found the simple solution which is to comment out all the lines in koolreport\clients\Bootstrap.php though obviously this overwrites core functionality which is not the way to do it.

David Winterburn commented on Aug 14, 2018

Hi Dan,

Can you try to comment out this line and see how it goes without of changing Bootstrap.php:

use \koolreport\clients\Bootstrap;

Thanks!

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

Instant