feat: add graduation archive and public document services
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Integration;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\AcademicYear;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class AcademicYearSyncController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
/** @var \App\Models\SyncToken $token */
|
||||
$token = $request->attributes->get('syncToken');
|
||||
|
||||
abort_unless(collect($token->abilities ?? [])->contains('academic_years'), 403, 'Token tidak memiliki akses ke data tahun ajaran.');
|
||||
|
||||
$items = AcademicYear::query()
|
||||
->orderByDesc('is_active')
|
||||
->orderByDesc('start_year')
|
||||
->get(['id', 'name', 'start_year', 'end_year', 'is_active', 'updated_at']);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'source' => 'database-kesiswaan',
|
||||
'resource' => 'academic_years',
|
||||
'count' => $items->count(),
|
||||
'data' => $items,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Integration;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Department;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class DepartmentSyncController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
/** @var \App\Models\SyncToken $token */
|
||||
$token = $request->attributes->get('syncToken');
|
||||
|
||||
abort_unless(collect($token->abilities ?? [])->contains('departments'), 403, 'Token tidak memiliki akses ke data jurusan.');
|
||||
|
||||
$items = Department::query()
|
||||
->orderBy('name')
|
||||
->get(['id', 'code', 'name', 'description', 'is_active', 'updated_at']);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'source' => 'database-kesiswaan',
|
||||
'resource' => 'departments',
|
||||
'count' => $items->count(),
|
||||
'data' => $items,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Integration;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\SchoolClass;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class SchoolClassSyncController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
/** @var \App\Models\SyncToken $token */
|
||||
$token = $request->attributes->get('syncToken');
|
||||
|
||||
abort_unless(collect($token->abilities ?? [])->contains('classes'), 403, 'Token tidak memiliki akses ke data kelas.');
|
||||
|
||||
$items = SchoolClass::query()
|
||||
->orderByDesc('academic_year_id')
|
||||
->orderBy('name')
|
||||
->get([
|
||||
'id',
|
||||
'academic_year_id',
|
||||
'department_id',
|
||||
'name',
|
||||
'level',
|
||||
'homeroom_teacher',
|
||||
'capacity',
|
||||
'is_active',
|
||||
'updated_at',
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'source' => 'database-kesiswaan',
|
||||
'resource' => 'classes',
|
||||
'count' => $items->count(),
|
||||
'data' => $items,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Api\Integration;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Student;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class StudentSyncController extends Controller
|
||||
{
|
||||
public function __invoke(Request $request): JsonResponse
|
||||
{
|
||||
/** @var \App\Models\SyncToken $token */
|
||||
$token = $request->attributes->get('syncToken');
|
||||
|
||||
abort_unless(collect($token->abilities ?? [])->contains('students'), 403, 'Token tidak memiliki akses ke data siswa.');
|
||||
|
||||
$items = Student::query()
|
||||
->orderBy('full_name')
|
||||
->get([
|
||||
'id',
|
||||
'student_number',
|
||||
'nisn',
|
||||
'full_name',
|
||||
'gender',
|
||||
'academic_year_id',
|
||||
'department_id',
|
||||
'class_id',
|
||||
'status',
|
||||
'phone_number',
|
||||
'email',
|
||||
'photo_path',
|
||||
'notes',
|
||||
'updated_at',
|
||||
]);
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'source' => 'database-kesiswaan',
|
||||
'resource' => 'students',
|
||||
'count' => $items->count(),
|
||||
'data' => $items,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,168 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\AcademicYear;
|
||||
use App\Models\Department;
|
||||
use App\Models\SchoolClass;
|
||||
use App\Models\StudentGraduation;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\View\View;
|
||||
use RealRashid\SweetAlert\Facades\Alert;
|
||||
|
||||
class GraduatedStudentController extends Controller
|
||||
{
|
||||
public function index(Request $request): View
|
||||
{
|
||||
$search = trim((string) $request->get('search'));
|
||||
$academicYearId = $request->get('academic_year_id');
|
||||
$departmentId = $request->get('department_id');
|
||||
$classId = $request->get('class_id');
|
||||
$sort = (string) $request->get('sort', 'full_name');
|
||||
$direction = strtolower((string) $request->get('direction', 'asc')) === 'desc' ? 'desc' : 'asc';
|
||||
|
||||
$allowedSorts = [
|
||||
'full_name' => 'full_name',
|
||||
'student_number' => 'student_number',
|
||||
'academic_year' => 'academic_year_id',
|
||||
'department' => 'department_id',
|
||||
'class' => 'class_id',
|
||||
'graduation_date' => 'graduation_date',
|
||||
'created_at' => 'created_at',
|
||||
];
|
||||
|
||||
if (! array_key_exists($sort, $allowedSorts)) {
|
||||
$sort = 'full_name';
|
||||
}
|
||||
|
||||
$graduations = StudentGraduation::query()
|
||||
->with(['academicYear', 'department', 'classRoom'])
|
||||
->when($search !== '', function ($query) use ($search) {
|
||||
$query->where(function ($subQuery) use ($search) {
|
||||
$subQuery->where('full_name', 'like', "%{$search}%")
|
||||
->orWhere('student_number', 'like', "%{$search}%")
|
||||
->orWhere('nisn', 'like', "%{$search}%");
|
||||
});
|
||||
})
|
||||
->when($academicYearId, fn ($query) => $query->where('academic_year_id', $academicYearId))
|
||||
->when($departmentId, fn ($query) => $query->where('department_id', $departmentId))
|
||||
->when($classId, fn ($query) => $query->where('class_id', $classId))
|
||||
->orderBy($allowedSorts[$sort], $direction)
|
||||
->orderBy('id', $direction)
|
||||
->paginate(10)
|
||||
->withQueryString();
|
||||
|
||||
$summary = [
|
||||
'total' => $graduations->total(),
|
||||
'with_skl' => StudentGraduation::query()->whereNotNull('skl_file_path')->count(),
|
||||
'with_ijazah' => StudentGraduation::query()->whereNotNull('ijazah_file_path')->count(),
|
||||
];
|
||||
|
||||
return view('graduated-students.index', [
|
||||
'graduations' => $graduations,
|
||||
'search' => $search,
|
||||
'filters' => [
|
||||
'academic_year_id' => $academicYearId,
|
||||
'department_id' => $departmentId,
|
||||
'class_id' => $classId,
|
||||
],
|
||||
'academicYears' => AcademicYear::orderBy('name')->pluck('name', 'id'),
|
||||
'departments' => Department::orderBy('name')->pluck('name', 'id'),
|
||||
'classes' => SchoolClass::orderBy('name')->pluck('name', 'id'),
|
||||
'sort' => $sort,
|
||||
'direction' => $direction,
|
||||
'summary' => $summary,
|
||||
]);
|
||||
}
|
||||
|
||||
public function show(StudentGraduation $graduatedStudent): View
|
||||
{
|
||||
$graduatedStudent->load(['academicYear', 'department', 'classRoom']);
|
||||
|
||||
return view('graduated-students.show', [
|
||||
'graduation' => $graduatedStudent,
|
||||
]);
|
||||
}
|
||||
|
||||
public function update(Request $request, StudentGraduation $graduatedStudent): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'graduation_date' => ['nullable', 'date'],
|
||||
'graduation_note' => ['nullable', 'string'],
|
||||
'skl_file' => ['nullable', 'file', 'mimes:pdf,jpg,jpeg,png', 'max:4096'],
|
||||
'ijazah_file' => ['nullable', 'file', 'mimes:pdf,jpg,jpeg,png', 'max:4096'],
|
||||
], [
|
||||
'skl_file.mimes' => 'File SKL harus berupa PDF, JPG, JPEG, atau PNG.',
|
||||
'skl_file.max' => 'Ukuran file SKL maksimal 4 MB.',
|
||||
'ijazah_file.mimes' => 'File ijazah harus berupa PDF, JPG, JPEG, atau PNG.',
|
||||
'ijazah_file.max' => 'Ukuran file ijazah maksimal 4 MB.',
|
||||
]);
|
||||
|
||||
$graduatedStudent->graduation_date = $validated['graduation_date'] ?? $graduatedStudent->graduation_date;
|
||||
$graduatedStudent->graduation_note = $validated['graduation_note'] ?? $graduatedStudent->graduation_note;
|
||||
|
||||
if ($request->hasFile('skl_file')) {
|
||||
if ($graduatedStudent->skl_file_path && Storage::disk('public')->exists($graduatedStudent->skl_file_path)) {
|
||||
Storage::disk('public')->delete($graduatedStudent->skl_file_path);
|
||||
}
|
||||
|
||||
$file = $request->file('skl_file');
|
||||
$path = $file->store("student-graduation-documents/{$graduatedStudent->student_id}/skl", 'public');
|
||||
|
||||
$graduatedStudent->skl_file_name = $file->getClientOriginalName();
|
||||
$graduatedStudent->skl_file_path = $path;
|
||||
$graduatedStudent->skl_mime_type = $file->getMimeType();
|
||||
$graduatedStudent->skl_file_size = $file->getSize();
|
||||
}
|
||||
|
||||
if ($request->hasFile('ijazah_file')) {
|
||||
if ($graduatedStudent->ijazah_file_path && Storage::disk('public')->exists($graduatedStudent->ijazah_file_path)) {
|
||||
Storage::disk('public')->delete($graduatedStudent->ijazah_file_path);
|
||||
}
|
||||
|
||||
$file = $request->file('ijazah_file');
|
||||
$path = $file->store("student-graduation-documents/{$graduatedStudent->student_id}/ijazah", 'public');
|
||||
|
||||
$graduatedStudent->ijazah_file_name = $file->getClientOriginalName();
|
||||
$graduatedStudent->ijazah_file_path = $path;
|
||||
$graduatedStudent->ijazah_mime_type = $file->getMimeType();
|
||||
$graduatedStudent->ijazah_file_size = $file->getSize();
|
||||
}
|
||||
|
||||
$graduatedStudent->save();
|
||||
|
||||
Alert::success('Berhasil', 'Arsip siswa lulus berhasil diperbarui.');
|
||||
|
||||
return redirect()->route('graduated-students.show', $graduatedStudent)->with('success', 'Arsip siswa lulus berhasil diperbarui.');
|
||||
}
|
||||
|
||||
public function previewDocument(StudentGraduation $graduatedStudent, string $document): View
|
||||
{
|
||||
abort_unless(in_array($document, ['skl', 'ijazah'], true), 404);
|
||||
|
||||
$filePathField = $document === 'skl' ? 'skl_file_path' : 'ijazah_file_path';
|
||||
$fileNameField = $document === 'skl' ? 'skl_file_name' : 'ijazah_file_name';
|
||||
$mimeTypeField = $document === 'skl' ? 'skl_mime_type' : 'ijazah_mime_type';
|
||||
|
||||
abort_unless($graduatedStudent->{$filePathField} && Storage::disk('public')->exists($graduatedStudent->{$filePathField}), 404);
|
||||
|
||||
$mimeType = $graduatedStudent->{$mimeTypeField} ?: Storage::disk('public')->mimeType($graduatedStudent->{$filePathField});
|
||||
$fileUrl = asset('storage/' . $graduatedStudent->{$filePathField});
|
||||
$isImage = Str::startsWith((string) $mimeType, 'image/');
|
||||
$isPdf = $mimeType === 'application/pdf';
|
||||
|
||||
return view('graduated-students.preview-document', [
|
||||
'graduation' => $graduatedStudent,
|
||||
'documentType' => $document,
|
||||
'documentLabel' => $document === 'skl' ? 'SKL' : 'Ijazah',
|
||||
'fileName' => $graduatedStudent->{$fileNameField},
|
||||
'fileUrl' => $fileUrl,
|
||||
'mimeType' => $mimeType,
|
||||
'isImage' => $isImage,
|
||||
'isPdf' => $isPdf,
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\StudentGraduation;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\View\View;
|
||||
use RealRashid\SweetAlert\Facades\Alert;
|
||||
|
||||
class GraduationBulkUploadController extends Controller
|
||||
{
|
||||
public function index(Request $request): View
|
||||
{
|
||||
return view('graduated-students.bulk-upload', [
|
||||
'preview' => $request->session()->get('graduation_bulk_upload_preview'),
|
||||
'documentTypes' => [
|
||||
'skl' => 'SKL',
|
||||
'ijazah' => 'Ijazah',
|
||||
],
|
||||
'matchByOptions' => [
|
||||
'student_number' => 'NIS',
|
||||
'nisn' => 'NISN',
|
||||
],
|
||||
]);
|
||||
}
|
||||
|
||||
public function preview(Request $request): RedirectResponse
|
||||
{
|
||||
$validated = $request->validate([
|
||||
'document_type' => ['required', 'in:skl,ijazah'],
|
||||
'match_by' => ['required', 'in:student_number,nisn'],
|
||||
'documents' => ['required', 'array', 'min:1', 'max:10'],
|
||||
'documents.*' => ['required', 'file', 'mimes:pdf,jpg,jpeg,png', 'max:2048'],
|
||||
], [
|
||||
'documents.required' => 'Pilih minimal satu file dokumen untuk dipreview.',
|
||||
'documents.max' => 'Maksimal 10 file per batch upload.',
|
||||
'documents.*.mimes' => 'Dokumen hanya boleh berupa PDF, JPG, JPEG, atau PNG.',
|
||||
'documents.*.max' => 'Ukuran tiap dokumen maksimal 2 MB.',
|
||||
]);
|
||||
|
||||
$graduations = StudentGraduation::query()->get()->keyBy($validated['match_by']);
|
||||
$rows = [];
|
||||
$summary = [
|
||||
'total_files' => 0,
|
||||
'matched' => 0,
|
||||
'unmatched' => 0,
|
||||
'will_replace' => 0,
|
||||
'ready_to_upload' => 0,
|
||||
];
|
||||
|
||||
foreach ($request->file('documents', []) as $file) {
|
||||
$summary['total_files']++;
|
||||
|
||||
$originalName = $file->getClientOriginalName();
|
||||
$baseName = pathinfo($originalName, PATHINFO_FILENAME);
|
||||
$normalizedKey = trim($baseName);
|
||||
$graduation = $graduations->get($normalizedKey);
|
||||
$existingPathField = $validated['document_type'] === 'skl' ? 'skl_file_path' : 'ijazah_file_path';
|
||||
|
||||
$storedTempPath = $file->store('temp/graduation-bulk-upload', 'public');
|
||||
|
||||
$row = [
|
||||
'original_name' => $originalName,
|
||||
'stored_temp_path' => $storedTempPath,
|
||||
'mime_type' => $file->getMimeType(),
|
||||
'file_size' => $file->getSize(),
|
||||
'match_key' => $normalizedKey,
|
||||
'graduation_id' => $graduation?->id,
|
||||
'student_name' => $graduation?->full_name,
|
||||
'identifier_value' => $graduation?->{$validated['match_by']},
|
||||
'status' => $graduation ? 'matched' : 'unmatched',
|
||||
'will_replace' => $graduation ? filled($graduation->{$existingPathField}) : false,
|
||||
];
|
||||
|
||||
if ($graduation) {
|
||||
$summary['matched']++;
|
||||
$summary['ready_to_upload']++;
|
||||
|
||||
if ($row['will_replace']) {
|
||||
$summary['will_replace']++;
|
||||
}
|
||||
} else {
|
||||
$summary['unmatched']++;
|
||||
}
|
||||
|
||||
$rows[] = $row;
|
||||
}
|
||||
|
||||
$preview = [
|
||||
'token' => (string) Str::uuid(),
|
||||
'document_type' => $validated['document_type'],
|
||||
'document_label' => $validated['document_type'] === 'skl' ? 'SKL' : 'Ijazah',
|
||||
'match_by' => $validated['match_by'],
|
||||
'match_by_label' => $validated['match_by'] === 'student_number' ? 'NIS' : 'NISN',
|
||||
'rows' => $rows,
|
||||
'summary' => $summary,
|
||||
];
|
||||
|
||||
$request->session()->put('graduation_bulk_upload_preview', $preview);
|
||||
|
||||
return redirect()->route('graduated-students.bulk-upload.index');
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$request->validate([
|
||||
'preview_token' => ['required', 'string'],
|
||||
]);
|
||||
|
||||
$preview = $request->session()->get('graduation_bulk_upload_preview');
|
||||
|
||||
if (! $preview || ($preview['token'] ?? null) !== $request->string('preview_token')->value()) {
|
||||
return back()->withErrors([
|
||||
'preview_token' => 'Preview bulk upload sudah tidak valid. Silakan upload ulang dokumen.',
|
||||
]);
|
||||
}
|
||||
|
||||
$documentType = $preview['document_type'];
|
||||
$fileNameField = $documentType === 'skl' ? 'skl_file_name' : 'ijazah_file_name';
|
||||
$filePathField = $documentType === 'skl' ? 'skl_file_path' : 'ijazah_file_path';
|
||||
$mimeTypeField = $documentType === 'skl' ? 'skl_mime_type' : 'ijazah_mime_type';
|
||||
$fileSizeField = $documentType === 'skl' ? 'skl_file_size' : 'ijazah_file_size';
|
||||
|
||||
$processed = 0;
|
||||
$skipped = 0;
|
||||
|
||||
DB::transaction(function () use ($preview, $documentType, $fileNameField, $filePathField, $mimeTypeField, $fileSizeField, &$processed, &$skipped) {
|
||||
foreach ($preview['rows'] as $row) {
|
||||
if (($row['status'] ?? null) !== 'matched' || empty($row['graduation_id'])) {
|
||||
$skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
$graduation = StudentGraduation::query()->find($row['graduation_id']);
|
||||
|
||||
if (! $graduation) {
|
||||
$skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (! Storage::disk('public')->exists($row['stored_temp_path'])) {
|
||||
$skipped++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($graduation->{$filePathField} && Storage::disk('public')->exists($graduation->{$filePathField})) {
|
||||
Storage::disk('public')->delete($graduation->{$filePathField});
|
||||
}
|
||||
|
||||
$extension = pathinfo($row['original_name'], PATHINFO_EXTENSION);
|
||||
$finalPath = "student-graduation-documents/{$graduation->student_id}/{$documentType}/" . Str::uuid() . ($extension ? '.' . $extension : '');
|
||||
Storage::disk('public')->move($row['stored_temp_path'], $finalPath);
|
||||
|
||||
$graduation->update([
|
||||
$fileNameField => $row['original_name'],
|
||||
$filePathField => $finalPath,
|
||||
$mimeTypeField => $row['mime_type'],
|
||||
$fileSizeField => $row['file_size'],
|
||||
]);
|
||||
|
||||
$processed++;
|
||||
}
|
||||
});
|
||||
|
||||
foreach ($preview['rows'] as $row) {
|
||||
if (! empty($row['stored_temp_path']) && Storage::disk('public')->exists($row['stored_temp_path'])) {
|
||||
Storage::disk('public')->delete($row['stored_temp_path']);
|
||||
}
|
||||
}
|
||||
|
||||
$request->session()->forget('graduation_bulk_upload_preview');
|
||||
|
||||
Alert::success('Berhasil', "Bulk upload {$preview['document_label']} selesai. {$processed} dokumen diproses, {$skipped} dilewati.");
|
||||
|
||||
return redirect()
|
||||
->route('graduated-students.bulk-upload.index')
|
||||
->with('success', "Bulk upload {$preview['document_label']} selesai. {$processed} dokumen diproses, {$skipped} dilewati.");
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,11 @@ namespace App\Http\Controllers;
|
||||
use App\Models\DocumentType;
|
||||
use App\Models\Student;
|
||||
use App\Models\StudentDocument;
|
||||
use App\Models\StudentGraduation;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Storage;
|
||||
use Illuminate\View\View;
|
||||
use Symfony\Component\HttpFoundation\StreamedResponse;
|
||||
|
||||
class PublicStudentLookupController extends Controller
|
||||
{
|
||||
@@ -44,6 +46,9 @@ class PublicStudentLookupController extends Controller
|
||||
if ($selectedStudent) {
|
||||
$requiredDocumentSummary = $this->buildRequiredDocumentSummary($selectedStudent);
|
||||
$matchedBy = $this->detectMatchedBy($selectedStudent, $query);
|
||||
$selectedStudent->public_graduation_record = $selectedStudent->status === 'graduated'
|
||||
? StudentGraduation::query()->where('student_id', $selectedStudent->id)->first()
|
||||
: null;
|
||||
}
|
||||
|
||||
$students->each(function (Student $student) {
|
||||
@@ -136,6 +141,21 @@ class PublicStudentLookupController extends Controller
|
||||
&& (str_contains($name, 'foto') || str_contains($fileName, 'foto'));
|
||||
}
|
||||
|
||||
public function downloadGraduationDocument(Student $student, string $document): StreamedResponse
|
||||
{
|
||||
abort_unless($student->status === 'graduated', 404);
|
||||
abort_unless(in_array($document, ['skl', 'ijazah'], true), 404);
|
||||
|
||||
$graduation = StudentGraduation::query()->where('student_id', $student->id)->firstOrFail();
|
||||
|
||||
$filePathField = $document === 'skl' ? 'skl_file_path' : 'ijazah_file_path';
|
||||
$fileNameField = $document === 'skl' ? 'skl_file_name' : 'ijazah_file_name';
|
||||
|
||||
abort_unless($graduation->{$filePathField} && Storage::disk('public')->exists($graduation->{$filePathField}), 404);
|
||||
|
||||
return Storage::disk('public')->download($graduation->{$filePathField}, $graduation->{$fileNameField} ?: basename($graduation->{$filePathField}));
|
||||
}
|
||||
|
||||
protected function buildRequiredDocumentSummary(Student $student): array
|
||||
{
|
||||
$requiredTypes = DocumentType::query()
|
||||
|
||||
@@ -13,6 +13,7 @@ use App\Models\Village;
|
||||
use App\Models\StudentAcademicHistory;
|
||||
use App\Models\StudentExit;
|
||||
use App\Models\StudentTransfer;
|
||||
use App\Models\StudentGraduation;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Http\Response;
|
||||
@@ -80,7 +81,7 @@ class StudentController extends Controller
|
||||
->when($academicYearId, fn ($query) => $query->where('students.academic_year_id', $academicYearId))
|
||||
->when($departmentId, fn ($query) => $query->where('students.department_id', $departmentId))
|
||||
->when($classId, fn ($query) => $query->where('students.class_id', $classId))
|
||||
->when($viewConfig['view'] === 'all' && blank($statusFilter), fn ($query) => $query->whereNotIn('students.status', ['dropped', 'transferred']))
|
||||
->when($viewConfig['view'] === 'all' && blank($statusFilter), fn ($query) => $query->where('students.status', 'active'))
|
||||
->when($viewConfig['view'] === 'all' && $statusFilter === 'active', fn ($query) => $query->where('students.status', 'active'))
|
||||
->when($viewConfig['view'] === 'all' && $statusFilter === 'non_active', fn ($query) => $query->whereIn('students.status', ['inactive', 'graduated', 'dropped', 'transferred']))
|
||||
->when($viewConfig['view'] !== 'all' && $status, fn ($query) => $query->where('students.status', $status))
|
||||
@@ -150,6 +151,29 @@ class StudentController extends Controller
|
||||
return $student;
|
||||
});
|
||||
|
||||
$summary = [
|
||||
'total' => $students->total(),
|
||||
'byAcademicYear' => Student::query()
|
||||
->select('academic_years.name', 'academic_years.start_year', DB::raw('count(*) as total'))
|
||||
->join('academic_years', 'academic_years.id', '=', 'students.academic_year_id')
|
||||
->when($search !== '', function ($query) use ($search) {
|
||||
$query->where(function ($subQuery) use ($search) {
|
||||
$subQuery->where('students.full_name', 'like', "%{$search}%")
|
||||
->orWhere('students.student_number', 'like', "%{$search}%")
|
||||
->orWhere('students.nisn', 'like', "%{$search}%")
|
||||
->orWhere('students.phone_number', 'like', "%{$search}%");
|
||||
});
|
||||
})
|
||||
->when($academicYearId, fn ($query) => $query->where('students.academic_year_id', $academicYearId))
|
||||
->when($departmentId, fn ($query) => $query->where('students.department_id', $departmentId))
|
||||
->when($classId, fn ($query) => $query->where('students.class_id', $classId))
|
||||
->where('students.status', $status ?: 'graduated')
|
||||
->groupBy('academic_years.name', 'academic_years.start_year')
|
||||
->orderByDesc('academic_years.start_year')
|
||||
->limit(3)
|
||||
->get(),
|
||||
];
|
||||
|
||||
return view('students.index', [
|
||||
'students' => $students,
|
||||
'search' => $search,
|
||||
@@ -162,16 +186,19 @@ class StudentController extends Controller
|
||||
'academicYears' => AcademicYear::orderBy('name')->pluck('name', 'id'),
|
||||
'departments' => Department::where('is_active', true)->orderBy('name')->pluck('name', 'id'),
|
||||
'classes' => SchoolClass::orderBy('name')->pluck('name', 'id'),
|
||||
'statuses' => [
|
||||
'statuses' => $viewConfig['view'] === 'all'
|
||||
? [
|
||||
'active' => 'Aktif',
|
||||
'non_active' => 'Non Aktif',
|
||||
],
|
||||
]
|
||||
: [],
|
||||
'studentStatusLabels' => $this->statusOptions(),
|
||||
'sort' => $sort,
|
||||
'direction' => $direction,
|
||||
'pageTitle' => $viewConfig['title'],
|
||||
'pageDescription' => $viewConfig['description'],
|
||||
'viewMode' => $viewConfig['view'],
|
||||
'summary' => $summary,
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -188,6 +215,7 @@ class StudentController extends Controller
|
||||
$this->syncAcademicHistory($student, $data);
|
||||
$this->syncExitRecord($student, $data);
|
||||
$this->syncTransferRecord($student, $data);
|
||||
$this->syncGraduationRecord($student, $data);
|
||||
|
||||
Alert::success('Berhasil', 'Data siswa berhasil ditambahkan.');
|
||||
|
||||
@@ -261,6 +289,7 @@ class StudentController extends Controller
|
||||
$this->syncAcademicHistory($student, $data);
|
||||
$this->syncExitRecord($student, $data);
|
||||
$this->syncTransferRecord($student, $data);
|
||||
$this->syncGraduationRecord($student, $data);
|
||||
|
||||
Alert::success('Berhasil', 'Data siswa berhasil diperbarui.');
|
||||
|
||||
@@ -750,6 +779,60 @@ class StudentController extends Controller
|
||||
StudentTransfer::query()->where('student_id', $student->id)->delete();
|
||||
}
|
||||
|
||||
protected function syncGraduationRecord(Student $student, array $data): void
|
||||
{
|
||||
if (($data['status'] ?? null) === 'graduated') {
|
||||
$graduationRecord = StudentGraduation::firstOrNew(['student_id' => $student->id]);
|
||||
|
||||
$graduationRecord->fill([
|
||||
'student_number' => $student->student_number,
|
||||
'nisn' => $student->nisn,
|
||||
'full_name' => $student->full_name,
|
||||
'academic_year_id' => $student->academic_year_id,
|
||||
'department_id' => $student->department_id,
|
||||
'class_id' => $student->class_id,
|
||||
'entry_date' => $student->entry_date,
|
||||
'graduation_date' => $graduationRecord->graduation_date ?? now()->toDateString(),
|
||||
'graduation_note' => $student->notes,
|
||||
'status' => 'graduated',
|
||||
]);
|
||||
|
||||
if (request()->hasFile('skl_file')) {
|
||||
if ($graduationRecord->skl_file_path && Storage::disk('public')->exists($graduationRecord->skl_file_path)) {
|
||||
Storage::disk('public')->delete($graduationRecord->skl_file_path);
|
||||
}
|
||||
|
||||
$file = request()->file('skl_file');
|
||||
$path = $file->store("student-graduation-documents/{$student->id}/skl", 'public');
|
||||
|
||||
$graduationRecord->skl_file_name = $file->getClientOriginalName();
|
||||
$graduationRecord->skl_file_path = $path;
|
||||
$graduationRecord->skl_mime_type = $file->getMimeType();
|
||||
$graduationRecord->skl_file_size = $file->getSize();
|
||||
}
|
||||
|
||||
if (request()->hasFile('ijazah_file')) {
|
||||
if ($graduationRecord->ijazah_file_path && Storage::disk('public')->exists($graduationRecord->ijazah_file_path)) {
|
||||
Storage::disk('public')->delete($graduationRecord->ijazah_file_path);
|
||||
}
|
||||
|
||||
$file = request()->file('ijazah_file');
|
||||
$path = $file->store("student-graduation-documents/{$student->id}/ijazah", 'public');
|
||||
|
||||
$graduationRecord->ijazah_file_name = $file->getClientOriginalName();
|
||||
$graduationRecord->ijazah_file_path = $path;
|
||||
$graduationRecord->ijazah_mime_type = $file->getMimeType();
|
||||
$graduationRecord->ijazah_file_size = $file->getSize();
|
||||
}
|
||||
|
||||
$graduationRecord->save();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
StudentGraduation::query()->where('student_id', $student->id)->delete();
|
||||
}
|
||||
|
||||
protected function importRules(): array
|
||||
{
|
||||
return [
|
||||
@@ -1114,12 +1197,6 @@ class StudentController extends Controller
|
||||
protected function resolveStudentViewConfig(string $viewMode, mixed $requestedStatus): array
|
||||
{
|
||||
return match ($viewMode) {
|
||||
'graduated' => [
|
||||
'view' => 'graduated',
|
||||
'status' => 'graduated',
|
||||
'title' => 'Data Siswa Lulus',
|
||||
'description' => 'Daftar siswa yang sudah berstatus lulus.',
|
||||
],
|
||||
'transferred' => [
|
||||
'view' => 'transferred',
|
||||
'status' => 'transferred',
|
||||
|
||||
@@ -6,6 +6,7 @@ use App\Models\AcademicYear;
|
||||
use App\Models\SchoolClass;
|
||||
use App\Models\Student;
|
||||
use App\Models\StudentAcademicHistory;
|
||||
use App\Models\StudentGraduation;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Collection;
|
||||
@@ -19,15 +20,64 @@ class StudentPromotionController extends Controller
|
||||
{
|
||||
$fromAcademicYearId = $request->integer('from_academic_year_id') ?: AcademicYear::where('is_active', true)->value('id');
|
||||
$toAcademicYearId = $request->integer('to_academic_year_id');
|
||||
$selectedClassId = $request->integer('class_id');
|
||||
|
||||
$academicYears = AcademicYear::orderByDesc('start_year')->orderByDesc('end_year')->get();
|
||||
|
||||
$availableClasses = collect();
|
||||
$classSummaries = collect();
|
||||
$selectedClass = null;
|
||||
$students = collect();
|
||||
|
||||
if ($fromAcademicYearId) {
|
||||
$availableClasses = SchoolClass::query()
|
||||
->with(['department'])
|
||||
->where('academic_year_id', $fromAcademicYearId)
|
||||
->where('is_active', true)
|
||||
->withCount([
|
||||
'students as active_students_count' => fn ($query) => $query->where('status', 'active'),
|
||||
])
|
||||
->orderBy('level')
|
||||
->orderBy('name')
|
||||
->get()
|
||||
->filter(fn (SchoolClass $classRoom) => $classRoom->active_students_count > 0)
|
||||
->values();
|
||||
|
||||
$classSummaries = $availableClasses->map(function (SchoolClass $classRoom) use ($toAcademicYearId) {
|
||||
$sampleStudent = Student::query()
|
||||
->with(['classRoom'])
|
||||
->where('academic_year_id', $classRoom->academic_year_id)
|
||||
->where('class_id', $classRoom->id)
|
||||
->where('status', 'active')
|
||||
->orderBy('full_name')
|
||||
->first();
|
||||
|
||||
$recommendation = $sampleStudent
|
||||
? $this->buildPromotionRecommendation($sampleStudent, $toAcademicYearId)
|
||||
: [
|
||||
'label' => 'Belum ada siswa aktif',
|
||||
'target_class_name' => null,
|
||||
];
|
||||
|
||||
return (object) [
|
||||
'id' => $classRoom->id,
|
||||
'name' => $classRoom->name,
|
||||
'level' => $classRoom->level,
|
||||
'department_name' => $classRoom->department?->name,
|
||||
'active_students_count' => $classRoom->active_students_count,
|
||||
'recommendation_label' => $recommendation['label'] ?? '-',
|
||||
'recommendation_target_name' => $recommendation['target_class_name'] ?? null,
|
||||
];
|
||||
})->values();
|
||||
|
||||
if ($selectedClassId) {
|
||||
$selectedClass = $availableClasses->firstWhere('id', $selectedClassId);
|
||||
|
||||
if ($selectedClass) {
|
||||
$students = Student::query()
|
||||
->with(['academicYear', 'department', 'classRoom'])
|
||||
->where('academic_year_id', $fromAcademicYearId)
|
||||
->where('class_id', $selectedClassId)
|
||||
->where('status', 'active')
|
||||
->orderBy('full_name')
|
||||
->get()
|
||||
@@ -37,13 +87,19 @@ class StudentPromotionController extends Controller
|
||||
return $student;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return view('student-promotions.index', [
|
||||
'academicYears' => $academicYears,
|
||||
'availableClasses' => $availableClasses,
|
||||
'classSummaries' => $classSummaries,
|
||||
'selectedClass' => $selectedClass,
|
||||
'students' => $students,
|
||||
'filters' => [
|
||||
'from_academic_year_id' => $fromAcademicYearId,
|
||||
'to_academic_year_id' => $toAcademicYearId,
|
||||
'class_id' => $selectedClassId,
|
||||
],
|
||||
]);
|
||||
}
|
||||
@@ -53,6 +109,7 @@ class StudentPromotionController extends Controller
|
||||
$data = $request->validate([
|
||||
'from_academic_year_id' => ['required', 'exists:academic_years,id'],
|
||||
'to_academic_year_id' => ['required', 'exists:academic_years,id', 'different:from_academic_year_id'],
|
||||
'class_id' => ['nullable', 'exists:classes,id'],
|
||||
'promotions' => ['required', 'array', 'min:1'],
|
||||
'promotions.*.student_id' => ['required', 'exists:students,id'],
|
||||
'promotions.*.target_class_id' => ['nullable', 'exists:classes,id'],
|
||||
@@ -102,6 +159,12 @@ class StudentPromotionController extends Controller
|
||||
->withInput();
|
||||
}
|
||||
|
||||
if (! empty($data['class_id']) && (int) $student->class_id !== (int) $data['class_id']) {
|
||||
return back()
|
||||
->withErrors(["promotions.$index.student_id" => "Siswa {$student->full_name} tidak berasal dari kelas asal yang dipilih."])
|
||||
->withInput();
|
||||
}
|
||||
|
||||
if ($student->status !== 'active') {
|
||||
return back()
|
||||
->withErrors(["promotions.$index.student_id" => "Siswa {$student->full_name} tidak berstatus aktif sehingga tidak bisa diproses promosi."])
|
||||
@@ -200,6 +263,22 @@ class StudentPromotionController extends Controller
|
||||
'notes' => $promotion['notes'] ?? 'Diproses melalui modul promosi siswa.',
|
||||
]);
|
||||
|
||||
StudentGraduation::updateOrCreate(
|
||||
['student_id' => $student->id],
|
||||
[
|
||||
'student_number' => $student->student_number,
|
||||
'nisn' => $student->nisn,
|
||||
'full_name' => $student->full_name,
|
||||
'academic_year_id' => $student->academic_year_id,
|
||||
'department_id' => $student->department_id,
|
||||
'class_id' => $student->class_id,
|
||||
'entry_date' => $student->entry_date,
|
||||
'graduation_date' => now()->toDateString(),
|
||||
'graduation_note' => $promotion['notes'] ?? 'Diproses melalui modul promosi siswa.',
|
||||
'status' => 'graduated',
|
||||
]
|
||||
);
|
||||
|
||||
$processed++;
|
||||
continue;
|
||||
}
|
||||
@@ -245,6 +324,7 @@ class StudentPromotionController extends Controller
|
||||
->route('student-promotions.index', [
|
||||
'from_academic_year_id' => $data['from_academic_year_id'],
|
||||
'to_academic_year_id' => $data['to_academic_year_id'],
|
||||
'class_id' => $data['class_id'] ?? null,
|
||||
])
|
||||
->with('success', $processed . ' siswa berhasil diproses melalui modul promosi.');
|
||||
}
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\SyncToken;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Illuminate\Support\Str;
|
||||
use Illuminate\View\View;
|
||||
|
||||
class SyncTokenController extends Controller
|
||||
{
|
||||
public function index(Request $request): View
|
||||
{
|
||||
return view('settings.sync-tokens.index', [
|
||||
'tokens' => SyncToken::query()->with('creator')->latest()->get(),
|
||||
'plainToken' => $request->session()->get('sync_token_plain'),
|
||||
]);
|
||||
}
|
||||
|
||||
public function store(Request $request): RedirectResponse
|
||||
{
|
||||
$data = $request->validate([
|
||||
'name' => ['required', 'string', 'max:255'],
|
||||
'abilities' => ['nullable', 'array'],
|
||||
'abilities.*' => ['string', 'max:100'],
|
||||
]);
|
||||
|
||||
$plainToken = 'dksync_' . Str::random(48);
|
||||
|
||||
SyncToken::query()->create([
|
||||
'name' => $data['name'],
|
||||
'token_hash' => Hash::make($plainToken),
|
||||
'abilities' => $data['abilities'] ?? ['academic_years', 'departments', 'classes', 'students'],
|
||||
'created_by' => $request->user()->id,
|
||||
]);
|
||||
|
||||
return redirect()
|
||||
->route('settings.sync-tokens.index')
|
||||
->with('status', 'Token sinkronisasi berhasil dibuat.')
|
||||
->with('sync_token_plain', $plainToken);
|
||||
}
|
||||
|
||||
public function revoke(SyncToken $syncToken): RedirectResponse
|
||||
{
|
||||
if (! $syncToken->revoked_at) {
|
||||
$syncToken->update([
|
||||
'revoked_at' => now(),
|
||||
]);
|
||||
}
|
||||
|
||||
return redirect()
|
||||
->route('settings.sync-tokens.index')
|
||||
->with('status', 'Token sinkronisasi berhasil dinonaktifkan.');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use App\Models\SyncToken;
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class EnsureValidSyncToken
|
||||
{
|
||||
public function handle(Request $request, Closure $next): Response
|
||||
{
|
||||
$bearerToken = $request->bearerToken();
|
||||
|
||||
if (! $bearerToken) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Token sinkronisasi tidak ditemukan.',
|
||||
], 401);
|
||||
}
|
||||
|
||||
$token = SyncToken::query()
|
||||
->whereNull('revoked_at')
|
||||
->get()
|
||||
->first(fn (SyncToken $item) => Hash::check($bearerToken, $item->token_hash));
|
||||
|
||||
if (! $token) {
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'message' => 'Token sinkronisasi tidak valid atau sudah dinonaktifkan.',
|
||||
], 401);
|
||||
}
|
||||
|
||||
$token->forceFill([
|
||||
'last_used_at' => now(),
|
||||
])->save();
|
||||
|
||||
$request->attributes->set('syncToken', $token);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
@@ -145,6 +145,11 @@ class Student extends Model
|
||||
return $this->hasOne(StudentTransfer::class);
|
||||
}
|
||||
|
||||
public function graduationRecord(): HasOne
|
||||
{
|
||||
return $this->hasOne(StudentGraduation::class);
|
||||
}
|
||||
|
||||
public function achievements(): HasMany
|
||||
{
|
||||
return $this->hasMany(StudentAchievement::class)->latest('achievement_year')->latest('achievement_date');
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class StudentGraduation extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'student_id',
|
||||
'student_number',
|
||||
'nisn',
|
||||
'full_name',
|
||||
'academic_year_id',
|
||||
'department_id',
|
||||
'class_id',
|
||||
'entry_date',
|
||||
'graduation_date',
|
||||
'graduation_note',
|
||||
'skl_file_name',
|
||||
'skl_file_path',
|
||||
'skl_mime_type',
|
||||
'skl_file_size',
|
||||
'ijazah_file_name',
|
||||
'ijazah_file_path',
|
||||
'ijazah_mime_type',
|
||||
'ijazah_file_size',
|
||||
'status',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'entry_date' => 'date',
|
||||
'graduation_date' => 'date',
|
||||
];
|
||||
}
|
||||
|
||||
public function student(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Student::class);
|
||||
}
|
||||
|
||||
public function academicYear(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(AcademicYear::class);
|
||||
}
|
||||
|
||||
public function department(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(Department::class);
|
||||
}
|
||||
|
||||
public function classRoom(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(SchoolClass::class, 'class_id');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
|
||||
class SyncToken extends Model
|
||||
{
|
||||
use HasFactory;
|
||||
|
||||
protected $fillable = [
|
||||
'name',
|
||||
'token_hash',
|
||||
'abilities',
|
||||
'created_by',
|
||||
'last_used_at',
|
||||
'revoked_at',
|
||||
];
|
||||
|
||||
protected function casts(): array
|
||||
{
|
||||
return [
|
||||
'abilities' => 'array',
|
||||
'last_used_at' => 'datetime',
|
||||
'revoked_at' => 'datetime',
|
||||
];
|
||||
}
|
||||
|
||||
public function creator(): BelongsTo
|
||||
{
|
||||
return $this->belongsTo(User::class, 'created_by');
|
||||
}
|
||||
|
||||
public function getIsRevokedAttribute(): bool
|
||||
{
|
||||
return ! is_null($this->revoked_at);
|
||||
}
|
||||
}
|
||||
@@ -7,12 +7,14 @@ use Illuminate\Foundation\Configuration\Middleware;
|
||||
return Application::configure(basePath: dirname(__DIR__))
|
||||
->withRouting(
|
||||
web: __DIR__.'/../routes/web.php',
|
||||
api: __DIR__.'/../routes/api.php',
|
||||
commands: __DIR__.'/../routes/console.php',
|
||||
health: '/up',
|
||||
)
|
||||
->withMiddleware(function (Middleware $middleware): void {
|
||||
$middleware->alias([
|
||||
'role' => \App\Http\Middleware\EnsureUserHasRole::class,
|
||||
'sync.token' => \App\Http\Middleware\EnsureValidSyncToken::class,
|
||||
]);
|
||||
})
|
||||
->withExceptions(function (Exceptions $exceptions): void {
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('sync_tokens', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('name');
|
||||
$table->string('token_hash')->unique();
|
||||
$table->text('abilities')->nullable();
|
||||
$table->foreignId('created_by')->constrained('users')->cascadeOnDelete();
|
||||
$table->timestamp('last_used_at')->nullable();
|
||||
$table->timestamp('revoked_at')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('sync_tokens');
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('student_graduations', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->foreignId('student_id')->constrained()->cascadeOnDelete();
|
||||
$table->string('student_number')->nullable();
|
||||
$table->string('nisn')->nullable();
|
||||
$table->string('full_name');
|
||||
$table->foreignId('academic_year_id')->nullable()->constrained('academic_years')->nullOnDelete();
|
||||
$table->foreignId('department_id')->nullable()->constrained('departments')->nullOnDelete();
|
||||
$table->foreignId('class_id')->nullable()->constrained('classes')->nullOnDelete();
|
||||
$table->date('entry_date')->nullable();
|
||||
$table->date('graduation_date')->nullable();
|
||||
$table->text('graduation_note')->nullable();
|
||||
$table->string('skl_file_name')->nullable();
|
||||
$table->string('skl_file_path')->nullable();
|
||||
$table->string('skl_mime_type')->nullable();
|
||||
$table->unsignedBigInteger('skl_file_size')->nullable();
|
||||
$table->string('ijazah_file_name')->nullable();
|
||||
$table->string('ijazah_file_path')->nullable();
|
||||
$table->string('ijazah_mime_type')->nullable();
|
||||
$table->unsignedBigInteger('ijazah_file_size')->nullable();
|
||||
$table->string('status')->default('graduated');
|
||||
$table->timestamps();
|
||||
|
||||
$table->unique('student_id');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('student_graduations');
|
||||
}
|
||||
};
|
||||
+189
-3
@@ -369,14 +369,179 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
if (promotionForm) {
|
||||
const rows = promotionForm.querySelectorAll('tbody tr');
|
||||
const counterElements = {
|
||||
promote: document.querySelector('[data-promotion-counter="promote"]'),
|
||||
repeat: document.querySelector('[data-promotion-counter="repeat"]'),
|
||||
graduate: document.querySelector('[data-promotion-counter="graduate"]'),
|
||||
skip: document.querySelector('[data-promotion-counter="skip"]'),
|
||||
};
|
||||
const liveSummary = document.querySelector('[data-promotion-live-summary]');
|
||||
const capacitySummary = document.querySelector('[data-promotion-capacity-summary]');
|
||||
const finalPreview = document.querySelector('[data-promotion-final-preview]');
|
||||
const submitButton = document.querySelector('[data-promotion-submit-button]');
|
||||
const toolbar = document.querySelector('[data-promotion-toolbar]');
|
||||
|
||||
const getOptionsForAction = (targetSelect, actionValue) => {
|
||||
const optionKey = actionValue === 'repeat' ? 'optionsRepeat' : 'optionsPromote';
|
||||
return JSON.parse(targetSelect?.dataset?.[optionKey] || '[]');
|
||||
};
|
||||
|
||||
const calculateCounts = () => {
|
||||
const counts = { promote: 0, repeat: 0, graduate: 0, skip: 0 };
|
||||
|
||||
rows.forEach((row) => {
|
||||
const actionSelect = row.querySelector('.promotion-action-select');
|
||||
const actionValue = actionSelect?.value || 'skip';
|
||||
if (counts[actionValue] !== undefined) {
|
||||
counts[actionValue] += 1;
|
||||
}
|
||||
});
|
||||
|
||||
return counts;
|
||||
};
|
||||
|
||||
const updateCounters = () => {
|
||||
const counts = calculateCounts();
|
||||
|
||||
Object.entries(counterElements).forEach(([key, element]) => {
|
||||
if (element) {
|
||||
element.textContent = counts[key];
|
||||
}
|
||||
});
|
||||
|
||||
if (liveSummary) {
|
||||
liveSummary.innerHTML = `Ringkasan live: <span class="font-semibold">${counts.promote}</span> naik, <span class="font-semibold">${counts.repeat}</span> tinggal kelas, <span class="font-semibold">${counts.graduate}</span> lulus, dan <span class="font-semibold">${counts.skip}</span> dilewati.`;
|
||||
}
|
||||
};
|
||||
|
||||
const updateFinalPreview = () => {
|
||||
if (!finalPreview) {
|
||||
return;
|
||||
}
|
||||
|
||||
const counts = calculateCounts();
|
||||
const totalProcessed = counts.promote + counts.repeat + counts.graduate;
|
||||
|
||||
finalPreview.classList.remove('hidden');
|
||||
finalPreview.innerHTML = `
|
||||
<div class="font-semibold">Preview final sebelum submit</div>
|
||||
<div class="mt-2">Batch ini akan memproses <span class="font-semibold">${totalProcessed}</span> siswa.</div>
|
||||
<ul class="mt-2 list-disc space-y-1 pl-5">
|
||||
<li><span class="font-semibold">${counts.promote}</span> siswa naik kelas</li>
|
||||
<li><span class="font-semibold">${counts.repeat}</span> siswa tinggal kelas</li>
|
||||
<li><span class="font-semibold">${counts.graduate}</span> siswa lulus</li>
|
||||
<li><span class="font-semibold">${counts.skip}</span> siswa dilewati</li>
|
||||
</ul>
|
||||
`;
|
||||
};
|
||||
|
||||
const updateCapacitySummary = () => {
|
||||
if (!capacitySummary) {
|
||||
return;
|
||||
}
|
||||
|
||||
const plannedByClass = new Map();
|
||||
|
||||
rows.forEach((row) => {
|
||||
const actionSelect = row.querySelector('.promotion-action-select');
|
||||
const targetSelect = row.querySelector('.promotion-target-select');
|
||||
const actionValue = actionSelect?.value || 'skip';
|
||||
|
||||
if (!targetSelect || !['promote', 'repeat'].includes(actionValue) || !targetSelect.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
const options = getOptionsForAction(targetSelect, actionValue);
|
||||
const selectedOption = options.find((option) => String(option.id) === String(targetSelect.value));
|
||||
|
||||
if (!selectedOption) {
|
||||
return;
|
||||
}
|
||||
|
||||
const entry = plannedByClass.get(String(selectedOption.id)) || {
|
||||
name: selectedOption.name,
|
||||
planned: 0,
|
||||
remaining: selectedOption.remaining_capacity,
|
||||
capacityLabel: selectedOption.capacity_label,
|
||||
};
|
||||
|
||||
entry.planned += 1;
|
||||
plannedByClass.set(String(selectedOption.id), entry);
|
||||
});
|
||||
|
||||
const conflicts = Array.from(plannedByClass.values()).filter((entry) => entry.remaining !== null && entry.planned > entry.remaining);
|
||||
const warnings = Array.from(plannedByClass.values()).filter((entry) => entry.remaining !== null && entry.planned <= entry.remaining && entry.remaining - entry.planned <= 1);
|
||||
|
||||
capacitySummary.classList.remove('hidden', 'border-rose-200', 'bg-rose-50', 'text-rose-700', 'border-amber-200', 'bg-amber-50', 'text-amber-700', 'border-emerald-200', 'bg-emerald-50', 'text-emerald-700');
|
||||
|
||||
if (conflicts.length > 0) {
|
||||
capacitySummary.classList.add('border-rose-200', 'bg-rose-50', 'text-rose-700');
|
||||
capacitySummary.innerHTML = `<div class="font-semibold">Konflik kapasitas terdeteksi sebelum submit.</div><ul class="mt-2 list-disc space-y-1 pl-5">${conflicts.map((entry) => `<li>${entry.name}: alokasi ${entry.planned} siswa, sisa kuota hanya ${entry.remaining}. (${entry.capacityLabel})</li>`).join('')}</ul>`;
|
||||
if (submitButton) {
|
||||
submitButton.disabled = true;
|
||||
submitButton.classList.add('opacity-50', 'cursor-not-allowed');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (warnings.length > 0) {
|
||||
capacitySummary.classList.add('border-amber-200', 'bg-amber-50', 'text-amber-700');
|
||||
capacitySummary.innerHTML = `<div class="font-semibold">Perhatian: alokasi mendekati batas kuota.</div><ul class="mt-2 list-disc space-y-1 pl-5">${warnings.map((entry) => `<li>${entry.name}: alokasi ${entry.planned} siswa. ${entry.capacityLabel}.</li>`).join('')}</ul>`;
|
||||
if (submitButton) {
|
||||
submitButton.disabled = false;
|
||||
submitButton.classList.remove('opacity-50', 'cursor-not-allowed');
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
capacitySummary.classList.add('border-emerald-200', 'bg-emerald-50', 'text-emerald-700');
|
||||
capacitySummary.innerHTML = '<div class="font-semibold">Cek kapasitas aman.</div><div class="mt-1">Belum ada konflik kuota pada alokasi kelas tujuan saat ini.</div>';
|
||||
if (submitButton) {
|
||||
submitButton.disabled = false;
|
||||
submitButton.classList.remove('opacity-50', 'cursor-not-allowed');
|
||||
}
|
||||
};
|
||||
|
||||
const updateCapacityWarning = (row, actionValue) => {
|
||||
const targetSelect = row.querySelector('.promotion-target-select');
|
||||
const warningBox = row.querySelector('[data-promotion-capacity-warning]');
|
||||
|
||||
if (!targetSelect || !warningBox || (actionValue !== 'promote' && actionValue !== 'repeat')) {
|
||||
warningBox?.classList.add('hidden');
|
||||
warningBox?.classList.remove('border-rose-200', 'bg-rose-50', 'text-rose-700', 'border-amber-200', 'bg-amber-50', 'text-amber-700', 'border-emerald-200', 'bg-emerald-50', 'text-emerald-700');
|
||||
return;
|
||||
}
|
||||
|
||||
const options = getOptionsForAction(targetSelect, actionValue);
|
||||
const selectedOption = options.find((option) => String(option.id) === String(targetSelect.value));
|
||||
|
||||
if (!selectedOption) {
|
||||
warningBox.classList.add('hidden');
|
||||
warningBox.classList.remove('border-rose-200', 'bg-rose-50', 'text-rose-700', 'border-amber-200', 'bg-amber-50', 'text-amber-700', 'border-emerald-200', 'bg-emerald-50', 'text-emerald-700');
|
||||
return;
|
||||
}
|
||||
|
||||
warningBox.classList.remove('hidden', 'border-rose-200', 'bg-rose-50', 'text-rose-700', 'border-amber-200', 'bg-amber-50', 'text-amber-700', 'border-emerald-200', 'bg-emerald-50', 'text-emerald-700');
|
||||
|
||||
if (selectedOption.warning_level === 'full') {
|
||||
warningBox.classList.add('border-rose-200', 'bg-rose-50', 'text-rose-700');
|
||||
warningBox.textContent = `Peringatan: ${selectedOption.name} sudah penuh. ${selectedOption.capacity_label}.`;
|
||||
} else if (selectedOption.warning_level === 'low') {
|
||||
warningBox.classList.add('border-amber-200', 'bg-amber-50', 'text-amber-700');
|
||||
warningBox.textContent = `Perhatian: kuota ${selectedOption.name} menipis. ${selectedOption.capacity_label}.`;
|
||||
} else {
|
||||
warningBox.classList.add('border-emerald-200', 'bg-emerald-50', 'text-emerald-700');
|
||||
warningBox.textContent = `Kelas tujuan tersedia. ${selectedOption.capacity_label}.`;
|
||||
}
|
||||
};
|
||||
|
||||
const renderTargetOptions = (targetSelect, actionValue) => {
|
||||
if (!targetSelect) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
const optionKey = actionValue === 'repeat' ? 'optionsRepeat' : 'optionsPromote';
|
||||
const selectedKey = actionValue === 'repeat' ? 'selectedRepeat' : 'selectedPromote';
|
||||
const options = JSON.parse(targetSelect.dataset[optionKey] || '[]');
|
||||
const options = getOptionsForAction(targetSelect, actionValue);
|
||||
const selectedValue = targetSelect.dataset[selectedKey] || '';
|
||||
|
||||
targetSelect.innerHTML = '<option value="">Pilih kelas tujuan</option>';
|
||||
@@ -384,7 +549,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
options.forEach((option) => {
|
||||
const optionElement = document.createElement('option');
|
||||
optionElement.value = option.id;
|
||||
optionElement.textContent = option.name;
|
||||
optionElement.textContent = option.option_label || option.name;
|
||||
if (String(option.id) === String(selectedValue)) {
|
||||
optionElement.selected = true;
|
||||
}
|
||||
@@ -439,16 +604,26 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
}
|
||||
|
||||
row.classList.toggle('opacity-60', actionValue === 'skip');
|
||||
updateCapacityWarning(row, actionValue);
|
||||
updateCounters();
|
||||
updateCapacitySummary();
|
||||
updateFinalPreview();
|
||||
};
|
||||
|
||||
rows.forEach((row) => {
|
||||
const actionSelect = row.querySelector('.promotion-action-select');
|
||||
const targetSelect = row.querySelector('.promotion-target-select');
|
||||
|
||||
if (!actionSelect) {
|
||||
return;
|
||||
}
|
||||
|
||||
applyRowActionState(row, actionSelect.value);
|
||||
actionSelect.addEventListener('change', () => applyRowActionState(row, actionSelect.value));
|
||||
targetSelect?.addEventListener('change', () => {
|
||||
updateCapacityWarning(row, actionSelect.value);
|
||||
updateCapacitySummary();
|
||||
});
|
||||
});
|
||||
|
||||
promotionForm.querySelectorAll('[data-promotion-bulk-action]').forEach((button) => {
|
||||
@@ -463,6 +638,8 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
|
||||
if (actionValue === 'promote' && actionSelect.querySelector('option[value="promote"]')) {
|
||||
actionSelect.value = 'promote';
|
||||
} else if (actionValue === 'graduate' && actionSelect.querySelector('option[value="graduate"]')) {
|
||||
actionSelect.value = 'graduate';
|
||||
} else if (actionValue === 'repeat') {
|
||||
actionSelect.value = 'repeat';
|
||||
} else if (actionValue === 'skip') {
|
||||
@@ -473,5 +650,14 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
if (toolbar?.dataset?.classLevel === 'XII') {
|
||||
const graduateButton = toolbar.querySelector('[data-promotion-bulk-action="graduate"]');
|
||||
graduateButton?.classList.add('ring-2', 'ring-sky-200');
|
||||
}
|
||||
|
||||
updateCounters();
|
||||
updateCapacitySummary();
|
||||
updateFinalPreview();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -0,0 +1,135 @@
|
||||
<x-master-page title="Bulk Upload Dokumen Kelulusan" description="Upload SKL atau ijazah dalam jumlah besar dengan pencocokan otomatis berdasarkan NIS atau NISN.">
|
||||
<div class="space-y-6">
|
||||
<x-master-card title="Bulk Upload Dokumen Kelulusan" subtitle="Gunakan nama file sesuai NIS atau NISN agar sistem dapat mencocokkan dokumen secara otomatis ke siswa lulus.">
|
||||
<div class="mb-6 rounded-2xl border border-sky-200 bg-sky-50 px-4 py-4 text-sm text-sky-700">
|
||||
<p class="font-semibold">Aturan nama file yang disarankan</p>
|
||||
<ul class="mt-2 list-disc space-y-1 pl-5 text-sky-700/90">
|
||||
<li>Jika memilih pencocokan <strong>NIS</strong>, nama file harus berupa NIS siswa. Contoh: <code>2024001.pdf</code></li>
|
||||
<li>Jika memilih pencocokan <strong>NISN</strong>, nama file harus berupa NISN siswa. Contoh: <code>9988776655.pdf</code></li>
|
||||
<li>Upload dipisah per jenis dokumen: jalankan batch <strong>SKL</strong> dan <strong>Ijazah</strong> secara terpisah agar lebih aman.</li>
|
||||
<li>Untuk meminimalkan error, gunakan maksimal <strong>10 file</strong> per batch dengan ukuran maksimal <strong>2 MB</strong> per file.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<form method="POST" action="{{ route('graduated-students.bulk-upload.preview') }}" enctype="multipart/form-data" class="space-y-6">
|
||||
@csrf
|
||||
|
||||
<div class="grid grid-cols-1 gap-6 lg:grid-cols-2">
|
||||
<div>
|
||||
<label for="document_type" class="mb-2 block text-sm font-medium text-slate-700">Jenis Dokumen</label>
|
||||
<select id="document_type" name="document_type" class="h-12 w-full rounded-2xl border border-slate-200 bg-white px-4 text-sm text-slate-700 focus:border-indigo-300 focus:outline-none focus:ring-4 focus:ring-indigo-100" required>
|
||||
<option value="">Pilih jenis dokumen</option>
|
||||
@foreach ($documentTypes as $value => $label)
|
||||
<option value="{{ $value }}" @selected(old('document_type') === $value)>{{ $label }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<x-input-error :messages="$errors->get('document_type')" class="mt-2" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="match_by" class="mb-2 block text-sm font-medium text-slate-700">Cocokkan Berdasarkan</label>
|
||||
<select id="match_by" name="match_by" class="h-12 w-full rounded-2xl border border-slate-200 bg-white px-4 text-sm text-slate-700 focus:border-indigo-300 focus:outline-none focus:ring-4 focus:ring-indigo-100" required>
|
||||
@foreach ($matchByOptions as $value => $label)
|
||||
<option value="{{ $value }}" @selected(old('match_by', 'student_number') === $value)>{{ $label }}</option>
|
||||
@endforeach
|
||||
</select>
|
||||
<x-input-error :messages="$errors->get('match_by')" class="mt-2" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="documents" class="mb-2 block text-sm font-medium text-slate-700">Pilih Banyak Dokumen Sekaligus</label>
|
||||
<input id="documents" name="documents[]" type="file" accept=".pdf,.jpg,.jpeg,.png" multiple class="block w-full rounded-2xl border border-slate-200 bg-white px-4 py-3 text-sm text-slate-700 file:mr-4 file:rounded-xl file:border-0 file:bg-slate-100 file:px-4 file:py-2 file:text-sm file:font-semibold file:text-slate-700 hover:file:bg-slate-200">
|
||||
<p class="mt-2 text-xs text-slate-500">Format yang didukung: PDF, JPG, JPEG, PNG. Maksimal 2 MB per file dan 10 file per batch upload.</p>
|
||||
<x-input-error :messages="$errors->get('documents')" class="mt-2" />
|
||||
<x-input-error :messages="$errors->get('documents.*')" class="mt-2" />
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<button type="submit" class="inline-flex items-center rounded-2xl bg-indigo-600 px-5 py-3 text-sm font-semibold text-white shadow-lg shadow-indigo-200 transition hover:bg-indigo-700">
|
||||
Preview Mapping Dokumen
|
||||
</button>
|
||||
<a href="{{ route('graduated-students.index') }}" class="inline-flex items-center rounded-2xl border border-slate-200 px-5 py-3 text-sm font-semibold text-slate-700 transition hover:bg-slate-50">
|
||||
Kembali ke Data Siswa Lulus
|
||||
</a>
|
||||
</div>
|
||||
</form>
|
||||
</x-master-card>
|
||||
|
||||
@if ($preview)
|
||||
<x-master-card title="Preview Hasil Mapping" :subtitle="'Periksa hasil pencocokan file ' . $preview['document_label'] . ' sebelum diproses permanen.'">
|
||||
<div class="mb-6 grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-5">
|
||||
<div class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-4">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">Jenis Dokumen</div>
|
||||
<div class="mt-2 text-lg font-bold text-slate-900">{{ $preview['document_label'] }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-4">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">Pencocokan</div>
|
||||
<div class="mt-2 text-lg font-bold text-slate-900">{{ $preview['match_by_label'] }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-4">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">Total File</div>
|
||||
<div class="mt-2 text-lg font-bold text-slate-900">{{ $preview['summary']['total_files'] }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-4">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.16em] text-emerald-700">Cocok</div>
|
||||
<div class="mt-2 text-lg font-bold text-emerald-800">{{ $preview['summary']['matched'] }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-amber-200 bg-amber-50 px-4 py-4">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.16em] text-amber-700">Akan Replace</div>
|
||||
<div class="mt-2 text-lg font-bold text-amber-800">{{ $preview['summary']['will_replace'] }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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-slate-500">
|
||||
<tr>
|
||||
<th class="px-4 py-3 font-semibold">Nama File</th>
|
||||
<th class="px-4 py-3 font-semibold">Key Terdeteksi</th>
|
||||
<th class="px-4 py-3 font-semibold">Siswa Lulus</th>
|
||||
<th class="px-4 py-3 font-semibold">Status</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-100 bg-white">
|
||||
@foreach ($preview['rows'] as $row)
|
||||
<tr>
|
||||
<td class="px-4 py-3 text-slate-700">{{ $row['original_name'] }}</td>
|
||||
<td class="px-4 py-3 text-slate-600">{{ $row['match_key'] ?: '-' }}</td>
|
||||
<td class="px-4 py-3 text-slate-700">
|
||||
@if ($row['graduation_id'])
|
||||
<div class="font-semibold text-slate-900">{{ $row['student_name'] }}</div>
|
||||
<div class="text-xs text-slate-500">{{ $preview['match_by_label'] }}: {{ $row['identifier_value'] ?: '-' }}</div>
|
||||
@else
|
||||
<span class="text-slate-400">Tidak ditemukan</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-4 py-3">
|
||||
@if ($row['status'] === 'matched')
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<span class="inline-flex rounded-full bg-emerald-100 px-3 py-1 text-xs font-semibold text-emerald-700">Siap Diproses</span>
|
||||
@if ($row['will_replace'])
|
||||
<span class="inline-flex rounded-full bg-amber-100 px-3 py-1 text-xs font-semibold text-amber-700">Replace Dokumen Lama</span>
|
||||
@endif
|
||||
</div>
|
||||
@else
|
||||
<span class="inline-flex rounded-full bg-rose-100 px-3 py-1 text-xs font-semibold text-rose-700">Tidak Cocok</span>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@endforeach
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<form method="POST" action="{{ route('graduated-students.bulk-upload.store') }}" class="mt-6 flex flex-wrap items-center gap-3">
|
||||
@csrf
|
||||
<input type="hidden" name="preview_token" value="{{ $preview['token'] }}">
|
||||
<button type="submit" class="inline-flex items-center rounded-2xl bg-emerald-600 px-5 py-3 text-sm font-semibold text-white shadow-lg shadow-emerald-200 transition hover:bg-emerald-700">
|
||||
Proses Bulk Upload
|
||||
</button>
|
||||
</form>
|
||||
</x-master-card>
|
||||
@endif
|
||||
</div>
|
||||
</x-master-page>
|
||||
@@ -0,0 +1,169 @@
|
||||
<x-master-page title="Data Siswa Lulus" description="Arsip siswa yang sudah dinyatakan lulus beserta kelengkapan dokumen kelulusan.">
|
||||
@php
|
||||
$indexRoute = route('graduated-students.index');
|
||||
|
||||
$sortUrl = function (string $column) use ($sort, $direction, $indexRoute) {
|
||||
$nextDirection = $sort === $column && $direction === 'asc' ? 'desc' : 'asc';
|
||||
return $indexRoute . '?' . http_build_query(array_merge(request()->query(), ['sort' => $column, 'direction' => $nextDirection]));
|
||||
};
|
||||
|
||||
$sortIcon = function (string $column) use ($sort, $direction) {
|
||||
if ($sort !== $column) {
|
||||
return '↕';
|
||||
}
|
||||
|
||||
return $direction === 'asc' ? '↑' : '↓';
|
||||
};
|
||||
@endphp
|
||||
|
||||
<div class="grid grid-cols-1 gap-4 xl:grid-cols-3">
|
||||
<div class="xl:col-span-2 rounded-[28px] border border-sky-200 bg-gradient-to-br from-sky-50 via-white to-indigo-50 px-6 py-6 shadow-sm">
|
||||
<div class="flex flex-col gap-4 lg:flex-row lg:items-start lg:justify-between">
|
||||
<div>
|
||||
<div class="inline-flex items-center rounded-full bg-sky-100 px-3 py-1 text-xs font-semibold uppercase tracking-[0.18em] text-sky-700">
|
||||
Arsip Kelulusan
|
||||
</div>
|
||||
<h2 class="mt-4 text-2xl font-bold text-slate-800">Data Siswa Lulus</h2>
|
||||
<p class="mt-2 max-w-2xl text-sm leading-6 text-slate-600">
|
||||
Modul arsip khusus lulusan untuk menelusuri identitas akhir siswa, akademik terakhir, tanggal kelulusan, serta kelengkapan dokumen SKL dan ijazah.
|
||||
</p>
|
||||
</div>
|
||||
<div class="rounded-3xl border border-white/70 bg-white/80 px-5 py-4 text-right shadow-sm backdrop-blur">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-500">Total Lulusan</div>
|
||||
<div class="mt-2 text-4xl font-bold text-sky-700">{{ $summary['total'] ?? $graduations->total() }}</div>
|
||||
<div class="mt-1 text-xs text-slate-500">Arsip siswa lulus</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rounded-[28px] border border-emerald-200 bg-white px-6 py-6 shadow-sm">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-emerald-600">Kelengkapan Dokumen</div>
|
||||
<div class="mt-4 space-y-3">
|
||||
<div class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3">
|
||||
<div class="text-sm font-semibold text-slate-800">SKL tersedia</div>
|
||||
<div class="mt-1 text-xs text-slate-500">{{ $summary['with_skl'] ?? 0 }} arsip</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3">
|
||||
<div class="text-sm font-semibold text-slate-800">Ijazah tersedia</div>
|
||||
<div class="mt-1 text-xs text-slate-500">{{ $summary['with_ijazah'] ?? 0 }} arsip</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<x-master-card title="Filter Arsip Kelulusan" subtitle="Cari lulusan berdasarkan nama, identitas siswa, jurusan, kelas terakhir, dan tahun ajaran.">
|
||||
<form method="GET" action="{{ $indexRoute }}" class="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-4">
|
||||
<x-form-input name="search" label="Pencarian" :value="$search" placeholder="Nama / NIS / NISN" />
|
||||
<x-form-select name="academic_year_id" label="Tahun Ajaran" :options="$academicYears->all()" :value="$filters['academic_year_id']" />
|
||||
<x-form-select name="department_id" label="Program Keahlian" :options="$departments->all()" :value="$filters['department_id']" />
|
||||
<x-form-select name="class_id" label="Kelas Terakhir" :options="$classes->all()" :value="$filters['class_id']" />
|
||||
|
||||
<input type="hidden" name="sort" value="{{ $sort }}">
|
||||
<input type="hidden" name="direction" value="{{ $direction }}">
|
||||
|
||||
<div class="flex items-end gap-3 md:col-span-2 xl:col-span-4">
|
||||
<button type="submit" class="rounded-2xl bg-sky-600 px-5 py-3 text-sm font-semibold text-white transition hover:bg-sky-700">Terapkan Filter</button>
|
||||
<a href="{{ $indexRoute }}" class="rounded-2xl border border-slate-200 px-5 py-3 text-sm font-semibold text-slate-700 transition hover:bg-slate-50">Reset</a>
|
||||
</div>
|
||||
</form>
|
||||
</x-master-card>
|
||||
|
||||
<div class="rounded-[28px] border border-slate-200 bg-white shadow-sm shadow-slate-200/50">
|
||||
<div class="flex flex-col gap-3 border-b border-slate-200 px-6 py-5 lg:flex-row lg:items-center lg:justify-between">
|
||||
<div>
|
||||
<div class="text-lg font-semibold text-slate-800">Daftar Arsip Siswa Lulus</div>
|
||||
<div class="mt-1 text-sm text-slate-500">Fokus pada identitas lulusan, akademik terakhir, tanggal lulus, dan dokumen kelulusan.</div>
|
||||
</div>
|
||||
<div class="flex flex-col items-start gap-3 lg:items-end">
|
||||
<a href="{{ route('graduated-students.bulk-upload.index') }}" class="inline-flex items-center rounded-2xl bg-indigo-600 px-4 py-2.5 text-sm font-semibold text-white shadow-lg shadow-indigo-200 transition hover:bg-indigo-700">Bulk Upload SKL / Ijazah</a>
|
||||
<div class="text-sm text-slate-500">
|
||||
Menampilkan <span class="font-semibold text-slate-800">{{ $graduations->firstItem() ?? 0 }}</span> sampai <span class="font-semibold text-slate-800">{{ $graduations->lastItem() ?? 0 }}</span> dari <span class="font-semibold text-slate-800">{{ $graduations->total() }}</span> arsip lulusan.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="overflow-x-auto">
|
||||
<table class="min-w-full divide-y divide-slate-200">
|
||||
<thead class="bg-slate-50">
|
||||
<tr>
|
||||
<th class="px-6 py-4 text-left text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">
|
||||
<a href="{{ $sortUrl('full_name') }}" class="inline-flex items-center gap-2 hover:text-slate-700">Lulusan <span>{{ $sortIcon('full_name') }}</span></a>
|
||||
</th>
|
||||
<th class="px-6 py-4 text-left text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">
|
||||
<a href="{{ $sortUrl('academic_year') }}" class="inline-flex items-center gap-2 hover:text-slate-700">Akademik Terakhir <span>{{ $sortIcon('academic_year') }}</span></a>
|
||||
</th>
|
||||
<th class="px-6 py-4 text-left text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">
|
||||
<a href="{{ $sortUrl('graduation_date') }}" class="inline-flex items-center gap-2 hover:text-slate-700">Kelulusan <span>{{ $sortIcon('graduation_date') }}</span></a>
|
||||
</th>
|
||||
<th class="px-6 py-4 text-left text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">Dokumen</th>
|
||||
<th class="px-6 py-4 text-left text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-100 bg-white">
|
||||
@forelse ($graduations as $graduation)
|
||||
<tr class="hover:bg-sky-50/40">
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex items-start gap-3">
|
||||
<div class="flex h-11 w-11 shrink-0 items-center justify-center rounded-2xl bg-sky-100 text-sm font-bold text-sky-700">
|
||||
{{ strtoupper(mb_substr($graduation->full_name, 0, 1)) }}
|
||||
</div>
|
||||
<div>
|
||||
<div class="font-semibold text-slate-800">{{ $graduation->full_name }}</div>
|
||||
<div class="mt-1 text-xs text-slate-500">NIS: {{ $graduation->student_number ?: '-' }} · NISN: {{ $graduation->nisn ?: '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-slate-600">
|
||||
<div class="font-medium text-slate-700">{{ $graduation->academicYear?->name ?: '-' }}</div>
|
||||
<div class="mt-1">{{ $graduation->department?->name ?: '-' }}</div>
|
||||
<div class="text-xs text-slate-500">Kelas terakhir: {{ $graduation->classRoom?->name ?: '-' }}</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-slate-600">
|
||||
<div class="inline-flex rounded-full bg-sky-100 px-3 py-1 text-xs font-semibold text-sky-700">Lulus</div>
|
||||
<div class="mt-2 text-xs text-slate-500">Tanggal lulus: {{ optional($graduation->graduation_date)->format('d-m-Y') ?: '-' }}</div>
|
||||
</td>
|
||||
<td class="px-6 py-4 text-sm text-slate-600">
|
||||
<div class="flex flex-col gap-2">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="inline-flex min-w-[88px] items-center justify-center rounded-full px-3 py-1 text-xs font-semibold {{ $graduation->skl_file_path ? 'bg-emerald-100 text-emerald-700' : 'bg-slate-100 text-slate-500' }}">SKL</span>
|
||||
@unless ($graduation->skl_file_path)
|
||||
<span class="text-xs text-slate-500">Belum ada</span>
|
||||
@endunless
|
||||
@if ($graduation->skl_file_path)
|
||||
<a href="{{ route('graduated-students.preview-document', [$graduation, 'skl']) }}" class="inline-flex items-center rounded-full border border-sky-200 bg-sky-50 px-3 py-1 text-xs font-semibold text-sky-700 transition hover:border-sky-300 hover:bg-sky-100 hover:text-sky-800">Preview</a>
|
||||
@endif
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<span class="inline-flex min-w-[88px] items-center justify-center rounded-full px-3 py-1 text-xs font-semibold {{ $graduation->ijazah_file_path ? 'bg-emerald-100 text-emerald-700' : 'bg-slate-100 text-slate-500' }}">Ijazah</span>
|
||||
@unless ($graduation->ijazah_file_path)
|
||||
<span class="text-xs text-slate-500">Belum ada</span>
|
||||
@endunless
|
||||
@if ($graduation->ijazah_file_path)
|
||||
<a href="{{ route('graduated-students.preview-document', [$graduation, 'ijazah']) }}" class="inline-flex items-center rounded-full border border-sky-200 bg-sky-50 px-3 py-1 text-xs font-semibold text-sky-700 transition hover:border-sky-300 hover:bg-sky-100 hover:text-sky-800">Preview</a>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="px-6 py-4">
|
||||
<a href="{{ route('graduated-students.show', $graduation) }}" class="rounded-xl border border-sky-200 px-3 py-2 text-xs font-semibold text-sky-700 transition hover:bg-sky-50">Detail Arsip</a>
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="5" class="px-6 py-12 text-center text-sm text-slate-500">Belum ada arsip siswa lulus.</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-3 rounded-2xl border border-slate-200 bg-white px-5 py-4 shadow-sm lg:flex-row lg:items-center lg:justify-between">
|
||||
<div class="text-sm text-slate-600">
|
||||
Arsip lulusan dipisahkan agar pengelolaan dokumen kelulusan lebih rapi dan tidak bercampur dengan data siswa aktif.
|
||||
</div>
|
||||
<div>
|
||||
{{ $graduations->onEachSide(1)->links() }}
|
||||
</div>
|
||||
</div>
|
||||
</x-master-page>
|
||||
@@ -0,0 +1,43 @@
|
||||
<x-master-page :title="'Preview Dokumen ' . $documentLabel" description="Lihat dokumen siswa lulus langsung di browser bila format mendukung.">
|
||||
<div class="grid grid-cols-1 gap-6 xl:grid-cols-3">
|
||||
<x-master-card :title="'Informasi ' . $documentLabel" subtitle="Metadata dokumen siswa lulus.">
|
||||
<div class="space-y-4 text-sm text-slate-600">
|
||||
<div><span class="font-semibold text-slate-800">Nama Siswa:</span> {{ $graduation->full_name }}</div>
|
||||
<div><span class="font-semibold text-slate-800">Jenis Dokumen:</span> {{ $documentLabel }}</div>
|
||||
<div><span class="font-semibold text-slate-800">Nama File:</span> {{ $fileName ?: '-' }}</div>
|
||||
<div><span class="font-semibold text-slate-800">Tipe MIME:</span> {{ $mimeType ?: '-' }}</div>
|
||||
<div><span class="font-semibold text-slate-800">Ukuran:</span> {{ ($documentType === 'skl' ? $graduation->skl_file_size : $graduation->ijazah_file_size) ? number_format((($documentType === 'skl' ? $graduation->skl_file_size : $graduation->ijazah_file_size) / 1024), 1) . ' KB' : '-' }}</div>
|
||||
<div><span class="font-semibold text-slate-800">Tanggal Lulus:</span> {{ $graduation->graduation_date?->format('d-m-Y') ?: '-' }}</div>
|
||||
@if ($graduation->graduation_note)
|
||||
<div class="rounded-2xl bg-slate-50 px-4 py-3 text-xs text-slate-500">
|
||||
<span class="font-semibold text-slate-700">Catatan Kelulusan:</span> {{ $graduation->graduation_note }}
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="mt-6 flex flex-wrap gap-3">
|
||||
<a href="{{ $fileUrl }}" target="_blank" rel="noopener noreferrer" class="rounded-2xl bg-sky-600 px-4 py-3 text-sm font-semibold text-white transition hover:bg-sky-700">Buka File Asli</a>
|
||||
<a href="{{ route('graduated-students.index') }}" class="rounded-2xl border border-slate-200 px-4 py-3 text-sm font-semibold text-slate-700 transition hover:bg-slate-50">Kembali ke Arsip</a>
|
||||
</div>
|
||||
</x-master-card>
|
||||
|
||||
<div class="xl:col-span-2">
|
||||
<x-master-card :title="'Tampilan ' . $documentLabel" subtitle="Preview langsung untuk gambar dan PDF.">
|
||||
@if ($isImage)
|
||||
<div class="overflow-hidden rounded-2xl border border-slate-200 bg-slate-50 p-4">
|
||||
<img src="{{ $fileUrl }}" alt="{{ $fileName ?: $documentLabel }}" class="mx-auto max-h-[70vh] rounded-xl object-contain shadow-sm">
|
||||
</div>
|
||||
@elseif ($isPdf)
|
||||
<div class="overflow-hidden rounded-2xl border border-slate-200 bg-slate-50">
|
||||
<iframe src="{{ $fileUrl }}" class="h-[75vh] w-full rounded-2xl" title="Preview {{ $documentLabel }}"></iframe>
|
||||
</div>
|
||||
@else
|
||||
<div class="rounded-2xl border border-dashed border-slate-300 bg-slate-50 p-10 text-center">
|
||||
<div class="text-lg font-semibold text-slate-800">Preview tidak tersedia</div>
|
||||
<p class="mt-2 text-sm text-slate-500">Format file ini belum didukung untuk preview langsung di browser. Silakan gunakan tombol buka file asli.</p>
|
||||
</div>
|
||||
@endif
|
||||
</x-master-card>
|
||||
</div>
|
||||
</div>
|
||||
</x-master-page>
|
||||
@@ -0,0 +1,98 @@
|
||||
<x-master-page title="Detail Arsip Siswa Lulus" description="Lihat ringkasan arsip lulusan dan kelola dokumen SKL maupun ijazah tanpa bercampur dengan siswa aktif.">
|
||||
<div class="grid grid-cols-1 gap-6 xl:grid-cols-3">
|
||||
<div class="xl:col-span-2 space-y-6">
|
||||
<x-master-card title="Identitas Siswa" subtitle="Snapshot data terakhir saat siswa dipindahkan ke arsip lulusan.">
|
||||
<div class="grid grid-cols-1 gap-5 md:grid-cols-2">
|
||||
<div>
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">Nama Lengkap</div>
|
||||
<div class="mt-1 text-sm font-semibold text-slate-900">{{ $graduation->full_name }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">Status Arsip</div>
|
||||
<div class="mt-1"><span class="inline-flex rounded-full bg-sky-100 px-3 py-1 text-xs font-semibold text-sky-700">Siswa Lulus</span></div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">NIS</div>
|
||||
<div class="mt-1 text-sm text-slate-700">{{ $graduation->student_number ?: '-' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">NISN</div>
|
||||
<div class="mt-1 text-sm text-slate-700">{{ $graduation->nisn ?: '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</x-master-card>
|
||||
|
||||
<x-master-card title="Akademik Terakhir" subtitle="Data akademik terakhir sebelum siswa dinyatakan lulus.">
|
||||
<div class="grid grid-cols-1 gap-5 md:grid-cols-2 xl:grid-cols-4">
|
||||
<div>
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">Tahun Angkatan</div>
|
||||
<div class="mt-1 text-sm text-slate-700">{{ $graduation->academicYear?->name ?: '-' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">Program Keahlian</div>
|
||||
<div class="mt-1 text-sm text-slate-700">{{ $graduation->department?->name ?: '-' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">Kelas Terakhir</div>
|
||||
<div class="mt-1 text-sm text-slate-700">{{ $graduation->classRoom?->name ?: '-' }}</div>
|
||||
</div>
|
||||
<div>
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">Tanggal Masuk</div>
|
||||
<div class="mt-1 text-sm text-slate-700">{{ $graduation->entry_date?->format('d-m-Y') ?: '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</x-master-card>
|
||||
</div>
|
||||
|
||||
<div class="space-y-6">
|
||||
<x-master-card title="Dokumen Kelulusan" subtitle="Upload atau ganti SKL dan ijazah langsung dari modul arsip lulusan.">
|
||||
<div class="mb-4">
|
||||
<a href="{{ route('graduated-students.bulk-upload.index') }}" class="inline-flex items-center rounded-2xl border border-indigo-200 bg-indigo-50 px-4 py-2.5 text-sm font-semibold text-indigo-700 transition hover:bg-indigo-100">
|
||||
Bulk Upload SKL / Ijazah
|
||||
</a>
|
||||
</div>
|
||||
<div class="space-y-4">
|
||||
<div class="rounded-2xl border {{ $graduation->skl_file_path ? 'border-emerald-200 bg-emerald-50' : 'border-amber-200 bg-amber-50' }} px-4 py-4">
|
||||
<div class="text-sm font-semibold {{ $graduation->skl_file_path ? 'text-emerald-700' : 'text-amber-700' }}">SKL {{ $graduation->skl_file_path ? 'sudah tersedia' : 'belum diupload' }}</div>
|
||||
@if ($graduation->skl_file_name)
|
||||
<div class="mt-1 text-xs {{ $graduation->skl_file_path ? 'text-emerald-600' : 'text-amber-600' }}">{{ $graduation->skl_file_name }}</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border {{ $graduation->ijazah_file_path ? 'border-emerald-200 bg-emerald-50' : 'border-amber-200 bg-amber-50' }} px-4 py-4">
|
||||
<div class="text-sm font-semibold {{ $graduation->ijazah_file_path ? 'text-emerald-700' : 'text-amber-700' }}">Ijazah {{ $graduation->ijazah_file_path ? 'sudah tersedia' : 'belum diupload' }}</div>
|
||||
@if ($graduation->ijazah_file_name)
|
||||
<div class="mt-1 text-xs {{ $graduation->ijazah_file_path ? 'text-emerald-600' : 'text-amber-600' }}">{{ $graduation->ijazah_file_name }}</div>
|
||||
@endif
|
||||
</div>
|
||||
|
||||
<form method="POST" action="{{ route('graduated-students.update', $graduation) }}" enctype="multipart/form-data" class="space-y-4">
|
||||
@csrf
|
||||
@method('PATCH')
|
||||
|
||||
<x-form-input name="graduation_date" label="Tanggal Lulus" type="date" :value="optional($graduation->graduation_date)->format('Y-m-d')" />
|
||||
<x-form-textarea name="graduation_note" label="Catatan Kelulusan" :value="$graduation->graduation_note" rows="4" placeholder="Masukkan catatan tambahan bila perlu" />
|
||||
|
||||
<div>
|
||||
<label for="skl_file" class="mb-2 block text-sm font-medium text-slate-700">Upload / Ganti SKL</label>
|
||||
<input id="skl_file" name="skl_file" type="file" accept=".pdf,.jpg,.jpeg,.png" class="block w-full rounded-2xl border border-slate-200 bg-white px-4 py-3 text-sm text-slate-700 file:mr-4 file:rounded-xl file:border-0 file:bg-slate-100 file:px-4 file:py-2 file:text-sm file:font-semibold file:text-slate-700 hover:file:bg-slate-200">
|
||||
<p class="mt-2 text-xs text-slate-500">Format: PDF, JPG, JPEG, PNG. Maksimal 4 MB.</p>
|
||||
<x-input-error :messages="$errors->get('skl_file')" class="mt-2" />
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="ijazah_file" class="mb-2 block text-sm font-medium text-slate-700">Upload / Ganti Ijazah</label>
|
||||
<input id="ijazah_file" name="ijazah_file" type="file" accept=".pdf,.jpg,.jpeg,.png" class="block w-full rounded-2xl border border-slate-200 bg-white px-4 py-3 text-sm text-slate-700 file:mr-4 file:rounded-xl file:border-0 file:bg-slate-100 file:px-4 file:py-2 file:text-sm file:font-semibold file:text-slate-700 hover:file:bg-slate-200">
|
||||
<p class="mt-2 text-xs text-slate-500">Format: PDF, JPG, JPEG, PNG. Maksimal 4 MB.</p>
|
||||
<x-input-error :messages="$errors->get('ijazah_file')" class="mt-2" />
|
||||
</div>
|
||||
|
||||
<button type="submit" class="inline-flex items-center rounded-2xl bg-indigo-600 px-5 py-3 text-sm font-semibold text-white shadow-lg shadow-indigo-200 transition hover:bg-indigo-700">
|
||||
Simpan Arsip Kelulusan
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</x-master-card>
|
||||
</div>
|
||||
</div>
|
||||
</x-master-page>
|
||||
@@ -171,14 +171,6 @@
|
||||
</svg>
|
||||
<span>Data Siswa Mutasi</span>
|
||||
</a>
|
||||
<a href="{{ route('students.graduated') }}"
|
||||
class="flex items-center gap-3 rounded-xl px-4 py-3 text-sm font-medium transition {{ request()->routeIs('students.graduated') ? 'bg-indigo-50 text-indigo-700' : 'text-slate-500 hover:bg-slate-100 hover:text-slate-900' }}">
|
||||
<svg class="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8" d="M3 9.5 12 5l9 4.5-9 4.5-9-4.5Z" />
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8" d="M7 12.5v3.5c0 .8 2.2 2.5 5 2.5s5-1.7 5-2.5v-3.5" />
|
||||
</svg>
|
||||
<span>Data Siswa Lulus</span>
|
||||
</a>
|
||||
<a href="{{ route('student-achievements.index') }}"
|
||||
class="flex items-center gap-3 rounded-xl px-4 py-3 text-sm font-medium transition {{ request()->routeIs('student-achievements.*') ? 'bg-indigo-50 text-indigo-700' : 'text-slate-500 hover:bg-slate-100 hover:text-slate-900' }}">
|
||||
<svg class="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||
@@ -203,6 +195,14 @@
|
||||
</svg>
|
||||
<span>Self Servis Siswa</span>
|
||||
</a>
|
||||
<a href="{{ route('graduated-students.index') }}"
|
||||
class="flex items-center gap-3 rounded-xl px-4 py-3 text-sm font-medium transition {{ request()->routeIs('graduated-students.*') ? 'bg-indigo-50 text-indigo-700' : 'text-slate-500 hover:bg-slate-100 hover:text-slate-900' }}">
|
||||
<svg class="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8" d="M3 9.5 12 5l9 4.5-9 4.5-9-4.5Z" />
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8" d="M7 12.5v3.5c0 .8 2.2 2.5 5 2.5s5-1.7 5-2.5v-3.5" />
|
||||
</svg>
|
||||
<span>Data Siswa Lulus</span>
|
||||
</a>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
@@ -244,6 +244,14 @@
|
||||
</svg>
|
||||
<span>Branding Aplikasi</span>
|
||||
</a>
|
||||
<a href="{{ route('settings.sync-tokens.index') }}"
|
||||
class="flex items-center gap-3 rounded-xl px-4 py-3 text-sm font-medium transition {{ request()->routeIs('settings.sync-tokens.*') ? 'bg-emerald-50 text-emerald-700' : 'text-slate-500 hover:bg-slate-100 hover:text-slate-900' }}">
|
||||
<svg class="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8" d="M9 12l2 2 4-4" />
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="1.8" d="M20 12A8 8 0 1 1 4 12a8 8 0 0 1 16 0Z" />
|
||||
</svg>
|
||||
<span>Sinkron Database</span>
|
||||
</a>
|
||||
<a href="{{ route('settings.reset-data.index') }}"
|
||||
class="flex items-center gap-3 rounded-xl px-4 py-3 text-sm font-medium transition {{ request()->routeIs('settings.reset-data.*') ? 'bg-rose-50 text-rose-700' : 'text-slate-500 hover:bg-rose-50 hover:text-rose-700' }}">
|
||||
<svg class="h-4 w-4" viewBox="0 0 24 24" fill="none" stroke="currentColor">
|
||||
|
||||
@@ -140,6 +140,93 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
@if ($student->status === 'graduated')
|
||||
<div class="overflow-hidden rounded-3xl border border-sky-200 bg-white shadow-sm shadow-sky-100/60">
|
||||
<div class="border-b border-sky-100 bg-gradient-to-r from-sky-50 via-white to-indigo-50 px-5 py-6 sm:px-6">
|
||||
<div class="grid gap-4 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-start">
|
||||
<div class="min-w-0">
|
||||
<div class="inline-flex items-center rounded-full bg-sky-100 px-3 py-1 text-[11px] font-semibold uppercase tracking-[0.16em] text-sky-700">
|
||||
Siswa Lulus Ditemukan
|
||||
</div>
|
||||
<h2 class="mt-3 text-2xl font-bold tracking-tight text-slate-900 sm:text-3xl">{{ $student->full_name }}</h2>
|
||||
<p class="mt-2 max-w-2xl text-sm leading-6 text-slate-500">
|
||||
Data cocok berdasarkan {{ strtolower($matchedBy ?? 'data siswa') }}. Untuk siswa lulusan, portal publik difokuskan pada layanan dokumen kelulusan tanpa menampilkan detail biodata panjang.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-3 sm:grid-cols-2 lg:min-w-[320px]">
|
||||
<div class="rounded-2xl border border-sky-100 bg-white px-4 py-4 text-center shadow-sm shadow-sky-100/40">
|
||||
<div class="text-[11px] font-semibold uppercase tracking-[0.16em] text-sky-600">Status</div>
|
||||
<div class="mt-2 text-2xl font-bold text-slate-900 sm:text-3xl">Lulus</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-emerald-100 bg-white px-4 py-4 text-center shadow-sm shadow-emerald-100/40">
|
||||
<div class="text-[11px] font-semibold uppercase tracking-[0.16em] text-emerald-600">Dokumen</div>
|
||||
<div class="mt-2 text-sm font-bold text-slate-900 sm:text-base">SKL & Ijazah</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-4 px-5 py-5 sm:px-6">
|
||||
<div class="grid gap-3 sm:grid-cols-2 xl:grid-cols-4">
|
||||
<div class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3">
|
||||
<div class="text-[11px] font-semibold uppercase tracking-[0.16em] text-slate-400">NIS</div>
|
||||
<div class="mt-1 text-sm font-semibold text-slate-800">{{ $student->student_number ?: '-' }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3">
|
||||
<div class="text-[11px] font-semibold uppercase tracking-[0.16em] text-slate-400">NISN</div>
|
||||
<div class="mt-1 text-sm font-semibold text-slate-800">{{ $student->nisn ?: '-' }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3">
|
||||
<div class="text-[11px] font-semibold uppercase tracking-[0.16em] text-slate-400">Program</div>
|
||||
<div class="mt-1 text-sm font-semibold text-slate-800">{{ $student->department?->name ?: '-' }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3">
|
||||
<div class="text-[11px] font-semibold uppercase tracking-[0.16em] text-slate-400">Kelas Terakhir</div>
|
||||
<div class="mt-1 text-sm font-semibold text-slate-800">{{ $student->classRoom?->name ?: '-' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rounded-3xl border border-sky-200 bg-white p-5 shadow-sm shadow-sky-100/50 sm:p-6">
|
||||
<div class="flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between">
|
||||
<div>
|
||||
<h3 class="text-base font-semibold text-slate-900">Layanan Dokumen Kelulusan</h3>
|
||||
<p class="mt-1 text-sm text-slate-500">Unduh SKL atau ijazah jika dokumen sudah tersedia di arsip sekolah.</p>
|
||||
</div>
|
||||
<div class="rounded-full bg-sky-100 px-4 py-2 text-xs font-semibold uppercase tracking-[0.14em] text-sky-700">
|
||||
To The Point
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-5 grid gap-4 md:grid-cols-2">
|
||||
<div class="rounded-2xl border {{ $student->public_graduation_record?->skl_file_path ? 'border-emerald-200 bg-emerald-50' : 'border-slate-200 bg-slate-50' }} px-4 py-4 text-sm">
|
||||
<div class="font-semibold {{ $student->public_graduation_record?->skl_file_path ? 'text-emerald-700' : 'text-slate-700' }}">SKL</div>
|
||||
<div class="mt-1 text-xs {{ $student->public_graduation_record?->skl_file_path ? 'text-emerald-600' : 'text-slate-500' }}">{{ $student->public_graduation_record?->skl_file_name ?: 'Dokumen belum tersedia' }}</div>
|
||||
<div class="mt-4">
|
||||
@if ($student->public_graduation_record?->skl_file_path)
|
||||
<a href="{{ route('public.students.graduation-documents.download', [$student, 'skl']) }}" class="inline-flex items-center rounded-2xl bg-sky-600 px-4 py-2.5 text-xs font-semibold text-white transition hover:bg-sky-700">Download SKL</a>
|
||||
@else
|
||||
<span class="inline-flex items-center rounded-2xl border border-slate-200 px-4 py-2.5 text-xs font-semibold text-slate-400">Belum tersedia</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="rounded-2xl border {{ $student->public_graduation_record?->ijazah_file_path ? 'border-emerald-200 bg-emerald-50' : 'border-slate-200 bg-slate-50' }} px-4 py-4 text-sm">
|
||||
<div class="font-semibold {{ $student->public_graduation_record?->ijazah_file_path ? 'text-emerald-700' : 'text-slate-700' }}">Ijazah</div>
|
||||
<div class="mt-1 text-xs {{ $student->public_graduation_record?->ijazah_file_path ? 'text-emerald-600' : 'text-slate-500' }}">{{ $student->public_graduation_record?->ijazah_file_name ?: 'Dokumen belum tersedia' }}</div>
|
||||
<div class="mt-4">
|
||||
@if ($student->public_graduation_record?->ijazah_file_path)
|
||||
<a href="{{ route('public.students.graduation-documents.download', [$student, 'ijazah']) }}" class="inline-flex items-center rounded-2xl bg-sky-600 px-4 py-2.5 text-xs font-semibold text-white transition hover:bg-sky-700">Download Ijazah</a>
|
||||
@else
|
||||
<span class="inline-flex items-center rounded-2xl border border-slate-200 px-4 py-2.5 text-xs font-semibold text-slate-400">Belum tersedia</span>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@else
|
||||
<div class="overflow-hidden rounded-3xl border border-emerald-200 bg-white shadow-sm shadow-emerald-100/60">
|
||||
<div class="border-b border-emerald-100 bg-gradient-to-r from-emerald-50 via-white to-sky-50 px-5 py-5 sm:px-6">
|
||||
<div class="grid gap-4 lg:grid-cols-[minmax(0,1fr)_auto] lg:items-start">
|
||||
@@ -392,6 +479,7 @@
|
||||
@endforelse
|
||||
</div>
|
||||
</div>
|
||||
@endif
|
||||
</div>
|
||||
@else
|
||||
<div class="overflow-hidden rounded-3xl border border-amber-200 bg-white shadow-sm shadow-amber-100/60">
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
<x-master-page title="Sinkron Database" description="Kelola token integrasi read-only untuk aplikasi eksternal seperti aplikasi ujian.">
|
||||
<div class="space-y-6">
|
||||
<x-master-card title="Generate Token Sinkronisasi" subtitle="Token ini nantinya dipakai aplikasi ujian untuk mengambil data akademik secara aman tanpa membuka akses database langsung.">
|
||||
@if ($plainToken)
|
||||
<div class="mb-6 rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-4 text-sm text-emerald-700">
|
||||
<p class="font-semibold">Token baru berhasil dibuat.</p>
|
||||
<p class="mt-1">Salin sekarang dan simpan baik-baik. Token plain hanya ditampilkan sekali.</p>
|
||||
<div class="mt-3 rounded-xl border border-emerald-200 bg-white px-4 py-3 font-mono text-xs text-slate-700 break-all">{{ $plainToken }}</div>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<form method="POST" action="{{ route('settings.sync-tokens.store') }}" class="space-y-6">
|
||||
@csrf
|
||||
|
||||
<div class="grid grid-cols-1 gap-6 lg:grid-cols-2">
|
||||
<div>
|
||||
<label for="name" class="mb-2 block text-sm font-medium text-slate-700">Nama Token</label>
|
||||
<input id="name" name="name" type="text" value="{{ old('name') }}" class="h-12 w-full rounded-2xl border border-slate-200 bg-white px-4 text-sm text-slate-700 focus:border-indigo-300 focus:outline-none focus:ring-4 focus:ring-indigo-100" placeholder="Contoh: Sinkron Aplikasi Ujian" required>
|
||||
<x-input-error :messages="$errors->get('name')" class="mt-2" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<p class="mb-3 text-sm font-medium text-slate-700">Hak Akses Data</p>
|
||||
<div class="grid grid-cols-1 gap-3 sm:grid-cols-2 xl:grid-cols-4">
|
||||
@foreach ([
|
||||
'academic_years' => 'Tahun Ajaran',
|
||||
'departments' => 'Jurusan',
|
||||
'classes' => 'Kelas',
|
||||
'students' => 'Siswa',
|
||||
] as $value => $label)
|
||||
<label class="flex items-center gap-3 rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm text-slate-700">
|
||||
<input type="checkbox" name="abilities[]" value="{{ $value }}" class="rounded border-slate-300 text-indigo-600 focus:ring-indigo-500" @checked(collect(old('abilities', ['academic_years', 'departments', 'classes', 'students']))->contains($value))>
|
||||
<span>{{ $label }}</span>
|
||||
</label>
|
||||
@endforeach
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<button type="submit" class="inline-flex items-center rounded-2xl bg-indigo-600 px-5 py-3 text-sm font-semibold text-white shadow-lg shadow-indigo-200 transition hover:bg-indigo-700">
|
||||
Generate Token
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</x-master-card>
|
||||
|
||||
<x-master-card title="Daftar Token Sinkronisasi" subtitle="Token yang sudah dibuat untuk integrasi eksternal. Token yang direvoke tidak boleh dipakai lagi.">
|
||||
<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-slate-500">
|
||||
<tr>
|
||||
<th class="px-4 py-3 font-semibold">Nama</th>
|
||||
<th class="px-4 py-3 font-semibold">Hak Akses</th>
|
||||
<th class="px-4 py-3 font-semibold">Dibuat Oleh</th>
|
||||
<th class="px-4 py-3 font-semibold">Terakhir Dipakai</th>
|
||||
<th class="px-4 py-3 font-semibold">Status</th>
|
||||
<th class="px-4 py-3 font-semibold text-right">Aksi</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="divide-y divide-slate-100 bg-white">
|
||||
@forelse ($tokens as $token)
|
||||
<tr>
|
||||
<td class="px-4 py-3 font-medium text-slate-900">{{ $token->name }}</td>
|
||||
<td class="px-4 py-3 text-slate-600">{{ collect($token->abilities ?? [])->join(', ') ?: '-' }}</td>
|
||||
<td class="px-4 py-3 text-slate-600">{{ $token->creator?->name ?? '-' }}</td>
|
||||
<td class="px-4 py-3 text-slate-600">{{ $token->last_used_at?->format('d M Y H:i') ?? 'Belum pernah' }}</td>
|
||||
<td class="px-4 py-3">
|
||||
@if ($token->revoked_at)
|
||||
<span class="inline-flex rounded-full bg-rose-100 px-3 py-1 text-xs font-semibold text-rose-700">Nonaktif</span>
|
||||
@else
|
||||
<span class="inline-flex rounded-full bg-emerald-100 px-3 py-1 text-xs font-semibold text-emerald-700">Aktif</span>
|
||||
@endif
|
||||
</td>
|
||||
<td class="px-4 py-3 text-right">
|
||||
@if (! $token->revoked_at)
|
||||
<form method="POST" action="{{ route('settings.sync-tokens.revoke', $token) }}" onsubmit="return confirm('Nonaktifkan token ini?')" class="inline-flex">
|
||||
@csrf
|
||||
@method('PATCH')
|
||||
<button type="submit" class="inline-flex items-center rounded-xl border border-rose-200 bg-rose-50 px-3 py-2 text-xs font-semibold text-rose-700 transition hover:bg-rose-100">
|
||||
Revoke
|
||||
</button>
|
||||
</form>
|
||||
@else
|
||||
<span class="text-xs text-slate-400">Sudah direvoke</span>
|
||||
@endif
|
||||
</td>
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="6" class="px-4 py-10 text-center text-slate-500">Belum ada token sinkronisasi.</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</x-master-card>
|
||||
</div>
|
||||
</x-master-page>
|
||||
@@ -1,6 +1,6 @@
|
||||
<x-master-page title="Kenaikan Kelas / Promosi Siswa" description="Proses semi otomatis untuk memindahkan siswa aktif ke kelas/tahun ajaran berikutnya.">
|
||||
<x-master-card title="Filter Promosi" subtitle="Pilih tahun ajaran asal dan tujuan untuk menyiapkan rekomendasi promosi.">
|
||||
<form method="GET" action="{{ route('student-promotions.index') }}" class="grid grid-cols-1 gap-4 lg:grid-cols-3 lg:items-end">
|
||||
<x-master-card title="Filter Promosi" subtitle="Pilih tahun ajaran, lalu fokuskan proses per kelas agar pengecualian siswa lebih mudah dikelola.">
|
||||
<form method="GET" action="{{ route('student-promotions.index') }}" class="grid grid-cols-1 gap-4 lg:grid-cols-4 lg:items-end">
|
||||
<div>
|
||||
<label for="from_academic_year_id" class="mb-2 block text-sm font-medium text-slate-700">Tahun Ajaran Asal</label>
|
||||
<select id="from_academic_year_id" name="from_academic_year_id" class="w-full rounded-2xl border border-slate-200 bg-white px-4 py-3 text-sm text-slate-700 focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-100">
|
||||
@@ -25,6 +25,18 @@
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="class_id" class="mb-2 block text-sm font-medium text-slate-700">Kelas Asal</label>
|
||||
<select id="class_id" name="class_id" class="w-full rounded-2xl border border-slate-200 bg-white px-4 py-3 text-sm text-slate-700 focus:border-indigo-300 focus:outline-none focus:ring-2 focus:ring-indigo-100">
|
||||
<option value="">Pilih kelas asal</option>
|
||||
@foreach ($availableClasses as $classRoom)
|
||||
<option value="{{ $classRoom->id }}" @selected((int) $filters['class_id'] === (int) $classRoom->id)>
|
||||
{{ $classRoom->name }} — {{ $classRoom->department?->name }} ({{ $classRoom->active_students_count }} siswa)
|
||||
</option>
|
||||
@endforeach
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<button type="submit" class="inline-flex w-full items-center justify-center rounded-2xl bg-indigo-600 px-5 py-3 text-sm font-semibold text-white shadow-lg shadow-indigo-200 transition hover:bg-indigo-700">
|
||||
Muat Rekomendasi
|
||||
@@ -33,18 +45,64 @@
|
||||
</form>
|
||||
</x-master-card>
|
||||
|
||||
<x-master-card title="Daftar Rekomendasi Promosi" subtitle="Sistem memberi saran berdasarkan level kelas saat ini. Admin tetap bisa menyesuaikan sebelum diproses.">
|
||||
<x-master-card title="Kenaikan Kelas per Rombel" subtitle="Mayoritas siswa biasanya mengikuti hasil kelasnya, lalu admin tinggal mengubah siswa pengecualian.">
|
||||
@if (blank($filters['from_academic_year_id']) || blank($filters['to_academic_year_id']))
|
||||
<div class="rounded-2xl border border-amber-200 bg-amber-50 px-5 py-4 text-sm text-amber-700">
|
||||
Pilih tahun ajaran asal dan tujuan terlebih dahulu untuk memuat rekomendasi promosi siswa.
|
||||
Pilih tahun ajaran asal dan tujuan terlebih dahulu untuk melihat kelas yang siap diproses.
|
||||
</div>
|
||||
@elseif ($classSummaries->isEmpty())
|
||||
<div class="rounded-2xl border border-slate-200 bg-slate-50 px-5 py-4 text-sm text-slate-500">
|
||||
Belum ada kelas aktif dengan siswa aktif pada tahun ajaran asal yang dipilih.
|
||||
</div>
|
||||
@elseif (blank($filters['class_id']) || ! $selectedClass)
|
||||
<div class="mb-6 rounded-2xl border border-indigo-200 bg-indigo-50 px-5 py-4 text-sm text-indigo-700">
|
||||
Pilih <span class="font-semibold">kelas asal</span> untuk memproses siswa per rombel. Ini lebih aman daripada menampilkan semua siswa sekaligus.
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-1 gap-4 xl:grid-cols-2">
|
||||
@foreach ($classSummaries as $summary)
|
||||
<a
|
||||
href="{{ route('student-promotions.index', ['from_academic_year_id' => $filters['from_academic_year_id'], 'to_academic_year_id' => $filters['to_academic_year_id'], 'class_id' => $summary->id]) }}"
|
||||
class="group rounded-3xl border border-slate-200 bg-white p-5 transition hover:border-indigo-200 hover:bg-indigo-50/40"
|
||||
>
|
||||
<div class="flex flex-wrap items-start justify-between gap-4">
|
||||
<div>
|
||||
<div class="text-lg font-semibold text-slate-800">{{ $summary->name }}</div>
|
||||
<div class="mt-1 text-sm text-slate-500">{{ $summary->department_name ?: '-' }} • Level {{ $summary->level }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl bg-slate-100 px-3 py-2 text-right">
|
||||
<div class="text-[11px] font-semibold uppercase tracking-[0.14em] text-slate-500">Siswa Aktif</div>
|
||||
<div class="mt-1 text-2xl font-bold text-slate-800">{{ $summary->active_students_count }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 grid grid-cols-1 gap-3 md:grid-cols-2">
|
||||
<div class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3">
|
||||
<div class="text-[11px] font-semibold uppercase tracking-[0.14em] text-slate-500">Rekomendasi Default</div>
|
||||
<div class="mt-1 font-semibold text-slate-800">{{ $summary->recommendation_label }}</div>
|
||||
</div>
|
||||
<div class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3">
|
||||
<div class="text-[11px] font-semibold uppercase tracking-[0.14em] text-slate-500">Target Umum</div>
|
||||
<div class="mt-1 font-semibold text-slate-800">{{ $summary->recommendation_target_name ?: 'Perlu cek setelah kelas dipilih' }}</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 inline-flex items-center text-sm font-semibold text-indigo-700 transition group-hover:translate-x-0.5">
|
||||
Proses kelas ini →
|
||||
</div>
|
||||
</a>
|
||||
@endforeach
|
||||
</div>
|
||||
@elseif ($students->isEmpty())
|
||||
<div class="text-sm text-slate-500">Tidak ada siswa aktif pada tahun ajaran asal yang dipilih.</div>
|
||||
<div class="rounded-2xl border border-slate-200 bg-slate-50 px-5 py-4 text-sm text-slate-500">
|
||||
Tidak ada siswa aktif pada kelas asal yang dipilih.
|
||||
</div>
|
||||
@else
|
||||
@php
|
||||
$promotionCount = $students->filter(fn ($student) => $student->promotion_recommendation['action'] === 'promote')->count();
|
||||
$repeatCount = $students->filter(fn ($student) => $student->promotion_recommendation['action'] === 'repeat')->count();
|
||||
$graduateCount = $students->filter(fn ($student) => $student->promotion_recommendation['action'] === 'graduate')->count();
|
||||
$skipCount = $students->filter(fn ($student) => $student->promotion_recommendation['action'] === 'skip')->count();
|
||||
@endphp
|
||||
|
||||
@if ($errors->any())
|
||||
@@ -58,36 +116,69 @@
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="mb-6 grid grid-cols-1 gap-4 md:grid-cols-3">
|
||||
<div class="rounded-3xl border border-emerald-200 bg-emerald-50 px-5 py-4">
|
||||
<div class="mb-6 rounded-3xl border border-slate-200 bg-slate-50 px-5 py-4">
|
||||
<div class="flex flex-wrap items-start justify-between gap-4">
|
||||
<div>
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-500">Kelas Sedang Diproses</div>
|
||||
<div class="mt-2 text-2xl font-bold text-slate-800">{{ $selectedClass->name }}</div>
|
||||
<div class="mt-1 text-sm text-slate-500">{{ $selectedClass->department?->name ?: '-' }} • {{ $selectedClass->active_students_count }} siswa aktif</div>
|
||||
</div>
|
||||
<a href="{{ route('student-promotions.index', ['from_academic_year_id' => $filters['from_academic_year_id'], 'to_academic_year_id' => $filters['to_academic_year_id']]) }}" class="inline-flex items-center rounded-2xl border border-slate-200 bg-white px-4 py-2 text-sm font-semibold text-slate-700 transition hover:bg-slate-100">
|
||||
Ganti Kelas
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-6 grid grid-cols-1 gap-4 md:grid-cols-4">
|
||||
<div class="rounded-3xl border border-emerald-200 bg-emerald-50 px-5 py-4" data-promotion-counter-card="promote">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-emerald-600">Naik Kelas</div>
|
||||
<div class="mt-2 text-3xl font-bold text-emerald-700">{{ $promotionCount }}</div>
|
||||
<div class="mt-1 text-sm text-emerald-600">Siswa direkomendasikan naik ke level berikutnya.</div>
|
||||
<div class="mt-2 text-3xl font-bold text-emerald-700" data-promotion-counter="promote">{{ $promotionCount }}</div>
|
||||
<div class="mt-1 text-sm text-emerald-600">Siswa yang akan naik ke level berikutnya.</div>
|
||||
</div>
|
||||
<div class="rounded-3xl border border-amber-200 bg-amber-50 px-5 py-4">
|
||||
<div class="rounded-3xl border border-amber-200 bg-amber-50 px-5 py-4" data-promotion-counter-card="repeat">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-amber-600">Tinggal Kelas</div>
|
||||
<div class="mt-2 text-3xl font-bold text-amber-700">{{ $repeatCount }}</div>
|
||||
<div class="mt-1 text-sm text-amber-600">Siswa akan tetap di level yang sama pada tahun ajaran baru.</div>
|
||||
<div class="mt-2 text-3xl font-bold text-amber-700" data-promotion-counter="repeat">{{ $repeatCount }}</div>
|
||||
<div class="mt-1 text-sm text-amber-600">Siswa yang akan tetap di level yang sama.</div>
|
||||
</div>
|
||||
<div class="rounded-3xl border border-sky-200 bg-sky-50 px-5 py-4">
|
||||
<div class="rounded-3xl border border-sky-200 bg-sky-50 px-5 py-4" data-promotion-counter-card="graduate">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-sky-600">Lulus</div>
|
||||
<div class="mt-2 text-3xl font-bold text-sky-700">{{ $graduateCount }}</div>
|
||||
<div class="mt-1 text-sm text-sky-600">Siswa kelas akhir yang direkomendasikan lulus.</div>
|
||||
<div class="mt-2 text-3xl font-bold text-sky-700" data-promotion-counter="graduate">{{ $graduateCount }}</div>
|
||||
<div class="mt-1 text-sm text-sky-600">Siswa kelas akhir yang akan diluluskan.</div>
|
||||
</div>
|
||||
<div class="rounded-3xl border border-slate-200 bg-slate-50 px-5 py-4" data-promotion-counter-card="skip">
|
||||
<div class="text-xs font-semibold uppercase tracking-[0.18em] text-slate-500">Lewati</div>
|
||||
<div class="mt-2 text-3xl font-bold text-slate-700" data-promotion-counter="skip">{{ $skipCount }}</div>
|
||||
<div class="mt-1 text-sm text-slate-500">Siswa yang tidak ikut diproses pada batch ini.</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mb-6 rounded-3xl border border-indigo-200 bg-indigo-50 px-5 py-4 text-sm text-indigo-700" data-promotion-live-summary>
|
||||
Ringkasan live: <span class="font-semibold">{{ $promotionCount }}</span> naik, <span class="font-semibold">{{ $repeatCount }}</span> tinggal kelas, <span class="font-semibold">{{ $graduateCount }}</span> lulus, dan <span class="font-semibold">{{ $skipCount }}</span> dilewati.
|
||||
</div>
|
||||
|
||||
<form method="POST" action="{{ route('student-promotions.store') }}" class="space-y-6" data-student-promotion-form>
|
||||
@csrf
|
||||
<input type="hidden" name="from_academic_year_id" value="{{ $filters['from_academic_year_id'] }}">
|
||||
<input type="hidden" name="to_academic_year_id" value="{{ $filters['to_academic_year_id'] }}">
|
||||
<input type="hidden" name="class_id" value="{{ $filters['class_id'] }}">
|
||||
|
||||
<div class="flex flex-wrap items-center gap-3 rounded-2xl border border-slate-200 bg-slate-50 px-5 py-4">
|
||||
<div class="text-sm font-medium text-slate-700">Aksi cepat:</div>
|
||||
<div class="flex flex-wrap items-center gap-3 rounded-2xl border border-slate-200 bg-slate-50 px-5 py-4" data-promotion-toolbar data-class-level="{{ strtoupper((string) $selectedClass->level) }}">
|
||||
<div class="text-sm font-medium text-slate-700">Aksi cepat untuk kelas ini:</div>
|
||||
<button type="button" class="rounded-xl border border-emerald-200 px-4 py-2 text-xs font-semibold text-emerald-700 transition hover:bg-emerald-50" data-promotion-bulk-action="promote">Set semua → Naik Kelas</button>
|
||||
<button type="button" class="rounded-xl border border-sky-200 px-4 py-2 text-xs font-semibold text-sky-700 transition hover:bg-sky-50" data-promotion-bulk-action="graduate">Set semua → Lulus</button>
|
||||
<button type="button" class="rounded-xl border border-amber-200 px-4 py-2 text-xs font-semibold text-amber-700 transition hover:bg-amber-50" data-promotion-bulk-action="repeat">Set semua → Tinggal Kelas</button>
|
||||
<button type="button" class="rounded-xl border border-slate-200 px-4 py-2 text-xs font-semibold text-slate-700 transition hover:bg-slate-100" data-promotion-bulk-action="skip">Set semua → Lewati</button>
|
||||
</div>
|
||||
|
||||
@if (strtoupper((string) $selectedClass->level) === 'XII')
|
||||
<div class="mt-4 rounded-2xl border border-sky-200 bg-sky-50 px-5 py-4 text-sm text-sky-700">
|
||||
Kelas ini berada di level <span class="font-semibold">XII</span>. Default operasionalnya biasanya <span class="font-semibold">Lulus</span>, lalu admin hanya mengubah siswa pengecualian bila perlu.
|
||||
</div>
|
||||
@endif
|
||||
|
||||
<div class="hidden rounded-3xl border px-5 py-4 text-sm" data-promotion-capacity-summary></div>
|
||||
<div class="hidden rounded-3xl border border-indigo-200 bg-indigo-50 px-5 py-4 text-sm text-indigo-700" data-promotion-final-preview></div>
|
||||
|
||||
<div class="overflow-x-auto rounded-3xl border border-slate-200">
|
||||
<table class="min-w-full divide-y divide-slate-200">
|
||||
<thead class="bg-slate-50">
|
||||
@@ -127,6 +218,7 @@
|
||||
'option_label' => $classRoom->option_label,
|
||||
'capacity_label' => $classRoom->capacity_label,
|
||||
'remaining_capacity' => $classRoom->remaining_capacity,
|
||||
'warning_level' => is_null($classRoom->remaining_capacity) ? 'normal' : ($classRoom->remaining_capacity <= 0 ? 'full' : ($classRoom->remaining_capacity <= 3 ? 'low' : 'normal')),
|
||||
])->values();
|
||||
$repeatClassOptions = $repeatClasses->map(fn ($classRoom) => [
|
||||
'id' => $classRoom->id,
|
||||
@@ -134,6 +226,7 @@
|
||||
'option_label' => $classRoom->option_label,
|
||||
'capacity_label' => $classRoom->capacity_label,
|
||||
'remaining_capacity' => $classRoom->remaining_capacity,
|
||||
'warning_level' => is_null($classRoom->remaining_capacity) ? 'normal' : ($classRoom->remaining_capacity <= 0 ? 'full' : ($classRoom->remaining_capacity <= 3 ? 'low' : 'normal')),
|
||||
])->values();
|
||||
$badgeClass = match ($recommendation['action']) {
|
||||
'promote' => 'bg-emerald-100 text-emerald-700',
|
||||
@@ -178,7 +271,7 @@
|
||||
<option value="graduate" @selected($oldAction === 'graduate')>Lulus</option>
|
||||
<option value="skip" @selected($oldAction === 'skip')>Lewati</option>
|
||||
</select>
|
||||
<div class="mt-2 text-xs text-slate-500">Admin bisa ubah rekomendasi sebelum proses.</div>
|
||||
<div class="mt-2 text-xs text-slate-500">Ubah hanya untuk siswa pengecualian.</div>
|
||||
</td>
|
||||
<td class="px-4 py-4">
|
||||
<div class="rounded-2xl border border-slate-200 bg-slate-50 px-4 py-3 text-sm text-slate-500 promotion-graduate-placeholder {{ $oldAction === 'graduate' ? '' : 'hidden' }}">
|
||||
@@ -204,10 +297,11 @@
|
||||
<div class="mt-2 text-xs {{ $defaultClasses->isEmpty() ? 'text-amber-600' : 'text-slate-500' }} promotion-target-help">
|
||||
{{ $defaultClasses->isEmpty() ? 'Belum ada kelas aktif yang cocok pada tahun ajaran target untuk aksi ini.' : 'Pilih kelas tujuan sesuai aksi. Naik kelas memakai level berikutnya, tinggal kelas memakai level yang sama.' }}
|
||||
</div>
|
||||
<div class="mt-2 hidden rounded-2xl border px-3 py-2 text-xs promotion-capacity-warning" data-promotion-capacity-warning></div>
|
||||
@if ($defaultClasses->isNotEmpty())
|
||||
<div class="mt-2 space-y-1 text-[11px] text-slate-500">
|
||||
@foreach ($defaultClasses as $classRoom)
|
||||
<div>• {{ $classRoom->name }} — {{ $classRoom->capacity_label }}</div>
|
||||
<div class="{{ filled($classRoom->remaining_capacity) && $classRoom->remaining_capacity <= 0 ? 'text-rose-600 font-semibold' : (filled($classRoom->remaining_capacity) && $classRoom->remaining_capacity <= 3 ? 'text-amber-600 font-semibold' : '') }}">• {{ $classRoom->name }} — {{ $classRoom->capacity_label }}</div>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
@@ -223,11 +317,11 @@
|
||||
|
||||
<div class="flex flex-wrap items-center justify-between gap-3 rounded-2xl border border-slate-200 bg-slate-50 px-5 py-4">
|
||||
<div class="space-y-1 text-sm text-slate-500">
|
||||
<div>Total siswa siap diproses: <span class="font-semibold text-slate-800">{{ $students->count() }}</span></div>
|
||||
<div class="text-xs text-slate-400">Tips: untuk siswa tinggal kelas, pastikan tahun ajaran target punya kelas dengan level yang sama dan sisa kuota masih cukup.</div>
|
||||
<div>Total siswa siap diproses dari kelas ini: <span class="font-semibold text-slate-800">{{ $students->count() }}</span></div>
|
||||
<div class="text-xs text-slate-400">Tips: pola kerja idealnya set semua sesuai rekomendasi kelas, lalu ubah hanya siswa yang menjadi pengecualian.</div>
|
||||
</div>
|
||||
<button type="submit" class="inline-flex items-center rounded-2xl bg-indigo-600 px-5 py-3 text-sm font-semibold text-white shadow-lg shadow-indigo-200 transition hover:bg-indigo-700">
|
||||
Proses Promosi Siswa
|
||||
<button type="submit" class="inline-flex items-center rounded-2xl bg-indigo-600 px-5 py-3 text-sm font-semibold text-white shadow-lg shadow-indigo-200 transition hover:bg-indigo-700" data-promotion-submit-button>
|
||||
Proses Promosi Kelas Ini
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
$isAdmin = auth()->user()?->isAdmin() ?? false;
|
||||
|
||||
$indexRoute = match ($viewMode ?? 'all') {
|
||||
'graduated' => route('students.graduated'),
|
||||
'transferred' => route('students.transferred'),
|
||||
default => route('students.index'),
|
||||
};
|
||||
@@ -28,6 +27,7 @@
|
||||
<div class="flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between">
|
||||
<div></div>
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
@if (($viewMode ?? 'all') === 'all')
|
||||
@if ($isAdmin)
|
||||
<a href="{{ route('students.import.form') }}" class="inline-flex items-center justify-center rounded-2xl border border-emerald-200 bg-emerald-50 px-5 py-3 text-sm font-semibold text-emerald-700 transition hover:bg-emerald-100">
|
||||
Import Data Siswa
|
||||
@@ -36,17 +36,19 @@
|
||||
<a href="{{ route('students.create') }}" class="inline-flex items-center justify-center rounded-2xl bg-indigo-600 px-5 py-3 text-sm font-semibold text-white shadow-lg shadow-indigo-200 transition hover:bg-indigo-700">
|
||||
Tambah Siswa
|
||||
</a>
|
||||
@endif
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<x-master-card title="Filter Data Siswa" subtitle="Cari berdasarkan nama, NIS, NISN, kontak, atau filter akademik dasar.">
|
||||
<form method="GET" action="{{ $indexRoute }}" class="grid grid-cols-1 gap-4 md:grid-cols-2 xl:grid-cols-5">
|
||||
<x-form-input name="search" label="Pencarian" :value="$search" placeholder="Nama / NIS / NISN / HP" />
|
||||
<x-form-select name="academic_year_id" label="Tahun Angkatan" :options="$academicYears->all()" :value="$filters['academic_year_id']" />
|
||||
<x-form-select name="department_id" label="Program Keahlian" :options="$departments->all()" :value="$filters['department_id']" />
|
||||
<x-form-select name="class_id" label="Kelas" :options="$classes->all()" :value="$filters['class_id']" />
|
||||
@if (($viewMode ?? 'all') === 'all')
|
||||
<x-form-select name="status" label="Status" :options="$statuses" :value="$filters['status']" />
|
||||
@endif
|
||||
|
||||
<input type="hidden" name="sort" value="{{ $sort }}">
|
||||
<input type="hidden" name="direction" value="{{ $direction }}">
|
||||
@@ -67,7 +69,7 @@
|
||||
<div><span class="font-semibold text-slate-800">Total data:</span> {{ $students->total() }} siswa</div>
|
||||
<div class="text-xs text-slate-400">Halaman {{ $students->currentPage() }} dari {{ $students->lastPage() }}</div>
|
||||
</div>
|
||||
@if ($isAdmin)
|
||||
@if ($isAdmin && ($viewMode ?? 'all') === 'all')
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<label class="inline-flex items-center gap-2 text-sm text-slate-600">
|
||||
<input type="checkbox" id="select-all-students" class="rounded border-slate-300 text-indigo-600 focus:ring-indigo-500">
|
||||
@@ -89,7 +91,7 @@
|
||||
<table class="min-w-full divide-y divide-slate-200">
|
||||
<thead class="bg-slate-50">
|
||||
<tr>
|
||||
@if ($isAdmin)
|
||||
@if ($isAdmin && ($viewMode ?? 'all') === 'all')
|
||||
<th class="px-6 py-4 text-left text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">Pilih</th>
|
||||
@endif
|
||||
<th class="px-6 py-4 text-left text-xs font-semibold uppercase tracking-[0.16em] text-slate-500">
|
||||
@@ -111,7 +113,7 @@
|
||||
<tbody class="divide-y divide-slate-100 bg-white">
|
||||
@forelse ($students as $student)
|
||||
<tr>
|
||||
@if ($isAdmin)
|
||||
@if ($isAdmin && ($viewMode ?? 'all') === 'all')
|
||||
<td class="px-6 py-4 align-top">
|
||||
<input type="checkbox" name="student_ids[]" value="{{ $student->id }}" class="student-row-checkbox rounded border-slate-300 text-indigo-600 focus:ring-indigo-500">
|
||||
</td>
|
||||
@@ -197,8 +199,10 @@
|
||||
<td class="px-6 py-4">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<a href="{{ route('students.show', $student) }}" class="rounded-xl border border-sky-200 px-3 py-2 text-xs font-semibold text-sky-700 transition hover:bg-sky-50">Detail</a>
|
||||
@if (($viewMode ?? 'all') === 'all')
|
||||
<a href="{{ route('students.edit', $student) }}" class="rounded-xl border border-slate-200 px-3 py-2 text-xs font-semibold text-slate-700 transition hover:bg-slate-50">Edit</a>
|
||||
@if ($isAdmin)
|
||||
@endif
|
||||
@if ($isAdmin && ($viewMode ?? 'all') === 'all')
|
||||
<form action="{{ route('students.destroy', $student) }}" method="POST" class="delete-form" data-entity="data siswa {{ $student->full_name }}">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
@@ -210,7 +214,7 @@
|
||||
</tr>
|
||||
@empty
|
||||
<tr>
|
||||
<td colspan="{{ $isAdmin ? 7 : 6 }}" class="px-6 py-10 text-center text-sm text-slate-500">Belum ada data siswa.</td>
|
||||
<td colspan="{{ ($isAdmin && ($viewMode ?? 'all') === 'all') ? 7 : 6 }}" class="px-6 py-10 text-center text-sm text-slate-500">Belum ada data siswa.</td>
|
||||
</tr>
|
||||
@endforelse
|
||||
</tbody>
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
|
||||
use App\Http\Controllers\Api\Integration\AcademicYearSyncController;
|
||||
use App\Http\Controllers\Api\Integration\DepartmentSyncController;
|
||||
use App\Http\Controllers\Api\Integration\SchoolClassSyncController;
|
||||
use App\Http\Controllers\Api\Integration\StudentSyncController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
Route::prefix('integration')
|
||||
->middleware('sync.token')
|
||||
->group(function () {
|
||||
Route::get('academic-years', AcademicYearSyncController::class)->name('api.integration.academic-years');
|
||||
Route::get('departments', DepartmentSyncController::class)->name('api.integration.departments');
|
||||
Route::get('classes', SchoolClassSyncController::class)->name('api.integration.classes');
|
||||
Route::get('students', StudentSyncController::class)->name('api.integration.students');
|
||||
});
|
||||
+14
-1
@@ -16,9 +16,12 @@ use App\Http\Controllers\StudentParentController;
|
||||
use App\Http\Controllers\StudentDocumentController;
|
||||
use App\Http\Controllers\StudentExitController;
|
||||
use App\Http\Controllers\StudentTransferController;
|
||||
use App\Http\Controllers\GraduatedStudentController;
|
||||
use App\Http\Controllers\GraduationBulkUploadController;
|
||||
use App\Http\Controllers\StudentPromotionController;
|
||||
use App\Http\Controllers\StudentSelfServiceController;
|
||||
use App\Http\Controllers\StudentAchievementController;
|
||||
use App\Http\Controllers\SyncTokenController;
|
||||
use App\Http\Controllers\UserManagementController;
|
||||
use Illuminate\Support\Facades\Route;
|
||||
|
||||
@@ -32,6 +35,7 @@ Route::redirect('/portal-admin-dk-login', '/masuk-admin');
|
||||
Route::redirect('/masuk-admin-rahasia', '/masuk-admin')->name('hidden-login');
|
||||
Route::get('public/student-documents/{document}/preview', [StudentDocumentController::class, 'publicPreview'])->name('public.students.documents.preview');
|
||||
Route::get('public/student-documents/{document}/download', [StudentDocumentController::class, 'publicDownload'])->name('public.students.documents.download');
|
||||
Route::get('public/students/{student}/graduation-documents/{document}/download', [PublicStudentLookupController::class, 'downloadGraduationDocument'])->name('public.students.graduation-documents.download');
|
||||
Route::get('regions/provinces/{province}/regencies', [RegionController::class, 'regencies'])->name('regions.regencies');
|
||||
Route::get('regions/regencies/{regency}/districts', [RegionController::class, 'districts'])->name('regions.districts');
|
||||
Route::get('regions/districts/{district}/villages', [RegionController::class, 'villages'])->name('regions.villages');
|
||||
@@ -50,6 +54,9 @@ Route::middleware(['auth', 'verified'])->group(function () {
|
||||
Route::resource('users', UserManagementController::class)->except(['show']);
|
||||
Route::get('branding', [BrandingSettingController::class, 'index'])->name('branding.index');
|
||||
Route::put('branding', [BrandingSettingController::class, 'update'])->name('branding.update');
|
||||
Route::get('sync-tokens', [SyncTokenController::class, 'index'])->name('sync-tokens.index');
|
||||
Route::post('sync-tokens', [SyncTokenController::class, 'store'])->name('sync-tokens.store');
|
||||
Route::patch('sync-tokens/{syncToken}/revoke', [SyncTokenController::class, 'revoke'])->name('sync-tokens.revoke');
|
||||
Route::get('reset-data', [MaintenanceController::class, 'index'])->name('reset-data.index');
|
||||
Route::post('reset-data', [MaintenanceController::class, 'reset'])->name('reset-data.execute');
|
||||
});
|
||||
@@ -63,7 +70,13 @@ Route::middleware(['auth', 'verified'])->group(function () {
|
||||
Route::get('students/mutasi/{studentTransfer}', [StudentTransferController::class, 'show'])->name('student-transfers.show');
|
||||
Route::patch('students/mutasi/{studentTransfer}', [StudentTransferController::class, 'update'])->name('student-transfers.update');
|
||||
Route::get('students/mutasi/{studentTransfer}/preview-letter', [StudentTransferController::class, 'previewLetter'])->name('student-transfers.preview-letter');
|
||||
Route::get('students/lulus', [StudentController::class, 'index'])->defaults('view', 'graduated')->name('students.graduated');
|
||||
Route::get('students/lulus', [GraduatedStudentController::class, 'index'])->name('graduated-students.index');
|
||||
Route::get('students/lulus/bulk-upload', [GraduationBulkUploadController::class, 'index'])->name('graduated-students.bulk-upload.index');
|
||||
Route::post('students/lulus/bulk-upload/preview', [GraduationBulkUploadController::class, 'preview'])->name('graduated-students.bulk-upload.preview');
|
||||
Route::post('students/lulus/bulk-upload', [GraduationBulkUploadController::class, 'store'])->name('graduated-students.bulk-upload.store');
|
||||
Route::get('students/lulus/{graduatedStudent}', [GraduatedStudentController::class, 'show'])->name('graduated-students.show');
|
||||
Route::patch('students/lulus/{graduatedStudent}', [GraduatedStudentController::class, 'update'])->name('graduated-students.update');
|
||||
Route::get('students/lulus/{graduatedStudent}/preview-document/{document}', [GraduatedStudentController::class, 'previewDocument'])->name('graduated-students.preview-document');
|
||||
Route::get('students/import', [StudentController::class, 'importForm'])->name('students.import.form');
|
||||
Route::post('students/import/preview', [StudentController::class, 'previewImport'])->name('students.import.preview');
|
||||
Route::post('students/import', [StudentController::class, 'import'])->name('students.import');
|
||||
|
||||
@@ -0,0 +1,307 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\AcademicYear;
|
||||
use App\Models\Department;
|
||||
use App\Models\SchoolClass;
|
||||
use App\Models\Student;
|
||||
use App\Models\StudentAcademicHistory;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
|
||||
class StudentPromotionTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_index_shows_class_summary_instead_of_loading_all_students_when_class_is_not_selected(): void
|
||||
{
|
||||
$admin = User::factory()->create(['role' => 'admin']);
|
||||
|
||||
[$fromYear, $toYear, $department, $fromClass] = $this->createPromotionContext();
|
||||
|
||||
Student::create([
|
||||
'student_number' => 'S-100',
|
||||
'full_name' => 'Ahmad Ringkasan',
|
||||
'gender' => 'L',
|
||||
'academic_year_id' => $fromYear->id,
|
||||
'department_id' => $department->id,
|
||||
'class_id' => $fromClass->id,
|
||||
'status' => 'active',
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($admin)->get(route('student-promotions.index', [
|
||||
'from_academic_year_id' => $fromYear->id,
|
||||
'to_academic_year_id' => $toYear->id,
|
||||
]));
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertSee('Pilih <span class="font-semibold">kelas asal</span> untuk memproses siswa per rombel.', false);
|
||||
$response->assertSee($fromClass->name);
|
||||
$response->assertSee('Proses kelas ini');
|
||||
$response->assertDontSee('Ahmad Ringkasan');
|
||||
}
|
||||
|
||||
public function test_admin_can_promote_student_and_create_new_academic_history(): void
|
||||
{
|
||||
$admin = User::factory()->create(['role' => 'admin']);
|
||||
|
||||
[$fromYear, $toYear, $department, $fromClass, $targetClass] = $this->createPromotionContext();
|
||||
|
||||
$student = Student::create([
|
||||
'student_number' => 'S-001',
|
||||
'full_name' => 'Budi Santoso',
|
||||
'gender' => 'L',
|
||||
'academic_year_id' => $fromYear->id,
|
||||
'department_id' => $department->id,
|
||||
'class_id' => $fromClass->id,
|
||||
'status' => 'active',
|
||||
]);
|
||||
|
||||
StudentAcademicHistory::create([
|
||||
'student_id' => $student->id,
|
||||
'academic_year_id' => $fromYear->id,
|
||||
'department_id' => $department->id,
|
||||
'class_id' => $fromClass->id,
|
||||
'status' => 'active',
|
||||
'start_date' => '2025-07-01',
|
||||
'is_current' => true,
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($admin)->post(route('student-promotions.store'), [
|
||||
'from_academic_year_id' => $fromYear->id,
|
||||
'to_academic_year_id' => $toYear->id,
|
||||
'class_id' => $fromClass->id,
|
||||
'promotions' => [
|
||||
[
|
||||
'student_id' => $student->id,
|
||||
'target_class_id' => $targetClass->id,
|
||||
'action' => 'promote',
|
||||
'notes' => 'Naik kelas otomatis hasil akhir tahun.',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$response->assertRedirect(route('student-promotions.index', [
|
||||
'from_academic_year_id' => $fromYear->id,
|
||||
'to_academic_year_id' => $toYear->id,
|
||||
'class_id' => $fromClass->id,
|
||||
]));
|
||||
|
||||
$student->refresh();
|
||||
|
||||
$this->assertSame($toYear->id, $student->academic_year_id);
|
||||
$this->assertSame($targetClass->id, $student->class_id);
|
||||
$this->assertSame('active', $student->status);
|
||||
|
||||
$this->assertDatabaseHas('student_academic_histories', [
|
||||
'student_id' => $student->id,
|
||||
'academic_year_id' => $fromYear->id,
|
||||
'class_id' => $fromClass->id,
|
||||
'status' => 'promoted',
|
||||
'is_current' => 0,
|
||||
'notes' => 'Naik kelas otomatis hasil akhir tahun.',
|
||||
]);
|
||||
|
||||
$this->assertDatabaseHas('student_academic_histories', [
|
||||
'student_id' => $student->id,
|
||||
'academic_year_id' => $toYear->id,
|
||||
'class_id' => $targetClass->id,
|
||||
'status' => 'active',
|
||||
'is_current' => 1,
|
||||
'notes' => 'Naik kelas otomatis hasil akhir tahun.',
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_promotion_is_rejected_when_target_class_exceeds_capacity(): void
|
||||
{
|
||||
$admin = User::factory()->create(['role' => 'admin']);
|
||||
|
||||
[$fromYear, $toYear, $department, $fromClass, $targetClass] = $this->createPromotionContext([
|
||||
'target_capacity' => 1,
|
||||
]);
|
||||
|
||||
Student::create([
|
||||
'student_number' => 'S-EXIST',
|
||||
'full_name' => 'Siswa Existing',
|
||||
'gender' => 'L',
|
||||
'academic_year_id' => $toYear->id,
|
||||
'department_id' => $department->id,
|
||||
'class_id' => $targetClass->id,
|
||||
'status' => 'active',
|
||||
]);
|
||||
|
||||
$student = Student::create([
|
||||
'student_number' => 'S-002',
|
||||
'full_name' => 'Citra Lestari',
|
||||
'gender' => 'P',
|
||||
'academic_year_id' => $fromYear->id,
|
||||
'department_id' => $department->id,
|
||||
'class_id' => $fromClass->id,
|
||||
'status' => 'active',
|
||||
]);
|
||||
|
||||
StudentAcademicHistory::create([
|
||||
'student_id' => $student->id,
|
||||
'academic_year_id' => $fromYear->id,
|
||||
'department_id' => $department->id,
|
||||
'class_id' => $fromClass->id,
|
||||
'status' => 'active',
|
||||
'start_date' => '2025-07-01',
|
||||
'is_current' => true,
|
||||
]);
|
||||
|
||||
$response = $this->from(route('student-promotions.index', [
|
||||
'from_academic_year_id' => $fromYear->id,
|
||||
'to_academic_year_id' => $toYear->id,
|
||||
'class_id' => $fromClass->id,
|
||||
]))->actingAs($admin)->post(route('student-promotions.store'), [
|
||||
'from_academic_year_id' => $fromYear->id,
|
||||
'to_academic_year_id' => $toYear->id,
|
||||
'class_id' => $fromClass->id,
|
||||
'promotions' => [
|
||||
[
|
||||
'student_id' => $student->id,
|
||||
'target_class_id' => $targetClass->id,
|
||||
'action' => 'promote',
|
||||
'notes' => 'Coba promosi ke kelas penuh.',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$response->assertRedirect(route('student-promotions.index', [
|
||||
'from_academic_year_id' => $fromYear->id,
|
||||
'to_academic_year_id' => $toYear->id,
|
||||
'class_id' => $fromClass->id,
|
||||
]));
|
||||
$response->assertSessionHas('errors');
|
||||
$this->assertStringContainsString(
|
||||
"Kelas {$targetClass->name} melebihi kapasitas. Sisa kuota 0, tetapi alokasi promosi/repeat yang dipilih 1.",
|
||||
session('errors')->first()
|
||||
);
|
||||
|
||||
$student->refresh();
|
||||
|
||||
$this->assertSame($fromYear->id, $student->academic_year_id);
|
||||
$this->assertSame($fromClass->id, $student->class_id);
|
||||
|
||||
$this->assertDatabaseMissing('student_academic_histories', [
|
||||
'student_id' => $student->id,
|
||||
'academic_year_id' => $toYear->id,
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_promotion_is_rejected_when_student_already_has_target_year_history(): void
|
||||
{
|
||||
$admin = User::factory()->create(['role' => 'admin']);
|
||||
|
||||
[$fromYear, $toYear, $department, $fromClass, $targetClass] = $this->createPromotionContext();
|
||||
|
||||
$student = Student::create([
|
||||
'student_number' => 'S-003',
|
||||
'full_name' => 'Dewi Anjani',
|
||||
'gender' => 'P',
|
||||
'academic_year_id' => $fromYear->id,
|
||||
'department_id' => $department->id,
|
||||
'class_id' => $fromClass->id,
|
||||
'status' => 'active',
|
||||
]);
|
||||
|
||||
StudentAcademicHistory::create([
|
||||
'student_id' => $student->id,
|
||||
'academic_year_id' => $fromYear->id,
|
||||
'department_id' => $department->id,
|
||||
'class_id' => $fromClass->id,
|
||||
'status' => 'active',
|
||||
'start_date' => '2025-07-01',
|
||||
'is_current' => true,
|
||||
]);
|
||||
|
||||
StudentAcademicHistory::create([
|
||||
'student_id' => $student->id,
|
||||
'academic_year_id' => $toYear->id,
|
||||
'department_id' => $department->id,
|
||||
'class_id' => $targetClass->id,
|
||||
'status' => 'active',
|
||||
'start_date' => '2026-07-01',
|
||||
'is_current' => false,
|
||||
]);
|
||||
|
||||
$response = $this->from(route('student-promotions.index', [
|
||||
'from_academic_year_id' => $fromYear->id,
|
||||
'to_academic_year_id' => $toYear->id,
|
||||
'class_id' => $fromClass->id,
|
||||
]))->actingAs($admin)->post(route('student-promotions.store'), [
|
||||
'from_academic_year_id' => $fromYear->id,
|
||||
'to_academic_year_id' => $toYear->id,
|
||||
'class_id' => $fromClass->id,
|
||||
'promotions' => [
|
||||
[
|
||||
'student_id' => $student->id,
|
||||
'target_class_id' => $targetClass->id,
|
||||
'action' => 'promote',
|
||||
'notes' => 'Tidak boleh dobel histori.',
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
$response->assertRedirect(route('student-promotions.index', [
|
||||
'from_academic_year_id' => $fromYear->id,
|
||||
'to_academic_year_id' => $toYear->id,
|
||||
'class_id' => $fromClass->id,
|
||||
]));
|
||||
$response->assertSessionHasErrors([
|
||||
'promotions.0.student_id' => 'Siswa Dewi Anjani sudah memiliki histori akademik pada tahun ajaran tujuan.',
|
||||
]);
|
||||
|
||||
$student->refresh();
|
||||
|
||||
$this->assertSame($fromYear->id, $student->academic_year_id);
|
||||
$this->assertSame($fromClass->id, $student->class_id);
|
||||
$this->assertDatabaseCount('student_academic_histories', 2);
|
||||
}
|
||||
|
||||
protected function createPromotionContext(array $overrides = []): array
|
||||
{
|
||||
$fromYear = AcademicYear::create([
|
||||
'name' => '2025/2026',
|
||||
'start_year' => 2025,
|
||||
'end_year' => 2026,
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$toYear = AcademicYear::create([
|
||||
'name' => '2026/2027',
|
||||
'start_year' => 2026,
|
||||
'end_year' => 2027,
|
||||
'is_active' => false,
|
||||
]);
|
||||
|
||||
$department = Department::create([
|
||||
'code' => 'RPL',
|
||||
'name' => 'Rekayasa Perangkat Lunak',
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$fromClass = SchoolClass::create([
|
||||
'academic_year_id' => $fromYear->id,
|
||||
'department_id' => $department->id,
|
||||
'name' => 'X RPL 1',
|
||||
'level' => 'X',
|
||||
'capacity' => 36,
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$targetClass = SchoolClass::create([
|
||||
'academic_year_id' => $toYear->id,
|
||||
'department_id' => $department->id,
|
||||
'name' => 'XI RPL 1',
|
||||
'level' => 'XI',
|
||||
'capacity' => $overrides['target_capacity'] ?? 36,
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
return [$fromYear, $toYear, $department, $fromClass, $targetClass];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user