-
Notifications
You must be signed in to change notification settings - Fork 22
/
Detail.php
114 lines (98 loc) · 5.33 KB
/
Detail.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
<?php
namespace JasperPHP;
use \JasperPHP;
/**
* classe TLabel
* classe para construção de rótulos de texto
*
* @author Rogerio Muniz de Castro <rogerio@quilhasoft.com.br>
* @version 2015.03.11
* @access restrict
*
* 2015.03.11 -- criação
* */
class Detail extends Element {
public function generate($obj = null) {
$dbData = $obj->dbData;
if ($this->children) {
$rowIndex = 1;
$totalRows = is_array($dbData) ? count($dbData) : $dbData->rowCount();
$row = is_array($dbData) ? $dbData[0] : $obj->rowData; // $dbData->fetchObject($recordObject);
while ($row) {
$row->rowIndex = $rowIndex;
$obj->arrayVariable['REPORT_COUNT']["ans"] = $rowIndex;
$obj->arrayVariable['REPORT_COUNT']['target'] = $rowIndex;
$obj->arrayVariable['REPORT_COUNT']['calculation'] = null;
$obj->arrayVariable['totalRows']["ans"] = $totalRows;
$obj->arrayVariable['totalRows']["target"] = $totalRows;
$obj->arrayVariable['totalRows']["calculation"] = null;
$row->totalRows = $totalRows;
$obj->variables_calculation($obj, $row);
if (count($obj->arrayGroup) > 0) {
foreach ($obj->arrayGroup as $group) {
preg_match_all("/F{(\w+)}/", $group->groupExpression, $matchesF);
$groupExpression = $matchesF[1][0];
if (($rowIndex == 1 || $group->resetVariables == 'true') && ($group->groupHeader)) {
$groupHeader = new GroupHeader($group->groupHeader);
$groupHeader->generate(array($obj, $row));
$group->resetVariables = 'false';
}
}
}
$background = $obj->getChildByClassName('Background');
if ($background)
$background->generate($obj);
// armazena no array $results;
foreach ($this->children as $child) {
// se for objeto
if (is_object($child)) {
$print_expression_result = false;
$printWhenExpression = (string) $child->objElement->printWhenExpression;
if ($printWhenExpression != '') {
$printWhenExpression = $obj->get_expression($printWhenExpression, $row);
//echo 'if('.$printWhenExpression.'){$print_expression_result=true;}';
eval('if(' . $printWhenExpression . '){$print_expression_result=true;}');
} else {
$print_expression_result = true;
}
$height = (string) $child->objElement['height'];
if ($print_expression_result == true) {
if ($child->objElement['splitType'] == 'Stretch' || $child->objElement['splitType'] == 'Prevent') {
JasperPHP\Instructions::addInstruction(array("type" => "PreventY_axis", "y_axis" => $height));
}
$child->generate(array($obj, $row));
if ($child->objElement['splitType'] == 'Stretch' || $child->objElement['splitType'] == 'Prevent') {
JasperPHP\Instructions::addInstruction(array("type" => "SetY_axis", "y_axis" => $height));
}
if ($obj->arrayPageSetting['columnCount'] > 1) {
JasperPHP\Instructions::addInstruction(array("type" => "ChangeCollumn"));
if (is_int($rowIndex / $obj->arrayPageSetting['columnCount'])) {
JasperPHP\Instructions::addInstruction(array("type" => "SetY_axis", "y_axis" => $height));
}
}
}
}
}
$arrayVariable = ($obj->arrayVariable) ? $obj->arrayVariable : array();
$recordObject = array_key_exists('recordObj', $arrayVariable) ? $obj->arrayVariable['recordObj']['initialValue'] : "stdClass";
$obj->lastRowData = $obj->rowData;
$row = ( is_array($dbData) ) ? (array_key_exists($rowIndex, $dbData)) ? $dbData[$rowIndex] : null : $dbData->fetchObject($recordObject);
//echo $rowIndex;
if (count($obj->arrayGroup) > 0) {
foreach ($obj->arrayGroup as $group) {
preg_match_all("/F{(\w+)}/", $group->groupExpression, $matchesF);
$groupExpression = $matchesF[1][0];
if (($obj->rowData->$groupExpression != $row->$groupExpression) || ($obj->rowData->$groupExpression==NULL)) {
$groupFooter = new GroupFooter($group->groupFooter);
$groupFooter->generate(array($obj, $obj->rowData));
$group->resetVariables = 'true';
}
}
}
$obj->rowData = $row;
$rowIndex++;
}
//$this->close();
}
}
}