feat: reset selektif + import Excel jenis pelanggaran
- Reset selektif: admin bisa pilih data mana yang akan dikosongkan - Auto-seed kategori & SP threshold default setelah direset - Deteksi admin via role (tidak hardcoded ID 1) - UI reset full-width dengan checkbox card - Import Excel jenis pelanggaran (.xlsx) dengan template download - Drag & drop upload, validasi header, auto-match kategori, skip duplikat - Tombol Import + Download Template di halaman Jenis Pelanggaran
This commit is contained in:
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\ViolationCategory;
|
||||
use App\Models\ViolationType;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Str;
|
||||
use PhpOffice\PhpSpreadsheet\IOFactory;
|
||||
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;
|
||||
|
||||
class ImportController extends Controller
|
||||
{
|
||||
public function downloadTemplate()
|
||||
{
|
||||
$spreadsheet = new \PhpOffice\PhpSpreadsheet\Spreadsheet();
|
||||
$sheet = $spreadsheet->getActiveSheet();
|
||||
|
||||
// Header
|
||||
$sheet->setCellValue('A1', 'Kategori');
|
||||
$sheet->setCellValue('B1', 'Nama Pelanggaran');
|
||||
$sheet->setCellValue('C1', 'Poin');
|
||||
$sheet->setCellValue('D1', 'Sanksi Default');
|
||||
$sheet->setCellValue('E1', 'Deskripsi');
|
||||
|
||||
// Bold header
|
||||
$sheet->getStyle('A1:E1')->getFont()->setBold(true);
|
||||
$sheet->getStyle('A1:E1')->getFill()
|
||||
->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
|
||||
->getStartColor()->setARGB('FFE2E8F0');
|
||||
|
||||
// Contoh baris
|
||||
$sheet->setCellValue('A2', 'Ringan');
|
||||
$sheet->setCellValue('B2', 'Terlambat masuk kelas');
|
||||
$sheet->setCellValue('C2', 5);
|
||||
$sheet->setCellValue('D2', 'Teguran lisan');
|
||||
$sheet->setCellValue('E2', 'Terlambat masuk kelas setelah bel berbunyi');
|
||||
|
||||
$sheet->setCellValue('A3', 'Sedang');
|
||||
$sheet->setCellValue('B3', 'Membuang sampah sembarangan');
|
||||
$sheet->setCellValue('C3', 20);
|
||||
$sheet->setCellValue('D3', 'Membersihkan lingkungan selama 1 jam');
|
||||
|
||||
// Autofit column width
|
||||
foreach (range('A', 'E') as $col) {
|
||||
$sheet->getColumnDimension($col)->setAutoSize(true);
|
||||
}
|
||||
|
||||
// Data validation for kategori column
|
||||
$categories = ViolationCategory::where('is_active', true)->pluck('name')->toArray();
|
||||
if (!empty($categories)) {
|
||||
$validation = $sheet->getCell('A2')->getDataValidation();
|
||||
$validation->setType(\PhpOffice\PhpSpreadsheet\Cell\DataValidation::TYPE_LIST);
|
||||
$validation->setFormula1('"' . implode(',', $categories) . '"');
|
||||
$validation->setAllowBlank(false);
|
||||
$validation->setShowDropDown(true);
|
||||
}
|
||||
|
||||
$writer = new Xlsx($spreadsheet);
|
||||
|
||||
return response()->streamDownload(function () use ($writer) {
|
||||
$writer->save('php://output');
|
||||
}, 'template-jenis-pelanggaran.xlsx', [
|
||||
'Content-Type' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
|
||||
]);
|
||||
}
|
||||
|
||||
public function importViolationTypes(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'file' => ['required', 'file', 'mimes:xlsx,xls', 'max:2048'],
|
||||
]);
|
||||
|
||||
try {
|
||||
$file = $request->file('file');
|
||||
$spreadsheet = IOFactory::load($file->getPathname());
|
||||
$worksheet = $spreadsheet->getActiveSheet();
|
||||
$rows = $worksheet->toArray();
|
||||
|
||||
if (count($rows) < 2) {
|
||||
return back()->with('error', 'File kosong. Isi minimal 1 baris data.');
|
||||
}
|
||||
|
||||
// Validate header
|
||||
$header = array_map('trim', $rows[0]);
|
||||
$expectedHeader = ['Kategori', 'Nama Pelanggaran', 'Poin', 'Sanksi Default', 'Deskripsi'];
|
||||
if (array_slice($header, 0, 4) !== array_slice($expectedHeader, 0, 4)) {
|
||||
return back()->with('error', 'Format kolom tidak sesuai. Gunakan template yang disediakan.');
|
||||
}
|
||||
|
||||
$categories = ViolationCategory::where('is_active', true)->get()->keyBy(fn($c) => strtolower(trim($c->name)));
|
||||
$imported = 0;
|
||||
$skipped = 0;
|
||||
$errors = [];
|
||||
|
||||
foreach (array_slice($rows, 1) as $index => $row) {
|
||||
$rowNum = $index + 2;
|
||||
|
||||
$categoryName = trim($row[0] ?? '');
|
||||
$typeName = trim($row[1] ?? '');
|
||||
$points = trim($row[2] ?? '');
|
||||
$sanction = trim($row[3] ?? '');
|
||||
$description = trim($row[4] ?? '');
|
||||
|
||||
// Skip baris kosong
|
||||
if (empty($categoryName) && empty($typeName)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Validasi: nama pelanggaran wajib
|
||||
if (empty($typeName)) {
|
||||
$errors[] = "Baris {$rowNum}: Nama Pelanggaran tidak boleh kosong.";
|
||||
$skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Validasi: poin harus angka
|
||||
if (!is_numeric($points) || $points < 0) {
|
||||
$errors[] = "Baris {$rowNum} ('{$typeName}'): Poin harus angka positif.";
|
||||
$skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
// Cari kategori
|
||||
$catKey = strtolower($categoryName);
|
||||
if (empty($categoryName) || !isset($categories[$catKey])) {
|
||||
$errors[] = "Baris {$rowNum} ('{$typeName}'): Kategori '{$categoryName}' tidak ditemukan. Buat kategori terlebih dahulu.";
|
||||
$skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
$category = $categories[$catKey];
|
||||
|
||||
// Cek duplikat nama
|
||||
$exists = ViolationType::where('name', $typeName)
|
||||
->where('category_id', $category->id)
|
||||
->exists();
|
||||
|
||||
if ($exists) {
|
||||
$skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
ViolationType::create([
|
||||
'category_id' => $category->id,
|
||||
'name' => $typeName,
|
||||
'slug' => Str::slug($typeName . '-' . $category->id),
|
||||
'points' => (int) $points,
|
||||
'default_sanction' => $sanction ?: null,
|
||||
'description' => $description ?: null,
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$imported++;
|
||||
}
|
||||
|
||||
$message = "Berhasil mengimpor {$imported} jenis pelanggaran.";
|
||||
if ($skipped > 0) {
|
||||
$message .= " {$skipped} dilewati (duplikat/error).";
|
||||
}
|
||||
|
||||
if (!empty($errors)) {
|
||||
$message .= ' ' . implode(', ', array_slice($errors, 0, 5));
|
||||
if (count($errors) > 5) {
|
||||
$message .= ' (+' . (count($errors) - 5) . ' error lainnya)';
|
||||
}
|
||||
}
|
||||
|
||||
if ($imported > 0) {
|
||||
return back()->with('success', $message);
|
||||
} else {
|
||||
return back()->with('error', 'Tidak ada data baru yang diimpor. ' . implode(', ', array_slice($errors, 0, 3)));
|
||||
}
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return back()->with('error', 'Gagal membaca file: ' . $e->getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,9 @@ namespace App\Http\Controllers\Admin;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\User;
|
||||
use App\Models\ViolationCategory;
|
||||
use App\Models\ViolationType;
|
||||
use App\Models\SpThreshold;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
@@ -22,7 +25,10 @@ class ResetController extends Controller
|
||||
'students' => DB::table('students')->count(),
|
||||
'classes' => DB::table('classes')->count(),
|
||||
'settings' => DB::table('settings')->count(),
|
||||
'users_other' => DB::table('users')->where('id', '!=', 1)->count(),
|
||||
'categories' => DB::table('violation_categories')->count(),
|
||||
'types' => DB::table('violation_types')->count(),
|
||||
'thresholds' => DB::table('sp_thresholds')->count(),
|
||||
'users_other' => DB::table('users')->where('role', '!=', 'admin')->count(),
|
||||
];
|
||||
|
||||
return view('settings.reset', compact('stats'));
|
||||
@@ -32,30 +38,88 @@ class ResetController extends Controller
|
||||
{
|
||||
$request->validate([
|
||||
'confirm_password' => ['required', 'string'],
|
||||
'reset_items' => ['required', 'array', 'min:1'],
|
||||
'reset_items.*' => ['in:violations,evidences,sp_letters,notifications,students,classes,categories,types,thresholds,settings,users'],
|
||||
]);
|
||||
|
||||
if (!Hash::check($request->confirm_password, $request->user()->password)) {
|
||||
return back()->with('error', 'Password salah. Reset dibatalkan.');
|
||||
}
|
||||
|
||||
$items = $request->reset_items;
|
||||
$admin = User::where('role', 'admin')->orderBy('id')->first();
|
||||
|
||||
DB::statement('SET FOREIGN_KEY_CHECKS=0');
|
||||
|
||||
DB::table('violation_evidences')->delete();
|
||||
DB::table('violations')->delete();
|
||||
DB::table('sp_letters')->delete();
|
||||
DB::table('notifications')->delete();
|
||||
DB::table('students')->delete();
|
||||
DB::table('classes')->delete();
|
||||
DB::table('violation_types')->delete();
|
||||
DB::table('violation_categories')->delete();
|
||||
DB::table('sp_thresholds')->delete();
|
||||
DB::table('settings')->delete();
|
||||
$cleared = [];
|
||||
|
||||
User::where('id', '!=', 1)->delete();
|
||||
User::where('id', 1)->update(['is_active' => true, 'role' => 'admin']);
|
||||
if (in_array('evidences', $items)) {
|
||||
DB::table('violation_evidences')->delete();
|
||||
$cleared[] = 'Foto bukti';
|
||||
}
|
||||
|
||||
if (in_array('violations', $items)) {
|
||||
DB::table('violations')->delete();
|
||||
$cleared[] = 'Pelanggaran';
|
||||
}
|
||||
|
||||
if (in_array('sp_letters', $items)) {
|
||||
DB::table('sp_letters')->delete();
|
||||
$cleared[] = 'Surat Peringatan';
|
||||
}
|
||||
|
||||
if (in_array('notifications', $items)) {
|
||||
DB::table('notifications')->delete();
|
||||
$cleared[] = 'Notifikasi';
|
||||
}
|
||||
|
||||
if (in_array('students', $items)) {
|
||||
DB::table('students')->delete();
|
||||
$cleared[] = 'Data siswa';
|
||||
}
|
||||
|
||||
if (in_array('classes', $items)) {
|
||||
DB::table('classes')->delete();
|
||||
$cleared[] = 'Data kelas';
|
||||
}
|
||||
|
||||
if (in_array('types', $items)) {
|
||||
DB::table('violation_types')->delete();
|
||||
$cleared[] = 'Jenis pelanggaran';
|
||||
}
|
||||
|
||||
if (in_array('categories', $items)) {
|
||||
DB::table('violation_categories')->delete();
|
||||
$cleared[] = 'Kategori pelanggaran';
|
||||
}
|
||||
|
||||
if (in_array('thresholds', $items)) {
|
||||
DB::table('sp_thresholds')->delete();
|
||||
$cleared[] = 'Ambang SP';
|
||||
}
|
||||
|
||||
if (in_array('settings', $items)) {
|
||||
DB::table('settings')->delete();
|
||||
$cleared[] = 'Pengaturan sekolah';
|
||||
}
|
||||
|
||||
if (in_array('users', $items)) {
|
||||
DB::table('users')->where('role', '!=', 'admin')->delete();
|
||||
$cleared[] = 'User lain';
|
||||
}
|
||||
|
||||
DB::statement('SET FOREIGN_KEY_CHECKS=1');
|
||||
|
||||
// Auto-seed defaults jika kategori/tipe/threshold dihapus
|
||||
if (in_array('categories', $items) && ViolationCategory::count() === 0) {
|
||||
$this->seedDefaultCategories();
|
||||
}
|
||||
if (in_array('thresholds', $items) && SpThreshold::count() === 0) {
|
||||
$this->seedDefaultThresholds();
|
||||
}
|
||||
|
||||
// Hapus file foto jika evidences dihapus
|
||||
if (in_array('evidences', $items)) {
|
||||
$violationsDir = storage_path('app/public/violations');
|
||||
if (is_dir($violationsDir)) {
|
||||
$it = new \RecursiveIteratorIterator(
|
||||
@@ -67,8 +131,34 @@ class ResetController extends Controller
|
||||
else unlink($file->getRealPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return redirect()->route('users.index')
|
||||
->with('success', 'Reset berhasil! Semua data pelanggaran, siswa, master data, dan user lain dihapus. Hanya akun admin yang tersisa.');
|
||||
$msg = 'Reset berhasil! Data yang dibersihkan: ' . implode(', ', $cleared) . '.';
|
||||
|
||||
if ($admin) {
|
||||
$admin->update(['is_active' => true]);
|
||||
}
|
||||
|
||||
return redirect()->route('settings.reset')->with('success', $msg);
|
||||
}
|
||||
|
||||
private function seedDefaultCategories(): void
|
||||
{
|
||||
$categories = [
|
||||
['name' => 'Ringan', 'description' => 'Pelanggaran ringan (poin 1-15)', 'color' => '#eab308', 'min_points' => 1, 'max_points' => 15, 'is_active' => true, 'sort_order' => 1, 'created_at' => now(), 'updated_at' => now()],
|
||||
['name' => 'Sedang', 'description' => 'Pelanggaran sedang (poin 15-50)', 'color' => '#f97316', 'min_points' => 15, 'max_points' => 50, 'is_active' => true, 'sort_order' => 2, 'created_at' => now(), 'updated_at' => now()],
|
||||
['name' => 'Berat', 'description' => 'Pelanggaran berat (poin 50-100)', 'color' => '#ef4444', 'min_points' => 50, 'max_points' => 100, 'is_active' => true, 'sort_order' => 3, 'created_at' => now(), 'updated_at' => now()],
|
||||
];
|
||||
DB::table('violation_categories')->insert($categories);
|
||||
}
|
||||
|
||||
private function seedDefaultThresholds(): void
|
||||
{
|
||||
$thresholds = [
|
||||
['name' => 'SP 1', 'slug' => 'sp-1', 'min_points' => 50, 'max_points' => 99, 'color' => '#eab308', 'is_active' => true, 'description' => 'Surat Peringatan 1 — poin mencapai 50', 'created_at' => now(), 'updated_at' => now()],
|
||||
['name' => 'SP 2', 'slug' => 'sp-2', 'min_points' => 100, 'max_points' => 149, 'color' => '#f97316', 'is_active' => true, 'description' => 'Surat Peringatan 2 — poin mencapai 100', 'created_at' => now(), 'updated_at' => now()],
|
||||
['name' => 'SP 3', 'slug' => 'sp-3', 'min_points' => 150, 'max_points' => null, 'color' => '#ef4444', 'is_active' => true, 'description' => 'Surat Peringatan 3 — poin mencapai 150', 'created_at' => now(), 'updated_at' => now()],
|
||||
];
|
||||
DB::table('sp_thresholds')->insert($thresholds);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,114 +2,266 @@
|
||||
|
||||
@section('title', 'Reset Aplikasi')
|
||||
|
||||
@push('styles')
|
||||
<style>
|
||||
.reset-card {
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
.reset-card:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 8px 20px -6px rgba(0, 0, 0, 0.06);
|
||||
}
|
||||
.reset-checkbox:checked {
|
||||
background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e");
|
||||
}
|
||||
.reset-item.selected {
|
||||
ring: 2px;
|
||||
}
|
||||
</style>
|
||||
@endpush
|
||||
|
||||
@section('content')
|
||||
<div class="max-w-2xl mx-auto">
|
||||
<div>
|
||||
{{-- Header --}}
|
||||
<div class="mb-6">
|
||||
<div class="flex items-center space-x-3">
|
||||
<div class="w-12 h-12 rounded-xl bg-red-100 flex items-center justify-center">
|
||||
<i class="fa-solid fa-rotate-left text-red-600 text-xl"></i>
|
||||
</div>
|
||||
<div class="mb-6 flex items-center justify-between">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-gray-900">Reset Aplikasi</h1>
|
||||
<p class="text-sm text-gray-500 mt-0.5">Kembalikan aplikasi ke kondisi awal pabrik</p>
|
||||
</div>
|
||||
<p class="text-sm text-gray-500 mt-0.5">Kosongkan data aplikasi secara selektif</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Warning Card --}}
|
||||
<div class="bg-red-50 border border-red-200 rounded-xl p-5 mb-6">
|
||||
<div class="flex items-start space-x-3">
|
||||
<i class="fa-solid fa-triangle-exclamation text-red-600 mt-0.5"></i>
|
||||
<div class="bg-red-50 border border-red-200 rounded-2xl p-5 mb-6">
|
||||
<div class="flex items-start gap-3">
|
||||
<div class="w-8 h-8 rounded-lg bg-red-100 flex items-center justify-center flex-shrink-0">
|
||||
<svg class="w-4 h-4 text-red-600" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<h3 class="text-sm font-semibold text-red-800">⚠️ Peringatan Keras!</h3>
|
||||
<p class="text-sm text-red-700 mt-1">Semua data berikut akan <strong>DIHAPUS PERMANEN</strong>:</p>
|
||||
<ul class="mt-2 space-y-1 text-sm text-red-700">
|
||||
<li>✕ Pelanggaran & foto bukti</li>
|
||||
<li>✕ Surat Peringatan & notifikasi</li>
|
||||
<li>✕ Data siswa & kelas (hasil sinkron)</li>
|
||||
<li>✕ Kategori, jenis pelanggaran & ambang SP</li>
|
||||
<li>✕ User lain (selain admin utama)</li>
|
||||
<li>✕ Pengaturan sekolah</li>
|
||||
<li>✕ File foto yang sudah diupload</li>
|
||||
</ul>
|
||||
<p class="text-sm text-green-700 mt-3 font-medium">Yang <u>tetap</u> tersimpan:</p>
|
||||
<ul class="mt-1 space-y-0.5 text-sm text-green-700">
|
||||
<li>✓ Akun super admin (username: <strong>admin</strong>)</li>
|
||||
</ul>
|
||||
<h3 class="text-sm font-semibold text-red-800">⚠️ Peringatan</h3>
|
||||
<p class="text-xs text-red-600 mt-1">Data yang dipilih akan dihapus permanen dan tidak bisa dikembalikan. Pastikan Anda telah membackup data penting sebelum melanjutkan.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Stats Cards --}}
|
||||
<div class="bg-white rounded-xl shadow-sm border border-gray-200 mb-6">
|
||||
<div class="px-5 py-4 border-b border-gray-100">
|
||||
<h3 class="text-sm font-semibold text-gray-900">Data yang akan terhapus</h3>
|
||||
<form method="POST" action="{{ route('settings.reset.run') }}" id="reset-form">
|
||||
@csrf
|
||||
|
||||
{{-- Selectable Data Cards --}}
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden mb-6">
|
||||
<div class="px-6 py-4 border-b border-gray-100 flex items-center justify-between">
|
||||
<div class="flex items-center gap-2.5">
|
||||
<div class="w-8 h-8 rounded-lg bg-red-50 flex items-center justify-center">
|
||||
<svg class="w-4 h-4 text-red-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<h3 class="text-base font-semibold text-gray-900">Pilih Data yang Akan Dikosongkan</h3>
|
||||
<p class="text-xs text-gray-400">Centang data yang ingin dihapus, lalu masukkan password admin</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<button type="button" id="select-all" class="text-xs text-blue-600 hover:text-blue-800 font-medium transition">Pilih Semua</button>
|
||||
<span class="text-gray-300">|</span>
|
||||
<button type="button" id="deselect-all" class="text-xs text-gray-500 hover:text-gray-700 font-medium transition">Hapus Semua</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="p-5">
|
||||
<div class="grid grid-cols-2 sm:grid-cols-4 gap-3">
|
||||
<div class="p-4 bg-red-50 rounded-xl border border-red-100 text-center">
|
||||
<p class="text-xs text-red-600 font-medium uppercase tracking-wider">Pelanggaran</p>
|
||||
<p class="text-2xl font-bold text-red-700 mt-1">{{ $stats['violations'] }}</p>
|
||||
<div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3">
|
||||
{{-- 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">
|
||||
<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">
|
||||
<div class="min-w-0">
|
||||
<p class="text-sm font-semibold text-gray-900">Pelanggaran</p>
|
||||
<p class="text-xs text-gray-400 mt-0.5">{{ $stats['violations'] }} data</p>
|
||||
</div>
|
||||
<div class="p-4 bg-orange-50 rounded-xl border border-orange-100 text-center">
|
||||
<p class="text-xs text-orange-600 font-medium uppercase tracking-wider">Foto</p>
|
||||
<p class="text-2xl font-bold text-orange-700 mt-1">{{ $stats['evidences'] }}</p>
|
||||
</label>
|
||||
|
||||
<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="evidences" 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">
|
||||
<div class="min-w-0">
|
||||
<p class="text-sm font-semibold text-gray-900">Foto Bukti</p>
|
||||
<p class="text-xs text-gray-400 mt-0.5">{{ $stats['evidences'] }} file</p>
|
||||
</div>
|
||||
<div class="p-4 bg-yellow-50 rounded-xl border border-yellow-100 text-center">
|
||||
<p class="text-xs text-yellow-600 font-medium uppercase tracking-wider">SP</p>
|
||||
<p class="text-2xl font-bold text-yellow-700 mt-1">{{ $stats['sp_letters'] }}</p>
|
||||
</label>
|
||||
|
||||
{{-- Surat Peringatan --}}
|
||||
<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="sp_letters" 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">
|
||||
<div class="min-w-0">
|
||||
<p class="text-sm font-semibold text-gray-900">Surat Peringatan</p>
|
||||
<p class="text-xs text-gray-400 mt-0.5">{{ $stats['sp_letters'] }} surat</p>
|
||||
</div>
|
||||
<div class="p-4 bg-red-50 rounded-xl border border-red-100 text-center">
|
||||
<p class="text-xs text-red-600 font-medium uppercase tracking-wider">Notifikasi</p>
|
||||
<p class="text-2xl font-bold text-red-700 mt-1">{{ $stats['notifications'] }}</p>
|
||||
</label>
|
||||
|
||||
{{-- Notifikasi --}}
|
||||
<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="notifications" 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">
|
||||
<div class="min-w-0">
|
||||
<p class="text-sm font-semibold text-gray-900">Notifikasi</p>
|
||||
<p class="text-xs text-gray-400 mt-0.5">{{ $stats['notifications'] }} notifikasi</p>
|
||||
</div>
|
||||
<div class="p-4 bg-purple-50 rounded-xl border border-purple-100 text-center">
|
||||
<p class="text-xs text-purple-600 font-medium uppercase tracking-wider">Siswa</p>
|
||||
<p class="text-2xl font-bold text-purple-700 mt-1">{{ $stats['students'] }}</p>
|
||||
</label>
|
||||
|
||||
{{-- Data Siswa --}}
|
||||
<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="students" 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">
|
||||
<div class="min-w-0">
|
||||
<p class="text-sm font-semibold text-gray-900">Siswa</p>
|
||||
<p class="text-xs text-gray-400 mt-0.5">{{ $stats['students'] }} siswa</p>
|
||||
</div>
|
||||
<div class="p-4 bg-indigo-50 rounded-xl border border-indigo-100 text-center">
|
||||
<p class="text-xs text-indigo-600 font-medium uppercase tracking-wider">Kelas</p>
|
||||
<p class="text-2xl font-bold text-indigo-700 mt-1">{{ $stats['classes'] }}</p>
|
||||
</label>
|
||||
|
||||
{{-- Kelas --}}
|
||||
<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="classes" 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">
|
||||
<div class="min-w-0">
|
||||
<p class="text-sm font-semibold text-gray-900">Kelas</p>
|
||||
<p class="text-xs text-gray-400 mt-0.5">{{ $stats['classes'] }} kelas</p>
|
||||
</div>
|
||||
<div class="p-4 bg-teal-50 rounded-xl border border-teal-100 text-center">
|
||||
<p class="text-xs text-teal-600 font-medium uppercase tracking-wider">Settings</p>
|
||||
<p class="text-2xl font-bold text-teal-700 mt-1">{{ $stats['settings'] }}</p>
|
||||
</label>
|
||||
|
||||
{{-- Kategori Pelanggaran --}}
|
||||
<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="categories" 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">Kategori Pelanggaran</p>
|
||||
<p class="text-xs text-gray-400 mt-0.5">{{ $stats['categories'] }} kategori</p>
|
||||
<p class="text-xs text-green-600 font-medium mt-1">Akan dibuat ulang default</p>
|
||||
</div>
|
||||
<div class="p-4 bg-gray-50 rounded-xl border border-gray-100 text-center">
|
||||
<p class="text-xs text-gray-600 font-medium uppercase tracking-wider">User Lain</p>
|
||||
<p class="text-2xl font-bold text-gray-700 mt-1">{{ $stats['users_other'] }}</p>
|
||||
</label>
|
||||
|
||||
{{-- Jenis Pelanggaran --}}
|
||||
<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="types" 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">Jenis Pelanggaran</p>
|
||||
<p class="text-xs text-gray-400 mt-0.5">{{ $stats['types'] }} jenis</p>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
{{-- Ambang SP --}}
|
||||
<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="thresholds" 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">Ambang SP</p>
|
||||
<p class="text-xs text-gray-400 mt-0.5">{{ $stats['thresholds'] }} threshold</p>
|
||||
<p class="text-xs text-green-600 font-medium mt-1">Akan dibuat ulang default</p>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
{{-- Pengaturan --}}
|
||||
<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-purple-300 has-[:checked]:bg-purple-50/50 transition-all select-none">
|
||||
<input type="checkbox" name="reset_items[]" value="settings" class="reset-checkbox mt-0.5 w-4 h-4 rounded border-gray-300 text-purple-500 focus:ring-purple-400 focus:ring-offset-0 flex-shrink-0">
|
||||
<div class="min-w-0">
|
||||
<p class="text-sm font-semibold text-gray-900">Pengaturan</p>
|
||||
<p class="text-xs text-gray-400 mt-0.5">{{ $stats['settings'] }} setting</p>
|
||||
<p class="text-xs text-red-500 font-medium mt-1">Nama & logo sekolah ikut hilang</p>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
{{-- User Lain --}}
|
||||
<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="users" 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">
|
||||
<div class="min-w-0">
|
||||
<p class="text-sm font-semibold text-gray-900">User Lain</p>
|
||||
<p class="text-xs text-gray-400 mt-0.5">{{ $stats['users_other'] }} user (non-admin)</p>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Confirm Form --}}
|
||||
<div class="bg-white rounded-xl shadow-sm border border-gray-200">
|
||||
<form action="{{ route('settings.reset.run') }}" method="POST" onsubmit="return confirm('⚠️ YAKIN INGIN RESET? Semua data kecuali akun admin akan hilang permanen!')">
|
||||
@csrf
|
||||
<div class="p-5 space-y-4">
|
||||
<div class="bg-white rounded-2xl shadow-sm border border-gray-200 overflow-hidden">
|
||||
<div class="px-6 py-4 border-b border-gray-100">
|
||||
<div class="flex items-center gap-2.5">
|
||||
<div class="w-8 h-8 rounded-lg bg-gray-50 flex items-center justify-center">
|
||||
<svg class="w-4 h-4 text-gray-400" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z"/>
|
||||
</svg>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-gray-700 mb-1.5">
|
||||
<i class="fa-solid fa-lock mr-1.5 text-gray-400"></i>
|
||||
Masukkan Password Admin untuk Konfirmasi
|
||||
</label>
|
||||
<h3 class="text-base font-semibold text-gray-900">Konfirmasi Password</h3>
|
||||
<p class="text-xs text-gray-400">Masukkan password admin untuk menjalankan reset</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="p-6">
|
||||
<div class="flex flex-col sm:flex-row items-stretch sm:items-center gap-3 max-w-xl">
|
||||
<div class="flex-1">
|
||||
<input type="password" name="confirm_password" required
|
||||
placeholder="Password akun admin saat ini"
|
||||
placeholder="Password admin saat ini"
|
||||
class="w-full px-4 py-2.5 border border-gray-300 rounded-xl text-sm focus:outline-none focus:ring-2 focus:ring-blue-500/20 focus:border-blue-500 transition">
|
||||
</div>
|
||||
</div>
|
||||
<div class="px-5 py-4 bg-gray-50 border-t border-gray-100 rounded-b-xl flex justify-between items-center">
|
||||
<a href="{{ route('dashboard') }}" class="text-sm text-gray-500 hover:text-gray-700 transition">
|
||||
<i class="fa-solid fa-arrow-left mr-1"></i> Kembali
|
||||
</a>
|
||||
<button type="submit"
|
||||
class="inline-flex items-center px-6 py-2.5 text-sm font-medium text-white bg-blue-600 rounded-xl hover:bg-blue-700 transition shadow-sm">
|
||||
<i class="fa-solid fa-bomb mr-2"></i>
|
||||
Reset Aplikasi
|
||||
<button type="submit" id="reset-btn" disabled
|
||||
class="px-6 py-2.5 text-sm font-semibold text-white bg-gray-300 rounded-xl cursor-not-allowed transition flex items-center justify-center gap-2 whitespace-nowrap">
|
||||
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16"/>
|
||||
</svg>
|
||||
Jalankan Reset
|
||||
</button>
|
||||
</div>
|
||||
<div id="reset-hint" class="mt-2 text-xs text-red-500 hidden">
|
||||
Pilih minimal satu data yang akan direset.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const checkboxes = document.querySelectorAll('input[name="reset_items[]"]');
|
||||
const resetBtn = document.getElementById('reset-btn');
|
||||
const resetHint = document.getElementById('reset-hint');
|
||||
const selectAll = document.getElementById('select-all');
|
||||
const deselectAll = document.getElementById('deselect-all');
|
||||
const form = document.getElementById('reset-form');
|
||||
|
||||
function updateButton() {
|
||||
const checked = document.querySelectorAll('input[name="reset_items[]"]:checked');
|
||||
if (checked.length > 0) {
|
||||
resetBtn.disabled = false;
|
||||
resetBtn.className = 'px-6 py-2.5 text-sm font-semibold text-white bg-red-600 rounded-xl hover:bg-red-700 transition flex items-center justify-center gap-2 whitespace-nowrap shadow-sm';
|
||||
resetHint.classList.add('hidden');
|
||||
} else {
|
||||
resetBtn.disabled = true;
|
||||
resetBtn.className = 'px-6 py-2.5 text-sm font-semibold text-white bg-gray-300 rounded-xl cursor-not-allowed transition flex items-center justify-center gap-2 whitespace-nowrap';
|
||||
resetHint.classList.remove('hidden');
|
||||
}
|
||||
}
|
||||
|
||||
checkboxes.forEach(cb => cb.addEventListener('change', updateButton));
|
||||
|
||||
selectAll.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
checkboxes.forEach(cb => cb.checked = true);
|
||||
updateButton();
|
||||
});
|
||||
|
||||
deselectAll.addEventListener('click', function (e) {
|
||||
e.preventDefault();
|
||||
checkboxes.forEach(cb => cb.checked = false);
|
||||
updateButton();
|
||||
});
|
||||
|
||||
form.addEventListener('submit', function (e) {
|
||||
const checked = document.querySelectorAll('input[name="reset_items[]"]:checked');
|
||||
if (checked.length === 0) {
|
||||
e.preventDefault();
|
||||
resetHint.classList.remove('hidden');
|
||||
return;
|
||||
}
|
||||
if (!confirm('⚠️ YAKIN INGIN MELANJUTKAN?\n\nData yang dipilih akan dihapus permanen!\nTindakan ini tidak bisa dibatalkan.')) {
|
||||
e.preventDefault();
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
@endpush
|
||||
|
||||
@@ -3,13 +3,28 @@
|
||||
@section('title', 'Jenis Pelanggaran')
|
||||
|
||||
@section('content')
|
||||
<div x-data="violationTypeManager()">
|
||||
<div x-data="violationTypeManager()" x-init="showImport = false">
|
||||
{{-- Header --}}
|
||||
<div class="mb-6 flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4">
|
||||
<div>
|
||||
<h1 class="text-2xl font-bold text-gray-900">Jenis Pelanggaran</h1>
|
||||
<p class="text-sm text-gray-500 mt-1">Daftar jenis pelanggaran beserta poin dan sanksi default</p>
|
||||
</div>
|
||||
<div class="flex items-center gap-2">
|
||||
<a href="{{ route('settings.import.template') }}"
|
||||
class="inline-flex items-center px-3.5 py-2.5 text-sm font-medium text-gray-600 bg-white border border-gray-200 rounded-lg hover:bg-gray-50 hover:border-gray-300 transition shadow-sm">
|
||||
<svg class="w-4 h-4 mr-1.5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"/>
|
||||
</svg>
|
||||
Download Template
|
||||
</a>
|
||||
<button @click="showImport = true"
|
||||
class="inline-flex items-center px-4 py-2.5 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 transition shadow-sm">
|
||||
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L5 8m4-4v12"/>
|
||||
</svg>
|
||||
Import Excel
|
||||
</button>
|
||||
<button @click="openCreate()"
|
||||
class="inline-flex items-center px-4 py-2.5 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 transition shadow-sm">
|
||||
<svg class="w-4 h-4 mr-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
@@ -18,6 +33,7 @@
|
||||
Tambah Jenis
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Filter & Search Bar --}}
|
||||
<div class="bg-white rounded-xl shadow-sm border border-gray-200 mb-6">
|
||||
@@ -312,11 +328,98 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{-- Import Modal --}}
|
||||
<div x-show="showImport"
|
||||
x-transition:enter="transition ease-out duration-200"
|
||||
x-transition:enter-start="opacity-0"
|
||||
x-transition:enter-end="opacity-100"
|
||||
x-transition:leave="transition ease-in duration-150"
|
||||
x-transition:leave-start="opacity-100"
|
||||
x-transition:leave-end="opacity-0"
|
||||
class="fixed inset-0 z-50 flex items-center justify-center bg-gray-900/40 backdrop-blur-sm" style="display: none;"
|
||||
@click.away="showImport = false"
|
||||
@keydown.escape="showImport = false">
|
||||
<div class="bg-white rounded-2xl shadow-2xl border border-gray-200 w-full max-w-lg mx-4 overflow-hidden"
|
||||
@click.stop>
|
||||
<div class="px-6 py-4 border-b border-gray-100 flex items-center justify-between">
|
||||
<div class="flex items-center gap-2.5">
|
||||
<div class="w-8 h-8 rounded-lg bg-blue-50 flex items-center justify-center">
|
||||
<svg class="w-4 h-4 text-blue-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-8l-4-4m0 0L5 8m4-4v12"/>
|
||||
</svg>
|
||||
</div>
|
||||
<h3 class="text-base font-semibold text-gray-900">Import Excel</h3>
|
||||
</div>
|
||||
<button @click="showImport = false" class="text-gray-400 hover:text-gray-600 transition">
|
||||
<svg class="w-5 h-5" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<form action="{{ route('settings.import.violation-types') }}" method="POST" enctype="multipart/form-data" class="p-6">
|
||||
@csrf
|
||||
|
||||
<div class="text-sm text-gray-600 mb-4 leading-relaxed">
|
||||
<p class="mb-2">Upload file Excel (.xlsx) untuk mengimpor jenis pelanggaran secara massal.</p>
|
||||
<p class="text-xs text-gray-400">Format kolom: <strong>Kategori</strong> • <strong>Nama Pelanggaran</strong> • <strong>Poin</strong> • <strong>Sanksi Default</strong> • <strong>Deskripsi</strong></p>
|
||||
</div>
|
||||
|
||||
<label class="flex flex-col items-center justify-center h-36 border-2 border-dashed border-gray-200 rounded-xl cursor-pointer hover:border-blue-300 hover:bg-blue-50/30 transition file-drop"
|
||||
x-data="{ fileName: '' }"
|
||||
@dragover.prevent="$el.classList.add('border-blue-400', 'bg-blue-50/50')"
|
||||
@dragleave.prevent="$el.classList.remove('border-blue-400', 'bg-blue-50/50')"
|
||||
@drop.prevent="$el.classList.remove('border-blue-400', 'bg-blue-50/50'); const f = $event.dataTransfer.files[0]; if(f) { document.getElementById('import-file-input').files = $event.dataTransfer.files; fileName = f.name; }">
|
||||
<input id="import-file-input" type="file" name="file" accept=".xlsx,.xls" class="hidden"
|
||||
@change="fileName = $event.target.files[0]?.name || ''">
|
||||
|
||||
<template x-if="!fileName">
|
||||
<div class="text-center">
|
||||
<svg class="w-8 h-8 text-gray-300 mx-auto mb-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12"/>
|
||||
</svg>
|
||||
<p class="text-sm text-gray-500">Klik atau drag & drop file di sini</p>
|
||||
<p class="text-xs text-gray-400 mt-1">.xlsx atau .xls, maks 2 MB</p>
|
||||
</div>
|
||||
</template>
|
||||
<template x-if="fileName">
|
||||
<div class="text-center">
|
||||
<svg class="w-8 h-8 text-green-500 mx-auto mb-2" fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"/>
|
||||
</svg>
|
||||
<p class="text-sm font-medium text-gray-900" x-text="fileName"></p>
|
||||
<p class="text-xs text-green-600 mt-1">Siap diupload</p>
|
||||
</div>
|
||||
</template>
|
||||
</label>
|
||||
|
||||
<div class="flex items-center justify-between mt-6">
|
||||
<a href="{{ route('settings.import.template') }}" class="text-xs text-blue-600 hover:text-blue-800 font-medium transition">
|
||||
Download template →
|
||||
</a>
|
||||
<div class="flex items-center gap-2">
|
||||
<button type="button" @click="showImport = false"
|
||||
class="px-4 py-2 text-sm font-medium text-gray-600 border border-gray-200 rounded-lg hover:bg-gray-50 transition">
|
||||
Batal
|
||||
</button>
|
||||
<button type="submit"
|
||||
class="px-4 py-2 text-sm font-medium text-white bg-blue-600 rounded-lg hover:bg-blue-700 transition shadow-sm">
|
||||
Import
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@endsection
|
||||
|
||||
@push('scripts')
|
||||
<script>
|
||||
function violationTypeManager() {
|
||||
return {
|
||||
modalOpen: false,
|
||||
showImport: false,
|
||||
isEditing: false,
|
||||
editId: null,
|
||||
formCategory: '',
|
||||
@@ -358,4 +461,3 @@ function violationTypeManager() {
|
||||
}
|
||||
</script>
|
||||
@endpush
|
||||
@endsection
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\ProfileController;
|
||||
use App\Http\Controllers\Admin\ImportController;
|
||||
use App\Http\Controllers\Admin\MasterDataController;
|
||||
use App\Http\Controllers\Admin\SettingsController;
|
||||
use App\Http\Controllers\Admin\SyncController;
|
||||
@@ -65,6 +66,10 @@ Route::middleware('auth')->group(function () {
|
||||
Route::put('/settings/violation-types/{type}', [MasterDataController::class, 'updateType'])->name('settings.violation-types.update');
|
||||
Route::delete('/settings/violation-types/{type}', [MasterDataController::class, 'destroyType'])->name('settings.violation-types.destroy');
|
||||
|
||||
// Import
|
||||
Route::get('/settings/import/template', [ImportController::class, 'downloadTemplate'])->name('settings.import.template');
|
||||
Route::post('/settings/import/violation-types', [ImportController::class, 'importViolationTypes'])->name('settings.import.violation-types');
|
||||
|
||||
Route::get('/settings/thresholds', [MasterDataController::class, 'thresholds'])->name('settings.thresholds');
|
||||
Route::put('/settings/thresholds', [MasterDataController::class, 'updateThresholds'])->name('settings.thresholds.update');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user