diff --git a/Exports/DailySalePaymentReportExport.php b/Exports/DailySalePaymentReportExport.php
index 441ae2a..0df0a11 100644
--- a/Exports/DailySalePaymentReportExport.php
+++ b/Exports/DailySalePaymentReportExport.php
@@ -5,8 +5,13 @@ namespace Modules\DailySalePaymentReportModule\Exports;
use Illuminate\Contracts\View\View;
use Maatwebsite\Excel\Concerns\FromView;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
+use Maatwebsite\Excel\Concerns\WithEvents;
+use Maatwebsite\Excel\Events\AfterSheet;
+use PhpOffice\PhpSpreadsheet\Style\Alignment;
+use PhpOffice\PhpSpreadsheet\Style\Border;
+use PhpOffice\PhpSpreadsheet\Style\Fill;
-class DailySalePaymentReportExport implements FromView, ShouldAutoSize
+class DailySalePaymentReportExport implements FromView, ShouldAutoSize, WithEvents
{
protected $data;
@@ -19,4 +24,20 @@ class DailySalePaymentReportExport implements FromView, ShouldAutoSize
{
return view('dailysalepaymentreportmodule::export', $this->data);
}
+
+ public function registerEvents(): array
+ {
+ return [
+ AfterSheet::class => function (AfterSheet $event) {
+ $sheet = $event->sheet->getDelegate();
+ $highestColumn = $sheet->getHighestColumn();
+ $highestRow = $sheet->getHighestRow();
+ $dataRange = 'A1:' . $highestColumn . $highestRow;
+
+ // Set borders for everything
+ $sheet->getStyle($dataRange)->getBorders()->getAllBorders()->setBorderStyle(Border::BORDER_THIN);
+ $sheet->getStyle($dataRange)->getAlignment()->setVertical(Alignment::VERTICAL_TOP);
+ },
+ ];
+ }
}
diff --git a/Http/Controllers/DailySalePaymentReportModuleController.php b/Http/Controllers/DailySalePaymentReportModuleController.php
index d4b277c..99af0c4 100644
--- a/Http/Controllers/DailySalePaymentReportModuleController.php
+++ b/Http/Controllers/DailySalePaymentReportModuleController.php
@@ -303,13 +303,6 @@ class DailySalePaymentReportModuleController extends Controller
$data = $this->getReportData($date);
$filename = 'Daily_Sale_Payment_Report_' . $date;
-
- if ($type === 'pdf') {
- // Use DOMPDF directly for PDF to preserve advanced CSS and layout
- $pdf = app('dompdf.wrapper')->loadView('dailysalepaymentreportmodule::export', $data);
- $pdf->setPaper('a4', 'landscape');
- return $pdf->download($filename . '.pdf');
- }
// For Excel and CSV, use Maatwebsite Excel
$export = new \Modules\DailySalePaymentReportModule\Exports\DailySalePaymentReportExport($data);
diff --git a/Resources/views/export.blade.php b/Resources/views/export.blade.php
index 21964fd..0a89e41 100644
--- a/Resources/views/export.blade.php
+++ b/Resources/views/export.blade.php
@@ -1,272 +1,152 @@
-
-
-
-
- Daily Sale Payment Report
-
-
-
-
-
+
+
- |
- Daily Sale Payment Report
- |
+ Daily Sale Payment Report - {{ $report_date }} |
-
-
-
- |
- REPORT DATE: {{ $report_date }}
- |
+ Sales Table (Daily Sale) |
-
-
-
- |
- Daily Sales
- |
+ Date |
+ Reference Number |
+ Cashier |
+ Customer |
+ Grand Total |
+ @foreach($paymentOptions as $option)
+ {{ $option->name }} |
+ @endforeach
+ Due Amount |
-
-
-
+
+
+ @php
+ $tot_grand = 0;
+ $tot_due = 0;
+ $option_totals = [];
+ foreach ($paymentOptions as $opt) {
+ $option_totals[$opt->id] = 0;
+ }
+ @endphp
+ @foreach($sales_data as $sale)
- | Date |
- Reference Number |
- Cashier |
- Customer |
- Grand Total |
+ {{ $sale->date }} |
+ {{ $sale->reference_no }} |
+ {{ $sale->cashier }} |
+ {{ $sale->customer }} |
+ {{ number_format($sale->grand_total, 2) }} |
@foreach($paymentOptions as $option)
- {{ $option->name }} |
+ {{ number_format($sale->methods[$option->id] ?? 0, 2) }} |
@endforeach
- Due Amount |
+ {{ number_format($sale->due_amount, 2) }} |
-
-
@php
- $tot_grand = 0;
- $tot_due = 0;
- $option_totals = [];
+ $tot_grand += $sale->grand_total;
+ $tot_due += $sale->due_amount;
foreach ($paymentOptions as $opt) {
- $option_totals[$opt->id] = 0;
+ $option_totals[$opt->id] += ($sale->methods[$opt->id] ?? 0);
}
@endphp
- @foreach($sales_data as $sale)
-
- | {{ $sale->date }} |
- {{ $sale->reference_no }} |
- {{ $sale->cashier }} |
- {{ $sale->customer }} |
- {{ number_format($sale->grand_total, 2) }} |
- @foreach($paymentOptions as $option)
- {{ number_format($sale->methods[$option->id] ?? 0, 2) }} |
- @endforeach
- {{ number_format($sale->due_amount, 2) }} |
-
- @php
- $tot_grand += $sale->grand_total;
- $tot_due += $sale->due_amount;
- foreach ($paymentOptions as $opt) {
- $option_totals[$opt->id] += ($sale->methods[$opt->id] ?? 0);
- }
- @endphp
- @endforeach
-
-
-
- | DAILY TOTALS |
- {{ number_format($tot_grand, 2) }} |
- @foreach($paymentOptions as $option)
- {{ number_format($option_totals[$option->id], 2) }} |
- @endforeach
- {{ number_format($tot_due, 2) }} |
-
-
-
-
-
-
-
-
+ @endforeach
+
+
- |
- Credit Sale Collections
- |
-
-
-
-
-
- | Original Bill Date |
- Reference Number |
- Cashier |
- Customer |
- Grand Total |
- @foreach ($paymentOptions as $option)
- {{ $option->name }} |
- @endforeach
-
-
-
- @foreach ($creditCollections as $row)
-
- | {{ \Carbon\Carbon::parse($row['date'])->format('Y-m-d') }} |
- {{ $row['reference'] }} |
- {{ $row['cashier'] }} |
- {{ $row['customer'] }} |
- {{ number_format($row['grand_total'], 2) }} |
- @foreach ($paymentOptions as $option)
- {{ number_format($row['methods'][$option->id] ?? 0, 2) }} |
- @endforeach
-
+ Total |
+ {{ number_format($tot_grand, 2) }} |
+ @foreach($paymentOptions as $option)
+ {{ number_format($option_totals[$option->id], 2) }} |
@endforeach
-
-
+ {{ number_format($tot_due, 2) }} |
+
+
+
+
+
+
+
+
+
+ | Credit Sale Collections |
+
+
+ | Original Bill Date |
+ Reference Number |
+ Cashier |
+ Customer |
+ Grand Total |
+ @foreach ($paymentOptions as $option)
+ {{ $option->name }} |
+ @endforeach
+
+
+
+ @foreach ($creditCollections as $row)
- | COLLECTION TOTALS |
- {{ number_format($creditTotals['grand_total'], 2) }} |
+ {{ \Carbon\Carbon::parse($row['date'])->format('Y-m-d') }} |
+ {{ $row['reference'] }} |
+ {{ $row['cashier'] }} |
+ {{ $row['customer'] }} |
+ {{ number_format($row['grand_total'], 2) }} |
@foreach ($paymentOptions as $option)
- {{ number_format($creditTotals['methods'][$option->id] ?? 0, 2) }} |
+ {{ number_format($row['methods'][$option->id] ?? 0, 2) }} |
@endforeach
-
-
-
-
-
-
-
+ @endforeach
+
+
- |
- Payment Method Summary
- |
+ Total |
+ {{ number_format($creditTotals['grand_total'], 2) }} |
+ @foreach ($paymentOptions as $option)
+ {{ number_format($creditTotals['methods'][$option->id] ?? 0, 2) }} |
+ @endforeach
-
-
+
+
+
+
+
+
+ | Payment Method Summary |
+
+
+ | Payment Option |
+ Sale Amount |
+ Received Amount |
+ Total Amount |
+
+
+
+ @php
+ $grand_sale = 0;
+ $grand_received = 0;
+ $grand_total = 0;
+ @endphp
+ @foreach ($summaryData as $summary)
- | Payment Option |
- Sale Amount |
- Received Amount |
- Total Amount |
+ {{ $summary['name'] }} |
+ {{ number_format($summary['sale_amount'], 2) }} |
+ {{ number_format($summary['received_amount'], 2) }} |
+ {{ number_format($summary['total_amount'], 2) }} |
-
-
@php
- $grand_sale = 0;
- $grand_received = 0;
- $grand_total = 0;
+ $grand_sale += $summary['sale_amount'];
+ $grand_received += $summary['received_amount'];
+ $grand_total += $summary['total_amount'];
@endphp
- @foreach ($summaryData as $summary)
-
- | {{ strtoupper($summary['name']) }} |
- {{ number_format($summary['sale_amount'], 2) }} |
- {{ number_format($summary['received_amount'], 2) }} |
- {{ number_format($summary['total_amount'], 2) }} |
-
- @php
- $grand_sale += $summary['sale_amount'];
- $grand_received += $summary['received_amount'];
- $grand_total += $summary['total_amount'];
- @endphp
- @endforeach
-
-
-
- | GRAND TOTAL |
- {{ number_format($grand_sale, 2) }} |
- {{ number_format($grand_received, 2) }} |
- {{ number_format($grand_total, 2) }} |
-
-
-
-
-
-
+ @endforeach
+
+
+
+ | Grand Total |
+ {{ number_format($grand_sale, 2) }} |
+ {{ number_format($grand_received, 2) }} |
+ {{ number_format($grand_total, 2) }} |
+
+
+
diff --git a/Resources/views/index.blade.php b/Resources/views/index.blade.php
index 35b1a7d..1db3a2e 100644
--- a/Resources/views/index.blade.php
+++ b/Resources/views/index.blade.php
@@ -53,7 +53,7 @@
- -->