3
* © Copyright 2008 IntraHealth International, Inc.
5
* This File is part of I2CE
7
* I2CE is free software; you can redistribute it and/or modify
8
* it under the terms of the GNU General Public License as published by
9
* the Free Software Foundation; either version 3 of the License, or
10
* (at your option) any later version.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <http://www.gnu.org/licenses/>.
3
* @copyright © 2008, 2009 Intrahealth International, Inc.
4
* This File is part of I2CE
6
* I2CE is free software; you can redistribute it and/or modify it
7
* under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 3 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program. If not, see <http://www.gnu.org/licenses/>.
21
20
* I2CE_CustomReport_Display_Default -- the default HTML display of a report view
24
23
* @author Carl Leitner <litlfred@ibiblio.org>
25
* @copyright Copyright © 2008 IntraHealth International, Inc.
26
* This file is part of I2CE. I2CE is free software; you can redistribute it and/or modify it under
27
* the terms of the GNU General Public License as published by the Free Software Foundation; either
28
* version 3 of the License, or (at your option) any later version. I2CE is distributed in the hope
29
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
30
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have
31
* received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
63
* @var protected array $formfields The array of formfields to display for this report.
64
* Keys are the formfields
66
protected $formfields = null;
71
70
protected function doHeaderRow($contentNode) {
72
$page_root = "CustomReports/view/{$this->view}/{$this->display}";
71
$page_root = "CustomReports/show/{$this->view}/{$this->display}";
74
73
$qry_fields = $this->page->request();
75
74
if (array_key_exists('sort_order',$this->defaultOptions)) {
81
80
if (count($qry_fields) > 0) {
83
$qry_fields = $this->page->flattenVariables($qry_fields,$flat);
82
$qry_fields = I2CE_Util::flattenVariables($qry_fields,$flat);
85
84
foreach ($flat as $key=>$val) {
86
85
if (is_array($val)) {
87
86
foreach ($val as $v) {
88
array_push($fields, "{$key}[]=$v");
87
array_push($fields, urlencode($key) . "[]=" . $v);
91
array_push($fields, "$key=$val");
90
array_push($fields, urlencode($key) . '=' . $val);
94
93
$page_root .= '?' . implode('&',$fields);
97
96
if ($this->page->hasAjax()) {
98
$this->page->getTemplate()->addHeaderLink("mootools.js");
97
$this->page->getTemplate()->addHeaderLink("mootools-core.js");
100
99
$sort_order = array();
101
$formfields = $this->getDisplayFieldsData();
100
if ($this->formfields == null) {
101
$this->formfields = $this->getDisplayFieldsData();
102
103
$sort_descriptions = array();
103
104
$t_sortFields = array();
104
105
foreach ($sortFields as $i=>$s) {
108
109
if ($s[0] == '-') {
109
110
$s = substr($s,1);
110
if ( !array_key_exists($s,$formfields)) {
111
if ( !array_key_exists($s,$this->formfields)) {
113
$sort_descriptions[] = $formfields[$s]['header'] . ' (Decreasing)';
114
$sort_descriptions[] = $this->formfields[$s]['header'] . ' (Decreasing)';
114
115
$t_sortFields[$s] = true;
115
116
$sort_order[$s] = '-';
117
if ( !array_key_exists($s,$formfields)) {
118
if ( !array_key_exists($s,$this->formfields)) {
120
$sort_descriptions[] = $formfields[$s]['header'] . ' (Increasing)';
121
$sort_descriptions[] = $this->formfields[$s]['header'] . ' (Increasing)';
121
122
$t_sortFields[$s] = true;
122
123
$sort_order[$s] = '';
128
129
$sort_description = implode(',',$sort_descriptions);
130
131
$this->template->setDisplayDataImmediate('sort_description',$sort_description,$contentNode);
132
134
if (count($sortFields) > 0) {
133
135
$color_grad = (int) floor((0xFF - 0xCC) /(count($sortFields)));
135
foreach ($formfields as $formfield=>$data) {
137
foreach ($this->formfields as $formfield=>$data) {
136
138
$head = $this->template->appendFileByName( "customReports_table_head_cell.html", "th", "report_header",0,$contentNode );
137
139
if (!$head instanceof DOMNode) {
138
140
I2CE::raiseError("Could not add head cell to table");
141
if ( $formfield == $sortFields[count($sortFields) -1]) {
143
if ( count($sortFields) > 0 && $formfield == $sortFields[count($sortFields) -1]) {
142
144
$this->template->setNodeAttribute( "class", "selected", $head );
144
146
$position = array_search($formfield,$sortFields);
235
237
foreach (array('limit_page') as $key) {
236
238
unset($qry_fields[$key]);
238
$url = "CustomReports/view/{$this->view}/{$this->display}";
240
$url = "CustomReports/show/{$this->view}/{$this->display}";
241
$qry_fields = I2CE_Page::flattenRequestVars($qry_fields);
239
242
$this->page->makeJumper('report',$page,$total_pages,$url,$qry_fields,'limit_page');
245
247
* Process a result row.
249
251
* @param DOMNode $contentNode. Default to null. A node to append the result onto
251
253
protected function processResultRow($row,$row_num,$contentNode=null) {
252
$formfields = $this->getDisplayFieldsData();
254
if ($this->formfields == null) {
255
$this->formfields = $this->getDisplayFieldsData();
253
257
$mapped_row = $this->mapResults($row);
254
258
$rowNode = $this->template->appendFileByNode( "customReports_table_data_row.html", "tr",$contentNode);
255
259
if (!$rowNode instanceof DOMNode) {
259
263
$this->template->setDisplayDataImmediate( "row_count", $row_num+1 ,$rowNode);
260
foreach ($formfields as $formfield =>$data) {
264
foreach ($this->formfields as $formfield =>$data) {
261
265
if ($data['link']) {
262
266
$cellNode =$this->template->appendFileByNode( "customReports_table_link_cell.html", "td", $rowNode );
263
267
$link_append = '';