first commit

This commit is contained in:
Ariyutta
2026-08-07 10:47:09 +07:00
commit 1c094fbe7f
11630 changed files with 1580900 additions and 0 deletions
@@ -0,0 +1,106 @@
<?php
namespace App\Http\Controllers\Api\Pengajuan;
use App\Http\Controllers\Controller;
use App\Http\Resources\Sanggahan\SanggahanCollection;
use App\Models\DokSiremun\Syarat;
use App\Models\Verifikator\Periode;
use Error;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Throwable;
class SanggahanController extends Controller
{
public function index(Request $request)
{
try {
$periode = Periode::where('status', true)->first()->id_periode;
$pengajuans = Syarat::with([
'kegiatan',
'kegiatan.unit',
'statusVerifikasi',
'dokumens' => function ($query) {
$query->orderBy('kategori_dokumen');
},
'notes' => function ($query) {
$query->orderBy('id');
},
'logs' => function ($query) {
$query->orderBy('id');
}
])
->where('id_pelaksana', $request->nip)
->where('status_verifikasi_id', 2)
// ->whereNotIn('id_kategori', [1, 2, 3, 5, 6])
->whereHas('kegiatan', function ($query) use ($periode) {
return $query->whereNull('feeder')
->whereNotIn('kategori_kegiatan', ['Penelitian', 'Pengabdian'])
->where('uploader', '!=', 'Api MS1')
->where('id_periode', $periode);
})
->orderBy('id')
->get();
return new SanggahanCollection($pengajuans);
} catch (Throwable $th) {
throw new Error('Server Error', 500);
}
}
public function store(Request $request)
{
// if (!now()->isBetween('2025-12-01', '2025-12-23 23:59:59')) {
// return response()->json([
// 'code' => 400,
// 'status' => 'failed',
// 'message' => 'Masa Sanggahan Sudah Ditutup',
// ], 400);
// }
try {
DB::beginTransaction();
$syarat = Syarat::findOrFail($request->id);
if ($request->nip !== $syarat->id_pelaksana) {
throw new AuthorizationException('NIP tidak sesuai');
}
if ($syarat->rubrik->syarats->where('nama', 'laporan kegiatan')->count() === 0) {
$syarat->update([
'status_verifikasi_id' => 4,
]);
$syarat->logs()->create([
'user_id' => $syarat->pegawai->nip,
'employee_id' => $syarat->pegawai->nip,
'employee_name' => $syarat->pegawai->nama,
'employee_role' => $syarat->pegawai->jenis_pegawai,
'message' => 'Pengajuan berhasil diperbaiki',
]);
$syarat->notes()->create([
'type' => 'Sanggahan',
'user_id' => $syarat->pegawai->nip,
'employee_id' => $syarat->pegawai->nip,
'employee_name' => $syarat->pegawai->nama,
'employee_role' => 'Verifikator',
'message' => $request->sanggahan,
]);
DB::commit();
return response()->json([
'code' => 201,
'status' => 'success',
'message' => 'Pengajuan berhasil disanggah',
]);
}
} catch (Throwable $th) {
DB::rollBack();
return response()->json([
'code' => 500,
'status' => 'error',
'message' => $th->getMessage(),
]);
}
}
}
@@ -0,0 +1,88 @@
<?php
namespace App\Http\Controllers\Api\Pengajuan\TriDharma;
use App\Http\Controllers\Controller;
use App\Models\DokSiremun\Syarat;
use App\Models\Verifikator\View\Pegawai;
use App\Services\KegiatanService;
use Carbon\Carbon;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Throwable;
class MbkmController extends Controller
{
function store(Request $request)
{
$start = Carbon::parse('2024-05-20 00:00:00');
$end = Carbon::parse('2024-06-15 23:59:59');
if (!now()->isBetween($start, $end)) {
return response()->json([
'code' => 400,
'status' => 'failed',
'message' => 'Pengajuan Sudah Ditutup',
], 400);
}
try {
$pegawai = Pegawai::where('nip', $request->nip)->orWhere('nip_siakad', $request->nip)->firstOrFail();
$kegiatanService = new KegiatanService();
$countUpdated = 0;
if ($pegawai->jenis_pegawai === 'dosen') {
$token = $request->bearerToken();
$data = Crypt::decrypt($token);
if ($data['nip'] !== $request->nip) {
throw new AuthorizationException();
}
}
foreach ($request->id as $id) {
$syarat = Syarat::with('rubrik')
->select('id_kegiatan', 'id_kategori', 'id_rubrik', 'status_verifikasi_id')
->where('id_rubrik', 660)
->find($id);
if (!$syarat) continue;
if ($syarat->rubrik->syarats->where('nama', 'laporan kegiatan')->count() > 0) continue;
if ($syarat->status_verifikasi_id == 1) continue;
try {
$kegiatanService->pengajuan($id, $request->method());
$countUpdated++;
} catch (Throwable $th) {
continue;
}
}
return response()->json([
'status' => 'success',
'code' => 200,
'message' => "Berhasil mengajukan $countUpdated kegiatan",
], 200);
} catch (Throwable $th) {
DB::rollBack();
Log::error("Lainnya: " . $th->getMessage());
Log::error("Lainnya: " . $request->nip);
if ($th instanceof ModelNotFoundException) {
return response()->json([
'code' => 404,
'status' => 'failed',
'message' => 'Kegiatan tidak ditemukan',
], 404);
}
if ($th instanceof AuthorizationException) {
throw new AuthorizationException();
}
if ($th instanceof DecryptException) {
throw new AuthorizationException();
}
return response()->json([
'code' => 500,
'status' => 'failed',
'message' => 'Server Error',
], 500);
}
}
}
@@ -0,0 +1,103 @@
<?php
namespace App\Http\Controllers\Api\Pengajuan\TriDharma;
use App\Http\Controllers\Controller;
use App\Models\DokSiremun\Membimbing;
use App\Models\Verifikator\View\Pegawai;
use Carbon\Carbon;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Throwable;
class MembimbingController extends Controller
{
function store(Request $request)
{
$start = Carbon::parse('2024-05-20 00:00:00');
$end = Carbon::parse('2024-06-15 23:59:59');
if (!now()->isBetween($start, $end)) {
return response()->json([
'code' => 400,
'status' => 'failed',
'message' => 'Pengajuan Sudah Ditutup',
], 400);
}
try {
$user = Pegawai::select('id', 'nip', 'nama', 'jenis_pegawai')->where('nip', $request->nip)->orWhere('nip_siakad', $request->nip)->firstOrFail();
if ($user->jenis_pegawai === 'dosen') {
$token = $request->bearerToken();
$data = Crypt::decrypt($token);
if ($data['nip'] !== $request->nip) {
throw new AuthorizationException();
}
}
$countUpdated = 0;
DB::beginTransaction();
foreach ($request->id as $id) {
$membimbing = Membimbing::where('id', $id)
->where('id_pelaksana', $user->nip)
->firstOrFail();
if ($membimbing->status_verifikasi_id === 1 && $membimbing->status_syarat === 'COMPLETE') {
$countUpdated++;
$membimbing->update([
'status_verifikasi_id' => 3,
'tanggal_pengajuan' => Carbon::today(),
]);
$membimbing->logs()->create([
'user_id' => $user->id,
'method' => $request->method(),
'employee_id' => $user->nip,
'employee_name' => $user->name,
'employee_role' => ucwords($user->jenis_pegawai),
'message' => 'Pengajuan baru berhasil ditambahkan',
]);
}
}
if ($countUpdated === 0) {
$message = 'Tidak ada pengajuan baru';
} else {
$message = "Berhasil melakukan $countUpdated pengajuan";
}
DB::commit();
return response()->json([
'code' => 201,
'status' => 'success',
'message' => $message,
], 201);
} catch (Throwable $th) {
DB::rollBack();
Log::error("Membimbing: " . $th->getMessage());
Log::error("Membimbing: " . $request->nip);
if ($th instanceof ModelNotFoundException) {
return response()->json([
'code' => 404,
'status' => 'failed',
'message' => 'Kegiatan tidak ditemukan',
], 404);
}
if ($th instanceof AuthorizationException) {
throw new AuthorizationException();
}
if ($th instanceof DecryptException) {
throw new AuthorizationException();
}
return response()->json([
'code' => 500,
'status' => 'failed',
'message' => 'Internal Server Error',
], 500);
}
}
}
@@ -0,0 +1,107 @@
<?php
namespace App\Http\Controllers\Api\Pengajuan\TriDharma;
use App\Http\Controllers\Controller;
use App\Models\DokSiremun\Mengajar;
use App\Models\Verifikator\View\Pegawai;
use Carbon\Carbon;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Throwable;
class MengajarController extends Controller
{
function store(Request $request)
{
$exceptions = [196312201988101001, 196106051986022001];
$start = Carbon::parse('2024-05-20 00:00:00');
$end = Carbon::parse('2024-06-15 23:59:59');
$user = Pegawai::select('id', 'nip', 'nama', 'jenis_pegawai')->where('nip', $request->nip)->orWhere('nip_siakad', $request->nip)->firstOrFail();
if (!in_array($user->nip, $exceptions)) {
if (!now()->isBetween($start, $end)) {
return response()->json([
'code' => 400,
'status' => 'failed',
'message' => 'Pengajuan Sudah Ditutup',
], 400);
}
}
try {
if ($user->jenis_pegawai === 'dosen') {
$token = $request->bearerToken();
$data = Crypt::decrypt($token);
if ($data['nip'] !== $request->nip) {
throw new AuthorizationException();
}
}
$countUpdated = 0;
DB::beginTransaction();
foreach ($request->id as $id) {
$mengajar = Mengajar::where('id', $id)
->where('id_pelaksana', $user->nip)
->firstOrFail();
if ($mengajar->dpna && $mengajar->rps && $mengajar->absen > 0 && $mengajar->status_verifikasi_id === 1) {
$countUpdated++;
$mengajar->logs()->create([
'user_id' => $user->id,
'method' => $request->method(),
'employee_id' => $user->nip,
'employee_name' => $user->name,
'employee_role' => 'Dosen',
'message' => 'Pengajuan baru berhasil ditambahkan',
]);
$mengajar->update([
'status_verifikasi_id' => 3,
'tanggal_pengajuan' => Carbon::today(),
]);
}
}
if ($countUpdated === 0) {
$message = 'Tidak ada pengajuan baru';
} else {
$message = "Berhasil melakukan $countUpdated pengajuan";
}
DB::commit();
return response()->json([
'code' => 201,
'status' => 'success',
'message' => $message,
], 201);
} catch (Throwable $th) {
DB::rollBack();
Log::error("Mengajar: " . $th->getMessage());
Log::error("Mengajar: " . $request->nip);
if ($th instanceof ModelNotFoundException) {
return response()->json([
'code' => 400,
'status' => 'failed',
'message' => 'Kegiatan tidak ditemukan',
], 400);
}
if ($th instanceof AuthorizationException) {
throw new AuthorizationException();
}
if ($th instanceof DecryptException) {
throw new AuthorizationException();
}
return response()->json([
'code' => 500,
'status' => 'failed',
'message' => 'Internal Server Error',
], 500);
}
}
}
@@ -0,0 +1,102 @@
<?php
namespace App\Http\Controllers\Api\Pengajuan\TriDharma;
use App\Http\Controllers\Controller;
use App\Models\DokSiremun\Menguji;
use App\Models\Verifikator\View\Pegawai;
use Carbon\Carbon;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Crypt;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Throwable;
class MengujiController extends Controller
{
function store(Request $request)
{
$start = Carbon::parse('2024-05-20 00:00:00');
$end = Carbon::parse('2024-06-15 23:59:59');
if (!now()->isBetween($start, $end)) {
return response()->json([
'code' => 400,
'status' => 'failed',
'message' => 'Pengajuan Sudah Ditutup',
], 400);
}
try {
$user = Pegawai::select('id', 'nip', 'nama', 'jenis_pegawai')->where('nip', $request->nip)->orWhere('nip_siakad', $request->nip)->firstOrFail();
$countUpdated = 0;
if ($user->jenis_pegawai === 'dosen') {
$token = $request->bearerToken();
$data = Crypt::decrypt($token);
if ($data['nip'] !== $request->nip) {
throw new AuthorizationException();
}
}
DB::beginTransaction();
foreach ($request->id as $id) {
$menguji = Menguji::where('id', $id)
->where('id_pelaksana', $user->nip)
->firstOrFail();
if ($menguji->status_verifikasi_id === 1 && $menguji->status_syarat === 'COMPLETE') {
$countUpdated++;
$menguji->update([
'status_verifikasi_id' => 3,
'tanggal_pengajuan' => Carbon::today(),
]);
$menguji->logs()->create([
'user_id' => $user->id,
'method' => $request->method(),
'employee_id' => $user->nip,
'employee_name' => $user->name,
'employee_role' => ucwords($user->jenis_pegawai),
'message' => 'Pengajuan baru berhasil ditambahkan',
]);
}
}
if ($countUpdated === 0) {
$message = 'Tidak ada pengajuan baru';
} else {
$message = "Berhasil melakukan $countUpdated pengajuan";
}
DB::commit();
return response()->json([
'code' => 201,
'status' => 'success',
'message' => $message,
], 201);
} catch (Throwable $th) {
DB::rollBack();
Log::error("Menguji: " . $th->getMessage());
Log::error("Menguji: " . $request->nip);
if ($th instanceof ModelNotFoundException) {
return response()->json([
'code' => 404,
'status' => 'failed',
'message' => 'Kegiatan tidak ditemukan',
], 404);
}
if ($th instanceof AuthorizationException) {
throw new AuthorizationException();
}
if ($th instanceof DecryptException) {
throw new AuthorizationException();
}
return response()->json([
'code' => 500,
'status' => 'failed',
'message' => 'Internal Server Error',
], 500);
}
}
}
@@ -0,0 +1,91 @@
<?php
namespace App\Http\Controllers\Api\Pengajuan\TriDharma;
use App\Http\Controllers\Controller;
use App\Models\DokSiremun\Syarat;
use App\Models\Verifikator\View\Pegawai;
use App\Services\KegiatanService;
use Carbon\Carbon;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
use Throwable;
class ModulController extends Controller
{
function store(Request $request)
{
$start = Carbon::parse('2024-05-20 00:00:00');
$end = Carbon::parse('2024-06-15 23:59:59');
if (!now()->isBetween($start, $end)) {
return response()->json([
'code' => 400,
'status' => 'failed',
'message' => 'Pengajuan Sudah Ditutup',
], 400);
}
try {
$pegawai = Pegawai::where('nip', $request->nip)->orWhere('nip_siakad', $request->nip)->firstOrFail();
$kegiatanService = new KegiatanService();
$countUpdated = 0;
if (gettype($request->id) === 'array') {
foreach ($request->id as $id) {
$syarat = Syarat::with('rubrik')->select('id_kegiatan', 'id_kategori', 'id_rubrik', 'status_verifikasi_id')->find($id);
if (!$syarat) continue;
if ($syarat->rubrik->syarats->where('nama', 'laporan kegiatan')->count() > 0) continue;
if ($syarat->status_verifikasi_id == 2 && $syarat->rubrik->syarats->where('nama', 'laporan kegiatan')->count() === 0) {
Log::info('Pengajuan Ulang:' . $id);
continue;
};
if ($syarat->status_verifikasi_id !== 1 && in_array($syarat->id_kategori, [1, 2, 3, 5, 6])) continue;
try {
$kegiatanService->pengajuan($id, $request->method());
$countUpdated++;
} catch (Throwable $th) {
continue;
}
}
} else {
$syarat = Syarat::select('id_rubrik', 'status_verifikasi_id')->find($request->id);
if ($syarat->status_verifikasi_id == 1) {
$kegiatanService->pengajuan($request->id, $request->method());
$countUpdated++;
}
}
return response()->json([
'status' => 'success',
'code' => 200,
'message' => "Berhasil mengajukan $countUpdated kegiatan",
], 200);
} catch (Throwable $th) {
DB::rollBack();
Log::error("Lainnya: " . $th->getMessage());
Log::error("Lainnya: " . $request->nip);
if ($th instanceof ModelNotFoundException) {
return response()->json([
'code' => 404,
'status' => 'failed',
'message' => 'Kegiatan tidak ditemukan',
], 404);
}
if ($th instanceof AuthorizationException) {
throw new AuthorizationException();
}
if ($th instanceof DecryptException) {
throw new AuthorizationException();
}
return response()->json([
'code' => 500,
'status' => 'failed',
'message' => 'Server Error',
], 500);
}
}
}