219 lines
13 KiB
PHP
219 lines
13 KiB
PHP
<x-app-layout>
|
|
<div class="max-w-7xl mx-auto space-y-6 pb-12">
|
|
{{-- SECTION 1: Header & Statistik --}}
|
|
<div class="flex flex-col md:flex-row md:items-center justify-between gap-4">
|
|
<div>
|
|
<h2 class="text-2xl font-black text-slate-800 tracking-tighter uppercase leading-none">Breeding Activity</h2>
|
|
<p class="text-[10px] text-slate-400 font-bold uppercase tracking-widest mt-1 italic">Monitoring silsilah & kelahiran • Real-time Lineage Data</p>
|
|
</div>
|
|
|
|
<div class="flex items-center gap-3">
|
|
<div class="hidden sm:block bg-white border border-slate-200 px-4 py-2 rounded-xl shadow-sm">
|
|
<p class="text-[8px] font-black text-slate-400 uppercase tracking-widest leading-none">Total Program</p>
|
|
<p class="text-sm font-black text-indigo-600 mt-1">{{ $mattings->total() }}</p>
|
|
</div>
|
|
|
|
{{-- PROTEKSI TOMBOL CREATE MATTING --}}
|
|
@can('check-access', ['matting', 'create'])
|
|
<a href="{{ route('matting.create') }}" class="inline-flex items-center px-5 py-3 bg-indigo-600 text-white text-[10px] font-black rounded-xl shadow-lg shadow-indigo-100 hover:bg-indigo-700 transition-all active:scale-95">
|
|
<i class="fas fa-plus mr-2"></i> INPUT MATTING BARU
|
|
</a>
|
|
@endcan
|
|
</div>
|
|
</div>
|
|
|
|
{{-- SECTION 2: Tabel Matting --}}
|
|
<div class="bg-white border border-slate-200 rounded-[2rem] overflow-hidden shadow-sm">
|
|
<div class="overflow-x-auto">
|
|
<table class="w-full text-left border-collapse table-auto">
|
|
<thead class="bg-slate-50 text-[10px] font-black text-slate-400 uppercase tracking-widest border-b border-slate-100">
|
|
<tr>
|
|
<th class="px-6 py-4">Indukan (Sire x Dam)</th>
|
|
<th class="px-4 py-4 text-center">Periode Kawin</th>
|
|
<th class="px-4 py-4 text-center">Estimasi Lahir</th>
|
|
<th class="px-4 py-4 text-center">Hasil</th>
|
|
<th class="px-6 py-4 text-right" style="min-width: 280px;">Aksi</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody class="divide-y divide-slate-100 font-medium text-slate-700">
|
|
@forelse($mattings as $m)
|
|
<tr class="hover:bg-slate-50/50 transition-all group">
|
|
{{-- Pasangan Indukan --}}
|
|
<td class="px-6 py-4 align-middle">
|
|
<div class="flex items-center gap-3">
|
|
@if($m->sire->foto || $m->dam->foto)
|
|
<div class="flex -space-x-3 shrink-0">
|
|
@if($m->sire->foto)
|
|
<div class="w-11 h-11 rounded-xl bg-slate-100 border-2 border-white overflow-hidden shadow-sm">
|
|
<img src="{{ asset('storage/'.$m->sire->foto) }}" class="w-full h-full object-cover">
|
|
</div>
|
|
@endif
|
|
@if($m->dam->foto)
|
|
<div class="w-11 h-11 rounded-xl bg-slate-100 border-2 border-white overflow-hidden shadow-sm">
|
|
<img src="{{ asset('storage/'.$m->dam->foto) }}" class="w-full h-full object-cover">
|
|
</div>
|
|
@endif
|
|
</div>
|
|
@endif
|
|
|
|
<div class="min-w-0">
|
|
<div class="text-xs font-black text-slate-800 flex items-center gap-1 whitespace-nowrap">
|
|
{{ $m->sire->nama_kucing }} <i class="fas fa-heart text-[8px] text-rose-400"></i> {{ $m->dam->nama_kucing }}
|
|
</div>
|
|
<div class="flex gap-1.5 mt-1.5">
|
|
<span class="text-[8px] font-black bg-slate-800 text-white px-2 py-0.5 rounded uppercase tracking-tighter shadow-sm">
|
|
{{ $m->sire->kode_ems ?? 'NO EMS' }}
|
|
</span>
|
|
<span class="text-[8px] font-black bg-indigo-100 text-indigo-700 px-2 py-0.5 rounded uppercase border border-indigo-200 tracking-tighter shadow-sm">
|
|
{{ $m->dam->kode_ems ?? 'NO EMS' }}
|
|
</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</td>
|
|
|
|
<td class="px-4 py-4 text-center align-middle whitespace-nowrap">
|
|
<p class="text-[10px] font-black text-slate-700 leading-none">
|
|
{{ $m->tgl_kawin_awal->format('d M') }} - {{ $m->tgl_kawin_akhir->format('d M Y') }}
|
|
</p>
|
|
<span class="text-[9px] text-slate-400 font-bold italic uppercase">{{ $m->tgl_kawin_awal->diffInDays($m->tgl_kawin_akhir) + 1 }} Hari</span>
|
|
</td>
|
|
|
|
<td class="px-4 py-4 text-center align-middle" x-data="breedingCountdown('{{ $m->tgl_kawin_awal->addDays(63)->format('Y-m-d') }}')">
|
|
<div :class="isUrgent ? 'bg-rose-50 border-rose-100' : 'bg-indigo-50 border-indigo-100'"
|
|
class="inline-flex flex-col px-3 py-1.5 rounded-xl border border-dashed transition-all w-28">
|
|
<div class="flex items-center justify-center gap-1.5 mb-0.5">
|
|
<i :class="isUrgent ? 'text-rose-500 animate-pulse' : 'text-indigo-400'" class="fas fa-stopwatch text-[9px]"></i>
|
|
<span class="text-[8px] font-black uppercase" :class="isUrgent ? 'text-rose-600' : 'text-indigo-600'">HPL: {{ $m->tgl_kawin_awal->addDays(63)->format('d/m') }}</span>
|
|
</div>
|
|
<p class="text-[10px] font-black" :class="isUrgent ? 'text-rose-700' : 'text-slate-700'">
|
|
<template x-if="daysRemaining > 0"><span x-text="daysRemaining + ' Hari'"></span></template>
|
|
<template x-if="daysRemaining === 0"><span>HARI H</span></template>
|
|
<template x-if="daysRemaining < 0"><span class="text-slate-400 italic">LEWAT</span></template>
|
|
</p>
|
|
</div>
|
|
</td>
|
|
|
|
<td class="px-4 py-4 text-center align-middle whitespace-nowrap">
|
|
<div class="flex flex-col gap-1 items-center">
|
|
<span class="px-3 py-1 bg-emerald-50 text-emerald-600 rounded-lg text-[10px] font-black border border-emerald-100 uppercase">
|
|
{{ $m->kittens_count }} Anak
|
|
</span>
|
|
{!! $m->status_badge !!}
|
|
</div>
|
|
</td>
|
|
|
|
<td class="px-6 py-4 text-right align-middle">
|
|
<div class="flex justify-end items-center gap-16">
|
|
|
|
{{-- PROTEKSI TOMBOL EDIT MATTING --}}
|
|
@can('check-access', ['matting', 'update'])
|
|
<a href="{{ route('matting.edit', $m->id) }}"
|
|
class="flex items-center gap-3 p-3 text-slate-400 hover:text-indigo-600 hover:bg-indigo-50 rounded-2xl transition-all group/btn"
|
|
title="Edit Data">
|
|
<i class="fas fa-pencil-alt text-base"></i>
|
|
<span class="text-[10px] font-black uppercase hidden group-hover/btn:inline tracking-widest">Edit</span>
|
|
</a>
|
|
@endcan
|
|
|
|
{{-- PROTEKSI TOMBOL HAPUS MATTING --}}
|
|
@can('check-access', ['matting', 'delete'])
|
|
<form action="{{ route('matting.destroy', $m->id) }}" method="POST" class="inline m-0">
|
|
@csrf @method('DELETE')
|
|
<button type="button"
|
|
onclick="confirmDelete(this, '{{ addslashes($m->sire->nama_kucing) }} x {{ addslashes($m->dam->nama_kucing) }}')"
|
|
class="flex items-center gap-3 p-3 text-slate-400 hover:text-rose-500 hover:bg-rose-50 rounded-2xl transition-all group/btn"
|
|
title="Hapus Data">
|
|
<i class="fas fa-trash-alt text-base"></i>
|
|
<span class="text-[10px] font-black uppercase hidden group-hover/btn:inline tracking-widest">Hapus</span>
|
|
</button>
|
|
</form>
|
|
@endcan
|
|
|
|
</div>
|
|
</td>
|
|
</tr>
|
|
@empty
|
|
<tr>
|
|
<td colspan="5" class="px-6 py-20 text-center text-slate-400 uppercase text-[10px] font-black tracking-widest">
|
|
Belum ada riwayat breeding
|
|
</td>
|
|
</tr>
|
|
@endforelse
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<div class="p-6 bg-slate-50/30 border-t border-slate-100">
|
|
{{ $mattings->links() }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@push('scripts')
|
|
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@11"></script>
|
|
<script>
|
|
{{-- Script Alpine Init & SweetAlert Tetap Sama --}}
|
|
document.addEventListener('alpine:init', () => {
|
|
Alpine.data('breedingCountdown', (targetDate) => ({
|
|
target: new Date(targetDate),
|
|
daysRemaining: 0,
|
|
isUrgent: false,
|
|
init() {
|
|
const now = new Date();
|
|
now.setHours(0,0,0,0);
|
|
const targetDateObj = new Date(this.target);
|
|
targetDateObj.setHours(0,0,0,0);
|
|
const diffTime = targetDateObj - now;
|
|
const diffDays = Math.ceil(diffTime / (1000 * 60 * 60 * 24));
|
|
this.daysRemaining = diffDays;
|
|
this.isUrgent = diffDays <= 7 && diffDays >= 0;
|
|
}
|
|
}));
|
|
});
|
|
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
const Toast = Swal.mixin({
|
|
toast: true,
|
|
position: 'top-end',
|
|
showConfirmButton: false,
|
|
timer: 3500,
|
|
timerProgressBar: true
|
|
});
|
|
|
|
@if(session('success'))
|
|
Toast.fire({ icon: 'success', title: '{{ session('success') }}' });
|
|
@endif
|
|
|
|
@if(session('error'))
|
|
Swal.fire({
|
|
icon: 'info',
|
|
title: 'Informasi Sistem',
|
|
text: '{{ session('error') }}',
|
|
confirmButtonColor: '#4f46e5',
|
|
customClass: { popup: 'rounded-[2rem]' }
|
|
});
|
|
@endif
|
|
});
|
|
|
|
function confirmDelete(button, pairName) {
|
|
Swal.fire({
|
|
title: 'Hapus Riwayat?',
|
|
html: "Anda akan menghapus data breeding:<br><b class='text-indigo-600'>" + pairName + "</b>",
|
|
icon: 'warning',
|
|
showCancelButton: true,
|
|
confirmButtonColor: '#ef4444',
|
|
cancelButtonColor: '#64748b',
|
|
confirmButtonText: 'Ya, Hapus!',
|
|
cancelButtonText: 'Batal',
|
|
reverseButtons: true,
|
|
customClass: { popup: 'rounded-[2rem]' }
|
|
}).then((result) => {
|
|
if (result.isConfirmed) {
|
|
button.closest('form').submit();
|
|
}
|
|
});
|
|
}
|
|
</script>
|
|
@endpush
|
|
</x-app-layout> |