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

« back to all changes in this revision

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