Refactor SendInvoiceDataReport and InvoiceDataMail to dynamically set date range for daily reports and improve email content formatting
This commit is contained in:
@@ -44,9 +44,18 @@ class InvoiceDataMail extends Mailable
|
||||
$greeting = 'Dear Sir/Madam,<br><br>We are sending here with list of "Despatch pending sale invoice & STO invoice as on date"';
|
||||
|
||||
if ($this->scheduleType == 'Daily') {
|
||||
$fromDate = (new DateTime('yesterday 10:00'))->format('d/m/Y H:i') . ':000';//08:00
|
||||
$toDate = (new DateTime('today 09:59'))->format('d/m/Y H:i') . ':999';//07:59
|
||||
$reportPeriod = "from: $fromDate to $toDate. <br><br>Please arrange to despatch the same immediately.";
|
||||
$firstRecord = \App\Models\InvoiceDataValidation::orderBy('document_date', 'asc')->first();
|
||||
//$lastRecord = \App\Models\InvoiceDataValidation::orderBy('document_date', 'desc')->first();
|
||||
|
||||
if ($firstRecord) {
|
||||
$startDate = \Carbon\Carbon::parse($firstRecord->document_date)->startOfDay();
|
||||
//$endDate = \Carbon\Carbon::parse($lastRecord->document_date)->endOfDay();
|
||||
}
|
||||
$endDate = now()->setTime(10, 0, 0);
|
||||
|
||||
// $fromDate = (new DateTime('yesterday 10:00'))->format('d/m/Y H:i') . ':000';//08:00
|
||||
// $toDate = (new DateTime('today 09:59'))->format('d/m/Y H:i') . ':999';//07:59
|
||||
$reportPeriod = "from: $startDate to $endDate\".<br><br>Please arrange to despatch the same immediately.";
|
||||
$greeting .= $reportPeriod;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user