source: extensions/net.sf.basedb.reggie/trunk/resources/histology_protocol2.jsp @ 1849

Last change on this file since 1849 was 1849, checked in by Nicklas Nordborg, 7 years ago

References #462: Implement a print function that can print complete pages

Implemented a javascript function that opens a popup window and copies the content of a specified html tag (given by the id) to the popup window.

openPrintWindow(ID, printElementId, pageTitle, pageOrientation, printNote)

The change also includes printing changes made in separate branch for #425 in [1723].

File size: 7.3 KB
Line 
1<%@ page
2  pageEncoding="UTF-8"
3  session="false"
4  import="net.sf.basedb.core.User"
5  import="net.sf.basedb.core.DbControl"
6  import="net.sf.basedb.core.SessionControl"
7  import="net.sf.basedb.core.Application"
8  import="net.sf.basedb.core.Sample"
9  import="net.sf.basedb.core.BioMaterialList"
10  import="net.sf.basedb.core.BioWell"
11  import="net.sf.basedb.core.BioPlate"
12  import="net.sf.basedb.core.AnyToAny"
13  import="net.sf.basedb.core.ItemQuery"
14  import="net.sf.basedb.core.PermissionDeniedException"
15  import="net.sf.basedb.core.query.Hql"
16  import="net.sf.basedb.core.query.Orders"
17  import="net.sf.basedb.util.Values"
18  import="net.sf.basedb.util.extensions.Extension"
19  import="net.sf.basedb.clients.web.Base" 
20  import="net.sf.basedb.clients.web.util.HTML"
21  import="net.sf.basedb.clients.web.extensions.ExtensionsControl"
22  import="java.util.List"
23  import="java.util.ArrayList"
24%>
25<%!
26String getSampleForLocation(List<Sample> samples, int offset, int position)
27{
28  String name = "<i>empty</i>";
29  int index = offset + position - 1;
30  if (index < samples.size())
31  {
32    Sample s = samples.get(index);
33    name = "<b>" + HTML.encodeTags(s.getName()) + "</b>";
34    try
35    {
36      BioWell well = s.getBioWell();
37      if (well != null)
38      {
39        BioPlate plate = well.getPlate();
40        name += " [" + plate.getName() + " " + well.getCoordinate() + "]";
41      }
42    }
43    catch (PermissionDeniedException ex)
44    {}
45  }
46  return name;
47}
48%>
49<%
50final SessionControl sc = Base.getExistingSessionControl(request, true);
51final String ID = sc.getId();
52final float scale = Base.getScale(sc);
53final String home = ExtensionsControl.getHomeUrl("net.sf.basedb.reggie");
54final String root = request.getContextPath();
55final int BLOCKS_PER_PAGE = 3;
56final int SAMPLES_PER_BLOCK = 5;
57DbControl dc = null;
58try
59{
60  dc = sc.newDbControl();
61  final Extension reggie = ExtensionsControl.get(dc).getExtension("net.sf.basedb.reggie");
62  final User user = User.getById(dc, sc.getLoggedInUserId());
63  final int listId = Values.getInt(request.getParameter("workList"));
64  BioMaterialList workList = BioMaterialList.getById(dc, listId);
65 
66  ItemQuery<Sample> query = (ItemQuery<Sample>)workList.getMemberBioMaterials();
67 
68  query.join(Hql.leftJoin(null, "bioWell", "bw", null, true));
69  query.join(Hql.leftJoin("bw", "bioPlate", "bp", null, true));
70 
71  // Sort by bioplate position
72  query.order(Orders.asc(Hql.expression("coalesce(bp.name, 'zzzz')", null)));
73  query.order(Orders.asc(Hql.property("bw", "row")));
74  query.order(Orders.asc(Hql.property("bw", "column")));
75  query.order(Orders.asc(Hql.property("id")));
76
77  List<Sample> histology = query.list(dc);
78 
79  int totalBlocks = 1 + (histology.size()-1) / SAMPLES_PER_BLOCK;
80  int totalPages = 1 + (totalBlocks-1) / BLOCKS_PER_PAGE;
81%>
82<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
83<html>
84<head>
85  <title>Lab tracking protocol for FFPE/HE</title>
86  <link rel="SHORTCUT ICON" href="<%=home%>/images/microscope.png">
87  <link rel="stylesheet" type="text/css" href="<%=home %>/css/printable.css">
88  <script language="JavaScript" src="<%=root %>/include/scripts/main.js" type="text/javascript" charset="UTF-8"></script>
89  <script language="JavaScript" src="<%=root %>/include/scripts/ajax.js" type="text/javascript" charset="UTF-8"></script>
90
91  <style>
92  table.protocolheader
93  {
94    width: 100%;
95  }
96 
97  table.protocolheader > tbody > tr
98  {
99    height: 2em;
100  }
101
102  table.protocolheader > tbody > tr > th, table.protocolheader > tbody > tr > td b
103  {
104    text-align: left;
105    font-size: 1.25em;
106  }
107 
108  div.paraffinblock
109  {
110    margin-top: 1em;
111    margin-bottom: 2em;
112    height: 6.5cm;
113  }
114 
115  div.paraffinblock .title
116  {
117    font-size: 1.2em;
118    margin-bottom: 0.5em;
119  }
120 
121  div.paraffinblock > table
122  {
123    width: 100%;
124    height: 5.5cm;
125    border-collapse: collapse;
126    border: 1px solid #000000;
127  }
128 
129  div.paraffinblock > table > tbody > tr > td
130  {
131    vertical-align: top;
132    border: 1px solid #000000;
133    padding: 2px;
134    width: 50%;
135  }
136 
137  div.entryform
138  {
139    margin-left: 0.5em;
140    margin-right: 1em;
141    border: 1px solid #000000;
142    height: 2em;
143  }
144  </style>
145 
146  <script>
147  function downloadHEGlassLabels()
148  {
149    var numLabelsPerBlock = prompt('Number of labels per block?', 3);
150    if (numLabelsPerBlock == null) return;
151   
152    if (!parseInt(numLabelsPerBlock, 10))
153    {
154      alert('"' + numLabelsPerBlock + '" is not a valid number');
155      return;
156    }
157   
158    var url = 'Histology.servlet?ID=<%=ID%>&cmd=DownloadHEGlassLabels';
159    url += '&workListId=<%=listId%>';
160    url += '&numSlides=' + parseInt(numLabelsPerBlock, 10);
161   
162    location.href = url;
163  }
164 
165  </script>
166</head>
167<body>
168  <div class="paper">
169  <div class="noprint fullwidth" style="border-bottom: 1px dashed #A0A0A0; padding-left: 1em; padding-bottom: 1em;">
170    <span class="button" onclick="window.print()">
171      <img src="images/print.png">Print&hellip;
172    </span>
173   
174    <span class="button" onclick="downloadHEGlassLabels()" style="margin-left: 2em;">
175      <img src="images/download.png">Download HE glass labels&hellip;
176    </span>
177  </div>
178  <%
179  int pageNo = 0;
180  for (int blockNo = 0; blockNo < totalBlocks; ++blockNo)
181  {
182    AnyToAny link = AnyToAny.getByName(dc, workList, "block."+(blockNo+1));
183    BioPlate block = (BioPlate)link.getTo();
184    int offset = SAMPLES_PER_BLOCK * blockNo;
185    if (blockNo % BLOCKS_PER_PAGE == 0)
186    {
187      pageNo++;
188      %>
189      <div class="<%=blockNo > 0 ? "pagebreak" : ""%>"></div>
190      <h1>Lab tracking protocol for FFPE/HE v.1.0</h1>
191      <table class="protocolheader">
192      <tr>
193        <td colspan="2">Reggie <%=reggie.getAbout().getVersion() %>; Page <%=pageNo %> of <%=totalPages %></td>
194      </tr>
195      <tr>
196        <td colspan="2"><b>Work list:</b> <%=HTML.encodeTags(workList.getName()) %> (<%=workList.getSize() %> samples)</td>
197      </tr>
198      <tr>
199        <th style="width: 50%;">Start date:</th>
200        <th style="width: 50%;">Operator:</th>
201      </tr>
202      </table>
203      <%
204    }
205    %>
206    <div class="paraffinblock">
207      <div class="title">
208        <table style="width: 100%;">
209        <tr>
210          <td style="width: 50%;">
211            <table style="width: 100%;">
212            <tr>
213              <td style="width: 25%; white-space: nowrap;"><b>Block:</b> <%=block.getName() %></td>
214              <td style="width: 75%;"><div class="entryform">&nbsp;</div></td>
215            </tr>
216            </table>
217          </td>
218         
219          <td style="width: 50%;">
220            <table style="width: 100%;">
221            <tr>
222              <td style="width: 25%; white-space: nowrap;"><b>Slides: </b><%=block.getName().replace("PB", "HE") %>.#</td>
223              <td style="width: 75%;"><div class="entryform" style="margin-right: 0em;">&nbsp;</div></td>
224            </tr>
225            </table>
226          </td>
227        </tr>
228        </table>
229      </div>
230      <table>
231        <tr>
232        <td>
233          <b>3</b>: <%=getSampleForLocation(histology, offset, 3) %>
234        </td>
235        <td>
236          <b>6</b>: <i>not used</i>
237        </td>
238        </tr>
239       
240        <tr>
241        <td>
242          <b>2</b>: <%=getSampleForLocation(histology, offset, 2) %>
243        </td>
244        <td>
245          <b>5</b>: <%=getSampleForLocation(histology, offset, 5) %>
246        </td>
247        </tr>
248       
249        <tr>
250        <td>
251          <b>1</b>: <%=getSampleForLocation(histology, offset, 1) %>
252        </td>
253        <td>
254          <b>4</b>: <%=getSampleForLocation(histology, offset, 4) %>
255        </td>
256        </tr>
257      </table>
258    </div>
259    <%
260  }
261  %>
262  </div>
263</body>
264</html>
265<%
266}
267finally
268{
269  if (dc != null) dc.close();
270}
271%>
Note: See TracBrowser for help on using the repository browser.