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
ac889b9d
Commit
ac889b9d
authored
Oct 30, 2025
by
Hannah Zahra
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fourth Update
parent
5961a3ce
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
57 additions
and
49 deletions
+57
-49
packages/portal/mileage/resources/views/applyform/index.blade.php
+0
-0
packages/portal/mileage/resources/views/applyform/noproject.blade.php
+0
-0
packages/portal/mileage/resources/views/projectManager/index.blade.php
+1
-0
packages/portal/mileage/routes/web.php
+1
-3
packages/portal/mileage/src/Http/Controllers/ApplicationsController.php
+43
-45
packages/portal/mileage/src/Http/Controllers/ApplyformController.php
+11
-0
packages/portal/mileage/src/Model/Aclrole.php
+1
-1
No files found.
packages/portal/mileage/resources/views/applyform/index.blade.php
View file @
ac889b9d
This diff is collapsed.
Click to expand it.
packages/portal/mileage/resources/views/applyform/noproject.blade.php
View file @
ac889b9d
This diff is collapsed.
Click to expand it.
packages/portal/mileage/resources/views/projectManager/index.blade.php
View file @
ac889b9d
...
...
@@ -138,6 +138,7 @@
<br>
@else
<div
class=
"ui message"
>
Tiada tuntutan untuk projek ini bulan ini.
</div>
<br>
@endif
</div>
@empty
...
...
packages/portal/mileage/routes/web.php
View file @
ac889b9d
...
...
@@ -21,8 +21,8 @@ function () {
Route
::
prefix
(
'applyform'
)
->
name
(
'applyform'
)
->
group
(
function
()
{
Route
::
get
(
'/'
,
[
ApplyformController
::
class
,
'index'
])
->
name
(
'.index'
);
Route
::
get
(
'/noproject'
,
[
ApplyformController
::
class
,
'noproject'
])
->
name
(
'.noproject'
);
Route
::
get
(
'/applyform/getDates'
,
[
ApplyformController
::
class
,
'getDates'
])
->
name
(
'.getDates'
);
});
// Route::resource('applyform', ApplyformController::class);
// Applications
...
...
@@ -32,8 +32,6 @@ function () {
Route
::
get
(
'applications/view/claim/{id}'
,
[
ApplicationsController
::
class
,
'viewEach'
])
->
name
(
'applications.viewEach'
);
Route
::
put
(
'applications/{id}'
,
[
ApplicationsController
::
class
,
'update'
])
->
name
(
'applications.update'
);
Route
::
get
(
'/applications/dates'
,
[
\Portal\Mileage\Http\Controllers\ApplicationsController
::
class
,
'getClaimDates'
])
->
name
(
'mileage::applications.getDates'
);
// Project Manager
Route
::
prefix
(
'projectManager'
)
->
name
(
'projectManager'
)
->
group
(
function
()
{
...
...
packages/portal/mileage/src/Http/Controllers/ApplicationsController.php
View file @
ac889b9d
...
...
@@ -9,6 +9,7 @@
use
Illuminate\Routing\Controller
;
use
Illuminate\Support\Collection
;
use
Illuminate\Support\Facades\Auth
;
use
Illuminate\Http\Request
;
use
Carbon\Carbon
;
...
...
@@ -68,53 +69,29 @@ public function index(Request $request)
public
function
store
(
Request
$request
)
{
// Validate request data
$validated
=
$request
->
validate
([
'claim_date'
=>
'required|date'
,
'jenis_kenderaan_id'
=>
'required|exists:lkp_jenis_kenderaans,id'
,
'project_id'
=>
'nullable|exists:lkp_project,id'
,
'description'
=>
'required'
,
'distance_from'
=>
'nullable'
,
'distance_to'
=>
'nullable'
,
'total_mileage'
=>
'required|numeric'
,
'toll_amount'
=>
'nullable|numeric'
,
'others_amount'
=>
'nullable|numeric'
,
'others_description'
=>
'nullable|string|max:255'
,
]);
$validated
[
'user_id'
]
=
auth
()
->
id
();
// Get the current authenticated user
// Calculate the total claim amount and mileage
$calculatedAmount
=
$this
->
calculateClaimAmount
(
$validated
);
$validated
[
'calculated_amount'
]
=
$calculatedAmount
;
// Handle the status based on actions (e.g., project manager, director, finance)
$validated
[
'status'
]
=
'Diproses'
;
// Initial status
// Store the claim in the database
$claim
=
Claim
::
create
(
$validated
);
// Now, we need to manage the role and verify the project
// Example: If project_id is set, link the claim with the project and handle roles
if
(
$claim
->
project
)
{
$project
=
$claim
->
project
;
// Here, you can check if the claim should be verified by a Project Manager (HOD)
// For now, we’re assuming you use the role directly to set verified_by
if
(
$project
->
project_manager_id
)
{
$claim
->
verified_by
=
$project
->
project_manager_id
;
}
// Similarly, you can handle who approves and reviews (e.g., Project Director or BOD)
if
(
$project
->
project_director_id
)
{
$claim
->
approved_by
=
$project
->
project_director_id
;
}
// your existing store logic
$calculation
=
$this
->
calculateClaimAmount
(
$request
);
$claim
->
save
();
}
Claim
::
create
([
'user_id'
=>
Auth
::
id
(),
'project_id'
=>
$request
->
project_id
,
'claim_date'
=>
$request
->
claim_date
,
'jenis_kenderaan_id'
=>
$request
->
jenis_kenderaan_id
,
'description'
=>
$request
->
description
,
'distance_from'
=>
$request
->
distance_from
,
'distance_to'
=>
$request
->
distance_to
,
'total_mileage'
=>
$request
->
total_mileage
,
'toll_amount'
=>
$request
->
toll_amount
??
0
,
'others_amount'
=>
$request
->
others_amount
??
0
,
'claimable_mileage'
=>
$calculation
[
'claimable_mileage'
],
'rate'
=>
$calculation
[
'rate'
],
'mileage_amount'
=>
$calculation
[
'mileage_amount'
],
'total_claim_amount'
=>
$calculation
[
'total_claim'
],
'status'
=>
'Diproses'
,
]);
return
redirect
()
->
route
(
'mileage::applications.index'
)
->
with
(
'success'
,
'Claim submitted successfully!'
);
return
redirect
()
->
route
(
'mileage::applications.index'
)
->
with
(
'success'
,
'Tuntutan berjaya dihantar!'
);
}
public
function
edit
(
$id
)
...
...
@@ -265,5 +242,26 @@ public function updateStatus(Request $request, $id)
return
back
()
->
with
(
'success'
,
'Claim status updated to '
.
$claim
->
status
);
}
private
function
calculateClaimAmount
(
$request
)
{
$totalMileage
=
(
float
)
$request
->
total_mileage
;
$toll
=
(
float
)
$request
->
toll_amount
;
$others
=
(
float
)
$request
->
others_amount
;
// Deduct first 40km
$claimableMileage
=
$totalMileage
>
40
?
$totalMileage
-
40
:
0
;
// Apply rate logic
$rate
=
$claimableMileage
>
500
?
0.50
:
0.55
;
$mileageAmount
=
$claimableMileage
*
$rate
;
$totalClaim
=
$mileageAmount
+
$toll
+
$others
;
return
[
'claimable_mileage'
=>
$claimableMileage
,
'rate'
=>
$rate
,
'mileage_amount'
=>
$mileageAmount
,
'total_claim'
=>
$totalClaim
,
];
}
}
packages/portal/mileage/src/Http/Controllers/ApplyformController.php
View file @
ac889b9d
...
...
@@ -130,4 +130,15 @@ public function noproject()
return
view
(
'mileage::applyform.noproject'
,
compact
(
'jenisKenderaan'
));
}
public
function
getDates
()
{
$userId
=
auth
()
->
id
();
$dates
=
Claim
::
where
(
'user_id'
,
$userId
)
->
pluck
(
'claim_date'
)
// get all submitted dates
->
map
(
fn
(
$d
)
=>
\Carbon\Carbon
::
parse
(
$d
)
->
format
(
'Y-m-d'
));
// format to yyyy-mm-dd
return
response
()
->
json
(
$dates
);
}
}
packages/portal/mileage/src/Model/Aclrole.php
View file @
ac889b9d
...
...
@@ -6,7 +6,7 @@
class
AclRole
extends
Model
{
protected
$table
=
'acl_roles'
;
//
⚠️
must be your roles definition table
protected
$table
=
'acl_roles'
;
// must be your roles definition table
protected
$primaryKey
=
'id'
;
public
$timestamps
=
false
;
...
...
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