Skip to content

Commit

Permalink
add cabang konsep
Browse files Browse the repository at this point in the history
  • Loading branch information
punkestu committed Nov 25, 2024
1 parent 2e640f7 commit 2af38fd
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 8 deletions.
5 changes: 3 additions & 2 deletions app/Http/Controllers/PersonelController.php
Original file line number Diff line number Diff line change
Expand Up @@ -328,7 +328,7 @@ public function togglePensiun($id)

public function konsep()
{
$konseps = Konsep::all();
$konseps = Konsep::where('cabang_id', null)->get();
return view('personel.konsep', ["konseps" => $konseps]);
}

Expand All @@ -352,7 +352,8 @@ public function uploadKonsep(Request $request)

Konsep::create([
"name" => $request->name,
"berkas" => $berkas
"berkas" => $berkas,
"caban_id" => null
]);

return redirect()->route("konsep");
Expand Down
33 changes: 33 additions & 0 deletions app/Http/Controllers/Rotasi/CabangController.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use App\Http\Controllers\Controller;
use App\Models\Cabang;
use App\Models\Kelas;
use App\Models\Konsep;
use Illuminate\Support\Facades\DB;

class CabangController extends Controller
Expand Down Expand Up @@ -249,4 +250,36 @@ public function delete($id)
$cabang->delete();
return redirect()->route("rotasi.cabang")->with('success', 'Cabang berhasil dihapus');
}

public function konsep($id)
{
$konseps = Konsep::where('cabang_id', $id)->get();
return view('rotasi.cabang.konsep', ['konseps' => $konseps, 'cabang_id' => $id]);
}

public function uploadKonsep($id, Request $request)
{
$request->validate([
'name' => 'required',
'berkas' => 'file|mimes:pdf|max:2048',
]);

if ($request->hasFile("berkas")) {
$file = $request->file('berkas');
$fileName = time() . '_' . $file->getClientOriginalName();
$berkas = "/storage/" . $file->storeAs('files', $fileName, 'public');
} else {
$request->validate([
"url" => "required"
]);
$berkas = $request->url;
}

$konsep = new Konsep();
$konsep->name = $request->name;
$konsep->cabang_id = $id;
$konsep->berkas = $berkas;
$konsep->save();
return redirect()->back()->with('success', 'Konsep berhasil ditambahkan');
}
}
3 changes: 2 additions & 1 deletion app/Models/Konsep.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class Konsep extends Model
use HasFactory;
protected $fillable = [
"name",
"berkas"
"berkas",
"cabang_id",
];
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('konseps', function (Blueprint $table) {
$table->foreignId('cabang_id')->nullable()->after('id')->constrained('cabangs')->onDelete('cascade');
});
}

/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('konseps', function (Blueprint $table) {
$table->dropForeign(['cabang_id']);
$table->dropColumn('cabang_id');
});
}
};
17 changes: 12 additions & 5 deletions resources/views/rotasi/cabang/detail.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@ class="p-2 break-all w-full font-sans">{{ $cabang->alamat }}</pre>
<a href="/rotasi/cabang/input/{{ $cabang->id }}"
class="bg-[#003285] hover:bg-white text-white hover:text-black border-2 border-[#003285] duration-200 w-full text-center p-2 rounded-lg font-semibold mb-2">Update</a>
<a href="/rotasi/cabang/input/{{ $cabang->id }}/delete"
class="bg-white hover:bg-[#003285] text-black hover:text-white border-2 border-[#003285] duration-200 w-full text-center p-2 rounded-lg font-semibold">Hapus
class="bg-white hover:bg-[#003285] text-black hover:text-white border-2 border-[#003285] duration-200 w-full text-center p-2 rounded-lg font-semibold mb-2">Hapus
Cabang</a>
<a href="/rotasi/cabang/konsep/{{ $cabang->id }}"
class="bg-white hover:bg-[#003285] text-black hover:text-white border-2 border-[#003285] duration-200 w-full text-center p-2 rounded-lg font-semibold">Konsep</a>
@endcan
</aside>
<aside class="flex-grow col-span-2 grid md:grid-cols-2 md:grid-rows-1 gap-4">
Expand Down Expand Up @@ -135,15 +137,20 @@ class="{{ $skalaPersonelATC >= 10 ? 'w-12 h-12' : 'w-8 h-8' }} aspect-square bg-
<h2 class="font-bold text-xl text-center">Prediksi Personel {{ date('Y') + 1 }}</h2>
<hr class="border-[1px] my-1">
<p class="font-medium ms-4 text-center">
ATC {{ $cabang->jumlah_personel - count($cabang->personelPensiunATC) + count($cabang->personelMagangATC) }} Orang</p>
ATC
{{ $cabang->jumlah_personel - count($cabang->personelPensiunATC) + count($cabang->personelMagangATC) }}
Orang</p>
<p class="font-medium ms-4 text-center">
ACO {{ $cabang->jumlah_personel_aco - count($cabang->personelPensiunACO) + count($cabang->personelMagangACO) }}
ACO
{{ $cabang->jumlah_personel_aco - count($cabang->personelPensiunACO) + count($cabang->personelMagangACO) }}
Orang</p>
<p class="font-medium ms-4 text-center">
AIS {{ $cabang->jumlah_personel_ais - count($cabang->personelPensiunAIS) + count($cabang->personelMagangAIS) }}
AIS
{{ $cabang->jumlah_personel_ais - count($cabang->personelPensiunAIS) + count($cabang->personelMagangAIS) }}
Orang</p>
<p class="font-medium ms-4 text-center">
ATFM {{ $cabang->jumlah_personel_atfm - count($cabang->personelPensiunATFM) + count($cabang->personelMagangATFM) }}
ATFM
{{ $cabang->jumlah_personel_atfm - count($cabang->personelPensiunATFM) + count($cabang->personelMagangATFM) }}
Orang</p>
<p class="font-medium ms-4 text-center">
TAPOR
Expand Down
117 changes: 117 additions & 0 deletions resources/views/rotasi/cabang/konsep.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">

<head>
@include('components/head')
<title>Air Mutasi | Personel</title>
</head>

<body class="font-sans tracking-wider text-lg">
@include('components/header', ['static' => true])
@include('components.modal-component')

<div id="import-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 -->
<form method="POST" action="/personel/import" enctype="multipart/form-data"
class="relative bg-white rounded-lg shadow ">
@csrf
<!-- 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 ">
Import Data Personel
</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="import-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 class="p-4 md:p-5 space-y-4">
<input type="file" name="sheet" id="sheet" required>
</div>
<!-- Modal footer -->
<div class="flex items-center p-4 md:p-5 border-t border-gray-200 rounded-b">
<button data-modal-hide="import-modal" type="submit"
class="text-white bg-blue-700 hover:bg-blue-800 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-lg text-sm px-5 py-2.5 text-center">Kirim</button>
<button data-modal-hide="import-modal" type="button"
class="py-2.5 px-5 ms-3 text-sm font-medium text-gray-900 focus:outline-none bg-white rounded-lg border border-gray-200 hover:bg-gray-100 hover:text-blue-700 focus:z-10 focus:ring-4 focus:ring-gray-100">Batal</button>
</div>
</form>
</div>
</div>
<main class="min-h-screen">
<form action="" method="POST" enctype="multipart/form-data" class="flex flex-col p-4">
@csrf
<div class="flex flex-col gap-2 border-2 p-2 rounded-md">
<label for="name">Nama</label>
<input type="text" name="name" id="name"
class="resize-none flex-grow p-2 border-2 border-slate-400 rounded-s-md"
placeholder="Nama Berkas ...">
<label for="url">Berkas</label>
<div class="flex w-full">
<input type="text" name="url" id="url"
class="resize-none flex-grow p-2 border-2 border-slate-400 rounded-s-md"
placeholder="URL Berkas">
<button id="url_set" type="button"
class="bg-[#003285] opacity-80 hover:opacity-100 duration-200 text-white p-2 rounded-e-lg font-semibold">Set</button>
</div>
<p class="text-center">atau</p>
<label
class="bg-[#003285] opacity-80 hover:opacity-100 duration-200 text-white px-2 py-1 rounded-md font-medium hover:cursor-pointer text-center">
<span id="berkas_label" class="text-center">Upload Berkas (max 2MB)</span>
<input type="file" name="berkas" id="berkas" class="h-0 w-0" accept=".pdf,.jpeg,.png">
</label>
<p id="errors" class="text-center text-red-500 text-sm hidden"></p>
<button
class="bg-[#003285] opacity-80 hover:opacity-100 duration-200 text-white px-2 py-1 rounded-md font-medium hover:cursor-pointer text-center">Kirim</button>
</div>
</form>
<div class="flex flex-col px-4 py-2 gap-2">
@foreach ($konseps as $konsep)
<div class="w-full">
<a href="{{$konsep->berkas}}" class="w-full flex gap-2" target="_blank">{{ $konsep->name }} <svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true"
xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="none"
viewBox="0 0 24 24">
<path stroke="currentColor" stroke-linecap="round" stroke-linejoin="round" stroke-width="2"
d="M18 14v4.833A1.166 1.166 0 0 1 16.833 20H5.167A1.167 1.167 0 0 1 4 18.833V7.167A1.166 1.166 0 0 1 5.167 6h4.618m4.447-2H20v5.768m-7.889 2.121 7.778-7.778" />
</svg>
</a>
<iframe class="w-full h-[60vh]" src="{{ $konsep->berkas }}" frameborder="0"></iframe>
</div>
@endforeach
</div>
</main>
@include('components.footer')
<script src="/script/nav.js"></script>
<script src="/script/chatbot.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/flowbite.min.js"></script>
<script>
document
.querySelector(`#url_set`)
.addEventListener("click", function() {
document.querySelector(`#berkas`).value = "";
document.querySelector(`#url_set`).innerHTML = "✅️ Ubah";
document.querySelector(`#berkas_label`).innerHTML = "Upload Berkas (max 2MB)";
});
document
.querySelector(`#berkas`)
.addEventListener("change", function() {
var file = this.files[0];
if (!file) return;
document.querySelector(`#url`).value = "";
document.querySelector(`#url_set`).innerHTML = "Set";
document.querySelector(`#berkas_label`).innerHTML = "✅️ Ubah";
});
</script>
</body>

</html>
2 changes: 2 additions & 0 deletions routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@

Route::get('/', [RotasiCabangController::class, 'index'])->name('rotasi.cabang');
Route::get("/{id}", [RotasiCabangController::class, 'detail']);
Route::get('/konsep/{id}', [RotasiCabangController::class, 'konsep']);
Route::post('/konsep/{id}', [RotasiCabangController::class, 'uploadKonsep']);
});
Route::group(['prefix' => 'pengajuan'], function () {
Route::get('/', [RotasiPengajuanController::class, 'inputView']);
Expand Down

0 comments on commit 2af38fd

Please sign in to comment.