source: extensions/net.sf.basedb.reggie/trunk/resources/personal/export_monthly_oplist.jsp @ 2217

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

References #540: Make sure Reggie works with BASE 3.3

Remove calls to non-existing methods.

File size: 7.4 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=0';
43  url += '&exportPatientId=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      var previewWarning = document.getElementById('previewWarning');
103      if (numMissingConsent > 0 || numNoConsent > 0)
104      {
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      else
110      {
111        previewWarning.innerHTML = '';
112      }
113     
114      previewTitle.innerHTML = 'Operation dates - ' + frm.time[frm.time.selectedIndex].text + ' (' + numCases + ')';
115      previewList.innerHTML = '<table>'+html+'</table>';
116      Main.show('previewWrapper');
117    }
118  }
119  else
120  {
121    window.location = url;   
122  }
123 
124}
125
126</script>
127<style>
128
129.fullyear
130{
131  font-weight: bold;
132}
133
134#previewWrapper
135{
136  position: absolute;
137  top: 11em;
138  bottom: 1em;
139  left: 20px;
140  width: 950px;
141  overflow: visible;
142}
143
144#previewList
145{
146  position: absolute;
147  top: 1.5em;
148  bottom: 0px;
149  width: 950px;
150  overflow: auto;
151  white-space: pre;
152  font-family: monospace;
153  border: 1px dotted #A0A0A0;
154  border-radius: 4px;
155  background: #E8E8E8;
156  padding: 0.25em;
157}
158
159#previewTitle
160{
161  font-weight: bold;
162}
163
164#previewList th
165{
166  border-bottom: 1px dotted #A0A0A0;
167}
168
169#previewList td, #previewList th
170{
171  text-align: left;
172  padding-right: 2em;
173  vertical-align: bottom;
174}
175
176.consent-warning
177{
178  color: #A00000;
179  background-color: #F8F8E8;
180}
181
182.consent-warning td:last-child
183{
184  background-image: url('../images/warning_small.png');
185  background-position: 95% 50%;
186  background-repeat: no-repeat;
187}
188
189</style>
190</base:head>
191<base:body>
192
193  <p:path><p:pathelement 
194    title="Reggie" href="<%="../index.jsp?ID="+ID%>" 
195    /><p:pathelement title="Export monthly operation list" 
196    /></p:path>
197
198  <div class="content">
199  <%
200  if (sc.getActiveProjectId() == 0)
201  {
202    %>
203    <div class="messagecontainer note" style="width: 950px; margin-left: 20px; margin-bottom: 20px; margin-right: 0px; font-weight: bold; color: #cc0000;">
204      No project has been selected. You may proceed with the export but
205      it may no include all items.
206    </div>
207    <%
208  }
209  %>
210  <form name="reggie" onsubmit="return false;">
211 
212  <!-- 1. Select month -->
213  <table border="0" cellspacing="0" cellpadding="0" class="stepform">
214  <tr>
215    <td rowspan="3" class="stepno">1</td>
216    <td class="steptitle">Select month or year</td>
217  </tr>
218  <tr>
219    <td class="stepfields">
220      <table border="0" cellspacing="0" cellpadding="0" width="100%">
221      <tr>
222        <td class="prompt">Month/Year</td>
223        <td class="input">
224          <select name="time">
225          <%
226          Calendar month = Calendar.getInstance(Locale.ENGLISH);
227          DateFormatter monthly = new DateFormatter(new SimpleDateFormat("yyyy MMMM", Locale.ENGLISH));
228          DateFormatter yearly = new DateFormatter(new SimpleDateFormat("yyyy", Locale.ENGLISH));
229          int index = 0;
230          while (month.get(Calendar.YEAR) > 2009)
231          {
232            %>
233            <option value="<%=month.getTimeInMillis()%>" <%=index==1 ? "selected" : "" %>><%=monthly.format(month.getTime())%>
234            <%
235            if (month.get(Calendar.MONTH) == 0)
236            {
237              %>
238              <option class="fullyear" value="-<%=month.getTimeInMillis()%>"><%=yearly.format(month.getTime()) %> (all)
239              <%
240            }
241            index++;
242            month.add(Calendar.MONTH, -1);
243          }
244          %>
245          </select>
246        </td>
247        <td class="help"><span id="time.message" class="message" style="display: none;"></span></td>
248      </tr>
249     
250      </table>
251    </td>
252  </tr>
253  </table>
254
255  <div class="messagecontainer error" id="errorMessage" style="display: none; width: 950px; margin-left: 20px; margin-bottom: 0px;"></div>
256
257  <div id="done" class="success" style="display: none; width: 950px; margin-left: 20px; margin-top: 20px;"></div>
258
259  <table style="margin-left: 20px; margin-top: 10px;" class="navigation">
260  <tr>
261    <td><base:button id="gopreview" title="Preview" image="<%=home+"/images/export.png"%>" onclick="goExport(true)"/></td>
262    <td><base:button id="goexport" title="Download" image="<%=home+"/images/download.png"%>" onclick="goExport(false)"/></td>
263  </tr>
264  </table>
265  </form>
266 
267  <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>
268 
269  <div id="previewWrapper" style="display: none;">
270    <div>
271      <span id="previewTitle">Preview</span>
272      <span id="previewWarning"></span>
273    </div>
274    <div id="previewList"></div>
275  </div>
276 
277  </div>
278 
279</base:body>
280</base:page>
281<%
282}
283finally
284{
285  if (dc != null) dc.close();
286}
287%>
Note: See TracBrowser for help on using the repository browser.