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
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
169 additions
and
36 deletions
+169
-36
packages/portal/mileage/resources/views/dashboard/pegawai.blade.php
+107
-29
packages/portal/mileage/src/Http/Controllers/DashboardController.php
+62
-7
No files found.
packages/portal/mileage/resources/views/dashboard/pegawai.blade.php
View file @
6cc815a5
This diff is collapsed.
Click to expand it.
packages/portal/mileage/src/Http/Controllers/DashboardController.php
View file @
6cc815a5
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
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
{
{
...
@@ -12,20 +13,73 @@ public function __construct()
...
@@ -12,20 +13,73 @@ 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
();
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
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