<?php $__env->startSection('title','Dashboard'); ?>
<?php $__env->startSection('page_title','Management Dashboard'); ?>
<?php $__env->startSection('content'); ?>
<div class="page-head"><div><h1>Business Overview</h1><p>Live figures derived from posted journals and transport operations.</p></div><div class="muted"><?php echo e(now()->format('l, d F Y')); ?></div></div>
<div class="grid grid-4"><div class="card metric"><div class="metric-label">Cash & Bank</div><div class="metric-value">AED <?php echo e(number_format((float)$metrics['cash'],2)); ?></div><div class="metric-note">Posted ledger balance</div></div><div class="card metric"><div class="metric-label">Accounts Receivable</div><div class="metric-value">AED <?php echo e(number_format((float)$metrics['receivables'],2)); ?></div><div class="metric-note">Customer ledger only</div></div><div class="card metric"><div class="metric-label">Accounts Payable</div><div class="metric-value">AED <?php echo e(number_format((float)$metrics['payables'],2)); ?></div><div class="metric-note">Vendor ledger only</div></div><div class="card metric"><div class="metric-label">Net Working Position</div><div class="metric-value">AED <?php echo e(number_format((float)$metrics['cash']+(float)$metrics['receivables']-(float)$metrics['payables'],2)); ?></div></div></div>
<div class="grid grid-4" style="margin-top:18px"><div class="card metric"><div class="metric-label">Revenue This Month</div><div class="metric-value">AED <?php echo e(number_format((float)$metrics['revenue'],2)); ?></div></div><div class="card metric"><div class="metric-label">Costs & Expenses</div><div class="metric-value">AED <?php echo e(number_format((float)$metrics['cost'],2)); ?></div></div><div class="card metric"><div class="metric-label">Net Profit</div><div class="metric-value">AED <?php echo e(number_format((float)$metrics['net_profit'],2)); ?></div></div><div class="card metric"><div class="metric-label">Open Jobs</div><div class="metric-value"><?php echo e($metrics['open_jobs']); ?></div><div class="metric-note"><?php echo e($metrics['in_transit']); ?> currently in transit</div></div></div>
<div class="grid grid-3" style="margin-top:18px"><div class="card metric"><div class="metric-label">Missing POD</div><div class="metric-value"><?php echo e($metrics['pending_pod']); ?></div><div class="metric-note"><a href="<?php echo e(route('jobs.index',['status'=>'delivered'])); ?>">Review delivered jobs</a></div></div><div class="card metric"><div class="metric-label">Ready to Invoice</div><div class="metric-value"><?php echo e($metrics['ready_to_invoice']); ?></div><div class="metric-note"><a href="<?php echo e(route('jobs.index',['status'=>'ready_to_invoice'])); ?>">Open billing queue</a></div></div><div class="card metric"><div class="metric-label">VAT Estimate</div><div class="metric-value"><a href="<?php echo e(route('reports.vat')); ?>">View Report</a></div><div class="metric-note">Output less recoverable input VAT</div></div></div>
<div class="grid grid-2" style="margin-top:18px"><div class="card"><div class="card-head"><strong>Recent Transport Jobs</strong><a href="<?php echo e(route('jobs.index')); ?>">View all</a></div><div class="table-wrap"><table class="table"><thead><tr><th>Job</th><th>Customer</th><th>Status</th><th>Profit</th></tr></thead><tbody><?php $__empty_1 = true; $__currentLoopData = $recentJobs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $job): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><tr><td><a href="<?php echo e(route('jobs.show',$job)); ?>"><?php echo e($job->job_number); ?></a><div class="muted"><?php echo e($job->job_date->format('d M')); ?></div></td><td><?php echo e($job->customer?->legal_name); ?></td><td><span class="badge status-<?php echo e($job->status); ?>"><?php echo e(ucwords(str_replace('_',' ',$job->status))); ?></span></td><td>AED <?php echo e(number_format((float)$job->profit,2)); ?></td></tr><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><tr><td colspan="4" class="empty">No jobs yet.</td></tr><?php endif; ?></tbody></table></div></div>
<div class="card"><div class="card-head"><strong>Overdue Customer Invoices</strong><a href="<?php echo e(route('reports.aging','customer')); ?>">Customer aging</a></div><div class="table-wrap"><table class="table"><thead><tr><th>Invoice</th><th>Customer</th><th>Due</th><th>Balance</th></tr></thead><tbody><?php $__empty_1 = true; $__currentLoopData = $overdueInvoices; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $i): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><tr><td><a href="<?php echo e(route('invoices.show',$i)); ?>"><?php echo e($i->invoice_number); ?></a></td><td><?php echo e($i->party?->legal_name); ?></td><td><?php echo e(optional($i->due_date)->format('d M Y')); ?></td><td>AED <?php echo e(number_format((float)$i->grand_total-(float)$i->paid_total-(float)$i->allocated_total,2)); ?></td></tr><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><tr><td colspan="4" class="empty">No overdue invoices.</td></tr><?php endif; ?></tbody></table></div></div></div>
<div class="grid grid-2" style="margin-top:18px"><div class="card"><div class="card-head"><strong>Vendor Bills Pending Action</strong><a href="<?php echo e(route('bills.index')); ?>">View bills</a></div><div class="table-wrap"><table class="table"><thead><tr><th>Bill</th><th>Vendor</th><th>Total</th><th>Status</th></tr></thead><tbody><?php $__empty_1 = true; $__currentLoopData = $pendingBills; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $b): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><?php ($s=$b->status instanceof \App\Enums\DocumentStatus?$b->status->value:$b->status); ?><tr><td><a href="<?php echo e(route('bills.show',$b)); ?>"><?php echo e($b->bill_number); ?></a></td><td><?php echo e($b->party?->legal_name); ?></td><td>AED <?php echo e(number_format((float)$b->grand_total,2)); ?></td><td><span class="badge status-<?php echo e($s); ?>"><?php echo e(ucwords(str_replace('_',' ',$s))); ?></span></td></tr><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><tr><td colspan="4" class="empty">Nothing pending.</td></tr><?php endif; ?></tbody></table></div></div><div class="card"><div class="card-head"><strong>Vehicle Document Alerts</strong><a href="<?php echo e(route('masters.index','vehicles')); ?>">Vehicle register</a></div><div class="table-wrap"><table class="table"><thead><tr><th>Vehicle</th><th>Registration</th><th>Insurance</th><th>Permit</th></tr></thead><tbody><?php $__empty_1 = true; $__currentLoopData = $expiringVehicles; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $v): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?><tr><td><?php echo e($v->plate_number); ?></td><td><?php echo e(optional($v->registration_expiry)->format('d M Y')); ?></td><td><?php echo e(optional($v->insurance_expiry)->format('d M Y')); ?></td><td><?php echo e(optional($v->permit_expiry)->format('d M Y')); ?></td></tr><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?><tr><td colspan="4" class="empty">No upcoming expiries.</td></tr><?php endif; ?></tbody></table></div></div></div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/cbo/public_html/resources/views/dashboard/index.blade.php ENDPATH**/ ?>