source: extensions/net.sf.basedb.reggie/branches/ticket-422/resources/export_monthly_oplist.jsp @ 1757

Last change on this file since 1757 was 1757, checked in by Nicklas Nordborg, 9 years ago

Catching up on trunk revisions 1734 to 1756.

File size: 7.9 KB
Line 
1<%@ page
2  pageEncoding="UTF-8"
3  session="false"
4  import="net.sf.basedb.core.Application"
5  import="net.sf.basedb.core.User"
6  import="net.sf.basedb.core.DbControl"
7  import="net.sf.basedb.core.SessionControl"
8  import="net.sf.basedb.clients.web.Base"
9  import="net.sf.basedb.clients.web.util.HTML"
10  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
11  import="net.sf.basedb.util.Values"
12  import="net.sf.basedb.util.formatter.DateFormatter"
13  import="java.util.Calendar"
14  import="java.util.Locale"
15  import="java.text.SimpleDateFormat"
16%>
17<%@ taglib prefix="base" uri="/WEB-INF/base.tld" %>
18<%@ taglib prefix="p" uri="/WEB-INF/path.tld" %>
19<%
20final SessionControl sc = Base.getExistingSessionControl(request, true);
21final String ID = sc.getId();
22final float scale = Base.getScale(sc);
23final String home = ExtensionsControl.getHomeUrl("net.sf.basedb.reggie");
24DbControl dc = null;
25try
26{
27  dc = sc.newDbControl();
28  final User user = User.getById(dc, sc.getLoggedInUserId());
29%>
30<base:page type="default" >
31<base:head scripts="ajax.js" styles="path.css">
32  <link rel="stylesheet" type="text/css" href="css/reggie.css">
33  <script language="JavaScript" src="reggie.js" type="text/javascript" charset="UTF-8"></script>
34
35<script language="JavaScript">
36
37function goExport(preview)
38{
39  var frm = document.forms['reggie'];
40  var url = 'Export.servlet?ID=<%=ID%>&cmd=ExportMonthlyOpList';
41  url += '&time=' + frm.time.value;
42  url += '&exportSubtype='+(frm.exportSubtype.checked ? 1 : 0);
43  url += '&exportPatientId='+(frm.exportPatientId.checked ? 1 : 0);
44  if (preview)
45  {
46    var previewTitle = document.getElementById('previewTitle');
47    var previewList = document.getElementById('previewList');
48   
49    Main.hide('previewWrapper');
50    previewTitle.innerHTML = 'Working...';
51    previewList.innerHTML = '';
52   
53    url += '&preview=1';
54    var request = Ajax.getXmlHttpRequest();
55   
56    try
57    {
58      showLoadingAnimation('Working...');
59      request.open("GET", url, false); 
60      request.send(null);
61    }
62    finally
63    {
64      hideLoadingAnimation();
65    }
66
67    if (request.status != 200)
68    {
69      Main.openPopup('', 'ErrorWindow', 800, 600);
70      Main.getWindow('ErrorWindow').document.write(request.responseText);
71    }
72    else
73    {
74      var allLines = request.responseText.split('\n');
75      var numCases = allLines.length - 2; // First line is a header line
76     
77      var html = '<tr><th>'+allLines[0].replace(/\t/g, '</th><th>')+'</th></tr>';
78      // Check last column for the 'Consent' value. All should be 'YES' for the export to be ok.
79      var numNoConsent = 0;
80      var numMissingConsent = 0;
81      for (var i = 1 ; i <= numCases; i++)
82      {
83        var line = allLines[i];
84        var cols = line.split(/\t/);
85        var consent = cols[cols.length-1];
86        var rowClass = '';
87        if (consent != 'YES')
88        {
89          rowClass = 'consent-warning';
90          if (consent == 'MISSING')
91          {
92            numMissingConsent++;
93          }
94          else
95          {
96            numNoConsent++;
97          }
98        }
99        html += '<tr class="'+rowClass+'"><td>'+cols.join('</td><td>')+'</td></tr>';
100      }
101     
102      if (numMissingConsent > 0 || numNoConsent > 0)
103      {
104        var previewWarning = document.getElementById('previewWarning');
105        var warning = '<img src="images/warning.png" alt="!">';
106        warning += ' Found ' + (numNoConsent+numMissingConsent) + ' case(s) with denied or missing consent!';
107        previewWarning.innerHTML = warning;
108      }
109     
110      previewTitle.innerHTML = 'Operation dates - ' + frm.time[frm.time.selectedIndex].text + ' (' + numCases + ')';
111      previewList.innerHTML = '<table>'+html+'</table>';
112      Main.show('previewWrapper');
113    }
114  }
115  else
116  {
117    window.location = url;   
118  }
119 
120}
121
122</script>
123<style>
124
125.fullyear
126{
127  font-weight: bold;
128}
129
130#previewWrapper
131{
132  position: absolute;
133  top: 11em;
134  bottom: 1em;
135  left: 20px;
136  width: 950px;
137  overflow: visible;
138}
139
140#previewList
141{
142  position: absolute;
143  top: 1.5em;
144  bottom: 0px;
145  width: 950px;
146  overflow: auto;
147  white-space: pre;
148  font-family: monospace;
149  border: 1px dotted #A0A0A0;
150  border-radius: 4px;
151  background: #E8E8E8;
152  padding: 0.25em;
153}
154
155#previewTitle
156{
157  font-weight: bold;
158}
159
160#previewList th
161{
162  border-bottom: 1px dotted #A0A0A0;
163}
164
165#previewList td, #previewList th
166{
167  text-align: left;
168  padding-right: 2em;
169  vertical-align: bottom;
170}
171
172.consent-warning
173{
174  color: #A00000;
175  background-color: #F8F8E8;
176}
177
178.consent-warning td:last-child
179{
180  background-image: url('images/warning_small.png');
181  background-position: 95% 50%;
182  background-repeat: no-repeat;
183}
184
185</style>
186</base:head>
187<base:body onload="init()">
188
189  <p:path><p:pathelement 
190    title="Reggie" href="<%="index.jsp?ID="+ID%>" 
191    /><p:pathelement title="Export monthly operation list" 
192    /></p:path>
193
194  <div class="content">
195  <%
196  if (sc.getActiveProjectId() == 0)
197  {
198    %>
199    <div class="messagecontainer note" style="width: 950px; margin-left: 20px; margin-bottom: 20px; margin-right: 0px; font-weight: bold; color: #cc0000;">
200      No project has been selected. You may proceed with the export but
201      it may no include all items.
202    </div>
203    <%
204  }
205  %>
206  <form name="reggie" onsubmit="return false;">
207 
208  <!-- 1. Select month -->
209  <table border="0" cellspacing="0" cellpadding="0" class="stepform">
210  <tr>
211    <td rowspan="3" class="stepno">1</td>
212    <td class="steptitle">Select month or year</td>
213  </tr>
214  <tr>
215    <td class="stepfields">
216      <table border="0" cellspacing="0" cellpadding="0" width="100%">
217      <tr>
218        <td class="prompt">Month/Year</td>
219        <td class="input">
220          <select name="time">
221          <%
222          Calendar month = Calendar.getInstance(Locale.ENGLISH);
223          DateFormatter monthly = new DateFormatter(new SimpleDateFormat("yyyy MMMM", Locale.ENGLISH));
224          DateFormatter yearly = new DateFormatter(new SimpleDateFormat("yyyy", Locale.ENGLISH));
225          int index = 0;
226          while (month.get(Calendar.YEAR) > 2009)
227          {
228            %>
229            <option value="<%=month.getTimeInMillis()%>" <%=index==1 ? "selected" : "" %>><%=monthly.format(month.getTime())%>
230            <%
231            if (month.get(Calendar.MONTH) == 0)
232            {
233              %>
234              <option class="fullyear" value="-<%=month.getTimeInMillis()%>"><%=yearly.format(month.getTime()) %> (all)
235              <%
236            }
237            index++;
238            month.add(Calendar.MONTH, -1);
239          }
240          %>
241          </select>
242        </td>
243        <td class="help"><span id="time.message" class="message" style="display: none;"></span></td>
244      </tr>
245     
246      <tr style="vertical-align: top;">
247        <td class="prompt">Optional columns</td>
248        <td class="input">
249          <input type="checkbox" name="exportSubtype" value="1" id="exportSubtype">
250          <label for="exportSubtype">Specimen/NoSpecimen</label><br>
251          <input type="checkbox" name="exportPatientId" value="1" id="exportPatientId">
252          <label for="exportPatientId">Patient ID</label>
253        </td>
254        <td class="help"><span id="subtype.message" class="message" style="display: none;"></span></td>
255      </tr>
256      </table>
257    </td>
258  </tr>
259  </table>
260
261  <div class="messagecontainer error" id="errorMessage" style="display: none; width: 950px; margin-left: 20px; margin-bottom: 0px;"></div>
262
263  <div id="done" class="success" style="display: none; width: 950px; margin-left: 20px; margin-top: 20px;"></div>
264
265  <table style="margin-left: 20px; margin-top: 10px;" class="navigation">
266  <tr>
267    <td><base:button id="gopreview" title="Preview" image="<%=home+"/images/export.png"%>" onclick="goExport(true)"/></td>
268    <td><base:button id="goexport" title="Download" image="<%=home+"/images/download.png"%>" onclick="goExport(false)"/></td>
269  </tr>
270  </table>
271  </form>
272 
273  <div class="loading" id="loading" style="display: none;"><table><tr><td><img src="images/loading.gif"></td><td id="loading.msg">Please wait...</td></tr></table></div>
274 
275  <div id="previewWrapper" style="display: none;">
276    <div>
277      <span id="previewTitle">Preview</span>
278      <span id="previewWarning"></span>
279    </div>
280    <div id="previewList"></div>
281  </div>
282 
283  </div>
284 
285</base:body>
286</base:page>
287<%
288}
289finally
290{
291  if (dc != null) dc.close();
292}
293%>
Note: See TracBrowser for help on using the repository browser.