update send mail warning checkin late
This commit is contained in:
parent
d53b786daf
commit
8d8985a6be
|
|
@ -344,13 +344,13 @@ class TicketController extends Controller
|
||||||
$date = Carbon::create($year, $month, $day)->setTimezone(env('TIME_ZONE'));
|
$date = Carbon::create($year, $month, $day)->setTimezone(env('TIME_ZONE'));
|
||||||
|
|
||||||
//Default: ALL
|
//Default: ALL
|
||||||
$start = $date->copy()->setTime(7, 31, 11);
|
$start = $date->copy()->setTime(7, 30, 0);
|
||||||
$end = $date->copy()->setTime(17, 1, 11);
|
$end = $date->copy()->setTime(17, 0, 0);
|
||||||
|
|
||||||
if ($type == 'S') {
|
if ($type == 'S') {
|
||||||
$end = $date->copy()->setTime(11, 31, 11);
|
$end = $date->copy()->setTime(11, 30, 0);
|
||||||
} else if ($type == 'C') {
|
} else if ($type == 'C') {
|
||||||
$start = $date->copy()->setTime(11, 31, 11);
|
$start = $date->copy()->setTime(11, 30, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Tracking::insert([
|
Tracking::insert([
|
||||||
|
|
|
||||||
|
|
@ -2,8 +2,9 @@
|
||||||
|
|
||||||
namespace Modules\Admin\app\Http\Controllers;
|
namespace Modules\Admin\app\Http\Controllers;
|
||||||
|
|
||||||
use App\Helper\Cache\CurrentMonthTimekeeping;
|
use App\Events\WarningChekinLate;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Mail\CheckinLateMail;
|
||||||
use App\Traits\AnalyzeData;
|
use App\Traits\AnalyzeData;
|
||||||
use App\Traits\HasFilterRequest;
|
use App\Traits\HasFilterRequest;
|
||||||
use App\Traits\HasOrderByRequest;
|
use App\Traits\HasOrderByRequest;
|
||||||
|
|
@ -11,6 +12,7 @@ use App\Traits\HasSearchRequest;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use DateTime;
|
use DateTime;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
use Illuminate\Support\Facades\Storage;
|
use Illuminate\Support\Facades\Storage;
|
||||||
use Modules\Admin\app\Models\Admin;
|
use Modules\Admin\app\Models\Admin;
|
||||||
use Modules\Admin\app\Models\MonthlyTimekeeping;
|
use Modules\Admin\app\Models\MonthlyTimekeeping;
|
||||||
|
|
@ -163,14 +165,9 @@ class TrackingController extends Controller
|
||||||
$id = $request->get('id');
|
$id = $request->get('id');
|
||||||
|
|
||||||
$tracking = Tracking::find($id);
|
$tracking = Tracking::find($id);
|
||||||
// $id = $request->get('id');
|
|
||||||
|
|
||||||
// $tracking = Tracking::find($id);
|
$user = Admin::find($tracking->user_id);
|
||||||
// $payload = $request->all();
|
$this->sendCheckinLateMail($user, $tracking->created_at, $tracking->status);
|
||||||
|
|
||||||
// if ($tracking) {
|
|
||||||
// $tracking->update($payload);
|
|
||||||
// }
|
|
||||||
if ($request->hasFile('image')) {
|
if ($request->hasFile('image')) {
|
||||||
$file = $request->file('image');
|
$file = $request->file('image');
|
||||||
$filename = $request->file_name;
|
$filename = $request->file_name;
|
||||||
|
|
@ -203,4 +200,54 @@ class TrackingController extends Controller
|
||||||
'status' => true
|
'status' => true
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// public function sendCheckinLateMail()
|
||||||
|
private function sendCheckinLateMail($user, $time, $status)
|
||||||
|
{
|
||||||
|
// $status = $this->CHECK_IN;
|
||||||
|
// $time =Tracking::find(1)->created_at;
|
||||||
|
// $user = Admin::where('name', 'LE TAN LUAN')->first();
|
||||||
|
if($status === $this->CHECK_IN){
|
||||||
|
$morning_time = Carbon::createFromTimeString('07:30AM')->setTimezone(env('TIME_ZONE'));
|
||||||
|
$morning_condition_time = Carbon::createFromTimeString('07:40AM')->setTimezone(env('TIME_ZONE'));
|
||||||
|
$afternoon_time = Carbon::createFromTimeString('01:00PM')->setTimezone(env('TIME_ZONE'));
|
||||||
|
$afternoon_condition_time = Carbon::createFromTimeString('01:10PM')->setTimezone(env('TIME_ZONE'));
|
||||||
|
$admin_mails = Admin::where('permission', 'like', '%admin%')->pluck('email');
|
||||||
|
|
||||||
|
if ($time->greaterThan($morning_condition_time) && $time->lessThan($afternoon_time))
|
||||||
|
{
|
||||||
|
$period = 'morning';
|
||||||
|
$minutes_late = $morning_time->diffInMinutes($time);
|
||||||
|
$data = array(
|
||||||
|
"email_template" => "email.checkin_late_notification",
|
||||||
|
"email" => $user->email,
|
||||||
|
"name" => $user->name,
|
||||||
|
"admin_mails" => $admin_mails,
|
||||||
|
"message1" => "Your ". $period ." starts ". $minutes_late ." minutes late",
|
||||||
|
"message2" => "You checked in at [" . $time ."]",
|
||||||
|
"url" => env('ADMIN_URL')."/tracking?search=&per_page=10&page=1&timezone=Asia%2FSaigon&name=".$user->name."&time_string=".$time->format("Y-m-d H:i")."&status=check+in",
|
||||||
|
"subject" => "[Management System] Late warning"
|
||||||
|
);
|
||||||
|
Mail::to($user->email)->cc($admin_mails)->send(new CheckinLateMail($data));
|
||||||
|
}
|
||||||
|
|
||||||
|
// if ($time->greaterThan($afternoon_condition_time))
|
||||||
|
// {
|
||||||
|
// $period = 'afternoon';
|
||||||
|
// $minutes_late = $afternoon_time->diffInMinutes($time);
|
||||||
|
// $data = array(
|
||||||
|
// "email_template" => "email.checkin_late_notification",
|
||||||
|
// "email" => $user->email,
|
||||||
|
// "name" => $user->name,
|
||||||
|
// "message1" => "Your ". $period ." starts <b>". $minutes_late ."</b> minutes late",
|
||||||
|
// "message2" => "You checked in at <b>[" . $time ."]</b>",
|
||||||
|
// "url" => env('ADMIN_URL')."/tracking?search=&per_page=10&page=1&timezone=Asia%2FSaigon&name=".$user->name."&time_string=".$time->format("Y-m-d H:i")."&status=check+in",
|
||||||
|
// "subject" => "[Management System] Late warning"
|
||||||
|
// );
|
||||||
|
// Mail::to($user->email)->cc($admin_mails)->send(new CheckinLateMail($data));
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,58 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Mail;
|
||||||
|
|
||||||
|
use Illuminate\Bus\Queueable;
|
||||||
|
use Illuminate\Contracts\Queue\ShouldQueue;
|
||||||
|
use Illuminate\Mail\Mailable;
|
||||||
|
use Illuminate\Mail\Mailables\Content;
|
||||||
|
use Illuminate\Mail\Mailables\Envelope;
|
||||||
|
use Illuminate\Queue\SerializesModels;
|
||||||
|
use Illuminate\Mail\Mailables\Address;
|
||||||
|
|
||||||
|
class CheckinLateMail extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
public $data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new message instance.
|
||||||
|
*/
|
||||||
|
public function __construct($data)
|
||||||
|
{
|
||||||
|
$this->data = $data;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message envelope.
|
||||||
|
*/
|
||||||
|
public function envelope(): Envelope
|
||||||
|
{
|
||||||
|
return new Envelope(
|
||||||
|
// replyTo: [
|
||||||
|
// new Address($this->data["email"], $this->data["name"]),
|
||||||
|
// ],
|
||||||
|
subject: $this->data["subject"],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message content definition.
|
||||||
|
*/
|
||||||
|
public function content(): Content
|
||||||
|
{
|
||||||
|
return new Content(
|
||||||
|
view: ($this->data["email_template"])
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the attachments for the message.
|
||||||
|
*
|
||||||
|
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||||
|
*/
|
||||||
|
public function attachments(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,153 @@
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8" />
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
font-family: "Arial", sans-serif;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
min-height: 100vh;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
background-color: #f7fafc;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
background-color: #fffefe;
|
||||||
|
padding: 2rem 0;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
width: 100vw;
|
||||||
|
}
|
||||||
|
|
||||||
|
.my-0 {
|
||||||
|
margin-bottom: 0;
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
<title>{{ $data['subject'] }}</title>
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<body style="
|
||||||
|
font-family: Arial, Helvetica, sans-serif;
|
||||||
|
background-color: #edf2f7;
|
||||||
|
">
|
||||||
|
<table style="margin: 0 auto">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<table
|
||||||
|
style="
|
||||||
|
margin: 0 auto;
|
||||||
|
width: 768px;
|
||||||
|
">
|
||||||
|
<tr>
|
||||||
|
<td align="center" valign="top" style="padding: 36px 24px;">
|
||||||
|
<a href="{{ config('app.url') }}" target="_blank" style="display: inline-block;">
|
||||||
|
<img src="https://apactech.io/wp-content/uploads/2022/12/APAC-TECH_side-e1670975093601-190x78.png"
|
||||||
|
alt="Logo" border="0" width="100"
|
||||||
|
style="display: block; width: 100px; max-width: 100px; min-width: 48px;">
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<table
|
||||||
|
style="
|
||||||
|
margin: 0 auto;
|
||||||
|
background-color: #ffffff;
|
||||||
|
width: 768px;
|
||||||
|
padding: 24px;
|
||||||
|
">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<h3 style="color: #222222; margin: 5px 0 0 0; font-weight: bold">
|
||||||
|
Hi {{ $data['name'] }},
|
||||||
|
</h3>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p style=" white-space:pre-line; margin: 0; margin-bottom: 5px">
|
||||||
|
{{ $data['message1'] }}
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p style=" white-space:pre-line; margin: 0; margin-bottom: 5px">
|
||||||
|
{{ $data['message2'] }}
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<p style="margin:0 0 16px;padding:5px;margin: 5px;text-align: center;">
|
||||||
|
<a href="{{ $data['url'] }}"
|
||||||
|
style="
|
||||||
|
color: #fff;
|
||||||
|
border-radius: 10px;
|
||||||
|
background-color: rgba(68,115,196);
|
||||||
|
background-image: linear-gradient(to top left,rgba(0,0,0,.2),rgba(0,0,0,.2) 30%,rgba(0,0,0,0));
|
||||||
|
text-decoration: none;
|
||||||
|
display: inline-block;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 16px;
|
||||||
|
line-height: 150%;
|
||||||
|
text-align: center;
|
||||||
|
margin: 0;
|
||||||
|
padding: 10px 12px;
|
||||||
|
">
|
||||||
|
Check now</a>
|
||||||
|
</p>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<table
|
||||||
|
style="
|
||||||
|
margin: 0 auto;
|
||||||
|
|
||||||
|
width: 768px;
|
||||||
|
">
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<h5
|
||||||
|
style="
|
||||||
|
color: #222222;
|
||||||
|
text-align: center;
|
||||||
|
padding: 10px 36px;
|
||||||
|
margin: 0;
|
||||||
|
">
|
||||||
|
<p>© 2024 APAC Tech.</p>
|
||||||
|
</h5>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
</body>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
@ -61,8 +61,8 @@ const data = [
|
||||||
link: '/tracking',
|
link: '/tracking',
|
||||||
label: 'Check in/out',
|
label: 'Check in/out',
|
||||||
icon: IconScan,
|
icon: IconScan,
|
||||||
permissions: 'hr,admin',
|
permissions: 'staff,hr,admin',
|
||||||
group: 'other',
|
group: 'staff',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
link: '/worklogs',
|
link: '/worklogs',
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue