KoolReport's Forum

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

Inhibiting sections of the report #1998

Closed Richb201 opened this topic on on Mar 27, 2021 - 3 comments

Richb201 commented on Mar 27, 2021

If no data exists for a particular part of my report, I'd like to not show that section in the report. For example, there is no data for Nexus in the report shown on the attached page. In the view I'd like to be able to not have that section 1.4 appear at all and skip to the next section. How do I do that? (please don't answer that I just remove that section from the view!)

Here is the section of view that creates nexus:

<h2> 1.4 Nexus </h2>
<h4><font color="#006699">business components</font></h4>
<?php
Table::create(array(
    "dataStore"=>$this->dataStore("survey_business_component")->filter("taxyear","=",$_SESSION['last_TY']),

    "showFooter"=>true,
    "columns"=>array(
        "Business_component",
        "amount"=>array(
            "cssStyle"=>"text-align:right",
            "prefix"=>"$",
            "footer"=>"sum",
            "footerText"=>"<b>Total dollars:</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"
)
));
?>

<h4><font color="#006699">projects</font></h4>
<?php
Table::create(array(
    "dataStore"=>$this->dataStore("survey_project")->filter("taxyear","=",$_SESSION['last_TY']),


        "showFooter"=>true,
    "columns"=>array(
        "Project",
        "qualified_$"=>array(
            "cssStyle"=>"text-align:right",
            "prefix"=>"$",
            "footer"=>"sum",
            "footerText"=>"<b>Total dollars:</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",
        )
    )
);

Here is another example.

Sections that say "No data available in table", I'd like to just not appear in the report. How can i do this?

Here is the code in the view for this section:

<h2 id="First_Point_Header" style="font-weight: bold;color:black;font-size:40px">2.  Methodology </h2>
<h2> 2.1 Division Background </h2>

<?php
Table::create(array(
    "dataStore"=>$this->dataStore("campaigns2"),
    "class"=>array(
        "table"=>"table table-hover"
    )
));
?>


<?php
Table::create(array(
    "dataStore"=>$this->dataStore("campaigns22"),
    "class"=>array(
        "table"=>"table table-hover"
    )
));
?>
<h2> <font color="#006699">2.15 IUS </h2>
<?php
if ($_SESSION['type']==2)  //2 is software therefore include IUS
    {
Table::create(array(
    "dataStore"=>$this->dataStore("ius")->filter("IUS","=",1),
    "columns"=>array(
        "bus_comp",
        "dual_use_text",
        "innovative_text",
        "sig_eco_text"),

    "class"=>array(
        "table"=>"table table-hover"
    )
));
  }
?>



<h2> 2.2 Products </h2>
<?php
Table::create(array(
    "dataStore"=>$this->dataStore("campaigns22"),
    "class"=>array(
        "table"=>"table table-hover"
    )
));
?>
KoolReport commented on Mar 29, 2021

You do:

<?php 
$source = $this->dataStore("survey_business_component")->filter("taxyear","=",$_SESSION['last_TY']);
?>

<?php if($source->count()>0): ?>
    <h2> 1.4 Nexus </h2>
    <h4><font color="#006699">business components</font></h4>
    <?php Table::create([
        "dataSource"=>$source
    ]);?>
    ...
<?php endif; ?>
Richb201 commented on Mar 29, 2021

I need to get the totals of certain reports, and then put this number into a spreadsheet. Can I just assign the totals like this: $sum=$source->sum()? Of course I have a number of columns, so i need to specify which. And how to I get them into Excel? I see that I can export from a table into Excel. Is this the preferred way?

KoolReport commented on Mar 30, 2021

Refered to topic #2000

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
solved

None