@extends('layouts.admin')
{{-- ১. স্টাইল সেকশন (হেডারে লোড হবে) --}}
@section('styles')
{{-- Select2 CSS --}}
@endsection
{{-- ২. কন্টেন্ট সেকশন (বডিতে লোড হবে) --}}
@section('content')
@php
$users = \App\Models\User::where('status', 1)->orderBy('name', 'asc')->get();
@endphp
@include('admin.partials.pro-hero', [
'icon' => 'fas fa-cash-register',
'title' => __('Point of Sale (POS)'),
'subtitle' => __('Create sales and manage orders'),
'breadcrumbs' => [
['label' => __('Dashboard'), 'url' => route('admin.dashboard')],
['label' => __('POS'), 'url' => null],
],
])
@include('includes.admin.form-error')
@include('includes.admin.form-success')
@if(session('success'))
Success! {{ session('success') }}
@endif
{{-- মেইন ফর্ম --}}
{{-- ৩. রিসেন্ট সেলস (অ্যাকশন বাটন ফিক্সড) --}}
@php
use App\Models\PaymentTransaction;
$methodLabels = [
'cash' => 'Cash (নগদ)', 'Cash' => 'Cash (নগদ)',
'bkash' => 'bKash', 'Bkash' => 'bKash', 'BKASH' => 'bKash',
'nagad' => 'Nagad', 'Nagad' => 'Nagad',
'rocket' => 'Rocket', 'Rocket' => 'Rocket',
'bank' => 'Bank Transfer', 'Bank' => 'Bank Transfer',
'other' => 'CreativePay', 'Other' => 'CreativePay',
];
$ordersData = [];
foreach ($orders as $o) {
$rawNote = $o->support_note ?? '';
$parsed = json_decode($rawNote, true);
$method = trim($o->payment_method ?? '');
$gatewayTrx = null;
$senderPhone = null;
$invoiceId = is_array($parsed) && !empty($parsed['txn_id'])
? $parsed['txn_id']
: (preg_match('/CP-[A-Z0-9]+(?:-[0-9]+)?/i', $rawNote, $m) ? strtoupper($m[0]) : null);
if ($invoiceId) {
$cpTxn = PaymentTransaction::where('invoice_id', $invoiceId)->first();
if ($cpTxn) {
if (!empty($cpTxn->payment_method)) {
$method = $cpTxn->payment_method;
}
$gatewayTrx = $cpTxn->transaction_id;
$senderPhone = $cpTxn->sender_number;
}
}
if ($method === '' || strtolower($method) === 'other') {
$method = $method !== '' ? $method : '—';
}
$ordersData[$o->id] = [
'invoice' => $o->order_number,
'customer' => $o->customer->name ?? '',
'phone' => $o->customer->phone ?? '',
'total' => (float) $o->total_amount,
'paid' => (float) $o->paid_amount,
'due' => (float) $o->due_amount,
'method' => $method,
'methodLabel' => $methodLabels[$method] ?? $methodLabels[strtolower($method)] ?? ucfirst($method),
'gatewayTrx' => $gatewayTrx,
'senderPhone' => $senderPhone,
'description' => $o->description ?? '',
'note' => is_array($parsed) ? $parsed : ($rawNote !== '' ? ['_raw' => $rawNote] : null),
'isPaid' => $o->due_amount <= 0,
];
}
@endphp
| Invoice |
Customer |
Total |
Paid |
Due |
Status |
Action |
@forelse($orders as $order)
{{ $order->order_number }}
{{ $order->created_at->format('d M, h:i A') }}
|
{{ $order->customer->name }}
{{ $order->customer->phone }}
|
৳{{ number_format($order->total_amount, 2) }} |
৳{{ number_format($order->paid_amount, 2) }} |
৳{{ number_format($order->due_amount, 2) }} |
@if($order->due_amount > 0) Due
@else Paid @endif
|
|
@empty
| No data found. |
@endforelse
{{-- Collect Due Modals (টেবিলের বাইরে) --}}
@foreach($orders as $order)
@if($order->due_amount > 0)