Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions app/controllers/tools_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
class ToolsController < ApplicationController
def index; end

def combine_pdf
uploaded_pdf = params[:pdf_file]

if uploaded_pdf.present?
templated_pdf = Invoices::TemplatedPDF.new(uploaded_pdf.read).read

send_data templated_pdf,
filename: uploaded_pdf.original_filename,
type: 'application/pdf',
disposition: 'attachment'
else
redirect_to tools_path, alert: 'Bitte wähle eine PDF-Datei aus.'
end
end
end
3 changes: 2 additions & 1 deletion app/models/invoices/swiss_qr_bill_qr_code.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ def self.generate_img_data_for(invoice)
module_px_size: 10,
resize_exactly_to: false,
resize_gte_to: false,
size: 1024
size: 1024,
level: :m
)

swiss_cross = ChunkyPNG::Image.from_file('app/assets/images/swiss_cross.png')
Expand Down
12 changes: 12 additions & 0 deletions app/views/tools/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<%= define_page_title(t('.title')) %>

<h4><%= t('.apply_pdf_template.title') %></h4>

<%= form_with url: combine_pdf_tools_path, method: :post, multipart: true, local: true do |form| %>
<div class="form-group">
<%= form.label :pdf_file, t('.apply_pdf_template.select_pdf_file') %>
<%= form.file_field :pdf_file, accept: 'application/pdf', required: true, class: 'form-control' %>
</div>

<%= form.submit t('.apply_pdf_template.submit'), class: 'btn btn-primary', data: { disable_with: false } %>
<% end %>
2 changes: 2 additions & 0 deletions config/bottom_navigation.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
SimpleNavigation::Configuration.run do |navigation|
navigation.items do |bottom|
bottom.item :tools, t('application.navigation.tools'), tools_path, highlights_on: %r{\A/tools(/.*)?\z}

bottom.item :preferences, t('application.navigation.preferences'),
employee_hourly_rates_path(current_employee),
html: { class: 'sub_nav preferences' } do |sub_nav|
Expand Down
1 change: 1 addition & 0 deletions config/locales/application.de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ de:
customer_report: Kunde
customers_report: Kunden
other_preferences: Sonstiges
tools: Werkzeuge
8 changes: 8 additions & 0 deletions config/locales/views/tools.de.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
de:
tools:
index:
title: Werkzeuge
apply_pdf_template:
title: "PDF mit Briefpapier kombinieren"
select_pdf_file: "PDF-Datei auswählen:"
submit: "PDF kombinieren und herunterladen"
5 changes: 5 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@
resources :debtors_reports, only: [:new, :create]
resources :versions, only: [:index]
resources :settings, only: [:index, :update]
resources :tools, only: [:index] do
collection do
post :combine_pdf
end
end

mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development?
end