Skip to content

Commit

Permalink
add pengajuan on personel cabang
Browse files Browse the repository at this point in the history
  • Loading branch information
punkestu committed Jan 3, 2025
1 parent 8f195c1 commit c172fa6
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 11 deletions.
46 changes: 35 additions & 11 deletions app/Http/Controllers/PersonelController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ public function index()
$cabang = request()->get('cabang');
if ($nik == "" && $name == "" && $cabang == "") {
$personels = Personel::with(['cabang', 'lokasiCabang', 'lokasiInduk', 'pengajuan_pindah' => [
'lokasiAwal',
'lokasiTujuan',
]])->limit($limit)->offset($page * $limit)->get();
'lokasiAwal',
'lokasiTujuan',
]])->limit($limit)->offset($page * $limit)->get();
$cabangs = Cabang::all();
if (!$cabangs) abort(404);
return view('personel.index', [
Expand Down Expand Up @@ -86,49 +86,70 @@ public function cabang(Request $request, $id)
})->toArray();
if ($request->tab === 'ACO') {
$cabang = Cabang::with(['personels' => function ($query) use ($limit, $page, $jabatan) {
$query->with(['kompetensis'])->where(function ($query) use ($jabatan) {
$query->with(['kompetensis', 'pengajuan_pindah' => [
'lokasiAwal',
'lokasiTujuan',
]])->where(function ($query) use ($jabatan) {
//$query->where('posisi', 'AERONAUTICAL COMMUNICATION OFFICER')->orWhere('posisi', 'ACO');
$query->whereIn('posisi', $jabatan['ACO'] ?? [])->orWhere('posisi', 'LIKE', 'ACO%');
})->limit($limit)->offset($page * $limit);
}])->find($id);
} else if ($request->tab === 'AIS') {
$cabang = Cabang::with(['personels' => function ($query) use ($limit, $page, $jabatan) {
$query->with(['kompetensis'])->where(function ($query) use ($jabatan) {
$query->with(['kompetensis', 'pengajuan_pindah' => [
'lokasiAwal',
'lokasiTujuan',
]])->where(function ($query) use ($jabatan) {
//$query->where('posisi', 'AIS')->orWhere('posisi', 'AERONAUTICAL INFORMATION SERVICE')->orWhere('posisi', 'LIKE', 'AIS%');
$query->whereIn('posisi', $jabatan['AIS'] ?? [])->orWhere('posisi', 'LIKE', 'AIS%');
})->limit($limit)->offset($page * $limit);
}])->find($id);
} else if ($request->tab === 'ATFM') {
$cabang = Cabang::with(['personels' => function ($query) use ($limit, $page, $jabatan) {
$query->with(['kompetensis'])->where(function ($query) use ($jabatan) {
$query->with(['kompetensis', 'pengajuan_pindah' => [
'lokasiAwal',
'lokasiTujuan',
]])->where(function ($query) use ($jabatan) {
//$query->where('posisi', 'ATFM')->orWhere('posisi', 'AIR TRAFFIC FLOW MANAGEMENT')->orWhere('posisi', 'STAF ATFM');
$query->whereIn('posisi', $jabatan['ATFM'] ?? [])->orWhere('posisi', 'LIKE', 'ATFM%');
})->limit($limit)->offset($page * $limit);
}])->find($id);
} else if ($request->tab === 'TAPOR') {
$cabang = Cabang::with(['personels' => function ($query) use ($limit, $page, $jabatan) {
$query->with(['kompetensis'])->where(function ($query) use ($jabatan) {
$query->with(['kompetensis', 'pengajuan_pindah' => [
'lokasiAwal',
'lokasiTujuan',
]])->where(function ($query) use ($jabatan) {
//$query->where('posisi', 'TAPOR')->orWhere('posisi', 'STAF PELAPORAN DATA');
$query->whereIn('posisi', $jabatan['TAPOR'] ?? [])->orWhere('posisi', 'LIKE', 'TAPOR%');
})->limit($limit)->offset($page * $limit);
}])->find($id);
} else if ($request->tab === 'ATSSystem') {
$cabang = Cabang::with(['personels' => function ($query) use ($limit, $page, $jabatan) {
$query->with(['kompetensis'])->where(function ($query) use ($jabatan) {
$query->with(['kompetensis', 'pengajuan_pindah' => [
'lokasiAwal',
'lokasiTujuan',
]])->where(function ($query) use ($jabatan) {
//$query->where('posisi', 'ATSSystem')->orWhere('posisi', 'AIR TRAFFIC SERVICES SYSTEM')->orWhere('posisi', 'SPESIALIS ATS SYSTEM');
$query->whereIn('posisi', $jabatan['ATSSystem'] ?? [])->orWhere('posisi', 'LIKE', 'ATSSystem%');
})->limit($limit)->offset($page * $limit);
}])->find($id);
} else if ($request->tab === 'ATC') {
$cabang = Cabang::with(['personels' => function ($query) use ($limit, $page, $jabatan) {
$query->with(['kompetensis'])->where(function ($query) use ($jabatan) {
$query->with(['kompetensis', 'pengajuan_pindah' => [
'lokasiAwal',
'lokasiTujuan',
]])->where(function ($query) use ($jabatan) {
//$query->where('posisi', 'LIKE', 'ATC%')->orWhere('posisi', 'AIR TRAFFIC CONTROLLER');
$query->whereIn('posisi', $jabatan['ATC'] ?? [])->orWhere('posisi', 'LIKE', 'ATC%');
})->limit($limit)->offset($page * $limit);
}])->find($id);
} else {
$cabang = Cabang::with(['personels' => function ($query) use ($limit, $page, $jabatan) {
$query->with(['kompetensis'])->where(function ($query) use ($jabatan) {
$query->with(['kompetensis', 'pengajuan_pindah' => [
'lokasiAwal',
'lokasiTujuan',
]])->where(function ($query) use ($jabatan) {
//$query->whereNotIn('posisi', ['ATC (APS)', 'ACO', 'AIS', 'ATFM', 'TAPOR', 'ATSSystem', 'AERONAUTICAL COMMUNICATION OFFICER', 'AERONAUTICAL INFORMATION SERVICE', 'AIR TRAFFIC FLOW MANAGEMENT', 'TOWER APPROACH', 'STAF PELAPORAN DATA', 'AIR TRAFFIC SERVICES SYSTEM', 'AIR TRAFFIC CONTROLLER'])->whereNot('posisi', 'LIKE', 'ATC%')->whereNot('posisi', 'LIKE', 'AIS%');
$query->whereNotIn('posisi', $jabatan['ACO'] ?? [])->whereNotIn('posisi', $jabatan['AIS'] ?? [])->whereNotIn('posisi', $jabatan['ATFM'] ?? [])->whereNotIn('posisi', $jabatan['TAPOR'] ?? [])->whereNotIn('posisi', $jabatan['ATSSystem'] ?? [])->whereNotIn('posisi', $jabatan['ATC'] ?? [])->whereNot('posisi', 'LIKE', 'ATC%')->whereNot('posisi', 'LIKE', 'AIS%')->whereNot('posisi', 'LIKE', 'ATFM%')->whereNot('posisi', 'LIKE', 'TAPOR%')->whereNot('posisi', 'LIKE', 'ATSSystem%')->whereNot('posisi', 'LIKE', 'ACO%');
})->limit($limit)->offset($page * $limit);
Expand All @@ -139,7 +160,10 @@ public function cabang(Request $request, $id)
if ($request->tab != "AIS") $cabang->personels = [];
else {
$cabang = Cabang::with(['personels' => function ($query) use ($limit, $page) {
$query->limit($limit)->offset($page * $limit);
$query->with(['pengajuan_pindah' => [
'lokasiAwal',
'lokasiTujuan',
]])->limit($limit)->offset($page * $limit);
}])->find($id);
}
}
Expand Down
55 changes: 55 additions & 0 deletions resources/views/personel/cabang.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,34 @@ class="flex flex-col gap-2" enctype="multipart/form-data">
class="text-center bg-[#7186F3] hover:bg-[#435EEF] duration-200 text-white px-4 py-2 rounded-lg font-semibold flex-grow">Export</button>
</form>
</div> --}}
<div id="detail-pindah-modal" tabindex="-1" aria-hidden="true"
class="hidden overflow-y-auto overflow-x-hidden fixed top-0 right-0 left-0 z-50 justify-center items-center w-full md:inset-0 h-[calc(100%-1rem)] max-h-full">
<div class="relative p-4 w-full max-w-2xl max-h-full">
<!-- Modal content -->
<div class="relative bg-white rounded-lg shadow ">
<!-- Modal header -->
<div class="flex items-center justify-between p-4 md:p-5 border-b rounded-t ">
<h3 class="text-xl font-semibold text-gray-900 ">
Detail Data Pindah
</h3>
<button type="button"
class="text-gray-400 bg-transparent hover:bg-gray-200 hover:text-gray-900 rounded-lg text-sm w-8 h-8 ms-auto inline-flex justify-center items-center"
data-modal-hide="detail-pindah-modal">
<svg class="w-3 h-3" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none"
viewBox="0 0 14 14">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
stroke-width="2" d="m1 1 6 6m0 0 6 6M7 7l6-6M7 7l-6 6" />
</svg>
<span class="sr-only">Close modal</span>
</button>
</div>
<!-- Modal body -->
<div id="body" class="p-4 md:p-5 space-y-4">

</div>
</div>
</div>
</div>
<section>
<div class="bg-[#FFB72D] p-8">
<h1 class="text-center font-bold text-xl">DATA PERSONIL OPERASI <br>
Expand Down Expand Up @@ -143,6 +171,9 @@ class="sticky top-0 text-xs text-gray-700 uppercase bg-gray-50 dark:bg-gray-700
<th scope="col" class="px-6 py-3">
Job Text
</th>
<th scope="col" class="px-6 py-3">
Pengajuan Pindah
</th>
</tr>
</thead>
<tbody>
Expand Down Expand Up @@ -235,6 +266,15 @@ class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
<td class="px-6 py-4">
{{ $personel->job_text }}
</td>
<td class="px-6 py-4">
@if (count($personel->pengajuan_pindah) > 0)
<button data-modal-target="detail-pindah-modal"
data-modal-toggle="detail-pindah-modal"
onclick='setPindahDetail(@json($personel->pengajuan_pindah))'>✅</button>
@else
-
@endif
</td>
</tr>
@endforeach
</tbody>
Expand All @@ -251,6 +291,20 @@ class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
@include('components.footer')
<script src="/script/nav.js"></script>
<script>
function setPindahDetail(dataPindah) {
const body = document.querySelector('#detail-pindah-modal #body');
body.innerHTML = '';
dataPindah.forEach(data => {
const div = `
<div class="flex gap-2 border mb-2 px-2 py-1">
<span>Dari: ${data.lokasi_awal.nama}</span>
<span>Ke: ${data.lokasi_tujuan.nama}</span>
<span>Diajukan: ${data.created_at}</span>
</div>
`;
body.innerHTML += div;
});
}
var activepopup = null;
const aksiPopup = document.querySelectorAll('.personels-action');
aksiPopup.forEach((element) => {
Expand All @@ -273,6 +327,7 @@ class="px-6 py-4 font-medium text-gray-900 whitespace-nowrap dark:text-white">
});
</script>
<script src="/script/chatbot.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/flowbite.min.js"></script>
</body>

</html>

0 comments on commit c172fa6

Please sign in to comment.