<?php ($line = $snapshot['line']); ?>
<div class="card card-body mb-3">
    <div class="row">
        <div class="col-md-6">
            <p class="mb-1"><?php echo e(__('messages.phone')); ?>: <strong class="fs-4"><?php echo e($line->phone_number); ?></strong></p>
            <p class="mb-1"><?php echo e(__('messages.customer')); ?>: <strong><?php echo e($snapshot['customer']?->name ?: '—'); ?></strong></p>
            <p class="mb-1"><?php echo e(__('messages.national_id')); ?>: <?php echo e($snapshot['customer']?->national_id ?: '—'); ?></p>
            <?php if($line->mainAccount || $line->subAccount): ?>
            <p class="mb-1"><?php echo e(__('messages.main_account')); ?>: <?php echo e($line->mainAccount?->name ?: '—'); ?></p>
            <p class="mb-1"><?php echo e(__('messages.sub_account')); ?>: <?php echo e($line->subAccount?->name ?: '—'); ?></p>
            <?php endif; ?>
        </div>
        <div class="col-md-6">
            <p class="mb-1"><?php echo e(__('messages.plan')); ?>: <?php echo e($snapshot['plan']?->name); ?> <?php echo e($snapshot['plan'] ? money($snapshot['plan_price']).' / '.__('messages.month') : ''); ?></p>
            <p class="mb-1"><?php echo e(__('messages.package_year')); ?>:
                <?php if($snapshot['year_start']): ?>
                    <?php echo e(__('messages.package_year_n', ['n' => $snapshot['year_number'] ?? 1])); ?>

                    — <?php echo e($snapshot['year_start']->translatedFormat('F Y')); ?> / <?php echo e($snapshot['year_end']->translatedFormat('F Y')); ?>

                <?php else: ?>
                    —
                <?php endif; ?>
            </p>
            <?php if(! empty($snapshot['new_year_opened'])): ?>
                <p class="small text-success"><?php echo e(__('messages.new_year_opened')); ?></p>
            <?php endif; ?>
            <p class="mb-1"><?php echo e(__('messages.paid_through')); ?>: <strong><?php echo e($snapshot['paid_through']?->label() ?: '—'); ?></strong></p>
            <p class="mb-1"><?php echo e(__('messages.outstanding')); ?>: <strong><?php echo e(money($snapshot['outstanding'])); ?></strong></p>
        </div>
    </div>
    <div class="mt-3">
        <div class="small text-muted mb-1"><?php echo e(__('messages.paid_months')); ?></div>
        <?php $__empty_1 = true; $__currentLoopData = $snapshot['paid_periods'] ?? []; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <span class="badge text-bg-success me-1 mb-1"><?php echo e($row['period']->label()); ?></span>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <span class="text-muted">—</span>
        <?php endif; ?>
    </div>
    <div class="mt-2">
        <div class="small text-muted mb-1"><?php echo e(__('messages.remaining_months')); ?></div>
        <?php $__empty_1 = true; $__currentLoopData = $snapshot['unpaid_periods']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
            <span class="badge text-bg-warning me-1 mb-1"><?php echo e($row['period']->label()); ?></span>
        <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
            <span class="text-muted">—</span>
        <?php endif; ?>
    </div>
</div>
<?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('billing.create')): ?>
<form method="post" action="<?php echo e(route('billing.collect')); ?>" class="card card-body" id="collectForm">
    <?php echo csrf_field(); ?>
    <input type="hidden" name="line_id" value="<?php echo e($line->id); ?>">
    <h2 class="h6"><?php echo e(__('messages.select_periods')); ?></h2>
    <p class="small text-muted"><?php echo e(__('messages.amount_may_change')); ?></p>
    <div class="d-flex flex-wrap gap-2 mb-3">
        <button type="button" class="btn btn-sm btn-outline-secondary" data-months="1"><?php echo e(__('messages.pay_months', ['count' => 1])); ?></button>
        <button type="button" class="btn btn-sm btn-outline-secondary" data-months="2"><?php echo e(__('messages.pay_months', ['count' => 2])); ?></button>
        <button type="button" class="btn btn-sm btn-outline-secondary" data-months="3"><?php echo e(__('messages.pay_months', ['count' => 3])); ?></button>
        <button type="button" class="btn btn-sm btn-outline-primary" data-months="all"><?php echo e(__('messages.pay_all_remaining')); ?></button>
    </div>
    <?php $__empty_1 = true; $__currentLoopData = $snapshot['unpaid_periods']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $row): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
        <div class="row align-items-center g-2 mb-2">
            <div class="col-md-6">
                <div class="form-check">
                    <input class="form-check-input period-check" type="checkbox" name="period_ids[]" value="<?php echo e($row['period']->id); ?>" id="p<?php echo e($row['period']->id); ?>">
                    <label class="form-check-label" for="p<?php echo e($row['period']->id); ?>"><?php echo e($row['period']->label()); ?></label>
                </div>
            </div>
            <div class="col-md-4">
                <input class="form-control" name="amounts[<?php echo e($row['period']->id); ?>]" value="<?php echo e($row['amount']); ?>" inputmode="decimal">
            </div>
        </div>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
        <p><?php echo e(__('messages.no_unpaid_periods')); ?></p>
    <?php endif; ?>
    <div class="row g-2 mt-2">
        <div class="col-md-4"><select class="form-select" name="payment_method"><?php $__currentLoopData = ['cash','visa','bank','wallet','other']; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $m): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?><option value="<?php echo e($m); ?>"><?php echo e(__('status.method_'.$m)); ?></option><?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?></select></div>
        <div class="col-md-4"><input class="form-control" name="discount" value="0" placeholder="<?php echo e(__('messages.discount')); ?>"></div>
        <div class="col-md-4"><button class="btn btn-success w-100"><?php echo e(__('messages.collect')); ?></button></div>
    </div>
</form>
<script>
document.querySelectorAll('#collectForm [data-months]').forEach((btn) => {
    btn.addEventListener('click', () => {
        const boxes = [...document.querySelectorAll('#collectForm .period-check')];
        const count = btn.dataset.months === 'all' ? boxes.length : Number(btn.dataset.months);
        boxes.forEach((box, i) => { box.checked = i < count; });
    });
});
</script>
<?php endif; ?>
<?php /**PATH D:\laragon\www\esim\resources\views/billing/partials/snapshot.blade.php ENDPATH**/ ?>