Files
ilycats/resources/views/pages/matting/index.blade.php
T

49 lines
6.7 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<x-app-layout>
<div class="mb-6 flex flex-col gap-4 sm:flex-row sm:items-end sm:justify-between">
<div><h1 class="text-2xl font-bold text-slate-900">Perkawinan & pembiakan</h1><p class="mt-1 text-sm text-slate-500">Alur: catat kawin → konfirmasi hamil → pantau HPL → catat kelahiran/anakan.</p></div>
@can('check-access',['matting','create'])<a href="{{ route('matting.create') }}" class="rounded-xl bg-indigo-600 px-4 py-2.5 text-sm font-semibold text-white hover:bg-indigo-700"><i class="fas fa-plus mr-2"></i>Catat perkawinan</a>@endcan
</div>
<div class="mb-5 grid gap-3 sm:grid-cols-4">
@php
$all=$mattings->getCollection();
$countProses=$all->where('status','proses')->count();
$countHamil=$all->where('status','hamil')->count();
$countLahir=$all->where('status','berhasil')->count();
$countGagal=$all->where('status','gagal')->count();
@endphp
<div class="rounded-2xl border border-blue-100 bg-blue-50/60 p-4"><p class="text-xs font-semibold text-blue-700">Menunggu konfirmasi</p><p class="mt-1 text-2xl font-bold text-blue-900">{{ $countProses }}</p></div>
<div class="rounded-2xl border border-amber-100 bg-amber-50/60 p-4"><p class="text-xs font-semibold text-amber-700">Hamil / menunggu lahir</p><p class="mt-1 text-2xl font-bold text-amber-900">{{ $countHamil }}</p></div>
<div class="rounded-2xl border border-emerald-100 bg-emerald-50/60 p-4"><p class="text-xs font-semibold text-emerald-700">Sudah lahir</p><p class="mt-1 text-2xl font-bold text-emerald-900">{{ $countLahir }}</p></div>
<div class="rounded-2xl border border-slate-200 bg-white p-4"><p class="text-xs font-semibold text-slate-500">Tidak berhasil</p><p class="mt-1 text-2xl font-bold text-slate-800">{{ $countGagal }}</p></div>
</div>
<section class="overflow-hidden rounded-2xl border border-slate-200 bg-white">
<div class="overflow-x-auto"><table class="min-w-full divide-y divide-slate-200 text-sm"><thead class="bg-slate-50 text-left text-xs font-semibold text-slate-500"><tr><th class="px-4 py-3">Pasangan induk</th><th class="px-4 py-3">Periode kawin</th><th class="px-4 py-3">HPL</th><th class="px-4 py-3">Tahap</th><th class="px-4 py-3">Anakan</th><th class="px-4 py-3 text-right">Aksi</th></tr></thead><tbody class="divide-y divide-slate-100">
@forelse($mattings as $m)
@php
$edd=$m->tgl_kawin_awal?->copy()->addDays(63); $days=$edd ? (int)now()->startOfDay()->diffInDays($edd->copy()->startOfDay(),false) : null;
$flowLabel=match($m->status){'hamil'=>'Hamil / menunggu lahir','berhasil'=>'Sudah lahir','gagal'=>'Tidak berhasil',default=>'Menunggu konfirmasi'};
$flowStyle=match($m->status){'hamil'=>'bg-amber-50 text-amber-700 border-amber-100','berhasil'=>'bg-emerald-50 text-emerald-700 border-emerald-100','gagal'=>'bg-rose-50 text-rose-700 border-rose-100',default=>'bg-blue-50 text-blue-700 border-blue-100'};
@endphp
<tr class="align-top hover:bg-slate-50">
<td class="px-4 py-4"><div class="flex items-center gap-3"><div class="flex -space-x-2">@foreach([$m->sire,$m->dam] as $parent)<img src="{{ $parent?->foto_url ?? asset('images/default-cat.png') }}" class="h-10 w-10 rounded-full border-2 border-white object-cover" alt="">@endforeach</div><div><p class="font-semibold text-slate-900">{{ $m->sire->nama_kucing ?? '-' }} × {{ $m->dam->nama_kucing ?? '-' }}</p><p class="mt-1 text-xs text-slate-500">EMS {{ $m->sire->kode_ems ?? '-' }} × {{ $m->dam->kode_ems ?? '-' }}</p></div></div></td>
<td class="px-4 py-4"><p class="text-slate-700">{{ $m->tgl_kawin_awal?->format('d-m-Y') ?? '-' }}{{ $m->tgl_kawin_akhir ? ' s.d. '.$m->tgl_kawin_akhir->format('d-m-Y') : '' }}</p>@if($m->tgl_kawin_awal && $m->tgl_kawin_akhir)<p class="mt-1 text-xs text-slate-500">{{ $m->tgl_kawin_awal->diffInDays($m->tgl_kawin_akhir)+1 }} hari</p>@endif</td>
<td class="px-4 py-4">@if($edd)<p class="font-semibold text-slate-800">{{ $edd->format('d-m-Y') }}</p>@if(in_array($m->status,['proses','hamil']))<p class="mt-1 text-xs {{ $days!==null && $days<=7 && $days>=0?'font-semibold text-rose-600':'text-slate-500' }}">{{ $days<0?'Lewat '.abs($days).' hari':($days===0?'HPL hari ini':$days.' hari lagi') }}</p>@endif @else<span class="text-slate-400">-</span>@endif</td>
<td class="px-4 py-4"><span class="inline-flex rounded-full border px-2.5 py-1 text-xs font-semibold {{ $flowStyle }}">{{ $flowLabel }}</span>
@can('check-access',['matting','update'])
<div class="mt-2 flex flex-wrap gap-1">
@if($m->status==='proses')<form method="POST" action="{{ route('matting.status',$m) }}">@csrf @method('PATCH')<input type="hidden" name="status" value="hamil"><button class="rounded-lg bg-amber-100 px-2 py-1 text-[11px] font-semibold text-amber-800">Konfirmasi hamil</button></form>@endif
@if(in_array($m->status,['proses','hamil']))<form method="POST" action="{{ route('matting.status',$m) }}">@csrf @method('PATCH')<input type="hidden" name="status" value="berhasil"><button class="rounded-lg bg-emerald-100 px-2 py-1 text-[11px] font-semibold text-emerald-800">Tandai lahir</button></form><form method="POST" action="{{ route('matting.status',$m) }}">@csrf @method('PATCH')<input type="hidden" name="status" value="gagal"><button class="rounded-lg bg-rose-100 px-2 py-1 text-[11px] font-semibold text-rose-800">Tidak berhasil</button></form>@endif
</div>
@endcan
</td>
<td class="px-4 py-4"><p class="font-semibold text-slate-800">{{ $m->kittens_count }}</p><p class="text-xs text-slate-500">anakan tercatat</p></td>
<td class="px-4 py-4"><div class="flex justify-end gap-1">@can('check-access',['matting','update'])<a href="{{ route('matting.edit',$m) }}" class="rounded-lg p-2 text-slate-500 hover:bg-slate-100" title="Ubah / catat anakan"><i class="fas fa-pen"></i></a>@endcan @can('check-access',['matting','delete'])<form method="POST" action="{{ route('matting.destroy',$m) }}" id="delete-matting-{{ $m->id }}">@csrf @method('DELETE')<button type="button" onclick="confirmDelete('delete-matting-{{ $m->id }}','riwayat pembiakan ini')" class="rounded-lg p-2 text-rose-500 hover:bg-rose-50"><i class="fas fa-trash"></i></button></form>@endcan</div></td>
</tr>
@empty<tr><td colspan="6" class="px-4 py-12 text-center text-sm text-slate-500">Belum ada riwayat pembiakan.</td></tr>@endforelse
</tbody></table></div>
<div class="border-t border-slate-200 p-4">{{ $mattings->links() }}</div>
</section>
</x-app-layout>