Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
M
mileage-claim
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
trainee
mileage-claim
Commits
6cc815a5
Commit
6cc815a5
authored
Oct 09, 2026
by
Muhammad Aniq bin Mohd Nizam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Homepage update
parent
00bade44
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
174 additions
and
41 deletions
+174
-41
packages/portal/mileage/resources/views/dashboard/pegawai.blade.php
+107
-29
packages/portal/mileage/src/Http/Controllers/DashboardController.php
+67
-12
No files found.
packages/portal/mileage/resources/views/dashboard/pegawai.blade.php
View file @
6cc815a5
...
@@ -48,6 +48,7 @@
...
@@ -48,6 +48,7 @@
@
section
(
'content'
)
@
section
(
'content'
)
{{
--
First
Card
(
Main
/
Staff
Info
)
--
}}
<
div
class
="
ui
raised
segment
">
<
div
class
="
ui
raised
segment
">
<a class="
ui
red
ribbon
label
">Selamat Kembali</a>
<a class="
ui
red
ribbon
label
">Selamat Kembali</a>
<br><br>
<br><br>
...
@@ -58,53 +59,48 @@
...
@@ -58,53 +59,48 @@
<tr>
<tr>
<td width="
50
%
">
<td width="
50
%
">
<h4 class="
ui
image
header
">
<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
">
<div class="
content
">
<span
<span style="
font
-
size
:
14
px
!
important
;
font
-
weight
:
normal
!
important
;
padding
-
left
:
10
px
">Nama</span>
style="
font
-
size
:
14
px
!
important
;
font
-
weight
:
normal
!
important
;
padding
-
left
:
10
px
">Nama</span>
</div>
</div>
</h4>
</h4>
</td>
</td>
<td>{{ data_get(
$staff
, 'name',
auth()->user()->name
) }}</td>
<td>{{ data_get(
$staff
, 'name',
auth()->user()->name ?? '-'
) }}</td>
</tr>
</tr>
<tr>
<tr>
<td width="
50
%
">
<td width="
50
%
">
<h4 class="
ui
image
header
">
<h4 class="
ui
image
header
">
<i class="
certificate
icon
"
class="
ui
mini
rounded
image
"
></i>
<i class="
certificate
icon
"></i>
<div class="
content
">
<div class="
content
">
<span
<span style="
font
-
size
:
14
px
!
important
;
font
-
weight
:
normal
!
important
;
padding
-
left
:
10
px
">No. Pekerja</span>
style="
font
-
size
:
14
px
!
important
;
font
-
weight
:
normal
!
important
;
padding
-
left
:
10
px
">No.
Pekerja</span>
</div>
</div>
</h4>
</h4>
</td>
</td>
<td>{{ data_get(
$staff
, 'employeeCode',
auth()->user()->id
) }}</td>
<td>{{ data_get(
$staff
, 'employeeCode',
auth()->user()->id ?? '-'
) }}</td>
</tr>
</tr>
<tr>
<tr>
<td width="
50
%
">
<td width="
50
%
">
<h4 class="
ui
image
header
">
<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
">
<div class="
content
" style="
font
-
style
:
unset
">
<span
<span style="
font
-
size
:
14
px
!
important
;
font
-
weight
:
normal
!
important
;
padding
-
left
:
10
px
">Department</span>
style="
font
-
size
:
14
px
!
important
;
font
-
weight
:
normal
!
important
;
padding
-
left
:
10
px
">Department</span>
</div>
</div>
</h4>
</h4>
</td>
</td>
<td>{{ data_get(
$staff
, 'staffinfo.department.description') }}</td>
<td>{{ data_get(
$staff
, 'staffinfo.department.description'
, '-'
) }}</td>
</tr>
</tr>
<tr>
<tr>
<td width="
50
%
">
<td width="
50
%
">
<h4 class="
ui
image
header
">
<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
">
<div class="
content
" style="
font
-
style
:
unset
">
<span
<span style="
font
-
size
:
14
px
!
important
;
font
-
weight
:
normal
!
important
;
padding
-
left
:
10
px
">Peranan</span>
style="
font
-
size
:
14
px
!
important
;
font
-
weight
:
normal
!
important
;
padding
-
left
:
10
px
">Peranan</span>
</div>
</div>
</h4>
</h4>
</td>
</td>
<td>
<td>
@php
@php
$roles
=
$staff->roles
->pluck('name')->toArray()
;
$roles
=
optional(
$staff
)->roles ?
$staff->roles
->pluck('name')->toArray() : []
;
@endphp
@endphp
{{ !empty(
$roles
) ? implode(', ',
$roles
) : '-' }}
{{ !empty(
$roles
) ? implode(', ',
$roles
) : '-' }}
</td>
</td>
...
@@ -114,17 +110,98 @@
...
@@ -114,17 +110,98 @@
</div>
</div>
</div>
</div>
</div>
</div>
@endsection
@push('script')
{{-- Second Card (Overtime System Info) --}}
<script src="
{{
asset
(
'web/vendor/fullcalendar/lib/moment.min.js'
)
}}
"></script>
<div class="
ui
raised
segment
">
<script src="
{{
asset
(
'web/vendor/fullcalendar/fullcalendar.min.js'
)
}}
"></script>
<a class="
ui
blue
ribbon
label
">Maklumat Kerja Lebih Masa (OT)</a>
<script src="
{{
asset
(
'web/vendor/fullcalendar/locale/ms-my.js'
)
}}
"></script>
<br><br>
<div class="
ui
stackable
grid
">
<script>
<div class="
sixteen
wide
column
">
$(document).ready(function() {
<table class="
ui
celled
table
" style="
width
:
100
%
!
important
">
<tbody>
});
<tr>
</script>
<td width="
50
%
">
<h4 class="
ui
image
header
">
<i class="
clock
icon
"></i>
<div class="
content
">
<span style="
font
-
size
:
14
px
!
important
;
font
-
weight
:
normal
!
important
;
padding
-
left
:
10
px
">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
:
14
px
!
important
;
font
-
weight
:
normal
!
important
;
padding
-
left
:
10
px
">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
:
14
px
!
important
;
font
-
weight
:
normal
!
important
;
padding
-
left
:
10
px
">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
:
14
px
!
important
;
font
-
weight
:
normal
!
important
;
padding
-
left
:
10
px
">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
:
14
px
!
important
;
font
-
weight
:
normal
!
important
;
padding
-
left
:
10
px
">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
:
14
px
!
important
;
font
-
weight
:
normal
!
important
;
padding
-
left
:
10
px
">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
packages/portal/mileage/src/Http/Controllers/DashboardController.php
View file @
6cc815a5
...
@@ -4,28 +4,82 @@
...
@@ -4,28 +4,82 @@
use
Illuminate\Routing\Controller
;
use
Illuminate\Routing\Controller
;
use
Portal\Mileage\Model\Users
;
use
Portal\Mileage\Model\Users
;
use
Portal\Mileage\Model\MileageClaimMain
;
class
DashboardController
extends
Controller
class
DashboardController
extends
Controller
{
{
public
function
__construct
()
public
function
__construct
()
{
{
}
}
public
function
index
()
public
function
index
()
{
{
// logic filter role kat user yang nak login
// Role filtering logic if needed
if
(
auth
()
->
user
()
->
hasRole
([
'Administrator'
]))
{
if
(
auth
()
->
user
()
->
hasRole
([
'Administrator'
])){
// allow access to dashboard
// allow access to dashboard
}
}
// Fetch staff details with staffinfo, department, and roles
$staff
=
Users
::
where
(
'employeeCode'
,
auth
()
->
user
()
->
employeeCode
)
$staff
=
Users
::
where
(
'employeeCode'
,
auth
()
->
user
()
->
employeeCode
)
->
with
(
'staffinfo.department'
,
'roles'
)
// added nested relationship
->
with
([
'staffinfo.department'
,
'roles'
])
->
first
();
->
first
();
// 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
'
));
return
view
(
'mileage::dashboard.pegawai'
,
compact
(
'staff'
,
'overtime'
,
'mileage
'
));
}
}
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment