Lookup ot task

parent 7a6b8b75
@extends('ui::layouts.app')
@section('content')
<div class="ui segments">
<div class="ui segment">
<p>Tambah Tugasan OT Baru</p>
</div>
<div class="ui secondary segment">
<div class="ui segment">
<form action="{{ route('overtime::ot-task.store') }}" method="POST" class="ui form">
@csrf
<div class="field @error('task_name') error @enderror">
<label>Nama Tugasan <span style="color:red;">*</span></label>
<input type="text" name="task_name" value="{{ old('task_name') }}" placeholder="Contoh: Create, Update, Submit" required>
@error('task_name')
<div class="ui basic red pointing prompt label">{{ $message }}</div>
@enderror
</div>
<div class="field @error('task_code') error @enderror">
<label>Kod Tugasan <span style="color:red;">*</span></label>
<input type="text" name="task_code" value="{{ old('task_code') }}" placeholder="Contoh: CREATE, UPDATE, SUBMIT" required>
@error('task_code')
<div class="ui basic red pointing prompt label">{{ $message }}</div>
@enderror
</div>
<div class="field @error('is_active') error @enderror">
<label>Status <span style="color:red;">*</span></label>
<select name="is_active" class="ui dropdown" required>
<option value="1" {{ old('is_active', '1') == '1' ? 'selected' : '' }}>Aktif</option>
<option value="0" {{ old('is_active') == '0' ? 'selected' : '' }}>Tidak Aktif</option>
</select>
@error('is_active')
<div class="ui basic red pointing prompt label">{{ $message }}</div>
@enderror
</div>
<div style="margin-top: 20px;">
<button type="submit" class="ui button primary"><i class="save icon"></i> Simpan</button>
<a href="{{ route('overtime::ot-task.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>Kemaskini Tugasan OT</p>
</div>
<div class="ui secondary segment">
<div class="ui segment">
<form action="{{ route('overtime::ot-task.update', $task->id) }}" method="POST" class="ui form">
@csrf
@method('PUT')
<div class="field @error('task_name') error @enderror">
<label>Nama Tugasan <span style="color:red;">*</span></label>
<input type="text" name="task_name" value="{{ old('task_name', $task->task_name) }}" required>
@error('task_name')
<div class="ui basic red pointing prompt label">{{ $message }}</div>
@enderror
</div>
<div class="field @error('task_code') error @enderror">
<label>Kod Tugasan <span style="color:red;">*</span></label>
<input type="text" name="task_code" value="{{ old('task_code', $task->task_code) }}" required>
@error('task_code')
<div class="ui basic red pointing prompt label">{{ $message }}</div>
@enderror
</div>
<div class="field @error('is_active') error @enderror">
<label>Status <span style="color:red;">*</span></label>
<select name="is_active" class="ui dropdown" required>
<option value="1" {{ old('is_active', $task->is_active) ? 'selected' : '' }}>Aktif</option>
<option value="0" {{ !old('is_active', $task->is_active) ? 'selected' : '' }}>Tidak Aktif</option>
</select>
@error('is_active')
<div class="ui basic red pointing prompt label">{{ $message }}</div>
@enderror
</div>
<div style="margin-top: 20px;">
<button type="submit" class="ui button primary"><i class="save icon"></i> Kemaskini</button>
<a href="{{ route('overtime::ot-task.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">
<div class="ui segment">
<p>Senarai Tugasan OT</p>
</div>
<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 Tugasan OT (LKP OT Task)</p>
<a href="{{ route('overtime::ot-task.create') }}" class="ui button primary small">
+ Tambah Tugasan
</a>
</div>
<table class="ui table celled" id="ot-task-table" style="width:100%;">
<thead>
<tr>
<th>Nama Tugasan</th>
<th>Kod Tugasan</th>
<th>Status</th>
<th width="150px">Tindakan</th>
</tr>
</thead>
<tbody>
@forelse($tasks as $task)
<tr>
<td>{{ $task->task_name }}</td>
<td>{{ $task->task_code }}</td>
<td>
@if($task->is_active)
<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('overtime::ot-task.show', $task->id) }}" class="ui button basic" title="Lihat"><i class="eye icon"></i></a>
<a href="{{ route('overtime::ot-task.edit', $task->id) }}" class="ui button primary" title="Kemaskini"><i class="edit icon"></i></a>
<form action="{{ route('overtime::ot-task.destroy', $task->id) }}" method="POST" style="display:inline;" onsubmit="return confirm('Adakah anda pasti untuk memadam tugasan 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 tugasan OT.</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>Maklumat Tugasan OT</p>
</div>
<div class="ui secondary segment">
<div class="ui segment">
<table class="ui definition table">
<tbody>
<tr>
<td class="two wide column">ID</td>
<td>{{ $task->id }}</td>
</tr>
<tr>
<td>Nama Tugasan</td>
<td>{{ $task->task_name }}</td>
</tr>
<tr>
<td>Kod Tugasan</td>
<td>{{ $task->task_code }}</td>
</tr>
<tr>
<td>Status</td>
<td>
@if($task->is_active)
<span class="ui green label small">Aktif</span>
@else
<span class="ui red label small">Tidak Aktif</span>
@endif
</td>
</tr>
<tr>
<td>Tarikh Cipta</td>
<td>{{ $task->created_at ? $task->created_at->format('d/m/Y H:i A') : '-' }}</td>
</tr>
<tr>
<td>Kemaskini Terakhir</td>
<td>{{ $task->updated_at ? $task->updated_at->format('d/m/Y H:i A') : '-' }}</td>
</tr>
</tbody>
</table>
<div style="margin-top: 20px;">
<a href="{{ route('overtime::ot-task.edit', $task->id) }}" class="ui button primary"><i class="edit icon"></i> Kemaskini</a>
<a href="{{ route('overtime::ot-task.index') }}" class="ui button basic">Kembali</a>
</div>
</div>
</div>
</div>
@endsection
\ No newline at end of file
......@@ -2,6 +2,7 @@
use Illuminate\Support\Facades\Route;
use App\Enums\Permission;
use Portal\Overtime\Http\Controllers\OtTaskController;
Route::group(
[
......@@ -102,5 +103,14 @@ function () {
// Tetapan
Route::get('tetapan', ['uses' => 'TetapanController@index', 'as' => 'overtime.tetapan']);
// OT Task
Route::get('ot-task', [OtTaskController::class, 'index'])->name('ot-task.index');
Route::get('ot-task/create', [OtTaskController::class, 'create'])->name('ot-task.create');
Route::post('ot-task', [OtTaskController::class, 'store'])->name('ot-task.store');
Route::get('ot-task/{id}', [OtTaskController::class, 'show'])->name('ot-task.show');
Route::get('ot-task/{id}/edit', [OtTaskController::class, 'edit'])->name('ot-task.edit');
Route::put('ot-task/{id}', [OtTaskController::class, 'update'])->name('ot-task.update');
Route::delete('ot-task/{id}', [OtTaskController::class, 'destroy'])->name('ot-task.destroy');
}
);
);
\ No newline at end of file
<?php
namespace Portal\Overtime\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use Portal\Overtime\Model\LkpOtTask;
class OtTaskController extends Controller
{
public function index()
{
$tasks = LkpOtTask::latest('id')->get();
return view('overtime::lkpotask.index', compact('tasks'));
}
public function create()
{
return view('overtime::lkpotask.create');
}
public function store(Request $request)
{
$request->validate([
'task_name' => 'required|string|max:255',
'task_code' => 'required|string|max:50',
'is_active' => 'required|in:0,1',
]);
LkpOtTask::create([
'task_name' => $request->task_name,
'task_code' => $request->task_code,
'is_active' => $request->is_active,
'created_by' => auth()->id(),
'updated_by' => auth()->id(),
]);
return redirect()->route('overtime::ot-task.index')->with('success', 'Tugasan OT berjaya ditambah.');
}
public function show($id)
{
$task = LkpOtTask::findOrFail($id);
return view('overtime::lkpotask.show', compact('task'));
}
public function edit($id)
{
$task = LkpOtTask::findOrFail($id);
return view('overtime::lkpotask.edit', compact('task'));
}
public function update(Request $request, $id)
{
$request->validate([
'task_name' => 'required|string|max:255',
'task_code' => 'required|string|max:50',
'is_active' => 'required|in:0,1',
]);
$task = LkpOtTask::findOrFail($id);
$task->update([
'task_name' => $request->task_name,
'task_code' => $request->task_code,
'is_active' => $request->is_active,
'updated_by' => auth()->id(),
]);
return redirect()->route('overtime::ot-task.index')->with('success', 'Tugasan OT berjaya dikemaskini.');
}
public function destroy($id)
{
$task = LkpOtTask::findOrFail($id);
$task->delete();
return redirect()->route('overtime::ot-task.index')->with('success', 'Tugasan OT berjaya dipadam.');
}
}
\ No newline at end of file
<?php
namespace Portal\Overtime\Model;
use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;
class LkpOtTask extends Model
{
use HasFactory, SoftDeletes;
protected $table = 'lkp_overtime_task';
protected $fillable = [
'task_name',
'task_code',
'is_active',
'created_by',
'updated_by',
];
protected $casts = [
'is_active' => 'boolean',
];
}
\ 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