Skip to content
Snippets Groups Projects
Commit dc8a12d8 authored by pabois's avatar pabois
Browse files

wip exports

parent 33c58881
No related branches found
No related tags found
No related merge requests found
class Admin::Communication::Extranets::ContactsController < Admin::Communication::Extranets::ApplicationController
def index
@persons = current_university.people.ordered.page params[:persons_page]
@organizations = current_university.organizations.ordered.page params[:organizations_page]
@persons = current_university.people.ordered
@organizations = current_university.organizations.ordered
respond_to do |format|
format.html {
@persons = @persons.page params[:persons_page]
@organizations = @organizations.page params[:organizations_page]
}
format.xlsx {
@export = params['export']
filename = "#{@export}-#{Time.now.strftime("%Y%m%d%H%M%S")}.xlsx"
response.headers['Content-Disposition'] = "attachment; filename=#{filename}"
render @export
}
end
breadcrumb
add_breadcrumb Communication::Extranet.human_attribute_name(:feature_contacts)
end
......@@ -26,4 +40,4 @@ class Admin::Communication::Extranets::ContactsController < Admin::Communication
object_id = params[:objectId]
@object = object_type.constantize.find object_id
end
end
\ No newline at end of file
end
......@@ -2,7 +2,7 @@
<%= render 'admin/communication/extranets/sidebar' do %>
<% action = link_to t('export'),
admin_communication_extranet_contacts_path(extranet_id: @extranet.id, export: 'persons'),
admin_communication_extranet_contacts_path(extranet_id: @extranet.id, export: 'persons', format: :xlsx),
class: button_classes('ms-1') if can?(:show, University::Person) %>
<%= osuny_panel University::Person.model_name.human(count: 2), action: action do %>
<div class="table-responsive">
......@@ -40,7 +40,10 @@
</div>
<%= paginate @persons, theme: 'bootstrap-5', param_name: :persons_page %>
<% end %>
<%= osuny_panel University::Organization.model_name.human(count: 2) do %>
<% action = link_to t('export'),
admin_communication_extranet_contacts_path(extranet_id: @extranet.id, export: 'organizations', format: :xlsx),
class: button_classes('ms-1') if can?(:show, University::Person) %>
<%= osuny_panel University::Organization.model_name.human(count: 2), action: action do %>
<div class="table-responsive">
<table class="<%= table_classes%>">
<tbody>
......
@users ||= users
wb = xlsx_package.workbook
wb.add_worksheet(name: "index") do |sheet|
headers = User::xls_header_for(current_brand)
# for headers types are always :string (because those are labels)
sheet.add_row headers[:labels], types: Array.new(headers[:types].length) { |_| :string }
@users.each do |user|
sheet.add_row user.xls_basic_row, types: headers[:types]
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment