feat: reset presensi (attendances) di menu Reset

Menambahkan opsi 'Presensi' pada form reset aplikasi:
- Hapus seluruh data attendances (dari sync E-Jurnal & manual)
- Tampilkan jumlah data presensi di card
- Dapat dipilih terpisah dari pelanggaran
This commit is contained in:
Bro
2026-07-24 17:41:20 +07:00
parent a867b3a267
commit 5206e2396b
2 changed files with 16 additions and 1 deletions
@@ -18,6 +18,7 @@ class ResetController extends Controller
public function index(): View public function index(): View
{ {
$stats = [ $stats = [
'attendances' => DB::table('attendances')->count(),
'violations' => DB::table('violations')->count(), 'violations' => DB::table('violations')->count(),
'evidences' => DB::table('violation_evidences')->count(), 'evidences' => DB::table('violation_evidences')->count(),
'handlings' => DB::table('violation_handlings')->count(), 'handlings' => DB::table('violation_handlings')->count(),
@@ -41,7 +42,7 @@ class ResetController extends Controller
$request->validate([ $request->validate([
'confirm_password' => ['required', 'string'], 'confirm_password' => ['required', 'string'],
'reset_items' => ['required', 'array', 'min:1'], 'reset_items' => ['required', 'array', 'min:1'],
'reset_items.*' => ['in:violations,evidences,handlings,sp_letters,notifications,students,classes,categories,types,thresholds,settings,users,backups'], 'reset_items.*' => ['in:attendances,violations,evidences,handlings,sp_letters,notifications,students,classes,categories,types,thresholds,settings,users,backups'],
]); ]);
if (!Hash::check($request->confirm_password, $request->user()->password)) { if (!Hash::check($request->confirm_password, $request->user()->password)) {
@@ -74,6 +75,11 @@ class ResetController extends Controller
$cleared[] = 'Foto bukti'; $cleared[] = 'Foto bukti';
} }
if (in_array('attendances', $items)) {
DB::table('attendances')->delete();
$cleared[] = 'Presensi';
}
if (in_array('violations', $items)) { if (in_array('violations', $items)) {
DB::table('handling_participants')->delete(); DB::table('handling_participants')->delete();
DB::table('violation_handlings')->delete(); DB::table('violation_handlings')->delete();
+9
View File
@@ -67,6 +67,15 @@
<div class="p-5"> <div class="p-5">
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3"> <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3">
{{-- Presensi --}}
<label class="reset-card relative flex items-start gap-3 p-4 rounded-xl border border-gray-200 cursor-pointer hover:border-gray-300 has-[:checked]:border-orange-300 has-[:checked]:bg-orange-50/50 transition-all select-none">
<input type="checkbox" name="reset_items[]" value="attendances" class="reset-checkbox mt-0.5 w-4 h-4 rounded border-gray-300 text-orange-500 focus:ring-orange-400 focus:ring-offset-0 flex-shrink-0">
<div class="min-w-0">
<p class="text-sm font-semibold text-gray-900">Presensi</p>
<p class="text-xs text-gray-400 mt-0.5">{{ $stats['attendances'] }} data (dari sinkron E-Jurnal & manual)</p>
</div>
</label>
{{-- Pelanggaran & Evidences --}} {{-- Pelanggaran & Evidences --}}
<label class="reset-card relative flex items-start gap-3 p-4 rounded-xl border border-gray-200 cursor-pointer hover:border-gray-300 has-[:checked]:border-red-300 has-[:checked]:bg-red-50/50 transition-all select-none"> <label class="reset-card relative flex items-start gap-3 p-4 rounded-xl border border-gray-200 cursor-pointer hover:border-gray-300 has-[:checked]:border-red-300 has-[:checked]:bg-red-50/50 transition-all select-none">
<input type="checkbox" name="reset_items[]" value="violations" class="reset-checkbox mt-0.5 w-4 h-4 rounded border-gray-300 text-red-500 focus:ring-red-400 focus:ring-offset-0 flex-shrink-0"> <input type="checkbox" name="reset_items[]" value="violations" class="reset-checkbox mt-0.5 w-4 h-4 rounded border-gray-300 text-red-500 focus:ring-red-400 focus:ring-offset-0 flex-shrink-0">