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
470f1281
Commit
470f1281
authored
Aug 17, 2026
by
Muhammad Iz'aan bin suhaimi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
download pdf features for staff and hr
parent
c56cda95
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
315 additions
and
183 deletions
+315
-183
packages/portal/mileage/resources/views/HR/index.blade.php
+0
-0
packages/portal/mileage/resources/views/HR/show.blade.php
+0
-0
packages/portal/mileage/resources/views/HR/view.blade.php
+0
-63
packages/portal/mileage/resources/views/mileage/form.blade.php
+6
-0
packages/portal/mileage/resources/views/mileage/pdf.blade.php
+225
-0
packages/portal/mileage/routes/web.php
+4
-5
packages/portal/mileage/src/Http/Controllers/HRController.php
+39
-110
packages/portal/mileage/src/Http/Controllers/MileageController.php
+37
-1
packages/portal/mileage/src/ServiceProvider.php
+4
-4
No files found.
packages/portal/mileage/resources/views/HR/index.blade.php
View file @
470f1281
This diff is collapsed.
Click to expand it.
packages/portal/mileage/resources/views/HR/show.blade.php
View file @
470f1281
This diff is collapsed.
Click to expand it.
packages/portal/mileage/resources/views/HR/view.blade.php
deleted
100644 → 0
View file @
c56cda95
<title>
Maklumat Tuntutan (HR)
</title>
@extends('ui::layouts.app')
@section('content')
<style>
body
{
background-color
:
#f0f2f5
;
}
.ui.container
{
max-width
:
70%
!important
;
margin-top
:
2rem
;
}
.ui.segment
{
box-shadow
:
0
4px
6px
rgba
(
0
,
0
,
0
,
0.1
);
border-radius
:
10px
;
background-color
:
#fff
;
padding
:
2rem
;
}
table
.ui.definition.table
td
:first-child
{
width
:
40%
;
font-weight
:
600
;
background-color
:
#f9fafb
;
}
.totals-row
td
{
font-weight
:
700
;
background
:
#f7f7f8
;
}
.button-bar
{
margin-top
:
2rem
;
display
:
flex
;
justify-content
:
space-between
;
}
</style>
<div
class=
"ui container"
>
<h2
class=
"ui header"
>
Maklumat Tuntutan (HR)
</h2>
<div
class=
"ui segment"
>
<table
class=
"ui definition table"
>
<tr><td>
Tarikh Tuntutan
</td><td>
{{ \Carbon\Carbon::parse($claim->claim_date)->format('d/m/Y') }}
</td></tr>
<tr><td>
Jenis Kenderaan
</td><td>
{{ $claim->jenisKenderaan->keterangan ?? $claim->jenisKenderaan->name ?? '-' }}
</td></tr>
<tr><td>
Nama Projek
</td><td>
{{ $claim->project->p_project_description ?? 'Tanpa Projek' }}
</td></tr>
<tr><td>
Butiran
</td><td>
{{ $claim->description ?? '-' }}
</td></tr>
<tr><td>
Jarak Dari
</td><td>
{{ $claim->distance_from ?? '-' }}
</td></tr>
<tr><td>
Jarak Ke
</td><td>
{{ $claim->distance_to ?? '-' }}
</td></tr>
<tr><td>
Jumlah Perbatuan
</td><td>
{{ number_format($claim->total_mileage, 2) }} km
</td></tr>
<tr><td>
Toll
</td><td>
RM {{ number_format($claim->toll_amount ?? 0, 2) }}
</td></tr>
<tr><td>
Lain-lain
</td><td>
RM {{ number_format($claim->others_amount ?? 0, 2) }}
</td></tr>
<tr><td>
Butiran Lain-lain
</td><td>
{{ $claim->others_description ?? '-' }}
</td></tr>
<tr><td>
Status
</td><td><strong>
{{ $claim->status }}
</strong></td></tr>
<tr
class=
"totals-row"
><td>
Jumlah Akhir
</td><td><strong>
RM {{ number_format($claim->total_claim_amount, 2) }}
</strong></td></tr>
</table>
</div>
<div
class=
"button-bar"
>
<form
action=
"{{ url()->previous() }}"
method=
"GET"
style=
"display:inline;"
>
<button
type=
"submit"
class=
"ui grey button"
>
<i
class=
"arrow left icon"
></i>
Kembali
</button>
</form>
@if(!in_array($claim->status, ['Ditolak', 'Diluluskan']))
<form
action=
"{{ route('mileage::HR.reject', $claim->id) }}"
method=
"POST"
style=
"display:inline;"
>
@csrf
<button
type=
"submit"
class=
"ui red button"
onclick=
"return confirm('Tolak tuntutan ini?')"
>
<i
class=
"times icon"
></i>
Tolak
</button>
</form>
@endif
</div>
</div>
@endsection
packages/portal/mileage/resources/views/mileage/form.blade.php
View file @
470f1281
...
@@ -455,8 +455,14 @@
...
@@ -455,8 +455,14 @@
<a href="
{{
route
(
'mileage::mileage.listmileage'
)
}}
" class="
ui
right
floated
button
">
<a href="
{{
route
(
'mileage::mileage.listmileage'
)
}}
" class="
ui
right
floated
button
">
<i class="
arrow
left
icon
"></i> Kembali ke Senarai
<i class="
arrow
left
icon
"></i> Kembali ke Senarai
</a>
</a>
@if(in_array(
$claim->status
, [11, 12]))
<a href="
{{
route
(
'mileage::mileage.claim.downloadPdf'
,
$claim
->
id
)
}}
" class="
ui
right
floated
teal
button
" target="
_blank
">
<i class="
file
pdf
icon
"></i> Muat Turun PDF
</a>
@endif
@endif
@endif
<br>
<br>
<br>
<br>
...
...
packages/portal/mileage/resources/views/mileage/pdf.blade.php
0 → 100644
View file @
470f1281
This diff is collapsed.
Click to expand it.
packages/portal/mileage/routes/web.php
View file @
470f1281
...
@@ -87,11 +87,8 @@ function () {
...
@@ -87,11 +87,8 @@ function () {
// HR
// HR
Route
::
prefix
(
'HR'
)
->
name
(
'HR'
)
->
group
(
function
()
{
Route
::
prefix
(
'HR'
)
->
name
(
'HR'
)
->
group
(
function
()
{
Route
::
get
(
'/dashboard'
,
[
HRController
::
class
,
'index'
])
->
name
(
'.index'
);
Route
::
get
(
'/'
,
[
HRController
::
class
,
'index'
])
->
name
(
'.index'
);
Route
::
get
(
'/show/{userId}'
,
[
HRController
::
class
,
'show'
])
->
name
(
'.show'
);
Route
::
get
(
'/{id}'
,
[
HRController
::
class
,
'show'
])
->
name
(
'.show'
);
Route
::
get
(
'/view/claim/{id}'
,
[
HRController
::
class
,
'viewEach'
])
->
name
(
'.viewEach'
);
Route
::
post
(
'/{id}/reject'
,
[
HRController
::
class
,
'reject'
])
->
name
(
'.reject'
);
Route
::
get
(
'/export'
,
[
HRController
::
class
,
'export'
])
->
name
(
'.export'
);
});
});
Route
::
get
(
'index'
,
[
'uses'
=>
'MileageController@index'
,
'as'
=>
'mileage.index'
]);
Route
::
get
(
'index'
,
[
'uses'
=>
'MileageController@index'
,
'as'
=>
'mileage.index'
]);
...
@@ -114,6 +111,8 @@ function () {
...
@@ -114,6 +111,8 @@ function () {
// Tetapan
// Tetapan
Route
::
get
(
'tetapan'
,
[
'uses'
=>
'TetapanController@index'
,
'as'
=>
'mileage.tetapan'
]);
Route
::
get
(
'tetapan'
,
[
'uses'
=>
'TetapanController@index'
,
'as'
=>
'mileage.tetapan'
]);
Route
::
get
(
'claim/{id}/pdf'
,
[
'uses'
=>
'MileageController@downloadPdf'
,
'as'
=>
'mileage.claim.downloadPdf'
]);
}
}
);
);
...
...
packages/portal/mileage/src/Http/Controllers/HRController.php
View file @
470f1281
...
@@ -2,128 +2,57 @@
...
@@ -2,128 +2,57 @@
namespace
Portal\Mileage\Http\Controllers
;
namespace
Portal\Mileage\Http\Controllers
;
use
Portal\Mileage\Model\Users
;
use
Portal\Mileage\Model\MileageClaimMain
;
use
Portal\Mileage\Model\Project
;
use
Portal\Mileage\Model\JenisKenderaan
;
use
Portal\Mileage\Model\Claim
;
use
Portal\Mileage\Model\ProjectTeam
;
use
App\Http\Controllers\Controller
;
use
App\Http\Controllers\Controller
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Carbon\Carbon
;
use
Carbon\Carbon
;
use
Illuminate\Support\Facades\Auth
;
use
Maatwebsite\Excel\Facades\Excel
;
use
Portal\Mileage\Exports\ClaimsExport
;
use
DB
;
class
HRController
extends
Controller
class
HRController
extends
Controller
{
{
public
function
index
(
Request
$request
)
public
function
index
(
Request
$request
)
{
{
$month
=
$request
->
input
(
'month'
,
Carbon
::
now
()
->
format
(
'Y-m'
));
$search
=
$request
->
get
(
'search'
);
$parsedMonth
=
Carbon
::
parse
(
$month
);
$tahun
=
$request
->
get
(
'tahun'
);
$bulan
=
$request
->
get
(
'bulan'
);
// Group claims by staff for the selected month
$status
=
$request
->
get
(
'status'
);
$claims
=
Claim
::
with
(
'user'
)
->
whereMonth
(
'claim_date'
,
$parsedMonth
->
month
)
$list
=
MileageClaimMain
::
with
([
'lkpStatus'
,
'staffInfo'
])
->
whereYear
(
'claim_date'
,
$parsedMonth
->
year
)
->
whereIn
(
'status'
,
[
11
,
12
])
->
get
()
->
when
(
$search
,
function
(
$q
)
use
(
$search
)
{
->
groupBy
(
'user_id'
);
$q
->
where
(
function
(
$q2
)
use
(
$search
)
{
$q2
->
where
(
'mm_apply_no'
,
'like'
,
'%'
.
$search
.
'%'
)
$users
=
$claims
->
map
(
function
(
$claimsForUser
)
{
->
orWhere
(
'mm_staff_name'
,
'like'
,
'%'
.
$search
.
'%'
);
$user
=
$claimsForUser
->
first
()
->
user
;
});
return
[
})
'id'
=>
$user
->
id
,
->
when
(
$tahun
,
fn
(
$q
)
=>
$q
->
where
(
'mm_claim_year'
,
$tahun
))
'name'
=>
$user
->
name
??
'-'
,
->
when
(
$bulan
,
fn
(
$q
)
=>
$q
->
where
(
'mm_claim_month'
,
$bulan
))
'total_claims'
=>
$claimsForUser
->
count
(),
->
when
(
$status
,
fn
(
$q
)
=>
$q
->
where
(
'status'
,
$status
))
'total_amount'
=>
$claimsForUser
->
sum
(
'total_claim_amount'
),
->
orderBy
(
'created_at'
,
'desc'
)
];
->
paginate
(
15
);
});
return
view
(
'mileage::HR.index'
,
compact
(
'list'
));
return
view
(
'mileage::hr.index'
,
compact
(
'users'
,
'month'
));
}
/**
* Show individual claim details
*/
public
function
show
(
$userId
,
Request
$request
)
{
$month
=
$request
->
input
(
'month'
,
Carbon
::
now
()
->
format
(
'Y-m'
));
$parsedMonth
=
Carbon
::
parse
(
$month
);
$user
=
Users
::
findOrFail
(
$userId
);
$claims
=
Claim
::
where
(
'user_id'
,
$userId
)
->
whereMonth
(
'claim_date'
,
$parsedMonth
->
month
)
->
whereYear
(
'claim_date'
,
$parsedMonth
->
year
)
->
orderBy
(
'claim_date'
,
'asc'
)
->
get
();
return
view
(
'mileage::hr.show'
,
compact
(
'user'
,
'claims'
,
'month'
));
}
/**
* Show a single claim (HR detailed view)
*/
public
function
viewEach
(
$id
)
{
$claim
=
Claim
::
with
([
'user'
,
'project'
,
'jenisKenderaan'
])
->
findOrFail
(
$id
);
return
view
(
'mileage::HR.view'
,
compact
(
'claim'
));
}
}
public
function
show
(
$id
)
/**
* Reject claim (HR decision)
*/
public
function
reject
(
$id
)
{
{
$hr
=
Auth
::
user
();
$claim
=
MileageClaimMain
::
with
([
$claim
=
Claim
::
findOrFail
(
$id
);
'details.jenisKenderaan.rates'
,
'details.project'
,
$claim
->
status
=
'Ditolak'
;
'details.pmReviews'
,
$claim
->
rejected_by
=
$hr
->
id
;
// record who rejected it
'lkpStatus'
,
$claim
->
save
();
'staffInfo'
,
'auditQueries'
,
return
back
()
->
with
(
'error'
,
'Tuntutan telah ditolak oleh HR.'
);
'attachments'
,
}
'faCategory'
,
'financeDetail'
,
/**
'verifiedBy'
,
* Export all claims to Excel
'approvedBy'
,
*/
])
->
findOrFail
(
$id
);
public
function
export
(
Request
$request
)
{
if
(
!
in_array
(
$claim
->
status
,
[
11
,
12
]))
{
$userId
=
$request
->
input
(
'user_id'
);
abort
(
403
,
'Permohonan ini tidak tersedia untuk semakan HR.'
);
$month
=
$request
->
input
(
'month'
);
// parse month safely
$parsedMonth
=
$month
?
Carbon
::
parse
(
$month
)
:
null
;
// fetch user
$user
=
$userId
?
Users
::
find
(
$userId
)
:
null
;
// query claims by filter
$claims
=
Claim
::
with
([
'user'
,
'project'
])
->
when
(
$userId
,
fn
(
$q
)
=>
$q
->
where
(
'user_id'
,
$userId
))
->
when
(
$parsedMonth
,
fn
(
$q
)
=>
$q
->
whereMonth
(
'claim_date'
,
$parsedMonth
->
month
)
->
whereYear
(
'claim_date'
,
$parsedMonth
->
year
)
)
->
orderBy
(
'claim_date'
,
'asc'
)
->
get
();
// if no data found, return with warning
if
(
$claims
->
isEmpty
())
{
return
back
()
->
with
(
'error'
,
'Tiada tuntutan dijumpai untuk penapis yang dipilih.'
);
}
}
// build filename dynamically
return
view
(
'mileage::HR.show'
,
compact
(
'claim'
));
$staffName
=
$user
?
str_replace
(
' '
,
'_'
,
strtoupper
(
$user
->
name
))
:
'SEMUA_STAF'
;
$monthName
=
$parsedMonth
?
$parsedMonth
->
format
(
'm-Y'
)
:
Carbon
::
now
()
->
format
(
'm-Y'
);
$fileName
=
"Tuntutan_
{
$staffName
}
_
{
$monthName
}
.xlsx"
;
// generate Excel using filtered data
return
Excel
::
download
(
new
ClaimsExport
(
$user
,
$claims
),
$fileName
);
}
}
}
}
packages/portal/mileage/src/Http/Controllers/MileageController.php
View file @
470f1281
...
@@ -4,10 +4,12 @@
...
@@ -4,10 +4,12 @@
use
Illuminate\Routing\Controller
;
use
Illuminate\Routing\Controller
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Auth
;
use
Illuminate\Support\Facades\Gate
;
use
Illuminate\Support\Facades\Input
;
use
Illuminate\Support\Facades\Input
;
use
Carbon\Carbon
;
use
Carbon\Carbon
;
use
Auth
;
use
DB
;
use
DB
;
use
Event
;
use
Event
;
use
File
;
use
File
;
...
@@ -175,5 +177,39 @@ public function deleteClaim(Request $request, $id)
...
@@ -175,5 +177,39 @@ public function deleteClaim(Request $request, $id)
return
redirect
()
->
route
(
'mileage::mileage.listmileage'
)
->
with
(
'success'
,
'Draf permohonan berjaya dipadam.'
);
return
redirect
()
->
route
(
'mileage::mileage.listmileage'
)
->
with
(
'success'
,
'Draf permohonan berjaya dipadam.'
);
}
}
public
function
downloadPdf
(
Request
$request
,
$id
)
{
$claim
=
\Portal\Mileage\Model\MileageClaimMain
::
with
([
'details.jenisKenderaan.rates'
,
'details.project'
,
'details.pmReviews'
,
'lkpStatus'
,
'staffInfo'
,
'auditQueries'
,
'attachments'
,
'faCategory'
,
'financeDetail'
,
])
->
findOrFail
(
$id
);
if
(
!
in_array
(
$claim
->
status
,
[
11
,
12
]))
{
abort
(
403
,
'PDF tidak tersedia untuk status ini.'
);
}
$staff
=
\Portal\Mileage\Model\StaffInfo
::
where
(
'fk_users'
,
Auth
::
id
())
->
first
();
$isOwner
=
$staff
&&
$claim
->
fk_lkp_staff_info
==
$staff
->
id
;
$isHR
=
Gate
::
allows
(
\App\Enums\Permission
::
HR
);
if
(
!
$isOwner
&&
!
$isHR
)
{
abort
(
403
,
'Anda tidak mempunyai akses untuk memuat turun dokumen ini.'
);
}
$html
=
view
(
'mileage::mileage.pdf'
,
compact
(
'claim'
))
->
render
();
$pdf
=
\Barryvdh\DomPDF\Facade\Pdf
::
loadHTML
(
$html
)
->
setPaper
(
'A4'
,
'portrait'
);
return
$pdf
->
download
(
'Tuntutan_Mileage_'
.
$claim
->
mm_apply_no
.
'.pdf'
);
}
}
}
packages/portal/mileage/src/ServiceProvider.php
View file @
470f1281
...
@@ -122,10 +122,10 @@ protected function menu()
...
@@ -122,10 +122,10 @@ protected function menu()
->
data
(
'permission'
,
Permission
::
BOD
);
->
data
(
'permission'
,
Permission
::
BOD
);
//
$menu->add(__('HR Dashboard'), route('mileage::HR.index'))
$menu
->
add
(
__
(
'HR Dashboard'
),
route
(
'mileage::HR.index'
))
//
->data('icon', 'id badge')
->
data
(
'icon'
,
'id badge'
)
//
->active('HR/*')
->
active
(
'HR/*'
)
//
->data('permission', Permission::HR);
->
data
(
'permission'
,
Permission
::
HR
);
$menu
->
add
(
__
(
'Finance Dashboard'
),
route
(
'mileage::finance.index'
))
$menu
->
add
(
__
(
'Finance Dashboard'
),
route
(
'mileage::finance.index'
))
->
data
(
'icon'
,
'calculator'
)
->
data
(
'icon'
,
'calculator'
)
...
...
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