~mortenoh/+junk/dhis2-detailed-import-export

« back to all changes in this revision

Viewing changes to local/in/dhis-web-dashboard/src/main/webapp/dhis-web-dashboard/graphicalAnalysisResult.vm

  • Committer: larshelge at gmail
  • Date: 2009-03-03 16:46:36 UTC
  • Revision ID: larshelge@gmail.com-20090303164636-2sjlrquo7ib1gf7r
Initial check-in

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
 
 
3
<html>
 
4
<head>
 
5
<title>Chart Result Screen</title>
 
6
<link type="text/css" rel="stylesheet" href="css/StylesForTags.css">
 
7
<script type="text/javascript" src="../dhis-web-commons/request.js"></script>
 
8
<script type="text/javascript" src="javascript/lists.js"></script>
 
9
<script type="text/javascript" src="javascript/ga.js"></script>
 
10
<script type="text/javascript" src="javascript/hashtable.js"></script>
 
11
 
 
12
<script>
 
13
 
 
14
  var indexForChart = 0;
 
15
  var chartNamesToView = new Array();
 
16
  chartNamesToView[0] = new Array("Nothing");
 
17
  chartNamesToView[1] = new Array("Vertical3DBarChart","Horizontal3DBarChart","LineChart","LineAndBarChart","DualAxisChart","AreaChart","PieChart3D");  
 
18
  chartNamesToView[2] = new Array("Vertical3DBarChart","Horizontal3DBarChart","LineChart","LineAndBarChart","DualAxisChart","AreaChart");                                                                                                       
 
19
        
 
20
  function nextCharttoView()
 
21
   {         
 
22
     indexForChart++;
 
23
     var chartType = 0;
 
24
     var tempICount = $selectedServiceList.size();
 
25
     if(tempICount==0)  chartType=0;
 
26
     else if(tempICount==1) chartType=1;
 
27
     else chartType=2;
 
28
 
 
29
     var chartDisplayOptionList = document.getElementById("chartDisplayOption");
 
30
         var chartDisplayOptionValue = chartDisplayOptionList.options[ chartDisplayOptionList.selectedIndex ].value;
 
31
   
 
32
     if(indexForChart >= chartNamesToView[chartType].length) indexForChart=0;
 
33
     iframeForChart.location.href = "generateChart.action?currentChart="+chartNamesToView[chartType][indexForChart]+"&chartDisplayOption="+chartDisplayOptionValue;
 
34
   }
 
35
   
 
36
   function prevCharttoView()
 
37
   {      
 
38
     indexForChart--;
 
39
     var chartType = 0;
 
40
     var tempICount = $selectedServiceList.size();
 
41
     if(tempICount==0)  chartType=0;
 
42
     else if(tempICount==1) chartType=1;
 
43
     else chartType=2;
 
44
 
 
45
     var chartDisplayOptionList = document.getElementById("chartDisplayOption");
 
46
         var chartDisplayOptionValue = chartDisplayOptionList.options[ chartDisplayOptionList.selectedIndex ].value;
 
47
   
 
48
     if(indexForChart < 0) indexForChart=chartNamesToView[chartType].length-1;
 
49
     iframeForChart.location.href = "generateChart.action?currentChart="+chartNamesToView[chartType][indexForChart]+"&chartDisplayOption="+chartDisplayOptionValue;     
 
50
   }   
 
51
   
 
52
   function chartDisplayOptionChange(evt)
 
53
   {
 
54
         
 
55
     var chartType = 0;
 
56
     var tempICount = $selectedServiceList.size();
 
57
     if(tempICount==0)  chartType=0;
 
58
     else if(tempICount==1) chartType=1;
 
59
     else chartType=2;
 
60
 
 
61
     var chartDisplayOptionList = document.getElementById("chartDisplayOption");
 
62
         var chartDisplayOptionValue = chartDisplayOptionList.options[ chartDisplayOptionList.selectedIndex ].value;
 
63
 
 
64
         iframeForChart.location.href = "generateChart.action?currentChart="+chartNamesToView[chartType][indexForChart]+"&chartDisplayOption="+chartDisplayOptionValue;
 
65
 
 
66
         getSortedList(chartDisplayOptionValue);         
 
67
   }
 
68
 
 
69
 
 
70
function getSortedList(chartDisplayOptionValue)
 
71
{
 
72
        var url = "getSortedData.action?chartDisplayOption=" + chartDisplayOptionValue;
 
73
                
 
74
        var request = new Request();
 
75
        request.setResponseTypeXML( 'messages' );
 
76
        request.setCallbackSuccess( getSortedListReceived );
 
77
        request.send( url );            
 
78
}
 
79
 
 
80
function getSortedListReceived(xmlObject)
 
81
{       
 
82
        var messages = xmlObject.getElementsByTagName("message");
 
83
        document.getElementById("headingInfoId").innerHTML = "";
 
84
        document.getElementById("testId").value = "";
 
85
        
 
86
        for ( var i = 0; i < messages.length; i++ )
 
87
    {
 
88
        var hinfo = messages[ i ].firstChild.nodeValue;
 
89
        //document.getElementById("headingInfoId").innerHTML += hinfo;
 
90
        document.getElementById("testId").value += hinfo;
 
91
    }
 
92
    
 
93
    document.getElementById("headingInfoId").innerHTML = document.getElementById("testId").value;               
 
94
}
 
95
 
 
96
function exportToExcelFunction1( summaryOption )
 
97
{
 
98
        var chartDisplayOptionList = document.getElementById("chartDisplayOption");
 
99
        var chartDisplayOptionValue = chartDisplayOptionList.options[ chartDisplayOptionList.selectedIndex ].value;
 
100
        
 
101
        document.getElementById("exportExcelAnchor1").href="exportToExcel.action?viewSummary="+summaryOption+"&chartDisplayOption="+chartDisplayOptionValue;
 
102
 
 
103
}
 
104
 
 
105
</script>
 
106
 
 
107
<script>
 
108
 
 
109
 
 
110
// -----------------------------------------------------------------------------
 
111
// Author:   Torgeir Lorange Ostby, torgeilo@gmail.com
 
112
// Version:  $Id: request.js 2644 2007-01-03 13:24:56Z torgeilo $
 
113
// -----------------------------------------------------------------------------
 
114
 
 
115
/*
 
116
 * Usage:
 
117
 *
 
118
 * function processResponse( response ) { ... }                 // Text or XML
 
119
 * function requestFailed( httpStatusCode ) { ... }
 
120
 *
 
121
 * var request = new Request();
 
122
 * request.setResponseTypeXML( 'rootElement' );                 // Optional
 
123
 * request.sendAsPost( 'value=1&value=2' );                                     // Optional
 
124
 * request.setCallbackSuccess( processResponse );               // Optional
 
125
 * request.setCallbackError( requestFailed );                   // Optional
 
126
 * request.send( 'url.action?value=1' );
 
127
 */
 
128
 
 
129
function Request()
 
130
{
 
131
    var request;
 
132
    var responseType = 'TEXT';
 
133
    var requestMethod = 'GET';
 
134
    var requestParameters = null;
 
135
    var rootElementName;
 
136
    var callbackSuccess;
 
137
    var callbackError;
 
138
 
 
139
    this.setResponseTypeXML = function( rootElementName_ )
 
140
    {
 
141
        responseType = 'XML';
 
142
        rootElementName = rootElementName_;
 
143
    };
 
144
    
 
145
    this.sendAsPost = function( requestParameters_ )
 
146
        {
 
147
                requestMethod = 'POST';
 
148
                requestParameters = requestParameters_;
 
149
        };
 
150
 
 
151
    this.setCallbackSuccess = function( callbackSuccess_ )
 
152
    {
 
153
        callbackSuccess = callbackSuccess_;
 
154
    };
 
155
    
 
156
    this.setCallbackError = function( callbackError_ )
 
157
    {
 
158
        callbackError = callbackError_;
 
159
    };
 
160
 
 
161
    this.send = function( url )
 
162
    {
 
163
        request = newXMLHttpRequest();
 
164
 
 
165
        if ( !request )
 
166
        {
 
167
            window.alert( "Your browser doesn't support XMLHttpRequest" );
 
168
            return;
 
169
        }
 
170
 
 
171
                request.onreadystatechange = responseReceived;
 
172
        request.open( requestMethod, url, true );
 
173
        request.setRequestHeader( 'Content-Type', 'application/x-www-form-urlencoded' );                 
 
174
        request.send( requestParameters );
 
175
    };
 
176
        
 
177
    function newXMLHttpRequest()
 
178
    {
 
179
        if ( window.XMLHttpRequest )
 
180
        {
 
181
            try
 
182
            {
 
183
                return new XMLHttpRequest();
 
184
            }
 
185
            catch ( e )
 
186
            {
 
187
                return false;
 
188
            }
 
189
        }
 
190
        else if ( window.ActiveXObject )
 
191
        {
 
192
            try
 
193
            {
 
194
                return new ActiveXObject( 'Msxml2.XMLHTTP' );
 
195
            }
 
196
            catch ( e )
 
197
            {
 
198
                try
 
199
                {
 
200
                    return new ActiveXObject( 'Microsoft.XMLHTTP' );
 
201
                }
 
202
                catch ( ee )
 
203
                {
 
204
                    return false;
 
205
                }
 
206
            }
 
207
        }
 
208
        
 
209
        return false;
 
210
    }
 
211
 
 
212
    function responseReceived()
 
213
    {
 
214
        if ( request.readyState == 4 )
 
215
        {
 
216
                switch( request.status )
 
217
                {
 
218
                case 200:
 
219
                if ( callbackSuccess )
 
220
                {
 
221
                    if ( responseType == 'TEXT' )
 
222
                    {
 
223
                        callbackSuccess( request.responseText );
 
224
                    }
 
225
                    else
 
226
                    {
 
227
                        var xml = textToXML( request.responseText, rootElementName );
 
228
 
 
229
                        callbackSuccess( xml );
 
230
                    }
 
231
                }
 
232
                break;
 
233
            case 204:
 
234
                if ( callbackSuccess )
 
235
                {
 
236
                    callbackSuccess( null );
 
237
                }
 
238
                break;
 
239
            case 500:
 
240
                var message = 'Operation failed - internal server error';
 
241
                
 
242
                var serverMessage = request.responseText;
 
243
 
 
244
                if ( serverMessage )
 
245
                {
 
246
                    var maxLength = 512;
 
247
                    
 
248
                    if ( serverMessage.length > maxLength )
 
249
                    {
 
250
                        serverMessage = serverMessage.substring( 0, maxLength - 3 ) + '...';
 
251
                    }
 
252
                    
 
253
                    if ( serverMessage.length > 0 )
 
254
                    {
 
255
                        message += '\n\n' + serverMessage;
 
256
                    }
 
257
                }
 
258
 
 
259
                message += '\n\nThe error details are logged';
 
260
 
 
261
                window.alert( message );
 
262
 
 
263
                break;
 
264
            default:
 
265
                if ( callbackError )
 
266
                {
 
267
                    callbackError( request.status );
 
268
                }
 
269
            }
 
270
        }
 
271
    }
 
272
 
 
273
    function textToXML( text, rootElementName )
 
274
    {
 
275
        var docImpl = document.implementation;
 
276
        var parser, dom;
 
277
 
 
278
        // For standards compliant browsers
 
279
        if ( docImpl && docImpl.createLSParser )
 
280
        {
 
281
            parser = docImpl.createLSParser( docImpl.MODE_SYNCHRONOUS, null );
 
282
            var input = docImpl.createLSInput();
 
283
            input.stringData = text;
 
284
            return parser.parse( input ).documentElement;
 
285
        }
 
286
 
 
287
        // For IE
 
288
        else if ( window.ActiveXObject )
 
289
        {
 
290
            dom = new ActiveXObject( 'Microsoft.XMLDOM' );
 
291
            dom.async = "false";
 
292
            dom.loadXML( text );
 
293
            return dom.getElementsByTagName( rootElementName )[0];
 
294
        }
 
295
 
 
296
        // For Mozilla
 
297
        else if ( window.DOMParser )
 
298
        {
 
299
            parser = new DOMParser();
 
300
            dom = parser.parseFromString( text, 'application\/xml' );
 
301
            return dom.documentElement;
 
302
        }
 
303
 
 
304
        // No parsing abilities
 
305
        return null;
 
306
    }
 
307
}
 
308
 
 
309
 
 
310
 
 
311
</script>
 
312
 
 
313
</head>
 
314
<body >
 
315
    <div align="right">
 
316
        
 
317
        #if($selectedButton.equals("ViewSummary"))
 
318
                                    <a href="exportToExcel.action?viewSummary=yes" target="_blank">Export To Excel</a>
 
319
                                          <br><br>
 
320
                                    
 
321
                                #else
 
322
                                        <a id="exportExcelAnchor1" name="exportExcelAnchor1" href="#" onclick="javascript:exportToExcelFunction1('no')" target="_blank">Export To Excel</a>
 
323
                                        &nbsp;&nbsp;
 
324
                                        <select id="chartDisplayOption" name="chartDisplayOption" onchange="chartDisplayOptionChange(event)">
 
325
                                                <option value="none">Select Sort Type</option>
 
326
                                                <option value="ascend">Ascending</option>
 
327
                                                <option value="desend">Desending</option>
 
328
                                                <option value="alphabet">Alphabetical</option>
 
329
                                        </select>
 
330
                                        &nbsp;&nbsp;
 
331
                                        <input type="button" name="prevChartButton" id="prevChartButton" style="width: 40; height: 35; background-image: url('images/moveLeft.gif'); background-repeat: no-repeat; background-position: center; " onClick="prevCharttoView()" title="Previous">
 
332
                                <input type="button" name="nextChartButton" id="nextChartButton" style="width: 40; height: 35; background-image: url('images/moveRight.gif'); background-repeat: no-repeat; background-position: center;" onClick="nextCharttoView()" title="Next">                             
 
333
                                <br>
 
334
                                #end          
 
335
    </div> 
 
336
    <br>
 
337
    
 
338
    #if($riRadio.equals("indicatorsRadio1") && $categoryLB.equals( "period" )) 
 
339
    <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-style: dotted" bordercolor="#111111" width="100%">                
 
340
        <tr>
 
341
            <td class="TableHeadingCellStyles" style="border-style: dotted; border-width: 1" rowspan="2">Service Name</td>              
 
342
                #foreach($xaxisvalue in $xseriesList)
 
343
                    <td class="TableHeadingCellStyles" align="center" style="border-style: dotted; border-width: 1" colspan="3">$xaxisvalue</td>                                     
 
344
                #end
 
345
            </tr>
 
346
            <tr>        
 
347
                #foreach($xaxisvalue in $xseriesList)
 
348
                    <td class="TableHeadingCellStyles" align="center" style="border-style: dotted; border-width: 1" >Num</td>
 
349
                    <td class="TableHeadingCellStyles" align="center" style="border-style: dotted; border-width: 1" >Den</td>
 
350
                    <td class="TableHeadingCellStyles" align="center" style="border-style: dotted; border-width: 1" >Val</td>                                                        
 
351
                #end                    
 
352
                </tr>
 
353
                #set($count1 = 0)                               
 
354
        #foreach($onedataList in $dataList)
 
355
                #set($oneNumList = $numList.get($count1))
 
356
                #set($oneDenList = $denList.get($count1))                    
 
357
            <tr>
 
358
                <td class="TableHeadingCellStyles" style="border-style: dotted; border-width: 1">$yseriesList.get($count1)</td>
 
359
                        #set($count2 = 0)
 
360
                         #foreach($data in $onedataList)                                
 
361
                                 <td class="TableDataCellStyles" align="center" style="border-style: dotted; border-width: 1">$oneNumList.get($count2)</td>
 
362
                                 <td class="TableDataCellStyles" align="center" style="border-style: dotted; border-width: 1">$oneDenList.get($count2)</td>
 
363
                             <td class="TableDataCellStyles" align="center" style="border-style: dotted; border-width: 1">$data</td>
 
364
                             #set($count2 = $count2 + 1)                                     
 
365
                         #end
 
366
                         #set($count1 = $count1 + 1)
 
367
            </tr>    
 
368
        #end    
 
369
    </table>
 
370
    
 
371
    #else
 
372
    <textarea id="testId" rows="10" cols="70" style="display:none">&nbsp;</textarea>
 
373
    <div id="headingInfoId">
 
374
    <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-style: dotted" bordercolor="#111111" width="100%">                
 
375
        <tr>
 
376
            <td class="TableHeadingCellStyles" style="border-style: dotted; border-width: 1">Service Name</td>
 
377
                #foreach($xaxisvalue in $xseriesList)
 
378
                    <td class="TableHeadingCellStyles" align="center" style="border-style: dotted; border-width: 1">$xaxisvalue</td>                                 
 
379
                #end
 
380
        </tr>
 
381
                #set($count1 = 0)                               
 
382
        #foreach($onedataList in $dataList)                    
 
383
            <tr>
 
384
                <td class="TableHeadingCellStyles" style="border-style: dotted; border-width: 1">$yseriesList.get($count1)</td>
 
385
                         #foreach($data in $onedataList)
 
386
                             <td class="TableDataCellStyles" align="center" style="border-style: dotted; border-width: 1">$data</td>                                         
 
387
                         #end
 
388
                         #set($count1 = $count1 + 1)
 
389
            </tr>    
 
390
        #end    
 
391
    </table>
 
392
    </div>
 
393
    #end
 
394
    
 
395
    #if($riRadio.equals("indicatorsRadio"))     
 
396
 
 
397
<div align="right">
 
398
        #foreach($service in $selectedServiceList)
 
399
                <br>
 
400
                <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-style: dotted">
 
401
                        <tr class="TableHeadingCellStyles">
 
402
                        <td  style="border-style: dotted; border-width: 1">Service Name</td>                    
 
403
                                #set($surveys = $indicatorSurveyList.get($service))
 
404
                                #foreach($survey in $surveys)
 
405
                                <td class="TableHeadingCellStyles" align="center" style="border-style: dotted; border-width: 1">$survey.name</td>
 
406
                        #end
 
407
                </tr>                           
 
408
                        <tr class="TableHeadingCellStyles">
 
409
                        <td  style="border-style: dotted; border-width: 1">$service.name</td>                   
 
410
                                #foreach($survey in $surveys)
 
411
                                <td align="center" style="border-style: dotted; border-width: 1">$survey.value</td>
 
412
                        #end
 
413
                </tr>
 
414
            </table>                                                         
 
415
        #end        
 
416
</div>
 
417
    #end
 
418
    
 
419
    #if($selectedButton.equals("ViewSummary"))
 
420
             <br><br>
 
421
         #else
 
422
             <br>
 
423
             <div align="center">
 
424
                 <iframe name="iframeForChart" id="iframeForChart" src="generateChart.action?currentChart=Vertical3DBarChart" width="850px" height="550px" scrolling=auto frameborder="0"></iframe>
 
425
             </div>    
 
426
             <br>
 
427
         #end
 
428
 
 
429
         #if($riRadio.equals("indicatorsRadio"))
 
430
             <table border="0" cellpadding="0" cellspacing="0" style="border-collapse: collapse; border-style: dotted" bordercolor="#111111" width="100%">
 
431
                                                <tr>
 
432
                                                                <td class="TableHeadingCellStyles" width="30%" style="border-left-style:dotted; border-left-width:1; border-right-width:1; border-top-style:dotted; border-top-width:1; border-bottom-style:dotted; border-bottom-width:1"><font color="maroon">Indicator Names</font></td>
 
433
                                                                <td class="TableHeadingCellStyles" width="30%" colspan="2" style="border-left-style:dotted; border-left-width:1; border-right-width:1; border-top-style:dotted; border-top-width:1; border-bottom-style:dotted; border-bottom-width:1"><font color="maroon">Formula</font></td>
 
434
                                                                <td class="TableHeadingCellStyles" width="20%" style="border-left-style:dotted; border-left-width:1; border-right-width:1; border-top-style:dotted; border-top-width:1; border-bottom-style:dotted; border-bottom-width:1"><font color="maroon">Numerator DataElements</font></td>
 
435
                                                                <td class="TableHeadingCellStyles" width="20%" style="border-left-style:dotted; border-left-width:1; border-right-width:1; border-top-style:dotted; border-top-width:1; border-bottom-style:dotted; border-bottom-width:1"><font color="maroon">Denominator DataElements</font></td>                                    
 
436
                                                    </tr>
 
437
                                                    #set($count1 = 0)
 
438
                                                    #foreach($service in $selectedServiceList)
 
439
                                                        <tr>
 
440
                                                                        <td class="TableHeadingCellStyles" width="30%" style="border-left-style:dotted; border-left-width:1; border-right-width:1; border-top-style:dotted; border-top-width:1; border-bottom-style:dotted; border-bottom-width:1">$service.getName()</td>
 
441
                                                                        <td class="TableHeadingCellStyles" width="25%" align="center" style="border-left-style:dotted; border-left-width:1; border-right-width:0; border-top-style:dotted; border-top-width:1; border-bottom-style:dotted; border-bottom-width:1"><u>$service.getNumeratorDescription()</u><br>$service.getDenominatorDescription()</td>
 
442
                                                                        <td class="TableHeadingCellStyles" width="5%" align="left" style="border-left-style:dotted; border-left-width:0; border-right-width:1; border-top-style:dotted; border-top-width:1; border-bottom-style:dotted; border-bottom-width:1">&nbsp;X&nbsp;$service.getIndicatorType().getFactor()</td>
 
443
                                                                        <td class="TableHeadingCellStyles" width="20%" style="border-left-style:dotted; border-left-width:1; border-right-width:1; border-top-style:dotted; border-top-width:1; border-bottom-style:dotted; border-bottom-width:1">$numeratorDEList.get($count1)</td>
 
444
                                                                        <td class="TableHeadingCellStyles" width="20%" style="border-left-style:dotted; border-left-width:1; border-right-width:1; border-top-style:dotted; border-top-width:1; border-bottom-style:dotted; border-bottom-width:1">$denominatorDEList.get($count1)</td>
 
445
                                                                </tr>                                                                   
 
446
                                                        #set($count1 = $count1 + 1)
 
447
                                                    #end
 
448
                                                </table>   
 
449
         #end
 
450
 </body>
 
451
 </html>   
 
 
b'\\ No newline at end of file'