1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace App\Mail; |
4
|
|
|
|
5
|
|
|
use App\Models\JobPoster; |
6
|
|
|
use App\Models\Lookup\CitizenshipDeclaration; |
7
|
|
|
use App\Models\Lookup\VeteranStatus; |
8
|
|
|
use App\Models\User; |
9
|
|
|
use Illuminate\Bus\Queueable; |
10
|
|
|
use Illuminate\Mail\Mailable; |
11
|
|
|
use Illuminate\Queue\SerializesModels; |
12
|
|
|
use Illuminate\Contracts\Queue\ShouldQueue; |
13
|
|
|
use Illuminate\Support\Facades\App; |
14
|
|
|
use Illuminate\Support\Facades\Config; |
15
|
|
|
use Illuminate\Support\Facades\Lang; |
16
|
|
|
|
17
|
|
|
class ScreenCandidatesPrompt extends Mailable implements ShouldQueue |
18
|
|
|
{ |
19
|
|
|
use Queueable, SerializesModels; |
20
|
|
|
|
21
|
|
|
/** |
22
|
|
|
* The Job Poster instance. |
23
|
|
|
* |
24
|
|
|
* @var JobPoster |
25
|
|
|
*/ |
26
|
|
|
public $job; |
27
|
|
|
|
28
|
|
|
/** |
29
|
|
|
* Create a new message instance. |
30
|
|
|
* |
31
|
|
|
* @return void |
32
|
|
|
*/ |
33
|
|
|
public function __construct(JobPoster $job) |
34
|
|
|
{ |
35
|
|
|
$this->job = $job; |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* Build the message. |
40
|
|
|
* |
41
|
|
|
* @return $this |
42
|
|
|
*/ |
43
|
|
|
public function build() |
44
|
|
|
{ |
45
|
|
|
// Get emails of all Hr Advisors who have claimed job. |
46
|
|
|
$hr_advisors_emails = []; |
47
|
|
|
$hr_advisors = $this->job->hr_advisors; |
48
|
|
|
|
49
|
|
|
foreach ($hr_advisors as $advisor) { |
50
|
|
|
$email = User::where('id', $advisor->user_id)->first()->email; |
51
|
|
|
array_push($hr_advisors_emails, $email); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
// Get date 2 weeks after job poster closes. |
55
|
|
|
$dateFormat = Config::get('app.date_format'); |
56
|
|
|
$locale = App::getLocale(); |
57
|
|
|
$timestamp_in_two_weeks = strtotime('+2 weeks', $this->job->close_date_time->timestamp); |
58
|
|
|
$date_in_two_weeks = date($dateFormat[$locale], $timestamp_in_two_weeks); |
59
|
|
|
|
60
|
|
|
// Number of applicants. |
61
|
|
|
$num_of_applicants = $this->job->job_applications->count(); |
62
|
|
|
|
63
|
|
|
// Number of non-citizens. |
64
|
|
|
$canadian_citizen = CitizenshipDeclaration::where('name', 'citizen')->first()->id; |
65
|
|
|
$num_of_noncitizens = $this->job->job_applications |
66
|
|
|
->where('citizenship_declaration_id', '!=', $canadian_citizen) |
67
|
|
|
->count(); |
68
|
|
|
|
69
|
|
|
// Number of veterans. |
70
|
|
|
$non_veteran = VeteranStatus::where('name', 'none')->first()->id; |
71
|
|
|
$num_of_veterans = $this->job->job_applications |
72
|
|
|
->where('veteran_status_id', '!=', $non_veteran) |
73
|
|
|
->count(); |
74
|
|
|
|
75
|
|
|
$position = $this->job->getTranslations('title'); |
76
|
|
|
$classification = $this->job->getClassificationMessageAttribute(); |
77
|
|
|
$subject = Lang::get('common/notifications/screen_candidates.subject', [ 'position' => $position['en'], 'classification' => $classification ]) . ' / ' . Lang::get('common/notifications/screen_candidates.subject', [ 'position' => $position['fr'], 'classification' => $classification ], 'fr'); |
78
|
|
|
|
79
|
|
|
return $this->subject($subject) |
80
|
|
|
->cc($hr_advisors_emails) |
81
|
|
|
->markdown('emails.job_posters.screen_candidates_plain', [ |
82
|
|
|
'drop_off_date' => $date_in_two_weeks, |
83
|
|
|
'manager_portal_link' => [ |
84
|
|
|
'en' => Lang::get('common/notifications/screen_candidates.manager_portal_link'), |
85
|
|
|
'fr' => Lang::get('common/notifications/screen_candidates.manager_portal_link', [], 'fr'), |
86
|
|
|
], |
87
|
|
|
'num_of_applicants' => $num_of_applicants, |
88
|
|
|
'num_of_noncitizens' => $num_of_noncitizens, |
89
|
|
|
'num_of_veterans' => $num_of_veterans, |
90
|
|
|
'position' => $position, |
91
|
|
|
'position_link' => [ |
92
|
|
|
'en' => Lang::get('common/notifications/screen_candidates.position_link', ['id' => $this->job->id]), |
93
|
|
|
'fr' => Lang::get('common/notifications/screen_candidates.position_link', ['id' => $this->job->id], 'fr'), |
94
|
|
|
], |
95
|
|
|
'talent_cloud_email' => config('mail.admin_address'), |
|
|
|
|
96
|
|
|
]); |
97
|
|
|
} |
98
|
|
|
} |
99
|
|
|
|