sacarmonar15
9/22/2017 - 5:19 PM

Exhibitors profile report

#Reporte de perfil de expositores
#incluye campos custom
event  = Event.find(1894)
custom = CustomField.list("EventReservationProfileFields", event.id, event.created_by, {default: false})
CSV.open("/home/ubuntu/usuga_stand_report.csv", "wb") do |csv|
  header = ["name", "website", "description"]
  header += custom.map{|id, data| data[:name]}
  csv << header
  event.stands.where(status: [2,3]).each do |stand|
    reservation = stand.current_reservation
    next if reservation.blank?
    fields = [ reservation.display_name, reservation.website, reservation.profile_description ]
    fields += custom.map{|id, data| (reservation.profile_data.present? ? reservation.profile_data[id.to_s].to_s : "") }
    csv << fields
  end
end