<?php $__env->startSection('title', __('nav.lines')); ?>
<?php $__env->startSection('content'); ?>
<div class="d-flex justify-content-between align-items-center mb-3">
    <h1 class="h4 mb-0"><?php echo e(__('nav.lines')); ?></h1>
    <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('lines.create')): ?><a class="btn btn-success" href="<?php echo e(route('lines.create')); ?>"><?php echo e(__('messages.create')); ?></a><?php endif; ?>
</div>

<div class="company-chips mb-3">
    <a class="company-chip <?php echo e(!request('telecom_company_id') ? 'active' : ''); ?>" href="<?php echo e(route('lines.index', request()->except('telecom_company_id', 'page'))); ?>"><?php echo e(__('messages.all')); ?></a>
    <?php $__currentLoopData = $companies; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $c): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <a class="company-chip <?php echo e((string) request('telecom_company_id') === (string) $c->id ? 'active' : ''); ?>" href="<?php echo e(route('lines.index', array_merge(request()->except('page'), ['telecom_company_id' => $c->id]))); ?>"><?php echo e($c->name); ?></a>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</div>

<div class="company-chips mb-3">
    <?php $__currentLoopData = ['' => __('messages.all'), 'available' => __('status.available'), 'active' => __('status.active'), 'suspended' => __('status.suspended'), 'returned' => __('status.returned')]; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $value => $label): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
        <a class="company-chip <?php echo e((string) request('status') === (string) $value ? 'active' : ''); ?>" href="<?php echo e(route('lines.index', array_merge(request()->except('page'), ['status' => $value]))); ?>"><?php echo e($label); ?></a>
    <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
</div>

<form class="row g-2 mb-3">
    <input type="hidden" name="telecom_company_id" value="<?php echo e(request('telecom_company_id')); ?>">
    <input type="hidden" name="status" value="<?php echo e(request('status')); ?>">
    <div class="col-md-4"><input class="form-control" name="q" value="<?php echo e(request('q')); ?>" placeholder="<?php echo e(__('messages.search_number')); ?>"></div>
    <div class="col-md-2"><button class="btn btn-outline-secondary"><?php echo e(__('messages.filter')); ?></button></div>
</form>
<div class="card">
    <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.customer')); ?></th>
                <th><?php echo e(__('messages.plan')); ?></th>
                <th><?php echo e(__('messages.line_price')); ?></th>
                <th><?php echo e(__('messages.plan_price')); ?></th>
                <th><?php echo e(__('messages.status')); ?></th>
                <th></th>
            </tr>
            </thead>
            <tbody>
            <?php $__empty_1 = true; $__currentLoopData = $lines; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $l): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <tr>
                    <td><a href="<?php echo e(route('lines.show',$l)); ?>"><?php echo e($l->phone_number); ?></a></td>
                    <td><?php echo e($l->telecomCompany?->name); ?></td>
                    <td><?php echo e($l->customer?->name ?? '—'); ?></td>
                    <td><?php echo e($l->currentPlan?->name ?? '—'); ?></td>
                    <td><?php echo e(money($l->sale_price)); ?></td>
                    <td><?php echo e($l->currentPlan ? money($l->currentPlan->price) : '—'); ?></td>
                    <td><span class="badge text-bg-secondary"><?php echo e($l->status->label()); ?></span></td>
                    <td>
                        <?php if (app(\Illuminate\Contracts\Auth\Access\Gate::class)->check('sales.create')): ?>
                            <?php if($l->isAvailable()): ?>
                                <a href="<?php echo e(route('sales.create')); ?>"><?php echo e(__('nav.new_sale')); ?></a>
                            <?php endif; ?>
                        <?php endif; ?>
                    </td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr><td colspan="8"><?php echo e(__('messages.no_results')); ?></td></tr>
            <?php endif; ?>
            </tbody>
        </table>
    </div>
    <?php echo $__env->make('partials.pagination', ['paginator' => $lines], \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?>
</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/lines/index.blade.php ENDPATH**/ ?>