From 5aa45834fec1e2628ceb45dda2775f94e3431aa7 Mon Sep 17 00:00:00 2001 From: dhanabalan Date: Wed, 5 Nov 2025 17:39:33 +0530 Subject: [PATCH] Refactor invoice data report to improve status handling and styling --- .../Commands/SendInvoiceDataReport.php | 25 ++++++++++++++++++- .../views/mail/invoice_data_report.blade.php | 17 ++++++++++--- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/app/Console/Commands/SendInvoiceDataReport.php b/app/Console/Commands/SendInvoiceDataReport.php index 6d5703b..ef07436 100644 --- a/app/Console/Commands/SendInvoiceDataReport.php +++ b/app/Console/Commands/SendInvoiceDataReport.php @@ -263,7 +263,29 @@ class SendInvoiceDataReport extends Command continue; } - foreach ($pendingInvoices as $inv) { + // foreach ($pendingInvoices as $inv) { + // $tableData[] = [ + // 'no' => $no++, + // 'plant' => $plant->name, + // // 'distribution_type' => $selectedDistribution, + // // 'customer_code' => $inv->customer_code, + // 'document_number' => $inv->document_number, + // 'document_date' => $inv->document_date, + // 'customer_trade_name' => $inv->customer_trade_name, + // 'customer_location' => $inv->customer_location, + // 'status' => 'Pending', + // ]; + // } + foreach ($pendingInvoices as $inv) + { + $documentDate = \Carbon\Carbon::parse($inv->document_date); + + if ($documentDate->lt($startDate)) { + $statusColor = 'status-pending-red'; + } else { + $statusColor = 'status-pending-yellow'; + } + $tableData[] = [ 'no' => $no++, 'plant' => $plant->name, @@ -274,6 +296,7 @@ class SendInvoiceDataReport extends Command 'customer_trade_name' => $inv->customer_trade_name, 'customer_location' => $inv->customer_location, 'status' => 'Pending', + 'status_class' => $statusColor, ]; } } diff --git a/resources/views/mail/invoice_data_report.blade.php b/resources/views/mail/invoice_data_report.blade.php index da79b97..81cf258 100644 --- a/resources/views/mail/invoice_data_report.blade.php +++ b/resources/views/mail/invoice_data_report.blade.php @@ -41,10 +41,18 @@ color: #10b981; font-weight: bold; } - .status-pending { + /* .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; @@ -85,8 +93,6 @@ {{-- {{ $row['distribution_type'] }} {{ $row['customer_code'] }} --}} {{ $row['document_number'] }} - - {{-- ✅ Safe Carbon parse --}} @if(!empty($row['document_date']) && $row['document_date'] != '-') {{ \Carbon\Carbon::parse($row['document_date'])->format('d-M-Y') }} @@ -97,7 +103,10 @@ {{ $row['customer_trade_name'] }} {{ $row['customer_location'] }} - + {{-- + {{ $row['status'] }} + --}} + {{ $row['status'] }}