added application flow and completed show pages

This commit is contained in:
Harry Bomrah 2018-01-03 02:30:32 +08:00
parent e3bdb3148a
commit 47772a6417
13 changed files with 311 additions and 80 deletions

View File

@ -25,6 +25,9 @@
font-weight: bolder;
}
}
.logout {
font-size: 16px;
}
}
ul.nav {

View File

@ -126,8 +126,13 @@ class RecruitmentsController < PseudoSessionController
end
end
def get_show_type
def check_session
page = Page.where(:module => "pseudo_member").first
session = OrbitHelper.request.session
available = session[:current_pseudo_user_id].present? && !session[:current_pseudo_user_id].nil? ? "true" : "false"
{
"session" => available,
"url" => "/" + I18n.locale.to_s + page.url,
"type" => OrbitHelper.params[:page_id]
}
end
@ -135,9 +140,25 @@ class RecruitmentsController < PseudoSessionController
def show_candidate(params)
rp = RecruitProfile.where(:uid => params[:uid]).first
profile = rp.profile
phone = !profile.country_code.nil? ? profile.country_code + " - " + profile.phone_number : profile.phone_number
skills = profile.skills
phone = !profile.country_code.nil? ? "+" + profile.country_code + " - " + profile.phone_number : profile.phone_number
skills = profile.skills.collect{|skill| {"skill-name" => skill}} if !profile.skills.empty?
infos = []
["autobiography", "resume_content", "recommendation1_info", "recommendation2_info"].each do |t|
if !profile.send(t).nil? && profile.send(t) != ""
infos << {
"title" => t("recruitment.#{t}"),
"text" => simple_format(profile.send(t))
}
end
end
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
{
"skills" => skills,
"infos" => infos,
"data" => {
"name" => rp.name,
"job-title" => profile.desired_job_title,
@ -145,7 +166,21 @@ class RecruitmentsController < PseudoSessionController
"phone" => phone,
"email" => rp.email,
"website" => profile.website,
"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"),
"martial" => t("recruitment.martial.#{profile.marital_status}"),
"language-title" => t("recruitment.language_title"),
"language" => profile.languages,
"workingtime-title" => t("recruitment.workingtime_title"),
"workingtime" => t("recruitment.working_time.#{profile.working_time}")
}
}
end
@ -160,7 +195,7 @@ class RecruitmentsController < PseudoSessionController
"text" => simple_format(profile.company_profile)
}
end
["job_description", "responsibility", "other_conditions"].each do |jj|
["job_description", "other_conditions"].each do |jj|
if !job.send(jj).nil? && job.send(jj) != ""
infos << {
"title" => t("recruitment.#{jj}"),
@ -189,6 +224,19 @@ class RecruitmentsController < PseudoSessionController
else
holiday = t("recruitment.not_available")
end
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)
applybtn = "<a href='#' id='jobApplicationBtn' class='btn btn-primary'>Apply</a>"
else
applybtn = "<a href='#' disabled='disabled' class='btn btn-success'>Already Applied</a>"
end
end
end
{
"infos" => infos,
"data" => {
@ -220,6 +268,8 @@ class RecruitmentsController < PseudoSessionController
"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,
"apply-btn" => applybtn,
"job-id" => job.id.to_s
}
}
end
@ -232,6 +282,20 @@ class RecruitmentsController < PseudoSessionController
end
end
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
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]}
@ -239,6 +303,17 @@ class RecruitmentsController < PseudoSessionController
render :layout => false
end
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
def select_profile
end

View File

@ -3,9 +3,13 @@ class EmployeeJobApplication
include Mongoid::Timestamps
field :job
field :cover_letter
field :archived, type: Boolean, :default => false
belongs_to :employee_profile
scope :not_archived, ->{ where(:archived => false) }
def get_job
RecruitmentJob.find(self.job) rescue nil
end

View File

@ -42,6 +42,10 @@ class EmployeeProfile
scope :job_seekers, ->{where(:active => true)}
def is_job_applied?(jobid)
self.employee_job_applications.where(:job => jobid).count > 0
end
def get_avatar
if self.avatar.url.nil?
return "/assets/person.png"

View File

@ -35,4 +35,8 @@ class RecruitmentJob
RecruitmentCategory.find(self.category).job_category rescue ""
end
def get_application_count
EmployeeJobApplication.where(:job => self.id.to_s).not_archived.count
end
end

View File

@ -1,4 +1,7 @@
<h3>Welcome <strong><%= @profile.name %></strong>!</h3>
<h3>
Welcome <strong><%= @profile.name %></strong>!
<div class="pull-right logout"><a href="/pseudo_users/logoutpseudouser">Logout</a></div>
</h3>
<ul class="nav nav-tabs">
<% if @profile.is_employer? %>
<li role="presentation" class="<%= params[:action] == "recruitment_dashboard" ? "active" : "" %>"><a href="<%= mydashboard_path %>">Jobs</a></li>

View File

@ -17,7 +17,13 @@
<td><a href="<%= @page + "/" + job.to_param %>" target="_blank"><%= job.job_title %></a></td>
<td><%= job.created_at.strftime("%Y-%m-%d") %></td>
<td><%= job.filled ? "Yes" : "No" %></td>
<td><button class="btn btn-info">Show</button></td>
<td>
<% job_count = job.get_application_count %>
<% if job_count > 0 %>
<a href="/recruit/<%= job.id.to_s %>/job_applications" class="btn btn-danger">Show (<%= job_count %>)</a></td>
<% else %>
<a href="#" disabled="disabled" class="btn btn-info">Show</a></td>
<% end %>
<td>
<a href="/recruit/<%= job.id.to_s %>/editjob" class="btn btn-warning">Edit</a>
<% if !job.filled %>

View File

@ -33,17 +33,7 @@
<div class="form-group">
<%= fe.label locale, "Job Description", :class => "col-sm-2 control-label" %>
<div class="col-sm-5">
<%= fe.text_area locale, :class => "form-control", :value => @job.job_description_translations[locale] %>
</div>
</div>
<% end %>
<!-- Responsibility -->
<%= f.fields_for :responsibility_translations do |fe| %>
<div class="form-group">
<%= fe.label locale, "Job Responsibility", :class => "col-sm-2 control-label" %>
<div class="col-sm-5">
<%= fe.text_area locale, :class => "form-control", :value => @job.responsibility_translations[locale] %>
<%= fe.text_area locale, :rows=>5, :class => "form-control", :value => @job.job_description_translations[locale] %>
</div>
</div>
<% end %>
@ -53,7 +43,7 @@
<div class="form-group">
<%= fe.label locale, "Other Conditions", :class => "col-sm-2 control-label" %>
<div class="col-sm-5">
<%= fe.text_area locale, :class => "form-control", :value => @job.other_conditions_translations[locale] %>
<%= fe.text_area locale, :rows=>5, :class => "form-control", :value => @job.other_conditions_translations[locale] %>
</div>
</div>
<% end %>
@ -148,19 +138,13 @@
<!-- Joining Day -->
<div class="form-group">
<label class="col-sm-2 control-label">Joining Time</label>
<label class="col-sm-2 control-label">Joining Period</label>
<div class="col-sm-8">
<label for="recruitment_job_joining_time_type1" class="control-label radio-label">
<%= f.radio_button :joining_time, "type1" %> Immediate
<%= f.radio_button :joining_time, "type1" %> Within a month
</label>
<label for="recruitment_job_joining_time_type2" class="control-label radio-label">
<%= f.radio_button :joining_time, "type2" %> Within a week
</label>
<label for="recruitment_job_joining_time_type3" class="control-label radio-label">
<%= f.radio_button :joining_time, "type3" %> Within a month
</label>
<label for="recruitment_job_joining_time_type4" class="control-label radio-label">
<%= f.radio_button :joining_time, "type4" %> More than a month
<%= f.radio_button :joining_time, "type2" %> More than a month
</label>
</div>
</div>
@ -192,13 +176,13 @@
<div class="form-group">
<%= f.label :work_experience_years, "Work Experience", :class => "col-sm-2 control-label" %>
<div class="col-sm-7">
<label for="recruitment_job_work_experience_years">
<%= f.number_field :work_experience_years, :class => "col-sm-3", :max => 50, :min => 0, :value => 0 %> Years
</label>
<label for="recruitment_job_work_experience_months">
<%= f.number_field :work_experience_months, :class => "col-sm-3", :max => 11, :min => 0, :value => 0 %> Months
</label>
<div class="col-sm-3">
<%= f.number_field :work_experience_years, :class => "form-control", :max => 50, :min => 0, :value => 0 %>
<label for="recruitment_job_work_experience_years">Years</label>
</div>
<div class="col-sm-3">
<%= f.number_field :work_experience_months, :class => "form-control", :max => 11, :min => 0, :value => 0 %>
<label for="recruitment_job_work_experience_months">Months</label>
</div>
</div>

View File

@ -1,36 +1,45 @@
<%= render_view %>
<% thissession = action_data("check_session") %>
<% if thissession["session"] == "true" %>
<%= render_view %>
<!-- Modal -->
<div class="modal fade" id="advancedSearch" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="ajax-content"><div style="margin-top:15px; text-align: center;">Loading...</div></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="searchBtn"><i class="fa fa-search" aria-hidden="true"></i> Search</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var searchBox = $("#advancedSearch");
$("#advancedSearchBtn").on("click",function(){
searchBox.modal("show");
if( searchBox.find(".ajax-content").data("loaded") != "false") {
$.ajax({
url : "/recruit/advancedform",
dataType : "html",
type : "get"
}).done(function(html){
searchBox.find(".ajax-content").html(html);
searchBox.find(".ajax-content").attr("data-loaded","true");
})
}
return false;
})
$("#searchBtn").on("click",function(){
$("#advancedSearchForm").find(":input").filter(function(){ return !this.value; }).attr("disabled", "disabled");
$("#advancedSearchForm").submit();
})
</script>
<% elsif thissession["session"] == "false" %>
<div>Please login to view this page. <a href="<%= thissession["url"] %>">Login</a></div>
<script type="text/javascript">
window.location.href = "<%= thissession["url"] %>";
</script>
<% end %>
<!-- Modal -->
<div class="modal fade" id="advancedSearch" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="ajax-content"><div style="margin-top:15px; text-align: center;">Loading...</div></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="searchBtn"><i class="fa fa-search" aria-hidden="true"></i> Search</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var searchBox = $("#advancedSearch");
$("#advancedSearchBtn").on("click",function(){
searchBox.modal("show");
if( searchBox.find(".ajax-content").data("loaded") != "false") {
$.ajax({
url : "/recruit/advancedform",
dataType : "html",
type : "get"
}).done(function(html){
searchBox.find(".ajax-content").html(html);
searchBox.find(".ajax-content").attr("data-loaded","true");
})
}
return false;
})
$("#searchBtn").on("click",function(){
$("#advancedSearchForm").find(":input").filter(function(){ return !this.value; }).attr("disabled", "disabled");
$("#advancedSearchForm").submit();
})
</script>

View File

@ -0,0 +1,66 @@
<style type="text/css">
#cover_letter_box .modal-dialog{
z-index: 1100;
}
</style>
<div id="dashboard-wrapper">
<%= render :partial => "dashboard_header" %>
<table class="table table-striped jobs-table">
<thead>
<tr>
<th>Candidate Name</th>
<th>Application Date</th>
<th>Cover Letter</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<% @applications.each do |application| %>
<% profile = application.employee_profile %>
<tr>
<td><a target="_blank" href="/<%= I18n.locale.to_s %>/candidates/<%= profile.recruit_profile.to_param %>"><%= profile.recruit_profile.name %></a></td>
<td><%= application.created_at.strftime("%d %B %Y") %></td>
<td>
<% if !application.cover_letter.nil? && application.cover_letter != "" %>
<a href="" for="<%= profile.recruit_profile.name %>" class="cover-letter-btn">Cover Letter</a><div style="display: none;"><%= application.cover_letter %></div>
<% else %>
<a href="" disabled="disabled" class="">Cover Letter</a>
<% end %>
</td>
<td><a class="btn btn-danger archive-button" href="/recruit/<%= application.id.to_s %>/archive_application">Delete</a></td>
</tr>
<% end %>
</tbody>
</table>
<div class="modal fade" id="cover_letter_box" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body"></div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var letterBox = $("#cover_letter_box");
$(".cover-letter-btn").on("click",function(){
var name = $(this).attr("for"),
letter = $(this).parent().find("div").html();
letterBox.find(".modal-body").html(letter);
letterBox.find(".modal-title").text(name + " ~ Cover Letter");
letterBox.modal("show");
return false;
})
$(".archive-button").on("click",function(){
if(!confirm("You can not undo once application is deleted. Are you sure?")){
return false;
}
})
</script>

View File

@ -1,6 +1,63 @@
<% data = action_data("get_show_type") %>
<% if data["type"] == "jobs" %>
<%= render_view %>
<% elsif data["type"] == "candidates" %>
<%= render_view("candidate_show") %>
<% end %>
<% data = action_data("check_session") %>
<% if data["session"] == "true" %>
<% if data["type"] == "jobs" %>
<%= render_view %>
<style type="text/css">
#applyForm .modal-dialog{
z-index: 1100;
}
#applicationform{
padding: 10px;
}
</style>
<!-- Modal -->
<div class="modal fade" id="applyForm" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title" id="myModalLabel">{{job-title}}</h4>
</div>
<div class="modal-body">
<form id="applicationform" action="/recruit/applyjob" method="post" class="form-horizontal">
<div class="form-group adv-search-bar">
<label for="cover-letter">Please write a cover letter</label>
<textarea id="cover-letter" placeholder="Cover Letter" name="cover_letter" rows="5" class="form-control"></textarea>
<div class="alert alert-warning">Your CV and Rest of your profile will be sent along with it.</div>
</div>
<input type="hidden" name="job_id" id="jobid" value="">
<input type="hidden" name="authenticity_token" value="<%= form_authenticity_token %>">
</form>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary" id="applyBtn">Apply</button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
var formModal = $("#applyForm");
$("#jobApplicationBtn").on("click",function(){
var jobid = $(this).parent().data("jobid"),
title = $(this).parent().data("jobtitle")
formModal.find("#jobid").val(jobid);
formModal.find(".modal-title").text(title);
formModal.modal("show");
return false;
})
$("#applyBtn").on("click",function(){
formModal.find("form").submit();
})
</script>
<% elsif data["type"] == "candidates" %>
<%= render_view("candidate_show") %>
<% end %>
<% else %>
<div>Please login to view this page. <a href="<%= data["url"] %>">Login</a></div>
<script type="text/javascript">
window.location.href = "<%= data["url"] %>";
</script>
<% end %>

View File

@ -25,10 +25,25 @@ en:
joining: Joining Time
worktype_title: Work Type
language: Language Requirements
language_title: Languages
workingtime_title: Working Time
holiday_title: Holiday
fresher: Fresher
advanced_search: Advanced Search
autobiography: Autobiography
resume_content: Resume
recommendation1_info: Recommendation (First)
recommendation2_info: Recommendation (Second)
resume_text: Download CV
gender_title: Gender
martial_title: Martial Status
martial:
type1: Un-Married
type2: Married
gender:
type1: Male
type2: Female
type3: Other
salary:
type1: Negotiable
type2: According to company rules
@ -44,10 +59,8 @@ en:
type1: According to company rules
type2: Other
joining_time:
type1: Immediate
type2: Within a week
type3: Within a month
type4: More than a month
type1: Within a month
type2: More than a month
work_type:
type1: Office Worker
type2: Graduate

View File

@ -49,6 +49,9 @@ Rails.application.routes.draw do
post "/create_experience", to: "recruitments#create_experience"
patch "/:id/update_exmployee_experience", to: "recruitments#update_exmployee_experience"
get "/:id/edit_employee_experience", to: "recruitments#edit_employee_experience"
post "/applyjob", to: "recruitments#applyjob"
get "/:id/job_applications", to: "recruitments#job_applications"
get "/:id/archive_application", to: "recruitments#archive_application"
end
end
end