2017-12-21 19:41:50 +00:00
|
|
|
class RecruitmentsController < PseudoSessionController
|
2017-12-29 12:00:33 +00:00
|
|
|
include ActionView::Helpers::TextHelper
|
|
|
|
before_filter :set_key_for_this, :except => ["index", "show"]
|
|
|
|
before_filter :load_profile, :except => ["newprofile", "createprofile", "index", "show", "advancedform"]
|
2018-06-23 13:34:09 +00:00
|
|
|
before_filter :is_user_authorized?, :except => ["index", "show", "advancedform", "write_recommendation", "create_recommendation"]
|
2017-12-21 19:41:50 +00:00
|
|
|
layout :get_layout
|
|
|
|
|
|
|
|
def index
|
2017-12-29 12:00:33 +00:00
|
|
|
params = OrbitHelper.params
|
2018-01-01 13:52:15 +00:00
|
|
|
if params[:page_id] == "jobs"
|
2018-01-15 12:26:18 +00:00
|
|
|
load_jobs(params, "type1")
|
|
|
|
elsif params[:page_id] == "internships"
|
|
|
|
load_jobs(params, "type2")
|
|
|
|
elsif params[:page_id] == "exchanges"
|
|
|
|
load_jobs(params, "type3")
|
2018-01-01 13:52:15 +00:00
|
|
|
elsif params[:page_id] == "candidates"
|
|
|
|
load_candidates(params)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def load_candidates(params)
|
|
|
|
data = []
|
|
|
|
if params[:type].present? && params[:type] == "aq"
|
|
|
|
candidates = advanced_filter_candidates(params)
|
|
|
|
criteria = "<span class='criteria'><i>-</i></span> <span class='reset-search'><a href='#{params[:url].gsub("/","")}'><i class='fa fa-refresh' aria-hidden='true'></i></a></span>"
|
|
|
|
elsif params[:q].present?
|
|
|
|
candidates = filter_candidates(params)
|
|
|
|
criteria = "<span class='criteria'><i>- " + params[:q] + "</i></span> <span class='reset-search'><a href='#{params[:url].gsub("/","")}'><i class='fa fa-refresh' aria-hidden='true'></i></a></span>"
|
|
|
|
else
|
|
|
|
criteria = ""
|
|
|
|
candidates = EmployeeProfile.job_seekers
|
|
|
|
end
|
|
|
|
if !candidates.nil? && !candidates.is_a?(Array)
|
|
|
|
candidates = candidates.desc(:updated_at).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count)
|
|
|
|
total_pages = candidates.total_pages
|
|
|
|
else
|
|
|
|
candidates = []
|
|
|
|
total_pages = 0
|
|
|
|
end
|
|
|
|
candidates.each do |candidate|
|
2018-01-18 07:37:08 +00:00
|
|
|
company = !candidate.current_company.nil? && candidate.current_company != "" ? candidate.current_company : (candidate.get_current_exp.company_name rescue nil)
|
2018-01-01 13:52:15 +00:00
|
|
|
company = "N/A" if company.nil?
|
|
|
|
if candidate.experience_years == 0 && candidate.experience_months == 0
|
|
|
|
wey = t("recruitment.fresher")
|
|
|
|
wem = ""
|
|
|
|
else
|
|
|
|
wey = (candidate.experience_years.to_s rescue "0") + " year(s)"
|
|
|
|
wem = (candidate.experience_months.to_s rescue "0") + " month(s)"
|
|
|
|
end
|
|
|
|
data << {
|
|
|
|
"name" => candidate.recruit_profile.name,
|
|
|
|
"designation" => candidate.desired_job_title,
|
|
|
|
"company_name" => company,
|
|
|
|
"location" => candidate.desired_place,
|
|
|
|
"url_to_show" => OrbitHelper.url_to_show(candidate.recruit_profile.to_param),
|
|
|
|
"work_experience_years" => wey,
|
|
|
|
"work_experience_months" => wem,
|
|
|
|
"introduction" => candidate.introduction,
|
|
|
|
"skills" => candidate.skills.collect{|skill| {"skill-tag" => skill}},
|
|
|
|
"avatar" => candidate.get_avatar
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"candidates" => data,
|
|
|
|
"extras" => {
|
2018-01-19 13:31:41 +00:00
|
|
|
"criteria" => criteria,
|
|
|
|
"advanced-search" => t("recruitment.advanced_search")
|
2018-01-01 13:52:15 +00:00
|
|
|
},
|
|
|
|
"total_pages" => total_pages
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-01-15 12:26:18 +00:00
|
|
|
def load_jobs(params, type)
|
2018-01-01 13:52:15 +00:00
|
|
|
jobs = []
|
2017-12-29 12:00:33 +00:00
|
|
|
if params[:type].present? && params[:type] == "aq"
|
2018-01-15 12:26:18 +00:00
|
|
|
rjobs = advanced_filter_jobs(params,type)
|
2017-12-29 12:00:33 +00:00
|
|
|
criteria = "<span class='criteria'><i>-</i></span> <span class='reset-search'><a href='#{params[:url].gsub("/","")}'><i class='fa fa-refresh' aria-hidden='true'></i></a></span>"
|
|
|
|
elsif params[:q].present?
|
2018-01-15 12:26:18 +00:00
|
|
|
rjobs = filter_jobs(params, type)
|
2017-12-29 12:00:33 +00:00
|
|
|
criteria = "<span class='criteria'><i>- " + params[:q] + "</i></span> <span class='reset-search'><a href='#{params[:url].gsub("/","")}'><i class='fa fa-refresh' aria-hidden='true'></i></a></span>"
|
|
|
|
else
|
|
|
|
criteria = ""
|
2018-01-15 12:26:18 +00:00
|
|
|
rjobs = RecruitmentJob.where(:post_type => type).not_filled
|
2017-12-29 12:00:33 +00:00
|
|
|
end
|
|
|
|
if !rjobs.nil? && !rjobs.is_a?(Array)
|
|
|
|
rjobs = rjobs.desc(:created_at).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count)
|
|
|
|
total_pages = rjobs.total_pages
|
|
|
|
else
|
|
|
|
rjobs = []
|
|
|
|
total_pages = 0
|
|
|
|
end
|
|
|
|
rjobs.each do |rj|
|
|
|
|
if rj.work_experience_years == 0 && rj.work_experience_months == 0
|
|
|
|
wey = t("recruitment.fresher")
|
|
|
|
wem = ""
|
|
|
|
else
|
|
|
|
wey = (rj.work_experience_years.to_s rescue "0") + " year(s)"
|
|
|
|
wem = (rj.work_experience_months.to_s rescue "0") + " month(s)"
|
|
|
|
end
|
|
|
|
jobs << {
|
|
|
|
"company_name" => rj.employer_profile.company_name,
|
|
|
|
"industry" => rj.employer_profile.get_industry,
|
|
|
|
"avatar" => rj.employer_profile.get_avatar,
|
|
|
|
"title" => rj.job_title,
|
|
|
|
"url_to_show" => OrbitHelper.url_to_show(rj.to_param),
|
|
|
|
"description" => simple_format(truncate(rj.job_description, :length => 50)),
|
|
|
|
"postdate" => rj.created_at,
|
|
|
|
"work_type" => rj.work_type,
|
|
|
|
"location" => rj.location_of_work,
|
|
|
|
"work_experience_years" => wey,
|
|
|
|
"work_experience_months" => wem,
|
|
|
|
"category" => rj.category,
|
2018-01-15 12:26:18 +00:00
|
|
|
"post-type" => rj.get_post_type_label,
|
2017-12-29 12:00:33 +00:00
|
|
|
"skills" => rj.skills.collect{|skill| {"skill-tag" => skill}}
|
|
|
|
}
|
|
|
|
end
|
|
|
|
{
|
|
|
|
"jobs" => jobs,
|
|
|
|
"extras" => {
|
2018-01-19 13:31:41 +00:00
|
|
|
"criteria" => criteria,
|
|
|
|
"advanced-search" => t("recruitment.advanced_search")
|
2017-12-29 12:00:33 +00:00
|
|
|
},
|
|
|
|
"total_pages" => total_pages
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
params = OrbitHelper.params
|
2018-01-15 12:26:18 +00:00
|
|
|
if params[:page_id] == "jobs" || params[:page_id] == "internships" || params[:page_id] == "exchanges"
|
2018-01-01 13:52:15 +00:00
|
|
|
show_job(params)
|
|
|
|
elsif params[:page_id] == "candidates"
|
|
|
|
show_candidate(params)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-01-02 18:30:32 +00:00
|
|
|
def check_session
|
|
|
|
page = Page.where(:module => "pseudo_member").first
|
|
|
|
session = OrbitHelper.request.session
|
2018-06-23 15:06:41 +00:00
|
|
|
available = session[:current_pseudo_user_id].present? && !session[:current_pseudo_user_id].nil? ? true : false
|
|
|
|
|
2018-06-23 14:46:35 +00:00
|
|
|
if !OrbitHelper.current_user.nil?
|
|
|
|
available = OrbitHelper.current_user.is_admin?
|
|
|
|
end
|
2018-01-01 13:52:15 +00:00
|
|
|
{
|
2018-01-02 18:30:32 +00:00
|
|
|
"session" => available,
|
|
|
|
"url" => "/" + I18n.locale.to_s + page.url,
|
2018-01-01 13:52:15 +00:00
|
|
|
"type" => OrbitHelper.params[:page_id]
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def show_candidate(params)
|
2018-01-02 09:00:53 +00:00
|
|
|
rp = RecruitProfile.where(:uid => params[:uid]).first
|
|
|
|
profile = rp.profile
|
2018-01-03 04:46:00 +00:00
|
|
|
if (profile.country_code.nil? || profile.country_code == "") && (profile.phone_number.nil? || profile.phone_number == "")
|
|
|
|
phone = t("recruitment.not_available")
|
|
|
|
else
|
|
|
|
phone = !profile.country_code.nil? ? "+" + profile.country_code + " - " + profile.phone_number : profile.phone_number
|
|
|
|
end
|
2018-01-11 18:51:30 +00:00
|
|
|
skills = []
|
2018-01-02 18:30:32 +00:00
|
|
|
skills = profile.skills.collect{|skill| {"skill-name" => skill}} if !profile.skills.empty?
|
|
|
|
infos = []
|
2018-01-11 12:21:16 +00:00
|
|
|
["autobiography", "resume_content"].each do |t|
|
2018-01-02 18:30:32 +00:00
|
|
|
if !profile.send(t).nil? && profile.send(t) != ""
|
|
|
|
infos << {
|
|
|
|
"title" => t("recruitment.#{t}"),
|
|
|
|
"text" => simple_format(profile.send(t))
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
2018-01-11 12:21:16 +00:00
|
|
|
|
|
|
|
recommendations = []
|
2018-01-16 12:06:04 +00:00
|
|
|
profile.employee_recommendations.desc(:created_at).each do |rec|
|
|
|
|
t = {
|
2018-01-11 12:21:16 +00:00
|
|
|
"name" => rec.name,
|
|
|
|
"email" => rec.email,
|
|
|
|
"rec-letter" => rec.info
|
|
|
|
}
|
2018-01-16 12:06:04 +00:00
|
|
|
|
|
|
|
t["download-file"] = !rec.file.nil? && !rec.file.url.nil? ? "<a href='#{rec.file.url}' target='_blank'>#{t("recruitment.download_file")}</a>" : ""
|
|
|
|
|
|
|
|
recommendations << t
|
2018-01-11 12:21:16 +00:00
|
|
|
end
|
|
|
|
|
2018-01-11 18:51:30 +00:00
|
|
|
academics = []
|
|
|
|
profile.employee_academics.each do |aca|
|
|
|
|
academics << {
|
|
|
|
"title" => (t("recruitment.academic_type.#{aca.academic_type}") + " " + t("recruitment.in") + " " + aca.degree_name),
|
2018-01-12 08:43:26 +00:00
|
|
|
"period" => aca.period,
|
2018-01-11 18:51:30 +00:00
|
|
|
"note" => aca.note
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-01-12 08:43:26 +00:00
|
|
|
experiences = []
|
|
|
|
profile.employee_experiences.asc(:end_date).each do |exp|
|
|
|
|
experiences << {
|
|
|
|
"job-title" => exp.job_title,
|
|
|
|
"company-name" => exp.company_name,
|
|
|
|
"period" => exp.period,
|
|
|
|
"responsibilities" => exp.responsibilities
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-01-02 18:30:32 +00:00
|
|
|
if profile.experience_years == 0 && profile.experience_months == 0
|
|
|
|
experience = t("recruitment.fresher")
|
|
|
|
else
|
|
|
|
experience = (profile.experience_years.to_s rescue "0") + " year(s) " + (profile.experience_months.to_s rescue "0") + " month(s)"
|
|
|
|
end
|
2018-01-11 18:51:30 +00:00
|
|
|
|
2018-01-01 13:52:15 +00:00
|
|
|
{
|
2018-01-02 18:30:32 +00:00
|
|
|
"skills" => skills,
|
|
|
|
"infos" => infos,
|
2018-01-11 18:51:30 +00:00
|
|
|
"academics" => academics,
|
2018-01-12 08:43:26 +00:00
|
|
|
"experiences" => experiences,
|
2018-01-11 12:21:16 +00:00
|
|
|
"recommendations" => recommendations,
|
2018-01-02 09:00:53 +00:00
|
|
|
"data" => {
|
|
|
|
"name" => rp.name,
|
|
|
|
"job-title" => profile.desired_job_title,
|
|
|
|
"company-name" => profile.current_company,
|
|
|
|
"phone" => phone,
|
|
|
|
"email" => rp.email,
|
|
|
|
"website" => profile.website,
|
2018-01-02 18:30:32 +00:00
|
|
|
"avatar" => profile.get_avatar,
|
|
|
|
"resume-url" => (profile.resume.url rescue ""),
|
|
|
|
"resume-text" => t("recruitment.resume_text"),
|
|
|
|
"location-title" => t("recruitment.location"),
|
|
|
|
"location" => profile.desired_place,
|
|
|
|
"experience-title" => t("recruitment.experience_title"),
|
|
|
|
"experience" => experience,
|
|
|
|
"gender-title" => t("recruitment.gender_title"),
|
|
|
|
"gender" => t("recruitment.gender.#{profile.gender}"),
|
|
|
|
"martial-title" => t("recruitment.martial_title"),
|
2018-01-03 08:45:07 +00:00
|
|
|
"martial" => (!profile.marital_status.nil? && profile.marital_status != "" ? t("recruitment.martial.#{profile.marital_status}") : t("recruitment.not_available")),
|
2018-01-02 18:30:32 +00:00
|
|
|
"language-title" => t("recruitment.language_title"),
|
|
|
|
"language" => profile.languages,
|
|
|
|
"workingtime-title" => t("recruitment.workingtime_title"),
|
2018-01-03 04:46:00 +00:00
|
|
|
"workingtime" => (!profile.working_time.nil? && profile.working_time != "" ? t("recruitment.working_time.#{profile.working_time}") : t("recruitment.not_available")),
|
2018-01-11 12:21:16 +00:00
|
|
|
"recommendation-title" => t("recruitment.recommendation")
|
2018-01-02 09:00:53 +00:00
|
|
|
}
|
2018-01-01 13:52:15 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def show_job(params)
|
2017-12-29 12:00:33 +00:00
|
|
|
job = RecruitmentJob.where(:uid => params[:uid]).first
|
|
|
|
profile = job.employer_profile
|
|
|
|
infos = []
|
|
|
|
if !profile.company_profile.nil? && profile.company_profile != ""
|
|
|
|
infos << {
|
|
|
|
"title" => t("recruitment.company_profile"),
|
|
|
|
"text" => simple_format(profile.company_profile)
|
|
|
|
}
|
|
|
|
end
|
2018-01-02 18:30:32 +00:00
|
|
|
["job_description", "other_conditions"].each do |jj|
|
2017-12-29 12:00:33 +00:00
|
|
|
if !job.send(jj).nil? && job.send(jj) != ""
|
|
|
|
infos << {
|
|
|
|
"title" => t("recruitment.#{jj}"),
|
|
|
|
"text" => simple_format(job.send(jj))
|
|
|
|
}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if !job.skills.empty?
|
2018-01-15 12:26:18 +00:00
|
|
|
skills = job.skills.collect{|skill| "<span class='label label-default'>#{skill}</span>"}
|
2018-01-01 14:01:26 +00:00
|
|
|
skills = skills.join(" ")
|
2017-12-29 12:00:33 +00:00
|
|
|
else
|
|
|
|
skills = t("recruitment.not_available")
|
|
|
|
end
|
|
|
|
|
|
|
|
if job.work_experience_years == 0 && job.work_experience_months == 0
|
|
|
|
experience = t("recruitment.fresher")
|
|
|
|
else
|
|
|
|
experience = (job.work_experience_years.to_s rescue "0") + " year(s) " + (job.work_experience_months.to_s rescue "0") + " month(s)"
|
|
|
|
end
|
|
|
|
if !job.holiday_system.nil? || job.holiday_system != ""
|
|
|
|
if job.holiday_system == "type2" && !job.holiday_system_other.nil? && job.holiday_system_other != ""
|
|
|
|
holiday = job.holiday_system_other
|
|
|
|
else
|
|
|
|
holiday = t("recruitment.holiday_system.#{job.holiday_system}")
|
|
|
|
end
|
|
|
|
else
|
|
|
|
holiday = t("recruitment.not_available")
|
|
|
|
end
|
2018-01-02 18:30:32 +00:00
|
|
|
session = OrbitHelper.request.session
|
|
|
|
applybtn = ""
|
|
|
|
if session[:current_pseudo_user_id].present? && !session[:current_pseudo_user_id].nil?
|
|
|
|
pu = PseudoUser.find(session[:current_pseudo_user_id]) rescue nil
|
|
|
|
current_loggedin_user = RecruitProfile.where(:pseudo_member_id => pu.user_name).first rescue nil
|
|
|
|
if !current_loggedin_user.nil? && current_loggedin_user.is_employee?
|
|
|
|
if !current_loggedin_user.profile.is_job_applied?(job.id.to_s)
|
2018-01-19 13:31:41 +00:00
|
|
|
applybtn = "<a href='#' id='jobApplicationBtn' class='btn btn-primary'>#{"recruitment.apply"}</a>"
|
2018-01-02 18:30:32 +00:00
|
|
|
else
|
2018-01-19 13:31:41 +00:00
|
|
|
applybtn = "<a href='#' disabled='disabled' class='btn btn-success'>#{"recruitment.already_applied"}</a>"
|
2018-01-02 18:30:32 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2018-01-11 12:21:16 +00:00
|
|
|
if job.max_salary > job.min_salary
|
|
|
|
range = (job.min_salary * 1000).to_s + " ~ " + (job.max_salary * 1000).to_s + " / Month "
|
|
|
|
elsif job.max_salary == job.min_salary
|
|
|
|
range = t("recruitment.not_available")
|
|
|
|
elsif job.max_salary < job.min_salary
|
|
|
|
range = (job.min_salary * 1000).to_s + " ~ #{t('recruitment.salary.type1')} / Month"
|
|
|
|
end
|
2018-01-15 12:26:18 +00:00
|
|
|
if job.internship_duration > 0
|
|
|
|
duration = job.internship_duration.to_s + " #{t("recruitment.months")}"
|
|
|
|
end
|
|
|
|
if job.part_time?
|
|
|
|
parttime = "<span class='label label-primary'>#{t("recruitment.internship_part_time")}<span>"
|
|
|
|
end
|
2018-01-16 12:06:04 +00:00
|
|
|
|
2017-12-29 12:00:33 +00:00
|
|
|
{
|
|
|
|
"infos" => infos,
|
|
|
|
"data" => {
|
2018-01-15 12:26:18 +00:00
|
|
|
"post-type" => job.get_post_type_label,
|
|
|
|
"part-time" => parttime,
|
2018-01-16 12:06:04 +00:00
|
|
|
"exchange-duration-title" => t("recruitment.exchange_duration"),
|
|
|
|
"min-credit-title" => t("recruitment.min_credit_score"),
|
|
|
|
"min-credit" => (job.min_credit_score > 0 ? job.min_credit_score : t("recruitment.not_available")),
|
|
|
|
"exchange-start-title" => t("recruitment.exchange_start_date"),
|
|
|
|
"exchange-start" => (job.exchange_start_date.nil? ? t("recruitment.not_available") : job.exchange_start_date ),
|
2018-01-15 12:26:18 +00:00
|
|
|
"internship-duration-title" => t("recruitment.internship_duration"),
|
|
|
|
"internship-duration" => duration,
|
|
|
|
"perks-title" => t("recruitment.perks_title"),
|
|
|
|
"perks" => (job.perks.nil? || job.perks != "" ? t("recruitment.perks.#{job.perks}") : t("recruitment.not_available")),
|
2017-12-29 12:00:33 +00:00
|
|
|
"job-title" => job.job_title,
|
|
|
|
"job-category" => job.get_category,
|
|
|
|
"avatar" => profile.get_avatar,
|
|
|
|
"company-name" => profile.company_name,
|
|
|
|
"industry" => profile.get_industry,
|
|
|
|
"post-date" => job.created_at,
|
|
|
|
"location-title" => t("recruitment.location"),
|
|
|
|
"location" => (!job.location_of_work.nil? && job.location_of_work != "" ? job.location_of_work : t("recruitment.not_available")),
|
|
|
|
"skills-title" => t("recruitment.skills_title"),
|
2018-01-01 14:01:26 +00:00
|
|
|
"skills" => skills,
|
2017-12-29 12:00:33 +00:00
|
|
|
"experience-title" => t("recruitment.experience_title"),
|
|
|
|
"experience" => experience,
|
2018-01-11 12:21:16 +00:00
|
|
|
"min-qualification-title" => t("recruitment.min_qualification"),
|
|
|
|
"min-qualification" => (!job.academic_type.nil? && job.academic_type != "" ? t("recruitment.academic_type.#{job.academic_type}") : t("recruitment.not_available")),
|
2017-12-29 12:00:33 +00:00
|
|
|
"qualification-title" => t("recruitment.qualification"),
|
|
|
|
"qualification" => (!job.academic_requirement.nil? && job.academic_requirement != "" ? simple_format(job.academic_requirement) : t("recruitment.not_available")),
|
|
|
|
"salary-title" => t("recruitment.salary-title"),
|
|
|
|
"salary" => (!job.salary.nil? && job.salary != "" ? t("recruitment.salary.#{job.salary}") : t("recruitment.not_available")),
|
2018-01-11 12:21:16 +00:00
|
|
|
"salary-range" => t("recruitment.salary_range"),
|
|
|
|
"range" => range,
|
2017-12-29 12:00:33 +00:00
|
|
|
"travel-title" => t("recruitment.travel"),
|
|
|
|
"travel" => (!job.travel_assignment.nil? && job.travel_assignment != "" ? t("recruitment.travel_assignment.#{job.travel_assignment}") : t("recruitment.not_available")),
|
|
|
|
"joining-title" => t("recruitment.joining"),
|
|
|
|
"joining" => (!job.joining_time.nil? && job.joining_time != "" ? t("recruitment.joining_time.#{job.joining_time}") : t("recruitment.not_available")),
|
|
|
|
"worktype-title" => t("recruitment.worktype_title"),
|
|
|
|
"worktype" => (!job.work_type.nil? && job.work_type != "" ? t("recruitment.work_type.#{job.work_type}") : t("recruitment.not_available")),
|
|
|
|
"language-title" => t("recruitment.language"),
|
|
|
|
"language" => (!job.language_requirement.nil? && job.language_requirement != "" ? job.language_requirement : t("recruitment.not_available")),
|
|
|
|
"workingtime-title" => t("recruitment.workingtime_title"),
|
|
|
|
"workingtime" => (!job.working_time.nil? && job.working_time != "" ? t("recruitment.working_time.#{job.working_time}") : t("recruitment.not_available")),
|
|
|
|
"holiday-title" => t("recruitment.holiday_title"),
|
|
|
|
"holiday" => holiday,
|
2018-01-02 18:30:32 +00:00
|
|
|
"apply-btn" => applybtn,
|
|
|
|
"job-id" => job.id.to_s
|
2017-12-29 12:00:33 +00:00
|
|
|
}
|
|
|
|
}
|
2017-12-21 19:41:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def firstruncheck
|
|
|
|
if @profile.nil?
|
|
|
|
redirect_to select_profile_path
|
|
|
|
else
|
|
|
|
redirect_to mydashboard_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-01-02 18:30:32 +00:00
|
|
|
def job_applications
|
|
|
|
if @profile.is_employee? || @profile.profile.recruitment_jobs.where(:id => params[:id]).count == 0
|
|
|
|
redirect_to mydashboard_path and return
|
|
|
|
end
|
|
|
|
@applications = EmployeeJobApplication.where(:job => params[:id]).not_archived.desc(:created_at)
|
|
|
|
end
|
|
|
|
|
|
|
|
def archive_application
|
|
|
|
eja = EmployeeJobApplication.find(params[:id])
|
|
|
|
eja.archived = true
|
|
|
|
eja.save
|
|
|
|
redirect_to "/recruit/#{eja.id.to_s}/job_applications"
|
|
|
|
end
|
|
|
|
|
2017-12-29 12:00:33 +00:00
|
|
|
def advancedform
|
|
|
|
@industries = RecruitmentIndustry.all.asc(:industry_title).collect{|ri| [ri.industry_title, ri.id]}
|
|
|
|
@categories = RecruitmentCategory.all.asc(:job_category).collect{|ri| [ri.job_category, ri.id]}
|
|
|
|
@locations = RecruitmentJob.all.asc(:location_of_work).pluck(:location_of_work).uniq
|
|
|
|
render :layout => false
|
|
|
|
end
|
|
|
|
|
2018-01-02 18:30:32 +00:00
|
|
|
def applyjob
|
|
|
|
if @profile.is_employee?
|
|
|
|
eja = EmployeeJobApplication.new
|
|
|
|
eja.job = params[:job_id]
|
|
|
|
eja.cover_letter = params[:cover_letter]
|
|
|
|
eja.employee_profile_id = @profile.profile.id
|
|
|
|
eja.save
|
|
|
|
end
|
|
|
|
redirect_to mydashboard_path
|
|
|
|
end
|
|
|
|
|
2017-12-21 19:41:50 +00:00
|
|
|
def select_profile
|
|
|
|
end
|
|
|
|
|
|
|
|
def newprofile
|
|
|
|
@profile = RecruitProfile.new
|
|
|
|
if params[:type] == "1"
|
|
|
|
@profile.build_employee_profile
|
|
|
|
elsif params[:type] == "2"
|
|
|
|
@profile.build_employer_profile
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def createprofile
|
|
|
|
profile = RecruitProfile.create(profile_params)
|
2018-01-01 13:52:15 +00:00
|
|
|
if profile.is_employer?
|
|
|
|
redirect_to mydashboard_path
|
|
|
|
elsif profile.is_employee?
|
|
|
|
if params[:commit] == "Next" && params[:step] == "step1"
|
|
|
|
redirect_to employee_academics_path
|
|
|
|
elsif params[:commit] == "Save"
|
|
|
|
redirect_to mydashboard_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def employee_academics
|
|
|
|
@academic = EmployeeAcademic.new
|
|
|
|
@academics = @profile.profile.employee_academics
|
|
|
|
@academic_types = ["type1","type2","type3","type4"].collect{|t| [t("recruitment.academic_type.#{t}"), t]}
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit_employee_academic
|
|
|
|
@academic = EmployeeAcademic.find(params[:id])
|
|
|
|
@academic_types = ["type1","type2","type3","type4"].collect{|t| [t("recruitment.academic_type.#{t}"), t]}
|
|
|
|
end
|
|
|
|
|
|
|
|
def update_academic
|
|
|
|
academic = EmployeeAcademic.find(params[:id])
|
|
|
|
academic.update_attributes(employee_academic_params)
|
|
|
|
redirect_to employee_academics_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_academic
|
|
|
|
if params[:commit] == "Add"
|
|
|
|
academic = EmployeeAcademic.create(employee_academic_params)
|
|
|
|
redirect_to employee_academics_path
|
|
|
|
elsif params[:commit] = "Next"
|
|
|
|
if params[:employee_academic][:degree_name].present?
|
|
|
|
academic = EmployeeAcademic.create(employee_academic_params)
|
|
|
|
end
|
|
|
|
redirect_to employee_portfolio_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def employee_portfolio
|
2017-12-21 19:41:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def recruitment_dashboard
|
2018-01-01 13:52:15 +00:00
|
|
|
if @profile.is_employer?
|
|
|
|
@jobsposted = @profile.profile.recruitment_jobs.desc(:created_at)
|
|
|
|
elsif @profile.is_employee?
|
|
|
|
@applications = @profile.profile.employee_job_applications.desc(:created_at)
|
|
|
|
end
|
2017-12-21 19:41:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def editprofile
|
|
|
|
end
|
|
|
|
|
|
|
|
def updateprofile
|
|
|
|
@profile.update_attributes(profile_params)
|
2018-01-01 13:52:15 +00:00
|
|
|
if @profile.is_employer?
|
|
|
|
redirect_to mydashboard_path
|
|
|
|
elsif @profile.is_employee?
|
2018-01-22 09:28:14 +00:00
|
|
|
if params[:commit] == "Next" || params[:commit] == "下一個"
|
2018-01-01 13:52:15 +00:00
|
|
|
if params[:step] == "step3"
|
|
|
|
redirect_to employee_experience_path
|
|
|
|
elsif params[:step] == "step1"
|
|
|
|
redirect_to employee_academics_path
|
|
|
|
end
|
2018-01-22 09:28:14 +00:00
|
|
|
elsif params[:commit] == "Save" || params[:commit] == "儲存"
|
2018-01-01 13:52:15 +00:00
|
|
|
redirect_to mydashboard_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def employee_experience
|
|
|
|
@exeperiences = @profile.employee_profile.employee_experiences.desc(:created_at)
|
|
|
|
@experience = EmployeeExperience.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_experience
|
|
|
|
if params[:commit] == "Add"
|
|
|
|
academic = EmployeeExperience.create(employee_exp_params)
|
|
|
|
redirect_to employee_experience_path
|
|
|
|
elsif params[:commit] = "Finish"
|
|
|
|
if params[:employee_experience][:job_title].present? || params[:employee_experience][:company_name].present?
|
|
|
|
academic = EmployeeExperience.create(employee_exp_params)
|
|
|
|
end
|
|
|
|
redirect_to mydashboard_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-01-11 12:21:16 +00:00
|
|
|
def employee_recommendation
|
|
|
|
@recommendations = @profile.profile.employee_recommendations.desc(:created_at)
|
|
|
|
if request.request_method == "POST"
|
|
|
|
token = rand(10**8).to_s
|
|
|
|
eprofile = @profile.profile
|
|
|
|
eprofile.recommendation_tokens << token
|
|
|
|
eprofile.save
|
|
|
|
url = "http://#{request.host_with_port}/recruit/#{@profile.uid}/write_recommendation?token=#{token}"
|
|
|
|
data = {"url" => url, "letter" => params[:request_letter], "referral_name" => params[:referral_name], "name" => @profile.name, "respected" => t("recruitment.respected"), "recommendation_link" => t("recruitment.recommendation_link"), "yours_sincerely" => t("recruitment.yours_sincerely")}
|
|
|
|
email = Email.new
|
|
|
|
email.mail_to = params[:referral_email]
|
|
|
|
email.mail_subject = t("recruitment.recommendation_subject")
|
|
|
|
email.template = "recruitments/recommendation_email.html.erb"
|
|
|
|
email.template_data = data
|
|
|
|
email.deliver
|
|
|
|
redirect_to employee_recommendation_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def write_recommendation
|
|
|
|
@profile = RecruitProfile.where(:uid => params[:id]).first
|
|
|
|
@is_written = @profile.profile.employee_recommendations.where(:employee_recommendation_token => params[:token]).count > 0
|
|
|
|
@recommendation = EmployeeRecommendation.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create_recommendation
|
2018-01-16 12:06:04 +00:00
|
|
|
if request.request_method == "POST"
|
|
|
|
rec = EmployeeRecommendation.create(recommendation_params)
|
|
|
|
end
|
2018-01-11 12:21:16 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def delete_employee_recommendation
|
|
|
|
rec = EmployeeRecommendation.find(params[:id])
|
|
|
|
rec.destroy
|
|
|
|
redirect_to employee_recommendation_path
|
|
|
|
end
|
|
|
|
|
2018-01-01 13:52:15 +00:00
|
|
|
def edit_employee_experience
|
|
|
|
@experience = EmployeeExperience.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def update_exmployee_experience
|
|
|
|
experience = EmployeeExperience.find(params[:id])
|
|
|
|
experience.update_attributes(employee_exp_params)
|
|
|
|
redirect_to employee_experience_path
|
2017-12-21 19:41:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def addjob
|
|
|
|
@job = RecruitmentJob.new
|
2018-01-11 12:21:16 +00:00
|
|
|
@academic_types = ["type1","type2","type3"].collect{|t| [t("recruitment.academic_type.#{t}"), t]}
|
2017-12-21 19:41:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def editjob
|
|
|
|
@job = RecruitmentJob.find(params[:id])
|
2018-01-11 12:21:16 +00:00
|
|
|
@academic_types = ["type1","type2","type3"].collect{|t| [t("recruitment.academic_type.#{t}"), t]}
|
2017-12-21 19:41:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def createjob
|
|
|
|
job = RecruitmentJob.create(recruitment_job_params)
|
|
|
|
redirect_to mydashboard_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def updatejob
|
|
|
|
job = RecruitmentJob.find(params[:id])
|
|
|
|
job.update_attributes(recruitment_job_params)
|
|
|
|
redirect_to mydashboard_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def markfilled
|
|
|
|
job = RecruitmentJob.find(params[:id])
|
|
|
|
if job.employer_profile_id.to_s == @profile.profile.id.to_s
|
|
|
|
job.filled = true
|
|
|
|
job.save
|
|
|
|
end
|
|
|
|
redirect_to mydashboard_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def unmarkfilled
|
|
|
|
job = RecruitmentJob.find(params[:id])
|
|
|
|
if job.employer_profile_id.to_s == @profile.profile.id.to_s
|
|
|
|
job.filled = false
|
|
|
|
job.save
|
|
|
|
end
|
|
|
|
redirect_to mydashboard_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def deletejob
|
|
|
|
job = RecruitmentJob.find(params[:id])
|
|
|
|
job.destroy
|
|
|
|
redirect_to mydashboard_path
|
|
|
|
end
|
|
|
|
|
2018-01-15 12:26:18 +00:00
|
|
|
|
2018-01-16 12:06:04 +00:00
|
|
|
# ------ ------ internship ------ ------- #
|
2018-01-15 12:26:18 +00:00
|
|
|
|
|
|
|
def addinternship
|
|
|
|
@job = RecruitmentJob.new
|
|
|
|
@academic_types = ["type1","type2","type3"].collect{|t| [t("recruitment.academic_type.#{t}"), t]}
|
|
|
|
end
|
|
|
|
|
2018-01-16 12:06:04 +00:00
|
|
|
def editinternship
|
|
|
|
@job = RecruitmentJob.find(params[:id])
|
|
|
|
@academic_types = ["type1","type2","type3"].collect{|t| [t("recruitment.academic_type.#{t}"), t]}
|
|
|
|
end
|
|
|
|
|
|
|
|
# ------ ------ exchange ------ ------- #
|
|
|
|
|
|
|
|
def addexchange
|
|
|
|
@job = RecruitmentJob.new
|
|
|
|
@academic_types = ["type1","type2","type3"].collect{|t| [t("recruitment.academic_type.#{t}"), t]}
|
|
|
|
end
|
|
|
|
|
|
|
|
def editexchange
|
|
|
|
@job = RecruitmentJob.find(params[:id])
|
|
|
|
@academic_types = ["type1","type2","type3"].collect{|t| [t("recruitment.academic_type.#{t}"), t]}
|
|
|
|
end
|
|
|
|
|
2018-01-19 13:31:41 +00:00
|
|
|
# ------ ------ account settings ------ ------- #
|
|
|
|
def account_settings
|
|
|
|
end
|
|
|
|
|
|
|
|
def update_settings
|
|
|
|
pu = PseudoUser.where(:user_name => @profile.pseudo_member_id).first
|
|
|
|
if pu.update_password(params[:password],params[:password_confirmation])
|
|
|
|
redirect_to mydashboard_path
|
|
|
|
else
|
|
|
|
redirect_to account_settings_path(:err => "1")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-12-21 19:41:50 +00:00
|
|
|
private
|
|
|
|
|
2018-01-15 12:26:18 +00:00
|
|
|
def filter_jobs(params, type)
|
2017-12-29 12:00:33 +00:00
|
|
|
rjobs = []
|
|
|
|
|
|
|
|
keywords = params[:q].split(",").collect{|s| /#{s.strip}/i}
|
|
|
|
companies = EmployerProfile.where(:company_name.in => keywords).pluck(:id)
|
2018-01-15 12:26:18 +00:00
|
|
|
skills = RecruitmentJob.where(:post_type => type).where(:skills.in => keywords)
|
|
|
|
designations = RecruitmentJob.where(:post_type => type).where(:job_title.in => keywords)
|
2017-12-29 12:00:33 +00:00
|
|
|
query = []
|
|
|
|
if companies.count > 0
|
|
|
|
query << {:employer_profile_id.in => companies}
|
|
|
|
end
|
|
|
|
if skills.count > 0
|
|
|
|
query << {:skills.in => keywords}
|
|
|
|
end
|
|
|
|
if designations.count > 0
|
|
|
|
query << {:job_title.in => keywords}
|
|
|
|
end
|
|
|
|
if !query.empty?
|
2018-01-15 12:26:18 +00:00
|
|
|
rjobs = RecruitmentJob.where(:post_type => type).any_of(query).not_filled
|
2017-12-29 12:00:33 +00:00
|
|
|
end
|
|
|
|
rjobs
|
|
|
|
end
|
|
|
|
|
2018-01-15 12:26:18 +00:00
|
|
|
def advanced_filter_jobs(params, type)
|
2017-12-29 12:00:33 +00:00
|
|
|
if params[:q].present?
|
2018-01-15 12:26:18 +00:00
|
|
|
rjobs = filter_jobs(params, type)
|
2017-12-29 12:00:33 +00:00
|
|
|
else
|
|
|
|
rjobs = []
|
|
|
|
end
|
|
|
|
query = []
|
|
|
|
if params[:exp].present?
|
|
|
|
if params[:exp].to_i > 0
|
|
|
|
query << {:work_experience_years.gte => params[:exp].to_i}
|
|
|
|
else
|
|
|
|
query << {:work_experience_years => params[:exp]}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if params[:industry].present?
|
|
|
|
companies = EmployerProfile.where(:industry => params[:industry]).pluck(:id)
|
|
|
|
if companies.count > 0
|
|
|
|
query << {:employer_profile_id.in => companies}
|
|
|
|
end
|
|
|
|
end
|
|
|
|
if params[:category].present?
|
|
|
|
query << {:category => params[:category]}
|
|
|
|
end
|
|
|
|
if params[:location].present?
|
|
|
|
query << {:location_of_work => /#{params[:location]}/i}
|
|
|
|
end
|
|
|
|
if !query.empty?
|
|
|
|
if !rjobs.empty?
|
|
|
|
rjobs = rjobs.where(query.reduce({}, :merge))
|
|
|
|
else
|
2018-01-15 12:26:18 +00:00
|
|
|
rjobs = RecruitmentJob.where(:post_type => type).where(query.reduce({}, :merge))
|
2017-12-29 12:00:33 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
rjobs
|
|
|
|
end
|
|
|
|
|
2018-01-01 13:52:15 +00:00
|
|
|
def filter_candidates
|
|
|
|
end
|
|
|
|
|
|
|
|
def advanced_filter_candidates
|
|
|
|
end
|
|
|
|
|
2017-12-21 19:41:50 +00:00
|
|
|
def get_layout
|
|
|
|
"recruit"
|
|
|
|
end
|
|
|
|
|
|
|
|
def load_profile
|
|
|
|
@profile = RecruitProfile.where(:pseudo_member_id => current_pseudo_user.user_name).first rescue nil
|
|
|
|
end
|
|
|
|
|
|
|
|
def profile_params
|
2018-01-01 13:52:15 +00:00
|
|
|
par = params.require(:recruit_profile).permit!
|
2018-01-02 09:00:53 +00:00
|
|
|
if par[:employee_profile_attributes].present? && par[:employee_profile_attributes][:skills].present?
|
2018-01-01 13:52:15 +00:00
|
|
|
par[:employee_profile_attributes][:skills] = par[:employee_profile_attributes][:skills].split(",")
|
|
|
|
par[:employee_profile_attributes][:skills].collect!{|sk| sk.strip}
|
|
|
|
end
|
2018-01-17 18:22:24 +00:00
|
|
|
# debugger
|
2018-01-01 13:52:15 +00:00
|
|
|
par
|
|
|
|
end
|
|
|
|
|
|
|
|
def employee_academic_params
|
|
|
|
params.require(:employee_academic).permit!
|
|
|
|
end
|
|
|
|
|
|
|
|
def employee_exp_params
|
|
|
|
params.require(:employee_experience).permit!
|
2017-12-21 19:41:50 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def recruitment_job_params
|
2017-12-26 13:07:35 +00:00
|
|
|
par = params.require(:recruitment_job).permit!
|
2018-01-16 12:06:04 +00:00
|
|
|
if par[:skills].present?
|
2017-12-29 12:00:33 +00:00
|
|
|
par[:skills] = par[:skills].split(",")
|
|
|
|
par[:skills].collect!{|sk| sk.strip}
|
2018-01-16 12:06:04 +00:00
|
|
|
elsif par[:skills] == ""
|
|
|
|
par[:skills] = []
|
2017-12-29 12:00:33 +00:00
|
|
|
end
|
2017-12-26 13:07:35 +00:00
|
|
|
par
|
2017-12-21 19:41:50 +00:00
|
|
|
end
|
|
|
|
|
2018-01-11 12:21:16 +00:00
|
|
|
def recommendation_params
|
|
|
|
params.require(:employee_recommendation).permit!
|
|
|
|
end
|
|
|
|
|
2017-12-21 19:41:50 +00:00
|
|
|
end
|