mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-08 07:21:03 +08:00
Add template partials to reports [SCI-5571]
This commit is contained in:
parent
6393337bc7
commit
ad8e404bca
4 changed files with 465 additions and 5 deletions
|
|
@ -146,14 +146,20 @@ class ReportsController < ApplicationController
|
|||
def generate
|
||||
content = params[:data]
|
||||
content = I18n.t('projects.reports.new.no_content_for_PDF_html') if content.blank?
|
||||
|
||||
template = {}
|
||||
|
||||
respond_to do |format|
|
||||
format.pdf do
|
||||
render pdf: 'report', header: { html: { template: 'reports/header.pdf.erb' }},
|
||||
footer: { html: { template: 'reports/footer.pdf.erb',
|
||||
locals: { current_time: I18n.l(Time.zone.now, format: :full) }}},
|
||||
render pdf: 'report', header: { html: { template: 'reports/templates/template_1/_header.html.erb', locals: {template: template} }},
|
||||
footer: { html: { template: 'reports/templates/template_1/_footer.html.erb', locals: {template: template} }},
|
||||
locals: { content: content },
|
||||
template: 'reports/report.pdf.erb',
|
||||
disable_javascript: true
|
||||
cover: render_to_string(partial: 'reports/templates/template_1/report.html.erb',
|
||||
locals: {
|
||||
template: template
|
||||
}),
|
||||
disable_javascript: true,
|
||||
template: 'reports/report.pdf.erb'
|
||||
end
|
||||
format.docx do
|
||||
@user = current_user
|
||||
|
|
|
|||
93
app/views/reports/templates/template_1/_footer.html.erb
Normal file
93
app/views/reports/templates/template_1/_footer.html.erb
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8' />
|
||||
<script>
|
||||
function number_pages() {
|
||||
var vars={};
|
||||
var x=document.location.search.substring(1).split('&');
|
||||
for(var i in x) {var z=x[i].split('=',2);vars[z[0]] = decodeURIComponent(z[1]);}
|
||||
var x=['frompage','topage','page','webpage','section','subsection','subsubsection'];
|
||||
for(var i in x) {
|
||||
var y = document.getElementsByClassName(x[i]);
|
||||
for(var j=0; j<y.length; ++j) y[j].textContent = vars[x[i]];
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<style>
|
||||
body {
|
||||
height: 95px;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
height: 80px;
|
||||
table-layout: fixed;
|
||||
width: 100%
|
||||
}
|
||||
|
||||
table td {
|
||||
border: 2px solid black;
|
||||
font-size: 12px;
|
||||
padding: .25em;
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
table td.pagination {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.info-row {
|
||||
height: 15px;
|
||||
}
|
||||
|
||||
.info-row td {
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body onload="number_pages()">
|
||||
<table>
|
||||
<tr>
|
||||
<td colspan=3>
|
||||
<div class="cell-label">
|
||||
<b>ANALYST(S)</b>
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template[:analysts] %>
|
||||
</div>
|
||||
</td>
|
||||
<td colspan=2>
|
||||
<div class="cell-label">
|
||||
<b>ANALYST EMPLOYEE NO.</b>
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template[:analyst_number] %>
|
||||
</div>
|
||||
</td>
|
||||
<td colspan=3>
|
||||
<div class="cell-label">
|
||||
<b>CHECKED BY:</b>
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template[:checked_by] %>
|
||||
</div>
|
||||
</td>
|
||||
<td colspan=2 class="pagination">
|
||||
PAGE <span class="page"></span> OF <span class="topage"></span>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="info-row">
|
||||
<td colspan="10">Single-Sided</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
61
app/views/reports/templates/template_1/_header.html.erb
Normal file
61
app/views/reports/templates/template_1/_header.html.erb
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8' />
|
||||
|
||||
<style>
|
||||
body {
|
||||
height: 95px;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
height: 80px;
|
||||
table-layout: fixed;
|
||||
width: 100%
|
||||
}
|
||||
|
||||
table td {
|
||||
border: 2px solid black;
|
||||
font-size: 12px;
|
||||
padding: .25em;
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
table td.title {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
white-space: nowrap;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
<tr>
|
||||
<td class="title " class="topage">
|
||||
GENERAL CONTINUATION SHEET
|
||||
</td>
|
||||
<td>
|
||||
<div class="cell-label">
|
||||
<b>PRODUCT</b>
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template[:product] %>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<div class="cell-label">
|
||||
<b>SAMPLE NUMBER</b>
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template[:sample_number] %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
300
app/views/reports/templates/template_1/_report.html.erb
Normal file
300
app/views/reports/templates/template_1/_report.html.erb
Normal file
|
|
@ -0,0 +1,300 @@
|
|||
|
||||
<div class="report-template-index">
|
||||
<style type="text/css" scoped>
|
||||
.report-template-index .template-table {
|
||||
height: 297mm;
|
||||
width: 100%;
|
||||
font-size: 12px;
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0;
|
||||
table-layout: fixed;
|
||||
}
|
||||
|
||||
.report-template-index .template-checkbox {
|
||||
border: 1px solid black;
|
||||
display: inline-block;
|
||||
height: 16px;
|
||||
margin-bottom: -3px;
|
||||
margin-right: .25em;
|
||||
position: relative;
|
||||
width: 16px;
|
||||
}
|
||||
|
||||
.report-template-index .template-checkbox.selected {
|
||||
background: black;
|
||||
}
|
||||
|
||||
.report-template-index .template-table > tbody > tr > td {
|
||||
border: 2px solid black;
|
||||
padding: .25em;
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.report-template-index .cell-label {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.report-template-index .template-table > tbody > tr > td.title {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.report-template-index tr.fixed-height {
|
||||
height: 5em;
|
||||
}
|
||||
|
||||
.report-template-index .seals-table {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.report-template-index .seals-table td {
|
||||
font-size: 12px;
|
||||
line-height: 16px;
|
||||
vertical-align: top;
|
||||
}
|
||||
|
||||
.report-template-index .net-contents-table {
|
||||
font-size: 12px;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.report-template-index .template-table > tbody > tr > td.pagination-cell {
|
||||
font-size: 14px;
|
||||
font-weight: bold;
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
|
||||
</style>
|
||||
<table class="template-table">
|
||||
<tr class="fixed-height">
|
||||
<td colspan=4 class="title">
|
||||
ANALYST WORKSHEET
|
||||
</td>
|
||||
<td colspan=7>
|
||||
<div class="cell-label">
|
||||
1. PRODUCT
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template[:product] %>
|
||||
</div>
|
||||
</td>
|
||||
<td colspan=5>
|
||||
<div class="cell-label">
|
||||
2. SAMPLE NUMBER
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template[:sample_number] %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fixed-height">
|
||||
<td colspan=4>
|
||||
<table class="seals-table">
|
||||
<tr>
|
||||
<td>
|
||||
<div class="cell-label">
|
||||
3. SEALS
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<span class="template-checkbox <%= 'selected' if template.dig(:seals, :intact) %>"></span>
|
||||
INTACT
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="template-checkbox <%= 'selected' if template.dig(:seals, :none) %>"></span>
|
||||
NONE
|
||||
</td>
|
||||
<td>
|
||||
<span class="template-checkbox <%= 'selected' if template.dig(:seals, :broken) %>"></span>
|
||||
BROKEN
|
||||
</td>
|
||||
</tr>
|
||||
<tr></tr>
|
||||
</table>
|
||||
</td>
|
||||
<td colspan=3>
|
||||
<div class="cell-label">
|
||||
4. DATE RECEIVED
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template[:date_recieved] %>
|
||||
</div>
|
||||
</td>
|
||||
<td colspan=4>
|
||||
<div class="cell-label">
|
||||
5.RECEIVED FROM
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template[:recieved_from] %>
|
||||
</div>
|
||||
</td>
|
||||
<td colspan=5>
|
||||
<div class="cell-label">
|
||||
6. DISTRICT OR LABORATORY
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template[:district_laboratory] %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=16>
|
||||
<div class="cell-label">
|
||||
7. DESCRIPTION OF SAMPLE
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template[:sample_description] %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fixed-height">
|
||||
<td colspan=2>
|
||||
<div class="cell-label">
|
||||
8. NET CONTENTS
|
||||
</div>
|
||||
</td>
|
||||
<td colspan=7>
|
||||
<table class="net-contents-table">
|
||||
<tr>
|
||||
<td>
|
||||
<span class="template-checkbox <%= 'selected' if template.dig(:net_contents, :not_applicable) %>"></span>
|
||||
NOT APPLICABLE
|
||||
</td>
|
||||
<td>DECLARE/UNIT <b><%= template.dig(:net_contents, :declare_unit) %></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="template-checkbox <%= 'selected' if template.dig(:net_contents, :not_determined) %>"></span>
|
||||
NOT DETERMINED
|
||||
</td>
|
||||
<td>AMOUNT FOUND <b><%= template.dig(:net_contents, :amount_found) %></b></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><b><%= template.dig(:net_contents, :units_examined) %></b> UNITS EXAMINED</td>
|
||||
<td>% of DECLARED <b><%= template.dig(:net_contents, :declared_percent) %></b></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
<td colspan=2>
|
||||
<div class="cell-label">
|
||||
9. LABELING
|
||||
</div>
|
||||
</td>
|
||||
<td colspan=5>
|
||||
<table class="net-contents-table">
|
||||
<tr>
|
||||
<td>
|
||||
<b><%= template.dig(:labeling, :originals_submitted) %></b> ORIGINAL(S) SUBMITTED
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<b><%= template.dig(:labeling, :copies_submitted) %></b> COPIES SUBMITTED
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<span class="template-checkbox <%= 'selected' if template.dig(:labeling, :none) %>"></span>
|
||||
NONE
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan=16>
|
||||
<div class="cell-label">
|
||||
10. SUMMARY OF ANALYSIS
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template[:analysis_summary] %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fixed-height">
|
||||
<td colspan=16>
|
||||
<div class="cell-label">
|
||||
11. RESERVE SAMPLE
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template[:reserve_sample] %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fixed-height">
|
||||
<td colspan=8 rowspan=2>
|
||||
<div class="cell-label">
|
||||
12. a. ANALYST SIGNATURE (Broke Seal <span class="template-checkbox <%= 'selected' if template.dig(:analyst_signature, :broke) %>"></span>)
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template.dig(:analyst_signature, :a) %>
|
||||
</div>
|
||||
</td>
|
||||
<td colspan=3 rowspan=2>
|
||||
<div class="cell-label">
|
||||
13. WORKSHEET CHECK
|
||||
</div>
|
||||
</td>
|
||||
<td colspan=5>
|
||||
<div class="cell-label">
|
||||
a. BY
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template.dig(:worksheet_check, :by) %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fixed-height">
|
||||
<td colspan=5>
|
||||
<div class="cell-label">
|
||||
b. DATE
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template.dig(:worksheet_check, :date) %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fixed-height">
|
||||
<td colspan=8>
|
||||
<div class="cell-label">
|
||||
b.
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template.dig(:analyst_signature, :b) %>
|
||||
</div>
|
||||
</td>
|
||||
<td colspan=8>
|
||||
<div class="cell-label">
|
||||
13. DATE REPORTED
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template[:date_reported] %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr class="fixed-height">
|
||||
<td colspan=8>
|
||||
<div class="cell-label">
|
||||
c.
|
||||
</div>
|
||||
<div class="cell-value">
|
||||
<%= template.dig(:analyst_signature, :c) %>
|
||||
</div>
|
||||
</td>
|
||||
<td colspan=8 class="pagination-cell">
|
||||
PAGE 1 OF
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
Loading…
Add table
Reference in a new issue