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'
)
@
section
(
'content'
)
<style>
body
{
background-color
:
#f0f2f5
;
}
.ui.container
{
max-width
:
100%
!important
;
overflow-x
:
hidden
;
padding
:
0
5rem
0
2rem
;
box-sizing
:
border-box
;
margin-top
:
3rem
;
}
h2
.ui.header
{
font-size
:
1.8rem
;
font-weight
:
700
;
color
:
#1b1c1d
;
margin-bottom
:
0.5rem
;
}
h3
.ui.dividing.header
{
font-size
:
1.3rem
;
font-weight
:
600
;
color
:
#444
;
margin-top
:
0.5rem
;
margin-bottom
:
1.5rem
;
border-bottom
:
2px
solid
#ddd
;
padding-bottom
:
0.5rem
;
}
.ui.statistics
{
display
:
flex
!important
;
justify-content
:
space-between
;
align-items
:
stretch
;
flex-wrap
:
nowrap
;
gap
:
1.5rem
;
margin-top
:
2rem
;
margin-bottom
:
2rem
;
}
.ui.statistic
{
flex
:
1
;
background
:
white
;
border-radius
:
10px
;
box-shadow
:
0
4px
6px
rgba
(
0
,
0
,
0
,
0.1
);
padding
:
1.5rem
;
text-align
:
center
;
transition
:
transform
0.2s
ease-in-out
;
}
.ui.statistic
:hover
{
transform
:
translateY
(
-4px
);
}
.ui.statistic
.value
{
font-size
:
2rem
;
font-weight
:
bold
;
color
:
#2185d0
;
}
.ui.statistic
.label
{
font-size
:
1rem
;
color
:
#555
;
margin-top
:
0.3rem
;
}
/* Filter bar (aligned right side of header) */
.header-with-filter
{
display
:
flex
;
justify-content
:
space-between
;
align-items
:
center
;
margin-bottom
:
1.2rem
;
}
.filter-bar
{
display
:
flex
;
align-items
:
center
;
gap
:
1rem
;
background
:
white
;
border-radius
:
8px
;
box-shadow
:
0
3px
6px
rgba
(
0
,
0
,
0
,
0.08
);
padding
:
0.5rem
1rem
;
width
:
fit-content
;
}
.filter-bar
label
{
font-weight
:
600
;
color
:
#333
;
margin-right
:
0.5rem
;
}
.filter-bar
input
[
type
=
"month"
]
{
border
:
1px
solid
#dcdcdc
;
border-radius
:
6px
;
padding
:
0.4rem
0.6rem
;
font-size
:
1rem
;
color
:
#333
;
transition
:
all
0.2s
ease
;
}
.filter-bar
input
[
type
=
"month"
]
:focus
{
border-color
:
#21ba45
;
outline
:
none
;
box-shadow
:
0
0
0
2px
rgba
(
33
,
186
,
69
,
0.15
);
}
.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>
<
div
class
="
ui
segment
">
<a class="
ui
teal
left
ribbon
label
">Finance Dashboard - Tuntutan Mileage</a><br/>
<div class="
ui
segment
">
@if(session('success'))
<div class="
ui
success
message
">{{ session('success') }}</div>
@endif
@if(session('error'))
<div class="
ui
error
message
">{{ session('error') }}</div>
@endif
@php
$bulan
= [
1=>'Januari', 2=>'Februari', 3=>'Mac', 4=>'April',
5=>'Mei', 6=>'Jun', 7=>'Julai', 8=>'Ogos',
9=>'September', 10=>'Oktober', 11=>'November', 12=>'Disember'
];
$currentYear
= \Carbon\Carbon::now()->year;
$statusOptions
= [
9 => 'Diluluskan BOD',
11 => 'Disemak',
];
@endphp
{{-- Filter --}}
<form method="
GET
" action="
{{
route
(
'mileage::finance.index'
)
}}
" class="
ui
form
" style="
margin
-
bottom
:
1
rem
;
">
<div class="
four
fields
">
<div class="
field
">
<label>Tahun</label>
<select name="
tahun
" class="
ui
dropdown
">
<option value="">Semua Tahun</option>
@for(
$y
=
$currentYear
;
$y
>=
$currentYear
- 4;
$y
--)
<option value="
{{
$y
}}
" {{ request('tahun') ==
$y
? 'selected' : '' }}>{{
$y
}}</option>
@endfor
</select>
</div>
<div class="
field
">
<label>Bulan</label>
<select name="
bulan
" class="
ui
dropdown
">
<option value="">Semua Bulan</option>
@foreach(
$bulan
as
$num
=>
$nama
)
<option value="
{{
$num
}}
" {{ request('bulan') ==
$num
? 'selected' : '' }}>{{
$nama
}}</option>
@endforeach
</select>
</div>
<div class="
field
">
<label>Status</label>
<select name="
status
" class="
ui
dropdown
">
<option value="">Semua Status</option>
@foreach(
$statusOptions
as
$val
=>
$label
)
<option value="
{{
$val
}}
" {{ request('status') ==
$val
? 'selected' : '' }}>{{
$label
}}</option>
@endforeach
</select>
</div>
<div class="
field
">
<label>Cari</label>
<input type="
text
" name="
search
" value="
{{
request
(
'search'
)
}}
" placeholder="
No
.
permohonan
/
nama
pemohon
">
</div>
</div>
<div style="
text
-
align
:
right
;
">
@if(request()->hasAny(['tahun', 'bulan', 'status', 'search']))
<a href="
{{
route
(
'mileage::finance.index'
)
}}
" class="
ui
button
">Reset</a>
@endif
<button type="
submit
" class="
ui
teal
button
"><i class="
search
icon
"></i> Cari</button>
</div>
</form>
</div>
{{-- Staff Summary Table --}}
<table
class=
"ui celled table"
>
<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)
{{-- Table --}}
<table class="
ui
celled
table
">
<thead>
<tr>
<t
d>
{{ $user['name'] }}
</td
>
<t
d>
{{ $user['total_claims'] }}
</td
>
<t
d>
RM {{ number_format($user['total_amount'], 2) }}
</td
>
<t
d
>
<a
href=
"{{ route('mileage::finance.show', ['userId' => $user['id'], 'month' => $month]) }}"
class=
"ui blue button tiny"
>
Lihat
</a
>
<
/td
>
<t
h>No</th
>
<t
h>No. Permohonan</th
>
<t
h>Nama Pemohon</th
>
<t
h>Bulan Tuntutan</th
>
<th>Tarikh Hantar</th>
<th>Status</th
>
<
th>Tindakan</th
>
</tr>
@empty
<tr>
<td
colspan=
"4"
class=
"center aligned"
>
Tiada tuntutan untuk bulan ini.
</td>
</tr>
@endforelse
</tbody>
</table>
</div>
</thead>
<tbody>
@forelse(
$list
as
$index
=>
$claim
)
@php
$refId
=
$claim->lkpStatus
?->ref_id ?? 0;
$color
= match(
$refId
) {
9 => 'teal',
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>
{{-- JS --}}
<script>
document
.
getElementById
(
'openExportModal'
).
addEventListener
(
'click'
,
function
()
{
$
(
'#exportModal'
).
modal
(
'show'
);
});
@endsection
document
.
getElementById
(
'cancelExport'
).
addEventListener
(
'click'
,
function
()
{
$
(
'#exportModal'
).
modal
(
'hide'
);
});
@push('script')
<script>
$(document).ready(function () {
$('.ui.dropdown').dropdown();
});
</script>
@end
section
@end
push
packages/portal/mileage/resources/views/finance/show.blade.php
View file @
0d252112
<title>
Butiran Tuntutan Staf
</title>
@
extends
(
'ui::layouts.app'
)
@
section
(
'content'
)
<style>
body
{
background-color
:
#f0f2f5
;
}
.ui.container
{
padding
:
0
5rem
3rem
2rem
;
margin-top
:
3rem
;
}
h2
.ui.header
{
font-size
:
1.8rem
;
font-weight
:
700
;
margin-bottom
:
.5rem
;
}
.ui.table
{
background
:
white
;
border-radius
:
10px
;
box-shadow
:
0
4px
6px
rgba
(
0
,
0
,
0
,
0.1
);
}
.ui.segment
{
background
:
white
;
border-radius
:
10px
;
box-shadow
:
0
4px
6px
rgba
(
0
,
0
,
0
,
0.1
);
margin-top
:
2rem
;
padding
:
1.5rem
;
}
.ui.button
{
margin-top
:
1rem
;
}
/* --- Larger, more comfortable action buttons --- */
.actions-group
.ui.button.tiny
{
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
;
}
<
div
class
="
ui
segment
">
<a class="
ui
teal
left
ribbon
label
">Semakan Permohonan (Finance) - {{
$claim->mm_apply_no
}}</a><br/><br/>
/* Hover effect for better feedback */
.actions-group
.ui.button.tiny
:hover
{
transform
:
translateY
(
-2px
);
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>
@if(session('success'))
<div class="
ui
success
message
">{{ session('success') }}</div>
@endif
{{-- Claims Table --}}
<table
class=
"ui celled table"
>
<thead>
{{-- Maklumat Permohonan --}}
<div class="
ui
segment
">
<h3 class="
ui
header
">Maklumat Permohonan</h3>
<table class="
ui
definition
table
">
<tr>
<th>
#
</th>
{{-- new column for numbering --}}
<th>
Tarikh
</th>
<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>
<td>No. Permohonan</td>
<td>{{
$claim->mm_apply_no
}}</td>
</tr>
</thead>
<tbody>
@php
use Carbon\Carbon;
// Sort claims by ascending date
$claims = $claims->sortBy(fn($c) => Carbon::parse($c->claim_date));
// Step 1: Non-rejected claims
$validClaims = $claims->where('status', '!=', 'Ditolak');
// Step 2: Restrict to claims within the displayed month
$monthStart = Carbon::parse($month)->startOfMonth();
$monthEnd = Carbon::parse($month)->endOfMonth();
$validInMonth = $validClaims->filter(function($c) use ($monthStart, $monthEnd) {
if (empty($c->claim_date)) return false;
try {
$d = Carbon::parse($c->claim_date);
} catch (\Exception $e) {
return false;
}
return $d->between($monthStart, $monthEnd);
});
// Step 3: Count unique calendar days (YYYY-MM-DD)
$uniqueDays = $validInMonth
->pluck('claim_date')
->map(fn($d) => Carbon::parse($d)->toDateString())
->unique()
->count();
// Step 4: Compute base totals
$total = 0;
$totalMileage = $validInMonth->sum('total_mileage');
$totalToll = $validInMonth->sum('toll_amount');
$totalOthers = $validInMonth->sum('others_amount');
// Step 5: Deduction
$deduction = 40 * $uniqueDays;
// === Calculate mileageAmount BEFORE the table ===
$rateCar1 = 0.55; $rateCar2 = 0.50; $rateMoto = 0.30;
$mileageAmount = 0;
$vehicleGroups = [];
$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 }}
<tr>
<td>Nama Pemohon</td>
<td>{{
$claim->mm_staff_name
?? '-' }}</td>
</tr>
<tr>
<td>Kategori FA</td>
<td>{{
$claim->faCategory
?->fa_category ?? '-' }}</td>
</tr>
<tr>
<td>Bulan Tuntutan</td>
<td>
@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
{{ (
$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>
@php
$refId
=
$claim->lkpStatus
?->ref_id ?? 0;
$color
= match(
$refId
) {
9 => 'teal',
11 => 'violet',
12 => 'green',
default => 'grey',
};
@endphp
<span class="
ui
{{
$color
}}
label
">{{
$claim->lkpStatus
?->description ?? '-' }}</span>
</td>
</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
$rowTotal = 0;
$claimableKM = 0;
$vehicle = strtolower($claim->jenisKenderaan->name ?? 'kereta');
if ($claim->status !== 'Ditolak') {
$claimableKM = $claim->total_mileage ?? 0;
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);
}
$grandAnggaran
= 0;
$grandTol
= 0;
$grandParking
= 0;
$sortedDetails
=
$claim->details
->sortBy('md_claim_date')->values();
$dateCounts
= [];
foreach (
$sortedDetails
as
$d
) {
$dk
=
$d->md_claim_date
;
$dateCounts[$dk]
= (
$dateCounts[$dk]
?? 0) + 1;
}
$dateFirstSeen
= [];
$cumulativeKmByDate
= [];
@endphp
<tr>
<td>
{{ $loop->iteration }}
</td>
<td>
{{ \Carbon\Carbon::parse($claim->claim_date)->format('d/m/Y') }}
</td>
<td>
{{ $claim->description ?? '-' }}
</td>
<td>
{{ ucfirst($vehicle) }}
</td>
<td>
{{ $claim->distance_from ?? '-' }}
</td>
<td>
{{ $claim->distance_to ?? '-' }}
</td>
<td>
{{ number_format($claim->total_mileage, 1) }}
</td>
<td>
{{ number_format($claim->toll_amount ?? 0, 2) }}
</td>
<td>
{{ number_format($claim->others_amount ?? 0, 2) }}
</td>
<td>
{{ $claim->status !== 'Ditolak'
? 'RM ' . number_format($rowTotal, 2)
: '- (Tuntutan Ditolak)' }}
</td>
<td><span
class=
"status-label status-{{ $claim->status }}"
>
{{ $claim->status }}
</span></td>
<td>
<div
class=
"actions-group"
>
{{-- Lihat (View) button - always visible --}}
<a
href=
"{{ route('mileage::finance.viewEach', $claim->id) }}"
class=
"ui blue button tiny"
title=
"Lihat Butiran"
>
<i
class=
"eye icon"
></i>
Lihat
</a>
@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;
$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
;
$jumlahTol
= (float)
$detail->md_total_toll
;
$jumlahParking
= (float)
$detail->md_total_parking_fee
;
$anggaranTuntutan
=
$mileageAmount
+
$jumlahTol
+
$jumlahParking
;
$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="
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 --}}
@if(in_array($claim->status, ['Diproses', 'Disokong', 'Disahkan']))
<button
class=
"ui yellow button tiny edit-btn"
data-id=
"{{ $claim->id }}"
data-date=
"{{ $claim->claim_date }}"
data-description=
"{{ $claim->description }}"
data-distance-from=
"{{ $claim->distance_from }}"
data-distance-to=
"{{ $claim->distance_to }}"
data-mileage=
"{{ $claim->total_mileage }}"
data-toll=
"{{ $claim->toll_amount }}"
data-others=
"{{ $claim->others_amount }}"
data-others-details=
"{{ $claim->others_details }}"
>
<i
class=
"edit icon"
></i>
Kemaskini
</button>
@endif
{{-- Lampiran --}}
<div class="
ui
segment
">
<h3 class="
ui
header
">Lampiran / Bukti Transaksi</h3>
@if(
$claim->attachments
->count() > 0)
<table class="
ui
celled
table
">
<thead>
<tr><th>No</th><th>Nama Fail</th></tr>
</thead>
<tbody>
@foreach(
$claim->attachments
as
$index
=>
$file
)
<tr>
<td>{{
$index
+ 1 }}</td>
<td>
<a href="
{{
asset
(
'storage/'
.
$file
->
file_path
)
}}
" target="
_blank
">
<i class="
file
icon
"></i> {{
$file->file_name
}}
</a>
</td>
</tr>
@endforeach
</tbody>
</table>
@else
<p class="
ui
grey
text
">Tiada lampiran.</p>
@endif
</div>
{{-- Show Semak/Tolak buttons only if claim is not final --}}
@if(!in_array($claim->status, ['Disemak', 'Ditolak', 'Dibayar']))
<form
action=
"{{ route('mileage::finance.updateStatus', $claim->id) }}"
method=
"POST"
class=
"inline-form"
>
@csrf
@method('PUT')
{{-- Perbandingan Pindaan (only if Finance has amended) --}}
@php
$hasAmendment
=
$claim->details
->contains(fn(
$d
) =>
$d->md_original_mileage
!== null);
@endphp
@if(in_array($claim->status, ['Disahkan', 'Disokong', 'Diproses']))
<button
type=
"submit"
name=
"action"
value=
"Disemak"
class=
"ui green button tiny"
>
<i
class=
"check icon"
></i>
Semak
</button>
@endif
@if(
$hasAmendment
)
@php
// Recalculate original grand total using original values + same tiered logic
$origDateFirstSeen
= [];
$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"
>
<i
class=
"times icon"
></i>
Tolak
</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>
$diffAnggaran
=
$grandAnggaran
-
$origGrandAnggaran
;
@endphp
@empty
<tr>
<td
colspan=
"11"
class=
"center aligned"
>
Tiada tuntutan untuk bulan ini.
</td>
</tr>
@endforelse
<div class="
ui
segment
">
<h3 class="
ui
header
">Perbandingan Pindaan Butiran</h3>
<table class="
ui
celled
table
">
<thead>
<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)
<tr
class=
"totals-row"
>
<td
colspan=
"6"
style=
"text-align:right;"
><strong>
Jumlah Keseluruhan
</strong></td>
<td><strong>
{{ number_format($totalMileage, 1) }} KM
</strong></td>
<td><strong>
RM {{ number_format($totalToll, 2) }}
</strong></td>
<td><strong>
RM {{ number_format($totalOthers, 2) }}
</strong></td>
<td
colspan=
"2"
><strong>
RM {{ number_format($mileageAmount, 2) }}
</strong></td>
{{-- Jumlah Keseluruhan Summary --}}
<table class="
ui
definition
table
" style="
margin
-
top
:
0.5
rem
;
">
<tr>
<td>Jumlah Anggaran Asal</td>
<td class="
right
aligned
">RM {{ number_format(
$origGrandAnggaran
, 2) }}</td>
</tr>
@endif
</tbody>
</table>
<tr>
<td><strong>Jumlah Anggaran Selepas Pindaan</strong></td>
<td class="
right
aligned
"><strong>RM {{ number_format(
$grandAnggaran
, 2) }}</strong></td>
</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 --}}
@if($claims->count() > 0)
@php
// Use already filtered valid claims
&
computed uniqueDays
$claimableDistance = max(0, $totalMileage - $deduction);
<p style="
color
:
grey
;
font
-
size
:
0.9
em
;
margin
-
top
:
0.5
rem
;
">
<i class="
info
circle
icon
"></i> Baris yang berwarna kuning menunjukkan butiran yang telah dipinda oleh Kewangan.
</p>
</div>
@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'])) {
$typeAmount = $typeClaimable * $rateMoto;
$vehicleGroups[] = [
'type' => ucfirst($type),
'details' => "{$typeClaimable} km × RM{$rateMoto}",
'amount' => $typeAmount
];
{{-- Penalty Preview (status 9 only) --}}
@if(
$claim->status
== 9)
@php
$earliestDate
=
$claim->details
->min('md_claim_date');
$submitDate
=
$claim->mm_submit_date
?? now();
$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 {
$firstPart = min($typeClaimable, 500);
$secondPart = max(0, $typeClaimable - 500);
$typeAmount = ($firstPart * $rateCar1) + ($secondPart * $rateCar2);
$vehicleGroups[] = [
'type' => ucfirst($type),
'details' => "{$firstPart} km × RM{$rateCar1}" .
($secondPart > 0 ? " + {$secondPart} km × RM{$rateCar2}" : ""),
'amount' => $typeAmount
];
$previewRate
= null;
$previewLabel
= 'Lewat hantar > 180 hari (Tertakluk BOD)';
}
$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;
}
// === Subtotal ===
$subtotal = $mileageAmount + $totalToll + $totalOthers;
// === Penalty ===
$finalTotal = $subtotal - $totalPenalty;
@endphp
{{-- Finance Detail (status 11 or 12) --}}
@if(
$claim->financeDetail
)
<div class="
ui
segment
">
<h3 class="
ui
header
">Pelarasan 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 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"
>
<h4><i
class=
"calculator icon"
></i>
Ringkasan Pengiraan Bulanan
</h4>
<table
class=
"ui definition table"
>
<tr><td>
Jumlah Perbatuan (Sebenar)
</td><td>
{{ number_format($totalMileage,1) }} KM
</td></tr>
<tr><td>
Hari Tuntutan
</td><td>
{{ $uniqueDays }} hari
</td></tr>
<tr><td>
Potongan 40 KM/Hari
</td><td>
{{ $uniqueDays }} × 40 = {{ $deduction }} KM
</td></tr>
<tr>
<td>
Jumlah Layak Tuntut
</td>
<td>
{{ number_format($totalMileage,1) }} KM − {{ number_format($deduction,1) }} KM
=
<strong>
{{ number_format($claimableDistance,1) }} KM
</strong>
</td>
</tr>
<tr>
<td>
Kadar Kiraan
</td>
<td>
@foreach($vehicleGroups as $v)
• {{ ucfirst($v['type']) }}: {!! $v['details'] !!} =
<strong>
RM {{ number_format($v['amount'],2) }}
</strong><br>
{{-- Sejarah Kuiri --}}
@if(
$claim->auditQueries
->count() > 0)
<div class="
ui
segment
">
<h3 class="
ui
header
">Sejarah Kuiri</h3>
<table class="
ui
celled
table
">
<thead>
<tr>
<th>Bil</th>
<th>Jenis</th>
<th>Catatan</th>
<th>Respons Pemohon</th>
<th>Tarikh</th>
</tr>
</thead>
<tbody>
@foreach(
$claim->auditQueries
as
$index
=>
$q
)
<tr>
<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
</td>
</tr>
<tr><td>
Jumlah Perbatuan (RM)
</td><td>
RM {{ number_format($mileageAmount,2) }}
</td></tr>
<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>
</tbody>
</table>
</div>
@endif
{{-- Edit Modal --}}
<div
class=
"ui modal"
id=
"editModal"
>
<i
class=
"close icon"
></i>
<div
class=
"header"
>
Kemaskini Tuntutan
</div>
<div
class=
"content"
>
<form
id=
"editForm"
method=
"POST"
action=
""
>
{{-- Tindakan Finance --}}
@if(
$claim->status
== 9)
<div class="
ui
segment
">
<h3 class="
ui
header
">Tindakan Kewangan</h3>
<form id="
formSemak
" action="
{{
route
(
'mileage::finance.semak'
,
$claim
->
id
)
}}
" method="
POST
">
@csrf
@method('PUT')
<div class="
ui
form
">
<div
class=
"field required"
>
<label>
Tarikh
</label>
<input
type=
"date"
name=
"claim_date"
id=
"editDate"
required
>
</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 class="
field
">
<label>Catatan Pindaan <span style="
color
:
grey
;
font
-
weight
:
normal
;
">(jika ada)</span></label>
<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>
<br>
</form>
</div>
<div
class=
"actions"
>
<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'
);
@endif
$
(
'#editModal'
).
modal
(
'show'
);
});
// === Show/Hide "Butiran Lain-lain" based on input ===
$
(
'#editOthers'
).
on
(
'input'
,
function
()
{
const
value
=
parseFloat
(
$
(
this
).
val
())
||
0
;
if
(
value
>
0
)
{
$
(
'#othersDetailsField'
).
slideDown
();
$
(
'#editOthersDetails'
).
attr
(
'required'
,
true
);
}
else
{
$
(
'#othersDetailsField'
).
slideUp
();
$
(
'#editOthersDetails'
).
removeAttr
(
'required'
).
val
(
''
);
}
});
{{-- Buttons --}}
<div style="
text
-
align
:
right
;
">
<a href="
{{
route
(
'mileage::finance.index'
)
}}
" class="
ui
button
">
<i class="
arrow
left
icon
"></i> Kembali
</a>
@if(
$claim->status
== 9)
<a href="
{{
route
(
'mileage::finance.edit'
,
$claim
->
id
)
}}
" class="
ui
orange
button
">
<i class="
edit
icon
"></i> Kemaskini Butiran
</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 ===
$
(
'#editForm'
).
on
(
'submit'
,
function
(
e
)
{
const
others
=
parseFloat
(
$
(
'#editOthers'
).
val
())
||
0
;
const
othersDetails
=
$
(
'#editOthersDetails'
).
val
().
trim
();
<br><br>
</div>
if
(
others
>
0
&&
othersDetails
===
''
)
{
e
.
preventDefault
();
alert
(
'Sila isi Butiran Lain-lain kerana jumlah Lain-lain (RM) lebih daripada 0.'
);
$
(
'#editOthersDetails'
).
focus
();
return
;
}
@endsection
let
valid
=
true
;
$
(
'#editForm [required]'
).
each
(
function
()
{
if
(
$
(
this
).
val
().
trim
()
===
''
)
{
valid
=
false
;
alert
(
'Sila isi semua ruangan yang diperlukan.'
);
$
(
this
).
focus
();
e
.
preventDefault
();
return
false
;
}
});
});
@push('script')
<script>
$(document).ready(function () {
$('#modalAnggaran').modal({ closable: true });
});
</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 @@
6, 8, 10 => 'orange',
7 => 'teal',
9 => 'green',
11 => 'violet',
12 => 'green',
default => 'grey',
};
@endphp
...
...
@@ -182,6 +184,8 @@
</table>
</div>
{{-- Segment 2: Tambah / Kemaskini butiran (Draf only) --}}
@if(
$claim->status
== 1)
...
...
@@ -336,6 +340,57 @@
@endif
</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 --}}
<div class="
ui
small
modal
" id="
modalAnggaran
">
<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 @@
$refId
=
$row->lkpStatus
?->ref_id ?? 0;
$color
= match(
$refId
) {
1 => 'grey',
2 => 'blue',
3 => 'yellow',
4 => 'red',
5 => 'olive',
1
=> 'grey',
2
=> 'blue',
3
=> 'yellow',
4
=> 'red',
5
=> 'olive',
6, 8, 10 => 'orange',
7 => 'teal',
9 => 'green',
default => 'grey',
7 => 'teal',
9 => 'green',
11 => 'violet',
12 => 'green',
default => 'grey',
};
return '<span class="
ui
' . $color . '
label
">' .
$status
. '</span>';
}],
...
...
@@ -113,6 +116,11 @@
Permohonan Baharu
</div>
<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
">
@csrf
...
...
@@ -154,9 +162,9 @@
</div>
<div class="
actions
">
<div class="
ui
black
deny
button
">Batal</div>
<div class="
ui
primary
approve
button
"
onclick="
document
.
getElementById
(
'formPermohonanBaharu'
)
.
submit
()
"
>
Seterusnya
</div>
<div class="
ui
primary
approve
button
">
Seterusnya
</div>
</div>
</div>
...
...
@@ -166,7 +174,23 @@
<script>
$(document).ready(function () {
$('.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
);
...
...
@@ -217,6 +241,21 @@ function updateMonthOptions(year) {
// Run immediately for the pre-selected current 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>
@endpush
...
...
packages/portal/mileage/routes/web.php
View file @
0d252112
...
...
@@ -55,19 +55,17 @@ function () {
Route
::
post
(
'/claim/{id}/reject'
,
[
ProjectDirectorController
::
class
,
'rejectClaim'
])
->
name
(
'.rejectClaim'
);
});
// Finance
Department
// Finance
Route
::
prefix
(
'finance'
)
->
name
(
'finance'
)
->
group
(
function
()
{
Route
::
get
(
'/dashboard'
,
[
FinanceController
::
class
,
'index'
])
->
name
(
'.index'
);
Route
::
get
(
'/show/{userId}'
,
[
FinanceController
::
class
,
'show'
])
->
name
(
'.show'
);
Route
::
put
(
'/finance/update/{id}'
,
[
FinanceController
::
class
,
'update'
])
->
name
(
'.update'
);
Route
::
get
(
'/view/claim/{id}'
,
[
FinanceController
::
class
,
'viewEach'
])
->
name
(
'.viewEach'
);
Route
::
put
(
'/finance/claims/{id}/update-status'
,
[
FinanceController
::
class
,
'updateStatus'
])
->
name
(
'.updateStatus'
);
// Route::post('/{id}/review', [FinanceController::class, 'review'])->name('.review');
// Route::post('/{id}/reject', [FinanceController::class, 'reject'])->name('.reject');
Route
::
get
(
'/export'
,
[
FinanceController
::
class
,
'export'
])
->
name
(
'.export'
);
Route
::
get
(
'/show/{id}'
,
[
FinanceController
::
class
,
'show'
])
->
name
(
'.show'
);
Route
::
get
(
'/{id}/edit'
,
[
FinanceController
::
class
,
'edit'
])
->
name
(
'.edit'
);
Route
::
put
(
'/{id}/update'
,
[
FinanceController
::
class
,
'update'
])
->
name
(
'.update'
);
Route
::
post
(
'/{id}/semak'
,
[
FinanceController
::
class
,
'semak'
])
->
name
(
'.semak'
);
// Route::post('/{id}/bayar', [FinanceController::class, 'bayar'])->name('.bayar');
});
// HOD
Route
::
prefix
(
'HOD'
)
->
name
(
'HOD'
)
->
group
(
function
()
{
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)
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 @@
namespace
Portal\Mileage\Http\Controllers
;
use
Portal\Mileage\Model\Users
;
use
Portal\Mileage\Model\Claim
;
use
App\Http\Controllers\Controller
;
use
Illuminate\Routing\Controller
;
use
Illuminate\Http\Request
;
use
Carbon\Carbon
;
use
Maatwebsite\Excel\Facades\Excel
;
use
Symfony\Component\HttpFoundation\StreamedResponse
;
use
Portal\Mileage\Exports\ClaimsExport
;
use
Portal\Mileage\Data\Repo\FinanceRepo
;
class
FinanceController
extends
Controller
{
public
function
index
(
Request
$request
)
{
$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
();
protected
$repos
;
return
view
(
'mileage::finance.index'
,
compact
(
'users'
,
'summary'
,
'month'
));
public
function
__construct
(
FinanceRepo
$repos
)
{
$this
->
repos
=
$repos
;
}
public
function
show
(
$userId
,
Request
$request
)
{
$month
=
$request
->
get
(
'month'
,
Carbon
::
now
()
->
format
(
'Y-m'
));
$parsedMonth
=
Carbon
::
parse
(
$month
);
$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
,
];
public
function
index
(
Request
$request
)
{
$list
=
$this
->
repos
->
getFinanceList
(
$request
);
return
view
(
'mileage::finance.index'
,
compact
(
'list'
));
}
return
view
(
'mileage::finance.show'
,
compact
(
'user'
,
'claims'
,
'month'
,
'totalPenalty'
,
'isBOD'
,
'penaltyBreakdown'
));
}
public
function
show
(
$id
)
{
$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
);
return
view
(
'mileage::finance.
view
'
,
compact
(
'claim'
));
$claim
=
$this
->
repos
->
findClaim
(
$id
);
return
view
(
'mileage::finance.
edit
'
,
compact
(
'claim'
));
}
public
function
update
(
Request
$request
,
$id
)
{
$claim
=
Claim
::
findOrFail
(
$id
);
$validated
=
$request
->
validate
([
'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.'
);
$this
->
repos
->
editClaim
(
$id
,
$request
->
input
(
'details'
,
[]));
return
redirect
()
->
route
(
'mileage::finance.show'
,
$id
)
->
with
(
'success'
,
'Pindaan butiran berjaya disimpan. Sila semak semula butiran di bawah dan tekan Semak untuk meneruskan.'
);
}
public
function
updateStatus
(
Request
$request
,
$id
)
public
function
semak
(
Request
$request
,
$id
)
{
$claim
=
Claim
::
findOrFail
(
$id
);
$action
=
$request
->
input
(
'action'
);
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
}
."
);
$this
->
repos
->
semakClaim
(
$id
,
$request
->
fin_remark
);
return
redirect
()
->
route
(
'mileage::finance.index'
)
->
with
(
'success'
,
'Permohonan berjaya disemak.'
);
}
public
function
export
(
Request
$request
)
public
function
bayar
(
Request
$request
,
$id
)
{
$month
=
$request
->
input
(
'month'
);
$userId
=
$request
->
input
(
'user_id'
);
$parsedMonth
=
$month
?
Carbon
::
parse
(
$month
)
:
Carbon
::
now
();
$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
.
'"'
,
]
);
$this
->
repos
->
bayarClaim
(
$id
);
return
redirect
()
->
route
(
'mileage::finance.index'
)
->
with
(
'success'
,
'Bayaran berjaya diproses.'
);
}
}
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 @@
use
App\Models\User
;
use
Illuminate\Database\Eloquent\Model
;
use
Portal\Mileage\Model\AuditQuery
;
use
Portal\Mileage\Model\MileageClaimFinance
;
class
MileageClaimMain
extends
Model
{
...
...
@@ -100,5 +101,11 @@ public function attachments()
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()
$menu
=
$menus
->
add
(
__
(
'Senarai Permohonan'
))
->
data
(
'icon'
,
'align justify'
);
$menu
->
add
(
__
(
'Senarai Permohonan Mileage Claim'
),
route
(
'mileage::mileage.listmileage'
))
->
data
(
'icon'
,
'bars'
)
->
active
(
'mileage/*'
)
;
->
active
(
'mileage/*'
)
->
data
(
'permission'
,
Permission
::
STAFF
);
// $menu->add(__('Project Manager Dashboard'), route('mileage::projectManager.index'))
// ->data('icon', 'briefcase')
...
...
@@ -127,10 +127,10 @@ protected function menu()
// ->active('HR/*')
// ->data('permission', Permission::HR);
//
$menu->add(__('Finance Dashboard'), route('mileage::finance.index'))
//
->data('icon', 'calculator')
//
->active('finance/*')
//
->data('permission', Permission::FINANCE);
$menu
->
add
(
__
(
'Finance Dashboard'
),
route
(
'mileage::finance.index'
))
->
data
(
'icon'
,
'calculator'
)
->
active
(
'finance/*'
)
->
data
(
'permission'
,
Permission
::
FINANCE
);
// $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