lkpdepartment page

parent 8a9ff11e
@extends('ui::layouts.app')
@section('content')
<div class="ui segments">
<div class="ui segment">
<p style="font-weight: bold; margin: 0;">Tambah Jabatan Baru</p>
</div>
<div class="ui secondary segment">
<div class="ui segment">
<form action="{{ route('mileage::department.store') }}" method="POST" class="ui form @if($errors->any()) error @endif">
@csrf
@if ($errors->any())
<div class="ui error message">
<i class="close icon"></i>
<div class="header">Ralat Input</div>
<ul class="list">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<div class="field required @error('code') error @enderror">
<label>Kod Jabatan</label>
<input type="text" name="code" value="{{ old('code') }}" placeholder="Contoh: FIN, TMS, PSS" required>
</div>
<div class="field required @error('description') error @enderror">
<label>Deskripsi</label>
<input type="text" name="description" value="{{ old('description') }}" placeholder="Contoh: Professional & Software Services" required>
</div>
<div class="field required @error('status') error @enderror">
<label>Status</label>
<select class="ui dropdown" name="status" required>
<option value="1" {{ old('status', '1') == '1' ? 'selected' : '' }}>Aktif</option>
<option value="0" {{ old('status') === '0' ? 'selected' : '' }}>Tidak Aktif</option>
</select>
</div>
<div style="margin-top: 20px;">
<button type="submit" class="ui button primary">
<i class="save icon"></i> Simpan
</button>
<a href="{{ route('mileage::department.index') }}" class="ui button basic">
Batal
</a>
</div>
</form>
</div>
</div>
</div>
@endsection
\ No newline at end of file
@extends('ui::layouts.app')
@section('content')
<div class="ui segments">
<div class="ui segment">
<p style="font-weight: bold; margin: 0;">Kemaskini Jabatan: {{ $department->code }}</p>
</div>
<div class="ui secondary segment">
<div class="ui segment">
<form action="{{ route('mileage::department.update', $department->id) }}" method="POST" class="ui form @if($errors->any()) error @endif">
@csrf
@method('PUT')
@if ($errors->any())
<div class="ui error message">
<i class="close icon"></i>
<div class="header">Ralat Input</div>
<ul class="list">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<div class="field required @error('code') error @enderror">
<label>Kod Jabatan</label>
<input type="text" name="code" value="{{ old('code', $department->code) }}" required>
</div>
<div class="field required @error('description') error @enderror">
<label>Keterangan / Deskripsi</label>
<input type="text" name="description" value="{{ old('description', $department->description) }}" required>
</div>
<div class="field required @error('status') error @enderror">
<label>Status</label>
<select class="ui dropdown" name="status" required>
<option value="1" {{ old('status', $department->status) == 1 ? 'selected' : '' }}>Aktif</option>
<option value="0" {{ old('status', $department->status) == 0 && old('status', $department->status) !== null ? 'selected' : '' }}>Tidak Aktif</option>
</select>
</div>
<div style="margin-top: 20px;">
<button type="submit" class="ui button primary">
<i class="save icon"></i> Kemaskini
</button>
<a href="{{ route('mileage::department.index') }}" class="ui button basic">
Batal
</a>
</div>
</form>
</div>
</div>
</div>
@endsection
\ No newline at end of file
@extends('ui::layouts.app')
@section('content')
@if(session('success'))
<div class="ui positive message">
<i class="close icon"></i>
<div class="header">Kejayaan</div>
<p>{{ session('success') }}</p>
</div>
@endif
<div class="ui segments">
{{-- Header Card --}}
<div class="ui segment">
<p>Senarai Jabatan</p>
</div>
{{-- Body Container --}}
<div class="ui secondary segment">
<div class="ui segment">
<div style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px;">
<p style="font-weight: bold; margin: 0;">Senarai Jabatan (LKP Department)</p>
<a href="{{ route('mileage::department.create') }}" class="ui button primary small">
+ Tambah Jabatan
</a>
</div>
<table class="ui table celled" id="department-table" style="width:100%;">
<thead>
<tr>
<th>Kod</th>
<th>Keterangan</th>
<th>Status</th>
<th width="150px">Tindakan</th>
</tr>
</thead>
<tbody>
@forelse($departments as $dept)
<tr>
<td>{{ $dept->code }}</td>
<td>{{ $dept->description }}</td>
<td>
@if($dept->status == '1' || $dept->status === 'Aktif')
<span class="ui green label small">Aktif</span>
@else
<span class="ui red label small">Tidak Aktif</span>
@endif
</td>
<td>
<div class="ui small icon buttons">
<a href="{{ route('mileage::department.show', $dept->id) }}" class="ui button basic" title="Lihat"><i class="eye icon"></i></a>
<a href="{{ route('mileage::department.edit', $dept->id) }}" class="ui button primary" title="Kemaskini"><i class="edit icon"></i></a>
<form action="{{ route('mileage::department.destroy', $dept->id) }}" method="POST" style="display:inline;" onsubmit="return confirm('Adakah anda pasti untuk memadam Jabatan ini?');">
@csrf
@method('DELETE')
<button type="submit" class="ui button red" title="Padam"><i class="trash icon"></i></button>
</form>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="4" class="center aligned">Tiada rekod jabatan.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</div>
</div>
@endsection
\ No newline at end of file
@extends('ui::layouts.app')
@section('content')
<div class="ui segments">
<div class="ui segment">
<p style="font-weight: bold; margin: 0;">Maklumat Jabatan</p>
</div>
<div class="ui secondary segment">
<div class="ui segment">
<table class="ui definition table">
<tbody>
<tr>
<td class="two wide column">ID Jabatan</td>
<td>{{ $department->id }}</td>
</tr>
<tr>
<td>Kod Jabatan</td>
<td><strong>{{ $department->code }}</strong></td>
</tr>
<tr>
<td>Keterangan</td>
<td>{{ $department->description }}</td>
</tr>
<tr>
<td>Status</td>
<td>
@if($department->status === 'Aktif' || $department->status == '1')
<span class="ui green label small">Aktif</span>
@else
<span class="ui red label small">Tidak Aktif</span>
@endif
</td>
</tr>
</tbody>
</table>
<div style="margin-top: 20px;">
<a href="{{ route('mileage::department.edit', $department->id) }}" class="ui button primary">
<i class="edit icon"></i> Kemaskini
</a>
<a href="{{ route('mileage::department.index') }}" class="ui button basic">
Kembali
</a>
</div>
</div>
</div>
</div>
@endsection
\ No newline at end of file
......@@ -9,6 +9,7 @@
use Portal\Mileage\Http\Controllers\BODController;
use Portal\Mileage\Http\Controllers\HRController;
use Portal\Mileage\Http\Controllers\FinanceController;
use Portal\Mileage\Http\Controllers\DepartmentController;
Route::group(
[
......@@ -64,7 +65,6 @@ function () {
// Route::post('/{id}/bayar', [FinanceController::class, 'bayar'])->name('.bayar');
});
// HOD
Route::prefix('HOD')->name('HOD')->group(function () {
Route::get('/dashboard', [HODController::class, 'index'])->name('.index');
......@@ -74,7 +74,6 @@ function () {
Route::get('/history', [HODController::class, 'history'])->name('.history');
});
// BOD
Route::prefix('BOD')->name('BOD')->group(function () {
Route::get('/dashboard', [BODController::class, 'index'])->name('.index');
......@@ -84,7 +83,6 @@ function () {
Route::get('/history', [BODController::class, 'history'])->name('.history');
});
// HR
Route::prefix('HR')->name('HR')->group(function () {
Route::get('/dashboard', [HRController::class, 'index'])->name('.index');
......@@ -114,7 +112,15 @@ function () {
// Tetapan
Route::get('tetapan', ['uses' => 'TetapanController@index', 'as' => 'mileage.tetapan']);
}
// Department
Route::get('department', [DepartmentController::class, 'index'])->name('department.index');
Route::get('department/create', [DepartmentController::class, 'create'])->name('department.create');
Route::post('department', [DepartmentController::class, 'store'])->name('department.store');
Route::get('department/{id}', [DepartmentController::class, 'show'])->name('department.show');
Route::get('department/{id}/edit', [DepartmentController::class, 'edit'])->name('department.edit');
Route::put('department/{id}', [DepartmentController::class, 'update'])->name('department.update');
Route::delete('department/{id}', [DepartmentController::class, 'destroy'])->name('department.destroy');
}
);
// Guest group (currently unused)
......@@ -127,4 +133,4 @@ function () {
function () {
//
}
);
);
\ No newline at end of file
<?php
namespace Portal\Mileage\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Portal\Mileage\Model\LkpDepartment;
class DepartmentController extends Controller
{
/**
* Display a listing of departments.
*/
public function index(Request $request)
{
$departments = LkpDepartment::latest('id')->get();
return view('mileage::lkpdepartment.index', compact('departments'));
}
/**
* Show the form for creating a new department.
*/
public function create()
{
return view('mileage::lkpdepartment.create');
}
/**
* Store a newly created department in storage.
*/
public function store(Request $request)
{
$request->validate([
'code' => 'required|string|max:50',
'description' => 'required|string|max:255',
'status' => 'required|in:0,1',
]);
LkpDepartment::create([
'code' => $request->code,
'description' => $request->description,
'status' => $request->status,
'created_by' => auth()->id(),
'updated_by' => auth()->id(),
]);
return redirect()->route('mileage::department.index')->with('success', 'Jabatan berjaya ditambah.');
}
/**
* Display the specified department.
*/
public function show($id)
{
$department = LkpDepartment::findOrFail($id);
return view('mileage::lkpdepartment.show', compact('department'));
}
/**
* Show the form for editing the specified department.
*/
public function edit($id)
{
$department = LkpDepartment::findOrFail($id);
return view('mileage::lkpdepartment.edit', compact('department'));
}
/**
* Update the specified department in storage.
*/
public function update(Request $request, $id)
{
$request->validate([
'code' => 'required|string|max:50',
'description' => 'required|string|max:255',
'status' => 'required|in:0,1',
]);
$department = LkpDepartment::findOrFail($id);
$department->update([
'code' => $request->code,
'description' => $request->description,
'status' => $request->status,
'updated_by' => auth()->id(),
]);
return redirect()->route('mileage::department.index')->with('success', 'Jabatan berjaya dikemaskini.');
}
/**
* Remove the specified department from storage.
*/
public function destroy($id)
{
$department = LkpDepartment::findOrFail($id);
$department->delete();
return redirect()->route('mileage::department.index')->with('success', 'Jabatan berjaya dipadam.');
}
}
\ No newline at end of file
......@@ -13,7 +13,7 @@ class LkpDepartment extends Model
*/
protected $table = 'lkp_department';
protected $primaryKey = 'id';
public $timestamps = false;
public $timestamps = true;
/**
* The attributes that are mass assignable.
......@@ -23,7 +23,10 @@ class LkpDepartment extends Model
protected $fillable = [
'name',
'code',
'description'
'description',
'status',
'created_by',
'updated_by',
];
/**
......@@ -33,4 +36,4 @@ public function staff()
{
return $this->hasMany(StaffInfo::class, 'fk_lkp_department', 'id');
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment