ranjith-dev #788
@@ -2,6 +2,8 @@
|
|||||||
|
|
||||||
namespace App\Filament\Pages;
|
namespace App\Filament\Pages;
|
||||||
|
|
||||||
|
use App\Mail\VisitorOutMail;
|
||||||
|
use App\Models\EmployeeMaster;
|
||||||
use App\Models\Plant;
|
use App\Models\Plant;
|
||||||
use App\Models\VisitorEntry;
|
use App\Models\VisitorEntry;
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
@@ -15,6 +17,8 @@ use Filament\Forms\Components\Select;
|
|||||||
use Filament\Forms\Components\TextInput;
|
use Filament\Forms\Components\TextInput;
|
||||||
use Filament\Notifications\Notification;
|
use Filament\Notifications\Notification;
|
||||||
use Illuminate\Support\Facades\Auth;
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use App\Mail\VisitorMail;
|
||||||
|
use Illuminate\Support\Facades\Mail;
|
||||||
|
|
||||||
class GateOutEntry extends Page implements HasForms
|
class GateOutEntry extends Page implements HasForms
|
||||||
{
|
{
|
||||||
@@ -162,6 +166,16 @@ class GateOutEntry extends Page implements HasForms
|
|||||||
$entry->out_time = now();
|
$entry->out_time = now();
|
||||||
$entry->save();
|
$entry->save();
|
||||||
|
|
||||||
|
$employee = EmployeeMaster::find($entry->employee_master_id);
|
||||||
|
|
||||||
|
if ($employee && !empty($employee->email)) {
|
||||||
|
Mail::to($employee->email)
|
||||||
|
->send(new VisitorOutMail($entry)); // or ->send()
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
\Log::warning('No email found for employee ID: ' . $entry->employee_master_id);
|
||||||
|
}
|
||||||
|
|
||||||
Notification::make()
|
Notification::make()
|
||||||
->title('Gate Pass Processed')
|
->title('Gate Pass Processed')
|
||||||
->body('Visitor marked as exited.')
|
->body('Visitor marked as exited.')
|
||||||
|
|||||||
63
app/Mail/VisitorOutMail.php
Normal file
63
app/Mail/VisitorOutMail.php
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
<?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;
|
||||||
|
|
||||||
|
class VisitorOutMail extends Mailable
|
||||||
|
{
|
||||||
|
use Queueable, SerializesModels;
|
||||||
|
|
||||||
|
public $entry;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a new message instance.
|
||||||
|
*/
|
||||||
|
public function __construct($entry)
|
||||||
|
{
|
||||||
|
$this->entry = $entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message envelope.
|
||||||
|
*/
|
||||||
|
public function envelope(): Envelope
|
||||||
|
{
|
||||||
|
return new Envelope(
|
||||||
|
subject: 'Visitor Out Notification',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the message content definition.
|
||||||
|
*/
|
||||||
|
public function content(): Content
|
||||||
|
{
|
||||||
|
$greeting = '<b>Dear Sir</b>';
|
||||||
|
|
||||||
|
return new Content(
|
||||||
|
view: 'mail.visitor-out',
|
||||||
|
with: [
|
||||||
|
'company' => 'CRI Digital Manufacturing Solutions',
|
||||||
|
'greeting' => $greeting,
|
||||||
|
'wishes' => 'Thanks & Regards,<br>CRI Digital Manufacturing Solutions',
|
||||||
|
],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the attachments for the message.
|
||||||
|
*
|
||||||
|
* @return array<int, \Illuminate\Mail\Mailables\Attachment>
|
||||||
|
*/
|
||||||
|
public function attachments(): array
|
||||||
|
{
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
}
|
||||||
119
resources/views/mail/visitor-out.blade.php
Normal file
119
resources/views/mail/visitor-out.blade.php
Normal file
@@ -0,0 +1,119 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Visitor Out Notification</title>
|
||||||
|
</head>
|
||||||
|
<body style="margin:0;padding:0;background:#ffffff;font-family:Arial,Helvetica,sans-serif;">
|
||||||
|
|
||||||
|
<table width="100%" cellpadding="0" cellspacing="0" style="background:#ffffff;">
|
||||||
|
<tr>
|
||||||
|
<td align="center">
|
||||||
|
|
||||||
|
<table width="700" cellpadding="0" cellspacing="0" style="background:#ffffff;border:1px solid #e5e7eb;">
|
||||||
|
|
||||||
|
<!-- Header -->
|
||||||
|
<tr>
|
||||||
|
<td style="background:#0f766e;padding:20px;text-align:center;">
|
||||||
|
<h2 style="margin:0;color:#ffffff;">
|
||||||
|
Visitor Out Notification
|
||||||
|
</h2>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Content -->
|
||||||
|
<tr>
|
||||||
|
<td style="padding:25px;">
|
||||||
|
|
||||||
|
<p style="margin-top:0;">
|
||||||
|
{!! $greeting !!}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
A visitor has checked out. Please find the details below:
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<table width="100%" cellpadding="10" cellspacing="0"
|
||||||
|
style="border-collapse:collapse;margin-top:15px;">
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="border:1px solid #d1d5db;width:30%;font-weight:bold;">
|
||||||
|
Visitor Name
|
||||||
|
</td>
|
||||||
|
<td style="border:1px solid #d1d5db;">
|
||||||
|
{{ $entry?->name ?? '-' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="border:1px solid #d1d5db;font-weight:bold;">
|
||||||
|
Mobile Number
|
||||||
|
</td>
|
||||||
|
<td style="border:1px solid #d1d5db;">
|
||||||
|
{{ $entry?->mobile_number ?? '-' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="border:1px solid #d1d5db;font-weight:bold;">
|
||||||
|
Company
|
||||||
|
</td>
|
||||||
|
<td style="border:1px solid #d1d5db;">
|
||||||
|
{{ $entry?->company ?? '-' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="border:1px solid #d1d5db;font-weight:bold;">
|
||||||
|
Purpose of Visit
|
||||||
|
</td>
|
||||||
|
<td style="border:1px solid #d1d5db;">
|
||||||
|
{{ $entry?->purpose_of_visit ?? '-' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="border:1px solid #d1d5db;font-weight:bold;">
|
||||||
|
No of Persons
|
||||||
|
</td>
|
||||||
|
<td style="border:1px solid #d1d5db;">
|
||||||
|
{{ $entry?->number_of_person ?? '-' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td style="border:1px solid #d1d5db;font-weight:bold;">
|
||||||
|
Out Time
|
||||||
|
</td>
|
||||||
|
<td style="border:1px solid #d1d5db;">
|
||||||
|
{{ $entry?->out_time?->format('d-m-Y h:i A') ?? '-' }}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<br>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
{!! $wishes !!}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<!-- Footer -->
|
||||||
|
<tr>
|
||||||
|
<td style="padding:15px;text-align:center;border-top:1px solid #e5e7eb;font-size:12px;color:#666;">
|
||||||
|
© {{ date('Y') }} {{ $company }}<br>
|
||||||
|
Visitor Management System
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Reference in New Issue
Block a user