
<?php $__env->startSection('title','Loan Admin – Dashboard'); ?>

<?php $__env->startPush('styles'); ?>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css"/>
<style>
.card{border-radius:16px;background:#fff;box-shadow:0 10px 24px rgba(0,0,0,.06);border:1px solid rgba(2,8,23,.06)}
.badge{display:inline-flex;align-items:center;gap:.35rem;border-radius:999px;padding:.25rem .6rem;font-weight:700;font-size:11px;border:1px solid transparent}
.badge-pending{background:#fff7ed;color:#c2410c;border-color:#fed7aa}
.btn{display:inline-flex;align-items:center;gap:.45rem;border-radius:999px;padding:.55rem .9rem;font-weight:800;color:#fff;background:linear-gradient(90deg,#6366f1,#06b6d4)}
.table{width:100%;border-collapse:separate;border-spacing:0}
.table th,.table td{padding:.7rem .6rem;border-bottom:1px solid #eef2f7;font-size:14px}
.table th{background:#f8fafc;text-align:left;font-weight:800;color:#1f2937}
</style>
<?php $__env->stopPush(); ?>

<?php $__env->startSection('content'); ?>
<div class="mx-auto max-w-6xl px-4 py-6 space-y-6">

  <?php if(session('success')): ?>
    <div class="rounded-xl border border-emerald-200 bg-emerald-50 px-3 py-3 text-sm text-emerald-800">
      <i class="fa-solid fa-circle-check"></i> <?php echo e(session('success')); ?>

    </div>
  <?php endif; ?>

  
  <div class="card p-5">
    <div class="mb-3 flex items-center gap-2">
      <div class="h-9 w-9 rounded-xl bg-indigo-500 text-white flex items-center justify-center">
        <i class="fa-solid fa-users"></i>
      </div>
      <div class="text-lg font-extrabold text-slate-900">Users who took loans</div>
    </div>

    <div class="overflow-x-auto">
      <table class="table">
        <thead>
          <tr>
            <th>User</th>
            <th>Total Loans</th>
            <th>Running</th>
            <th>Completed (Paid)</th>
          </tr>
        </thead>
        <tbody>
          <?php $__empty_1 = true; $__currentLoopData = $users; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $u): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <tr>
              <td class="font-semibold text-slate-800"><?php echo e($u->name); ?> <div class="text-xs text-slate-500"><?php echo e($u->email); ?></div></td>
              <td><?php echo e($u->total_loans); ?></td>
              <td><?php echo e($u->running_loans); ?></td>
              <td><?php echo e($u->completed_loans); ?></td>
            </tr>
          <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <tr><td colspan="4" class="text-sm text-slate-500 py-4">No users with loans.</td></tr>
          <?php endif; ?>
        </tbody>
      </table>
    </div>

    <div class="mt-3"><?php echo e($users->links()); ?></div>
  </div>

  
  <div class="card p-5">
    <div class="mb-3 flex items-center gap-2">
      <div class="h-9 w-9 rounded-xl bg-amber-500 text-white flex items-center justify-center">
        <i class="fa-solid fa-bell"></i>
      </div>
      <div class="text-lg font-extrabold text-slate-900">Installments pending approval</div>
      <span class="badge badge-pending ms-2"><i class="fa-regular fa-clock"></i> <?php echo e($pendingInstallments->total()); ?></span>
    </div>

    <div class="overflow-x-auto">
      <table class="table">
        <thead>
          <tr>
            <th>Installment</th>
            <th>User</th>
            <th>Loan</th>
            <th>Amount</th>
            <th>Method / Trx</th>
            <th>Submitted</th>
            <th>Action</th>
          </tr>
        </thead>
        <tbody>
        <?php $__empty_1 = true; $__currentLoopData = $pendingInstallments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $ins): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
          <tr>
            <td>#<?php echo e($ins->id); ?></td>
            <td><?php echo e($ins->loan->user->name); ?></td>
            <td>#<?php echo e($ins->loan_id); ?></td>
            <td>৳ <?php echo e(number_format($ins->paid_amount ?? $ins->amount)); ?></td>
            <td><?php echo e(strtoupper($ins->payment_method ?? '-')); ?> / <?php echo e($ins->payment_trx_id ?? '-'); ?></td>
            <td><?php echo e(optional($ins->paid_at)->format('d M Y, h:i A') ?? $ins->created_at->format('d M Y, h:i A')); ?></td>
            <td>
              <form method="POST" action="<?php echo e(route('admin.installments.approve', $ins)); ?>">
                <?php echo csrf_field(); ?>
                <button class="btn"><i class="fa-solid fa-badge-check"></i> Approve</button>
              </form>
            </td>
          </tr>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
          <tr><td colspan="7" class="text-sm text-slate-500 py-4">No pending submissions.</td></tr>
        <?php endif; ?>
        </tbody>
      </table>
    </div>

    <div class="mt-3"><?php echo e($pendingInstallments->links()); ?></div>
  </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('backend.master', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /home/ecareba2/loan.rkmotorsbike.top/resources/views/admin/loans/dashboard.blade.php ENDPATH**/ ?>