293 lines
10 KiB
Plaintext
293 lines
10 KiB
Plaintext
# encoding: utf-8
|
|
|
|
wb = xlsx_package.workbook
|
|
|
|
wb.add_worksheet(name: "RecruitmentModule") do |sheet|
|
|
|
|
heading = sheet.styles.add_style(:b => true, :locked => true)
|
|
example = sheet.styles.add_style(:i => true)
|
|
row = []
|
|
row1 = []
|
|
row2 = []
|
|
|
|
row << t("category")
|
|
row1 << "select"
|
|
tags_str = ""
|
|
categories = @module_app.categories.asc(:created_at)
|
|
categories.each_with_index do |cat,i|
|
|
tags_str = tags_str + "#{i}" + " -> " + cat.title + ", "
|
|
end
|
|
if categories.count > 0
|
|
tags_str = tags_str + " Example : 0"
|
|
else
|
|
tags_str = "Leave this field blank"
|
|
end
|
|
row2 << tags_str
|
|
|
|
row << t("tags")
|
|
row1 << "select"
|
|
tags_str2 = ""
|
|
tags = @module_app.tags.asc(:created_at)
|
|
tags.each_with_index do |tag,i|
|
|
tags_str2 = tags_str2 + "#{i}" + " -> " + tag.name + ", "
|
|
end
|
|
if tags.count > 0
|
|
tags_str2 = tags_str2 + " Example : 0,1,2"
|
|
else
|
|
tags_str2 = "Leave this field blank"
|
|
end
|
|
row2 << tags_str2
|
|
|
|
row << t("recruitment.recruitment_date")
|
|
row1 << "datetime"
|
|
row2 << "Format: YYYY/MM/DD HH:mm, Example: 2015/12/10 15:20"
|
|
|
|
row << t("recruitment.start_date")
|
|
row1 << "datetime"
|
|
row2 << "Format: YYYY/MM/DD HH:mm, Example: 2015/12/10 15:30"
|
|
|
|
row << t("recruitment.end_date")
|
|
row1 << "datetime"
|
|
row2 << "Format: YYYY/MM/DD HH:mm, Example: 2015/12/12 17:30"
|
|
|
|
row << t("top")
|
|
row1 << "boolean"
|
|
row2 << "0 for false, 1 for true"
|
|
|
|
row << t("hot")
|
|
row1 << "boolean"
|
|
row2 << "0 for false, 1 for true"
|
|
|
|
row << t("hide")
|
|
row1 << "boolean"
|
|
row2 << "0 for false, 1 for true "
|
|
|
|
row << t("image")
|
|
row1 << "url"
|
|
row2 << "http://www.example.com/images/example.png"
|
|
|
|
row << t("image") + " " + t("description") + " - " + t("en")
|
|
row1 << "textfield"
|
|
row2 << ""
|
|
row << t("image") + " " + t("description") + " - " + t("zh_tw")
|
|
row1 << "textfield"
|
|
row2 << ""
|
|
|
|
row << t("title") + " - " + t("en")
|
|
row1 << "textfield"
|
|
row2 << ""
|
|
row << t("title") + " - " + t("zh_tw")
|
|
row1 << "textfield"
|
|
row2 << ""
|
|
|
|
row1 << "textfield"
|
|
row2 << ""
|
|
row1 << "textfield"
|
|
row2 << ""
|
|
|
|
row1 << "textfield"
|
|
row2 << ""
|
|
row1 << "textfield"
|
|
row2 << ""
|
|
|
|
row << t("subtitle") + " - " + t("en")
|
|
row1 << "textarea"
|
|
row2 << ""
|
|
row << t("subtitle") + " - " + t("zh_tw")
|
|
row1 << "textarea"
|
|
row2 << ""
|
|
|
|
row << t("content") + " - " + t("en")
|
|
row1 << "editor"
|
|
row2 << ""
|
|
row << t("content") + " - " + t("zh_tw")
|
|
row1 << "editor"
|
|
row2 << ""
|
|
|
|
row << t("recruitment.notes") + " - " + t("en")
|
|
row1 << "editor"
|
|
row2 << ""
|
|
row << t("recruitment.notes") + " - " + t("zh_tw")
|
|
row1 << "editor"
|
|
row2 << ""
|
|
|
|
row << t("recruitment.education_requirement") + " - " + t("en")
|
|
row1 << "editor"
|
|
row2 << ""
|
|
row << t("recruitment.education_requirement") + " - " + t("zh_tw")
|
|
row1 << "editor"
|
|
row2 << ""
|
|
|
|
row << t("recruitment.experience_requirement") + " - " + t("en")
|
|
row1 << "editor"
|
|
row2 << ""
|
|
row << t("recruitment.experience_requirement") + " - " + t("zh_tw")
|
|
row1 << "editor"
|
|
row2 << ""
|
|
|
|
row << t("recruitment.skills_requirement") + " - " + t("en")
|
|
row1 << "editor"
|
|
row2 << ""
|
|
row << t("recruitment.skills_requirement") + " - " + t("zh_tw")
|
|
row1 << "editor"
|
|
row2 << ""
|
|
|
|
row << t("recruitment.language") + " - " + t("en")
|
|
row1 << "editor"
|
|
row2 << ""
|
|
row << t("recruitment.language") + " - " + t("zh_tw")
|
|
row1 << "editor"
|
|
row2 << ""
|
|
|
|
row << t("recruitment.salary_info") + " - " + t("en")
|
|
row1 << "editor"
|
|
row2 << ""
|
|
row << t("recruitment.salary_info") + " - " + t("zh_tw")
|
|
row1 << "editor"
|
|
row2 << ""
|
|
|
|
row << t("recruitment.contact_info") + " - " + t("en")
|
|
row1 << "editor"
|
|
row2 << ""
|
|
row << t("recruitment.contact_info") + " - " + t("zh_tw")
|
|
row1 << "editor"
|
|
row2 << ""
|
|
|
|
row << t("link")
|
|
row1 << "textfield"
|
|
row2 << "Seperate with ';'. Example: http://rulingcom.com; http://google.com"
|
|
|
|
row << t("link") + " " + t("url_alt") + " - " + t("en")
|
|
row1 << "textfield"
|
|
row2 << "Seperate with ';' with respective to the links in the link columns. Example : Rulingcom official site; Google search engine"
|
|
row << t("link") + " " + t("url_alt") + " - " + t("zh_tw")
|
|
row1 << "textfield"
|
|
row2 << "Seperate with ';' with respective to the links in the link columns. Example : Rulingcom official site; Google search engine"
|
|
|
|
row << t("file_")
|
|
row1 << "textfield"
|
|
row2 << "Seperate with ';'. Example: http://www.example.com/images/example.png; http://www.example.com/images/example2.png"
|
|
|
|
row << t("file_") + " " + t("description") + " - " + t("en")
|
|
row1 << "textfield"
|
|
row2 << "Seperate with ';' with respective to the links in the link columns. Example : Great view; Nice potrait"
|
|
row << t("file_") + " " + t("description") + " - " + t("zh_tw")
|
|
row1 << "textfield"
|
|
row2 << "Seperate with ';' with respective to the links in the link columns. Example : Great view; Nice potrait"
|
|
|
|
row << t("file_") + " " + t("alternative") + " - " + t("en")
|
|
row1 << "textfield"
|
|
row2 << "Seperate with ';' with respective to the links in the link columns. Example : example1; example2"
|
|
row << t("file_") + " " + t("alternative") + " - " + t("zh_tw")
|
|
row1 << "textfield"
|
|
row2 << "Seperate with ';' with respective to the links in the link columns. Example : example1; example2"
|
|
|
|
row << t("recruitment.event_end_date")
|
|
row1 << "datetime"
|
|
row2 << "Format: YYYY/MM/DD HH:mm, Example: 2015/12/10 15:20"
|
|
row << t("recruitment.carousel_image") + "-" + t("image")
|
|
row1 << "url"
|
|
row2 << "Seperate with ';'. Example: http://www.example.com/images/example.png; http://www.example.com/images/example2.png"
|
|
row << t("recruitment.carousel_image") + "-" + t("description") + " - " + t("en")
|
|
row1 << "textfield"
|
|
row2 << "Seperate with ';' with respective to the links in the link columns. Example : Great view; Nice potrait"
|
|
row << t("recruitment.carousel_image") + "-" + t("description") + " - " + t("zh_tw")
|
|
row1 << "textfield"
|
|
row2 << "Seperate with ';' with respective to the links in the link columns. Example : Great view; Nice potrait"
|
|
sheet.add_row row, :style => heading
|
|
sheet.add_row row1
|
|
sheet.add_row row2, :style => example
|
|
if @thread
|
|
all_count = @recruitment.count
|
|
puts_every_count = [all_count * 3 / 100, 1].max
|
|
current_count = 0
|
|
finish_percent = 0
|
|
@thread.update(:status=>{:status=>'Processing','all_count'=>all_count,'current_count'=>current_count,'finish_percent'=>finish_percent})
|
|
end
|
|
@recruitment.each do |anns|
|
|
row = []
|
|
row << categories.to_a.index(anns.category)
|
|
t = []
|
|
anns.tags.each do |tag|
|
|
t << tags.to_a.index(tag)
|
|
end
|
|
row << t.join(",")
|
|
row << (anns.recruitment_date.strftime("%Y/%m/%d %H:%M") rescue "")
|
|
row << (anns.postdate.strftime("%Y/%m/%d %H:%M") rescue "")
|
|
row << (anns.deadline.strftime("%Y/%m/%d %H:%M") rescue "")
|
|
row << (anns.is_top? ? 1 : 0)
|
|
row << (anns.is_hot? ? 1 : 0)
|
|
row << (anns.is_hidden? ? 1 : 0)
|
|
row << (anns.image.try(:url) || "")
|
|
row << anns.image_description_translations["en"]
|
|
row << anns.image_description_translations["zh_tw"]
|
|
row << anns.title_translations["en"]
|
|
row << anns.title_translations["zh_tw"]
|
|
row << anns.subtitle_translations["en"]
|
|
row << anns.subtitle_translations["zh_tw"]
|
|
row << anns.text_translations["en"]
|
|
row << anns.text_translations["zh_tw"]
|
|
row << anns.notes_translations["en"]
|
|
row << anns.notes_translations["zh_tw"]
|
|
row << (anns.education_requirement_translations["en"] rescue "")
|
|
row << (anns.education_requirement_translations["zh_tw"] rescue "")
|
|
row << (anns.experience_requirement_translations["en"] rescue "")
|
|
row << (anns.experience_requirement_translations["zh_tw"] rescue "")
|
|
row << (anns.skills_requirement_translations["en"] rescue "")
|
|
row << (anns.skills_requirement_translations["zh_tw"] rescue "")
|
|
row << (anns.language_translations["en"] rescue "")
|
|
row << (anns.language_translations["zh_tw"] rescue "")
|
|
row << (anns.salary_info_translations["en"] rescue "")
|
|
row << (anns.salary_info_translations["zh_tw"] rescue "")
|
|
row << (anns.contact_info_translations["en"] rescue "")
|
|
row << (anns.contact_info_translations["zh_tw"] rescue "")
|
|
|
|
links = anns.recruitment_links.asc(:created_at)
|
|
t = links.collect{|l|l.url}
|
|
row << t.join(";")
|
|
t = links.collect{|l|l.title_translations["en"]}
|
|
row << t.join(";")
|
|
t = links.collect{|l|l.title_translations["zh_tw"]}
|
|
row << t.join(";")
|
|
|
|
files = anns.recruitment_files.asc(:created_at)
|
|
file_urls = files.collect{|l|l.url}
|
|
file_urls.delete(nil)
|
|
row << file_urls.join(";")
|
|
t = files.collect{|l|l.description_translations["en"]}
|
|
row << t.join(";")
|
|
t = files.collect{|l|l.description_translations["zh_tw"]}
|
|
row << t.join(";")
|
|
t = files.collect{|l|l.title_translations["en"]}
|
|
row << t.join(";")
|
|
t = files.collect{|l|l.title_translations["zh_tw"]}
|
|
row << t.join(";")
|
|
|
|
row << (anns.event_end_date.strftime("%Y/%m/%d %H:%M") rescue "")
|
|
|
|
carousel_images = anns.recruitment_carousel_images.asc(:created_at)
|
|
t = carousel_images.collect{|l|l.image.try(:url)}
|
|
row << t.join(";")
|
|
t = carousel_images.collect{|l|l.description_translations["en"]}
|
|
row << t.join(";")
|
|
t = carousel_images.collect{|l|l.description_translations["zh_tw"]}
|
|
row << t.join(";")
|
|
sheet.add_row row
|
|
if @thread
|
|
current_count += 1
|
|
if current_count % puts_every_count == 0
|
|
finish_percent = (current_count * 100.0 / all_count).round(1)
|
|
@thread.update(:status=>{:status=>'Processing','all_count'=>all_count,'current_count'=>current_count,'finish_percent'=>finish_percent})
|
|
end
|
|
end
|
|
end
|
|
if @thread
|
|
finish_percent = 100
|
|
@thread.update(:status=>{:status=>'finish','all_count'=>all_count,'current_count'=>current_count,'finish_percent'=>finish_percent})
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
end |