class Admin::RecruitmentsController < OrbitAdminController def index @job_postings = RecruitmentJob.jobs.count @internship_postings = RecruitmentJob.internships.count @exchange_postings = RecruitmentJob.exchanges.count @total_employees = EmployeeProfile.count @total_employers = EmployerProfile.count @total_position_filled = RecruitmentJob.filled.count end def load_chart month = params[:month].present? ? params[:month] : Time.now.month year = params[:year].present? ? params[:year] : Time.now.year case params[:type] when "posting" @startdt = DateTime.parse("#{year}/#{month}") if month.to_i < 12 enddt = DateTime.parse("#{year}/#{month.to_i + 1}") else enddt = DateTime.parse("#{year.to_i + 1}/1") end @data = {} @data[t("recruitment.post_t.type1")] = RecruitmentJob.jobs.where(:created_at.gte => @startdt, :created_at.lt => enddt).count @data[t("recruitment.post_t.type2")] = RecruitmentJob.internships.where(:created_at.gte => @startdt, :created_at.lt => enddt).count @data[t("recruitment.post_t.type3")] = RecruitmentJob.exchanges.where(:created_at.gte => @startdt, :created_at.lt => enddt).count when "registration" @startdt = DateTime.parse("#{year}/#{month}") if month.to_i < 12 enddt = DateTime.parse("#{year}/#{month.to_i + 1}") else enddt = DateTime.parse("#{year.to_i + 1}/1") end @data = {} @data[t("recruitment.user_type.type1")] = RecruitProfile.employees.where(:created_at.gte => @startdt, :created_at.lt => enddt).count @data[t("recruitment.user_type.type2")] = RecruitProfile.employers.where(:created_at.gte => @startdt, :created_at.lt => enddt).count when "filled" @startdt = DateTime.parse("#{year}/#{month}") if month.to_i < 12 enddt = DateTime.parse("#{year}/#{month.to_i + 1}") else enddt = DateTime.parse("#{year.to_i + 1}/1") end @data = {} @data[t("recruitment.post_t.type1")] = RecruitmentJob.jobs.filled.where(:created_at.gte => @startdt, :created_at.lt => enddt).count @data[t("recruitment.post_t.type2")] = RecruitmentJob.internships.filled.where(:created_at.gte => @startdt, :created_at.lt => enddt).count @data[t("recruitment.post_t.type3")] = RecruitmentJob.exchanges.filled.where(:created_at.gte => @startdt, :created_at.lt => enddt).count end render :layout => false end def member_management @filter_fields = {:user_type => [{:title => t("recruitment.user_type.type1"), :id => "1"},{:title => t("recruitment.user_type.type2"), :id => "2"}]} @table_fields = ["recruitment.name", "recruitment.user_type_title", "recruitment.actions"] if params[:filters].present? && params[:filters]["user_type"].present? numbers = params[:filters]["user_type"].collect{|ut| ut.to_i} @users = RecruitProfile.where(:user_type.in => numbers).order_by(sort) else @users = RecruitProfile.all.order_by(sort) end @users = search_data(@users,[:pseudo_member_id, :email, :first_name, :last_name]).page(params[:page]).per(10) if request.xhr? render :partial => "member_index" end end def postings @filter_fields = {:application_type => [{:title => "recruitment.post_t.type1", :id => "type1"},{:title => "recruitment.post_t.type2", :id => "type2"},{:title => "recruitment.post_t.type3", :id => "type3"}]} @table_fields = ["recruitment.job_title", "recruitment.company_name", "recruitment.position_filled", "recruitment.number_of_applicants", "recruitment.post_type", "recruitment.actions"] if params[:filters].present? && params[:filters]["application_type"].present? @jobs = RecruitmentJob.where(:post_type.in => params[:filters]["application_type"]) else @jobs = RecruitmentJob.all end @jobs = search_data(@jobs,[:job_title]).page(params[:page]).per(10) if request.xhr? render :partial => "posting_index" end end def show_member @user = RecruitProfile.find(params[:id]) @profile = @user.profile end def applications @job = RecruitmentJob.find(params[:id]) @applications = EmployeeJobApplication.where(:job => @job.id.to_s).not_archived @table_fields = ["recruitment.name", "recruitment.applied_date"] end def member_applications @user = RecruitProfile.find(params[:id]) profile = @user.profile @applications = profile.employee_job_applications.not_archived @table_fields = ["recruitment.job_title", "recruitment.company_name", "recruitment.applied_date", "recruitment.post_type"] end def company_postings @user = RecruitProfile.find(params[:id]) profile = @user.profile @jobs = profile.recruitment_jobs @filter_fields = {:application_type => [{:title => "recruitment.post_t.type1", :id => "type1"},{:title => "recruitment.post_t.type2", :id => "type2"},{:title => "recruitment.post_t.type3", :id => "type3"}]} @table_fields = ["recruitment.job_title", "recruitment.company_name", "recruitment.position_filled", "recruitment.number_of_applicants", "recruitment.post_type", "recruitment.actions"] if params[:filters].present? && params[:filters]["application_type"].present? @jobs = @jobs.where(:post_type.in => params[:filters]["application_type"]) end @jobs = search_data(@jobs,[:job_title]).page(params[:page]).per(10) if request.xhr? render :partial => "posting_index" end end def delete_user user = RecruitProfile.find(params[:id]) if params[:status].present? if params[:status] == "disable" user.disable_user elsif params[:status] == "enable" user.enable_user end else pu = PseudoUser.where(:user_name => user.pseudo_member_id).first user.destroy pu.destroy end redirect_to member_management_admin_recruitments_path(:page => params[:page]) end def industries @industries = RecruitmentIndustry.all end def addindustry @industry = RecruitmentIndustry.new render :layout => false end def createindustry industry = RecruitmentIndustry.create(industry_params) redirect_to industries_admin_recruitments_path end def editindustry @industry = RecruitmentIndustry.find(params[:id]) render :layout => false end def updateindustry industry = RecruitmentIndustry.find(params[:id]) industry.update_attributes(industry_params) redirect_to industries_admin_recruitments_path end def deleteindustry industry = RecruitmentIndustry.find(params[:id]) industry.destroy redirect_to industries_admin_recruitments_path end def categories @categories = RecruitmentCategory.all end def addcategory @category = RecruitmentCategory.new render :layout => false end def createcategory category = RecruitmentCategory.create(category_params) redirect_to categories_admin_recruitments_path end def editcategory @category = RecruitmentCategory.find(params[:id]) render :layout => false end def updatecategory category = RecruitmentCategory.find(params[:id]) category.update_attributes(category_params) redirect_to categories_admin_recruitments_path end def deletecategory category = RecruitmentCategory.find(params[:id]) category.destroy redirect_to categories_admin_recruitments_path end private def industry_params params.require(:recruitment_industry).permit! end def category_params params.require(:recruitment_category).permit! end end