Compare commits

..

3 Commits

Author SHA1 Message Date
SUM2046
58d1555743 export pdf 2026-07-03 17:38:49 +05:30
26273d92c2 Implement dynamic Payment Method Summary (Table 3) 2026-07-03 16:14:19 +05:30
d849bd41ff Update index.blade.php Print Button 2026-07-03 15:57:30 +05:30
4 changed files with 618 additions and 283 deletions

View File

@@ -2,6 +2,7 @@
namespace Modules\DailySalePaymentReportModule\Http\Controllers;
use Barryvdh\DomPDF\Facade\Pdf;
use Illuminate\Contracts\Support\Renderable;
use Illuminate\Http\Request;
use Illuminate\Routing\Controller;
@@ -23,8 +24,8 @@ class DailySalePaymentReportModuleController extends Controller
->orderBy('id')
->get(['id', 'name']);
$creditCollections = $this->getCreditSaleCollections($report_date);
$creditCollections = $this->getCreditSaleCollections($report_date);
$creditTotals = [
'grand_total' => $creditCollections->sum('grand_total'),
'methods' => [],
@@ -32,7 +33,7 @@ class DailySalePaymentReportModuleController extends Controller
foreach ($paymentOptions as $option) {
$creditTotals['methods'][$option->id] = $creditCollections->sum(
fn($row) => $row['methods'][$option->id] ?? 0
fn($row) => $row['methods'][$option->id] ?? 0
);
}
@@ -82,7 +83,7 @@ class DailySalePaymentReportModuleController extends Controller
$sales_data = [];
foreach ($sales as $sale) {
$methodTotals = [];
// Sum from payments table
foreach ($paymentsTable->where('sale_id', $sale->id) as $p) {
$optionId = $p->payment_option_id;
@@ -108,13 +109,49 @@ class DailySalePaymentReportModuleController extends Controller
];
}
// --- Table 3: Payment Method Summary Calculation ---
$summaryData = [];
// මුලින්ම හැම Payment Option එකටම බින්දුව දාලා Array එකක් හදාගන්නවා
foreach ($paymentOptions as $option) {
$summaryData[$option->id] = [
'name' => $option->name,
'sale_amount' => 0,
'received_amount' => 0,
'total_amount' => 0
];
}
// Table 1 (Daily Sales) වල සල්ලි ටික එකතු කරනවා
foreach ($sales_data as $sale) {
foreach ($paymentOptions as $option) {
$amount = $sale->methods[$option->id] ?? 0;
$summaryData[$option->id]['sale_amount'] += $amount;
$summaryData[$option->id]['total_amount'] += $amount;
}
}
// Table 2 (Credit Collections) වල සල්ලි ටික එකතු කරනවා
foreach ($creditCollections as $credit) {
foreach ($paymentOptions as $option) {
$amount = $credit['methods'][$option->id] ?? 0;
$summaryData[$option->id]['received_amount'] += $amount;
$summaryData[$option->id]['total_amount'] += $amount;
}
}
$data = $this->buildReportData($report_date);
return view('dailysalepaymentreportmodule::index', compact(
'sales_data',
'report_date',
'paymentOptions',
'sales_data',
'report_date',
'paymentOptions',
'creditCollections',
'creditTotals',
));
'summaryData',
'data'
));
}
private function getCreditSaleCollections($date)
@@ -183,18 +220,127 @@ class DailySalePaymentReportModuleController extends Controller
}
$rows[] = [
'date' => $sale->created_at,
'reference' => $sale->reference_no,
'cashier' => $users[$sale->user_id] ?? '-',
'customer' => $customers[$sale->customer_id] ?? '-',
'date' => $sale->created_at,
'reference' => $sale->reference_no,
'cashier' => $users[$sale->user_id] ?? '-',
'customer' => $customers[$sale->customer_id] ?? '-',
'grand_total' => $sale->grand_total - $sale->paid_amount,
'methods' => $methodTotals,
'methods' => $methodTotals,
];
}
return collect($rows);
}
private function buildReportData($report_date)
{
$paymentOptions = DB::table('payment_options')->where('is_active', 1)
->orderBy('id')
->get(['id', 'name']);
$creditCollections = $this->getCreditSaleCollections($report_date);
$creditTotals = [
'grand_total' => $creditCollections->sum('grand_total'),
'methods' => [],
];
foreach ($paymentOptions as $option) {
$creditTotals['methods'][$option->id] = $creditCollections->sum(
fn($row) => $row['methods'][$option->id] ?? 0
);
}
$sales = DB::table('sales')
->leftJoin('users', 'sales.user_id', '=', 'users.id')
->leftJoin('customers', 'sales.customer_id', '=', 'customers.id')
->whereDate('sales.created_at', $report_date)
->select(
'sales.id',
'sales.created_at as date',
'sales.reference_no',
'users.name as cashier',
'customers.name as customer',
'sales.grand_total',
'sales.due_amount',
)->get();
$saleIds = $sales->pluck('id')->all();
$paymentsTable = DB::table('payments')
->whereIn('sale_id', $saleIds)
->whereDate('created_at', $report_date)
->get(['id', 'sale_id', 'amount', 'payment_option_id']);
$usedPaymentIds = $paymentsTable->pluck('id')->all();
$salesPaymentsTable = DB::table('sales_payments')
->whereIn('sale_id', $saleIds)
->whereDate('created_at', $report_date)
->where(function ($q) use ($usedPaymentIds) {
$q->whereNull('payment_id');
if (!empty($usedPaymentIds)) {
$q->orWhereNotIn('payment_id', $usedPaymentIds);
}
})
->get(['id', 'sale_id', 'amount', 'payment_id']);
$linkedPaymentIds = $salesPaymentsTable->whereNotNull('payment_id')->pluck('payment_id')->unique();
$linkedOptionMap = DB::table('payments')->whereIn('id', $linkedPaymentIds)->pluck('payment_option_id', 'id');
$sales_data = [];
foreach ($sales as $sale) {
$methodTotals = [];
foreach ($paymentsTable->where('sale_id', $sale->id) as $p) {
$optionId = $p->payment_option_id;
$methodTotals[$optionId] = ($methodTotals[$optionId] ?? 0) + $p->amount;
}
foreach ($salesPaymentsTable->where('sale_id', $sale->id) as $sp) {
$optionId = $sp->payment_id ? ($linkedOptionMap[$sp->payment_id] ?? null) : null;
if ($optionId) {
$methodTotals[$optionId] = ($methodTotals[$optionId] ?? 0) + $sp->amount;
}
}
$sales_data[] = (object) [
'date' => Carbon::parse($sale->date)->format('Y-m-d'),
'reference_no' => $sale->reference_no,
'cashier' => $sale->cashier ?? 'N/A',
'customer' => $sale->customer ?? 'N/A',
'grand_total' => $sale->grand_total,
'due_amount' => $sale->due_amount,
'methods' => $methodTotals
];
}
$summaryData = [];
foreach ($paymentOptions as $option) {
$summaryData[$option->id] = [
'name' => $option->name,
'sale_amount' => 0,
'received_amount' => 0,
'total_amount' => 0
];
}
foreach ($sales_data as $sale) {
foreach ($paymentOptions as $option) {
$amount = $sale->methods[$option->id] ?? 0;
$summaryData[$option->id]['sale_amount'] += $amount;
$summaryData[$option->id]['total_amount'] += $amount;
}
}
foreach ($creditCollections as $credit) {
foreach ($paymentOptions as $option) {
$amount = $credit['methods'][$option->id] ?? 0;
$summaryData[$option->id]['received_amount'] += $amount;
$summaryData[$option->id]['total_amount'] += $amount;
}
}
return compact('report_date', 'paymentOptions', 'sales_data', 'creditCollections', 'creditTotals', 'summaryData');
}
/**
* Show the form for creating a new resource.
* @return Renderable
@@ -262,6 +408,22 @@ class DailySalePaymentReportModuleController extends Controller
$type = $request->query('type');
return "Export function is working. Selected Date: " . $date . " | Export Type: " . $type;
}
public function exportPDF(Request $request)
{
$date = $request->query('date', Carbon::today()->toDateString());
$type = $request->query('type');
$data = $this->buildReportData($date);
if ($type === 'pdf') {
$pdf = Pdf::loadView('dailysalepaymentreportmodule::export.pdf', $data)
->setPaper('a4', 'landscape');
return $pdf->download('daily-sale-payment-report-' . $date . '.pdf');
}
return "Export function is working. Selected Date: " . $date . " | Export Type: " . $type;
}
}

View File

@@ -0,0 +1,182 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<style>
body {
font-family: sans-serif;
font-size: 11px;
}
h2,
h4 {
margin: 5px 0;
color: #00489f;
}
table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
}
th,
td {
border: 1px solid #999;
padding: 4px 6px;
text-align: left;
}
th {
background-color: #078bce;
color: white;
}
tfoot td {
background-color: #cdd4da;
font-weight: bold;
}
.text-right {
text-align: right;
}
</style>
</head>
<body>
<h2>Sunbeam Lanka Tailoring - Daily Sale Payment Report</h2>
<p>Date: {{ $report_date }}</p>
<h4>Sales Table (Daily Sale)</h4>
<table>
<thead>
<tr>
<th>Date</th>
<th>Reference Number</th>
<th>Cashier</th>
<th>Customer</th>
<th>Grand Total</th>
@foreach($paymentOptions as $option)
<th>{{ $option->name }}</th>
@endforeach
<th>Due Amount</th>
</tr>
</thead>
<tbody>
@php
$tot_grand = 0; $tot_due = 0; $option_totals = [];
foreach ($paymentOptions as $opt) { $option_totals[$opt->id] = 0; }
@endphp
@foreach ($sales_data as $sale)
<tr>
<td>{{ $sale->date }}</td>
<td>{{ $sale->reference_no }}</td>
<td>{{ $sale->cashier }}</td>
<td>{{ $sale->customer }}</td>
<td class="text-right">{{ number_format($sale->grand_total, 2) }}</td>
@foreach($paymentOptions as $option)
<td class="text-right">{{ number_format($sale->methods[$option->id] ?? 0, 2) }}</td>
@endforeach
<td class="text-right">{{ number_format($sale->due_amount, 2) }}</td>
</tr>
@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
</tbody>
<tfoot>
<tr>
<td colspan="4" class="text-right">Total</td>
<td class="text-right">{{ number_format($tot_grand, 2) }}</td>
@foreach($paymentOptions as $option)
<td class="text-right">{{ number_format($option_totals[$option->id], 2) }}</td>
@endforeach
<td class="text-right">{{ number_format($tot_due, 2) }}</td>
</tr>
</tfoot>
</table>
<h4>Credit Sale Collections</h4>
<table>
<thead>
<tr>
<th>Original Bill Date</th>
<th>Reference Number</th>
<th>Cashier</th>
<th>Customer</th>
<th>Grand Total</th>
@foreach ($paymentOptions as $option)
<th>{{ $option->name }}</th>
@endforeach
</tr>
</thead>
<tbody>
@foreach ($creditCollections as $row)
<tr>
<td>{{ \Carbon\Carbon::parse($row['date'])->format('Y-m-d') }}</td>
<td>{{ $row['reference'] }}</td>
<td>{{ $row['cashier'] }}</td>
<td>{{ $row['customer'] }}</td>
<td class="text-right">{{ number_format($row['grand_total'], 2) }}</td>
@foreach ($paymentOptions as $option)
<td class="text-right">{{ number_format($row['methods'][$option->id] ?? 0, 2) }}</td>
@endforeach
</tr>
@endforeach
</tbody>
<tfoot>
<tr>
<td colspan="4" class="text-right">Total</td>
<td class="text-right">{{ number_format($creditTotals['grand_total'], 2) }}</td>
@foreach ($paymentOptions as $option)
<td class="text-right">{{ number_format($creditTotals['methods'][$option->id] ?? 0, 2) }}</td>
@endforeach
</tr>
</tfoot>
</table>
<h4>Payment Method Summary</h4>
<table style="width: 60%;">
<thead>
<tr>
<th>Payment Option</th>
<th>Sale Amount</th>
<th>Received Amount</th>
<th>Total Amount</th>
</tr>
</thead>
<tbody>
@php
$grand_sale = 0; $grand_received = 0; $grand_total = 0;
@endphp
@foreach ($summaryData as $summary)
<tr>
<td>{{ $summary['name'] }}</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>
</tr>
@php
$grand_sale += $summary['sale_amount'];
$grand_received += $summary['received_amount'];
$grand_total += $summary['total_amount'];
@endphp
@endforeach
</tbody>
<tfoot>
<tr>
<td class="text-right">Grand Total</td>
<td class="text-right">{{ number_format($grand_sale, 2) }}</td>
<td class="text-right">{{ number_format($grand_received, 2) }}</td>
<td class="text-right">{{ number_format($grand_total, 2) }}</td>
</tr>
</tfoot>
</table>
</body>
</html>

View File

@@ -1,299 +1,289 @@
@extends('backend.layout.main')
@section('content')
@if ($errors->has('title'))
<div class="alert alert-danger alert-dismissible text-center">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
aria-hidden="true">&times;</span></button>{{ $errors->first('title') }}
</div>
@endif
@if (session()->has('message'))
<div class="alert alert-success alert-dismissible text-center">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>{{ session()->get('message') }}
</div>
@endif
@if (session()->has('not_permitted'))
<div class="alert alert-danger alert-dismissible text-center">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>{{ session()->get('not_permitted') }}
</div>
@endif
@if ($errors->has('title'))
<div class="alert alert-danger alert-dismissible text-center">
<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span
aria-hidden="true">&times;</span></button>{{ $errors->first('title') }}
</div>
@endif
@if (session()->has('message'))
<div class="alert alert-success alert-dismissible text-center">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>{{ session()->get('message') }}
</div>
@endif
@if (session()->has('not_permitted'))
<div class="alert alert-danger alert-dismissible text-center">
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>{{ session()->get('not_permitted') }}
</div>
@endif
<section>
<div class="container-fluid">
<div style="border-radius: 30px;" class="card pb-4 ">
<link rel="stylesheet" href="{{ asset('public/css/cloudma.css') }}">
<div style="background: linear-gradient(to right, #00c1e3, #00489f); border-radius: 30px 30px 0px 0px; font-weight: bold; color: white;"
class="card-header mt-2">
<h3 class="text-center">Daily Sale Payment Report</h3>
</div>
<section>
<div class="container-fluid">
<div style="border-radius: 30px;" class="card pb-4 ">
<link rel="stylesheet" href="{{ asset('public/css/cloudma.css') }}">
<div style="background: linear-gradient(to right, #00c1e3, #00489f); border-radius: 30px 30px 0px 0px; font-weight: bold; color: white;"
class="card-header mt-2">
<h3 class="text-center">Daily Sale Payment Report</h3>
</div>
<form action="{{ url('dailysalepaymentreportmodule') }}" method="GET">
<div class="row mr-1 mt-4 pl-4 align-items-center">
<div class="col-md-4">
<label><strong>Select Date</strong> &nbsp;</label>
<div class="input-group">
<input type="date" name="report_date" id="report_date"
value="{{ request()->input('report_date', date('Y-m-d')) }}" class="form-control"
required />
<form action="{{ url('dailysalepaymentreportmodule') }}" method="GET">
<div class="row mr-1 mt-4 pl-4 align-items-center">
<div class="col-md-4">
<label><strong>Select Date</strong> &nbsp;</label>
<div class="input-group">
<input type="date" name="report_date" id="report_date"
value="{{ request()->input('report_date', date('Y-m-d')) }}" class="form-control"
required />
</div>
</div>
<div class="col-md-3 pt-md-4">
<button type="submit" class="btn btn-primary" id="generate-report-btn">Generate Report</button>
</div>
</div>
<div class="col-md-3 pt-md-4">
<button type="submit" class="btn btn-primary" id="generate-report-btn">Generate Report</button>
</div>
</div>
</form>
</div>
</div>
<div class="container-fluid mt-4">
<!-- අලුතෙන් දාපු 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;">
<i class="fa fa-file-pdf-o"></i> Export PDF
</button>
<button class="btn btn-success" onclick="exportFullReport('excel')" style="border-radius: 10px;">
<i class="dripicons-document-new"></i> Export Excel
</button>
<button class="btn btn-info" onclick="exportFullReport('csv')" style="border-radius: 10px;">
<i class="fa fa-file-text-o"></i> Export CSV
</button>
<button class="btn btn-secondary" onclick="window.print()" style="border-radius: 10px;">
<i class="fa fa-print"></i> Print Report
</button>
</form>
</div>
</div>
<!-- Sales Table -->
<h4 class="mb-3" style="color: #00489f; font-weight: bold;">Sales Table (Daily Sale)</h4>
<div class="table-responsive">
<table style="border-radius: 15px; background-color: #e0e5ea;" class="table table-hover table-bordered">
<thead
style="border-radius: 50px; background: linear-gradient(to right, #078bce, #1a1d1e); color: white;">
<tr>
<th>Date</th>
<th>Reference Number</th>
<th>Cashier</th>
<th>Customer</th>
<th>Grand Total</th>
@foreach($paymentOptions as $option)
<th>{{ $option->name }}</th>
<div class="container-fluid mt-4">
<!-- අලුතෙන් දාපු Single Export Buttons ටික -->
<div class="row mb-3">
<div class="col-md-12 text-right">
<button class="btn btn-danger" onclick="exportFullPdf('pdf')" 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;">
<i class="dripicons-document-new"></i> Export Excel
</button>
<button class="btn btn-info" onclick="exportFullReport('csv')" style="border-radius: 10px;">
<i class="fa fa-file-text-o"></i> Export CSV
</button>
<!-- <button class="btn btn-secondary" onclick="window.print()" style="border-radius: 10px;">
<i class="fa fa-print"></i> Print Report
</button> -->
</div>
</div>
<!-- Sales Table -->
<h4 class="mb-3" style="color: #00489f; font-weight: bold;">Sales Table (Daily Sale)</h4>
<div class="table-responsive">
<table style="border-radius: 15px; background-color: #e0e5ea;" class="table table-hover table-bordered">
<thead
style="border-radius: 50px; background: linear-gradient(to right, #078bce, #1a1d1e); color: white;">
<tr>
<th>Date</th>
<th>Reference Number</th>
<th>Cashier</th>
<th>Customer</th>
<th>Grand Total</th>
@foreach($paymentOptions as $option)
<th>{{ $option->name }}</th>
@endforeach
<th>Due Amount</th>
</tr>
</thead>
<tbody>
@php
$tot_grand = 0;
$tot_due = 0;
// Initialize dynamic option totals
$option_totals = [];
foreach ($paymentOptions as $opt) {
$option_totals[$opt->id] = 0;
}
@endphp
@foreach ($sales_data as $sale)
<tr>
<td>{{ $sale->date }}</td>
<td>{{ $sale->reference_no }}</td>
<td>{{ $sale->cashier }}</td>
<td>{{ $sale->customer }}</td>
<td class="text-right">{{ number_format($sale->grand_total, 2) }}</td>
@foreach($paymentOptions as $option)
<td class="text-right">{{ number_format($sale->methods[$option->id] ?? 0, 2) }}</td>
@endforeach
<td class="text-right">{{ number_format($sale->due_amount, 2) }}</td>
</tr>
@php
$tot_grand += $sale->grand_total;
$tot_due += $sale->due_amount;
// Accumulate dynamic option totals
foreach ($paymentOptions as $opt) {
$option_totals[$opt->id] += ($sale->methods[$opt->id] ?? 0);
}
@endphp
@endforeach
<th>Due Amount</th>
</tr>
</thead>
<tbody>
@php
$tot_grand = 0;
$tot_due = 0;
// Initialize dynamic option totals
$option_totals = [];
foreach ($paymentOptions as $opt) {
$option_totals[$opt->id] = 0;
}
@endphp
</tbody>
<tfoot style="background-color: #cdd4da; font-weight: bold;">
<tr>
<td colspan="4" class="text-right">Total</td>
<td class="text-right">{{ number_format($tot_grand, 2) }}</td>
@foreach ($sales_data as $sale)
<tr>
<td>{{ $sale->date }}</td>
<td>{{ $sale->reference_no }}</td>
<td>{{ $sale->cashier }}</td>
<td>{{ $sale->customer }}</td>
<td class="text-right">{{ number_format($sale->grand_total, 2) }}</td>
@foreach($paymentOptions as $option)
<td class="text-right">{{ number_format($option_totals[$option->id], 2) }}</td>
@endforeach
@foreach($paymentOptions as $option)
<td class="text-right">{{ number_format($sale->methods[$option->id] ?? 0, 2) }}</td>
@endforeach
<td class="text-right">{{ number_format($sale->due_amount, 2) }}</td>
</tr>
@php
$tot_grand += $sale->grand_total;
$tot_due += $sale->due_amount;
// Accumulate dynamic option totals
foreach ($paymentOptions as $opt) {
$option_totals[$opt->id] += ($sale->methods[$opt->id] ?? 0);
}
@endphp
@endforeach
</tbody>
<tfoot style="background-color: #cdd4da; font-weight: bold;">
<tr>
<td colspan="4" class="text-right">Total</td>
<td class="text-right">{{ number_format($tot_grand, 2) }}</td>
@foreach($paymentOptions as $option)
<td class="text-right">{{ number_format($option_totals[$option->id], 2) }}</td>
@endforeach
<td class="text-right">{{ number_format($tot_due, 2) }}</td>
</tr>
</tfoot>
</table>
<td class="text-right">{{ number_format($tot_due, 2) }}</td>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
<div class="container-fluid mt-5">
<!-- Credit Sale Collections Table -->
<h4 class="mb-3" style="color: #00489f; font-weight: bold;">Credit Sale Collections</h4>
<div class="table-responsive">
<table style="border-radius: 15px; background-color: #e0e5ea;" class="table table-hover table-bordered">
<thead
style="border-radius: 50px; background: linear-gradient(to right, #078bce, #1a1d1e); color: white;">
<tr>
<th>Original Bill Date</th>
<th>Reference Number</th>
<th>Cashier</th>
<th>Customer</th>
<th>Grand Total</th>
@foreach ($paymentOptions as $option)
<th>{{ $option->name }}</th>
<div class="container-fluid mt-5">
<!-- Credit Sale Collections Table -->
<h4 class="mb-3" style="color: #00489f; font-weight: bold;">Credit Sale Collections</h4>
<div class="table-responsive">
<table style="border-radius: 15px; background-color: #e0e5ea;" class="table table-hover table-bordered">
<thead
style="border-radius: 50px; background: linear-gradient(to right, #078bce, #1a1d1e); color: white;">
<tr>
<th>Original Bill Date</th>
<th>Reference Number</th>
<th>Cashier</th>
<th>Customer</th>
<th>Grand Total</th>
@foreach ($paymentOptions as $option)
<th>{{ $option->name }}</th>
@endforeach
</tr>
</thead>
<tbody>
@foreach ($creditCollections as $row)
<tr>
<td>{{ \Carbon\Carbon::parse($row['date'])->format('Y-m-d') }}</td>
<td>{{ $row['reference'] }}</td>
<td>{{ $row['cashier'] }}</td>
<td>{{ $row['customer'] }}</td>
<td>{{ number_format($row['grand_total'], 2) }}</td>
@foreach ($paymentOptions as $option)
<td>{{ number_format($row['methods'][$option->id] ?? 0, 2) }}</td>
@endforeach
</tr>
@endforeach
</tr>
</thead>
<tbody>
@foreach ($creditCollections as $row)
<tr>
<td>{{ \Carbon\Carbon::parse($row['date'])->format('Y-m-d') }}</td>
<td>{{ $row['reference'] }}</td>
<td>{{ $row['cashier'] }}</td>
<td>{{ $row['customer'] }}</td>
<td>{{ number_format($row['grand_total'], 2) }}</td>
@foreach ($paymentOptions as $option)
<td>{{ number_format($row['methods'][$option->id] ?? 0, 2) }}</td>
@endforeach
</tr>
@endforeach
</tbody>
<tfoot style="background-color: #cdd4da; font-weight: bold;">
<tr>
<td colspan="4" class="text-right">Total</td>
<td>{{ number_format($creditTotals['grand_total'], 2) }}</td>
@foreach ($paymentOptions as $option)
<td>{{ number_format($creditTotals['methods'][$option->id] ?? 0, 2) }}</td>
@endforeach
</tr>
</tfoot>
</table>
</div>
</div>
</tbody>
<tfoot style="background-color: #cdd4da; font-weight: bold;">
<tr>
<td colspan="4" class="text-right">Total</td>
<td>{{ number_format($creditTotals['grand_total'], 2) }}</td>
@foreach ($paymentOptions as $option)
<td>{{ number_format($creditTotals['methods'][$option->id] ?? 0, 2) }}</td>
@endforeach
</tr>
</tfoot>
</table>
</div>
<div class="container-fluid mt-5 mb-5">
<!-- Payment Method Summary Table -->
<h4 class="mb-3" style="color: #00489f; font-weight: bold;">Payment Method Summary</h4>
<div class="table-responsive">
<table style="border-radius: 15px; background-color: #e0e5ea; width: 60%;"
class="table table-hover table-bordered">
<thead
style="border-radius: 50px; background: linear-gradient(to right, #078bce, #1a1d1e); color: white;">
<tr>
<th>Payment Option</th>
<th>Sale Amount</th>
<th>Received Amount</th>
<th>Total Amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>Cash</td>
<td>0.00</td>
<td>0.00</td>
<td>0.00</td>
</tr>
<tr>
<td>Card 1</td>
<td>0.00</td>
<td>0.00</td>
<td>0.00</td>
</tr>
<tr>
<td>Card 2</td>
<td>0.00</td>
<td>0.00</td>
<td>0.00</td>
</tr>
<tr>
<td>Card 3</td>
<td>0.00</td>
<td>0.00</td>
<td>0.00</td>
</tr>
<tr>
<td>Online Transfer</td>
<td>0.00</td>
<td>0.00</td>
<td>0.00</td>
</tr>
<tr>
<td>Link Pay</td>
<td>0.00</td>
<td>0.00</td>
<td>0.00</td>
</tr>
</tbody>
<tfoot style="background-color: #cdd4da; font-weight: bold;">
<tr>
<td class="text-right">Grand Total</td>
<td>0.00</td>
<td>0.00</td>
<td>0.00</td>
</tr>
</tfoot>
</table>
</div>
</div>
</section>
<div class="container-fluid mt-5 mb-5">
<!-- Payment Method Summary Table -->
<h4 class="mb-3" style="color: #00489f; font-weight: bold;">Payment Method Summary</h4>
<div class="table-responsive">
<table style="border-radius: 15px; background-color: #e0e5ea; width: 60%;"
class="table table-hover table-bordered">
<thead
style="border-radius: 50px; background: linear-gradient(to right, #078bce, #1a1d1e); color: white;">
<tr>
<th>Payment Option</th>
<th>Sale Amount</th>
<th>Received Amount</th>
<th>Total Amount</th>
</tr>
</thead>
<tbody>
@php
$grand_sale = 0;
$grand_received = 0;
$grand_total = 0;
@endphp
<style>
.bootstrap-select.form-control,
.form-control,
.input-group-text {
background-color: #fdfdff;
border-color: #002250;
border-radius: 15px;
}
@foreach ($summaryData as $summary)
<tr>
<td>{{ $summary['name'] }}</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>
</tr>
@php
$grand_sale += $summary['sale_amount'];
$grand_received += $summary['received_amount'];
$grand_total += $summary['total_amount'];
@endphp
@endforeach
</tbody>
<tfoot style="background-color: #cdd4da; font-weight: bold;">
<tr>
<td class="text-right">Grand Total</td>
<td class="text-right">{{ number_format($grand_sale, 2) }}</td>
<td class="text-right">{{ number_format($grand_received, 2) }}</td>
<td class="text-right">{{ number_format($grand_total, 2) }}</td>
</tr>
</tfoot>
.btn-primary {
background-color: #002250;
border-color: #002250;
border-radius: 15px;
padding: 10px 25px;
}
</table>
</div>
</div>
</section>
.btn-primary:hover {
background-color: #0068e3;
}
<style>
.bootstrap-select.form-control,
.form-control,
.input-group-text {
background-color: #fdfdff;
border-color: #002250;
border-radius: 15px;
}
table {
border-collapse: collapse !important;
}
</style>
.btn-primary {
background-color: #002250;
border-color: #002250;
border-radius: 15px;
padding: 10px 25px;
}
.btn-primary:hover {
background-color: #0068e3;
}
table {
border-collapse: collapse !important;
}
</style>
@endsection
@push('scripts')
<script type="text/javascript">
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
<script type="text/javascript">
$.ajaxSetup({
headers: {
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
}
});
// මුළු රිපෝට් එකම එක්ස්පෝර්ට් කරන්න හදපු Function එක
function exportFullReport(exportType) {
var selectedDate = $('#report_date').val();
// ඔයාගේ Controller එකේ export route එකට මේක හරවන්න ඕනේ.
// උදාහරණයක් විදිහට: url('/dailysalepaymentreportmodule/export')
var exportUrl = "{{ url('/dailysalepaymentreportmodule/export') }}" + "?date=" + selectedDate + "&type=" + exportType;
window.location.href = exportUrl;
}
});
// මුළු රිපෝට් එකම එක්ස්පෝර්ට් කරන්න හදපු Function එක
function exportFullReport(exportType) {
var selectedDate = $('#report_date').val();
function exportFullPdf(exportType) {
var selectedDate = $('#report_date').val();
// ඔයාගේ Controller එකේ export route එකට මේක හරවන්න ඕනේ.
// උදාහරණයක් විදිහට: url('/dailysalepaymentreportmodule/export')
var exportUrl = "{{ url('/dailysalepaymentreportmodule/export') }}" + "?date=" + selectedDate + "&type=" + exportType;
window.location.href = exportUrl;
}
</script>
var exportUrl = "{{ url('/dailysalepaymentreportmodule/export_pdf') }}" + "?date=" + selectedDate + "&type=" + exportType;
window.location.href = exportUrl;
}
</script>
@endpush

View File

@@ -17,5 +17,6 @@ Route::middleware(['common', 'auth', 'active'])->group(function () {
Route::controller(DailySalePaymentReportModuleController::class)->prefix('dailysalepaymentreportmodule')->group(function () {
Route::get('/', 'index');
Route::get('/export', 'exportReport');
Route::get('/export_pdf', 'exportPDF');
});
});