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

« back to all changes in this revision

Viewing changes to local/in/dhis-web-ga/DataStatusPW.jsp

  • 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
<%@ page contentType="text/html ; charset=UTF-8"%>
 
3
 
 
4
<%@ page import="java.sql.*,java.util.*" %>
 
5
<%@ page session="true"%>
 
6
 
 
7
<!-- Bean Specification -->
 
8
<jsp:useBean id="DataStausAction" scope="session" class="org.hisp.gtool.action.DataStatusAction" />
 
9
<jsp:useBean id="GAUtilities" scope="session" class="org.hisp.gtool.utilities.GAUtilities" />
 
10
 
 
11
<% 
 
12
  String urlForSR = request.getParameter("Action");
 
13
  String partsOfUrl[] = urlForSR.split("@@");
 
14
                                  
 
15
  int i=0;
 
16
 
 
17
  int selOrgUnitLevel = 1;
 
18
  int maxOrgUnitLevel = 1;
 
19
  
 
20
  // these are the input parameters
 
21
  int selOrgUnitID = Integer.parseInt(partsOfUrl[0]);
 
22
  String startingDate = partsOfUrl[1];
 
23
  String endingDate = partsOfUrl[2];
 
24
  
 
25
 
 
26
  String selOrgUnitName = "";
 
27
 
 
28
  double dataStatusPer  = 0.0;
 
29
  double totDataStatusPer =0.0;
 
30
  double selOrgUnitDataStatus[];
 
31
 
 
32
// These 2 are hard coded, we need to change these
 
33
  int periodIDs[] = new int[200]; 
 
34
  String periodNames[] = new String[200];
 
35
 
 
36
  int totDataSetMem = 1;
 
37
  int periodCount = 0;
 
38
 
 
39
  int dataSetID = -1;
 
40
  String dataSetName = "";
 
41
 
 
42
  String monthNames[] = {"","Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
 
43
  
 
44
  // if we want to use this Program to another state we need to give the level names of that state
 
45
  String levelNames[] = {"","State","District","Taluk","PHC","Subcentre"};
 
46
 
 
47
  int dataStatus =0;
 
48
  String query = "";
 
49
  String cellColor = "";
 
50
  
 
51
//  String strPeriodIDs = "-1";
 
52
  
 
53
  Hashtable htForChildOUTree = DataStausAction.getChildOrgUnitTree(selOrgUnitID);
 
54
  if(htForChildOUTree == null) {out.println("<h3>No Children</h3>");return ; }
 
55
  
 
56
  List liForChildOUIDs = (ArrayList) htForChildOUTree.get("childOUIDsList");
 
57
  List liForChildOUNames = (ArrayList) htForChildOUTree.get("childOUNamesList");
 
58
  List liForChildOULevles = (ArrayList) htForChildOUTree.get("childOULevelsList");
 
59
  maxOrgUnitLevel = ((Integer) Collections.max(liForChildOULevles)).intValue();
 
60
        
 
61
 
 
62
  Hashtable htForDataSets = DataStausAction.getAllDataSetMemebers();
 
63
  if(htForDataSets == null) {out.println("<h3>No DataSets</h3>");return ; }
 
64
  Vector keysFoDataSets = new Vector(htForDataSets.keySet());
 
65
  Collections.sort(keysFoDataSets);
 
66
  Iterator keysFoDataSetsIter = keysFoDataSets.iterator();
 
67
  
 
68
  List liForSelOU = (ArrayList) DataStausAction.getSelectedOUDetails(selOrgUnitID);
 
69
  selOrgUnitName = (String) liForSelOU.get(0);
 
70
  selOrgUnitLevel = ((Integer) liForSelOU.get(1)).intValue();
 
71
    
 
72
  List liForPeriods = (ArrayList) DataStausAction.getPeriodDetails(startingDate, endingDate, 1);
 
73
  Iterator itForPeriods = liForPeriods.iterator();
 
74
%>
 
75
 
 
76
<html>
 
77
        <head>   
 
78
        <title>DataStatus</title>   
 
79
        </head>
 
80
        <body >
 
81
                <center>
 
82
                        <font face="arial" size="3"><b><%=selOrgUnitName%> Data Entry Status</b></font>
 
83
                </center>
 
84
                <div align="right">
 
85
                        <table width="30%">
 
86
                                <tr><td bgcolor="green">&nbsp;</td><td><font face="arial" size="1"> &nbsp;Completed (75+)</font></td></tr>
 
87
                                <tr><td bgcolor="yellow">&nbsp;</td><td><font face="arial" size="1"> &nbsp;Partially Completed (40 - 75)</font></td></tr>
 
88
                                <tr><td bgcolor="red">&nbsp;</td><td><font face="arial" size="1"> &nbsp;Not Completed (< 40)</font></td></tr>
 
89
                        </table>
 
90
                </div>
 
91
        
 
92
<%              
 
93
                int count1 = 0;
 
94
                //This is to get Datasets - id,name,totalnumber of dataelements that are members of dataset                             
 
95
                while(keysFoDataSetsIter.hasNext())
 
96
                {
 
97
                        String strDataSetID = (String)keysFoDataSetsIter.next();
 
98
                        dataSetID = Integer.parseInt(strDataSetID);
 
99
                        
 
100
                        ArrayList liForDataSets = (ArrayList) htForDataSets.get(strDataSetID);
 
101
                        dataSetName  = (String) liForDataSets.get(0);
 
102
                        int totNoOfDSMemebers = ((Integer) liForDataSets.get(1)).intValue();
 
103
                        
 
104
                        %>
 
105
                        <br><br>
 
106
                        <div align="left"><font face="arial" size="3"><b>DataSet : <%=dataSetName%></b></font></div>
 
107
                        <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" width="100%">               
 
108
                                <tr>
 
109
                                        <%
 
110
                                        for(count1=selOrgUnitLevel+1;count1<=maxOrgUnitLevel;count1++)
 
111
                                        { 
 
112
                                        %>
 
113
                                                <td><font face="arial" size="2"><b><%=levelNames[count1]%></b></font></td>
 
114
                                        <%
 
115
                                        }// for end
 
116
 
 
117
                                        // strPeriodIDs = "-1";
 
118
                                        periodCount = 0;
 
119
                                        itForPeriods = liForPeriods.iterator();
 
120
                                        while(itForPeriods.hasNext())
 
121
                                        {
 
122
                                                List templi = (ArrayList) itForPeriods.next();
 
123
                                                int periodID = ((Integer)templi.get(0)).intValue();
 
124
                                                String startDate = (String)templi.get(1);
 
125
                                                String monYearFormat = GAUtilities.getMonYearFormat(startDate);
 
126
                                                periodCount++;
 
127
                                                // strPeriodIDs += ","+periodID;
 
128
                                                %>
 
129
                                                <td><font face="arial" size="2"><b><%=monYearFormat%></b></font></td>           
 
130
                                                <%
 
131
                                        }// Period While loop end
 
132
                                        %>
 
133
                                        <td><font face="arial" size="2"><b>Overall %</b></font></td>
 
134
                                </tr>
 
135
                                <%
 
136
                                        Iterator itForChildOUIDs = liForChildOUIDs.iterator();
 
137
                                        Iterator itForChildOUNames = liForChildOUNames.iterator();
 
138
                                        Iterator itForChildOULevels = liForChildOULevles.iterator();
 
139
                
 
140
                                        while(itForChildOUIDs.hasNext())
 
141
                                        {
 
142
                                                %>
 
143
                                                <tr>
 
144
                                                <%
 
145
                                                int childOUID = ((Integer)itForChildOUIDs.next()).intValue();
 
146
                                                String childOUName = (String) itForChildOUNames.next();
 
147
                                                int childOULevel = ((Integer) itForChildOULevels.next()).intValue();
 
148
                                                
 
149
                                                String tempOUName ="";
 
150
                                                for(count1=selOrgUnitLevel+1;count1<=maxOrgUnitLevel;count1++)
 
151
                                                { 
 
152
                                                        if(count1==childOULevel) tempOUName = childOUName;
 
153
                                                        else tempOUName = "";
 
154
                                                        %>
 
155
                                                        <td><font face="arial" size="2"><%=tempOUName%></font></td>
 
156
                                                        <%
 
157
                                                } // for end
 
158
                                                totDataStatusPer = 0.0;                                                                         
 
159
                                                String cellData = "";
 
160
                                                
 
161
                                                itForPeriods = liForPeriods.iterator();
 
162
                                                while(itForPeriods.hasNext())
 
163
                                                {
 
164
                                                        List templi = (ArrayList) itForPeriods.next();
 
165
                                                        int periodID = ((Integer)templi.get(0)).intValue();
 
166
                                                        String startDate = (String)templi.get(1);
 
167
                                                        
 
168
                                                        dataStatus = DataStausAction.getStatusByPeriod(childOUID,dataSetID,periodID);
 
169
                                                        dataStatusPer =  ((double)dataStatus / (double)totNoOfDSMemebers) * 100.0;                                      
 
170
                                                        totDataStatusPer += dataStatusPer;
 
171
                                                        
 
172
                                                        if(dataStatusPer >= 75)  cellColor = "green";
 
173
                                                        else if (dataStatusPer >=40 && dataStatusPer < 75) cellColor = "yellow";
 
174
                                                        else cellColor = "red";
 
175
 
 
176
                                                        if(childOULevel!=maxOrgUnitLevel) { cellColor = "white"; cellData="";}
 
177
                                                        else cellData = ""+( Math.round(dataStatusPer*Math.pow(10,1)) / Math.pow(10,1));
 
178
                                                        %>
 
179
                                                        <td bgcolor="<%=cellColor%>" align="center"><font face="Arial" size="1" color="#FF6633"><%=cellData%></font></td>
 
180
                                                        <%
 
181
                                                }// Period While loop end
 
182
                                                
 
183
                                                if(totDataStatusPer/periodCount >= 75)  cellColor = "green";
 
184
                                                else if (totDataStatusPer/periodCount >=40 && totDataStatusPer/periodCount < 75) cellColor = "yellow";
 
185
                                                else cellColor = "red";
 
186
 
 
187
                                                if(childOULevel!=maxOrgUnitLevel) { cellColor = "white"; cellData="";}
 
188
                                                else cellData = ""+( Math.round( (totDataStatusPer/periodCount) *Math.pow(10,1)) / Math.pow(10,1));                                                                                     
 
189
                                                %>
 
190
                                                        <td bgcolor="<%=cellColor%>" align="center"><font face="Arial" size="1" color="#FF6633"><%=cellData%></font></td>                               
 
191
                                                </tr>
 
192
                                                <%                                                              
 
193
                                        }// ChildOrgUnit While loop end         
 
194
                                %>
 
195
                        </table>                        
 
196
                        <%
 
197
                }// DataSet While loop end                                                      
 
198
%>      
 
199
 
 
200
</table>