From d959a5d4a77a64babc886f382d9631e4d07391cb Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Sat, 3 Jan 2026 11:59:01 +0530 Subject: [PATCH] Added mail pages for invoice in transit --- app/Mail/InvoiceTransitMail.php | 117 +++++++++++++++++ .../mail/invoice-in-transit-report.blade.php | 123 ++++++++++++++++++ 2 files changed, 240 insertions(+) create mode 100644 app/Mail/InvoiceTransitMail.php create mode 100644 resources/views/mail/invoice-in-transit-report.blade.php diff --git a/app/Mail/InvoiceTransitMail.php b/app/Mail/InvoiceTransitMail.php new file mode 100644 index 0000000..fb548ed --- /dev/null +++ b/app/Mail/InvoiceTransitMail.php @@ -0,0 +1,117 @@ +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,

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 = "

" + . "Report Period: {$startDate->format('d-m-Y')} " + . "to {$endDate->format('d-m-Y')}." + . "
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.

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.

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,
CRI Digital Manufacturing Solutions', + ], + ); + } + + /** + * Get the attachments for the message. + * + * @return array + */ + public function attachments(): array + { + return []; + } +} diff --git a/resources/views/mail/invoice-in-transit-report.blade.php b/resources/views/mail/invoice-in-transit-report.blade.php new file mode 100644 index 0000000..18bd00d --- /dev/null +++ b/resources/views/mail/invoice-in-transit-report.blade.php @@ -0,0 +1,123 @@ + + + + + Invoice Data Report + + + +
+ {{ $company }} +
+
+

{!! $greeting !!}

+
+ @if(empty($tableData)) +

No invoice in transit data available.

+ @else + + + + + + + + + + + + + + + + @foreach ($tableData as $row) + + + + + + + + + + {{-- --}} + + + + {{-- --}} + + @endforeach + +
NoPlant CodeReceiving Plant CodeReceiving Plant NameInvoice NumberTransport NameLR_BL_AW DateTransit DaysStatus
{{ $row['no'] }}{{ $row['plant'] }}{{ $row['receiving_plant'] }}{{ $row['receiving_plant_name'] }}{{ $row['invoice_number'] }}{{ $row['transport_name'] }} + @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 + {{ $row['lr_bl_aw_date'] }}{{ $row['transit_days'] }}{{ $row['status'] }} + {{ $row['status'] }} +
+ @endif +

{!! $wishes !!}

+
+ +