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
786bc219
Commit
786bc219
authored
Aug 17, 2026
by
Muhammad Aniq bin Mohd Nizam
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of
https://coders.3fresources.com/trainee/mileage-claim
# Conflicts: # packages/portal/mileage/routes/web.php
parents
c40125a6
470f1281
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
819 additions
and
539 deletions
+819
-539
packages/portal/mileage/resources/views/HR/index.blade.php
+109
-197
packages/portal/mileage/resources/views/HR/show.blade.php
+254
-153
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
+5
-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
packages/portal/overtime/resources/views/overtime/overtimeclaim/view_modal.blade.php
+38
-2
packages/portal/overtime/resources/views/overtime/overtimeclaim/view_modal_content.blade.php
+4
-4
packages/portal/overtime/routes/web.php
+1
-0
packages/portal/overtime/src/Http/Controllers/OvertimeClaimController.php
+97
-0
No files found.
packages/portal/mileage/resources/views/HR/index.blade.php
View file @
786bc219
<title>
HR Dashboard
</title>
@
extends
(
'ui::layouts.app'
)
@
extends
(
'ui::layouts.app'
)
@
section
(
'content'
)
@
section
(
'content'
)
<style>
body
{
background-color
:
#f0f2f5
;
}
.ui.container
{
<
div
class
="
ui
segment
">
max-width
:
100%
!important
;
<a class="
ui
teal
left
ribbon
label
">Senarai Tuntutan Mileage (HR)</a><br/>
overflow-x
:
hidden
;
<div class="
ui
segment
">
padding
:
0
5rem
0
2rem
;
box-sizing
:
border-box
;
@if(session('success'))
margin-top
:
3rem
;
<div class="
ui
success
message
">{{ session('success') }}</div>
}
@endif
@if(session('error'))
h2
.ui.header
{
<div class="
ui
error
message
">{{ session('error') }}</div>
font-size
:
1.8rem
;
@endif
font-weight
:
700
;
color
:
#1b1c1d
;
@php
margin-bottom
:
0.5rem
;
$bulan
= [
}
1=>'Januari', 2=>'Februari', 3=>'Mac', 4=>'April',
5=>'Mei', 6=>'Jun', 7=>'Julai', 8=>'Ogos',
h3
.ui.dividing.header
{
9=>'September', 10=>'Oktober', 11=>'November', 12=>'Disember'
font-size
:
1.3rem
;
];
font-weight
:
600
;
$currentYear
= \Carbon\Carbon::now()->year;
color
:
#444
;
$statusOptions
= [
margin-top
:
0.5rem
;
11 => 'Disemak Kewangan',
margin-bottom
:
1.5rem
;
12 => 'Dibayar',
border-bottom
:
2px
solid
#ddd
;
];
padding-bottom
:
0.5rem
;
@endphp
}
<form method="
GET
" action="
{{
route
(
'mileage::HR.index'
)
}}
" class="
ui
form
" style="
margin
-
bottom
:
1
rem
;
">
.ui.table
{
<div class="
four
fields
">
margin-top
:
1rem
!important
;
<div class="
field
">
background
:
white
;
<label>Tahun</label>
border-radius
:
10px
;
<select name="
tahun
" class="
ui
dropdown
">
box-shadow
:
0
4px
6px
rgba
(
0
,
0
,
0
,
0.1
);
<option value="">Semua Tahun</option>
}
@for(
$y
=
$currentYear
;
$y
>=
$currentYear
- 4;
$y
--)
<option value="
{{
$y
}}
" {{ request('tahun') ==
$y
? 'selected' : '' }}>{{
$y
}}</option>
.ui.table
th
{
@endfor
background
:
#f9fafb
!important
;
</select>
color
:
#444
;
</div>
font-weight
:
600
;
<div class="
field
">
}
<label>Bulan</label>
<select name="
bulan
" class="
ui
dropdown
">
.ui.button
{
<option value="">Semua Bulan</option>
margin-right
:
0.3rem
!important
;
@foreach(
$bulan
as
$num
=>
$nama
)
}
<option value="
{{
$num
}}
" {{ request('bulan') ==
$num
? 'selected' : '' }}>{{
$nama
}}</option>
@endforeach
/* Filter bar (aligned right side of header) */
</select>
.header-with-filter
{
</div>
display
:
flex
;
<div class="
field
">
justify-content
:
space-between
;
<label>Status</label>
align-items
:
center
;
<select name="
status
" class="
ui
dropdown
">
margin-bottom
:
1.2rem
;
<option value="">Semua Status</option>
}
@foreach(
$statusOptions
as
$val
=>
$label
)
<option value="
{{
$val
}}
" {{ request('status') ==
$val
? 'selected' : '' }}>{{
$label
}}</option>
.filter-bar
{
@endforeach
display
:
flex
;
</select>
align-items
:
center
;
</div>
gap
:
1rem
;
<div class="
field
">
background
:
white
;
<label>Cari</label>
border-radius
:
8px
;
<input type="
text
" name="
search
" value="
{{
request
(
'search'
)
}}
" placeholder="
No
.
permohonan
/
nama
pemohon
">
box-shadow
:
0
3px
6px
rgba
(
0
,
0
,
0
,
0.08
);
</div>
padding
:
0.5rem
1rem
;
</div>
width
:
fit-content
;
<div style="
text
-
align
:
right
;
">
}
@if(request()->hasAny(['tahun', 'bulan', 'status', 'search']))
<a href="
{{
route
(
'mileage::HR.index'
)
}}
" class="
ui
button
">Reset</a>
.filter-bar
label
{
@endif
font-weight
:
600
;
<button type="
submit
" class="
ui
teal
button
"><i class="
search
icon
"></i> Cari</button>
color
:
#333
;
</div>
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>
<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>
</form>
</div>
{{-- Staff Table --}}
<table class="
ui
celled
table
">
<table
class=
"ui celled table"
>
<thead>
<thead>
<tr>
<th>
Nama Staf
</th>
<th>
Jumlah Tuntutan
</th>
<th>
Jumlah Keseluruhan (RM)
</th>
<th>
Tindakan
</th>
</tr>
</thead>
<tbody>
@forelse($users as $user)
<tr>
<tr>
<t
d>
{{ $user['name'] }}
</td
>
<t
h>No</th
>
<t
d>
{{ $user['total_claims'] }}
</td
>
<t
h>No. Permohonan</th
>
<t
d>
RM {{ number_format($user['total_amount'], 2) }}
</td
>
<t
h>Nama Pemohon</th
>
<t
d
>
<t
h>Bulan Tuntutan</th
>
<a
href=
"{{ route('mileage::HR.show', ['userId' => $user['id'], 'month' => $month]) }}"
<th>Tarikh Hantar</th>
class=
"ui blue button tiny"
>
Lihat
</a
>
<th>Status</th
>
<
/td
>
<
th>Tindakan</th
>
</tr>
</tr>
@empty
</thead>
<tr>
<tbody>
<td
colspan=
"4"
class=
"center aligned"
>
Tiada rekod tuntutan untuk bulan ini.
</td>
@forelse(
$list
as
$index
=>
$claim
)
</tr>
<tr>
@endforelse
<td>{{
$list->firstItem
() +
$index
}}</td>
</tbody>
<td>{{
$claim->mm_apply_no
}}</td>
</table>
<td>{{
$claim->mm_staff_name
?? '-' }}</td>
</div>
<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>
{{-- Filter Modal for Excel Export --}}
<td>
<div
class=
"ui modal"
id=
"exportModal"
>
<span class="
ui
{{
$claim
->
status
==
12
?
'green'
:
'blue'
}}
label
">
<div
class=
"header"
>
Penapis Laporan Excel
</div>
{{
$claim->lkpStatus
?->description ?? '-' }}
<div
class=
"content"
>
</span>
<form
class=
"ui form"
action=
"{{ route('mileage::HR.export') }}"
method=
"GET"
>
</td>
<div
class=
"field"
>
<td>
<label>
Nama Staf
</label>
<a href="
{{
route
(
'mileage::HR.show'
,
$claim
->
id
)
}}
" class="
ui
blue
small
button
">
<select
name=
"user_id"
class=
"ui dropdown"
required
>
<i class="
eye
icon
"></i> Lihat
<option
value=
""
>
-- Pilih Staf --
</option>
</a>
@foreach($users as $user)
</td>
<option
value=
"{{ $user['id'] }}"
>
{{ $user['name'] }}
</option>
</tr>
@endforeach
@empty
</select>
<tr>
</div>
<td colspan="
7
" class="
center
aligned
">Tiada rekod dijumpai.</td>
</tr>
@endforelse
</tbody>
</table>
{{
$list->withQueryString
()->links() }}
<div
class=
"field"
>
<label>
Bulan Tuntutan
</label>
<input
type=
"month"
name=
"month"
required
>
</div>
<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>
</div>
</div>
{{-- JS --}}
@endsection
<script>
document
.
getElementById
(
'openExportModal'
).
addEventListener
(
'click'
,
function
()
{
$
(
'#exportModal'
).
modal
(
'show'
);
});
document
.
getElementById
(
'cancelExport'
).
addEventListener
(
'click'
,
function
()
{
@push('script')
$
(
'#exportModal'
).
modal
(
'hide'
);
<script>
});
$(document).ready(function () {
$('.ui.dropdown').dropdown();
});
</script>
</script>
@end
section
@end
push
packages/portal/mileage/resources/views/HR/show.blade.php
View file @
786bc219
<title>
Butiran Tuntutan Staf
</title>
@
extends
(
'ui::layouts.app'
)
@
extends
(
'ui::layouts.app'
)
@
section
(
'content'
)
@
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
{
<
div
class
="
ui
segment
">
display
:
inline-block
;
<a class="
ui
teal
left
ribbon
label
">Butiran Tuntutan Mileage (HR) - {{
$claim->mm_apply_no
}}</a><br/><br/>
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
)
{
{{-- Maklumat Permohonan --}}
.ui.container
{
padding
:
0
2rem
;
}
<div class="
ui
segment
">
}
<h3 class="
ui
header
">Maklumat Permohonan</h3>
@php
.totals-row
td
{
$bulan
= [
font-weight
:
700
;
1=>'Januari', 2=>'Februari', 3=>'Mac', 4=>'April',
background
:
#f7f7f8
;
5=>'Mei', 6=>'Jun', 7=>'Julai', 8=>'Ogos',
}
9=>'September', 10=>'Oktober', 11=>'November', 12=>'Disember'
</style>
];
@endphp
<div
class=
"ui container"
>
<table class="
ui
definition
table
">
{{-- Header --}}
<h2
class=
"ui header"
>
{{ $user->name }}
</h2>
<p><strong>
Bulan:
</strong>
{{ \Carbon\Carbon::parse($month)->translatedFormat('F Y') }}
</p>
{{-- Back button --}}
<a
href=
"{{ route('mileage::HR.index', ['month' => $month]) }}"
class=
"ui grey button"
>
<i
class=
"arrow left icon"
></i>
Kembali
</a>
{{-- Claims Table --}}
<table
class=
"ui celled table"
>
<thead>
<tr>
<tr>
<th>
Tarikh
</th>
<td>No. Permohonan</td>
<th>
Butiran
</th>
<td>{{
$claim->mm_apply_no
}}</td>
<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>
</tr>
</tr>
</thead>
<tr>
<td>Nama Pemohon</td>
<tbody>
<td>{{
$claim->mm_staff_name
?? '-' }}</td>
@php
</tr>
$total = 0;
<tr>
$totalMileage = 0;
<td>Kategori FA</td>
$totalToll = 0;
<td>{{
$claim->faCategory
?->fa_category ?? '-' }}</td>
$totalOthers = 0;
</tr>
@endphp
<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>
@forelse($claims as $claim)
{{-- 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 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
@php
$total += $claim->total_claim_amount;
$grandAnggaran
= 0;
$grandTol
= 0;
$grandParking
= 0;
$grandJarak
= 0;
$totalMileage += $claim->total_mileage ?? 0;
$deductionCount
= 0;
$totalToll += $claim->toll_amount ?? 0;
$sortedDetails
=
$claim->details
->sortBy('md_claim_date')->values();
$totalOthers += $claim->others_amount ?? 0;
$dateCounts
= [];
foreach (
$sortedDetails
as
$d
) {
$dk
=
$d->md_claim_date
;
$dateCounts[$dk]
= (
$dateCounts[$dk]
?? 0) + 1;
}
$dateFirstSeen
= [];
$cumulativeKm
= 0;
@endphp
@endphp
@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>{{
$index
+ 1 }}</td>
@if(
$isFirstOfDate
)
<td rowspan="
{{
$dateCounts
[
$dateKey
]
}}
">{{ \Carbon\Carbon::parse(
$dateKey
)->format('d/m/Y') }}</td>
@endif
<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="
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>
{{-- 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>
<tr>
<td>
{{ \Carbon\Carbon::parse($claim->claim_date)->format('d/m/Y') }}
</td>
<td>Kadar Penalti</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>
<td>
<span
class=
"status-label status-{{ $claim->status }}"
>
@if(
$claim->financeDetail
->fin_penalty_rate === null)
{{ $claim->status }}
Budi Bicara BOD
</span>
@elseif(
$claim->financeDetail
->fin_penalty_rate == 0)
</td>
Tiada Penalti
<td>
{{ number_format($claim->total_claim_amount, 2) }}
</td>
@else
<td
style=
"text-align:center;"
>
{{
$claim->financeDetail
->fin_penalty_rate }}%
{{-- 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>
@endif
@endif
</td>
</td>
</tr>
</tr>
@empty
<tr>
<tr>
<td
colspan=
"10"
class=
"center aligned"
>
Tiada tuntutan untuk bulan ini.
</td>
<td>Potongan Penalti (RM)</td>
<td>{{ number_format(
$claim->financeDetail
->fin_penalty_amount, 2) }}</td>
</tr>
</tr>
@endforelse
@if(
$claim->financeDetail
->fin_amendment_remark)
</tbody>
<tr>
</table>
<td>Catatan Kewangan</td>
<td>{{
$claim->financeDetail
->fin_amendment_remark }}</td>
{{-- combined Calculation + Penalty Summary --}}
</tr>
@if($claims->count() > 0)
@endif
@php
<tr>
$uniqueDates = $claims->pluck('claim_date')->unique()->count();
<td><strong>Jumlah Akhir Tuntutan (RM)</strong></td>
$deduction = 40 * $uniqueDates;
<td><strong style="
color
:
green
;
">{{ number_format(
$claim->financeDetail
->fin_final_amount, 2) }}</strong></td>
$claimableDistance = max(0, $totalMileage - $deduction);
</tr>
</table>
// Vehicle-based rate note
</div>
$vehicleType = strtolower($claims->first()->jenisKenderaan->name ?? 'kereta');
@endif
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
";
}
//
Penalty
data
{{-- Lampiran --}}
$
latestClaim =
$claims-
>
sortByDesc('claim_date')->first();
<div class="
ui
segment
">
$penaltyAmount = $latestClaim->penalty_amount ?? 0;
<h3 class="
ui
header
">Lampiran / Bukti Transaksi</h3>
$penaltyReason = $latestClaim->penalty_reason ?? '-';
@if(
$claim->attachments
->count() > 0)
@endphp
<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
">
<div class="
ui
segment
">
<h4><i
class=
"calculator icon"
></i>
Ringkasan Pengiraan (Mengikut Rekod Sistem)
</h4>
<h3 class="
ui
header
">Sejarah Kuiri</h3>
<table
class=
"ui definition table"
>
<table class="
ui
celled
table
">
<tbody>
<thead>
<tr><td><strong>
Jumlah Jarak (Sebenar)
</strong></td><td>
{{ number_format($totalMileage, 1) }} KM
</td></tr>
<tr>
<tr><td><strong>
Jumlah Hari Tuntutan
</strong></td><td>
{{ $uniqueDates }} hari
</td></tr>
<th>Bil</th>
<tr><td><strong>
Potongan 40KM/Hari
</strong></td><td>
40 × {{ $uniqueDates }} = {{ $deduction }} KM
</td></tr>
<th>Dikuiri Oleh</th>
<tr><td><strong>
Jumlah Jarak Layak Tuntut
</strong></td><td>
{{ number_format($claimableDistance, 1) }} KM
</td></tr>
<th>Catatan</th>
<tr><td><strong>
Kadar Kiraan
</strong></td><td>
{{ $rateNote }}
</td></tr>
<th>Respons Pemohon</th>
<tr><td><strong>
Jumlah Tol
</strong></td><td>
RM {{ number_format($totalToll, 2) }}
</td></tr>
<th>Tarikh</th>
<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>
</tr>
</tr>
</thead>
<tbody>
@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>
</tbody>
</table>
</table>
</div>
</div>
@endif
@endif
{{-- Info Section --}}
{{-- Buttons --}}
<div
class=
"ui segment"
>
<div style="
text
-
align
:
right
;
">
<h4><i
class=
"info circle icon"
></i>
Seksyen Pengiraan:
</h4>
<a href="
{{
route
(
'mileage::HR.index'
)
}}
" class="
ui
button
">
<p>
<i class="
arrow
left
icon
"></i> Kembali
• Tuntutan bermula selepas 40KM pertama setiap hari.
<br>
</a>
• Kadar (Kereta): RM0.55/km (
<
500km), RM0.50/km (
>
500km).
<br>
<a href="
{{
route
(
'mileage::mileage.claim.downloadPdf'
,
$claim
->
id
)
}}
" class="
ui
teal
button
" target="
_blank
">
• Kadar (Motosikal): RM0.30/km.
<br>
<i class="
file
pdf
icon
"></i> Muat Turun PDF
• Penalti dikenakan sekiranya tuntutan lewat dihantar (
>
1 bulan).
</a>
</p>
</div>
</div>
<br><br>
</div>
</div>
@endsection
@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 @
c40125a6
<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 @
786bc219
...
@@ -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 @
786bc219
<!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 @
786bc219
...
@@ -85,11 +85,8 @@ function () {
...
@@ -85,11 +85,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'
]);
...
@@ -121,6 +118,9 @@ function () {
...
@@ -121,6 +118,9 @@ function () {
Route
::
put
(
'department/{id}'
,
[
DepartmentController
::
class
,
'update'
])
->
name
(
'department.update'
);
Route
::
put
(
'department/{id}'
,
[
DepartmentController
::
class
,
'update'
])
->
name
(
'department.update'
);
Route
::
delete
(
'department/{id}'
,
[
DepartmentController
::
class
,
'destroy'
])
->
name
(
'department.destroy'
);
Route
::
delete
(
'department/{id}'
,
[
DepartmentController
::
class
,
'destroy'
])
->
name
(
'department.destroy'
);
}
}
Route
::
get
(
'claim/{id}/pdf'
,
[
'uses'
=>
'MileageController@downloadPdf'
,
'as'
=>
'mileage.claim.downloadPdf'
]);
}
);
);
// Guest group (currently unused)
// Guest group (currently unused)
...
...
packages/portal/mileage/src/Http/Controllers/HRController.php
View file @
786bc219
...
@@ -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 @
786bc219
...
@@ -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 @
786bc219
...
@@ -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'
)
...
...
packages/portal/overtime/resources/views/overtime/overtimeclaim/view_modal.blade.php
View file @
786bc219
...
@@ -43,6 +43,12 @@
...
@@ -43,6 +43,12 @@
</div>
</div>
<div
class=
"actions"
>
<div
class=
"actions"
>
<button
class=
"ui teal button"
type=
"button"
id=
"btn-vm-download"
disabled
>
<i
class=
"download icon"
></i>
Download
</button>
<button
class=
"ui blue button"
type=
"button"
id=
"btn-vm-print"
disabled
>
<i
class=
"print icon"
></i>
Print
</button>
<button
class=
"ui grey button"
onclick=
"$('#modalViewTuntutan').modal('hide');"
>
<button
class=
"ui grey button"
onclick=
"$('#modalViewTuntutan').modal('hide');"
>
<i
class=
"times icon"
></i>
Close
<i
class=
"times icon"
></i>
Close
</button>
</button>
...
@@ -56,6 +62,7 @@
...
@@ -56,6 +62,7 @@
'January'
,
'February'
,
'March'
,
'April'
,
'May'
,
'June'
,
'January'
,
'February'
,
'March'
,
'April'
,
'May'
,
'June'
,
'July'
,
'August'
,
'September'
,
'October'
,
'November'
,
'December'
'July'
,
'August'
,
'September'
,
'October'
,
'November'
,
'December'
];
];
var
VCM_CLAIM_TITLE
=
'Overtime Claim Form'
;
function
vcmPad
(
n
)
{
return
String
(
n
).
padStart
(
2
,
'0'
);
}
function
vcmPad
(
n
)
{
return
String
(
n
).
padStart
(
2
,
'0'
);
}
function
vcmEsc
(
s
)
{
function
vcmEsc
(
s
)
{
...
@@ -71,7 +78,8 @@ function vcmFmtDate(str) {
...
@@ -71,7 +78,8 @@ function vcmFmtDate(str) {
}
}
function
viewTuntutan
(
id
)
{
function
viewTuntutan
(
id
)
{
$
(
'#vm-claim-content'
).
html
(
$
(
'#btn-vm-download, #btn-vm-print'
).
prop
(
'disabled'
,
true
);
$
(
'#vm-claim-content'
).
removeAttr
(
'data-claim-id data-claim-number'
).
html
(
'<div class="vm-loading"><i class="spinner loading icon"></i> Loading data…</div>'
'<div class="vm-loading"><i class="spinner loading icon"></i> Loading data…</div>'
);
);
$
(
'#modalViewTuntutan'
).
modal
({
blurring
:
true
,
closable
:
true
}).
modal
(
'show'
);
$
(
'#modalViewTuntutan'
).
modal
({
blurring
:
true
,
closable
:
true
}).
modal
(
'show'
);
...
@@ -81,7 +89,12 @@ function viewTuntutan(id) {
...
@@ -81,7 +89,12 @@ function viewTuntutan(id) {
method
:
'GET'
,
method
:
'GET'
,
success
:
function
(
res
)
{
success
:
function
(
res
)
{
if
(
res
.
success
)
{
if
(
res
.
success
)
{
$
(
'#vm-claim-content'
).
html
(
vcmBuildHtml
(
res
.
data
.
main
,
res
.
data
.
details
));
$
(
'#vm-claim-content'
)
.
attr
(
'data-claim-id'
,
res
.
data
.
main
.
id
)
.
attr
(
'data-claim-number'
,
res
.
data
.
main
.
ocm_apply_no
)
.
html
(
vcmBuildHtml
(
res
.
data
.
main
,
res
.
data
.
details
));
var
canExport
=
Number
(
res
.
data
.
main
.
ocm_status
)
===
11
;
$
(
'#btn-vm-download, #btn-vm-print'
).
prop
(
'disabled'
,
!
canExport
);
}
else
{
}
else
{
$
(
'#vm-claim-content'
).
html
(
$
(
'#vm-claim-content'
).
html
(
'<div class="ui negative message"><p>'
'<div class="ui negative message"><p>'
...
@@ -98,6 +111,29 @@ function viewTuntutan(id) {
...
@@ -98,6 +111,29 @@ function viewTuntutan(id) {
});
});
}
}
function
vcmDownload
()
{
var
id
=
$
(
'#vm-claim-content'
).
data
(
'claim-id'
);
if
(
!
id
)
return
;
window
.
location
.
href
=
"{{ url('overtime/claim') }}/"
+
id
+
"/pdf"
;
}
function
vcmPrint
()
{
var
id
=
$
(
'#vm-claim-content'
).
data
(
'claim-id'
);
var
claimNumber
=
$
(
'#vm-claim-content'
).
data
(
'claim-number'
);
if
(
!
id
||
!
claimNumber
)
return
;
var
printWindow
=
window
.
open
(
"{{ url('overtime/claim') }}/"
+
id
+
"/pdf/"
+
encodeURIComponent
(
claimNumber
)
+
"?inline=1"
,
'_blank'
);
if
(
!
printWindow
)
{
alert
(
'Unable to open the print window. Please allow pop-ups and try again.'
);
return
;
}
}
$
(
document
).
on
(
'click'
,
'#btn-vm-download'
,
vcmDownload
);
$
(
document
).
on
(
'click'
,
'#btn-vm-print'
,
vcmPrint
);
function
vcmBuildHtml
(
main
,
details
)
{
function
vcmBuildHtml
(
main
,
details
)
{
var
badge
=
'<span class="ui label" style="font-size:.78rem;">'
+
vcmEsc
(
main
.
ocm_status_label
||
'-'
)
+
'</span>'
;
var
badge
=
'<span class="ui label" style="font-size:.78rem;">'
+
vcmEsc
(
main
.
ocm_status_label
||
'-'
)
+
'</span>'
;
...
...
packages/portal/overtime/resources/views/overtime/overtimeclaim/view_modal_content.blade.php
View file @
786bc219
...
@@ -31,7 +31,7 @@
...
@@ -31,7 +31,7 @@
?
(
$monthNames
[(
int
)
$main
[
'ocm_month'
]
-
1
]
??
'-'
)
.
' '
.
$main
[
'ocm_year'
]
?
(
$monthNames
[(
int
)
$main
[
'ocm_month'
]
-
1
]
??
'-'
)
.
' '
.
$main
[
'ocm_year'
]
:
'-'
;
:
'-'
;
$badge
=
'<span class="ui label
" style="font-size:.78rem;
">'
.
$escape
(
$main
[
'ocm_status_label'
]
??
'-'
)
.
'</span>'
;
$badge
=
'<span class="ui label
vm-status-badge
">'
.
$escape
(
$main
[
'ocm_status_label'
]
??
'-'
)
.
'</span>'
;
$grandTotalTotal
=
0
;
$grandTotalTotal
=
0
;
$grandTotalEffective
=
0
;
$grandTotalEffective
=
0
;
?>
?>
...
@@ -95,12 +95,12 @@
...
@@ -95,12 +95,12 @@
<td>
<td>
@php $isNoProject = (!empty($detail['project_id'])
&&
$detail['project_id'] == 110) || (!empty($detail['fk_lkp_project'])
&&
$detail['fk_lkp_project'] == 110); @endphp
@php $isNoProject = (!empty($detail['project_id'])
&&
$detail['project_id'] == 110) || (!empty($detail['fk_lkp_project'])
&&
$detail['fk_lkp_project'] == 110); @endphp
@if($isNoProject)
@if($isNoProject)
<span
class=
"ui tiny blue label"
>
Auto
</span>
<span
class=
"ui tiny blue label
vm-review-badge
"
>
Auto
</span>
@else
@else
@if (!empty($detail['ocd_pm_reviewed']))
@if (!empty($detail['ocd_pm_reviewed']))
<span
class=
"ui green label"
>
Reviewed
</span>
<span
class=
"ui green label
vm-review-badge
"
>
Reviewed
</span>
@else
@else
<span
class=
"ui orange label"
>
Pending
</span>
<span
class=
"ui orange label
vm-review-badge
"
>
Pending
</span>
@endif
@endif
@endif
@endif
</td>
</td>
...
...
packages/portal/overtime/routes/web.php
View file @
786bc219
...
@@ -21,6 +21,7 @@ function () {
...
@@ -21,6 +21,7 @@ function () {
Route
::
post
(
'claim/store'
,
[
'uses'
=>
'OvertimeClaimController@storeOvertimeClaim'
,
'as'
=>
'overtime.storeovertimeclaim'
]);
Route
::
post
(
'claim/store'
,
[
'uses'
=>
'OvertimeClaimController@storeOvertimeClaim'
,
'as'
=>
'overtime.storeovertimeclaim'
]);
Route
::
get
(
'claim/existing-months'
,
[
'uses'
=>
'OvertimeClaimController@getExistingMonths'
,
'as'
=>
'overtime.existingmonths'
]);
Route
::
get
(
'claim/existing-months'
,
[
'uses'
=>
'OvertimeClaimController@getExistingMonths'
,
'as'
=>
'overtime.existingmonths'
]);
Route
::
get
(
'claim/{id}/view'
,
[
'uses'
=>
'OvertimeClaimController@viewOvertimeClaim'
,
'as'
=>
'overtime.viewovertimeclaim'
]);
Route
::
get
(
'claim/{id}/view'
,
[
'uses'
=>
'OvertimeClaimController@viewOvertimeClaim'
,
'as'
=>
'overtime.viewovertimeclaim'
]);
Route
::
get
(
'claim/{id}/pdf/{filename?}'
,
[
'uses'
=>
'OvertimeClaimController@downloadOvertimeClaim'
,
'as'
=>
'overtime.downloadovertimeclaim'
]);
Route
::
get
(
'claim/{id}/edit'
,
[
'uses'
=>
'OvertimeClaimController@editOvertimeClaim'
,
'as'
=>
'overtime.editovertimeclaim'
]);
Route
::
get
(
'claim/{id}/edit'
,
[
'uses'
=>
'OvertimeClaimController@editOvertimeClaim'
,
'as'
=>
'overtime.editovertimeclaim'
]);
Route
::
post
(
'claim/{id}/detail/add'
,
[
'uses'
=>
'OvertimeClaimController@addOvertimeClaimDetail'
,
'as'
=>
'overtime.addovertimeclaim'
]);
Route
::
post
(
'claim/{id}/detail/add'
,
[
'uses'
=>
'OvertimeClaimController@addOvertimeClaimDetail'
,
'as'
=>
'overtime.addovertimeclaim'
]);
Route
::
post
(
'claim/detail/{id}/update'
,
[
'uses'
=>
'OvertimeClaimController@updateOvertimeClaimDetail'
,
'as'
=>
'overtime.updateovertimeclaimdetail'
]);
Route
::
post
(
'claim/detail/{id}/update'
,
[
'uses'
=>
'OvertimeClaimController@updateOvertimeClaimDetail'
,
'as'
=>
'overtime.updateovertimeclaimdetail'
]);
...
...
packages/portal/overtime/src/Http/Controllers/OvertimeClaimController.php
View file @
786bc219
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
use
Illuminate\Support\Facades\Auth
;
use
Illuminate\Support\Facades\Auth
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Support\Facades\DB
;
use
Illuminate\Validation\ValidationException
;
use
Illuminate\Validation\ValidationException
;
use
Barryvdh\DomPDF\Facade\Pdf
;
use
Portal\Overtime\Data\Repo\OvertimeClaimRepo
;
use
Portal\Overtime\Data\Repo\OvertimeClaimRepo
;
use
Portal\Overtime\Model\OvertimeClaimMain
;
use
Portal\Overtime\Model\OvertimeClaimMain
;
...
@@ -200,6 +201,102 @@ public function viewOvertimeClaim(Request $request, int $id): JsonResponse
...
@@ -200,6 +201,102 @@ public function viewOvertimeClaim(Request $request, int $id): JsonResponse
]);
]);
}
}
public
function
downloadOvertimeClaim
(
Request
$request
,
int
$id
,
?
string
$filename
=
null
)
{
$main
=
$this
->
repos
->
findOvertimeClaim
(
$id
);
$staffInfoId
=
DB
::
table
(
'staff_info'
)
->
where
(
'fk_users'
,
Auth
::
id
())
->
value
(
'id'
);
abort_unless
((
int
)
$main
->
fk_lkp_staff_info
===
(
int
)
$staffInfoId
,
403
);
abort_unless
((
int
)
$main
->
ocm_status
===
11
,
404
);
$details
=
$this
->
repos
->
findOvertimeClaimDetails
(
$id
);
$projectNames
=
DB
::
table
(
'lkp_project'
)
->
whereIn
(
'id'
,
$details
->
pluck
(
'fk_lkp_project'
)
->
filter
()
->
unique
())
->
pluck
(
'p_project_description'
,
'id'
);
$statusLabel
=
DB
::
table
(
'lkp_status'
)
->
where
(
'module'
,
'ot'
)
->
where
(
'ref_id'
,
$main
->
ocm_status
)
->
value
(
'description'
);
$staffInfo
=
DB
::
table
(
'staff_info'
)
->
where
(
'id'
,
$main
->
fk_lkp_staff_info
)
->
first
();
$departmentId
=
$staffInfo
->
fk_lkp_department
??
$main
->
ocm_division
;
$mainData
=
[
'ocm_apply_no'
=>
$main
->
ocm_apply_no
,
'ocm_staff_name'
=>
$main
->
ocm_staff_name
,
'ocm_division_label'
=>
$departmentId
?
(
DB
::
table
(
'lkp_department'
)
->
where
(
'id'
,
$departmentId
)
->
value
(
'description'
)
?:
DB
::
table
(
'lkp_department'
)
->
where
(
'id'
,
$departmentId
)
->
value
(
'name'
)
?:
'-'
)
:
'-'
,
'ocm_status_label'
=>
$statusLabel
?:
'-'
,
'ocm_month'
=>
$main
->
ocm_month
,
'ocm_year'
=>
$main
->
ocm_year
,
'ocm_submit_date'
=>
$main
->
ocm_submit_date
,
'ocm_approved_by_name'
=>
$main
->
ocm_approved_by
?
(
DB
::
table
(
'staff_info'
)
->
where
(
'fk_users'
,
$main
->
ocm_approved_by
)
->
value
(
'fullname'
)
?:
DB
::
table
(
'users'
)
->
where
(
'id'
,
$main
->
ocm_approved_by
)
->
value
(
'name'
)
?:
'-'
)
:
'-'
,
'ocm_approved_date'
=>
$main
->
ocm_approved_date
,
];
$detailData
=
$details
->
map
(
fn
(
$detail
)
=>
[
'ocd_date'
=>
$detail
->
ocd_date
,
'ocd_day_type'
=>
$detail
->
ocd_day_type
,
'ocd_office_hour'
=>
$detail
->
ocd_office_hour
,
'ocd_overtime_from'
=>
$detail
->
ocd_overtime_from
,
'ocd_overtime_to'
=>
$detail
->
ocd_overtime_to
,
'ocd_total_hours'
=>
$detail
->
ocd_total_hours
,
'ocd_effective_hours'
=>
$detail
->
ocd_effective_hours
,
'ocd_tasks'
=>
$detail
->
ocd_tasks
,
'fk_lkp_project'
=>
$detail
->
fk_lkp_project
,
'project_name'
=>
$projectNames
[
$detail
->
fk_lkp_project
]
??
''
,
'ocd_pm_reviewed'
=>
$detail
->
ocd_pm_reviewed
,
])
->
all
();
$claimContent
=
view
(
'overtime::overtime.overtimeclaim.view_modal_content'
,
[
'main'
=>
$mainData
,
'details'
=>
$detailData
,
])
->
render
();
$pdfStyles
=
<<<'CSS'
@page { size: A4 landscape; margin: 10mm; }
body { font-family: DejaVu Sans, sans-serif; color: #222; margin: 0; font-size: 9px; }
.vm-summary { background: #ddeeff; border-radius: 6px; padding: 8px 11px; margin-bottom: 10px; line-height: 1.75; }
.vm-summary .apply-no { font-size: 12px; font-weight: 700; color: #1a56a0; }
.vm-summary .meta-line { font-size: 9px; color: #333; }
.vm-tbl { width: 100%; border-collapse: collapse; table-layout: fixed; font-size: 8px; }
.vm-tbl th, .vm-tbl td { border: 1px solid #cfd8e3; padding: 5px 4px; min-width: 0 !important; vertical-align: middle; text-align: center; word-wrap: break-word; }
.vm-tbl thead tr.grp th { background: #2185d0; color: #fff; font-weight: 600; }
.vm-tbl thead tr.grp th.vm-light { background: #5aace8; }
.vm-tbl thead tr.grp th.vm-plain { background: #e8f0fa; color: #444; }
.vm-tbl tbody td.vm-shade { background: #f0f7ff; }
.vm-tbl tbody td.vm-left { text-align: left; }
.vm-tbl tfoot td { background: #ddeeff; font-weight: 700; color: #1a56a0; border-top: 2px solid #2185d0; }
.vm-tbl tfoot .lbl { text-align: right; font-size: 8px; }
.vm-empty { text-align: center; color: #bbb; font-style: italic; padding: 16px; }
.ui.label { display: inline-block; padding: 3px 6px; border-radius: 3px; background: #e8e8e8; font-size: 8px; }
.vm-status-badge, .vm-review-badge { vertical-align: middle; line-height: 1.2; white-space: nowrap; }
.vm-status-badge { margin-left: 2px; }
.ui.tiny.label, .ui.blue.label { background: #2185d0; color: #fff; }
.ui.green.label { background: #21ba45; color: #fff; }
.ui.orange.label { background: #f2711c; color: #fff; }
CSS;
$pdf
=
Pdf
::
loadHTML
(
'<!doctype html><html><head><meta charset="utf-8"><style>'
.
$pdfStyles
.
'</style></head><body>'
.
$claimContent
.
'</body></html>'
)
->
setPaper
(
'a4'
,
'landscape'
);
$filename
=
$main
->
ocm_apply_no
.
'.pdf'
;
if
(
$request
->
boolean
(
'inline'
))
{
return
response
(
$pdf
->
output
(),
200
,
[
'Content-Type'
=>
'application/pdf'
,
'Content-Disposition'
=>
'inline; filename="'
.
$filename
.
'"'
,
]);
}
return
response
(
$pdf
->
output
(),
200
,
[
'Content-Type'
=>
'application/pdf'
,
'Content-Disposition'
=>
'attachment; filename="'
.
$filename
.
'"'
,
]);
}
// EDIT
// EDIT
...
...
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