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
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
648 additions
and
503 deletions
+648
-503
packages/portal/mileage/resources/views/HR/index.blade.php
+92
-180
packages/portal/mileage/resources/views/HR/show.blade.php
+242
-141
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
+38
-109
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
<title>
HR Dashboard
</title>
@
extends
(
'ui::layouts.app'
)
@
section
(
'content'
)
<style>
body
{
background-color
:
#f0f2f5
;
}
.ui.container
{
max-width
:
100%
!important
;
overflow-x
:
hidden
;
padding
:
0
5rem
0
2rem
;
box-sizing
:
border-box
;
margin-top
:
3rem
;
}
h2
.ui.header
{
font-size
:
1.8rem
;
font-weight
:
700
;
color
:
#1b1c1d
;
margin-bottom
:
0.5rem
;
}
h3
.ui.dividing.header
{
font-size
:
1.3rem
;
font-weight
:
600
;
color
:
#444
;
margin-top
:
0.5rem
;
margin-bottom
:
1.5rem
;
border-bottom
:
2px
solid
#ddd
;
padding-bottom
:
0.5rem
;
}
.ui.table
{
margin-top
:
1rem
!important
;
background
:
white
;
border-radius
:
10px
;
box-shadow
:
0
4px
6px
rgba
(
0
,
0
,
0
,
0.1
);
}
.ui.table
th
{
background
:
#f9fafb
!important
;
color
:
#444
;
font-weight
:
600
;
}
.ui.button
{
margin-right
:
0.3rem
!important
;
}
/* Filter bar (aligned right side of header) */
.header-with-filter
{
display
:
flex
;
justify-content
:
space-between
;
align-items
:
center
;
margin-bottom
:
1.2rem
;
}
.filter-bar
{
display
:
flex
;
align-items
:
center
;
gap
:
1rem
;
background
:
white
;
border-radius
:
8px
;
box-shadow
:
0
3px
6px
rgba
(
0
,
0
,
0
,
0.08
);
padding
:
0.5rem
1rem
;
width
:
fit-content
;
}
.filter-bar
label
{
font-weight
:
600
;
color
:
#333
;
margin-right
:
0.5rem
;
}
.filter-bar
input
[
type
=
"month"
]
{
border
:
1px
solid
#dcdcdc
;
border-radius
:
6px
;
padding
:
0.4rem
0.6rem
;
font-size
:
1rem
;
color
:
#333
;
transition
:
all
0.2s
ease
;
}
.filter-bar
input
[
type
=
"month"
]
:focus
{
border-color
:
#21ba45
;
outline
:
none
;
box-shadow
:
0
0
0
2px
rgba
(
33
,
186
,
69
,
0.15
);
}
@media
(
max-width
:
768px
)
{
.ui.container
{
padding
:
0
2rem
;
}
.header-row
{
flex-direction
:
column
;
align-items
:
flex-start
;
gap
:
1rem
;
}
.filter-bar
{
flex-direction
:
column
;
align-items
:
flex-start
;
width
:
100%
;
}
.filter-bar
button
{
width
:
100%
;
}
}
</style>
<div
class=
"ui container mt-5"
style=
"margin-top: 10px"
>
{{-- Header --}}
<br>
<div
class=
"header-row"
style=
"display: flex; justify-content: space-between; align-items: center;"
>
<h2
class=
"ui header"
>
Human Resources (HR) Dashboard
</h2>
{{-- Excel Export Button --}}
<button
class=
"ui teal button"
id=
"openExportModal"
>
<i
class=
"file excel icon"
></i>
Muat Turun Laporan Excel
</button>
<
div
class
="
ui
segment
">
<a class="
ui
teal
left
ribbon
label
">Senarai Tuntutan Mileage (HR)</a><br/>
<div class="
ui
segment
">
@if(session('success'))
<div class="
ui
success
message
">{{ session('success') }}</div>
@endif
@if(session('error'))
<div class="
ui
error
message
">{{ session('error') }}</div>
@endif
@php
$bulan
= [
1=>'Januari', 2=>'Februari', 3=>'Mac', 4=>'April',
5=>'Mei', 6=>'Jun', 7=>'Julai', 8=>'Ogos',
9=>'September', 10=>'Oktober', 11=>'November', 12=>'Disember'
];
$currentYear
= \Carbon\Carbon::now()->year;
$statusOptions
= [
11 => 'Disemak Kewangan',
12 => 'Dibayar',
];
@endphp
<form method="
GET
" action="
{{
route
(
'mileage::HR.index'
)
}}
" class="
ui
form
" style="
margin
-
bottom
:
1
rem
;
">
<div class="
four
fields
">
<div class="
field
">
<label>Tahun</label>
<select name="
tahun
" class="
ui
dropdown
">
<option value="">Semua Tahun</option>
@for(
$y
=
$currentYear
;
$y
>=
$currentYear
- 4;
$y
--)
<option value="
{{
$y
}}
" {{ request('tahun') ==
$y
? 'selected' : '' }}>{{
$y
}}</option>
@endfor
</select>
</div>
<br><br>
{{-- Header + Filter Bar in same row --}}
<div
class=
"header-with-filter"
>
<h3
class=
"ui dividing header"
style=
"margin-bottom: 0;"
>
Senarai Tuntutan Mengikut Staf
</h3>
<form
method=
"GET"
class=
"filter-bar"
>
<label
for=
"month"
>
Bulan:
</label>
<input
type=
"month"
id=
"month"
name=
"month"
value=
"{{ $month ?? now()->format('Y-m') }}"
required
>
<button
class=
"ui teal button"
>
<i
class=
"filter icon"
></i>
Tapis
</button>
</form>
<div class="
field
">
<label>Bulan</label>
<select name="
bulan
" class="
ui
dropdown
">
<option value="">Semua Bulan</option>
@foreach(
$bulan
as
$num
=>
$nama
)
<option value="
{{
$num
}}
" {{ request('bulan') ==
$num
? 'selected' : '' }}>{{
$nama
}}</option>
@endforeach
</select>
</div>
<div class="
field
">
<label>Status</label>
<select name="
status
" class="
ui
dropdown
">
<option value="">Semua Status</option>
@foreach(
$statusOptions
as
$val
=>
$label
)
<option value="
{{
$val
}}
" {{ request('status') ==
$val
? 'selected' : '' }}>{{
$label
}}</option>
@endforeach
</select>
</div>
<div class="
field
">
<label>Cari</label>
<input type="
text
" name="
search
" value="
{{
request
(
'search'
)
}}
" placeholder="
No
.
permohonan
/
nama
pemohon
">
</div>
</div>
<div style="
text
-
align
:
right
;
">
@if(request()->hasAny(['tahun', 'bulan', 'status', 'search']))
<a href="
{{
route
(
'mileage::HR.index'
)
}}
" class="
ui
button
">Reset</a>
@endif
<button type="
submit
" class="
ui
teal
button
"><i class="
search
icon
"></i> Cari</button>
</div>
</form>
{{-- Staff Table --}}
<table class="
ui
celled
table
">
<thead>
<tr>
<th>
Nama Staf
</th>
<th>
Jumlah Tuntutan
</th>
<th>
Jumlah Keseluruhan (RM)
</th>
<th>No</th>
<th>No. Permohonan</th>
<th>Nama Pemohon</th>
<th>Bulan Tuntutan</th>
<th>Tarikh Hantar</th>
<th>Status</th>
<th>Tindakan</th>
</tr>
</thead>
<tbody>
@forelse($users as $user
)
@forelse(
$list
as
$index
=>
$claim
)
<tr>
<td>
{{ $user['name'] }}
</td>
<td>
{{ $user['total_claims'] }}
</td>
<td>
RM {{ number_format($user['total_amount'], 2) }}
</td>
<td>{{
$list->firstItem
() +
$index
}}</td>
<td>{{
$claim->mm_apply_no
}}</td>
<td>{{
$claim->mm_staff_name
?? '-' }}</td>
<td>{{ (
$bulan[$claim->mm_claim_month]
?? '-') . ' ' .
$claim->mm_claim_year
}}</td>
<td>{{
$claim->mm_submit_date
? \Carbon\Carbon::parse(
$claim->mm_submit_date
)->format('d/m/Y') : '-' }}</td>
<td>
<span class="
ui
{{
$claim
->
status
==
12
?
'green'
:
'blue'
}}
label
">
{{
$claim->lkpStatus
?->description ?? '-' }}
</span>
</td>
<td>
<a
href=
"{{ route('mileage::HR.show', ['userId' => $user['id'], 'month' => $month]) }}"
class=
"ui blue button tiny"
>
Lihat
</a>
<a href="
{{
route
(
'mileage::HR.show'
,
$claim
->
id
)
}}
" class="
ui
blue
small
button
">
<i class="
eye
icon
"></i> Lihat
</a>
</td>
</tr>
@empty
<tr>
<td
colspan=
"4"
class=
"center aligned"
>
Tiada rekod tuntutan untuk bulan in
i.
</td>
<td colspan="
7
" class="
center
aligned
">Tiada rekod dijumpa
i.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
{{-- Filter Modal for Excel Export --}}
<div
class=
"ui modal"
id=
"exportModal"
>
<div
class=
"header"
>
Penapis Laporan Excel
</div>
<div
class=
"content"
>
<form
class=
"ui form"
action=
"{{ route('mileage::HR.export') }}"
method=
"GET"
>
<div
class=
"field"
>
<label>
Nama Staf
</label>
<select
name=
"user_id"
class=
"ui dropdown"
required
>
<option
value=
""
>
-- Pilih Staf --
</option>
@foreach($users as $user)
<option
value=
"{{ $user['id'] }}"
>
{{ $user['name'] }}
</option>
@endforeach
</select>
</div>
<div
class=
"field"
>
<label>
Bulan Tuntutan
</label>
<input
type=
"month"
name=
"month"
required
>
</div>
{{
$list->withQueryString
()->links() }}
<div
class=
"actions"
style=
"text-align: right; margin-top: 2rem;"
>
<button
type=
"button"
class=
"ui button"
id=
"cancelExport"
>
Batal
</button>
<button
type=
"submit"
class=
"ui teal button"
>
<i
class=
"download icon"
></i>
Muat Turun
</button>
</div>
</form>
</div>
</div>
{{-- JS --}}
<script>
document
.
getElementById
(
'openExportModal'
).
addEventListener
(
'click'
,
function
()
{
$
(
'#exportModal'
).
modal
(
'show'
);
});
@endsection
document
.
getElementById
(
'cancelExport'
).
addEventListener
(
'click'
,
function
()
{
$
(
'#exportModal'
).
modal
(
'hide'
);
});
@push('script')
<script>
$(document).ready(function () {
$('.ui.dropdown').dropdown();
});
</script>
@end
section
@end
push
packages/portal/mileage/resources/views/HR/show.blade.php
View file @
470f1281
<title>
Butiran Tuntutan Staf
</title>
@
extends
(
'ui::layouts.app'
)
@
section
(
'content'
)
<style>
body
{
background-color
:
#f0f2f5
;
}
.ui.container
{
padding
:
0
5rem
3rem
2rem
;
margin-top
:
3rem
;
}
h2
.ui.header
{
font-size
:
1.8rem
;
font-weight
:
700
;
margin-bottom
:
.5rem
;
}
.ui.table
{
background
:
white
;
border-radius
:
10px
;
box-shadow
:
0
4px
6px
rgba
(
0
,
0
,
0
,
0.1
);
}
.ui.segment
{
background
:
white
;
border-radius
:
10px
;
box-shadow
:
0
4px
6px
rgba
(
0
,
0
,
0
,
0.1
);
margin-top
:
2rem
;
padding
:
1.5rem
;
}
.ui.button
{
margin-top
:
1rem
;
}
.status-label
{
display
:
inline-block
;
padding
:
6px
12px
;
border-radius
:
8px
;
font-size
:
0.85rem
;
font-weight
:
600
;
text-transform
:
capitalize
;
opacity
:
0.9
;
}
.status-Diproses
{
background-color
:
rgba
(
33
,
133
,
208
,
0.3
);
color
:
#1b4f72
;
}
.status-Disokong
{
background-color
:
rgba
(
46
,
204
,
113
,
0.3
);
color
:
#1d5d38
;
}
.status-Disahkan
{
background-color
:
rgba
(
241
,
196
,
15
,
0.3
);
color
:
#7a6000
;
}
.status-Disemak
{
background-color
:
rgba
(
155
,
89
,
182
,
0.3
);
color
:
#4a2c63
;
}
.status-Diluluskan
{
background-color
:
rgba
(
26
,
188
,
156
,
0.3
);
color
:
#0b5449
;
}
.status-Ditolak
{
background-color
:
rgba
(
231
,
76
,
60
,
0.3
);
color
:
#7e2018
;
}
@media
(
max-width
:
768px
)
{
.ui.container
{
padding
:
0
2rem
;
}
}
.totals-row
td
{
font-weight
:
700
;
background
:
#f7f7f8
;
}
</style>
<div
class=
"ui container"
>
{{-- Header --}}
<h2
class=
"ui header"
>
{{ $user->name }}
</h2>
<p><strong>
Bulan:
</strong>
{{ \Carbon\Carbon::parse($month)->translatedFormat('F Y') }}
</p>
<
div
class
="
ui
segment
">
<a class="
ui
teal
left
ribbon
label
">Butiran Tuntutan Mileage (HR) - {{
$claim->mm_apply_no
}}</a><br/><br/>
{{-- Back button --}}
<a
href=
"{{ route('mileage::HR.index', ['month' => $month]) }}"
class=
"ui grey button"
>
<i
class=
"arrow left icon"
></i>
Kembali
</a>
{{-- Maklumat Permohonan --}}
<div class="
ui
segment
">
<h3 class="
ui
header
">Maklumat Permohonan</h3>
@php
$bulan
= [
1=>'Januari', 2=>'Februari', 3=>'Mac', 4=>'April',
5=>'Mei', 6=>'Jun', 7=>'Julai', 8=>'Ogos',
9=>'September', 10=>'Oktober', 11=>'November', 12=>'Disember'
];
@endphp
<table class="
ui
definition
table
">
<tr>
<td>No. Permohonan</td>
<td>{{
$claim->mm_apply_no
}}</td>
</tr>
<tr>
<td>Nama Pemohon</td>
<td>{{
$claim->mm_staff_name
?? '-' }}</td>
</tr>
<tr>
<td>Kategori FA</td>
<td>{{
$claim->faCategory
?->fa_category ?? '-' }}</td>
</tr>
<tr>
<td>Bulan Tuntutan</td>
<td>{{ (
$bulan[$claim->mm_claim_month]
?? '-') . ' ' .
$claim->mm_claim_year
}}</td>
</tr>
<tr>
<td>Tarikh Hantar</td>
<td>{{
$claim->mm_submit_date
? \Carbon\Carbon::parse(
$claim->mm_submit_date
)->format('d/m/Y') : '-' }}</td>
</tr>
<tr>
<td>Disokong Oleh (HOD)</td>
<td>{{
$claim->verifiedBy
?->name ?? '-' }}{{
$claim->mm_verified_date
? ' (' . \Carbon\Carbon::parse(
$claim->mm_verified_date
)->format('d/m/Y') . ')' : '' }}</td>
</tr>
<tr>
<td>Diluluskan Oleh (BOD)</td>
<td>{{
$claim->approvedBy
?->name ?? '-' }}{{
$claim->mm_approved_date
? ' (' . \Carbon\Carbon::parse(
$claim->mm_approved_date
)->format('d/m/Y') . ')' : '' }}</td>
</tr>
<tr>
<td>Status</td>
<td>
<span class="
ui
{{
$claim
->
status
==
12
?
'green'
:
'blue'
}}
label
">
{{
$claim->lkpStatus
?->description ?? '-' }}
</span>
</td>
</tr>
</table>
</div>
{{-- Claims Table --}}
{{-- Butiran Tuntutan --}}
<div class="
ui
segment
">
<h3 class="
ui
header
">Butiran Tuntutan</h3>
<table class="
ui
celled
table
">
<thead>
<tr>
<th>No</th>
<th>Tarikh</th>
<th>Kenderaan</th>
<th>Projek</th>
<th>Butiran</th>
<th>
Dari
</th>
<th>
Ke
</th>
<th>
Jumlah KM
</th>
<th>
Tol (RM)
</th>
<th>
Lain-lain (RM)
</th>
<th>
Status
</th>
<th>
Jumlah (RM)
</th>
<th>
Tindakan
</th>
<th class="
right
aligned
">Jumlah Jarak (KM)</th>
<th class="
right
aligned
">Jumlah Tol (RM)</th>
<th class="
right
aligned
">Jumlah Parking (RM)</th>
<th class="
right
aligned
">Anggaran Tuntutan (RM)</th>
</tr>
</thead>
<tbody>
@php
$total = 0;
$totalMileage = 0;
$totalToll = 0;
$totalOthers = 0;
$grandAnggaran
= 0;
$grandTol
= 0;
$grandParking
= 0;
$grandJarak
= 0;
$deductionCount
= 0;
$sortedDetails
=
$claim->details
->sortBy('md_claim_date')->values();
$dateCounts
= [];
foreach (
$sortedDetails
as
$d
) {
$dk
=
$d->md_claim_date
;
$dateCounts[$dk]
= (
$dateCounts[$dk]
?? 0) + 1;
}
$dateFirstSeen
= [];
$cumulativeKm
= 0;
@endphp
@forelse($claims as $claim
)
@forelse(
$sortedDetails
as
$index
=>
$detail
)
@php
$total += $claim->total_claim_amount;
$totalMileage += $claim->total_mileage ?? 0;
$totalToll += $claim->toll_amount ?? 0;
$totalOthers += $claim->others_amount ?? 0;
$jumlahJarak
= (float)
$detail->md_total_mileage
;
$dateKey
=
$detail->md_claim_date
;
$isFirstOfDate
= !isset(
$dateFirstSeen[$dateKey]
);
if (
$isFirstOfDate
)
$dateFirstSeen[$dateKey]
= true;
if (
$isFirstOfDate
&&
$deductionCount
< 10) {
$claimableKm
= max(0,
$jumlahJarak
- 40);
$deductionCount
++;
} else {
$claimableKm
=
$jumlahJarak
;
}
$startKm
=
$cumulativeKm
;
$endKm
=
$cumulativeKm
+
$claimableKm
;
$mileageAmount
= 0;
foreach (
$detail->jenisKenderaan
?->rates ?? collect() as
$tier
) {
$kmInTier
= max(0, min(
$tier->km_to
,
$endKm
) - max(
$tier->km_from
,
$startKm
));
$mileageAmount
+=
$kmInTier
* (float)
$tier->rate
;
}
$cumulativeKm
=
$endKm
;
$jumlahTol
= (float)
$detail->md_total_toll
;
$jumlahParking
= (float)
$detail->md_total_parking_fee
;
$anggaranTuntutan
=
$mileageAmount
+
$jumlahTol
+
$jumlahParking
;
$grandJarak
+=
$jumlahJarak
;
$grandTol
+=
$jumlahTol
;
$grandParking
+=
$jumlahParking
;
$grandAnggaran
+=
$anggaranTuntutan
;
@endphp
<tr>
<td>
{{ \Carbon\Carbon::parse($claim->claim_date)->format('d/m/Y') }}
</td>
<td>
{{ $claim->description ?? '-' }}
</td>
<td>
{{ $claim->distance_from ?? '-' }}
</td>
<td>
{{ $claim->distance_to ?? '-' }}
</td>
<td>
{{ $claim->total_mileage }}
</td>
<td>
{{ number_format($claim->toll_amount ?? 0, 2) }}
</td>
<td>
{{ number_format($claim->others_amount ?? 0, 2) }}
</td>
<td>
<span
class=
"status-label status-{{ $claim->status }}"
>
{{ $claim->status }}
</span>
</td>
<td>
{{ number_format($claim->total_claim_amount, 2) }}
</td>
<td
style=
"text-align:center;"
>
{{-- Lihat (View) --}}
<a
href=
"{{ route('mileage::HR.viewEach', ['id' => $claim->id]) }}"
class=
"ui blue button tiny"
>
<i
class=
"eye icon"
></i>
Lihat
</a>
{{-- Tolak (Reject) --}}
@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 tiny"
onclick=
"return confirm('Tolak tuntutan ini?')"
>
<i
class=
"times icon"
></i>
Tolak
</button>
</form>
<td>{{
$index
+ 1 }}</td>
@if(
$isFirstOfDate
)
<td rowspan="
{{
$dateCounts
[
$dateKey
]
}}
">{{ \Carbon\Carbon::parse(
$dateKey
)->format('d/m/Y') }}</td>
@endif
</td>
<td>{{
$detail->jenisKenderaan
?->name ?? '-' }}</td>
<td>{{
$detail->project
?
$detail->project
->p_project_code . ' - ' .
$detail->project
->p_project_description : 'Tiada Projek' }}</td>
<td>{{
$detail->md_description
}}</td>
<td class="
right
aligned
">{{ number_format(
$jumlahJarak
, 1) }}</td>
<td class="
right
aligned
">{{ number_format(
$jumlahTol
, 2) }}</td>
<td class="
right
aligned
">{{ number_format(
$jumlahParking
, 2) }}</td>
<td class="
right
aligned
">{{ number_format(
$anggaranTuntutan
, 2) }}</td>
</tr>
@empty
<tr>
<td
colspan=
"10"
class=
"center aligned"
>
Tiada tuntutan untuk bulan ini
.
</td>
<td colspan="
9
" class="
center
aligned
">Tiada butiran
.</td>
</tr>
@endforelse
</tbody>
@if(
$claim->details
->count() > 0)
<tfoot>
<tr>
<th colspan="
5
" class="
right
aligned
">JUMLAH KESELURUHAN</th>
<th class="
right
aligned
">{{ number_format(
$grandJarak
, 1) }}</th>
<th class="
right
aligned
">{{ number_format(
$grandTol
, 2) }}</th>
<th class="
right
aligned
">{{ number_format(
$grandParking
, 2) }}</th>
<th class="
right
aligned
">{{ number_format(
$grandAnggaran
, 2) }}</th>
</tr>
</tfoot>
@endif
</table>
</div>
{{-- combined Calculation + Penalty Summary --}}
@if($claims->count() > 0)
@php
$uniqueDates = $claims->pluck('claim_date')->unique()->count();
$deduction = 40 * $uniqueDates;
$claimableDistance = max(0, $totalMileage - $deduction);
// Vehicle-based rate note
$vehicleType = strtolower($claims->first()->jenisKenderaan->name ?? 'kereta');
if ($vehicleType === 'motosikal' || $vehicleType === 'motorcycle') {
$rateNote = "Motosikal – RM0.30/km";
} else {
$rateNote = ($claimableDistance
<
=
500
)
?
"
Kereta
–
RM0
.
55
/
km
(≤
500km
)"
:
"
Kereta
–
500km
×
RM0
.
55
+
"
.
number_format
($
claimableDistance
-
500
,
1
)
.
"
km
×
RM0
.
50
";
}
{{-- Pelarasan Kewangan --}}
@if(
$claim->financeDetail
)
<div class="
ui
segment
">
<h3 class="
ui
header
">Pelarasan Kewangan</h3>
<table class="
ui
definition
table
">
<tr>
<td>Jumlah Asal (RM)</td>
<td>{{ number_format(
$claim->financeDetail
->fin_original_amount, 2) }}</td>
</tr>
<tr>
<td>Kadar Penalti</td>
<td>
@if(
$claim->financeDetail
->fin_penalty_rate === null)
Budi Bicara BOD
@elseif(
$claim->financeDetail
->fin_penalty_rate == 0)
Tiada Penalti
@else
{{
$claim->financeDetail
->fin_penalty_rate }}%
@endif
</td>
</tr>
<tr>
<td>Potongan Penalti (RM)</td>
<td>{{ number_format(
$claim->financeDetail
->fin_penalty_amount, 2) }}</td>
</tr>
@if(
$claim->financeDetail
->fin_amendment_remark)
<tr>
<td>Catatan Kewangan</td>
<td>{{
$claim->financeDetail
->fin_amendment_remark }}</td>
</tr>
@endif
<tr>
<td><strong>Jumlah Akhir Tuntutan (RM)</strong></td>
<td><strong style="
color
:
green
;
">{{ number_format(
$claim->financeDetail
->fin_final_amount, 2) }}</strong></td>
</tr>
</table>
</div>
@endif
//
Penalty
data
$
latestClaim =
$claims-
>
sortByDesc('claim_date')->first();
$penaltyAmount = $latestClaim->penalty_amount ?? 0;
$penaltyReason = $latestClaim->penalty_reason ?? '-';
@endphp
{{-- Lampiran --}}
<div class="
ui
segment
">
<h3 class="
ui
header
">Lampiran / Bukti Transaksi</h3>
@if(
$claim->attachments
->count() > 0)
<table class="
ui
celled
table
">
<thead>
<tr>
<th>No</th>
<th>Nama Fail</th>
</tr>
</thead>
<tbody>
@foreach(
$claim->attachments
as
$index
=>
$file
)
<tr>
<td>{{
$index
+ 1 }}</td>
<td>
<a href="
{{
asset
(
'storage/'
.
$file
->
file_path
)
}}
" target="
_blank
">
<i class="
file
icon
"></i> {{
$file->file_name
}}
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
@else
<p class="
ui
grey
text
">Tiada lampiran.</p>
@endif
</div>
{{-- Sejarah Kuiri --}}
@if(
$claim->auditQueries
->count() > 0)
<div class="
ui
segment
">
<h4><i
class=
"calculator icon"
></i>
Ringkasan Pengiraan (Mengikut Rekod Sistem)
</h4>
<table
class=
"ui definition table"
>
<h3 class="
ui
header
">Sejarah Kuiri</h3>
<table class="
ui
celled
table
">
<thead>
<tr>
<th>Bil</th>
<th>Dikuiri Oleh</th>
<th>Catatan</th>
<th>Respons Pemohon</th>
<th>Tarikh</th>
</tr>
</thead>
<tbody>
<tr><td><strong>
Jumlah Jarak (Sebenar)
</strong></td><td>
{{ number_format($totalMileage, 1) }} KM
</td></tr>
<tr><td><strong>
Jumlah Hari Tuntutan
</strong></td><td>
{{ $uniqueDates }} hari
</td></tr>
<tr><td><strong>
Potongan 40KM/Hari
</strong></td><td>
40 × {{ $uniqueDates }} = {{ $deduction }} KM
</td></tr>
<tr><td><strong>
Jumlah Jarak Layak Tuntut
</strong></td><td>
{{ number_format($claimableDistance, 1) }} KM
</td></tr>
<tr><td><strong>
Kadar Kiraan
</strong></td><td>
{{ $rateNote }}
</td></tr>
<tr><td><strong>
Jumlah Tol
</strong></td><td>
RM {{ number_format($totalToll, 2) }}
</td></tr>
<tr><td><strong>
Jumlah Lain-lain
</strong></td><td>
RM {{ number_format($totalOthers, 2) }}
</td></tr>
<tr><td><strong>
Penalti
</strong></td><td>
RM {{ number_format($penaltyAmount, 2) }}
</td></tr>
<tr><td><strong>
Sebab Penalti
</strong></td><td>
{{ $penaltyReason }}
</td></tr>
<tr
class=
"totals-row"
>
<td><strong>
Jumlah Keseluruhan Akhir
</strong></td>
<td><strong>
RM {{ number_format($total - $penaltyAmount, 2) }}
</strong></td>
@foreach(
$claim->auditQueries
as
$index
=>
$q
)
<tr>
<td>{{
$index
+ 1 }}</td>
<td>
@if(
$q->kuiri_by
=== 'PM')
<span class="
ui
olive
label
">PM</span>
@elseif(
$q->kuiri_by
=== 'HOD')
<span class="
ui
teal
label
">HOD</span>
@elseif(
$q->kuiri_by
=== 'BOD')
<span class="
ui
violet
label
">BOD</span>
@else
-
@endif
</td>
<td>{{
$q->comment
?? '-' }}</td>
<td>
@if(
$q->response
)
{{
$q->response
}}
@else
<span class="
ui
orange
label
">Belum Dijawab</span>
@endif
</td>
<td>{{ \Carbon\Carbon::parse(
$q->created_at
)->format('d/m/Y H:i') }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
{{-- Info Section --}}
<div
class=
"ui segment"
>
<h4><i
class=
"info circle icon"
></i>
Seksyen Pengiraan:
</h4>
<p>
• Tuntutan bermula selepas 40KM pertama setiap hari.
<br>
• Kadar (Kereta): RM0.55/km (
<
500km), RM0.50/km (
>
500km).
<br>
• Kadar (Motosikal): RM0.30/km.
<br>
• Penalti dikenakan sekiranya tuntutan lewat dihantar (
>
1 bulan).
</p>
{{-- Buttons --}}
<div style="
text
-
align
:
right
;
">
<a href="
{{
route
(
'mileage::HR.index'
)
}}
" class="
ui
button
">
<i class="
arrow
left
icon
"></i> Kembali
</a>
<a href="
{{
route
(
'mileage::mileage.claim.downloadPdf'
,
$claim
->
id
)
}}
" class="
ui
teal
button
" target="
_blank
">
<i class="
file
pdf
icon
"></i> Muat Turun PDF
</a>
</div>
<br><br>
</div>
@endsection
@push('script')
<script>
$(document).ready(function () {
$('#modalAnggaran').modal({ closable: true });
});
</script>
@endpush
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 @@
<a href="
{{
route
(
'mileage::mileage.listmileage'
)
}}
" class="
ui
right
floated
button
">
<i class="
arrow
left
icon
"></i> Kembali ke Senarai
</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
<br>
<br>
...
...
packages/portal/mileage/resources/views/mileage/pdf.blade.php
0 → 100644
View file @
470f1281
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
>
<title>
Tuntutan Mileage - {{ $claim->mm_apply_no }}
</title>
<style>
body
{
font-family
:
Arial
,
sans-serif
;
font-size
:
12px
;
color
:
#333
;
margin
:
20px
;
}
h2
{
font-size
:
13px
;
border-bottom
:
2px
solid
#333
;
padding-bottom
:
4px
;
margin-top
:
20px
;
}
table
{
width
:
100%
;
border-collapse
:
collapse
;
margin-bottom
:
10px
;
font-size
:
11px
;
}
th
{
background-color
:
#f0f0f0
;
border
:
1px
solid
#ccc
;
padding
:
5px
8px
;
text-align
:
left
;
}
td
{
border
:
1px
solid
#ccc
;
padding
:
5px
8px
;
vertical-align
:
top
;
}
.right
{
text-align
:
right
;
}
.center
{
text-align
:
center
;
}
.label
{
background-color
:
#f9f9f9
;
font-weight
:
bold
;
width
:
25%
;
}
tfoot
td
{
background-color
:
#f0f0f0
;
font-weight
:
bold
;
}
.footer
{
margin-top
:
30px
;
font-size
:
10px
;
color
:
#666
;
text-align
:
center
;
border-top
:
1px
solid
#ccc
;
padding-top
:
8px
;
}
</style>
</head>
<body>
{{-- Header --}}
<div
style=
"text-align:center; margin-bottom:20px;"
>
<div
style=
"font-size:15px; font-weight:bold;"
>
SISTEM TUNTUTAN MILEAGE
</div>
<div
style=
"font-size:13px; font-weight:bold; margin-top:4px;"
>
BORANG TUNTUTAN MILEAGE
</div>
<div
style=
"margin-top:4px;"
>
No. Permohonan:
<strong>
{{ $claim->mm_apply_no }}
</strong></div>
</div>
{{-- 1. Maklumat Permohonan --}}
<h2>
1. Maklumat Permohonan
</h2>
@php
$bulan = [
1=>'Januari', 2=>'Februari', 3=>'Mac', 4=>'April',
5=>'Mei', 6=>'Jun', 7=>'Julai', 8=>'Ogos',
9=>'September', 10=>'Oktober', 11=>'November', 12=>'Disember'
];
@endphp
<table>
<tr>
<td
class=
"label"
>
No. Permohonan
</td>
<td>
{{ $claim->mm_apply_no }}
</td>
<td
class=
"label"
>
Status
</td>
<td>
{{ $claim->lkpStatus?->description ?? '-' }}
</td>
</tr>
<tr>
<td
class=
"label"
>
Nama Pemohon
</td>
<td>
{{ $claim->mm_staff_name ?? '-' }}
</td>
<td
class=
"label"
>
Kategori FA
</td>
<td>
{{ $claim->faCategory?->fa_category ?? '-' }}
</td>
</tr>
<tr>
<td
class=
"label"
>
Bulan Tuntutan
</td>
<td>
{{ ($bulan[$claim->mm_claim_month] ?? '-') . ' ' . $claim->mm_claim_year }}
</td>
<td
class=
"label"
>
Tarikh Hantar
</td>
<td>
{{ $claim->mm_submit_date ? \Carbon\Carbon::parse($claim->mm_submit_date)->format('d/m/Y') : '-' }}
</td>
</tr>
<tr>
<td
class=
"label"
>
Disokong Oleh (HOD)
</td>
<td>
{{ $claim->verifiedBy?->name ?? '-' }}{{ $claim->mm_verified_date ? ' (' . \Carbon\Carbon::parse($claim->mm_verified_date)->format('d/m/Y') . ')' : '' }}
</td>
<td
class=
"label"
>
Diluluskan Oleh (BOD)
</td>
<td>
{{ $claim->approvedBy?->name ?? '-' }}{{ $claim->mm_approved_date ? ' (' . \Carbon\Carbon::parse($claim->mm_approved_date)->format('d/m/Y') . ')' : '' }}
</td>
</tr>
</table>
{{-- 2. Butiran Tuntutan --}}
<h2>
2. Butiran Tuntutan
</h2>
@php
$grandAnggaran = 0; $grandTol = 0; $grandParking = 0; $grandJarak = 0;
$deductionCount = 0;
$sortedDetails = $claim->details->sortBy('md_claim_date')->values();
$dateFirstSeen = [];
$cumulativeKm = 0;
@endphp
<table>
<thead>
<tr>
<th>
No
</th>
<th>
Tarikh
</th>
<th>
Kenderaan
</th>
<th>
Projek
</th>
<th>
Butiran
</th>
<th
class=
"right"
>
Jarak (KM)
</th>
<th
class=
"right"
>
Tol (RM)
</th>
<th
class=
"right"
>
Parking (RM)
</th>
<th
class=
"right"
>
Anggaran (RM)
</th>
</tr>
</thead>
<tbody>
@forelse($sortedDetails as $index => $detail)
@php
$jumlahJarak = (float) $detail->md_total_mileage;
$dateKey = $detail->md_claim_date;
$isFirstOfDate = !isset($dateFirstSeen[$dateKey]);
if ($isFirstOfDate) $dateFirstSeen[$dateKey] = true;
if ($isFirstOfDate
&&
$deductionCount
<
10
)
{
$
claimableKm =
max(0,
$
jumlahJarak
-
40
);
$
deductionCount
++;
}
else
{
$
claimableKm =
$jumlahJarak;
}
$
startKm =
$cumulativeKm;
$
endKm =
$cumulativeKm
+
$
claimableKm
;
$
mileageAmount =
0;
foreach
($
detail-
>
jenisKenderaan?->rates ?? collect() as $tier) {
$kmInTier = max(0, min($tier->km_to, $endKm) - max($tier->km_from, $startKm));
$mileageAmount += $kmInTier * (float) $tier->rate;
}
$cumulativeKm = $endKm;
$jumlahTol = (float) $detail->md_total_toll;
$jumlahParking = (float) $detail->md_total_parking_fee;
$anggaranTuntutan = $mileageAmount + $jumlahTol + $jumlahParking;
$grandJarak += $jumlahJarak;
$grandTol += $jumlahTol;
$grandParking += $jumlahParking;
$grandAnggaran += $anggaranTuntutan;
@endphp
<tr>
<td
class=
"center"
>
{{ $index + 1 }}
</td>
<td>
{{ \Carbon\Carbon::parse($dateKey)->format('d/m/Y') }}
</td>
<td>
{{ $detail->jenisKenderaan?->name ?? '-' }}
</td>
<td>
{{ $detail->project ? $detail->project->p_project_code . ' - ' . $detail->project->p_project_description : 'Tiada Projek' }}
</td>
<td>
{{ $detail->md_description }}
</td>
<td
class=
"right"
>
{{ number_format($jumlahJarak, 1) }}
</td>
<td
class=
"right"
>
{{ number_format($jumlahTol, 2) }}
</td>
<td
class=
"right"
>
{{ number_format($jumlahParking, 2) }}
</td>
<td
class=
"right"
>
{{ number_format($anggaranTuntutan, 2) }}
</td>
</tr>
@empty
<tr><td
colspan=
"9"
class=
"center"
>
Tiada butiran.
</td></tr>
@endforelse
</tbody>
@if($claim->details->count() > 0)
<tfoot>
<tr>
<td
colspan=
"5"
class=
"right"
>
JUMLAH KESELURUHAN
</td>
<td
class=
"right"
>
{{ number_format($grandJarak, 1) }}
</td>
<td
class=
"right"
>
{{ number_format($grandTol, 2) }}
</td>
<td
class=
"right"
>
{{ number_format($grandParking, 2) }}
</td>
<td
class=
"right"
>
{{ number_format($grandAnggaran, 2) }}
</td>
</tr>
</tfoot>
@endif
</table>
{{-- 3. Pelarasan Kewangan --}}
@if($claim->financeDetail)
<h2>
3. Pelarasan Kewangan
</h2>
<table>
<tr>
<td
class=
"label"
>
Jumlah Asal (RM)
</td>
<td
class=
"right"
>
{{ number_format($claim->financeDetail->fin_original_amount, 2) }}
</td>
<td
class=
"label"
>
Kadar Penalti
</td>
<td
class=
"right"
>
@if($claim->financeDetail->fin_penalty_rate === null)
Budi Bicara BOD
@else
{{ $claim->financeDetail->fin_penalty_rate }}%
@endif
</td>
</tr>
<tr>
<td
class=
"label"
>
Jumlah Penalti (RM)
</td>
<td
class=
"right"
>
{{ number_format($claim->financeDetail->fin_penalty_amount, 2) }}
</td>
<td
class=
"label"
>
Jumlah Akhir (RM)
</td>
<td
class=
"right"
><strong>
{{ number_format($claim->financeDetail->fin_final_amount, 2) }}
</strong></td>
</tr>
@if($claim->financeDetail->fin_amendment_remark)
<tr>
<td
class=
"label"
>
Catatan Pindaan
</td>
<td
colspan=
"3"
>
{{ $claim->financeDetail->fin_amendment_remark }}
</td>
</tr>
@endif
</table>
@endif
{{-- 4. Lampiran --}}
@if($claim->attachments->count() > 0)
<h2>
4. Lampiran / Bukti Transaksi
</h2>
<table>
<thead>
<tr><th>
No
</th><th>
Nama Fail
</th></tr>
</thead>
<tbody>
@foreach($claim->attachments as $index => $file)
<tr>
<td
class=
"center"
>
{{ $index + 1 }}
</td>
<td>
{{ $file->file_name }}
</td>
</tr>
@endforeach
</tbody>
</table>
@endif
{{-- 5. Sejarah Kuiri --}}
@if($claim->auditQueries->count() > 0)
<h2>
5. Sejarah Kuiri
</h2>
<table>
<thead>
<tr>
<th>
Bil
</th>
<th>
Dikuiri Oleh
</th>
<th>
Catatan
</th>
<th>
Respons Pemohon
</th>
<th>
Tarikh
</th>
</tr>
</thead>
<tbody>
@foreach($claim->auditQueries as $index => $q)
<tr>
<td
class=
"center"
>
{{ $index + 1 }}
</td>
<td
class=
"center"
>
{{ $q->kuiri_by ?? '-' }}
</td>
<td>
{{ $q->comment ?? '-' }}
</td>
<td>
{{ $q->response ?? 'Belum Dijawab' }}
</td>
<td
class=
"center"
>
{{ \Carbon\Carbon::parse($q->created_at)->format('d/m/Y H:i') }}
</td>
</tr>
@endforeach
</tbody>
</table>
@endif
<div
class=
"footer"
>
Dokumen ini dijana secara automatik oleh sistem pada {{ \Carbon\Carbon::now()->format('d/m/Y H:i') }}.
</div>
</body>
</html>
packages/portal/mileage/routes/web.php
View file @
470f1281
...
...
@@ -87,11 +87,8 @@ function () {
// HR
Route
::
prefix
(
'HR'
)
->
name
(
'HR'
)
->
group
(
function
()
{
Route
::
get
(
'/dashboard'
,
[
HRController
::
class
,
'index'
])
->
name
(
'.index'
);
Route
::
get
(
'/show/{userId}'
,
[
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
(
'/'
,
[
HRController
::
class
,
'index'
])
->
name
(
'.index'
);
Route
::
get
(
'/{id}'
,
[
HRController
::
class
,
'show'
])
->
name
(
'.show'
);
});
Route
::
get
(
'index'
,
[
'uses'
=>
'MileageController@index'
,
'as'
=>
'mileage.index'
]);
...
...
@@ -114,6 +111,8 @@ function () {
// 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 @@
namespace
Portal\Mileage\Http\Controllers
;
use
Portal\Mileage\Model\Users
;
use
Portal\Mileage\Model\Project
;
use
Portal\Mileage\Model\JenisKenderaan
;
use
Portal\Mileage\Model\Claim
;
use
Portal\Mileage\Model\ProjectTeam
;
use
Portal\Mileage\Model\MileageClaimMain
;
use
App\Http\Controllers\Controller
;
use
Illuminate\Http\Request
;
use
Carbon\Carbon
;
use
Illuminate\Support\Facades\Auth
;
use
Maatwebsite\Excel\Facades\Excel
;
use
Portal\Mileage\Exports\ClaimsExport
;
use
DB
;
class
HRController
extends
Controller
{
public
function
index
(
Request
$request
)
{
$month
=
$request
->
input
(
'month'
,
Carbon
::
now
()
->
format
(
'Y-m'
));
$parsedMonth
=
Carbon
::
parse
(
$month
);
// Group claims by staff for the selected month
$claims
=
Claim
::
with
(
'user'
)
->
whereMonth
(
'claim_date'
,
$parsedMonth
->
month
)
->
whereYear
(
'claim_date'
,
$parsedMonth
->
year
)
->
get
()
->
groupBy
(
'user_id'
);
$users
=
$claims
->
map
(
function
(
$claimsForUser
)
{
$user
=
$claimsForUser
->
first
()
->
user
;
return
[
'id'
=>
$user
->
id
,
'name'
=>
$user
->
name
??
'-'
,
'total_claims'
=>
$claimsForUser
->
count
(),
'total_amount'
=>
$claimsForUser
->
sum
(
'total_claim_amount'
),
];
$search
=
$request
->
get
(
'search'
);
$tahun
=
$request
->
get
(
'tahun'
);
$bulan
=
$request
->
get
(
'bulan'
);
$status
=
$request
->
get
(
'status'
);
$list
=
MileageClaimMain
::
with
([
'lkpStatus'
,
'staffInfo'
])
->
whereIn
(
'status'
,
[
11
,
12
])
->
when
(
$search
,
function
(
$q
)
use
(
$search
)
{
$q
->
where
(
function
(
$q2
)
use
(
$search
)
{
$q2
->
where
(
'mm_apply_no'
,
'like'
,
'%'
.
$search
.
'%'
)
->
orWhere
(
'mm_staff_name'
,
'like'
,
'%'
.
$search
.
'%'
);
});
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'
));
})
->
when
(
$tahun
,
fn
(
$q
)
=>
$q
->
where
(
'mm_claim_year'
,
$tahun
))
->
when
(
$bulan
,
fn
(
$q
)
=>
$q
->
where
(
'mm_claim_month'
,
$bulan
))
->
when
(
$status
,
fn
(
$q
)
=>
$q
->
where
(
'status'
,
$status
))
->
orderBy
(
'created_at'
,
'desc'
)
->
paginate
(
15
);
return
view
(
'mileage::HR.index'
,
compact
(
'list'
));
}
/**
* Reject claim (HR decision)
*/
public
function
reject
(
$id
)
public
function
show
(
$id
)
{
$hr
=
Auth
::
user
();
$claim
=
Claim
::
findOrFail
(
$id
);
$claim
->
status
=
'Ditolak'
;
$claim
->
rejected_by
=
$hr
->
id
;
// record who rejected it
$claim
->
save
();
return
back
()
->
with
(
'error'
,
'Tuntutan telah ditolak oleh HR.'
);
$claim
=
MileageClaimMain
::
with
([
'details.jenisKenderaan.rates'
,
'details.project'
,
'details.pmReviews'
,
'lkpStatus'
,
'staffInfo'
,
'auditQueries'
,
'attachments'
,
'faCategory'
,
'financeDetail'
,
'verifiedBy'
,
'approvedBy'
,
])
->
findOrFail
(
$id
);
if
(
!
in_array
(
$claim
->
status
,
[
11
,
12
]))
{
abort
(
403
,
'Permohonan ini tidak tersedia untuk semakan HR.'
);
}
/**
* Export all claims to Excel
*/
public
function
export
(
Request
$request
)
{
$userId
=
$request
->
input
(
'user_id'
);
$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
$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
);
return
view
(
'mileage::HR.show'
,
compact
(
'claim'
));
}
}
packages/portal/mileage/src/Http/Controllers/MileageController.php
View file @
470f1281
...
...
@@ -4,10 +4,12 @@
use
Illuminate\Routing\Controller
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Auth
;
use
Illuminate\Support\Facades\Gate
;
use
Illuminate\Support\Facades\Input
;
use
Carbon\Carbon
;
use
Auth
;
use
DB
;
use
Event
;
use
File
;
...
...
@@ -175,5 +177,39 @@ public function deleteClaim(Request $request, $id)
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()
->
data
(
'permission'
,
Permission
::
BOD
);
//
$menu->add(__('HR Dashboard'), route('mileage::HR.index'))
//
->data('icon', 'id badge')
//
->active('HR/*')
//
->data('permission', Permission::HR);
$menu
->
add
(
__
(
'HR Dashboard'
),
route
(
'mileage::HR.index'
))
->
data
(
'icon'
,
'id badge'
)
->
active
(
'HR/*'
)
->
data
(
'permission'
,
Permission
::
HR
);
$menu
->
add
(
__
(
'Finance Dashboard'
),
route
(
'mileage::finance.index'
))
->
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