Homepage update

parent 00bade44
......@@ -48,6 +48,7 @@
@section('content')
{{-- First Card (Main / Staff Info) --}}
<div class="ui raised segment">
<a class="ui red ribbon label">Selamat Kembali</a>
<br><br>
......@@ -58,53 +59,48 @@
<tr>
<td width="50%">
<h4 class="ui image header">
<i class="id card icon" class="ui mini rounded image"></i>
<i class="id card icon"></i>
<div class="content">
<span
style="font-size: 14px !important;font-weight: normal !important;padding-left:10px">Nama</span>
<span style="font-size: 14px !important;font-weight: normal !important;padding-left:10px">Nama</span>
</div>
</h4>
</td>
<td>{{ data_get($staff, 'name',auth()->user()->name) }}</td>
<td>{{ data_get($staff, 'name', auth()->user()->name ?? '-') }}</td>
</tr>
<tr>
<td width="50%">
<h4 class="ui image header">
<i class="certificate icon" class="ui mini rounded image"></i>
<i class="certificate icon"></i>
<div class="content">
<span
style="font-size: 14px !important;font-weight: normal !important;padding-left:10px">No.
Pekerja</span>
<span style="font-size: 14px !important;font-weight: normal !important;padding-left:10px">No. Pekerja</span>
</div>
</h4>
</td>
<td>{{ data_get($staff, 'employeeCode',auth()->user()->id) }}</td>
<td>{{ data_get($staff, 'employeeCode', auth()->user()->id ?? '-') }}</td>
</tr>
<tr>
<td width="50%">
<h4 class="ui image header">
<i class="sitemap icon" class="ui mini rounded image"></i>
<i class="sitemap icon"></i>
<div class="content" style="font-style: unset">
<span
style="font-size: 14px !important;font-weight: normal !important;padding-left:10px">Department</span>
<span style="font-size: 14px !important;font-weight: normal !important;padding-left:10px">Department</span>
</div>
</h4>
</td>
<td>{{ data_get($staff, 'staffinfo.department.description') }}</td>
<td>{{ data_get($staff, 'staffinfo.department.description', '-') }}</td>
</tr>
<tr>
<td width="50%">
<h4 class="ui image header">
<i class="user tie icon" class="ui mini rounded image"></i>
<i class="user tie icon"></i>
<div class="content" style="font-style: unset">
<span
style="font-size: 14px !important;font-weight: normal !important;padding-left:10px">Peranan</span>
<span style="font-size: 14px !important;font-weight: normal !important;padding-left:10px">Peranan</span>
</div>
</h4>
</td>
<td>
@php
$roles = $staff->roles->pluck('name')->toArray();
$roles = optional($staff)->roles ? $staff->roles->pluck('name')->toArray() : [];
@endphp
{{ !empty($roles) ? implode(', ', $roles) : '-' }}
</td>
......@@ -114,17 +110,98 @@
</div>
</div>
</div>
@endsection
@push('script')
<script src="{{ asset('web/vendor/fullcalendar/lib/moment.min.js') }}"></script>
<script src="{{ asset('web/vendor/fullcalendar/fullcalendar.min.js') }}"></script>
<script src="{{ asset('web/vendor/fullcalendar/locale/ms-my.js') }}"></script>
<script>
$(document).ready(function() {
});
</script>
{{-- Second Card (Overtime System Info) --}}
<div class="ui raised segment">
<a class="ui blue ribbon label">Maklumat Kerja Lebih Masa (OT)</a>
<br><br>
<div class="ui stackable grid">
<div class="sixteen wide column">
<table class="ui celled table" style="width:100% !important">
<tbody>
<tr>
<td width="50%">
<h4 class="ui image header">
<i class="clock icon"></i>
<div class="content">
<span style="font-size: 14px !important;font-weight: normal !important;padding-left:10px">Jumlah Jam OT (Bulan Ini)</span>
</div>
</h4>
</td>
<td>{{ data_get($overtime ?? [], 'total_hours', '0') }} Jam</td>
</tr>
<tr>
<td width="50%">
<h4 class="ui image header">
<i class="calculator icon"></i>
<div class="content">
<span style="font-size: 14px !important;font-weight: normal !important;padding-left:10px">Anggaran Bayaran OT</span>
</div>
</h4>
</td>
<td>RM {{ number_format((float) data_get($overtime ?? [], 'estimated_pay', 0), 2) }}</td>
</tr>
<tr>
<td width="50%">
<h4 class="ui image header">
<i class="tasks icon"></i>
<div class="content" style="font-style: unset">
<span style="font-size: 14px !important;font-weight: normal !important;padding-left:10px">Status Permohonan</span>
</div>
</h4>
</td>
<td>{{ data_get($overtime ?? [], 'status', '-') }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
@endpush
{{-- Third Card (Mileage Claim Info) --}}
<div class="ui raised segment">
<a class="ui teal ribbon label">Maklumat Tuntutan Mileage</a>
<br><br>
<div class="ui stackable grid">
<div class="sixteen wide column">
<table class="ui celled table" style="width:100% !important">
<tbody>
<tr>
<td width="50%">
<h4 class="ui image header">
<i class="car icon"></i>
<div class="content">
<span style="font-size: 14px !important;font-weight: normal !important;padding-left:10px">Jumlah Jarak Perjalanan</span>
</div>
</h4>
</td>
<td>{{ number_format((float) data_get($mileage ?? [], 'total_distance', 0), 1) }} KM</td>
</tr>
<tr>
<td width="50%">
<h4 class="ui image header">
<i class="money bill alternate icon"></i>
<div class="content">
<span style="font-size: 14px !important;font-weight: normal !important;padding-left:10px">Jumlah Tuntutan Mileage</span>
</div>
</h4>
</td>
<td>RM {{ number_format((float) data_get($mileage ?? [], 'total_amount', 0), 2) }}</td>
</tr>
<tr>
<td width="50%">
<h4 class="ui image header">
<i class="file alternate icon"></i>
<div class="content" style="font-style: unset">
<span style="font-size: 14px !important;font-weight: normal !important;padding-left:10px">Status Permohonan Terkini</span>
</div>
</h4>
</td>
<td>{{ data_get($mileage ?? [], 'status', '-') }}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
@endsection
\ No newline at end of file
......@@ -4,6 +4,7 @@
use Illuminate\Routing\Controller;
use Portal\Mileage\Model\Users;
use Portal\Mileage\Model\MileageClaimMain;
class DashboardController extends Controller
{
......@@ -12,20 +13,73 @@ public function __construct()
}
public function index()
{
// logic filter role kat user yang nak login
if (auth()->user()->hasRole(['Administrator'])){
// Role filtering logic if needed
if (auth()->user()->hasRole(['Administrator'])) {
// allow access to dashboard
}
// Fetch staff details with staffinfo, department, and roles
$staff = Users::where('employeeCode', auth()->user()->employeeCode)
->with('staffinfo.department', 'roles') // added nested relationship
->with(['staffinfo.department', 'roles'])
->first();
return view('mileage::dashboard.pegawai',compact('staff'));
// Default / Fallback overtime structure
$overtime = [
'total_hours' => 0,
'estimated_pay' => 0.00,
'status' => '-'
];
// Fetch Mileage Claim stats for the logged-in user
$staffInfoId = optional($staff)->staffinfo ? $staff->staffinfo->id : null;
$totalMileageDistance = 0;
$totalMileageAmount = 0;
$latestClaimStatus = '-';
if ($staffInfoId) {
$userClaims = MileageClaimMain::where('fk_lkp_staff_info', $staffInfoId)
->with(['details', 'finance', 'lkpStatus'])
->get();
foreach ($userClaims as $claim) {
// Sum distance from details or main table
if ($claim->details && $claim->details->count() > 0) {
$totalMileageDistance += $claim->details->sum(function ($d) {
return (float) ($d->md_total_mileage ?? $d->md_distance ?? $d->md_mileage ?? 0);
});
} else {
$totalMileageDistance += (float) ($claim->mm_total_mileage ?? 0);
}
// Sum claim amount from finance or detail
$amount = (float) (
optional($claim->finance)->fin_final_amount ??
$claim->fin_final_amount ??
$claim->total_amount ??
0
);
$totalMileageAmount += $amount;
}
// Grab latest claim status
$latestClaim = $userClaims->sortByDesc('mm_submit_date')->first();
if ($latestClaim) {
$latestClaimStatus = optional($latestClaim->lkpStatus)->ref_description
?? $latestClaim->status_label
?? $latestClaim->status
?? '-';
}
}
$mileage = [
'total_distance' => $totalMileageDistance,
'total_amount' => $totalMileageAmount,
'status' => $latestClaimStatus,
];
return view('mileage::dashboard.pegawai', compact('staff', 'overtime', 'mileage'));
}
}
\ 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