venue_management/app/views/admin/venue_managements/export.xlsx.axlsx

80 lines
2.4 KiB
Plaintext

# encoding: utf-8
wb = xlsx_package.workbook
wb.add_worksheet(name: (@venue_management.title.to_s[0..27]+'...')) do |sheet|
row = [t(:category)]
row << t('venue_management.manager')
row << t('venue_management.contractor')
row << t('venue_management.venue_management_start_date')
row << t('venue_management.venue_management_end_date')
row << t('venue_management.title')
row << t('venue_management_signup.address')
row << t('venue_management.land_number')
row << t('venue_management.area')
row << t('venue_management.land_zoning')
row << t('venue_management.content')
row << t('venue_management.act_place')
row << t("link") # Seperate with ';'
@site_in_use_locales.each do |locale|
row << t("link") + " " + t("url_alt") + " - " + t(locale)
end
row << t("file_") # Seperate with ';' Example: http://www.example.com/images/example.png; http://www.example.com/images/example2.png"
@site_in_use_locales.each do |locale|
row << t("file_") + " " + t("description") + " - " + t(locale) #"Seperate with ';' with respective to the links in the link columns. Example : Great view; Nice potrait"
end
@site_in_use_locales.each do |locale|
row << t("file_") + " " + t("alternative") + " - " + t(locale) #"Seperate with ';' with respective to the links in the link columns. Example : example1; example2"
end
@venue_management.venue_management_signup_fields.asc(:_id).each do |rf|
if rf.can_muti_lang_input?
@site_in_use_locales.each do |l|
row << rf.title + " (#{t(l.to_s)})"
end
else
row << rf.title
end
end
sheet.add_row row
@venue_management.venue_management_signups.each do |signup|
row2 = []
row2 << "#{signup.created_at} "
row2 << "#{signup[:name]} "
row2 << "#{signup.unit} "
row2 << "#{signup[:tel]} "
row2 << "#{signup[:phone]} "
row2 << "#{signup[:fax]} "
row2 << "#{signup.address} "
row2 << "#{signup[:email]} "
row2 << "#{signup.note} "
@venue_management.venue_management_signup_fields.asc(:_id).each do |rf|
if rf.can_muti_lang_input?
@site_in_use_locales.each do |l|
row2 << nl2br(show_attribute_value(@venue_management.get_attribute_value(rf,signup.id).get_value_by_locale(l))) rescue ' '
end
else
row2 << nl2br(show_attribute_value(@venue_management.get_attribute_value(rf,signup.id).get_value_by_locale(I18n.locale))) rescue ' '
end
end
sheet.add_row row2
end
end