Initial commit - lms-v2 + CLAUDE.md

This commit is contained in:
Iwit
2026-05-30 22:15:16 +07:00
commit 5811409e2d
183 changed files with 23225 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\FromArray;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
class EmployeeTemplateExport implements FromArray, WithHeadings, ShouldAutoSize
{
public function headings(): array
{
// PENTING: Header ini dibaca oleh Controller, jangan diubah formatnya
return [
'nik', 'no_ktp', 'inisial', 'nama_depan', 'nama_belakang',
'email', 'telepon', 'jenis_kelamin', 'tgl_lahir', 'tgl_masuk',
'department_id', 'position_id'
];
}
public function array(): array
{
return [
// Baris contoh (Gunakan format YYYY-MM-DD untuk tanggal)
['10102023', '3201012345678901', 'BDS', 'Budi', 'Santoso', 'budi@perusahaan.com', '0812345678', 'L', '1990-01-30', '2023-01-01', '1', '2'],
['10102024', '', 'STA', 'Siti', 'Aminah', 'siti@perusahaan.com', '0887654321', 'P', '1995-12-15', '2023-05-10', '1', '3'],
];
}
}
+89
View File
@@ -0,0 +1,89 @@
<?php
namespace App\Exports;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Concerns\WithCustomStartCell;
use Maatwebsite\Excel\Events\AfterSheet;
use Carbon\Carbon;
class EmployeesExport implements FromCollection, WithHeadings, WithMapping, ShouldAutoSize, WithEvents, WithCustomStartCell
{
protected $employees;
// Menangkap data hasil filter dari Controller
public function __construct($employees)
{
$this->employees = $employees;
}
public function collection()
{
return $this->employees;
}
// Mulai tabel data di baris ke-6 (Baris 1-4 untuk informasi header)
public function startCell(): string
{
return 'A6';
}
public function headings(): array
{
return ['NIK', 'No. KTP', 'Inisial', 'Nama Depan', 'Nama Belakang', 'Email', 'No. HP', 'Jenis Kelamin', 'Tgl Lahir', 'Tgl Masuk', 'Departemen', 'Jabatan', 'Status', 'Hak Akses'];
}
public function map($user): array
{
return [
$user->nik,
$user->identity_number ?? '-',
strtoupper($user->initial ?? '-'),
$user->first_name,
$user->last_name,
$user->email,
$user->phone ?? '-',
$user->gender == 'L' ? 'Laki-laki' : 'Perempuan',
$user->date_of_birth ? Carbon::parse($user->date_of_birth)->format('Y-m-d') : '-',
$user->join_date ? Carbon::parse($user->join_date)->format('Y-m-d') : '-',
$user->department->name ?? '-',
$user->position->name ?? '-',
$user->is_active ? 'Aktif' : 'Non-Aktif',
$user->roles->pluck('name')->implode(', '),
];
}
// Event untuk menyuntikkan Teks Header di atas tabel dan memberi warna
public function registerEvents(): array
{
return [
AfterSheet::class => function(AfterSheet $event) {
$sheet = $event->sheet->getDelegate();
$count = $this->employees->count();
$user = auth()->user()->first_name . ' ' . auth()->user()->last_name;
$date = Carbon::now()->translatedFormat('d F Y - H:i:s');
// Menyuntikkan Informasi di baris atas
$sheet->setCellValue('A1', 'LAPORAN DATA KARYAWAN');
$sheet->setCellValue('A2', 'Total Data (Sesuai Filter) : ' . $count . ' Karyawan');
$sheet->setCellValue('A3', 'Dicetak Oleh : ' . $user);
$sheet->setCellValue('A4', 'Waktu Cetak : ' . $date);
// Styling (Merge judul & warna header tabel)
$sheet->mergeCells('A1:N1');
$sheet->getStyle('A1')->getFont()->setBold(true)->setSize(14);
$sheet->getStyle('A2:A4')->getFont()->setBold(true);
$sheet->getStyle('A6:N6')->getFont()->setBold(true);
// Memberi warna latar abu-abu pada header tabel (Baris 6)
$sheet->getStyle('A6:N6')->getFill()
->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
->getStartColor()->setARGB('FFE2E8F0');
},
];
}
}
+69
View File
@@ -0,0 +1,69 @@
<?php
namespace App\Exports;
use App\Models\Position;
use Maatwebsite\Excel\Concerns\FromCollection;
use Maatwebsite\Excel\Concerns\WithHeadings;
use Maatwebsite\Excel\Concerns\WithMapping;
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
use Maatwebsite\Excel\Concerns\WithEvents;
use Maatwebsite\Excel\Concerns\WithCustomStartCell;
use Maatwebsite\Excel\Events\AfterSheet;
use Carbon\Carbon;
class PositionsExport implements FromCollection, WithHeadings, WithMapping, ShouldAutoSize, WithEvents, WithCustomStartCell
{
public function collection()
{
return Position::orderBy('name', 'asc')->get();
}
public function startCell(): string
{
return 'A6';
}
public function headings(): array
{
return ['No', 'Nama Jabatan / Posisi', 'Dibuat Pada'];
}
public function map($position): array
{
static $number = 0;
$number++;
return [
$number,
$position->name,
$position->created_at ? Carbon::parse($position->created_at)->format('d-m-Y H:i') : '-',
];
}
public function registerEvents(): array
{
return [
AfterSheet::class => function(AfterSheet $event) {
$sheet = $event->sheet->getDelegate();
$count = Position::count();
$user = auth()->user()->first_name . ' ' . auth()->user()->last_name;
$date = Carbon::now()->translatedFormat('d F Y - H:i:s');
$sheet->setCellValue('A1', 'LAPORAN MASTER DATA JABATAN');
$sheet->setCellValue('A2', 'Total Data : ' . $count . ' Jabatan');
$sheet->setCellValue('A3', 'Dicetak Oleh: ' . $user);
$sheet->setCellValue('A4', 'Waktu Cetak : ' . $date);
$sheet->mergeCells('A1:C1');
$sheet->getStyle('A1')->getFont()->setBold(true)->setSize(14);
$sheet->getStyle('A2:A4')->getFont()->setBold(true);
$sheet->getStyle('A6:C6')->getFont()->setBold(true);
$sheet->getStyle('A6:C6')->getFill()
->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)
->getStartColor()->setARGB('FFE2E8F0');
},
];
}
}