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
0d252112
Commit
0d252112
authored
Jul 20, 2026
by
Muhammad Iz'aan bin suhaimi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
finance's workflow. (semak and calculate the actual claim total)
parent
d26a4cf1
Hide whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
1053 additions
and
1054 deletions
+1053
-1054
database/migrations/2026_07_13_144746_create_mileage_claim_finance_table.php
+39
-0
database/migrations/2026_07_14_105138_add_original_columns_to_mileage_claim_detail.php
+34
-0
packages/portal/mileage/resources/views/finance/edit.blade.php
+104
-0
packages/portal/mileage/resources/views/finance/index.blade.php
+115
-248
packages/portal/mileage/resources/views/finance/show.blade.php
+405
-512
packages/portal/mileage/resources/views/finance/view.blade.php
+0
-54
packages/portal/mileage/resources/views/mileage/form.blade.php
+55
-0
packages/portal/mileage/resources/views/mileage/list.blade.php
+51
-12
packages/portal/mileage/routes/web.php
+7
-9
packages/portal/mileage/src/Data/Repo/FinanceRepo.php
+168
-0
packages/portal/mileage/src/Data/Repo/MileageRepo.php
+1
-1
packages/portal/mileage/src/Http/Controllers/FinanceController.php
+29
-212
packages/portal/mileage/src/Model/MileageClaimFinance.php
+32
-0
packages/portal/mileage/src/Model/MileageClaimMain.php
+7
-0
packages/portal/mileage/src/ServiceProvider.php
+6
-6
No files found.
database/migrations/2026_07_13_144746_create_mileage_claim_finance_table.php
0 → 100644
View file @
0d252112
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
return
new
class
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
create
(
'mileage_claim_finance'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
Integer
(
'fk_mileage_claim_main'
)
->
index
();
$table
->
decimal
(
'fin_original_amount'
,
10
,
2
)
->
nullable
();
$table
->
decimal
(
'fin_penalty_rate'
,
5
,
2
)
->
nullable
();
$table
->
decimal
(
'fin_penalty_amount'
,
10
,
2
)
->
nullable
();
$table
->
text
(
'fin_amendment_remark'
)
->
nullable
();
$table
->
decimal
(
'fin_final_amount'
,
10
,
2
)
->
nullable
();
$table
->
Integer
(
'fin_processed_by'
)
->
nullable
()
->
index
();
$table
->
timestamp
(
'fin_processed_date'
)
->
nullable
();
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'mileage_claim_finance'
);
}
};
database/migrations/2026_07_14_105138_add_original_columns_to_mileage_claim_detail.php
0 → 100644
View file @
0d252112
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
return
new
class
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
Schema
::
table
(
'mileage_claim_detail'
,
function
(
Blueprint
$table
)
{
$table
->
decimal
(
'md_original_mileage'
,
10
,
1
)
->
nullable
()
->
after
(
'md_total_mileage'
);
$table
->
decimal
(
'md_original_toll'
,
10
,
2
)
->
nullable
()
->
after
(
'md_total_toll'
);
$table
->
decimal
(
'md_original_parking_fee'
,
10
,
2
)
->
nullable
()
->
after
(
'md_total_parking_fee'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
table
(
'mileage_claim_detail'
,
function
(
Blueprint
$table
)
{
$table
->
dropColumn
([
'md_original_mileage'
,
'md_original_toll'
,
'md_original_parking_fee'
]);
});
}
};
packages/portal/mileage/resources/views/finance/edit.blade.php
0 → 100644
View file @
0d252112
@
extends
(
'ui::layouts.app'
)
@
section
(
'content'
)
<
div
class
="
ui
segment
">
<a class="
ui
teal
left
ribbon
label
">Pindaan Butiran Tuntutan - {{
$claim->mm_apply_no
}}</a><br/><br/>
<div class="
ui
info
message
">
<i class="
info
circle
icon
"></i>
Hanya medan <strong>Jumlah Jarak (KM)</strong>, <strong>Jumlah Tol</strong> dan <strong>Jumlah Letak Kereta</strong> boleh dipinda. Medan lain adalah untuk rujukan sahaja.
</div>
<form action="
{{
route
(
'mileage::finance.update'
,
$claim
->
id
)
}}
" method="
POST
">
@csrf
@method('PUT')
@php
$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
= [];
@endphp
<div class="
ui
segment
">
<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 Bayaran Letak Kereta (RM)</th>
</tr>
</thead>
<tbody>
@forelse(
$sortedDetails
as
$index
=>
$detail
)
@php
$dateKey
=
$detail->md_claim_date
;
$isFirstOfDate
= !isset(
$dateFirstSeen[$dateKey]
);
if (
$isFirstOfDate
)
$dateFirstSeen[$dateKey]
= true;
@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
">
<input type="
number
"
name="
details
[{{
$detail
->
id
}}][
md_total_mileage
]
"
value="
{{
$detail
->
md_total_mileage
}}
"
step="
0.1
" min="
0
"
style="
width
:
90
px
;
text
-
align
:
right
;
">
</td>
<td class="
right
aligned
">
<input type="
number
"
name="
details
[{{
$detail
->
id
}}][
md_total_toll
]
"
value="
{{
$detail
->
md_total_toll
}}
"
step="
0.01
" min="
0
"
style="
width
:
90
px
;
text
-
align
:
right
;
">
</td>
<td class="
right
aligned
">
<input type="
number
"
name="
details
[{{
$detail
->
id
}}][
md_total_parking_fee
]
"
value="
{{
$detail
->
md_total_parking_fee
}}
"
step="
0.01
" min="
0
"
style="
width
:
90
px
;
text
-
align
:
right
;
">
</td>
</tr>
@empty
<tr>
<td colspan="
8
" class="
center
aligned
">Tiada butiran.</td>
</tr>
@endforelse
</tbody>
</table>
</div>
<div style="
text
-
align
:
right
;
">
<a href="
{{
route
(
'mileage::finance.show'
,
$claim
->
id
)
}}
" class="
ui
button
">
<i class="
arrow
left
icon
"></i> Batal
</a>
<button type="
submit
" class="
ui
teal
button
"
onclick="
return
confirm
(
'Simpan pindaan butiran tuntutan ini?'
)
">
<i class="
save
icon
"></i> Simpan Pindaan
</button>
</div>
</form>
<br><br>
</div>
@endsection
packages/portal/mileage/resources/views/finance/index.blade.php
View file @
0d252112
<title>
Finance 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
">Finance Dashboard - Tuntutan Mileage</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
;
9 => 'Diluluskan BOD',
margin-bottom
:
1.5rem
;
11 => 'Disemak',
border-bottom
:
2px
solid
#ddd
;
];
padding-bottom
:
0.5rem
;
@endphp
}
{{-- Filter --}}
.ui.statistics
{
<form method="
GET
" action="
{{
route
(
'mileage::finance.index'
)
}}
" class="
ui
form
" style="
margin
-
bottom
:
1
rem
;
">
display
:
flex
!important
;
<div class="
four
fields
">
justify-content
:
space-between
;
<div class="
field
">
align-items
:
stretch
;
<label>Tahun</label>
flex-wrap
:
nowrap
;
<select name="
tahun
" class="
ui
dropdown
">
gap
:
1.5rem
;
<option value="">Semua Tahun</option>
margin-top
:
2rem
;
@for(
$y
=
$currentYear
;
$y
>=
$currentYear
- 4;
$y
--)
margin-bottom
:
2rem
;
<option value="
{{
$y
}}
" {{ request('tahun') ==
$y
? 'selected' : '' }}>{{
$y
}}</option>
}
@endfor
</select>
.ui.statistic
{
</div>
flex
:
1
;
<div class="
field
">
background
:
white
;
<label>Bulan</label>
border-radius
:
10px
;
<select name="
bulan
" class="
ui
dropdown
">
box-shadow
:
0
4px
6px
rgba
(
0
,
0
,
0
,
0.1
);
<option value="">Semua Bulan</option>
padding
:
1.5rem
;
@foreach(
$bulan
as
$num
=>
$nama
)
text-align
:
center
;
<option value="
{{
$num
}}
" {{ request('bulan') ==
$num
? 'selected' : '' }}>{{
$nama
}}</option>
transition
:
transform
0.2s
ease-in-out
;
@endforeach
}
</select>
</div>
.ui.statistic
:hover
{
<div class="
field
">
transform
:
translateY
(
-4px
);
<label>Status</label>
}
<select name="
status
" class="
ui
dropdown
">
<option value="">Semua Status</option>
.ui.statistic
.value
{
@foreach(
$statusOptions
as
$val
=>
$label
)
font-size
:
2rem
;
<option value="
{{
$val
}}
" {{ request('status') ==
$val
? 'selected' : '' }}>{{
$label
}}</option>
font-weight
:
bold
;
@endforeach
color
:
#2185d0
;
</select>
}
</div>
<div class="
field
">
.ui.statistic
.label
{
<label>Cari</label>
font-size
:
1rem
;
<input type="
text
" name="
search
" value="
{{
request
(
'search'
)
}}
" placeholder="
No
.
permohonan
/
nama
pemohon
">
color
:
#555
;
</div>
margin-top
:
0.3rem
;
</div>
}
<div style="
text
-
align
:
right
;
">
@if(request()->hasAny(['tahun', 'bulan', 'status', 'search']))
/* Filter bar (aligned right side of header) */
<a href="
{{
route
(
'mileage::finance.index'
)
}}
" class="
ui
button
">Reset</a>
.header-with-filter
{
@endif
display
:
flex
;
<button type="
submit
" class="
ui
teal
button
"><i class="
search
icon
"></i> Cari</button>
justify-content
:
space-between
;
</div>
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
);
}
.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
;
}
.status-label
{
display
:
inline-block
;
padding
:
6px
12px
;
border-radius
:
8px
;
font-size
:
0.9rem
;
font-weight
:
600
;
color
:
#fff
;
text-transform
:
capitalize
;
border
:
none
;
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-Dibayar
{
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
;
}
.header-row
,
.header-with-filter
{
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%
;
}
.ui.statistics
{
flex-wrap
:
wrap
;
}
.ui.statistic
{
flex
:
0
0
48%
;
}
}
@media
(
max-width
:
600px
)
{
.ui.statistic
{
flex
:
0
0
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"
>
Finance Dashboard
</h2>
{{-- Excel Export Button --}}
<button
class=
"ui teal button"
id=
"openExportModal"
>
<i
class=
"file excel icon"
></i>
Muat Turun Laporan Excel
</button>
</div>
{{-- Statistic Section --}}
<div
class=
"ui statistics"
>
<div
class=
"statistic"
><div
class=
"value"
>
{{ $summary['processed'] }}
</div><div
class=
"label"
>
Diproses
</div></div>
<div
class=
"statistic"
><div
class=
"value"
>
{{ $summary['verified'] }}
</div><div
class=
"label"
>
Disokong
</div></div>
<div
class=
"statistic"
><div
class=
"value"
>
{{ $summary['approved'] }}
</div><div
class=
"label"
>
Disahkan
</div></div>
<div
class=
"statistic"
><div
class=
"value"
>
{{ $summary['reviewed'] }}
</div><div
class=
"label"
>
Disemak
</div></div>
<div
class=
"statistic"
><div
class=
"value"
>
{{ $summary['paid'] }}
</div><div
class=
"label"
>
Dibayar
</div></div>
<div
class=
"statistic"
><div
class=
"value"
>
{{ $summary['rejected'] }}
</div><div
class=
"label"
>
Ditolak
</div></div>
</div>
{{-- 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 Summary Table --}}
{{-- 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::finance.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 tuntutan untuk bulan ini.
</td>
@forelse(
$list
as
$index
=>
$claim
)
</tr>
@php
@endforelse
$refId
=
$claim->lkpStatus
?->ref_id ?? 0;
</tbody>
$color
= match(
$refId
) {
</table>
9 => 'teal',
</div>
11 => 'violet',
default => 'grey',
};
@endphp
<tr>
<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
{{
$color
}}
label
">{{
$claim->lkpStatus
?->description ?? '-' }}</span></td>
<td>
<a href="
{{
route
(
'mileage::finance.show'
,
$claim
->
id
)
}}
" class="
ui
blue
small
button
">
<i class="
eye
icon
"></i>
</a>
</td>
</tr>
@empty
<tr>
<td colspan="
7
" class="
center
aligned
">Tiada permohonan untuk disemak.</td>
</tr>
@endforelse
</tbody>
</table>
{{
$list->withQueryString
()->links() }}
{{-- 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::finance.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"
value=
"{{ $month ?? now()->format('Y-m') }}"
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/finance/show.blade.php
View file @
0d252112
<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
;
}
/* --- Larger, more comfortable action buttons --- */
<
div
class
="
ui
segment
">
.actions-group
.ui.button.tiny
{
<a class="
ui
teal
left
ribbon
label
">Semakan Permohonan (Finance) - {{
$claim->mm_apply_no
}}</a><br/><br/>
padding
:
9px
14px
!important
;
/* more padding for height & width */
font-size
:
0.9rem
!important
;
/* slightly larger font */
line-height
:
1.2rem
!important
;
min-width
:
100px
;
/* more space for labels */
text-align
:
center
;
border-radius
:
8px
!important
;
/* smoother rounded edges */
font-weight
:
600
!important
;
transition
:
all
0.2s
ease-in-out
;
}
/* Hover effect for better feedback */
@if(session('success'))
.actions-group
.ui.button.tiny
:hover
{
<div class="
ui
success
message
">{{ session('success') }}</div>
transform
:
translateY
(
-2px
);
@endif
box-shadow
:
0
3px
6px
rgba
(
0
,
0
,
0
,
0.15
);
}
/* Keep consistent gap between buttons */
.actions-group
{
display
:
flex
;
align-items
:
center
;
justify-content
:
center
;
gap
:
10px
;
flex-wrap
:
wrap
;
}
.inline-form
{
display
:
inline-flex
;
align-items
:
center
;
gap
:
6px
;
margin
:
0
;
}
.actions-group
.ui.red.button.tiny
,
.actions-group
.ui.green.button.tiny
,
.actions-group
.ui.blue.button.tiny
{
border-radius
:
6px
!important
;
font-weight
:
500
!important
;
}
/* Responsive alignment */
@media
(
max-width
:
768px
)
{
.actions-group
{
flex-direction
:
column
;
gap
:
4px
;
}
}
.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-Dibayar
{
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
;
}
td
form
{
display
:
inline-block
;
margin-left
:
4px
;
}
</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>
{{-- Back button --}}
<a
href=
"{{ route('mileage::finance.index', ['month' => $month]) }}"
class=
"ui grey button"
>
<i
class=
"arrow left icon"
></i>
Kembali
</a>
{{-- Claims Table --}}
{{-- Maklumat Permohonan --}}
<table
class=
"ui celled table"
>
<div class="
ui
segment
">
<thead>
<h3 class="
ui
header
">Maklumat Permohonan</h3>
<table class="
ui
definition
table
">
<tr>
<tr>
<th>
#
</th>
{{-- new column for numbering --}}
<td>No. Permohonan</td>
<th>
Tarikh
</th>
<td>{{
$claim->mm_apply_no
}}</td>
<th>
Butiran
</th>
<th>
Jenis Kenderaan
</th>
<th>
Dari
</th>
<th>
Ke
</th>
<th>
KM
</th>
<th>
Tol (RM)
</th>
<th>
Lain-lain (RM)
</th>
<th>
Jumlah (RM)
</th>
<th>
Status
</th>
<th>
Tindakan
</th>
</tr>
</tr>
</thead>
<tr>
<tbody>
<td>Nama Pemohon</td>
@php
<td>{{
$claim->mm_staff_name
?? '-' }}</td>
use Carbon\Carbon;
</tr>
<tr>
// Sort claims by ascending date
<td>Kategori FA</td>
$claims = $claims->sortBy(fn($c) => Carbon::parse($c->claim_date));
<td>{{
$claim->faCategory
?->fa_category ?? '-' }}</td>
</tr>
// Step 1: Non-rejected claims
<tr>
$validClaims = $claims->where('status', '!=', 'Ditolak');
<td>Bulan Tuntutan</td>
<td>
// Step 2: Restrict to claims within the displayed month
@php
$monthStart = Carbon::parse($month)->startOfMonth();
$bulan
= [
$monthEnd = Carbon::parse($month)->endOfMonth();
1=>'Januari', 2=>'Februari', 3=>'Mac', 4=>'April',
5=>'Mei', 6=>'Jun', 7=>'Julai', 8=>'Ogos',
$validInMonth = $validClaims->filter(function($c) use ($monthStart, $monthEnd) {
9=>'September', 10=>'Oktober', 11=>'November', 12=>'Disember'
if (empty($c->claim_date)) return false;
];
try {
@endphp
$d = Carbon::parse($c->claim_date);
{{ (
$bulan[$claim->mm_claim_month]
?? '-') . ' ' .
$claim->mm_claim_year
}}
} catch (\Exception $e) {
</td>
return false;
</tr>
}
<tr>
return $d->between($monthStart, $monthEnd);
<td>Tarikh Hantar</td>
});
<td>{{
$claim->mm_submit_date
? \Carbon\Carbon::parse(
$claim->mm_submit_date
)->format('d/m/Y') : '-' }}</td>
</tr>
// Step 3: Count unique calendar days (YYYY-MM-DD)
<tr>
$uniqueDays = $validInMonth
<td>Disokong Oleh (HOD)</td>
->pluck('claim_date')
<td>{{
$claim->verifiedBy
?->name ?? '-' }} {{
$claim->mm_verified_date
? '(' . \Carbon\Carbon::parse(
$claim->mm_verified_date
)->format('d/m/Y') . ')' : '' }}</td>
->map(fn($d) => Carbon::parse($d)->toDateString())
</tr>
->unique()
<tr>
->count();
<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>
// Step 4: Compute base totals
</tr>
$total = 0;
<tr>
$totalMileage = $validInMonth->sum('total_mileage');
<td>Status</td>
$totalToll = $validInMonth->sum('toll_amount');
<td>
$totalOthers = $validInMonth->sum('others_amount');
@php
$refId
=
$claim->lkpStatus
?->ref_id ?? 0;
// Step 5: Deduction
$color
= match(
$refId
) {
$deduction = 40 * $uniqueDays;
9 => 'teal',
11 => 'violet',
// === Calculate mileageAmount BEFORE the table ===
12 => 'green',
$rateCar1 = 0.55; $rateCar2 = 0.50; $rateMoto = 0.30;
default => 'grey',
$mileageAmount = 0;
};
$vehicleGroups = [];
@endphp
<span class="
ui
{{
$color
}}
label
">{{
$claim->lkpStatus
?->description ?? '-' }}</span>
$vehicleGroupCount = max(1, $validInMonth->groupBy(fn($c) => strtolower($c->jenisKenderaan->name ?? 'kereta'))->count());
foreach ($validInMonth->groupBy(fn($c) => strtolower($c->jenisKenderaan->name ?? 'kereta')) as $type => $group) {
$typeMileage = $group->sum('total_mileage');
$typeClaimable = max(0, $typeMileage - ($deduction / $vehicleGroupCount));
if (in_array($type, ['motosikal', 'motorcycle'])) {
$typeAmount = $typeClaimable * $rateMoto;
} else {
$firstPart = min($typeClaimable, 500);
$secondPart = max(0, $typeClaimable - 500);
$typeAmount = ($firstPart * $rateCar1) + ($secondPart * $rateCar2);
}
$mileageAmount += $typeAmount;
}
$subtotal = $mileageAmount + $totalToll + $totalOthers;
@endphp
@php
// Group all claims by project (null = Tiada Projek)
$groupedClaims = $claims->groupBy(function ($c) {
return $c->project->p_project_description ?? 'Tiada Projek';
});
// Move "Tiada Projek" to the bottom
$groupedClaims = $groupedClaims->sortBy(function ($claims, $projectName) {
return $projectName === 'Tiada Projek' ? 1 : 0;
});
@endphp
@forelse($groupedClaims as $projectName => $projectClaims)
{{-- Project header --}}
<tr
style=
"background:#f8f9fa;"
>
<td
colspan=
"11"
style=
"font-weight:bold;"
>
<i
class=
"file alternate outline icon"
></i>
{{ $projectName }}
</td>
</td>
</tr>
</tr>
</table>
</div>
@foreach($projectClaims as $index => $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 Bayaran Letak Kereta (RM)</th>
<th class="
right
aligned
">Anggaran Tuntutan (RM)</th>
</tr>
</thead>
<tbody>
@php
@php
$rowTotal = 0;
$grandAnggaran
= 0;
$grandTol
= 0;
$grandParking
= 0;
$claimableKM = 0;
$sortedDetails
=
$claim->details
->sortBy('md_claim_date')->values();
$vehicle = strtolower($claim->jenisKenderaan->name ?? 'kereta');
$dateCounts
= [];
foreach (
$sortedDetails
as
$d
) {
if ($claim->status !== 'Ditolak') {
$dk
=
$d->md_claim_date
;
$claimableKM = $claim->total_mileage ?? 0;
$dateCounts[$dk]
= (
$dateCounts[$dk]
?? 0) + 1;
if (in_array($vehicle, ['motosikal', 'motorcycle'])) {
$rowTotal = $claimableKM * 0.30;
} else {
$firstPart = min($claimableKM, 500);
$secondPart = max(0, $claimableKM - 500);
$rowTotal = ($firstPart * 0.55) + ($secondPart * 0.50);
}
}
}
$dateFirstSeen
= [];
$cumulativeKmByDate
= [];
@endphp
@endphp
<tr>
@forelse(
$sortedDetails
as
$index
=>
$detail
)
<td>
{{ $loop->iteration }}
</td>
@php
<td>
{{ \Carbon\Carbon::parse($claim->claim_date)->format('d/m/Y') }}
</td>
$jumlahJarak
= (float)
$detail->md_total_mileage
;
<td>
{{ $claim->description ?? '-' }}
</td>
$dateKey
=
$detail->md_claim_date
;
<td>
{{ ucfirst($vehicle) }}
</td>
$isFirstOfDate
= !isset(
$dateFirstSeen[$dateKey]
);
<td>
{{ $claim->distance_from ?? '-' }}
</td>
if (
$isFirstOfDate
)
$dateFirstSeen[$dateKey]
= true;
<td>
{{ $claim->distance_to ?? '-' }}
</td>
$claimableKm
=
$isFirstOfDate
? max(0,
$jumlahJarak
- 40) :
$jumlahJarak
;
<td>
{{ number_format($claim->total_mileage, 1) }}
</td>
$startKm
=
$cumulativeKmByDate[$dateKey]
?? 0;
<td>
{{ number_format($claim->toll_amount ?? 0, 2) }}
</td>
$endKm
=
$startKm
+
$claimableKm
;
<td>
{{ number_format($claim->others_amount ?? 0, 2) }}
</td>
$mileageAmount
= 0;
<td>
foreach (
$detail->jenisKenderaan
?->rates ?? collect() as
$tier
) {
{{ $claim->status !== 'Ditolak'
$kmInTier
= max(0, min(
$tier->km_to
,
$endKm
) - max(
$tier->km_from
,
$startKm
));
? 'RM ' . number_format($rowTotal, 2)
$mileageAmount
+=
$kmInTier
* (float)
$tier->rate
;
: '- (Tuntutan Ditolak)' }}
}
</td>
$cumulativeKmByDate[$dateKey]
=
$endKm
;
<td><span
class=
"status-label status-{{ $claim->status }}"
>
{{ $claim->status }}
</span></td>
$jumlahTol
= (float)
$detail->md_total_toll
;
<td>
$jumlahParking
= (float)
$detail->md_total_parking_fee
;
<div
class=
"actions-group"
>
$anggaranTuntutan
=
$mileageAmount
+
$jumlahTol
+
$jumlahParking
;
{{-- Lihat (View) button - always visible --}}
$grandTol
+=
$jumlahTol
;
<a
href=
"{{ route('mileage::finance.viewEach', $claim->id) }}"
$grandParking
+=
$jumlahParking
;
class=
"ui blue button tiny"
$grandAnggaran
+=
$anggaranTuntutan
;
title=
"Lihat Butiran"
>
@endphp
<i
class=
"eye icon"
></i>
Lihat
<tr>
</a>
<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="
6
" class="
right
aligned
">JUMLAH KESELURUHAN (RM)</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>
{{-- Kemaskini button - show only for claims that can be edited --}}
{{-- Lampiran --}}
@if(in_array($claim->status, ['Diproses', 'Disokong', 'Disahkan']))
<div class="
ui
segment
">
<button
class=
"ui yellow button tiny edit-btn"
<h3 class="
ui
header
">Lampiran / Bukti Transaksi</h3>
data-id=
"{{ $claim->id }}"
@if(
$claim->attachments
->count() > 0)
data-date=
"{{ $claim->claim_date }}"
<table class="
ui
celled
table
">
data-description=
"{{ $claim->description }}"
<thead>
data-distance-from=
"{{ $claim->distance_from }}"
<tr><th>No</th><th>Nama Fail</th></tr>
data-distance-to=
"{{ $claim->distance_to }}"
</thead>
data-mileage=
"{{ $claim->total_mileage }}"
<tbody>
data-toll=
"{{ $claim->toll_amount }}"
@foreach(
$claim->attachments
as
$index
=>
$file
)
data-others=
"{{ $claim->others_amount }}"
<tr>
data-others-details=
"{{ $claim->others_details }}"
>
<td>{{
$index
+ 1 }}</td>
<i
class=
"edit icon"
></i>
Kemaskini
<td>
</button>
<a href="
{{
asset
(
'storage/'
.
$file
->
file_path
)
}}
" target="
_blank
">
@endif
<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>
{{-- Show Semak/Tolak buttons only if claim is not final --}}
{{-- Perbandingan Pindaan (only if Finance has amended) --}}
@if(!in_array($claim->status, ['Disemak', 'Ditolak', 'Dibayar']))
@php
<form
action=
"{{ route('mileage::finance.updateStatus', $claim->id) }}"
method=
"POST"
class=
"inline-form"
>
$hasAmendment
=
$claim->details
->contains(fn(
$d
) =>
$d->md_original_mileage
!== null);
@csrf
@endphp
@method('PUT')
@if(in_array($claim->status, ['Disahkan', 'Disokong', 'Diproses']))
@if(
$hasAmendment
)
<button
type=
"submit"
name=
"action"
value=
"Disemak"
class=
"ui green button tiny"
>
@php
<i
class=
"check icon"
></i>
Semak
// Recalculate original grand total using original values + same tiered logic
</button>
$origDateFirstSeen
= [];
@endif
$origCumKmByDate
= [];
$origGrandAnggaran
= 0;
$origGrandTol
= 0;
$origGrandParking
= 0;
foreach (
$sortedDetails
as
$detail
) {
$origKm
= (float) (
$detail->md_original_mileage
??
$detail->md_total_mileage
);
$dateKey
=
$detail->md_claim_date
;
$isFirst
= !isset(
$origDateFirstSeen[$dateKey]
);
if (
$isFirst
)
$origDateFirstSeen[$dateKey]
= true;
$claimKm
=
$isFirst
? max(0,
$origKm
- 40) :
$origKm
;
$startKm
=
$origCumKmByDate[$dateKey]
?? 0;
$endKm
=
$startKm
+
$claimKm
;
$mileageAmt
= 0;
foreach (
$detail->jenisKenderaan
?->rates ?? collect() as
$tier
) {
$kmInTier
= max(0, min(
$tier->km_to
,
$endKm
) - max(
$tier->km_from
,
$startKm
));
$mileageAmt
+=
$kmInTier
* (float)
$tier->rate
;
}
$origCumKmByDate[$dateKey]
=
$endKm
;
$origToll
= (float) (
$detail->md_original_toll
??
$detail->md_total_toll
);
$origParking
= (float) (
$detail->md_original_parking_fee
??
$detail->md_total_parking_fee
);
$origGrandAnggaran
+=
$mileageAmt
+
$origToll
+
$origParking
;
$origGrandTol
+=
$origToll
;
$origGrandParking
+=
$origParking
;
}
<button
type=
"submit"
name=
"action"
value=
"Ditolak"
class=
"ui red button tiny"
>
$diffAnggaran
=
$grandAnggaran
-
$origGrandAnggaran
;
<i
class=
"times icon"
></i>
Tolak
@endphp
</button>
</form>
@endif
{{-- Show Bayar button only if claim is Disemak --}}
@if($claim->status === 'Disemak')
<form
action=
"{{ route('mileage::finance.updateStatus', $claim->id) }}"
method=
"POST"
class=
"inline-form"
>
@csrf
@method('PUT')
<button
type=
"submit"
name=
"action"
value=
"Dibayar"
class=
"ui teal button tiny"
>
<i
class=
"money bill alternate icon"
></i>
Bayar
</button>
</form>
@endif
</div>
</td>
</tr>
@endforeach
@php
$projMileage = $projectClaims->sum('total_mileage');
$projToll = $projectClaims->sum('toll_amount');
$projOthers = $projectClaims->sum('others_amount');
@endphp
<tr
class=
"totals-row"
>
<td
colspan=
"6"
style=
"text-align:right;"
><strong>
Jumlah Projek Ini
</strong></td>
<td><strong>
{{ number_format($projMileage, 1) }} KM
</strong></td>
<td><strong>
RM {{ number_format($projToll, 2) }}
</strong></td>
<td><strong>
RM {{ number_format($projOthers, 2) }}
</strong></td>
<td
colspan=
"2"
></td>
</tr>
@empty
<div class="
ui
segment
">
<tr>
<h3 class="
ui
header
">Perbandingan Pindaan Butiran</h3>
<td
colspan=
"11"
class=
"center aligned"
>
Tiada tuntutan untuk bulan ini.
</td>
<table class="
ui
celled
table
">
</tr>
<thead>
@endforelse
<tr>
<th>No</th>
<th>Tarikh</th>
<th>Butiran</th>
<th class="
right
aligned
">Asal KM</th>
<th class="
right
aligned
">Pindaan KM</th>
<th class="
right
aligned
">Asal Tol (RM)</th>
<th class="
right
aligned
">Pindaan Tol (RM)</th>
<th class="
right
aligned
">Asal Letak Kereta (RM)</th>
<th class="
right
aligned
">Pindaan Letak Kereta (RM)</th>
</tr>
</thead>
<tbody>
@foreach(
$sortedDetails
as
$index
=>
$detail
)
@php
$kmChanged
=
$detail->md_original_mileage
!== null &&
$detail->md_original_mileage
!=
$detail->md_total_mileage
;
$tollChanged
=
$detail->md_original_toll
!== null &&
$detail->md_original_toll
!=
$detail->md_total_toll
;
$parkChanged
=
$detail->md_original_parking_fee
!== null &&
$detail->md_original_parking_fee
!=
$detail->md_total_parking_fee
;
$rowChanged
=
$kmChanged
||
$tollChanged
||
$parkChanged
;
@endphp
<tr class="
{{
$rowChanged
?
'warning'
:
''
}}
">
<td>{{
$index
+ 1 }}</td>
<td>{{ \Carbon\Carbon::parse(
$detail->md_claim_date
)->format('d/m/Y') }}</td>
<td>{{
$detail->md_description
}}</td>
<td class="
right
aligned
">{{ number_format(
$detail->md_original_mileage
??
$detail->md_total_mileage
, 1) }}</td>
<td class="
right
aligned
">
{{ number_format(
$detail->md_total_mileage
, 1) }}
@if(
$kmChanged
)
<span style="
color
:
{{
(
$detail
->
md_total_mileage
-
$detail
->
md_original_mileage
)
<
0
?
'red'
:
'green'
}};
">
({{ number_format(
$detail->md_total_mileage
-
$detail->md_original_mileage
, 1) }})
</span>
@endif
</td>
<td class="
right
aligned
">{{ number_format(
$detail->md_original_toll
??
$detail->md_total_toll
, 2) }}</td>
<td class="
right
aligned
">
{{ number_format(
$detail->md_total_toll
, 2) }}
@if(
$tollChanged
)
<span style="
color
:
{{
(
$detail
->
md_total_toll
-
$detail
->
md_original_toll
)
<
0
?
'red'
:
'green'
}};
">
({{ number_format(
$detail->md_total_toll
-
$detail->md_original_toll
, 2) }})
</span>
@endif
</td>
<td class="
right
aligned
">{{ number_format(
$detail->md_original_parking_fee
??
$detail->md_total_parking_fee
, 2) }}</td>
<td class="
right
aligned
">
{{ number_format(
$detail->md_total_parking_fee
, 2) }}
@if(
$parkChanged
)
<span style="
color
:
{{
(
$detail
->
md_total_parking_fee
-
$detail
->
md_original_parking_fee
)
<
0
?
'red'
:
'green'
}};
">
({{ number_format(
$detail->md_total_parking_fee
-
$detail->md_original_parking_fee
, 2) }})
</span>
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
@if($validInMonth->count() > 0)
{{-- Jumlah Keseluruhan Summary --}}
<tr
class=
"totals-row"
>
<table class="
ui
definition
table
" style="
margin
-
top
:
0.5
rem
;
">
<td
colspan=
"6"
style=
"text-align:right;"
><strong>
Jumlah Keseluruhan
</strong></td>
<tr>
<td><strong>
{{ number_format($totalMileage, 1) }} KM
</strong></td>
<td>Jumlah Anggaran Asal</td>
<td><strong>
RM {{ number_format($totalToll, 2) }}
</strong></td>
<td class="
right
aligned
">RM {{ number_format(
$origGrandAnggaran
, 2) }}</td>
<td><strong>
RM {{ number_format($totalOthers, 2) }}
</strong></td>
<td
colspan=
"2"
><strong>
RM {{ number_format($mileageAmount, 2) }}
</strong></td>
</tr>
</tr>
@endif
<tr>
<td><strong>Jumlah Anggaran Selepas Pindaan</strong></td>
</tbody>
<td class="
right
aligned
"><strong>RM {{ number_format(
$grandAnggaran
, 2) }}</strong></td>
</table>
</tr>
<tr>
<td>Perbezaan</td>
<td class="
right
aligned
" style="
color
:
{{
$diffAnggaran
<
0
?
'red'
:
(
$diffAnggaran
>
0
?
'green'
:
'inherit'
)
}};
">
{{
$diffAnggaran
>= 0 ? '+' : '' }}RM {{ number_format(
$diffAnggaran
, 2) }}
</td>
</tr>
</table>
{{-- Detailed Calculation Summary --}}
<p style="
color
:
grey
;
font
-
size
:
0.9
em
;
margin
-
top
:
0.5
rem
;
">
@if($claims->count() > 0)
<i class="
info
circle
icon
"></i> Baris yang berwarna kuning menunjukkan butiran yang telah dipinda oleh Kewangan.
@php
</p>
// Use already filtered valid claims
&
computed uniqueDays
</div>
$claimableDistance = max(0, $totalMileage - $deduction);
@endif
// === Mileage by vehicle type ===
$rateCar1 = 0.55; $rateCar2 = 0.50; $rateMoto = 0.30;
$mileageAmount = 0;
$vehicleGroups = [];
foreach ($validInMonth->groupBy(fn($c) => strtolower($c->jenisKenderaan->name ?? 'kereta')) as $type => $group) {
$typeMileage = $group->sum('total_mileage');
$typeClaimable = max(0, $typeMileage - ($deduction / max($validInMonth->groupBy('jenisKenderaan.name')->count(), 1)));
if (in_array($type, ['motosikal', 'motorcycle'])) {
{{-- Penalty Preview (status 9 only) --}}
$typeAmount = $typeClaimable * $rateMoto;
@if(
$claim->status
== 9)
$vehicleGroups[] = [
@php
'type' => ucfirst($type),
$earliestDate
=
$claim->details
->min('md_claim_date');
'details' => "{$typeClaimable} km × RM{$rateMoto}",
$submitDate
=
$claim->mm_submit_date
?? now();
'amount' => $typeAmount
$daysDiff
= \Carbon\Carbon::parse(
$earliestDate
)->diffInDays(\Carbon\Carbon::parse(
$submitDate
));
];
if (
$daysDiff
<= 30) {
$previewRate
= 0;
$previewLabel
= 'Tiada penalti (≤ 30 hari)';
} elseif (
$daysDiff
<= 90) {
$previewRate
= 10;
$previewLabel
= 'Lewat hantar > 30 ≤ 90 hari (10%)';
} elseif (
$daysDiff
<= 180) {
$previewRate
= 30;
$previewLabel
= 'Lewat hantar > 90 ≤ 180 hari (30%)';
} else {
} else {
$firstPart = min($typeClaimable, 500);
$previewRate
= null;
$secondPart = max(0, $typeClaimable - 500);
$previewLabel
= 'Lewat hantar > 180 hari (Tertakluk BOD)';
$typeAmount = ($firstPart * $rateCar1) + ($secondPart * $rateCar2);
$vehicleGroups[] = [
'type' => ucfirst($type),
'details' => "{$firstPart} km × RM{$rateCar1}" .
($secondPart > 0 ? " + {$secondPart} km × RM{$rateCar2}" : ""),
'amount' => $typeAmount
];
}
}
$previewPenalty
=
$previewRate
!== null ? round(
$grandAnggaran
* (
$previewRate
/ 100), 2) : 0;
$previewFinal
= round(
$grandAnggaran
-
$previewPenalty
, 2);
@endphp
<div class="
ui
segment
">
<h3 class="
ui
header
">Pengiraan Penalti</h3>
<table class="
ui
definition
table
">
<tr><td>Tarikh Tuntutan Terawal</td><td>{{ \Carbon\Carbon::parse(
$earliestDate
)->format('d/m/Y') }}</td></tr>
<tr><td>Tarikh Hantar</td><td>{{ \Carbon\Carbon::parse(
$submitDate
)->format('d/m/Y') }}</td></tr>
<tr><td>Selisih Hari</td><td>{{
$daysDiff
}} hari</td></tr>
<tr><td>Kadar Penalti</td><td>{{
$previewLabel
}}</td></tr>
<tr><td>Jumlah Anggaran</td><td>RM {{ number_format(
$grandAnggaran
, 2) }}</td></tr>
<tr><td>Potongan Penalti</td><td>RM {{ number_format(
$previewPenalty
, 2) }}</td></tr>
<tr><td><strong>Jumlah Akhir</strong></td><td><strong>RM {{ number_format(
$previewFinal
, 2) }}</strong></td></tr>
</table>
</div>
@endif
$mileageAmount += $typeAmount;
{{-- Finance Detail (status 11 or 12) --}}
}
@if(
$claim->financeDetail
)
<div class="
ui
segment
">
// === Subtotal ===
<h3 class="
ui
header
">Pelarasan Kewangan</h3>
$subtotal = $mileageAmount + $totalToll + $totalOthers;
<table class="
ui
definition
table
">
<tr><td>Jumlah Anggaran Asal</td><td>RM {{ number_format(
$claim->financeDetail
->fin_original_amount, 2) }}</td></tr>
// === Penalty ===
<tr>
$finalTotal = $subtotal - $totalPenalty;
<td>Kadar Penalti</td>
@endphp
<td>
@if(
$claim->financeDetail
->fin_penalty_rate === null)
Tertakluk BOD
@elseif(
$claim->financeDetail
->fin_penalty_rate == 0)
Tiada Penalti
@else
{{
$claim->financeDetail
->fin_penalty_rate }}%
@endif
</td>
</tr>
<tr><td>Potongan Penalti</td><td>RM {{ number_format(
$claim->financeDetail
->fin_penalty_amount, 2) }}</td></tr>
@if(
$claim->financeDetail
->fin_amendment_remark)
<tr><td>Catatan Pindaan</td><td>{{
$claim->financeDetail
->fin_amendment_remark }}</td></tr>
@endif
<tr><td><strong>Jumlah Akhir Dibayar</strong></td><td><strong>RM {{ number_format(
$claim->financeDetail
->fin_final_amount, 2) }}</strong></td></tr>
<tr><td>Disemak Oleh</td><td>{{
$claim->financeDetail
->processedBy?->name ?? '-' }} {{
$claim->financeDetail
->fin_processed_date ? '(' . \Carbon\Carbon::parse(
$claim->financeDetail
->fin_processed_date)->format('d/m/Y') . ')' : '' }}</td></tr>
</table>
</div>
@endif
<div
class=
"ui segment"
>
{{-- Sejarah Kuiri --}}
<h4><i
class=
"calculator icon"
></i>
Ringkasan Pengiraan Bulanan
</h4>
@if(
$claim->auditQueries
->count() > 0)
<table
class=
"ui definition table"
>
<div class="
ui
segment
">
<tr><td>
Jumlah Perbatuan (Sebenar)
</td><td>
{{ number_format($totalMileage,1) }} KM
</td></tr>
<h3 class="
ui
header
">Sejarah Kuiri</h3>
<tr><td>
Hari Tuntutan
</td><td>
{{ $uniqueDays }} hari
</td></tr>
<table class="
ui
celled
table
">
<tr><td>
Potongan 40 KM/Hari
</td><td>
{{ $uniqueDays }} × 40 = {{ $deduction }} KM
</td></tr>
<thead>
<tr>
<tr>
<td>
Jumlah Layak Tuntut
</td>
<th>Bil</th>
<td>
<th>Jenis</th>
{{ number_format($totalMileage,1) }} KM − {{ number_format($deduction,1) }} KM
<th>Catatan</th>
=
<strong>
{{ number_format($claimableDistance,1) }} KM
</strong>
<th>Respons Pemohon</th>
</td>
<th>Tarikh</th>
</tr>
</tr>
<tr>
</thead>
<td>
Kadar Kiraan
</td>
<tbody>
<td>
@foreach(
$claim->auditQueries
as
$index
=>
$q
)
@foreach($vehicleGroups as $v)
<tr>
• {{ ucfirst($v['type']) }}: {!! $v['details'] !!} =
<strong>
RM {{ number_format($v['amount'],2) }}
</strong><br>
<td>{{
$index
+ 1 }}</td>
<td>
@if(
$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
@endforeach
</td>
</tbody>
</tr>
</table>
<tr><td>
Jumlah Perbatuan (RM)
</td><td>
RM {{ number_format($mileageAmount,2) }}
</td></tr>
</div>
<tr><td>
Jumlah Tol
</td><td>
RM {{ number_format($totalToll,2) }}
</td></tr>
<tr><td>
Jumlah Lain-lain
</td><td>
RM {{ number_format($totalOthers,2) }}
</td></tr>
<tr><td><strong>
Subtotal (Sebelum Penalti)
</strong></td><td><strong>
RM {{ number_format($subtotal,2) }}
</strong></td></tr>
<tr>
<td>
Penalti
</td>
<td>
@if($isBOD)
<span
style=
"color:#d35400;"
><i
class=
"exclamation triangle icon"
></i>
Tertakluk kepada BOD
</span>
@elseif($totalPenalty > 0)
Tolak: RM {{ number_format($totalPenalty, 2) }}
<br>
@foreach($penaltyBreakdown as $p)
@if($p['penalty'] > 0)
• {{ \Carbon\Carbon::parse($p['claim_date'])->format('d/m/Y') }}: {{ $p['label'] }} (RM {{ number_format($p['penalty'], 2) }})
<br>
@endif
@endforeach
@else
Tiada penalti
@endif
</td>
</tr>
<tr
class=
"totals-row"
>
<td><strong>
Jumlah Akhir (Selepas Penalti)
</strong></td>
<td><strong>
RM {{ number_format($finalTotal,2) }}
</strong></td>
</tr>
</table>
</div>
@endif
@endif
{{-- Edit Modal --}}
{{-- Tindakan Finance --}}
<div
class=
"ui modal"
id=
"editModal"
>
@if(
$claim->status
== 9)
<i
class=
"close icon"
></i>
<div class="
ui
segment
">
<div
class=
"header"
>
Kemaskini Tuntutan
</div>
<h3 class="
ui
header
">Tindakan Kewangan</h3>
<div
class=
"content"
>
<form id="
formSemak
" action="
{{
route
(
'mileage::finance.semak'
,
$claim
->
id
)
}}
" method="
POST
">
<form
id=
"editForm"
method=
"POST"
action=
""
>
@csrf
@csrf
@method('PUT')
<div class="
ui
form
">
<div class="
ui
form
">
<div
class=
"field required"
>
<div class="
field
">
<label>
Tarikh
</label>
<label>Catatan Pindaan <span style="
color
:
grey
;
font
-
weight
:
normal
;
">(jika ada)</span></label>
<input
type=
"date"
name=
"claim_date"
id=
"editDate"
required
>
<textarea name="
fin_remark
" rows="
3
" placeholder="
Isi
jika
terdapat
pindaan
pada
butiran
tuntutan
.
Catatan
ini
akan
dipaparkan
dalam
rekod
tuntutan
pemohon
.
"></textarea>
</div>
<div
class=
"two fields"
>
<div
class=
"field required"
>
<label>
Dari
</label>
<input
type=
"text"
name=
"distance_from"
id=
"editFrom"
required
>
</div>
<div
class=
"field required"
>
<label>
Ke
</label>
<input
type=
"text"
name=
"distance_to"
id=
"editTo"
required
>
</div>
</div>
<div
class=
"field required"
>
<label>
Butiran
</label>
<input
type=
"text"
name=
"description"
id=
"editDescription"
required
>
</div>
<div
class=
"three fields"
>
<div
class=
"field required"
>
<label>
Jumlah KM
</label>
<input
type=
"number"
step=
"0.1"
name=
"total_mileage"
id=
"editMileage"
required
>
</div>
<div
class=
"field"
>
<label>
Tol (RM)
</label>
<input
type=
"number"
step=
"0.01"
name=
"toll_amount"
id=
"editToll"
>
</div>
<div
class=
"field"
>
<label>
Lain-lain (RM)
</label>
<input
type=
"number"
step=
"0.01"
name=
"others_amount"
id=
"editOthers"
>
</div>
</div>
<div
class=
"field"
id=
"othersDetailsField"
style=
"display:none;"
>
<label>
Butiran Lain-lain
</label>
<input
type=
"text"
name=
"others_details"
id=
"editOthersDetails"
placeholder=
"Nyatakan butiran lain-lain (contoh: bayaran penghantaran, dokumen, dsb)"
>
</div>
</div>
</div>
</div>
<br>
</form>
</form>
</div>
</div>
<div
class=
"actions"
>
@endif
<div
class=
"ui cancel button"
>
Batal
</div>
<button
type=
"submit"
form=
"editForm"
class=
"ui primary button"
>
Simpan
</button>
</div>
</div>
</div>
@endsection
<script
src=
"https://code.jquery.com/jquery-3.7.1.min.js"
></script>
<script>
$
(
document
).
ready
(
function
()
{
// === Handle Edit button click ===
$
(
'.edit-btn'
).
on
(
'click'
,
function
()
{
const
id
=
$
(
this
).
data
(
'id'
);
const
date
=
$
(
this
).
data
(
'date'
);
const
desc
=
$
(
this
).
data
(
'description'
);
const
from
=
$
(
this
).
data
(
'distance-from'
);
const
to
=
$
(
this
).
data
(
'distance-to'
);
const
mileage
=
$
(
this
).
data
(
'mileage'
);
const
toll
=
$
(
this
).
data
(
'toll'
);
const
others
=
$
(
this
).
data
(
'others'
);
const
othersDetails
=
$
(
this
).
data
(
'others-details'
);
const
updateUrl
=
"{{ route('mileage::finance.update', ':id') }}"
.
replace
(
':id'
,
id
);
$
(
'#editForm'
).
attr
(
'action'
,
updateUrl
);
$
(
'#editDate'
).
val
(
date
);
$
(
'#editDescription'
).
val
(
desc
);
$
(
'#editFrom'
).
val
(
from
);
$
(
'#editTo'
).
val
(
to
);
$
(
'#editMileage'
).
val
(
mileage
);
$
(
'#editToll'
).
val
(
toll
);
$
(
'#editOthers'
).
val
(
others
);
$
(
'#editOthersDetails'
).
val
(
othersDetails
||
''
);
// Trigger the others field logic
$
(
'#editOthers'
).
trigger
(
'input'
);
$
(
'#editModal'
).
modal
(
'show'
);
});
// === Show/Hide "Butiran Lain-lain" based on input ===
{{-- Buttons --}}
$
(
'#editOthers'
).
on
(
'input'
,
function
()
{
<div style="
text
-
align
:
right
;
">
const
value
=
parseFloat
(
$
(
this
).
val
())
||
0
;
<a href="
{{
route
(
'mileage::finance.index'
)
}}
" class="
ui
button
">
if
(
value
>
0
)
{
<i class="
arrow
left
icon
"></i> Kembali
$
(
'#othersDetailsField'
).
slideDown
();
</a>
$
(
'#editOthersDetails'
).
attr
(
'required'
,
true
);
@if(
$claim->status
== 9)
}
else
{
<a href="
{{
route
(
'mileage::finance.edit'
,
$claim
->
id
)
}}
" class="
ui
orange
button
">
$
(
'#othersDetailsField'
).
slideUp
();
<i class="
edit
icon
"></i> Kemaskini Butiran
$
(
'#editOthersDetails'
).
removeAttr
(
'required'
).
val
(
''
);
</a>
}
<button type="
submit
" form="
formSemak
" class="
ui
teal
button
"
});
onclick="
return
confirm
(
'Semak dan muktamadkan pengiraan penalti untuk permohonan ini?'
)
">
<i class="
check
icon
"></i> Semak
</button>
@endif
</div>
// === Validate before form submission ===
<br><br>
$
(
'#editForm'
).
on
(
'submit'
,
function
(
e
)
{
</div>
const
others
=
parseFloat
(
$
(
'#editOthers'
).
val
())
||
0
;
const
othersDetails
=
$
(
'#editOthersDetails'
).
val
().
trim
();
if
(
others
>
0
&&
othersDetails
===
''
)
{
@endsection
e
.
preventDefault
();
alert
(
'Sila isi Butiran Lain-lain kerana jumlah Lain-lain (RM) lebih daripada 0.'
);
$
(
'#editOthersDetails'
).
focus
();
return
;
}
let
valid
=
true
;
@push('script')
$
(
'#editForm [required]'
).
each
(
function
()
{
<script>
if
(
$
(
this
).
val
().
trim
()
===
''
)
{
$(document).ready(function () {
valid
=
false
;
$('#modalAnggaran').modal({ closable: true });
alert
(
'Sila isi semua ruangan yang diperlukan.'
);
$
(
this
).
focus
();
e
.
preventDefault
();
return
false
;
}
});
});
});
});
</script>
</script>
@endpush
packages/portal/mileage/resources/views/finance/view.blade.php
deleted
100644 → 0
View file @
d26a4cf1
<title>
Maklumat Tuntutan (Finance)
</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 (Finance)
</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>
</div>
</div>
@endsection
packages/portal/mileage/resources/views/mileage/form.blade.php
View file @
0d252112
...
@@ -51,6 +51,8 @@
...
@@ -51,6 +51,8 @@
6, 8, 10 => 'orange',
6, 8, 10 => 'orange',
7 => 'teal',
7 => 'teal',
9 => 'green',
9 => 'green',
11 => 'violet',
12 => 'green',
default => 'grey',
default => 'grey',
};
};
@endphp
@endphp
...
@@ -182,6 +184,8 @@
...
@@ -182,6 +184,8 @@
</table>
</table>
</div>
</div>
{{-- Segment 2: Tambah / Kemaskini butiran (Draf only) --}}
{{-- Segment 2: Tambah / Kemaskini butiran (Draf only) --}}
@if(
$claim->status
== 1)
@if(
$claim->status
== 1)
...
@@ -336,6 +340,57 @@
...
@@ -336,6 +340,57 @@
@endif
@endif
</div>
</div>
{{-- Keputusan Kewangan (shown after Finance semak) --}}
@if(
$claim->financeDetail
)
<div class="
ui
segment
">
<h3 class="
ui
header
">Keputusan Kewangan</h3>
<table class="
ui
definition
table
">
<tr>
<td>Jumlah Anggaran Asal</td>
<td>RM {{ number_format(
$claim->financeDetail
->fin_original_amount, 2) }}</td>
</tr>
<tr>
<td>Kadar Penalti</td>
<td>
@if(
$claim->financeDetail
->fin_penalty_rate === null)
Tertakluk BOD
@elseif(
$claim->financeDetail
->fin_penalty_rate == 0)
Tiada Penalti
@else
{{
$claim->financeDetail
->fin_penalty_rate }}%
@endif
</td>
</tr>
<tr>
<td>Potongan Penalti</td>
<td>RM {{ 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</strong></td>
<td><strong style="
font
-
size
:
1.1
em
;
color
:
green
;
">
RM {{ number_format(
$claim->financeDetail
->fin_final_amount, 2) }}
</strong></td>
</tr>
<tr>
<td>Disemak Oleh</td>
<td>
{{
$claim->financeDetail
->processedBy?->name ?? '-' }}
{{
$claim->financeDetail
->fin_processed_date
? '(' . \Carbon\Carbon::parse(
$claim->financeDetail
->fin_processed_date)->format('d/m/Y') . ')'
: '' }}
</td>
</tr>
</table>
</div>
@endif
{{-- Modal: Anggaran Tuntutan --}}
{{-- Modal: Anggaran Tuntutan --}}
<div class="
ui
small
modal
" id="
modalAnggaran
">
<div class="
ui
small
modal
" id="
modalAnggaran
">
<div class="
header
"><i class="
info
circle
icon
"></i> Formula Anggaran Tuntutan</div>
<div class="
header
"><i class="
info
circle
icon
"></i> Formula Anggaran Tuntutan</div>
...
...
packages/portal/mileage/resources/views/mileage/list.blade.php
View file @
0d252112
...
@@ -66,17 +66,20 @@
...
@@ -66,17 +66,20 @@
$refId
=
$row->lkpStatus
?->ref_id ?? 0;
$refId
=
$row->lkpStatus
?->ref_id ?? 0;
$color
= match(
$refId
) {
$color
= match(
$refId
) {
1 => 'grey',
1
=> 'grey',
2 => 'blue',
2
=> 'blue',
3 => 'yellow',
3
=> 'yellow',
4 => 'red',
4
=> 'red',
5 => 'olive',
5
=> 'olive',
6, 8, 10 => 'orange',
6, 8, 10 => 'orange',
7 => 'teal',
7 => 'teal',
9 => 'green',
9 => 'green',
default => 'grey',
11 => 'violet',
12 => 'green',
default => 'grey',
};
};
return '<span class="
ui
' . $color . '
label
">' .
$status
. '</span>';
return '<span class="
ui
' . $color . '
label
">' .
$status
. '</span>';
}],
}],
...
@@ -113,6 +116,11 @@
...
@@ -113,6 +116,11 @@
Permohonan Baharu
Permohonan Baharu
</div>
</div>
<div class="
content
">
<div class="
content
">
<div class="
ui
error
message
" id="
modalError
" style="
display
:
none
;
">
<i class="
exclamation
circle
icon
"></i>
Sila pilih <strong>Tahun</strong>, <strong>Bulan</strong> dan <strong>Kategori FA</strong> sebelum meneruskan.
</div>
<form class="
ui
form
" method="
POST
" action="
{{
route
(
'mileage::mileage.claim.store'
)
}}
" id="
formPermohonanBaharu
">
<form class="
ui
form
" method="
POST
" action="
{{
route
(
'mileage::mileage.claim.store'
)
}}
" id="
formPermohonanBaharu
">
@csrf
@csrf
...
@@ -154,9 +162,9 @@
...
@@ -154,9 +162,9 @@
</div>
</div>
<div class="
actions
">
<div class="
actions
">
<div class="
ui
black
deny
button
">Batal</div>
<div class="
ui
black
deny
button
">Batal</div>
<div class="
ui
primary
approve
button
"
onclick="
document
.
getElementById
(
'formPermohonanBaharu'
)
.
submit
()
"
>
<div class="
ui
primary
approve
button
">
Seterusnya
Seterusnya
</div>
</div>
</div>
</div>
</div>
</div>
...
@@ -166,7 +174,23 @@
...
@@ -166,7 +174,23 @@
<script>
<script>
$(document).ready(function () {
$(document).ready(function () {
$('.ui.dropdown').dropdown();
$('.ui.dropdown').dropdown();
$('#modalPermohonanBaharu').modal();
$('#modalPermohonanBaharu').modal({
closable: true,
onApprove: function () {
var tahun = $('select[name="
mm_claim_year
"]').val();
var bulan = $('select[name="
mm_claim_month
"]').val();
var fa = $('select[name="
fk_lkp_fa_category
"]').val();
if (!tahun || !bulan || !fa) {
$('#modalError').show();
return false; // modal stays open
}
$('#modalError').hide();
document.getElementById('formPermohonanBaharu').submit();
}
});
var usedMonths = @json(
$usedMonths
);
var usedMonths = @json(
$usedMonths
);
...
@@ -217,6 +241,21 @@ function updateMonthOptions(year) {
...
@@ -217,6 +241,21 @@ function updateMonthOptions(year) {
// Run immediately for the pre-selected current year
// Run immediately for the pre-selected current year
updateMonthOptions('{{ now()->year }}');
updateMonthOptions('{{ now()->year }}');
window.submitPermohonanBaharu = function () {
var tahun = $('select[name="
mm_claim_year
"]').val();
var bulan = $('select[name="
mm_claim_month
"]').val();
var fa = $('select[name="
fk_lkp_fa_category
"]').val();
if (!tahun || !bulan || !fa) {
$('#modalError').show();
return;
}
$('#modalError').hide();
document.getElementById('formPermohonanBaharu').submit();
};
});
});
</script>
</script>
@endpush
@endpush
...
...
packages/portal/mileage/routes/web.php
View file @
0d252112
...
@@ -55,19 +55,17 @@ function () {
...
@@ -55,19 +55,17 @@ function () {
Route
::
post
(
'/claim/{id}/reject'
,
[
ProjectDirectorController
::
class
,
'rejectClaim'
])
->
name
(
'.rejectClaim'
);
Route
::
post
(
'/claim/{id}/reject'
,
[
ProjectDirectorController
::
class
,
'rejectClaim'
])
->
name
(
'.rejectClaim'
);
});
});
// Finance
Department
// Finance
Route
::
prefix
(
'finance'
)
->
name
(
'finance'
)
->
group
(
function
()
{
Route
::
prefix
(
'finance'
)
->
name
(
'finance'
)
->
group
(
function
()
{
Route
::
get
(
'/dashboard'
,
[
FinanceController
::
class
,
'index'
])
->
name
(
'.index'
);
Route
::
get
(
'/dashboard'
,
[
FinanceController
::
class
,
'index'
])
->
name
(
'.index'
);
Route
::
get
(
'/show/{userId}'
,
[
FinanceController
::
class
,
'show'
])
->
name
(
'.show'
);
Route
::
get
(
'/show/{id}'
,
[
FinanceController
::
class
,
'show'
])
->
name
(
'.show'
);
Route
::
put
(
'/finance/update/{id}'
,
[
FinanceController
::
class
,
'update'
])
->
name
(
'.update'
);
Route
::
get
(
'/{id}/edit'
,
[
FinanceController
::
class
,
'edit'
])
->
name
(
'.edit'
);
Route
::
get
(
'/view/claim/{id}'
,
[
FinanceController
::
class
,
'viewEach'
])
->
name
(
'.viewEach'
);
Route
::
put
(
'/{id}/update'
,
[
FinanceController
::
class
,
'update'
])
->
name
(
'.update'
);
Route
::
put
(
'/finance/claims/{id}/update-status'
,
[
FinanceController
::
class
,
'updateStatus'
])
->
name
(
'.updateStatus'
);
Route
::
post
(
'/{id}/semak'
,
[
FinanceController
::
class
,
'semak'
])
->
name
(
'.semak'
);
// Route::post('/{id}/review', [FinanceController::class, 'review'])->name('.review');
// Route::post('/{id}/bayar', [FinanceController::class, 'bayar'])->name('.bayar');
// Route::post('/{id}/reject', [FinanceController::class, 'reject'])->name('.reject');
Route
::
get
(
'/export'
,
[
FinanceController
::
class
,
'export'
])
->
name
(
'.export'
);
});
});
// HOD
// HOD
Route
::
prefix
(
'HOD'
)
->
name
(
'HOD'
)
->
group
(
function
()
{
Route
::
prefix
(
'HOD'
)
->
name
(
'HOD'
)
->
group
(
function
()
{
Route
::
get
(
'/dashboard'
,
[
HODController
::
class
,
'index'
])
->
name
(
'.index'
);
Route
::
get
(
'/dashboard'
,
[
HODController
::
class
,
'index'
])
->
name
(
'.index'
);
...
...
packages/portal/mileage/src/Data/Repo/FinanceRepo.php
0 → 100644
View file @
0d252112
<?php
namespace
Portal\Mileage\Data\Repo
;
use
Portal\Mileage\Model\MileageClaimMain
;
use
Portal\Mileage\Model\MileageClaimDetail
;
use
Portal\Mileage\Model\MileageClaimFinance
;
use
Portal\Mileage\Model\MileageClaimAuditTrail
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Auth
;
use
Carbon\Carbon
;
class
FinanceRepo
{
public
function
getFinanceList
(
$request
)
{
$search
=
$request
->
get
(
'search'
);
$tahun
=
$request
->
get
(
'tahun'
);
$bulan
=
$request
->
get
(
'bulan'
);
$status
=
$request
->
get
(
'status'
);
return
MileageClaimMain
::
with
([
'lkpStatus'
,
'staffInfo'
])
->
whereIn
(
'status'
,
[
9
,
11
])
->
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
.
'%'
);
});
})
->
when
(
$tahun
,
function
(
$q
)
use
(
$tahun
)
{
$q
->
where
(
'mm_claim_year'
,
$tahun
);
})
->
when
(
$bulan
,
function
(
$q
)
use
(
$bulan
)
{
$q
->
where
(
'mm_claim_month'
,
$bulan
);
})
->
when
(
$status
,
function
(
$q
)
use
(
$status
)
{
$q
->
where
(
'status'
,
$status
);
})
->
orderBy
(
'created_at'
,
'desc'
)
->
paginate
(
15
);
}
public
function
findClaim
(
$id
)
{
return
MileageClaimMain
::
with
([
'details.jenisKenderaan.rates'
,
'details.project'
,
'lkpStatus'
,
'staffInfo'
,
'auditQueries'
,
'attachments'
,
'faCategory'
,
'financeDetail'
,
])
->
findOrFail
(
$id
);
}
public
function
editClaim
(
$id
,
$data
)
{
foreach
(
$data
as
$detailId
=>
$fields
)
{
$detail
=
MileageClaimDetail
::
findOrFail
(
$detailId
);
// Snapshot originals on first edit only
if
(
$detail
->
md_original_mileage
===
null
)
{
$detail
->
md_original_mileage
=
$detail
->
md_total_mileage
;
$detail
->
md_original_toll
=
$detail
->
md_total_toll
;
$detail
->
md_original_parking_fee
=
$detail
->
md_total_parking_fee
;
}
$detail
->
md_total_mileage
=
$fields
[
'md_total_mileage'
]
??
$detail
->
md_total_mileage
;
$detail
->
md_total_toll
=
$fields
[
'md_total_toll'
]
??
$detail
->
md_total_toll
;
$detail
->
md_total_parking_fee
=
$fields
[
'md_total_parking_fee'
]
??
$detail
->
md_total_parking_fee
;
$detail
->
save
();
}
}
public
function
semakClaim
(
$id
,
$remark
=
null
)
{
$claim
=
MileageClaimMain
::
with
([
'details.jenisKenderaan.rates'
])
->
findOrFail
(
$id
);
$originalAmount
=
$this
->
calculateTotal
(
$claim
);
$earliestDate
=
$claim
->
details
->
min
(
'md_claim_date'
);
$submitDate
=
$claim
->
mm_submit_date
??
now
();
$daysDiff
=
Carbon
::
parse
(
$earliestDate
)
->
diffInDays
(
Carbon
::
parse
(
$submitDate
));
if
(
$daysDiff
<=
30
)
{
$penaltyRate
=
0
;
}
elseif
(
$daysDiff
<=
90
)
{
$penaltyRate
=
10
;
}
elseif
(
$daysDiff
<=
180
)
{
$penaltyRate
=
30
;
}
else
{
$penaltyRate
=
null
;
}
$penaltyAmount
=
$penaltyRate
!==
null
?
round
(
$originalAmount
*
(
$penaltyRate
/
100
),
2
)
:
0
;
$finalAmount
=
round
(
$originalAmount
-
$penaltyAmount
,
2
);
MileageClaimFinance
::
updateOrCreate
(
[
'fk_mileage_claim_main'
=>
$id
],
[
'fin_original_amount'
=>
$originalAmount
,
'fin_penalty_rate'
=>
$penaltyRate
,
'fin_penalty_amount'
=>
$penaltyAmount
,
'fin_amendment_remark'
=>
$remark
,
'fin_final_amount'
=>
$finalAmount
,
'fin_processed_by'
=>
Auth
::
id
(),
'fin_processed_date'
=>
now
(),
]
);
$claim
->
update
([
'status'
=>
11
]);
MileageClaimAuditTrail
::
create
([
'fk_lkp_mileage_task'
=>
12
,
'fk_mileage_claim_main'
=>
$id
,
'action_by'
=>
Auth
::
id
(),
'remark'
=>
Auth
::
user
()
->
name
.
' Telah Semak Permohonan Tuntutan Mileage (mileage_claim_main.id = '
.
$id
.
')'
,
]);
return
$claim
;
}
public
function
bayarClaim
(
$id
)
{
$claim
=
MileageClaimMain
::
findOrFail
(
$id
);
$claim
->
update
([
'status'
=>
12
]);
MileageClaimAuditTrail
::
create
([
'fk_lkp_mileage_task'
=>
13
,
'fk_mileage_claim_main'
=>
$id
,
'action_by'
=>
Auth
::
id
(),
'remark'
=>
Auth
::
user
()
->
name
.
' Telah Proses Bayaran Tuntutan Mileage (mileage_claim_main.id = '
.
$id
.
')'
,
]);
return
$claim
;
}
private
function
calculateTotal
(
$claim
)
{
$total
=
0
;
$sortedDetails
=
$claim
->
details
->
sortBy
(
'md_claim_date'
)
->
values
();
$dateFirstSeen
=
[];
$cumulativeKmByDate
=
[];
foreach
(
$sortedDetails
as
$detail
)
{
$jumlahJarak
=
(
float
)
$detail
->
md_total_mileage
;
$dateKey
=
$detail
->
md_claim_date
;
$isFirstOfDate
=
!
isset
(
$dateFirstSeen
[
$dateKey
]);
if
(
$isFirstOfDate
)
$dateFirstSeen
[
$dateKey
]
=
true
;
$claimableKm
=
$isFirstOfDate
?
max
(
0
,
$jumlahJarak
-
40
)
:
$jumlahJarak
;
$startKm
=
$cumulativeKmByDate
[
$dateKey
]
??
0
;
$endKm
=
$startKm
+
$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
;
}
$cumulativeKmByDate
[
$dateKey
]
=
$endKm
;
$total
+=
$mileageAmount
+
(
float
)
$detail
->
md_total_toll
+
(
float
)
$detail
->
md_total_parking_fee
;
}
return
round
(
$total
,
2
);
}
}
packages/portal/mileage/src/Data/Repo/MileageRepo.php
View file @
0d252112
...
@@ -88,7 +88,7 @@ public function storeClaim($request)
...
@@ -88,7 +88,7 @@ public function storeClaim($request)
public
function
findClaim
(
$id
)
public
function
findClaim
(
$id
)
{
{
return
MileageClaimMain
::
with
([
'details.jenisKenderaan.rates'
,
'details.project'
,
'auditQueries'
,
'attachments'
,
'faCategory'
,
'lkpStatus'
])
->
findOrFail
(
$id
);
return
MileageClaimMain
::
with
([
'details.jenisKenderaan.rates'
,
'details.project'
,
'auditQueries'
,
'attachments'
,
'faCategory'
,
'lkpStatus'
,
'financeDetail'
])
->
findOrFail
(
$id
);
}
}
...
...
packages/portal/mileage/src/Http/Controllers/FinanceController.php
View file @
0d252112
...
@@ -2,238 +2,55 @@
...
@@ -2,238 +2,55 @@
namespace
Portal\Mileage\Http\Controllers
;
namespace
Portal\Mileage\Http\Controllers
;
use
Portal\Mileage\Model\Users
;
use
Illuminate\Routing\Controller
;
use
Portal\Mileage\Model\Claim
;
use
App\Http\Controllers\Controller
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Carbon\Carbon
;
use
Portal\Mileage\Data\Repo\FinanceRepo
;
use
Maatwebsite\Excel\Facades\Excel
;
use
Symfony\Component\HttpFoundation\StreamedResponse
;
use
Portal\Mileage\Exports\ClaimsExport
;
class
FinanceController
extends
Controller
class
FinanceController
extends
Controller
{
{
public
function
index
(
Request
$request
)
protected
$repos
;
{
$month
=
$request
->
get
(
'month'
,
Carbon
::
now
()
->
format
(
'Y-m'
));
$parsedMonth
=
Carbon
::
parse
(
$month
);
$claims
=
Claim
::
with
([
'user'
,
'project'
])
->
whereIn
(
'status'
,
[
'Disahkan'
,
'Disokong'
,
'Disemak'
,
'Diproses'
,
'Ditolak'
,
'Dibayar'
])
->
whereMonth
(
'claim_date'
,
$parsedMonth
->
month
)
->
whereYear
(
'claim_date'
,
$parsedMonth
->
year
)
->
get
();
$summary
=
[
'processed'
=>
$claims
->
where
(
'status'
,
'Diproses'
)
->
count
(),
'verified'
=>
$claims
->
where
(
'status'
,
'Disokong'
)
->
count
(),
'approved'
=>
$claims
->
where
(
'status'
,
'Disahkan'
)
->
count
(),
'reviewed'
=>
$claims
->
where
(
'status'
,
'Disemak'
)
->
count
(),
'paid'
=>
$claims
->
where
(
'status'
,
'Dibayar'
)
->
count
(),
'rejected'
=>
$claims
->
where
(
'status'
,
'Ditolak'
)
->
count
(),
];
$users
=
$claims
->
groupBy
(
'user_id'
)
->
map
(
function
(
$userClaims
)
{
$user
=
$userClaims
->
first
()
->
user
;
return
[
'id'
=>
$user
->
id
??
null
,
'name'
=>
$user
->
name
??
'-'
,
'total_claims'
=>
$userClaims
->
count
(),
'total_amount'
=>
$userClaims
->
sum
(
'total_claim_amount'
),
];
})
->
sortBy
(
'name'
)
->
values
();
return
view
(
'mileage::finance.index'
,
compact
(
'users'
,
'summary'
,
'month'
));
public
function
__construct
(
FinanceRepo
$repos
)
{
$this
->
repos
=
$repos
;
}
}
public
function
show
(
$userId
,
Request
$request
)
public
function
index
(
Request
$request
)
{
{
$month
=
$request
->
get
(
'month'
,
Carbon
::
now
()
->
format
(
'Y-m'
));
$list
=
$this
->
repos
->
getFinanceList
(
$request
);
$parsedMonth
=
Carbon
::
parse
(
$month
);
return
view
(
'mileage::finance.index'
,
compact
(
'list'
));
$user
=
Users
::
findOrFail
(
$userId
);
$claims
=
Claim
::
with
([
'project'
,
'jenisKenderaan'
])
->
where
(
'user_id'
,
$userId
)
->
whereMonth
(
'claim_date'
,
$parsedMonth
->
month
)
->
whereYear
(
'claim_date'
,
$parsedMonth
->
year
)
->
get
();
// === Calculate per-claim penalty (same formula as HOD/BOD) ===
$totalPenalty
=
0
;
$isBOD
=
false
;
$penaltyBreakdown
=
[];
foreach
(
$claims
as
$claim
)
{
$claimDate
=
Carbon
::
parse
(
$claim
->
claim_date
);
$submissionDate
=
$claim
->
created_at
??
Carbon
::
now
();
$daysDiff
=
$claimDate
->
diffInDays
(
$submissionDate
);
$claimableMileage
=
max
(
0
,
(
$claim
->
total_mileage
??
0
)
-
40
);
if
(
$claim
->
jenis_kenderaan_id
==
1
)
{
$rate
=
(
$claimableMileage
<=
500
)
?
0.55
:
0.50
;
}
else
{
$rate
=
0.30
;
}
$claimMileageAmount
=
round
(
$claimableMileage
*
$rate
,
2
);
if
(
$daysDiff
<=
30
)
{
$penaltyRate
=
0
;
$penaltyLabel
=
'Tiada penalti (≤ 1 bulan)'
;
}
elseif
(
$daysDiff
<=
90
)
{
$penaltyRate
=
0.10
;
$penaltyLabel
=
'Lewat hantar >1 ≤3 bulan (10%)'
;
}
elseif
(
$daysDiff
<=
180
)
{
$penaltyRate
=
0.30
;
$penaltyLabel
=
'Lewat hantar >3 ≤6 bulan (30%)'
;
}
else
{
$penaltyRate
=
'BOD'
;
$penaltyLabel
=
'Tertakluk kepada BOD'
;
$isBOD
=
true
;
}
$claimPenalty
=
$penaltyRate
===
'BOD'
?
0
:
round
(
$claimMileageAmount
*
$penaltyRate
,
2
);
$totalPenalty
+=
$claimPenalty
;
$penaltyBreakdown
[]
=
[
'claim_date'
=>
$claim
->
claim_date
,
'penalty'
=>
$claimPenalty
,
'label'
=>
$penaltyLabel
,
];
}
}
return
view
(
'mileage::finance.show'
,
compact
(
public
function
show
(
$id
)
'user'
,
'claims'
,
'month'
,
{
'totalPenalty'
,
'isBOD'
,
'penaltyBreakdown'
$claim
=
$this
->
repos
->
findClaim
(
$id
);
));
return
view
(
'mileage::finance.show'
,
compact
(
'claim'
));
}
}
public
function
viewEach
(
$id
)
public
function
edit
(
$id
)
{
{
$claim
=
Claim
::
with
([
'user'
,
'project'
,
'jenisKenderaan'
])
->
findOrFail
(
$id
);
$claim
=
$this
->
repos
->
findClaim
(
$id
);
return
view
(
'mileage::finance.
view
'
,
compact
(
'claim'
));
return
view
(
'mileage::finance.
edit
'
,
compact
(
'claim'
));
}
}
public
function
update
(
Request
$request
,
$id
)
public
function
update
(
Request
$request
,
$id
)
{
{
$claim
=
Claim
::
findOrFail
(
$id
);
$this
->
repos
->
editClaim
(
$id
,
$request
->
input
(
'details'
,
[]));
return
redirect
()
->
route
(
'mileage::finance.show'
,
$id
)
$validated
=
$request
->
validate
([
->
with
(
'success'
,
'Pindaan butiran berjaya disimpan. Sila semak semula butiran di bawah dan tekan Semak untuk meneruskan.'
);
'claim_date'
=>
'required|date'
,
'distance_from'
=>
'required|string|max:255'
,
'distance_to'
=>
'required|string|max:255'
,
'description'
=>
'required|string|max:255'
,
'total_mileage'
=>
'required|numeric|min:0'
,
'toll_amount'
=>
'nullable|numeric|min:0'
,
'others_amount'
=>
'nullable|numeric|min:0'
,
'others_details'
=>
'nullable|string|max:255'
,
]);
if
((
$request
->
others_amount
??
0
)
>
0
&&
empty
(
$request
->
others_details
))
{
return
back
()
->
with
(
'error'
,
'Butiran lain-lain perlu diisi apabila jumlah lain-lain melebihi 0.'
);
}
$claim
->
update
([
'claim_date'
=>
$validated
[
'claim_date'
],
'distance_from'
=>
$validated
[
'distance_from'
],
'distance_to'
=>
$validated
[
'distance_to'
],
'description'
=>
$validated
[
'description'
],
'total_mileage'
=>
$validated
[
'total_mileage'
],
'toll_amount'
=>
$validated
[
'toll_amount'
]
??
0
,
'others_amount'
=>
$validated
[
'others_amount'
]
??
0
,
'others_details'
=>
$validated
[
'others_details'
]
??
null
,
'updated_at'
=>
now
(),
]);
$vehicleType
=
strtolower
(
$claim
->
jenisKenderaan
->
name
??
'kereta'
);
$mileage
=
$claim
->
total_mileage
??
0
;
$rateCar1
=
0.55
;
$rateCar2
=
0.50
;
$rateMoto
=
0.30
;
if
(
in_array
(
$vehicleType
,
[
'motosikal'
,
'motorcycle'
]))
{
$mileageAmount
=
$mileage
*
$rateMoto
;
}
else
{
$firstPart
=
min
(
$mileage
,
500
);
$secondPart
=
max
(
0
,
$mileage
-
500
);
$mileageAmount
=
(
$firstPart
*
$rateCar1
)
+
(
$secondPart
*
$rateCar2
);
}
$claim
->
calculated_amount
=
$mileageAmount
+
(
$claim
->
toll_amount
??
0
)
+
(
$claim
->
others_amount
??
0
);
$claim
->
save
();
return
back
()
->
with
(
'success'
,
'Maklumat tuntutan telah berjaya dikemaskini.'
);
}
}
public
function
updateStatus
(
Request
$request
,
$id
)
public
function
semak
(
Request
$request
,
$id
)
{
{
$claim
=
Claim
::
findOrFail
(
$id
);
$this
->
repos
->
semakClaim
(
$id
,
$request
->
fin_remark
);
$action
=
$request
->
input
(
'action'
);
return
redirect
()
->
route
(
'mileage::finance.index'
)
->
with
(
'success'
,
'Permohonan berjaya disemak.'
);
if
(
!
in_array
(
$action
,
[
'Disemak'
,
'Ditolak'
,
'Dibayar'
]))
{
return
back
()
->
with
(
'error'
,
'Tindakan tidak sah.'
);
}
if
(
in_array
(
$claim
->
status
,
[
'Disemak'
,
'Ditolak'
,
'Dibayar'
]))
{
return
back
()
->
with
(
'error'
,
'Tuntutan ini telah disemak atau dimuktamadkan.'
);
}
// update status and reviewer
$claim
->
update
([
'status'
=>
$action
,
'reviewed_by'
=>
auth
()
->
id
(),
// ✅ log who reviewed the claim
]);
return
back
()
->
with
(
'success'
,
"Tuntutan telah dikemaskini kepada status
{
$action
}
."
);
}
}
public
function
export
(
Request
$request
)
public
function
bayar
(
Request
$request
,
$id
)
{
{
$month
=
$request
->
input
(
'month'
);
$this
->
repos
->
bayarClaim
(
$id
);
$userId
=
$request
->
input
(
'user_id'
);
return
redirect
()
->
route
(
'mileage::finance.index'
)
$parsedMonth
=
$month
?
Carbon
::
parse
(
$month
)
:
Carbon
::
now
();
->
with
(
'success'
,
'Bayaran berjaya diproses.'
);
$query
=
Claim
::
with
([
'user'
,
'project'
,
'approvedBy'
,
'reviewedBy'
])
->
where
(
'status'
,
'Disemak'
)
->
whereMonth
(
'claim_date'
,
$parsedMonth
->
month
)
->
whereYear
(
'claim_date'
,
$parsedMonth
->
year
)
->
orderBy
(
'claim_date'
,
'asc'
);
if
(
!
empty
(
$userId
))
{
$query
->
where
(
'user_id'
,
$userId
);
}
$claims
=
Claim
::
with
([
'user'
,
'project'
,
'approvedBy'
,
'reviewedBy'
])
->
whereMonth
(
'claim_date'
,
$parsedMonth
->
month
)
->
whereYear
(
'claim_date'
,
$parsedMonth
->
year
)
->
where
(
'status'
,
'Disemak'
)
->
get
();
$user
=
$claims
->
first
()
->
user
??
null
;
if
(
$claims
->
isEmpty
())
{
return
back
()
->
with
(
'error'
,
'Tiada tuntutan dijumpai untuk bulan ini.'
);
}
$fileName
=
!
empty
(
$userId
)
?
'Laporan_Tuntutan_'
.
str_replace
(
' '
,
'_'
,
$user
->
name
)
.
'_'
.
$parsedMonth
->
format
(
'm-Y'
)
.
'.xlsx'
:
'Laporan_Tuntutan_Semua_Staf_'
.
$parsedMonth
->
format
(
'm-Y'
)
.
'.xlsx'
;
$excelData
=
Excel
::
raw
(
new
ClaimsExport
(
$user
,
$claims
),
\Maatwebsite\Excel\Excel
::
XLSX
);
return
new
StreamedResponse
(
function
()
use
(
$excelData
)
{
echo
$excelData
;
},
200
,
[
'Content-Type'
=>
'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
,
'Content-Disposition'
=>
'inline; filename="'
.
$fileName
.
'"'
,
]
);
}
}
}
}
packages/portal/mileage/src/Model/MileageClaimFinance.php
0 → 100644
View file @
0d252112
<?php
namespace
Portal\Mileage\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
App\Models\User
;
class
MileageClaimFinance
extends
Model
{
protected
$table
=
'mileage_claim_finance'
;
protected
$fillable
=
[
'fk_mileage_claim_main'
,
'fin_original_amount'
,
'fin_penalty_rate'
,
'fin_penalty_amount'
,
'fin_amendment_remark'
,
'fin_final_amount'
,
'fin_processed_by'
,
'fin_processed_date'
,
];
public
function
claim
()
{
return
$this
->
belongsTo
(
MileageClaimMain
::
class
,
'fk_mileage_claim_main'
);
}
public
function
processedBy
()
{
return
$this
->
belongsTo
(
User
::
class
,
'fin_processed_by'
);
}
}
packages/portal/mileage/src/Model/MileageClaimMain.php
View file @
0d252112
...
@@ -5,6 +5,7 @@
...
@@ -5,6 +5,7 @@
use
App\Models\User
;
use
App\Models\User
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Portal\Mileage\Model\AuditQuery
;
use
Portal\Mileage\Model\AuditQuery
;
use
Portal\Mileage\Model\MileageClaimFinance
;
class
MileageClaimMain
extends
Model
class
MileageClaimMain
extends
Model
{
{
...
@@ -100,5 +101,11 @@ public function attachments()
...
@@ -100,5 +101,11 @@ public function attachments()
return
$this
->
hasMany
(
MileageClaimAttachment
::
class
,
'fk_main'
);
return
$this
->
hasMany
(
MileageClaimAttachment
::
class
,
'fk_main'
);
}
}
public
function
financeDetail
()
{
return
$this
->
hasOne
(
MileageClaimFinance
::
class
,
'fk_mileage_claim_main'
);
}
}
}
packages/portal/mileage/src/ServiceProvider.php
View file @
0d252112
...
@@ -88,8 +88,8 @@ protected function menu()
...
@@ -88,8 +88,8 @@ protected function menu()
$menu
=
$menus
->
add
(
__
(
'Senarai Permohonan'
))
->
data
(
'icon'
,
'align justify'
);
$menu
=
$menus
->
add
(
__
(
'Senarai Permohonan'
))
->
data
(
'icon'
,
'align justify'
);
$menu
->
add
(
__
(
'Senarai Permohonan Mileage Claim'
),
route
(
'mileage::mileage.listmileage'
))
$menu
->
add
(
__
(
'Senarai Permohonan Mileage Claim'
),
route
(
'mileage::mileage.listmileage'
))
->
data
(
'icon'
,
'bars'
)
->
data
(
'icon'
,
'bars'
)
->
active
(
'mileage/*'
)
;
->
active
(
'mileage/*'
)
->
data
(
'permission'
,
Permission
::
STAFF
);
// $menu->add(__('Project Manager Dashboard'), route('mileage::projectManager.index'))
// $menu->add(__('Project Manager Dashboard'), route('mileage::projectManager.index'))
// ->data('icon', 'briefcase')
// ->data('icon', 'briefcase')
...
@@ -127,10 +127,10 @@ protected function menu()
...
@@ -127,10 +127,10 @@ protected function menu()
// ->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'
)
//
->active('finance/*')
->
active
(
'finance/*'
)
//
->data('permission', Permission::FINANCE);
->
data
(
'permission'
,
Permission
::
FINANCE
);
// $menu = $menus->add(__('Borang Permohonan Mileage Claim'))->data('icon', 'align justify');
// $menu = $menus->add(__('Borang Permohonan Mileage Claim'))->data('icon', 'align justify');
...
...
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