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

« back to all changes in this revision

Viewing changes to dhis-2/dhis-web/dhis-web-reporting/src/main/webapp/dhis-web-reporting/javascript/report.js

  • 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
var tempUrl = null;
 
3
 
 
4
function runAndViewReport( reportId, reportUrl )
 
5
{
 
6
    var url = "reCreateTable.action?id=" + reportId + "&mode=report";
 
7
    
 
8
    if ( document.getElementById( "reportingPeriod" ) != null )
 
9
    {
 
10
        url += "&reportingPeriod=" + getListValue( "reportingPeriod" );
 
11
    }
 
12
    
 
13
    if ( document.getElementById( "parentOrganisationUnitId" ) != null )
 
14
    {
 
15
        url += "&parentOrganisationUnitId=" + getListValue( "parentOrganisationUnitId" );
 
16
    }
 
17
    
 
18
    if ( document.getElementById( "organisationUnitId" ) != null )
 
19
    {
 
20
        url += "&organisationUnitId=" + getListValue( "organisationUnitId" );
 
21
    }
 
22
    
 
23
        tempUrl = reportUrl;
 
24
    
 
25
    var request = new Request();
 
26
    request.setCallbackSuccess( runAndViewReportReceived );    
 
27
    request.send( url );
 
28
}
 
29
 
 
30
function runAndViewReportReceived( messageElement )
 
31
{   
 
32
    getReportStatus();
 
33
}
 
34
 
 
35
function getReportStatus()
 
36
{   
 
37
    var url = "getStatus.action";
 
38
    
 
39
    var request = new Request();
 
40
    request.setResponseTypeXML( "status" );
 
41
    request.setCallbackSuccess( reportStatusReceived );    
 
42
    request.send( url );
 
43
}
 
44
 
 
45
function reportStatusReceived( xmlObject )
 
46
{
 
47
    var statusMessage = getElementValue( xmlObject, "statusMessage" );
 
48
    var finished = getElementValue( xmlObject, "finished" );
 
49
    
 
50
    if ( finished == "true" )
 
51
    {
 
52
        setMessage( i18n_process_completed );
 
53
        
 
54
        viewReport( tempUrl );        
 
55
    }
 
56
    else if ( statusMessage == null )
 
57
    {
 
58
        setMessage( i18n_please_wait );
 
59
        
 
60
        waitAndGetReportStatus( 2000 );
 
61
    }
 
62
    else
 
63
    {
 
64
        setMessage( i18n_please_wait + ". " + statusMessage + "..."  );
 
65
        
 
66
        waitAndGetReportStatus( 2000 );
 
67
    }
 
68
}
 
69
 
 
70
function waitAndGetReportStatus( millis )
 
71
{
 
72
    setTimeout( "getReportStatus();", millis );
 
73
}
 
74
 
 
75
function viewReport( url )
 
76
{
 
77
        var dialog = window.open( url, "_blank", "directories=no, height=800, width=800, \
 
78
                location=no, menubar=no, status=no, toolbar=no, resizable=yes, scrollbars=yes" );
 
79
}
 
80
 
 
81
function addReport()
 
82
{
 
83
    selectAllById( "selectedReportTables" );
 
84
    
 
85
    document.getElementById( "reportForm" ).submit();
 
86
}
 
87
 
 
88
function removeReport( id )
 
89
{
 
90
        var dialog = window.confirm( i18n_confirm_remove_report );
 
91
        
 
92
        if ( dialog )
 
93
        {
 
94
                window.location.href = "removeReport.action?id=" + id;
 
95
        }
 
96
}
 
97
 
 
98
function addToDashboard( id )
 
99
{
 
100
    var dialog = window.confirm( i18n_confirm_add_to_dashboard );
 
101
    
 
102
    if ( dialog )
 
103
    {
 
104
        var request = new Request(); 
 
105
        request.send( "addReportToDashboard.action?id=" + id );
 
106
    }
 
107
}