<div id="policies-last-updated" class="box overflow-hidden">

	<div class="box-header">
		<div class="sm:flex justify-between space-y-2 sm:space-y-0">
			<h5 class="box-title my-auto">{{ __('forms.policies') }}: {{ $entity->entityable->first_name }}
				{{ $entity->entityable->last_name }} {{ $entity->entityable->short_name }}</h5>
			<div class="block ltr:ml-auto rtl:mr-auto my-auto">
				@if ($entity->entityable_type == 'App\Models\CRM\Company')
					<a href="{{ route('crm.companies.edit', $entity->entityable) }}"
						class="ti-btn ti-btn-soft-info py-1 px-3 my-0">Profil klijenta</a>
				@else
					<a href="{{ route('crm.individuals.edit', $entity->entityable) }}"
						class="ti-btn ti-btn-soft-info py-1 px-3 my-0">Profil klijenta</a>
				@endif
				<a href="{{ route('osiguranje.insurance-policies.create', $entity) }}"
					class="ti-btn ti-btn ti-btn-soft-success py-1 px-3 my-0">Kreriaj polisu</a>
			</div>
		</div>
	</div>

	<div class="box-body p-0 activity-table">
		<div class="overflow-auto">
			<table class="ti-custom-table ti-custom-table-head">
				<thead>
					<tr>
						<th scope="col">{{ __('forms.policy_number') }}</th>
						<th scope="col">{{ __('forms.insured_amount') }}</th>
						<th scope="col">{{ __('forms.premium') }}</th>
						<th scope="col">{{ __('forms.start_date') }}</th>
						<th scope="col">{{ __('forms.end_date') }}</th>
						<th scope="col">{{ __('Status') }}</th>
						<th scope="col" class="!text-end">{{ __('forms.Actions') }}</th>
					</tr>
				</thead>
				<tbody>
					@if ($policies)
						@forelse($policies as $policy)
							<tr>

								<td>
									<p class="text-sm mb-0 text-gray-800 dark:text-white">{{ $policy->policy_number }}</p>
								</td>
								<td>
									<code class="text-gray-800 dark:text-white">{{ number_format($policy->insured_amount, 2, ',', '.') }}</code>
								</td>
								<td>
									<code class="text-gray-800 dark:text-white">{{ number_format($policy->premium, 2, ',', '.') }}</code>
								</td>
								<td>
									<span class="text-xs text-gray-500 dark:text-white/70">{{ $policy->start_date }}</span>
								</td>
								<td>
									<span class="text-xs text-gray-500 dark:text-white/70">{{ $policy->end_date }}</span>
								</td>
								<td>
									@if ($policy->status == 'active')
										<span class="badge bg-success/10 text-success py-1">{{ $policy->status }}</span>
									@else
										<span class="badge bg-red-100 text-red-800 py-1">{{ $policy->status }}</span>
									@endif
								</td>
								<td class="border-top-dashed pe-4 text-right">
									<!-- View Button -->

									<a href="#"
										class="rounded-sm bg-success/10 text-success hover:bg-success hover:text-white py-1 px-3 mr-2">
										<i class="ti ti-eye"></i>
									</a>

									<!-- Edit Button -->
									<a href="{{ route('osiguranje.insurance-policies.edit', [$entity, $policy]) }}"
										class="rounded-sm bg-info/10 text-info hover:bg-info hover:text-white py-1 px-3 mr-2">
										<i class="ti ti-edit"></i>
									</a>

									<!-- Delete Button -->
									{{-- <button type="button" class="rounded-sm bg-danger/10 text-danger hover:bg-danger hover:text-white py-1 px-3">
										<i class="ti ti-trash"></i>
									</button> --}}
								</td>
							</tr>
						@empty
							<tr>
								<td colspan="6" class="text-center text-gray-500">No policies found.</td>
							</tr>
						@endforelse
					@endif

				</tbody>
			</table>

		</div>
	</div>
</div>
