1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-04 15:24:23 +01:00
fab-manager/app/views/exports/users_reservations.xlsx.axlsx

33 lines
1.5 KiB
Plaintext
Raw Normal View History

2016-07-12 13:00:56 +02:00
wb = xlsx_package.workbook
header = wb.styles.add_style b: true, :bg_color => Stylesheet.primary.upcase.gsub('#', 'FF'), :fg_color => 'FFFFFFFF'
2016-07-12 13:00:56 +02:00
date = wb.styles.add_style :format_code => Rails.application.secrets.excel_date_format
wb.add_worksheet(name: t('export_reservations.reservations')) do |sheet|
## data table
# heading labels
columns = [t('export_reservations.customer_id'), t('export_reservations.customer'), t('export_reservations.email'),
t('export_reservations.reservation_date'), t('export_reservations.reservation_type'), t('export_reservations.reservation_object'),
t('export_reservations.slots_number_hours_tickets'), t('export_reservations.payment_method')]
sheet.add_row columns, style: header
2016-07-12 13:00:56 +02:00
# data rows
@reservations.each do |resrv|
data = [
2020-07-21 17:25:19 +02:00
resrv.user&.id,
resrv.user&.profile&.full_name || t('export_reservations.deleted_user'),
resrv.user&.email,
2016-07-12 13:00:56 +02:00
resrv.created_at.to_date,
resrv.reservable_type,
(resrv.reservable.nil? ? '' : resrv.reservable.name),
(resrv.reservable_type == 'Event') ? resrv.total_booked_seats: resrv.slots.count,
(resrv.invoice&.paid_by_card?) ? t('export_reservations.online_payment') : t('export_reservations.local_payment')
2016-07-12 13:00:56 +02:00
]
styles = [nil, nil, nil, date, nil, nil, nil, nil]
types = [:integer, :string, :string, :date, :string, :string, :integer, :string]
sheet.add_row data, style: styles, types: types
2016-07-12 13:00:56 +02:00
end
end