minor changes in order and dashboard, records

This commit is contained in:
divya abdar
2025-12-19 16:15:18 +05:30
parent 7ef28e06ae
commit 48f7ab82ff
6 changed files with 113 additions and 45 deletions

View File

@@ -497,18 +497,18 @@ class AdminOrderController extends Controller
->with('success', 'Order reset successfully.');
}
public function orderShow()
{
$orders = Order::with([
'markList', // company, customer, origin, destination, date
'shipments', // shipment_id, shipment_date, status
'invoice' // invoice number, dates, amounts, status
public function orderShow()
{
$orders = Order::with([
'markList', // company, customer, origin, destination, date
'shipments', // shipment_id, shipment_date, status
'invoice' // invoice number, dates, amounts, status
])
->latest('id') // show latest orders first
->get();
->latest('id') // show latest orders first
->get();
return view('admin.orders', compact('orders'));
}
return view('admin.orders', compact('orders'));
}
// inside AdminOrderController

View File

@@ -1,7 +1,30 @@
@extends('admin.layouts.app')
@section('page-title', 'Dashboard')
@php
use App\Models\Order;
use App\Models\OrderItem;
use App\Models\Shipment;
use App\Models\Invoice;
use App\Models\User;
use App\Models\Staff;
$totalOrders = Order::count();
$pendingOrders = Order::where('status', 'pending')->count();
$totalShipments = Shipment::count();
$totalItems = OrderItem::count();
$totalRevenue = Invoice::sum('final_amount_with_gst');
// USERS (USING status COLUMN)
$activeCustomers = User::where('status', 'active')->count();
$inactiveCustomers = User::where('status', 'inactive')->count();
// STAFF (ACTIVE ONLY, SoftDeletes SAFE)
$totalStaff = Staff::where('status', 'active')->count();
$orders = Order::latest()->get();
@endphp
@section('content')
<style>
/* ===== GLOBAL RESPONSIVE STYLES ===== */
@@ -1114,16 +1137,16 @@ body, .container-fluid {
<!-- STATS CARDS -->
<div class="stats-row-wrap">
<div class="stats-row">
<div class="stats-card stats-card-blue"><span class="stats-icon">📦</span><div class="stats-label">Total Shipments</div><div class="stats-value">1,247</div></div>
<div class="stats-card stats-card-blue"><span class="stats-icon">👥</span><div class="stats-label">Active Customers</div><div class="stats-value">342</div></div>
<div class="stats-card stats-card-green"><span class="stats-icon">💰</span><div class="stats-label">Total Revenue</div><div class="stats-value">123</div></div>
<div class="stats-card stats-card-red"><span class="stats-icon"></span><div class="stats-label">Pending Order</div><div class="stats-value">23</div></div>
<div class="stats-card stats-card-blue"><span class="stats-icon">📦</span><div class="stats-label">Total Shipments</div><div class="stats-value">{{ $totalShipments }}</div></div>
<div class="stats-card stats-card-blue"><span class="stats-icon">👥</span><div class="stats-label">Active Customers</div><div class="stats-value">{{ $activeCustomers }}</div></div>
<div class="stats-card stats-card-green"><span class="stats-icon">💰</span><div class="stats-label">Total Revenue</div><div class="stats-value">{{ number_format($totalRevenue, 2) }}</div></div>
<div class="stats-card stats-card-red"><span class="stats-icon"></span><div class="stats-label">Pending Order</div><div class="stats-value">{{ $pendingOrders }}</div></div>
</div>
<div class="stats-row">
<div class="stats-card stats-card-blue"><span class="stats-icon">📦</span><div class="stats-label">Total Orders</div><div class="stats-value">453</div></div>
<div class="stats-card stats-card-blue"><span class="stats-icon">🧑‍💼</span><div class="stats-label">Total Staff</div><div class="stats-value">125</div></div>
<div class="stats-card stats-card-blue"><span class="stats-icon">📦</span><div class="stats-label">Total Items</div><div class="stats-value">321</div></div>
<div class="stats-card stats-card-orng"><span class="stats-icon"></span><div class="stats-label">Inactive Customers</div><div class="stats-value">10</div></div>
<div class="stats-card stats-card-blue"><span class="stats-icon">📦</span><div class="stats-label">Total Orders</div><div class="stats-value">{{ $totalOrders }}</div></div>
<div class="stats-card stats-card-blue"><span class="stats-icon">🧑‍💼</span><div class="stats-label">Total Staff</div><div class="stats-value">{{ $totalStaff }}</div></div>
<div class="stats-card stats-card-blue"><span class="stats-icon">📦</span><div class="stats-label">Total Items</div><div class="stats-value">{{ $totalItems }}</div></div>
<div class="stats-card stats-card-orng"><span class="stats-icon"></span><div class="stats-label">Inactive Customers</div><div class="stats-value">{{ $inactiveCustomers }}</div></div>
</div>
</div>

View File

@@ -799,7 +799,7 @@
// Pagination state
let currentPage = 1;
const itemsPerPage = 10;
let allOrders = @json($orders);
let allOrders = {!! $orders->toJson() !!};
let filteredOrders = [...allOrders];
// Status icon helper functions
@@ -874,11 +874,11 @@
const searchFields = [
order.order_id?.toString().toLowerCase(),
order.shipments?.[0]?.shipment_id?.toString().toLowerCase(),
order.markList?.customer_id?.toString().toLowerCase(),
order.markList?.company_name?.toString().toLowerCase(),
order.mark_list?.customer_id?.toString().toLowerCase(),
order.mark_list?.company_name?.toString().toLowerCase(),
order.invoice?.invoice_number?.toString().toLowerCase(),
order.markList?.origin?.toString().toLowerCase(),
order.markList?.destination?.toString().toLowerCase()
order.mark_list?.origin?.toString().toLowerCase(),
order.mark_list?.destination?.toString().toLowerCase()
];
matchesSearch = searchFields.some(field => field && field.includes(searchTerm.toLowerCase()));
}
@@ -901,7 +901,7 @@
// Initialize pagination and filters
document.addEventListener('DOMContentLoaded', function() {
// Set today as default "to" date
renderTable();
renderTable();
updatePaginationControls();
// Pagination events
@@ -1099,7 +1099,7 @@
const paginatedItems = filteredOrders.slice(startIndex, endIndex);
paginatedItems.forEach(order => {
const mark = order.markList || null;
const mark = order.mark_list || null;
const invoice = order.invoice || null;
const shipment = order.shipments?.[0] || null;

View File

@@ -912,10 +912,6 @@
</label>
<select class="filter-control" id="companyFilter">
<option value="" selected>All Companies</option>
<option value="ABC Corporation">ABC Corporation</option>
<option value="XYZ Enterprises">XYZ Enterprises</option>
<option value="Global Traders">Global Traders</option>
<option value="Tech Solutions Ltd">Tech Solutions Ltd</option>
</select>
</div>
<div class="filter-group">
@@ -1101,6 +1097,7 @@
document.addEventListener('DOMContentLoaded', function() {
// Initialize statistics and pagination
populateCompanyFilter(allReports);
updateStatistics();
renderTable();
updatePaginationControls();
@@ -1403,5 +1400,33 @@
// Initial filter application
filterTable();
});
function populateCompanyFilter(reports) {
const companySelect = document.getElementById('companyFilter');
if (!companySelect) return;
// Collect unique company names
const companies = new Set();
reports.forEach(r => {
if (r.company_name && r.company_name.trim() !== '') {
companies.add(r.company_name.trim());
}
});
// Sort alphabetically
const sortedCompanies = Array.from(companies).sort();
// Remove existing options except "All Companies"
companySelect.innerHTML = '<option value="">All Companies</option>';
// Append options
sortedCompanies.forEach(company => {
const option = document.createElement('option');
option.value = company;
option.textContent = company;
companySelect.appendChild(option);
});
}
</script>
@endsection

View File

@@ -1074,7 +1074,7 @@
<thead>
<tr>
<th>#</th>
<th>Order ID</th>
<th>Description</th>
<th>Origin</th>
<th>Destination</th>
<th>Description</th>
@@ -1090,11 +1090,8 @@
<tr class="{{ $orderItem['order_id'] == $orderData['order_id'] ? 'current-order' : '' }}">
<td>{{ $index + 1 }}</td>
<td>
<strong>{{ $orderItem['order_id'] ?? '-' }}</strong>
@if($orderItem['order_id'] == $orderData['order_id'])
<span class="badge bg-primary ms-1">Current</span>
@endif
</td>
<strong>{{ $orderItem['description'] ?? '-' }}</strong>
</td>
<td>{{ $orderItem['origin'] ?? '-' }}</td>
<td>{{ $orderItem['destination'] ?? '-' }}</td>
<td>{{ $orderItem['description'] ?? '-' }}</td>
@@ -1103,7 +1100,13 @@
<td>{{ $orderItem['ttl_qty'] ?? '-' }}</td>
<td><strong>{{ number_format($orderItem['amount'] ?? 0, 2) }}</strong></td>
<td>
<span class="badge bg-info">In Shipment</span>
@php
$status = strtolower(str_replace(' ', '-', $orderItem['status'] ?? 'pending'));
@endphp
<span class="status-badge status-{{ $status }}">
{{ ucfirst($orderItem['status'] ?? 'Pending') }}
</span>
</td>
</tr>
@endforeach
@@ -1162,6 +1165,22 @@
</div>
@endif
</div>
@php
$derivedShipmentId = null;
foreach ($shipmentsData as $shipment) {
foreach ($shipment['orders'] as $orderItem) {
if ($orderItem['order_id'] == $orderData['order_id']) {
$derivedShipmentId = $shipment['shipment_id'];
break 2; // exit both loops
}
}
}
@endphp
@php
$gstAmount = $invoiceData['summary']['total'] - $invoiceData['summary']['amount'];
@endphp
{{-- =====================================================
INVOICE DETAILS TAB
@@ -1209,7 +1228,9 @@
</div>
<div class="invoice-meta-item">
<div class="invoice-meta-label">Belongs to Shipment</div>
<div class="invoice-meta-value">{{ $order->invoice->shipment_id ?? 'N/A' }}</div>
<div class="invoice-meta-value">
{{ $invoiceData['shipment_id'] ?? $derivedShipmentId ?? 'N/A' }}
</div>
</div>
<div class="invoice-meta-item">
<div class="invoice-meta-label">Order ID</div>
@@ -1271,8 +1292,8 @@
<td>{{ $item->qty }}</td>
<td>{{ $item->qty }}</td>
<td>{{ $item->unit ?? '-' }}</td>
<td>{{ number_format($item->rate, 2) }}</td>
<td><strong>{{ number_format($item->amount, 2) }}</strong></td>
<td>{{ number_format($item->price ?? 0, 2) }}</td>
<td><strong>{{ number_format($item->ttl_amount ?? 0, 2) }}</strong></td>
<td>{{ number_format($item->cbm ?? 0, 3) }}</td>
<td>{{ number_format(($item->cbm ?? 0) * $item->qty, 3) }}</td>
<td>{{ number_format($item->kg ?? 0, 3) }}</td>
@@ -1293,13 +1314,12 @@
<div class="invoice-total-value">{{ number_format($invoiceData['summary']['amount'], 2) }}</div>
</div>
<div class="invoice-total-item">
<div class="invoice-total-label">CGST (0%):</div>
<div class="invoice-total-value">{{ number_format($invoiceData['summary']['cgst'], 2) }}</div>
</div>
<div class="invoice-total-item">
<div class="invoice-total-label">SGST (0%):</div>
<div class="invoice-total-value">{{ number_format($invoiceData['summary']['sgst'], 2) }}</div>
<div class="invoice-total-label">GST:</div>
<div class="invoice-total-value">
{{ number_format($gstAmount, 2) }}
</div>
</div>
</div>
<div class="invoice-grand-total">