ok I got it to work. tnx. now two questions:
1. In the report view header I have the teacher name. I do I make it to replace in each data source?
2. How do I make a page break for each teacher to be printed in a single page?
here is the code
<?php
//MyReport.php
require_once APPPATH."libraries/koolreport/core/autoload.php";
use \koolreport\cube\processes\Cube;
use \koolreport\processes\Filter;
class Teacher_schedule extends \koolreport\KoolReport
{
use \koolreport\amazing\Theme;
var $teacherName = "";
function settings()
{
return array(
"assets"=>array(
"path"=>"../../assets",
"url"=>"assets",
),
"dataSources"=>array(
"sbm"=>array(
"connectionString"=>"mysql:host=localhost;dbname=sbm",
"username"=>"admin",
"password"=>"9b72fa959aecee8a397ae1c3192ad30bef8ec2fe76cfe68a",
"charset"=>"utf8"
)
)
);
}
function setup()
{
$this->src("sbm")
->query('CALL getTeacherSchedule(:year, :teacher_id)')
->params(array(
':year'=>$this->params['year'],
':teacher_id'=>$this->params['teacher_id']
))
->saveTo($node1);
foreach (array(1,2,3,4) as $teacher) {
$node1->pipe( new Filter( array (
array("teacher_id", "=", $teacher)
)))
->pipe(new \koolreport\processes\Map(array(
"{value}" => function($row) {
$row['class_name'] =
$row['group_name'].'<br>'.
( $this->params['show_class'] != null ? $row['class_name'] != '' ? $row['class_name'] : 'ללא כיתה' : null ).'<br>'.
( $this->params['show_profession'] != null ? $row['profession_name'] : null ).'<br>'.
( $this->params['show_room'] != null ? $row['room_name'] : null );
$this->teacherName = $row['teacher_name'];
return $row;
}
)))
->pipe(new Cube(array(
'row' => 'hour_num',
'column' => 'day',
'max' => 'class_name'
)))
->pipe(new \koolreport\processes\Map(array(
"{value}" => function($row) {
foreach ($row as $k => $v)
if ($v == null) $row[$k] = "";
return $row;
}
)))
->pipe(new \koolreport\processes\RemoveColumn(array(
'{{all}}'
)))
->pipe(new \koolreport\processes\ColumnMeta(array(
'hour_num'=>array('label'=>lang('hour_num')),
'1' => array("label" => lang('day_1')),
'2' => array("label" => lang('day_2')),
'3' => array("label" => lang('day_3')),
'4' => array("label" => lang('day_4')),
'5' => array("label" => lang('day_5')),
'6' => array("label" => lang('day_6')),
)))
->pipe($this->dataStore("DS_" . $teacher));
}
}
}