mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-02-01 04:32:16 +08:00
Merge pull request #2715 from urbanrotnik/ur-sci-4771-improve-report-layout
Improve report layout [SCI-4771]
This commit is contained in:
commit
950f65b90e
7 changed files with 101 additions and 38 deletions
Binary file not shown.
Before Width: | Height: | Size: 4.5 KiB After Width: | Height: | Size: 3.7 KiB |
|
@ -21,3 +21,33 @@ tr {
|
|||
thead {
|
||||
display: table-row-group;
|
||||
}
|
||||
|
||||
.print-header-body {
|
||||
.print-header {
|
||||
line-height: 50px;
|
||||
|
||||
.logo-img {
|
||||
display: inline-block;
|
||||
margin: 0 0 0 30px;
|
||||
|
||||
img {
|
||||
width: 100px;
|
||||
}
|
||||
}
|
||||
|
||||
.page-numbers {
|
||||
display: inline-block;
|
||||
float: right;
|
||||
margin: 0 30px 0 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.print-footer-body {
|
||||
.print-footer {
|
||||
line-height: 50px;
|
||||
|
||||
margin-right: 30px;
|
||||
text-align: right;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,7 +148,9 @@ class ReportsController < ApplicationController
|
|||
content = I18n.t('projects.reports.new.no_content_for_PDF_html') if content.blank?
|
||||
respond_to do |format|
|
||||
format.pdf do
|
||||
render pdf: 'report', header: { right: '[page] of [topage]' },
|
||||
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) }}},
|
||||
locals: { content: content },
|
||||
template: 'reports/report.pdf.erb',
|
||||
disable_javascript: true
|
||||
|
|
|
@ -235,50 +235,29 @@ module Reports::Docx::PrivateMethods
|
|||
|
||||
@docx.page_numbers true, align: :right
|
||||
|
||||
path = Rails.root.join('app', 'assets', 'images', 'logo.png')
|
||||
|
||||
@docx.img path.to_s do
|
||||
height 20
|
||||
width 100
|
||||
align :left
|
||||
end
|
||||
@docx.p do
|
||||
text I18n.t('projects.reports.new.generate_PDF.generated_on', timestamp: I18n.l(Time.zone.now, format: :full))
|
||||
br
|
||||
end
|
||||
|
||||
generate_html_styles
|
||||
end
|
||||
|
||||
def generate_html_styles
|
||||
@docx.style do
|
||||
id 'h1'
|
||||
name 'h1'
|
||||
bold true
|
||||
size 64
|
||||
end
|
||||
|
||||
@docx.style do
|
||||
id 'h2'
|
||||
name 'h2'
|
||||
bold true
|
||||
size 48
|
||||
end
|
||||
|
||||
@docx.style do
|
||||
id 'h3'
|
||||
name 'h3'
|
||||
bold true
|
||||
id 'Heading1'
|
||||
name 'heading 1'
|
||||
font 'Arial'
|
||||
size 36
|
||||
end
|
||||
|
||||
@docx.style do
|
||||
id 'h4'
|
||||
name 'h4'
|
||||
bottom 120
|
||||
bold true
|
||||
size 32
|
||||
end
|
||||
|
||||
@docx.style do
|
||||
id 'h5'
|
||||
name 'h5'
|
||||
bold true
|
||||
size 26
|
||||
end
|
||||
|
||||
@docx.style do
|
||||
id 'h6'
|
||||
name 'h6'
|
||||
bold true
|
||||
size 24
|
||||
end
|
||||
|
||||
@link_style = {
|
||||
|
|
17
app/views/reports/footer.pdf.erb
Normal file
17
app/views/reports/footer.pdf.erb
Normal file
|
@ -0,0 +1,17 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8' />
|
||||
<%= wicked_pdf_stylesheet_link_tag "application" %>
|
||||
<%= wicked_pdf_stylesheet_link_tag "reports_pdf" %>
|
||||
<%= bootstrap_cdn_link_tag %>
|
||||
<%= font_awesome_cdn_link_tag %>
|
||||
</head>
|
||||
<body class="print-footer-body" style="height: 50px">
|
||||
<div class="print-footer">
|
||||
<p>
|
||||
<%= t('projects.reports.new.generate_PDF.generated_on', timestamp: current_time) %>
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
33
app/views/reports/header.pdf.erb
Normal file
33
app/views/reports/header.pdf.erb
Normal file
|
@ -0,0 +1,33 @@
|
|||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset='utf-8' />
|
||||
<%= wicked_pdf_stylesheet_link_tag "application" %>
|
||||
<%= wicked_pdf_stylesheet_link_tag "reports_pdf" %>
|
||||
<%= bootstrap_cdn_link_tag %>
|
||||
<%= font_awesome_cdn_link_tag %>
|
||||
|
||||
<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>
|
||||
</head>
|
||||
<body class="print-header-body" onload="number_pages()" style="height: 50px;">
|
||||
<div class="print-header">
|
||||
<div class="logo-img">
|
||||
<%= image_tag wicked_pdf_asset_base64('logo.png') %>
|
||||
</div>
|
||||
<div class="page-numbers">
|
||||
Page <span class="page"></span> of <span class="topage"></span>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
|
@ -429,6 +429,8 @@ en:
|
|||
here: "here"
|
||||
no_columns: "You do not have File columns in selected Inventory. Add a File column to selected Inventory or select another Inventory containing File columns."
|
||||
nothing_selected: "Nothing selected"
|
||||
generate_PDF:
|
||||
generated_on: "Report generated by SciNote on: %{timestamp}"
|
||||
elements:
|
||||
modals:
|
||||
project_contents:
|
||||
|
|
Loading…
Reference in a new issue