<?php $__env->startSection('title', __('nav.dashboard')); ?>
<?php $__env->startSection('content'); ?>
<div class="page-head">
    <div>
        <h1><?php echo e(__('nav.dashboard')); ?></h1>
        <div class="text-muted small"><?php echo e(format_datetime($date, false)); ?></div>
    </div>
    <div class="d-flex flex-wrap gap-2">
        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('billing.view')): ?><a class="btn btn-success" href="<?php echo e(route('billing.index')); ?>"><?php echo e(__('nav.billing')); ?></a><?php endif; ?>
        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('overdue.view')): ?><a class="btn btn-outline-warning" href="<?php echo e(route('overdue.index')); ?>"><?php echo e(__('nav.overdue')); ?></a><?php endif; ?>
        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('cash.view')): ?><a class="btn btn-outline-secondary" href="<?php echo e(route('cash.index')); ?>"><?php echo e(__('nav.cash')); ?></a><?php endif; ?>
    </div>
</div>

<div class="row g-3">
    <?php $__currentLoopData = ['current_cash','today_collections','overdue_bills','outstanding','available_lines','active_lines']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $key): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <div class="col-6 col-md-4 col-xl-2">
            <div class="card stat-card">
                <div class="card-body">
                    <div class="small text-muted"><?php echo e(__('messages.'.$key)); ?></div>
                    <div class="fs-5 fw-bold">
                        <?php if(in_array($key, ['today_collections','current_cash','outstanding'])): ?>
                            <?php echo e(money($stats[$key])); ?>

                        <?php else: ?>
                            <?php echo e($stats[$key]); ?>

                        <?php endif; ?>
                    </div>
                </div>
            </div>
        </div>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</div>

<form method="get" class="filter-bar d-flex flex-wrap align-items-end gap-3 mt-4 mb-3">
    <div>
        <label class="form-label small text-muted mb-1"><?php echo e(__('messages.date')); ?></label>
        <input class="form-control" type="date" name="date" value="<?php echo e($date); ?>">
    </div>
    <div>
        <label class="form-label small text-muted mb-1"><?php echo e(__('messages.per_page')); ?></label>
        <select class="form-select" name="limit" style="width:auto">
            <?php $__currentLoopData = [10, 25, 50]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $n): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                <option value="<?php echo e($n); ?>" <?php if((int) $limit === $n): echo 'selected'; endif; ?>><?php echo e($n); ?></option>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
        </select>
    </div>
    <button class="btn btn-success"><?php echo e(__('messages.filter')); ?></button>
</form>

<div class="row g-3">
    <div class="col-lg-6">
        <div class="card widget-card">
            <div class="card-header d-flex justify-content-between align-items-center">
                <strong><?php echo e(__('messages.payments_for_day')); ?> — <?php echo e(format_datetime($date, false)); ?></strong>
                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('billing.view')): ?><a href="<?php echo e(route('billing.index')); ?>"><?php echo e(__('messages.view')); ?></a><?php endif; ?>
            </div>
            <div class="table-responsive">
                <table class="table compact-table mb-0">
                    <thead>
                        <tr>
                            <th><?php echo e(__('messages.line')); ?></th>
                            <th><?php echo e(__('messages.customer')); ?></th>
                            <th><?php echo e(__('messages.amount')); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $recentPayments; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $payment): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td><?php echo e($payment->line?->phone_number ?? '—'); ?></td>
                            <td><?php echo e($payment->customer?->name ?? '—'); ?></td>
                            <td><?php echo e(money($payment->amount)); ?></td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr><td colspan="3"><?php echo e(__('messages.no_results')); ?></td></tr>
                    <?php endif; ?>
                    </tbody>
                </table>
            </div>
            <?php echo $__env->make('partials.widget-pagination', ['paginator' => $recentPayments], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
        </div>
    </div>
    <div class="col-lg-6">
        <div class="card widget-card">
            <div class="card-header d-flex justify-content-between align-items-center">
                <strong><?php echo e(__('nav.available_lines')); ?></strong>
                <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('lines.view')): ?><a href="<?php echo e(route('lines.index', ['status' => 'available'])); ?>"><?php echo e(__('messages.view')); ?></a><?php endif; ?>
            </div>
            <div class="table-responsive">
                <table class="table compact-table mb-0">
                    <thead>
                        <tr>
                            <th><?php echo e(__('messages.line')); ?></th>
                            <th><?php echo e(__('messages.company')); ?></th>
                            <th><?php echo e(__('messages.price')); ?></th>
                        </tr>
                    </thead>
                    <tbody>
                    <?php $__empty_1 = true; $__currentLoopData = $availableLines; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $line): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                        <tr>
                            <td><a href="<?php echo e(route('lines.show',$line)); ?>"><?php echo e($line->phone_number); ?></a></td>
                            <td><?php echo e($line->telecomCompany?->name); ?></td>
                            <td><?php echo e(money($line->sale_price)); ?></td>
                        </tr>
                    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                        <tr><td colspan="3"><?php echo e(__('messages.no_results')); ?></td></tr>
                    <?php endif; ?>
                    </tbody>
                </table>
            </div>
            <?php echo $__env->make('partials.widget-pagination', ['paginator' => $availableLines], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH D:\laragon\www\esim\resources\views/dashboard/index.blade.php ENDPATH**/ ?>