@extends('layouts.app')
@section('title', __('nav.overdue'))
@section('content')
<h1 class="h4 mb-3">{{ __('nav.overdue') }}</h1>
<form class="row g-2 mb-3">
<div class="col-md-4"><input class="form-control" name="q" value="{{ request('q') }}" placeholder="{{ __('messages.search_line_or_customer') }}"></div>
<div class="col-md-2"><input class="form-control" type="number" name="year" value="{{ request('year', now()->year) }}" placeholder="{{ __('messages.year') }}"></div>
<div class="col-md-2"><input class="form-control" type="number" name="month" min="1" max="12" value="{{ request('month', now()->month) }}" placeholder="{{ __('messages.month') }}"></div>
<div class="col-md-2"><select class="form-select" name="telecom_company_id"><option value="">{{ __('messages.company') }}</option>@foreach($companies as $c)<option value="{{ $c->id }}" @selected(request('telecom_company_id')==$c->id)>{{ $c->name }}</option>@endforeach</select></div>
<div class="col-md-2"><button class="btn btn-success w-100">{{ __('messages.search') }}</button></div>
</form>
<div class="mb-2">
<a class="btn btn-sm btn-outline-success" href="{{ route('overdue.export', request()->query()) }}">{{ __('messages.excel') }}</a>
<button class="btn btn-sm btn-outline-secondary" onclick="window.print()">{{ __('messages.print') }}</button>
</div>
<div class="card"><div class="table-responsive"><table class="table mb-0">
<thead><tr><th>{{ __('messages.line') }}</th><th>{{ __('messages.customer') }}</th><th>{{ __('messages.national_id') }}</th><th>{{ __('messages.main_account') }}</th><th>{{ __('messages.plan') }}</th><th>{{ __('messages.monthly_amount') }}</th><th>{{ __('messages.last_paid_period') }}</th><th>{{ __('messages.overdue_months') }}</th><th>{{ __('messages.outstanding') }}</th></tr></thead>
<tbody>@forelse($lines as $row)
<tr>
<td><a href="{{ route('billing.show',$row['line']) }}">{{ $row['line']->phone_number }}</a></td>
<td>{{ $row['line']->customer?->name }}</td>
<td>{{ $row['line']->customer?->national_id }}</td>
<td>{{ $row['line']->mainAccount?->name }}</td>
<td>{{ $row['line']->currentPlan?->name }}</td>
<td>{{ money($row['monthly']) }}</td>
<td>{{ $row['paid_through']?->label() }}</td>
<td>{{ $row['overdue_months'] }}</td>
<td>{{ money($row['outstanding']) }}</td>
</tr>
@empty<tr><td colspan="9">{{ __('messages.no_results') }}</td></tr>@endforelse</tbody></table></div>
<div class="card-body">{{ $lines->links() }}</div></div>
@endsection
