Hi tee,
If you check your email then you will received 3 files: AggregatedColumn.php, Table.php and Table.tpl.php
Please do:
- Copy the
AggregatedColumn.php
into \koolreport\processes
- Replace
Table.php
and Table.tpl.php
in folder \koolreport\widgets\koolphp
Now for your questions:
Problem 1: Arrange the date in first place, you simply set it at first in the columns settings of Table
Table::create(array(
...
"columns"=>array("date","apples","oranges")
))
Problem 2: Total of oranges in Table at footer
Table::create(array(
...
"showFooter"=>true,
"columns"=>array(
"date",
"apples",
"oranges"=>array(
"footer"=>"sum",
)
)
))
Problem 3: Percentage of orange (This is interesting)
Now is when the AggregatedColumn to come in with purpose of creating new column "oranges_total" holding the total number of oranges. Then later we use the CalculatedColumn to create column called "oranges_percent". Last step is to show to oranges_percent in Table with percent mark.
Now in the setup we do:
->pipe(new AggregatedColumn(array(
"oranges_total"=>array("sum","oranges")
)))
->pipe(new CalculatedColumn(array(
"oranges_percent"=>"{oranges}*100/{oranges_total}"
)))
->pipe($this->dataStore("mydata"));
In the view we do:
Table::create(array(
"columns"=>array(
"date",
"apples",
"oranges",
"oranges_percent"=>array(
"type"=>"number"
"suffix"=>"%",
)
)
))
Problem 4: Accumulated columns
Again, we will use the AggregatedColumn to calculated
->pipe(new AggregatedColumn(array(
"oranges_accumulated" =>array("acml","oranges")
)))
Now you have the accumulated column "oranges_accumulated"
All the best!