Merge pull request 'ranjith-dev' (#788) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 24s

Reviewed-on: #788
This commit was merged in pull request #788.
This commit is contained in:
2026-06-24 09:10:36 +00:00
3 changed files with 196 additions and 0 deletions

View File

@@ -2,6 +2,8 @@
namespace App\Filament\Pages;
use App\Mail\VisitorOutMail;
use App\Models\EmployeeMaster;
use App\Models\Plant;
use App\Models\VisitorEntry;
use Carbon\Carbon;
@@ -15,6 +17,8 @@ use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Illuminate\Support\Facades\Auth;
use App\Mail\VisitorMail;
use Illuminate\Support\Facades\Mail;
class GateOutEntry extends Page implements HasForms
{
@@ -162,6 +166,16 @@ class GateOutEntry extends Page implements HasForms
$entry->out_time = now();
$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()
->title('Gate Pass Processed')
->body('Visitor marked as exited.')

View 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 [];
}
}

View 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>