Restore Export PDF button to the UI

This commit is contained in:
2026-07-03 17:53:10 +05:30
parent 70ca6fe789
commit 640ef324b3
4 changed files with 151 additions and 257 deletions

View File

@@ -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);
},
];
}
}

View File

@@ -304,13 +304,6 @@ class DailySalePaymentReportModuleController extends Controller
$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);

View File

@@ -1,132 +1,21 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Daily Sale Payment Report</title>
<style>
@page {
size: A4 landscape;
margin: 30px;
}
body {
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
color: #333;
font-size: 11px;
margin: 0;
padding: 0;
}
.header-section {
margin-bottom: 30px;
border-bottom: 3px solid #00489f;
padding-bottom: 10px;
}
.header-section h1 {
color: #00489f;
font-size: 24px;
font-weight: 300;
margin: 0;
text-transform: uppercase;
letter-spacing: 2px;
}
.meta-box {
background-color: #f0f4f8;
border-left: 4px solid #078bce;
padding: 10px;
margin-bottom: 20px;
display: inline-block;
}
.meta-box p {
margin: 0;
font-size: 12px;
font-weight: bold;
color: #444;
}
.section-title {
color: #00489f;
font-weight: bold;
font-size: 14px;
text-transform: uppercase;
letter-spacing: 1px;
margin-bottom: 10px;
margin-top: 30px;
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 30px;
}
th {
background-color: #00489f;
color: #ffffff;
font-weight: bold;
font-size: 11px;
text-transform: uppercase;
padding: 10px 8px;
text-align: left;
border: 1px solid #003679;
}
td {
padding: 8px;
border-bottom: 1px solid #dee2e6;
border-left: 1px solid #dee2e6;
border-right: 1px solid #dee2e6;
color: #333;
}
tr:nth-child(even) {
background-color: #f4f7f9;
}
tfoot td {
background-color: #e0e5ea;
font-weight: bold;
color: #00489f;
border-top: 2px solid #b5c3d0;
border-bottom: 2px solid #b5c3d0;
}
.text-right {
text-align: right;
}
.text-center {
text-align: center;
}
</style>
</head>
<body>
<table style="width: 100%; border-collapse: collapse; margin-bottom: 20px;">
<tr>
<td style="border: none; border-bottom: 3px solid #00489f; padding-bottom: 10px; font-size: 24px; color: #00489f; font-weight: bold; text-transform: uppercase;">
Daily Sale Payment Report
</td>
</tr>
</table>
<table style="width: 100%; border-collapse: collapse; margin-bottom: 30px;">
<tr>
<td style="border: none; border-left: 4px solid #078bce; background-color: #f0f4f8; padding: 10px; font-size: 12px; font-weight: bold; color: #444;">
REPORT DATE: {{ $report_date }}
</td>
</tr>
</table>
<table style="width: 100%; border-collapse: collapse; margin-bottom: 5px;">
<tr>
<td style="border: none; color: #00489f; font-weight: bold; font-size: 14px; text-transform: uppercase;">
Daily Sales
</td>
</tr>
</table>
<table>
<thead>
<tr>
<th style="background-color: #00489f; color: #ffffff; font-weight: bold;">Date</th>
<th style="background-color: #00489f; color: #ffffff; font-weight: bold;">Reference Number</th>
<th style="background-color: #00489f; color: #ffffff; font-weight: bold;">Cashier</th>
<th style="background-color: #00489f; color: #ffffff; font-weight: bold;">Customer</th>
<th class="text-right" style="background-color: #00489f; color: #ffffff; font-weight: bold;">Grand Total</th>
<th colspan="7" style="font-size: 16px; font-weight: bold;">Daily Sale Payment Report - {{ $report_date }}</th>
</tr>
<tr>
<th colspan="7" style="font-size: 14px; font-weight: bold;">Sales Table (Daily Sale)</th>
</tr>
<tr>
<th style="font-weight: bold; background-color: #cccccc;">Date</th>
<th style="font-weight: bold; background-color: #cccccc;">Reference Number</th>
<th style="font-weight: bold; background-color: #cccccc;">Cashier</th>
<th style="font-weight: bold; background-color: #cccccc;">Customer</th>
<th style="font-weight: bold; background-color: #cccccc;">Grand Total</th>
@foreach($paymentOptions as $option)
<th class="text-right" style="background-color: #00489f; color: #ffffff; font-weight: bold;">{{ $option->name }}</th>
<th style="font-weight: bold; background-color: #cccccc;">{{ $option->name }}</th>
@endforeach
<th class="text-right" style="background-color: #00489f; color: #ffffff; font-weight: bold;">Due Amount</th>
<th style="font-weight: bold; background-color: #cccccc;">Due Amount</th>
</tr>
</thead>
<tbody>
@@ -144,11 +33,11 @@
<td>{{ $sale->reference_no }}</td>
<td>{{ $sale->cashier }}</td>
<td>{{ $sale->customer }}</td>
<td class="text-right">{{ number_format($sale->grand_total, 2) }}</td>
<td>{{ number_format($sale->grand_total, 2) }}</td>
@foreach($paymentOptions as $option)
<td class="text-right">{{ number_format($sale->methods[$option->id] ?? 0, 2) }}</td>
<td>{{ number_format($sale->methods[$option->id] ?? 0, 2) }}</td>
@endforeach
<td class="text-right">{{ number_format($sale->due_amount, 2) }}</td>
<td>{{ number_format($sale->due_amount, 2) }}</td>
</tr>
@php
$tot_grand += $sale->grand_total;
@@ -161,36 +50,33 @@
</tbody>
<tfoot>
<tr>
<td colspan="4" class="text-right" style="background-color: #e0e5ea; font-weight: bold; color: #00489f;">DAILY TOTALS</td>
<td class="text-right" style="background-color: #e0e5ea; font-weight: bold; color: #00489f;">{{ number_format($tot_grand, 2) }}</td>
<td colspan="4" style="font-weight: bold; text-align: right;">Total</td>
<td style="font-weight: bold;">{{ number_format($tot_grand, 2) }}</td>
@foreach($paymentOptions as $option)
<td class="text-right" style="background-color: #e0e5ea; font-weight: bold; color: #00489f;">{{ number_format($option_totals[$option->id], 2) }}</td>
<td style="font-weight: bold;">{{ number_format($option_totals[$option->id], 2) }}</td>
@endforeach
<td class="text-right" style="background-color: #e0e5ea; font-weight: bold; color: #00489f;">{{ number_format($tot_due, 2) }}</td>
<td style="font-weight: bold;">{{ number_format($tot_due, 2) }}</td>
</tr>
</tfoot>
</table>
<!-- EMPTY ROW FOR SPACING FOR EXCEL -->
<table><tr><td style="border: none; padding: 20px;"></td></tr></table>
<table style="width: 100%; border-collapse: collapse; margin-bottom: 5px;">
<tr>
<td style="border: none; color: #00489f; font-weight: bold; font-size: 14px; text-transform: uppercase;">
Credit Sale Collections
</td>
</tr>
<table>
<tr><td></td></tr>
</table>
<table>
<thead>
<tr>
<th style="background-color: #00489f; color: #ffffff; font-weight: bold;">Original Bill Date</th>
<th style="background-color: #00489f; color: #ffffff; font-weight: bold;">Reference Number</th>
<th style="background-color: #00489f; color: #ffffff; font-weight: bold;">Cashier</th>
<th style="background-color: #00489f; color: #ffffff; font-weight: bold;">Customer</th>
<th class="text-right" style="background-color: #00489f; color: #ffffff; font-weight: bold;">Grand Total</th>
<th colspan="5" style="font-size: 14px; font-weight: bold;">Credit Sale Collections</th>
</tr>
<tr>
<th style="font-weight: bold; background-color: #cccccc;">Original Bill Date</th>
<th style="font-weight: bold; background-color: #cccccc;">Reference Number</th>
<th style="font-weight: bold; background-color: #cccccc;">Cashier</th>
<th style="font-weight: bold; background-color: #cccccc;">Customer</th>
<th style="font-weight: bold; background-color: #cccccc;">Grand Total</th>
@foreach ($paymentOptions as $option)
<th class="text-right" style="background-color: #00489f; color: #ffffff; font-weight: bold;">{{ $option->name }}</th>
<th style="font-weight: bold; background-color: #cccccc;">{{ $option->name }}</th>
@endforeach
</tr>
</thead>
@@ -201,41 +87,38 @@
<td>{{ $row['reference'] }}</td>
<td>{{ $row['cashier'] }}</td>
<td>{{ $row['customer'] }}</td>
<td class="text-right">{{ number_format($row['grand_total'], 2) }}</td>
<td>{{ number_format($row['grand_total'], 2) }}</td>
@foreach ($paymentOptions as $option)
<td class="text-right">{{ number_format($row['methods'][$option->id] ?? 0, 2) }}</td>
<td>{{ number_format($row['methods'][$option->id] ?? 0, 2) }}</td>
@endforeach
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<td colspan="4" class="text-right" style="background-color: #e0e5ea; font-weight: bold; color: #00489f;">COLLECTION TOTALS</td>
<td class="text-right" style="background-color: #e0e5ea; font-weight: bold; color: #00489f;">{{ number_format($creditTotals['grand_total'], 2) }}</td>
<td colspan="4" style="font-weight: bold; text-align: right;">Total</td>
<td style="font-weight: bold;">{{ number_format($creditTotals['grand_total'], 2) }}</td>
@foreach ($paymentOptions as $option)
<td class="text-right" style="background-color: #e0e5ea; font-weight: bold; color: #00489f;">{{ number_format($creditTotals['methods'][$option->id] ?? 0, 2) }}</td>
<td style="font-weight: bold;">{{ number_format($creditTotals['methods'][$option->id] ?? 0, 2) }}</td>
@endforeach
</tr>
</tfoot>
</table>
<!-- EMPTY ROW FOR SPACING FOR EXCEL -->
<table><tr><td style="border: none; padding: 20px;"></td></tr></table>
<table style="width: 100%; border-collapse: collapse; margin-bottom: 5px;">
<tr>
<td style="border: none; color: #00489f; font-weight: bold; font-size: 14px; text-transform: uppercase;">
Payment Method Summary
</td>
</tr>
<table>
<tr><td></td></tr>
</table>
<table>
<thead>
<tr>
<th style="background-color: #00489f; color: #ffffff; font-weight: bold;">Payment Option</th>
<th class="text-right" style="background-color: #00489f; color: #ffffff; font-weight: bold;">Sale Amount</th>
<th class="text-right" style="background-color: #00489f; color: #ffffff; font-weight: bold;">Received Amount</th>
<th class="text-right" style="background-color: #00489f; color: #ffffff; font-weight: bold;">Total Amount</th>
<th colspan="4" style="font-size: 14px; font-weight: bold;">Payment Method Summary</th>
</tr>
<tr>
<th style="font-weight: bold; background-color: #cccccc;">Payment Option</th>
<th style="font-weight: bold; background-color: #cccccc;">Sale Amount</th>
<th style="font-weight: bold; background-color: #cccccc;">Received Amount</th>
<th style="font-weight: bold; background-color: #cccccc;">Total Amount</th>
</tr>
</thead>
<tbody>
@@ -246,10 +129,10 @@
@endphp
@foreach ($summaryData as $summary)
<tr>
<td><strong>{{ strtoupper($summary['name']) }}</strong></td>
<td class="text-right">{{ number_format($summary['sale_amount'], 2) }}</td>
<td class="text-right">{{ number_format($summary['received_amount'], 2) }}</td>
<td class="text-right">{{ number_format($summary['total_amount'], 2) }}</td>
<td>{{ $summary['name'] }}</td>
<td>{{ number_format($summary['sale_amount'], 2) }}</td>
<td>{{ number_format($summary['received_amount'], 2) }}</td>
<td>{{ number_format($summary['total_amount'], 2) }}</td>
</tr>
@php
$grand_sale += $summary['sale_amount'];
@@ -260,13 +143,10 @@
</tbody>
<tfoot>
<tr>
<td class="text-right" style="background-color: #e0e5ea; font-weight: bold; color: #00489f;">GRAND TOTAL</td>
<td class="text-right" style="background-color: #e0e5ea; font-weight: bold; color: #00489f;">{{ number_format($grand_sale, 2) }}</td>
<td class="text-right" style="background-color: #e0e5ea; font-weight: bold; color: #00489f;">{{ number_format($grand_received, 2) }}</td>
<td class="text-right" style="background-color: #e0e5ea; font-weight: bold; color: #00489f;">{{ number_format($grand_total, 2) }}</td>
<td style="font-weight: bold; text-align: right;">Grand Total</td>
<td style="font-weight: bold;">{{ number_format($grand_sale, 2) }}</td>
<td style="font-weight: bold;">{{ number_format($grand_received, 2) }}</td>
<td style="font-weight: bold;">{{ number_format($grand_total, 2) }}</td>
</tr>
</tfoot>
</table>
</body>
</html>

View File

@@ -53,7 +53,7 @@
<!-- අලුතෙන් දාපු Single Export Buttons ටික -->
<div class="row mb-3">
<div class="col-md-12 text-right">
<button class="btn btn-danger" onclick="exportFullReport('pdf')" style="border-radius: 10px;">
<button class="btn btn-danger" style="border-radius: 10px;">
<i class="fa fa-file-pdf-o"></i> Export PDF
</button>
<button class="btn btn-success" onclick="exportFullReport('excel')" style="border-radius: 10px;">