1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-29 18:52:22 +01:00

export spaces availabilities

This commit is contained in:
Sylvain 2017-03-02 12:57:07 +01:00
parent d9b30fa2b0
commit 056060a88d
3 changed files with 35 additions and 0 deletions

View File

@ -63,4 +63,37 @@ wb.add_worksheet(name: t('export_availabilities.trainings')) do |sheet|
sheet.add_row data, :style => styles, :types => types
end
end
## Spaces slots
if Rails.application.secrets.fablab_without_spaces != 'false'
wb.add_worksheet(name: t('export_availabilities.spaces')) do |sheet|
## data table
# heading labels
columns = [t('export_availabilities.date'), t('export_availabilities.slot'), t('export_availabilities.space'),
t('export_availabilities.reservations'), t('export_availabilities.available_seats')]
sheet.add_row columns, :style => header
# data rows
@availabilities.where(available_type: 'space').order(:start_at).each do |a|
((a.end_at - a.start_at) / ApplicationHelper::SLOT_DURATION.minutes).to_i.times do |i|
start_at = a.start_at + (i * ApplicationHelper::SLOT_DURATION).minutes
end_at = a.start_at + (i * ApplicationHelper::SLOT_DURATION).minutes + ApplicationHelper::SLOT_DURATION.minutes
reservations = a.slots.where(start_at: start_at).count
data = [
start_at.to_date,
print_slot(start_at, end_at),
a.spaces.first.name,
reservations,
a.nb_total_places
]
styles = [date, nil, nil, nil, nil]
types = [:date, :string, :string, :integer, :integer]
sheet.add_row data, :style => styles, :types => types
end
end
end
end

View File

@ -196,6 +196,7 @@ en:
slot: "Slot"
machine: "Machine"
training: "Training"
space: "Space"
reservations: "Reservations"
available_seats: "Available seats"

View File

@ -196,6 +196,7 @@ fr:
slot: "Créneau"
machine: "Machine"
training: "Formation"
space: "Espace"
reservations: "Réservations"
available_seats: "Places disponibles"