diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 2a8b55b..e4b1856 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -25,6 +25,12 @@ class HomeController < ApplicationController def show @dotation = Dotation.friendly.find(params[:id]) @company_sizes = CompanySize.all + respond_to do |format| + format.html + format.pdf do + render pdf: @dotation.safe_id # Excluding ".pdf" extension. + end + end end def emailfilter @@ -38,7 +44,15 @@ class HomeController < ApplicationController end def prepare_pdf - + filters = JSON.parse(cookies[:filter]).transform_keys(&:to_sym) + @company_sizes = CompanySize.all + @dotations = Dotation.search_with_filters(filters).public_dot + .point_desc.end_date_asc + respond_to do |format| + format.pdf do + render pdf: "zestawienie_dotacji_#{Time.now.strftime('%d%m%Y')}" + end + end end private diff --git a/app/views/experts/_expert_show.pdf.erb b/app/views/experts/_expert_show.pdf.erb new file mode 100644 index 0000000..ba66bfc --- /dev/null +++ b/app/views/experts/_expert_show.pdf.erb @@ -0,0 +1,15 @@ +
+
+ <%= image_tag expert.avatar, height: 150 %> +
+
+
+
+ <%= expert.name %> +
+
+
+
+ <%= expert.description %> +
+
diff --git a/app/views/home/_dotation_card.html.erb b/app/views/home/_dotation_card.html.erb index 8e2dde5..3e4234a 100644 --- a/app/views/home/_dotation_card.html.erb +++ b/app/views/home/_dotation_card.html.erb @@ -36,7 +36,7 @@ <% end %> - <% unless dotation.max_amount.blank? %> + <% unless dotation.max_percent.blank? %>
Poziom dofinansowania
diff --git a/app/views/home/_dotation_card.pdf.erb b/app/views/home/_dotation_card.pdf.erb new file mode 100644 index 0000000..040bd3b --- /dev/null +++ b/app/views/home/_dotation_card.pdf.erb @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + + + <% unless dotation.max_amount.blank? %> + + + + + <% end %> + <% unless dotation.max_percent.blank? %>, + + + + + <% end %> + <% unless dotation.expenses.blank? %> + + + + + <% end %> + +
<%= dotation.name %>
<%= dotation.formal_name %>
Składanie wnioskówod <%= dotation.start_date.strftime("%d-%m-%Y") %> do <%= dotation.end_date.strftime("%d-%m-%Y") %>
Lokalizacja: <%= dotation.localization %>
+ Wartość projektu + + do <%= change_ammount(dotation.max_amount) %> <%= dotation.max_amount_curr.name %> +
Poziom dofinansowaniado <%= dotation.max_percent %>% dotacji
Co można dofinansować? + <% max_expense = dotation.expenses.count %> + <% dotation.expenses.limit(5).each_with_index do |expense, index| %> + <%= expense.name %> + <% if index < max_expense - 1 && index < 4 %> + <%= ', ' -%> + <% elsif max_expense > 5 %> + <%= '...' -%> + <% end %> + <% end %> +
diff --git a/app/views/home/_filter_form.html.erb b/app/views/home/_filter_form.html.erb index e634728..61d92bd 100644 --- a/app/views/home/_filter_form.html.erb +++ b/app/views/home/_filter_form.html.erb @@ -2,11 +2,16 @@

Aktywne filtry

-
- -
+ <% unless params[:search].blank? %> +
+
+ <%= link_to raw(' Zapisz jako PDF'), "/zestawienie_dotacji/plik.pdf", class: 'btn btn-success btn-block' %> +
+
+
+ <% end %>

Wyszukiwana fraza:
diff --git a/app/views/home/_show.pdf.erb b/app/views/home/_show.pdf.erb new file mode 100644 index 0000000..23fd393 --- /dev/null +++ b/app/views/home/_show.pdf.erb @@ -0,0 +1,129 @@ +

+
+

<%= dotation.formal_name %>

+
+
+
+
+
+
+
+<% if !dotation.expert_id.blank? && !dotation.expert_info.blank? %> +
+
+ + + + + + + + + + +
Subiektywna opinia eksperta
+ <%= render '/experts/expert_show', expert: dotation.expert %> + <%= raw dotation.expert_info %>
+
+
+<% end %> +
+
+
+

Wielkość przedsiębiorstwa

+
+
+
+
+ <% @company_sizes.each do |company_size| %> + <% if dotation.company_sizes.include?(company_size) %> + <%= company_size.name %>   + <% end %> + <% end %> +
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Ogłoszenie aktualnego/najbliższego naboru + <%= dotation.announcement_date.strftime("%Y-%m-%d") unless dotation.announcement_date.blank? %>
+ Rozpoczęcie aktualnego/najbliższego naboru + <%= dotation.start_date.strftime("%Y-%m-%d") unless dotation.start_date.blank? %>
+ Zakończenie aktualnego/najbliższego naboru + <%= dotation.end_date.strftime("%Y-%m-%d") unless dotation.end_date.blank? %>
+ Co można dofinansować? + +
    + <% dotation.expenses.each do |expense| %> +
  • <%= expense.name %>
  • + <% end %> +
+
+ Miejsce realizacji projektu + <%= dotation.localization %>
+ Minimalna wartość projektu (wydatków) + <%= change_ammount(dotation.min_amount) %> <%= dotation.min_amount_curr.name %>
+ Maksymalna wartość projektu (wydatków) + <%= change_ammount(dotation.max_amount) %> <%= dotation.max_amount_curr.name %>
+
+
+
+
+
+

Szczegółowy opis dotacji

+
+
+
+
+ <%= raw dotation.full_descr %> +
+
+
+
+
+ <%= raw dotation.positioning_text %> +
+
+
+
+
+

Pomoc w opracowaniu wniosku – komu można zlecić opracowanie dokumentów do tego konkursu

+
+
+
+
+ <%= render '/partners/partner_show', partner: dotation.partner %> +
+
diff --git a/app/views/home/prepare_pdf.pdf.erb b/app/views/home/prepare_pdf.pdf.erb new file mode 100644 index 0000000..14b89fb --- /dev/null +++ b/app/views/home/prepare_pdf.pdf.erb @@ -0,0 +1,23 @@ + + + + + + +
+

Zestawienie dotacji

+ <% @dotations.each do |dotation| %> +
+ <%= render 'dotation_card', dotation: dotation %> +
+
+ <% end %> + <% @dotations.each do |dotation| %> +

+

<%= dotation.name %>

+ <%= render 'show', dotation: dotation %> +

+ <% end %> +
+ + diff --git a/app/views/home/show.html.erb b/app/views/home/show.html.erb index 61b1884..be46f0c 100644 --- a/app/views/home/show.html.erb +++ b/app/views/home/show.html.erb @@ -2,11 +2,15 @@
-
- <%= link_to 'Powrót do strony wyszukiwania', :back, class: 'btn btn-info' %> +
+
+ <%= link_to 'Powrót do strony wyszukiwania', '/', class: 'btn btn-info' %> +
+
+ <%= link_to raw(' Zapisz jako PDF'), "/dotacja/#{@dotation.safe_id}.pdf", class: 'btn btn-success float-right' %>
-
+
@@ -17,7 +21,8 @@
-
+
+

<%= @dotation.name %>

@@ -28,6 +33,7 @@
+
diff --git a/app/views/home/show.pdf.erb b/app/views/home/show.pdf.erb new file mode 100644 index 0000000..4c22600 --- /dev/null +++ b/app/views/home/show.pdf.erb @@ -0,0 +1,14 @@ + + + + + <%= wicked_pdf_javascript_include_tag "number_pages" %> + + + +
+

<%= @dotation.name %>

+ <%= render 'show', dotation: @dotation %> +
+ + diff --git a/app/views/partners/_partner_show.pdf.erb b/app/views/partners/_partner_show.pdf.erb new file mode 100644 index 0000000..7aa4fa4 --- /dev/null +++ b/app/views/partners/_partner_show.pdf.erb @@ -0,0 +1,19 @@ + + + + + + + +
+
+
+ <%= image_tag partner.logo, height: 40 %> +
+
+
+
+ <%= partner.name %> +
+
+
<%= raw partner.description %>
diff --git a/config/initializers/wicked_pdf.rb b/config/initializers/wicked_pdf.rb index beb8191..d663930 100644 --- a/config/initializers/wicked_pdf.rb +++ b/config/initializers/wicked_pdf.rb @@ -14,8 +14,8 @@ WickedPdf.config = { # exe_path: '/usr/local/bin/wkhtmltopdf', # or # exe_path: Gem.bin_path('wkhtmltopdf-binary', 'wkhtmltopdf') - exe_path: 'c:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe' - # exe_path: '/usr/bin/wkhtmltopdf' + # exe_path: 'c:\Program Files\wkhtmltopdf\bin\wkhtmltopdf.exe' + exe_path: '/usr/bin/wkhtmltopdf' # Layout file to be used for all PDFs # (but can be overridden in `render :pdf` calls) # layout: 'pdf.html', diff --git a/config/routes.rb b/config/routes.rb index 0956738..be2de96 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,6 +3,7 @@ Rails.application.routes.draw do get 'email_filter/unsubscribe' get 'kontakt' => 'home#contact' get 'dotacja/:id' => 'home#show' + get 'zestawienie_dotacji/plik' => 'home#prepare_pdf' get 'home/search' post 'home/search' post 'home/emailfilter'