first commit
This commit is contained in:
@@ -0,0 +1,117 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers\Verifikasi\SK;
|
||||
|
||||
use App\Http\Controllers\Controller;
|
||||
use App\Models\Verifikator\Periode;
|
||||
use App\Models\Verifikator\Team;
|
||||
use App\Services\SiskaService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Yajra\DataTables\Facades\DataTables;
|
||||
|
||||
class SudahDiperbaikiController extends Controller
|
||||
{
|
||||
private $siskaService;
|
||||
|
||||
private $auth;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->siskaService = new SiskaService;
|
||||
$this->auth = Auth::user();
|
||||
}
|
||||
|
||||
public function index()
|
||||
{
|
||||
$title = 'Sudah Diperbaiki';
|
||||
$units = [];
|
||||
|
||||
// Ambil daftar unit kerja hanya untuk Superuser
|
||||
if ($this->auth->hasRole('Superuser')) {
|
||||
$allUnits = $this->siskaService->daftarUnits();
|
||||
|
||||
// Cek jika service SISKA tidak tersedia
|
||||
if ($allUnits === null) {
|
||||
return redirect()->back()->with('info', 'Service SISKA sedang melakukan Maintenance, silahkan coba beberapa saat lagi.');
|
||||
}
|
||||
|
||||
// Filter hanya unit kerja dengan ID 1-10
|
||||
$units = array_filter($allUnits, function ($unit) {
|
||||
return $unit['id'] >= 1 && $unit['id'] <= 10;
|
||||
});
|
||||
}
|
||||
|
||||
$periode = Periode::where('status', true)->first();
|
||||
|
||||
return view('verifikasi.sk.sudah-diperbaiki.index', compact('title', 'units', 'periode'));
|
||||
}
|
||||
|
||||
public function data(Request $request)
|
||||
{
|
||||
$team = Team::find(session('team_id'));
|
||||
|
||||
// Jika Superuser dan memilih unit tertentu
|
||||
if ($this->auth->hasRole('Superuser') && $request->filled('unit_id')) {
|
||||
$unitId = $request->unit_id;
|
||||
} elseif ($team->unit_kerja_id === null) {
|
||||
$unitId = null;
|
||||
} else {
|
||||
$unitId = $team->unit_kerja_id + 1;
|
||||
}
|
||||
|
||||
if ($request->no_sk) {
|
||||
$response = $this->siskaService->searchStatusPerbaikanByNomorSk($unitId, $request->no_sk, 'Sudah Diperbaiki', request('start', 1) / request('length', 1) + 1, request('length', 10));
|
||||
} else {
|
||||
$response = $this->siskaService->statusPerbaikan($unitId, 'Sudah Diperbaiki', request('start', 1) / request('length', 1) + 1, request('length', 10), $request->tentang);
|
||||
}
|
||||
|
||||
$data = $response['data'] ?? [];
|
||||
|
||||
return DataTables::of($data)
|
||||
->addIndexColumn()
|
||||
->addColumn('tanggal_sk', function ($row) {
|
||||
return $row['tanggal_sk'] ? Carbon::parse($row['tanggal_sk'])->format('d/m/Y') : '-';
|
||||
})
|
||||
->addColumn('status_verifikator', function ($row) {
|
||||
if ($row['must_fix']) {
|
||||
return '<span class="badge bg-secondary rounded-pill fs-6 px-2 py-1">Perlu Perbaikan</span>';
|
||||
} elseif ($row['must_fix'] === 0) {
|
||||
return '<span class="badge bg-info rounded-pill fs-6 px-2 py-1">Sudah Diperbaiki</span>';
|
||||
} elseif ($row['status_verifikator'] === null) {
|
||||
return '<span class="badge bg-warning rounded-pill fs-6 px-2 py-1">Belum Diverifikasi</span>';
|
||||
} elseif ($row['status_verifikator'] == 1 && $row['finalisasi']) {
|
||||
return '<span class="badge bg-success rounded-pill fs-6 px-2 py-1">Sudah Finalisasi</span>';
|
||||
} elseif ($row['status_verifikator'] == 1 && ! $row['finalisasi']) {
|
||||
return '<span class="badge bg-primary rounded-pill fs-6 px-2 py-1">Belum Finalisasi</span>';
|
||||
} else {
|
||||
return '<span class="badge bg-danger rounded-pill fs-6 px-2 py-1">Ditolak</span>';
|
||||
}
|
||||
})
|
||||
->addColumn('pdf', function ($row) {
|
||||
if ($row['sk']) {
|
||||
return '<a href="'.$row['sk'].'" target="_blank" class="btn btn-sm btn-primary" data-bs-toggle="tooltip" data-bs-placement="top" title="Lihat PDF SK"><i class="uil-file-alt"></i></a>';
|
||||
}
|
||||
|
||||
return '<span class="text-muted">-</span>';
|
||||
})
|
||||
->addColumn('url_detail', function ($row) {
|
||||
return route('sk.detail.index', $row['id']);
|
||||
})
|
||||
->addColumn('no_anggota', function ($row) {
|
||||
return empty($row['anggota']);
|
||||
})
|
||||
->addColumn('tentang', function ($row) {
|
||||
$tentang = e($row['tentang'] ?? '-');
|
||||
if (empty($row['anggota'])) {
|
||||
return $tentang
|
||||
.'<br><small class="text-danger"><i class="uil-exclamation-triangle"></i> SK tidak memiliki anggota</small>';
|
||||
}
|
||||
|
||||
return $tentang;
|
||||
})
|
||||
->escapeColumns([])
|
||||
->make(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user