nkuht-donate/app/views/admin/nkuht_donates/export.xlsx.axlsx

118 lines
4.1 KiB
Plaintext

# encoding: utf-8
wb = xlsx_package.workbook
wb.add_worksheet(name: '捐贈芳名錄') do |sheet|
row = [
t('nkuht_donate.donate_public'),
t('nkuht_donate.donation_payment_number'),
t('nkuht_donate.donation_serial_date'),
t('nkuht_donate.is_alumni'),
t('nkuht_donate.graduation_department'),
t('nkuht_donate.graduation_year'), t('nkuht_donate.name'),
t('nkuht_donate.donors_service_unit'), t('nkuht_donate.tel'),
t('nkuht_donate.email'),
t('nkuht_donate.donation_amount'),
t('nkuht_donate.donation_way'),
t('nkuht_donate.cheque_number'),
t('nkuht_donate.donation_unit'),
t('nkuht_donate.donation_use'),
t('nkuht_donate.donation_use_other'),
t('nkuht_donate.has_receipt'),
t('nkuht_donate.receipt_title'),
t('nkuht_donate_receipt_title.title3'),
t('nkuht_donate.receipt_number'),
t('nkuht_donate.receipt_address'),
t('nkuht_donate_receipt_address.add2'),
t('nkuht_donate.donation_payment_status'),
t('nkuht_donate.donation_write_off_status'),
t('nkuht_donate.note')
]
sheet.add_row row
@nkuht_donates.each do |nkuht_donate|
row2 = []
@donate_public = nkuht_donate.donate_public.blank? ? "#{t('nkuht_donate.donate_public_no_')} " : "#{t('nkuht_donate.donate_public_yes_')} "
row2 << @donate_public
row2 << "#{nkuht_donate.donation_payment_number} "
row2 << "#{nkuht_donate.donation_serial_time} "
@is_alumni = nkuht_donate.is_alumni.blank? ? "#{t('nkuht_donate.no_')} " : "#{t('nkuht_donate.yes_')} "
row2 << @is_alumni
@nkuht_donate_department = !nkuht_donate.nkuht_donate_department.blank? ? nkuht_donate.nkuht_donate_department.title : ""
row2 << @nkuht_donate_department
@graduation_year = !nkuht_donate.nkuht_donate_department.blank? ? "#{nkuht_donate.graduation_year} " : ""
row2 << @graduation_year
row2 << "#{nkuht_donate.name} "
row2 << "#{nkuht_donate.donors_service_unit} "
row2 << "#{nkuht_donate.tel} "
row2 << "#{nkuht_donate.email} "
row2 << "#{number_to_currency(nkuht_donate.donation_amount, unit: '', precision: 0)} "
@donation_way = !nkuht_donate.donation_way.blank? ? t("nkuht_donate_ways.ways#{nkuht_donate.donation_way}") : ""
row2 << @donation_way
@cheque_number = nkuht_donate.donation_way == '5' ? "#{nkuht_donate.cheque_number} " : ""
row2 << @cheque_number
@nkuht_donate_unit = !nkuht_donate.nkuht_donate_unit.blank? ? nkuht_donate.nkuht_donate_unit.title : ""
row2 << @nkuht_donate_unit
@nkuht_donate_use = !nkuht_donate.nkuht_donate_use.blank? ? nkuht_donate.nkuht_donate_use.title : ""
row2 << @nkuht_donate_use
if !nkuht_donate.nkuht_donate_use.blank?
if @nkuht_donate_use == '其他' || @nkuht_donate_use == 'Other'
@donation_use_other = nkuht_donate.donation_use_other
else
@donation_use_other = ""
end
else
@donation_use_other = ""
end
row2 << @donation_use_other
@has_receipt = !nkuht_donate.has_receipt.blank? ? "#{t('nkuht_donate.yes_')} " : "#{t('nkuht_donate.no_')} "
row2 << @has_receipt
@receipt_title = !nkuht_donate.has_receipt.blank? ? t("nkuht_donate_receipt_title.title#{nkuht_donate.receipt_title}") : ""
row2 << @receipt_title
@receipt_title_other = !nkuht_donate.has_receipt.blank? ? "#{nkuht_donate.receipt_title_other} " : ""
row2 << @receipt_title_other
@receipt_number = !nkuht_donate.has_receipt.blank? ? "#{nkuht_donate.receipt_number} " : ""
row2 << @receipt_number
@receipt_address = !nkuht_donate.has_receipt.blank? ? t("nkuht_donate_receipt_address.add#{nkuht_donate.receipt_address}") : ""
row2 << @receipt_address
@receipt_address_other = !nkuht_donate.has_receipt.blank? ? "#{nkuht_donate.receipt_address_other} " : ""
row2 << @receipt_address_other
@donation_payment_status = nkuht_donate.donation_payment_status ? t('nkuht_donate.yes_') : t('nkuht_donate.no_')
row2 << @donation_payment_status
@donation_write_off_status = nkuht_donate.donation_write_off_status ? t('nkuht_donate.yes_') : t('nkuht_donate.no_')
row2 << @donation_write_off_status
row2 << nkuht_donate.note
sheet.add_row row2
end
end