1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Http\Controllers; |
4
|
|
|
|
5
|
|
|
use App\Http\Controllers\Controller; |
6
|
|
|
use App\Models\JobPoster; |
7
|
|
|
use App\Models\HrAdvisor; |
8
|
|
|
use Illuminate\Http\Request; |
9
|
|
|
use Illuminate\Support\Facades\Auth; |
10
|
|
|
use Illuminate\Support\Facades\Lang; |
11
|
|
|
|
12
|
|
|
class JobSummaryController extends Controller |
13
|
|
|
{ |
14
|
|
|
/** |
15
|
|
|
* Display the specified job summary. |
16
|
|
|
* |
17
|
|
|
* @param \Illuminate\Http\Request $request Incoming request object. |
18
|
|
|
* @param \App\Models\JobPoster $job Job Poster object. |
19
|
|
|
* @return \Illuminate\Http\Response |
20
|
|
|
*/ |
21
|
|
|
public function show(Request $request, JobPoster $job) |
22
|
|
|
{ |
23
|
|
|
$user = Auth::user(); |
24
|
|
|
|
25
|
|
|
$applications = $job->submitted_applications; |
26
|
|
|
$advisor = $user->hr_advisor; |
27
|
|
|
$jobIsClaimed = ($advisor !== null) && |
28
|
|
|
$advisor->claimed_job_ids->contains($job->id); |
29
|
|
|
|
30
|
|
|
$summaryLang = Lang::get('hr_advisor/job_summary'); |
31
|
|
|
|
32
|
|
|
$job_review_data = [ |
33
|
|
|
'imgSrc' => '/images/job-process-summary-tool-edit.svg', |
34
|
|
|
'imgAlt' => "{$summaryLang['edit_poster_icon']} {$summaryLang['flat_icons']}", |
35
|
|
|
'text' => $summaryLang['edit_poster_button'], |
36
|
|
|
'url' => route('hr_advisor.jobs.review', $job), |
|
|
|
|
37
|
|
|
'disabled' => false, |
38
|
|
|
]; |
39
|
|
|
|
40
|
|
|
$job_preview_data = [ |
41
|
|
|
'imgSrc' => '/images/job-process-summary-tool-view.svg', |
42
|
|
|
'imgAlt' => "{$summaryLang['view_poster_icon']} {$summaryLang['flat_icons']}", |
43
|
|
|
'text' => $summaryLang['view_poster_button'], |
44
|
|
|
'url' => route('hr_advisor.jobs.preview', $job), |
45
|
|
|
'disabled' => false, |
46
|
|
|
]; |
47
|
|
|
|
48
|
|
|
$screening_plan_data = [ |
49
|
|
|
'imgSrc' => '/images/job-process-summary-tool-screen.svg', |
50
|
|
|
'imgAlt' => "{$summaryLang['screening_plan_icon']} {$summaryLang['flat_icons']}", |
51
|
|
|
'text' => $summaryLang['screening_plan_button'], |
52
|
|
|
'url' => route('hr_advisor.jobs.screening_plan', $job), |
53
|
|
|
'disabled' => false |
54
|
|
|
]; |
55
|
|
|
|
56
|
|
|
$view_applicants_data = [ |
57
|
|
|
'imgSrc' => '/images/job-process-summary-tool-applicants.svg', |
58
|
|
|
'imgAlt' => "{$summaryLang['view_applicants_icon']} {$summaryLang['flat_icons']}", |
59
|
|
|
'text' => $summaryLang['view_applicants_button'], |
60
|
|
|
'url' => route('hr_advisor.jobs.applications', $job), |
61
|
|
|
'disabled' => !$job->isClosed(), |
62
|
|
|
]; |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
|
66
|
|
|
switch ($job->job_poster_status->name) { |
67
|
|
|
case 'draft': |
68
|
|
|
$status = Lang::get('common/lookup/job_status.draft'); |
69
|
|
|
break; |
70
|
|
|
case 'review_hr': |
71
|
|
|
case 'review_manager': |
72
|
|
|
$status = Lang::get('common/lookup/job_status.in_review'); |
73
|
|
|
break; |
74
|
|
|
case 'translation': |
75
|
|
|
$status = Lang::get('common/lookup/job_status.in_translation'); |
76
|
|
|
break; |
77
|
|
|
case 'final_review_manager': |
78
|
|
|
case 'final_review_hr': |
79
|
|
|
$status = Lang::get('common/lookup/job_status.final_review'); |
80
|
|
|
break; |
81
|
|
|
case 'approved': |
82
|
|
|
$status = Lang::get('common/lookup/job_status.approved'); |
83
|
|
|
break; |
84
|
|
|
case 'published': |
85
|
|
|
if ($job->isOpen()) { |
86
|
|
|
$status = Lang::get('common/lookup/job_status.open'); |
87
|
|
|
} elseif ($job->isClosed()) { |
88
|
|
|
$status = Lang::get('common/lookup/job_status.closed'); |
89
|
|
|
} else { |
90
|
|
|
$status = Lang::get('common/lookup/job_status.published'); |
91
|
|
|
} |
92
|
|
|
break; |
93
|
|
|
case 'completed': |
94
|
|
|
$status = Lang::get('common/lookup/job_status.complete'); |
95
|
|
|
break; |
96
|
|
|
} |
97
|
|
|
// TODO: Need to add more descriptions for different statuses |
98
|
|
|
$status_description = |
99
|
|
|
( |
100
|
|
|
$job->job_poster_status->name === 'review_hr' |
101
|
|
|
|| $job->job_poster_status->name === 'review_manager' |
102
|
|
|
|| $job->job_poster_status->name === 'final_review_manager' |
103
|
|
|
|| $job->job_poster_status->name === 'final_review_hr' |
104
|
|
|
) |
105
|
|
|
? $summaryLang['under_review'] |
106
|
|
|
: ''; |
107
|
|
|
|
108
|
|
|
$data = [ |
109
|
|
|
// Localized strings. |
110
|
|
|
'summary' => $summaryLang, |
111
|
|
|
'job_status' => $status, |
|
|
|
|
112
|
|
|
'job_status_description' => $status_description, |
113
|
|
|
'is_claimed' => $jobIsClaimed, |
114
|
|
|
// User data. |
115
|
|
|
'user' => $user, |
116
|
|
|
// Job Poster data. |
117
|
|
|
'job' => $job, |
118
|
|
|
// Application data. |
119
|
|
|
'applications' => $applications, |
120
|
|
|
// TODO: Add Routes. |
121
|
|
|
'send_manager' => '', //route('hr_advisor.jobs.setJobStatus', ['jobPoster'=> $job, 'status' => 'review_manager']), |
122
|
|
|
'send_translation' => '', //route('hr_advisor.jobs.setJobStatus', ['jobPoster'=> $job, 'status' => 'translation']), |
123
|
|
|
'approve_publishing' => '', //route('hr_advisor.jobs.setJobStatus', ['jobPoster'=> $job, 'status' => 'approved']), |
124
|
|
|
|
125
|
|
|
'job_review_data' => $job_review_data, |
126
|
|
|
'job_preview_data' => $job_preview_data, |
127
|
|
|
'screening_plan_data' => $screening_plan_data, |
128
|
|
|
'view_applicants_data' => $view_applicants_data, |
129
|
|
|
'relinquish_job' => route('hr_advisor.jobs.unclaim', $job), |
130
|
|
|
]; |
131
|
|
|
|
132
|
|
|
return view( |
|
|
|
|
133
|
|
|
'hr_advisor/job_summary', |
134
|
|
|
$data |
135
|
|
|
); |
136
|
|
|
} |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Unclaim a Job Poster. |
140
|
|
|
* |
141
|
|
|
* @param \Illuminate\Http\Request $request Incoming request object. |
142
|
|
|
* @param \App\Models\JobPoster $job |
143
|
|
|
* @return \Illuminate\Http\Response |
144
|
|
|
*/ |
145
|
|
|
public function unclaimJob(Request $request, JobPoster $job) |
146
|
|
|
{ |
147
|
|
|
$hrAdvisor = $request->user()->hr_advisor; |
148
|
|
|
$hrAdvisor->claimed_jobs()->detach($job); |
149
|
|
|
|
150
|
|
|
return redirect()->route('hr_advisor.jobs.index'); |
|
|
|
|
151
|
|
|
} |
152
|
|
|
} |
153
|
|
|
|