Added mail pages for invoice in transit
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / review (pull_request) Failing after 43s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Laravel Pint / pint (pull_request) Successful in 1m57s
Laravel Larastan / larastan (pull_request) Failing after 2m52s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / review (pull_request) Failing after 43s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 11s
Laravel Pint / pint (pull_request) Successful in 1m57s
Laravel Larastan / larastan (pull_request) Failing after 2m52s
This commit is contained in:
117
app/Mail/InvoiceTransitMail.php
Normal file
117
app/Mail/InvoiceTransitMail.php
Normal file
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace App\Mail;
|
||||
|
||||
use Carbon\Carbon;
|
||||
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 InvoiceTransitMail extends Mailable
|
||||
{
|
||||
use Queueable, SerializesModels;
|
||||
|
||||
public $scheduleType;
|
||||
|
||||
public $tableData;
|
||||
|
||||
public $mailSubject;
|
||||
|
||||
/**
|
||||
* Create a new message instance.
|
||||
*/
|
||||
public function __construct($scheduleType, $tableData, $mailSubject)
|
||||
{
|
||||
$this->scheduleType = $scheduleType;
|
||||
$this->tableData = $tableData ?? [];
|
||||
$this->mailSubject = $mailSubject ?? 'Invoice In Transit';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message envelope.
|
||||
*/
|
||||
public function envelope(): Envelope
|
||||
{
|
||||
return new Envelope(
|
||||
subject: $this->mailSubject,
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the message content definition.
|
||||
*/
|
||||
// public function content(): Content
|
||||
// {
|
||||
// return new Content(
|
||||
// view: 'view.name',
|
||||
// );
|
||||
// }
|
||||
|
||||
public function content(): Content
|
||||
{
|
||||
$greeting = 'Dear Sir/Madam,<br><br>We are sending here with list of pending sale invoices currently in transit.';
|
||||
|
||||
if (strtolower($this->scheduleType) == 'daily') {
|
||||
|
||||
$dates = collect($this->tableData)
|
||||
->pluck('lr_bl_aw_date')
|
||||
->filter()
|
||||
->map(fn ($d) => Carbon::parse($d));
|
||||
|
||||
if ($dates->isNotEmpty()) {
|
||||
$startDate = $dates->min()->startOfDay();
|
||||
}
|
||||
else
|
||||
{
|
||||
$startDate = now()->subDay()->startOfDay();
|
||||
}
|
||||
|
||||
$endDate = now();
|
||||
|
||||
$reportPeriod = "<br><br>"
|
||||
. "Report Period: <b>{$startDate->format('d-m-Y')}</b> "
|
||||
. "to <b>{$endDate->format('d-m-Y')}.</b>"
|
||||
. "<br>Please arrange to receipt the same immediately.";
|
||||
|
||||
$greeting .= $reportPeriod;
|
||||
}
|
||||
|
||||
if ($this->scheduleType == 'Hourly') {
|
||||
$now = now();
|
||||
$fromHour = $now->copy()->subHour()->format('H:i:s');
|
||||
$toHour = $now->format('H:i:s');
|
||||
$reportDate = $now->format('d/m/Y');
|
||||
$greeting .= "from: $reportDate, $fromHour to $toHour. <br><br>Please arrange to receipt the same immediately.";
|
||||
}
|
||||
|
||||
if ($this->scheduleType == 'Live') {
|
||||
$now = now();
|
||||
$fromMinute = $now->copy()->subMinute()->format('d/m/Y H:i:s');
|
||||
$toMinute = $now->format('d/m/Y H:i:s');
|
||||
$greeting .= "from: $fromMinute to $toMinute. <br><br>Please arrange to receipt the same immediately.";
|
||||
}
|
||||
|
||||
return new Content(
|
||||
view: 'mail.invoice-in-transit-report',
|
||||
with: [
|
||||
'company' => 'CRI Digital Manufacturing Solutions',
|
||||
'greeting' => $greeting,
|
||||
'tableData' => $this->tableData,
|
||||
'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 [];
|
||||
}
|
||||
}
|
||||
123
resources/views/mail/invoice-in-transit-report.blade.php
Normal file
123
resources/views/mail/invoice-in-transit-report.blade.php
Normal file
@@ -0,0 +1,123 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Invoice Data Report</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: 'Segoe UI', Arial, sans-serif;
|
||||
background-color: #f9fafb;
|
||||
color: #333;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
h2 {
|
||||
color: #215c98;
|
||||
text-align: center;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
width: 100%;
|
||||
font-size: 14px;
|
||||
white-space: nowrap !important;
|
||||
}
|
||||
th, td {
|
||||
border: 1px solid #020813da;
|
||||
padding: 8px 10px;
|
||||
text-align: center;
|
||||
white-space: nowrap !important;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
.td-left {
|
||||
text-align: left !important;
|
||||
}
|
||||
th {
|
||||
background-color: #215c98;
|
||||
color: #fff;
|
||||
white-space: nowrap !important;
|
||||
}
|
||||
tr:nth-child(even) {
|
||||
background-color: #f3f4f6;
|
||||
}
|
||||
.status-wentout {
|
||||
color: #10b981;
|
||||
font-weight: bold;
|
||||
}
|
||||
/* .status-pending {
|
||||
color: #ef4444;
|
||||
font-weight: bold;
|
||||
} */
|
||||
.status-pending-yellow {
|
||||
color: #eab308;
|
||||
font-weight: bold;
|
||||
}
|
||||
.status-pending-red {
|
||||
color: #ef4444;
|
||||
font-weight: bold;
|
||||
}
|
||||
.footer {
|
||||
text-align: center;
|
||||
font-size: 13px;
|
||||
color: #6b7280;
|
||||
margin-top: 30px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div style="text-align: center; font-weight: bold;">
|
||||
{{ $company }}
|
||||
</div>
|
||||
<br>
|
||||
<p>{!! $greeting !!}</p>
|
||||
<div class="container">
|
||||
@if(empty($tableData))
|
||||
<p style="text-align:center;">No invoice in transit data available.</p>
|
||||
@else
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>No</th>
|
||||
<th>Plant Code</th>
|
||||
<th>Receiving Plant Code</th>
|
||||
<th>Receiving Plant Name</th>
|
||||
<th>Invoice Number</th>
|
||||
<th>Transport Name</th>
|
||||
<th>LR_BL_AW Date</th>
|
||||
<th>Transit Days</th>
|
||||
<th>Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach ($tableData as $row)
|
||||
<tr>
|
||||
<td>{{ $row['no'] }}</td>
|
||||
<td>{{ $row['plant'] }}</td>
|
||||
<td>{{ $row['receiving_plant'] }}</td>
|
||||
<td>{{ $row['receiving_plant_name'] }}</td>
|
||||
<td>{{ $row['invoice_number'] }}</td>
|
||||
<td class="td-left">{{ $row['transport_name'] }}</td>
|
||||
|
||||
<td>
|
||||
@if(!empty($row['lr_bl_aw_date']) && $row['lr_bl_aw_date'] != '-')
|
||||
{{ \Carbon\Carbon::parse($row['lr_bl_aw_date'])->format('d-M-Y') }}
|
||||
@else
|
||||
-
|
||||
@endif
|
||||
</td>
|
||||
{{-- <td>{{ $row['lr_bl_aw_date'] }}</td> --}}
|
||||
<td>{{ $row['transit_days'] }}</td>
|
||||
<td>{{ $row['status'] }}</td>
|
||||
|
||||
{{-- <td class="{{ $row['status_class'] ?? '' }}">
|
||||
{{ $row['status'] }}
|
||||
</td> --}}
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
@endif
|
||||
<p>{!! $wishes !!}</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user