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_PDF
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/>.
47
39
* Display the report
48
40
* @param DOMNode $contentNode The DOM node we wish to display into
49
41
* @param boolean $processResults Defaults to true meaning we run through the results
42
* @param mixed $controls. If null (default), we display all the report controsl. If string or an array of string, we only display the indicated controls
50
43
* @returns boolean. true on sucess
52
public function display($contentNode,$processResults = true) {
45
public function display($contentNode,$processResults = true, $controls = null) {
53
46
if ($this->page->request_exists('flash_data')) {
54
return parent::display(false,true);
47
return parent::display(false,true, $controls);
56
return parent::display($contentNode,false);
49
$parent_return = parent::display($contentNode,false,$controls);
57
50
//we want to do the reference to the flash content (this will call processResults below)
51
// -- This doesn't seem to call processResults anymore so adding in the chart stuff here (?)
53
$i2ce_config = I2CE::getConfig();
55
$i2ce_config->setIfIsSet($license, 'modules/maani-charts/license');
56
$this->template->addHeaderLink('swfobject.js');
57
$flashDataURL = 'file/charts.swf?library_path=file/charts_library';
59
$flashDataURL .= '&license=' . $license;
61
$save_req = "flash_data&" . file_get_contents( "php://input" ) . "&" . $_SERVER['QUERY_STRING'];
62
$req_key = md5($save_req);
63
$_SESSION['req_query'][ $req_key ] = $save_req;
64
$flashDataURL .='&php_source=' .
65
urlencode("CustomReports/show/{$this->view}/{$this->display}?req_query=" . $req_key );
66
$js = "\tif(window.addEvent) { window.addEvent('domready', function() { swfobject.embedSWF('$flashDataURL', \n\t\t'report_results', '{$this->defaultOptions['flash_width']}', " .
67
" '{$this->defaultOptions['flash_height']}', '9.0.0' ,'expressInstall.swf', \n\t\t" .
68
" {}, \n\t\t{quality: 'high', bgcolor:'{$this->defaultOptions['flash_bgcolor']}',wmode:'opaque'}\n\t); } ); } ";
70
$this->template->addHeaderLink('mootools-core.js');
71
$this->template->addHeaderText($js,'script',true); //add this to a new script node.
73
return $parent_return;
83
100
SendChartData( $this->chart);
103
// I don't think this ever gets called anymore? Can it just be removed?
104
I2CE::raiseError( "I don't think this should be called this way anymore. It's being added to display() instead." );
86
105
//just make a reference to the chart
87
106
$i2ce_config = I2CE::getConfig();
89
if ($i2ce_config->__isset('modules/maani-charts/license')) {
90
$license = $i2ce_config->__get('modules/maani-charts/license');
92
//$restuls_data will be false b/c we called parent::display($contentNode,false) in display() above
108
$license = $i2ce_config->setIfIsSet($license, 'modules/maani-charts/license');
109
//$results_data will be false b/c we called parent::display($contentNode,false) in display() above
93
110
if (!$contentNode instanceof DOMNode) {
96
113
$this->template->addHeaderLink('swfobject.js');
97
$flashDataURL.= 'file/charts.swf?library_path=file/charts_library';
114
$flashDataURL = 'file/charts.swf?library_path=file/charts_library';
99
116
$flashDataURL .= '&license=' . $license;
102
119
$req_key = md5($save_req);
103
120
$_SESSION['req_query'][ $req_key ] = $save_req;
104
121
$flashDataURL .='&php_source=' .
105
urlencode("CustomReports/view/{$this->view}/{$this->display}?" . 'req_query=' . $req_key );
122
urlencode("CustomReports/show/{$this->view}/{$this->display}?req_query=" . $req_key );
106
123
$js = "\tif(window.addEvent) { window.addEvent('domready', function() { swfobject.embedSWF('$flashDataURL', \n\t\t'report_results', '{$this->defaultOptions['flash_width']}', " .
107
124
" '{$this->defaultOptions['flash_height']}', '9.0.0' ,'expressInstall.swf', \n\t\t" .
108
125
" {}, \n\t\t{quality: 'high', bgcolor:'{$this->defaultOptions['flash_bgcolor']}',wmode:'opaque'}\n\t); } ); } ";
110
$this->template->addHeaderLink('mootools.js');
127
$this->template->addHeaderLink('mootools-core.js');
111
128
$this->template->addHeaderText($js,'script',true); //add this to a new script node.
162
179
array_multisort($this->chart['chart_data'][1],SORT_DESC,$this->chart['chart_data'][0]); //sort the chart data on the second row, the values.
183
* Moving this to the conditional below instead.
184
* This corrects some issues with charts. I'm not sure if it introduces new problems or not.
165
185
if ($this->reverseOrder) {
166
186
array_unshift($this->chart['chart_data'],array('',''));
168
188
array_unshift($this->chart['chart_data'][0],'');
170
191
$displayedFields = $this->getDisplayFieldsData();
171
192
if ($type == 'one_row_total') {
172
$header = $displayedFields[$this->displayedChartFields[0]]['header'];
193
$header1 = $displayedFields[$this->displayedChartFields[0]]['header'];
194
$header2 = $displayedFields[$this->displayedChartFields[1]]['header'];
174
$header = $displayedFields[$this->displayedChartFields[1]]['header'];
196
$header1 = $displayedFields[$this->displayedChartFields[1]]['header'];
197
$header2 = $displayedFields[$this->displayedChartFields[0]]['header'];
176
199
if ($this->reverseOrder) {
177
$this->chart['chart_data'][0][1] = $header;
200
array_unshift($this->chart['chart_data'],array('',''));
201
$this->chart['chart_data'][0][1] = $header1;
179
array_unshift($this->chart['chart_data'][1],$header);
203
//array_unshift($this->chart['chart_data'][1],$header);
204
// I'm not sure if this is right, but it fixes a couple instances so I'm trying it
205
array_unshift($this->chart['chart_data'][0],$header1);
206
array_unshift($this->chart['chart_data'][1],$header2);
537
$this->template->addHeaderLink('mootools.js');
564
$this->template->addHeaderLink('mootools-core.js');
538
565
$this->template->addHeaderText($js,'script','script_chart_type_options');
540
$avail_fields = $this->getReportViewDisplayedFields(false,array(''));
567
$avail_fields = $this->getReportViewDisplayedFields( false, array( '' ) );
541
568
$numeric = $this->findNumericFields();
542
569
$selects = $this->template->query('.//select[@class="reportformfield" or @class="reportformfield_numeric"]',$contentNode);
543
570
for ($i=0; $i < $selects->length; $i++) {
590
617
if (!is_scalar($selected) || count($keys) > 0 || (is_string($selected) && strlen($selected) == 0)) {
591
618
$selected = false;
593
if ($selected === false) {
620
if ( $selected === false ) {
596
623
$options = $this->template->query(".//option[@value='$selected']",$selectNode);
597
624
if ($options->length == 1) {
598
$selected_options = $this->template->query(".//option[@selected]",$selectNode);
625
$selected_options = $this->template->query( ".//option[@selected]", $selectNode );
599
626
//remove any existing selections
600
for ($j=0; $k < $selected_options->length; $j++) {
601
$selected_options->removeAttribute('selected');
627
for( $j = 0; $j < $selected_options->length; $j++ ) {
628
$selected_options->item($j)->removeAttribute('selected');
603
630
$options->item(0)->setAttribute('selected','selected');
614
641
protected function setupFlashChart(&$defaultOptions) {
615
642
$type = $defaultOptions['displayFieldsType'];
616
643
$displayFields = $defaultOptions['displayFields'];
617
$this->update($defaultOptions['displayFields'], $defaultOptions['displayFieldsTypes'][$type]);
644
I2CE_Util::merge_recursive($defaultOptions['displayFields'], $defaultOptions['displayFieldsTypes'][$type]);
619
646
$data['title']['text']= $this->config->display_name;
620
647
$data['elements']= array();
624
651
if (array_key_exists('global_chart_options',$defaultOptions) && is_array($defaultOptions['global_chart_options'])) {
625
652
$this->chart = $defaultOptions['global_chart_options'];
627
$this->update($this->chart,$defaultOptions['styles'][$style]['chart_options']);
654
I2CE_Util::merge_recursive($this->chart,$defaultOptions['styles'][$style]['chart_options']);
628
655
$this->displayedChartFields = array();
629
656
foreach ($defaultOptions['displayFields'] as $index=>$data) {
630
657
if (!is_numeric($index)) {