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
93a00a5e
Commit
93a00a5e
authored
Jun 26, 2026
by
Muhammad Iz'aan bin suhaimi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HOD skrin
queryform auditquery serviceprovider
parent
033376d3
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1559 additions
and
622 deletions
+1559
-622
database/migrations/2026_06_23_032334_add_hod_comment_to_mileage_claim_main_table.php
+22
-0
database/migrations/2026_06_23_065423_create_audit_query_table.php
+35
-0
database/migrations/2026_06_23_065556_add_query_status_to_mileage_claim_main.php
+32
-0
database/migrations/2026_06_23_065706_drop_mm_hod_comment_from_mileage_claim_main.php
+32
-0
database/migrations/2026_06_25_022839_create_mileage_claim_attachments_table.php
+34
-0
packages/portal/mileage/resources/views/HOD/index.blade.php
+80
-173
packages/portal/mileage/resources/views/HOD/show.blade.php
+294
-123
packages/portal/mileage/resources/views/mileage/form.blade.php
+289
-149
packages/portal/mileage/resources/views/mileage/list.blade.php
+17
-11
packages/portal/mileage/resources/views/mileage/queryForm.blade.php
+329
-0
packages/portal/mileage/routes/web.php
+8
-2
packages/portal/mileage/src/Data/Repo/HODRepo.php
+80
-0
packages/portal/mileage/src/Data/Repo/MileageRepo.php
+115
-14
packages/portal/mileage/src/Http/Controllers/HODController.php
+21
-101
packages/portal/mileage/src/Http/Controllers/MileageController.php
+60
-6
packages/portal/mileage/src/Model/AuditQuery.php
+28
-0
packages/portal/mileage/src/Model/MileageClaimAttachment.php
+21
-0
packages/portal/mileage/src/Model/MileageClaimMain.php
+14
-0
packages/portal/mileage/src/ServiceProvider.php
+41
-35
packages/portal/overtime/src/ServiceProvider.php
+7
-8
No files found.
database/migrations/2026_06_23_032334_add_hod_comment_to_mileage_claim_main_table.php
0 → 100644
View file @
93a00a5e
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
return
new
class
extends
Migration
{
public
function
up
()
{
Schema
::
table
(
'mileage_claim_main'
,
function
(
Blueprint
$table
)
{
$table
->
text
(
'mm_hod_comment'
)
->
nullable
()
->
after
(
'status'
);
});
}
public
function
down
()
{
Schema
::
table
(
'mileage_claim_main'
,
function
(
Blueprint
$table
)
{
$table
->
dropColumn
(
'mm_hod_comment'
);
});
}
};
database/migrations/2026_06_23_065423_create_audit_query_table.php
0 → 100644
View file @
93a00a5e
<?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
(
'audit_query'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
integer
(
'fk_main'
)
->
index
();
$table
->
integer
(
'user_id'
)
->
index
();
$table
->
text
(
'comment'
)
->
nullable
();
$table
->
text
(
'response'
)
->
nullable
();
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'audit_query'
);
}
};
database/migrations/2026_06_23_065556_add_query_status_to_mileage_claim_main.php
0 → 100644
View file @
93a00a5e
<?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_main'
,
function
(
Blueprint
$table
)
{
$table
->
integer
(
'query_status'
)
->
nullable
()
->
after
(
'status'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
table
(
'mileage_claim_main'
,
function
(
Blueprint
$table
)
{
$table
->
dropColumn
(
'query_status'
);
});
}
};
database/migrations/2026_06_23_065706_drop_mm_hod_comment_from_mileage_claim_main.php
0 → 100644
View file @
93a00a5e
<?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_main'
,
function
(
Blueprint
$table
)
{
$table
->
dropColumn
(
'mm_hod_comment'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
table
(
'mileage_claim_main'
,
function
(
Blueprint
$table
)
{
$table
->
text
(
'mm_hod_comment'
)
->
nullable
()
->
after
(
'query_status'
);
});
}
};
database/migrations/2026_06_25_022839_create_mileage_claim_attachments_table.php
0 → 100644
View file @
93a00a5e
<?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_attachments'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
unsignedBigInteger
(
'fk_main'
)
->
index
();
$table
->
string
(
'file_name'
);
$table
->
string
(
'file_path'
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'mileage_claim_attachments'
);
}
};
packages/portal/mileage/resources/views/HOD/index.blade.php
View file @
93a00a5e
<title>
HOD Dashboard
</title>
@
extends
(
'ui::layouts.app'
)
@
section
(
'content'
)
<style
type=
"text/css"
>
body
{
background-color
:
#f0f2f5
;
}
.ui.container
{
max-width
:
100%
!important
;
overflow-x
:
hidden
;
padding
:
0
5rem
0
2rem
;
box-sizing
:
border-box
;
}
.ui.segments
{
margin-top
:
2rem
;
}
.ui.segment
{
box-shadow
:
0
4px
6px
rgba
(
0
,
0
,
0
,
0.1
);
}
/* .ui.celled.table {
table-layout: fixed; /* ensures column widths respect CSS widths */
/* width: 100%;
}
.ui.celled.table th,
.ui.celled.table td {
word-wrap: break-word;
}
.ui.celled.table th:nth-last-child(1),
.ui.celled.table td:nth-last-child(1) {
width: 25%; /* make Tindakan column longest */
/* }
.ui.celled.table th:nth-last-child(2),
.ui.celled.table td:nth-last-child(2) {
width: 10%; /* for Status */
/* } */
@keyframes
spin
{
to
{
transform
:
rotate
(
360deg
);
}
}
#loader
{
position
:
fixed
;
top
:
0
;
left
:
0
;
width
:
100%
;
height
:
100%
;
display
:
none
;
align-items
:
center
;
justify-content
:
center
;
background
:
rgba
(
0
,
0
,
0
,
0.5
);
z-index
:
9999
;
}
#loader
div
{
margin-top
:
20%
;
margin-left
:
45%
;
width
:
60px
;
height
:
60px
;
border
:
6px
solid
#fff
;
border-top
:
6px
solid
transparent
;
border-radius
:
50%
;
animation
:
spin
1s
linear
infinite
;
}
</style>
<div
class=
"ui container mt-5"
>
<h2
class=
"ui header"
>
Head of Department Dashboard
</h2>
{{-- Pending Claims --}}
<h3
class=
"ui dividing header"
>
Pending Verification Claims
</h3>
<table
class=
"ui celled table"
>
<thead>
<tr>
<th
style =
"text-align: center; width: 40px;"
>
#
</th>
<th
style =
"width: 15%;"
>
Staff
</th>
<th>
Tarikh
</th>
<th>
Butiran Projek
</th>
<th>
Jarak Layak (KM)
</th>
<th>
Jumlah Tuntutan (RM)
</th>
<th>
Status
</th>
<th>
Tindakan
</th>
</tr>
</thead>
<tbody>
@php
$pendingClaims = $claims->where('status', 'Diproses');
@endphp
@forelse($pendingClaims as $claim)
<
div
class
="
ui
segment
">
<a class="
ui
violet
left
ribbon
label
">HOD 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
<form method="
GET
" action="
{{
route
(
'mileage::HOD.index'
)
}}
" class="
ui
form
" style="
margin
-
bottom
:
1
rem
;
">
<div class="
ui
action
input
">
<input type="
text
" name="
search
" value="
{{
request
(
'search'
)
}}
" placeholder="
Cari
no
.
permohonan
...
">
<button type="
submit
" class="
ui
violet
button
">Cari</button>
@if(request('search'))
<a href="
{{
route
(
'mileage::HOD.index'
)
}}
" class="
ui
button
">Reset</a>
@endif
</div>
</form>
<table class="
ui
celled
table
">
<thead>
<tr>
<td
style =
"text-align: center;"
>
{{ $loop->iteration }}
</td>
<td>
{{ $claim->user->name ?? '-' }}
</td>
<td>
{{ $claim->claim_date }}
@php
$days = \Carbon\Carbon::parse($claim->claim_date)->diffInDays($claim->created_at ?? now());
@endphp
@if($days > 180)
<br><span
class=
"ui red label tiny"
>
Tertakluk BOD (
>
6 bulan)
</span>
@elseif($days > 90)
<br><span
class=
"ui red label tiny"
>
Lewat 3-6 bulan (-30%)
</span>
@elseif($days > 30)
<span
class=
"ui yellow label tiny"
>
Lewat 1-3 bulan (-10%)
</span>
@endif
</td>
<td>
{{ $claim->description ?? '-' }}
</td>
<td>
{{ max(0, $claim->total_mileage - 40) }} km
</td>
<td>
RM {{ number_format($claim->total_claim_amount, 2) }}
</td>
<td>
{{ $claim->status }}
</td>
<td
style =
"white-space: nowrap; width: 1%;"
>
<a
href=
"{{ route('mileage::HOD.show', $claim->id) }}"
class=
"ui blue button tiny"
>
Lihat
</a>
<form
action=
"{{ route('mileage::HOD.verify', $claim->id) }}"
method=
"POST"
style=
"display:inline;"
>
@csrf
<button
class=
"ui green button tiny"
type=
"submit"
>
Sokong
</button>
</form>
<form
action=
"{{ route('mileage::HOD.reject', $claim->id) }}"
method=
"POST"
style=
"display:inline;"
>
@csrf
<button
class=
"ui red button tiny"
type=
"submit"
>
Tolak
</button>
</form>
</td>
</tr>
@empty
<tr>
<td
colspan=
"8"
class=
"center aligned"
>
Tiada tuntutan menunggu sokongan
</td>
<th>No</th>
<th>No. Permohonan</th>
<th>Nama Pemohon</th>
<th>Bulan</th>
<th>Tarikh Hantar</th>
<th>Status</th>
<th>Tindakan</th>
</tr>
@endforelse
</tbody>
</table>
{{-- Verified / Rejected Claims --}}
<h3
class=
"ui dividing header mt-5"
>
Previous Claims
</h3>
<table
class=
"ui celled table"
>
<thead>
<tr>
<th>
#
</th>
<th>
Staff
</th>
<th>
Tarikh
</th>
<th>
Butiran Projek
</th>
<th>
Jarak Layak (KM)
</th>
<th>
Jumlah Tuntutan (RM)
</th>
<th>
Status
</th>
<th>
Tindakan
</th>
</tr>
</thead>
<tbody>
@php
$previousClaims = $claims->whereIn('status', ['Disokong', 'Ditolak']);
@endphp
@forelse($previousClaims as $claim)
<tr>
<td>
{{ $loop->iteration }}
</td>
<td>
{{ $claim->user->name ?? '-' }}
</td>
<td>
{{ $claim->claim_date }}
</td>
<td>
{{ $claim->description ?? '-' }}
</td>
<td>
{{ max(0, $claim->total_mileage - 40) }} km
</td>
<td>
RM {{ number_format($claim->total_claim_amount, 2) }}
</td>
<td>
{{ $claim->status }}
</td>
<td>
<a
href=
"{{ route('mileage::HOD.show', $claim->id) }}"
class=
"ui blue button tiny"
>
Lihat
</a>
</td>
</tr>
@empty
<tr>
<td
colspan=
"8"
class=
"center aligned"
>
Tiada rekod tuntutan terdahulu
</td>
</tr>
@endforelse
</tbody>
</table>
</thead>
<tbody>
@forelse(
$list
as
$index
=>
$claim
)
@php
$refId
=
$claim->lkpStatus
?->ref_id ?? 0;
$color
= match(
$refId
) {
1 => 'grey',
2 => 'blue',
3 => 'yellow',
4 => 'red',
5 => 'olive',
6, 8, 10 => 'orange',
7 => 'teal',
9 => 'green',
default => 'grey',
};
$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
<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>
<div class="
ui
small
icon
buttons
">
<a href="
{{
route
(
'mileage::HOD.show'
,
$claim
->
id
)
}}
" class="
ui
blue
button
">
<i class="
eye
icon
"></i>
</a>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="
7
" class="
center
aligned
">Tiada permohonan untuk diberi tindakan.</td>
</tr>
@endforelse
</tbody>
</table>
{{
$list->withQueryString
()->links() }}
</div>
</div>
@endsection
packages/portal/mileage/resources/views/HOD/show.blade.php
View file @
93a00a5e
<title>
Maklumat Tuntutan
</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
;
}
.small-muted
{
font-size
:
.9rem
;
color
:
#666
;
}
</style>
<div
class=
"ui container"
>
<h2
class=
"ui header"
>
Maklumat Tuntutan
</h2>
<
div
class
="
ui
segment
">
<a class="
ui
violet
left
ribbon
label
">Semakan Permohonan - {{
$claim->mm_apply_no
}}</a><br/><br/>
{{-- Claim Header Info --}}
<div class="
ui
segment
">
<h3 class="
ui
header
">Maklumat Permohonan</h3>
<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>
<td>No. Permohonan</td>
<td>{{
$claim->mm_apply_no
}}</td>
</tr>
<tr>
<td>
Nama P
rojek
</td>
<td>
{{ $claim->
project->p_project_description ?? 'Tanpa Projek
' }}
</td>
<td>Nama P
emohon
</td>
<td>{{
$claim->
mm_staff_name
?? '-
' }}</td>
</tr>
<tr>
<td>
Butiran Tuntutan
</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>
<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>
Jumlah Perbatuan (KM)
</td>
<td>
{{
number_format($claim->total_mileage ?? 0, 2) }} km
</td>
<td>
Tarikh Hantar
</td>
<td>{{
$claim->mm_submit_date
? \Carbon\Carbon::parse(
$claim->mm_submit_date
)->format('d/m/Y') : '-' }}
</td>
</tr>
{{-- Claimable mileage (deduct 40km rule) --}}
<tr>
<td>
Jumlah Perbatuan Layak Dituntut
</td>
<td>
Status
</td>
<td>
@php
$totalMileage = floatval($claim->total_mileage ?? 0);
$claimable = $claim->claimable_mileage ?? max(0, $totalMileage - 40);
$refId
=
$claim->lkpStatus
?->ref_id ?? 0;
$color
= match(
$refId
) {
1 => 'grey',
2 => 'blue',
3 => 'yellow',
4 => 'red',
5 => 'olive',
6, 8, 10 => 'orange',
7 => 'teal',
9 => 'green',
default => 'grey',
};
@endphp
{{ number_format($claimable, 2) }} km
<span class="
ui
{{
$color
}}
label
">{{
$claim->lkpStatus
?->description ?? '-' }}</span>
</td>
</tr>
</table>
</div>
{{-- Show per-km rate and mileage multiplication --}}
<tr>
<td>
Kiraan (Perbatuan × Kadar)
</td>
<td>
{{-- Claim Details Table --}}
<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 Perbelanjaan (RM)
<i class="
info
circle
icon
" style="
cursor
:
pointer
;
color
:
#2185d0;"
onclick
=
"$('#modalPerbelanjaan').modal('show');"
></
i
>
</
th
>
<
th
class
="
right
aligned
">
Anggaran Tuntutan (RM)
<i class="
info
circle
icon
" style="
cursor
:
pointer
;
color
:
#2185d0;"
onclick
=
"$('#modalAnggaran').modal('show');"
></
i
>
</
th
>
</
tr
>
</
thead
>
<
tbody
>
@
php
$grandAnggaran
=
0
;
@
endphp
@
forelse
(
$claim
->
details
as
$index
=>
$detail
)
@
php
// Determine rate by vehicle
$jenisId = $claim->jenis_kenderaan_id ?? ($claim->jenisKenderaan->id ?? null);
if ($jenisId == 1) {
$rate = ($claimable
<
=
500
)
?
0
.
55
:
0
.
50
;
//
Car
}
else
{
$
rate =
0.30;
//
Motorcycle
}
$
mileageAmount =
round($claimable
*
$
rate
,
2
);
$jumlahJarak
=
(
float
)
$detail
->
md_total_mileage
;
$claimableKm
=
max
(
0
,
$jumlahJarak
-
40
);
$vehicleName
=
strtolower
(
$detail
->
jenisKenderaan
?->
name
??
''
);
$isMotosikal
=
in_array
(
$vehicleName
,
[
'motosikal'
,
'motorcycle'
]);
$rate
=
$isMotosikal
?
0.30
:
(
$claimableKm
<=
500
?
0.55
:
0.50
);
$mileageAmount
=
$claimableKm
*
$rate
;
$jumlahBelanja
=
(
float
)
$detail
->
md_total_toll
+
(
float
)
$detail
->
md_total_parking_fee
;
$anggaranTuntutan
=
$mileageAmount
+
$jumlahBelanja
;
$grandAnggaran
+=
$anggaranTuntutan
;
@
endphp
<
tr
>
<
td
>
{{
$index
+
1
}}
</
td
>
<
td
>
{{
\Carbon\Carbon
::
parse
(
$detail
->
md_claim_date
)
->
format
(
'd/m/Y'
)
}}
</
td
>
<
td
>
{{
$detail
->
jenisKenderaan
?->
name
??
'-'
}}
</
td
>
<
td
>
{{
$detail
->
project
?
$detail
->
project
->
p_project_code
.
' - '
.
$detail
->
project
->
p_project_description
:
'Tiada Projek'
}}
</
td
>
<
td
>
{{
$detail
->
md_description
}}
</
td
>
<
td
class
="
right
aligned
">{{ number_format(
$jumlahJarak
, 1) }}</td>
<td class="
right
aligned
">{{ number_format(
$jumlahBelanja
, 2) }}</td>
<td class="
right
aligned
">{{ number_format(
$anggaranTuntutan
, 2) }}</td>
</tr>
@empty
<tr>
<td colspan="
8
" class="
center
aligned
">Tiada butiran.</td>
</tr>
@endforelse
</tbody>
@if(
$claim->details
->count() > 0)
<tfoot>
<tr>
<th colspan="
7
" class="
right
aligned
">JUMLAH KESELURUHAN ANGGARAN TUNTUTAN (RM)</th>
<th class="
right
aligned
">{{ number_format(
$grandAnggaran
, 2) }}</th>
</tr>
</tfoot>
@endif
</table>
</div>
<
span
class=
"small-muted"
>
{{ number_format($claimable, 2) }} km × RM {{ number_format($rate, 2) }}
</span>
=
<strong>
RM {{ number_format($mileageAmount, 2) }}
</strong>
</td>
</tr>
{{-- Toll amount --}}
{{-- Modal: Jumlah Perbelanjaan --}}
<div class="
ui
small
modal
" id="
modalPerbelanjaan
">
<div class="
header
"><i class="
info
circle
icon
"></i> Jumlah Perbelanjaan</div>
<div class="
content
">
<table class="
ui
definition
table
">
<tr>
<td>
Tol (RM)
</td>
<td>
RM {{ number_format(floatval($claim->toll_amount ?? 0), 2) }}
</td>
<td>
Formula
</td>
<td>
Jumlah Tol + Jumlah Bayaran Letak Kereta
</td>
</tr>
</table>
</div>
<br>
</div>
{{-- Others amount --}}
{{-- Modal: Anggaran Tuntutan --}}
<div class="
ui
small
modal
" id="
modalAnggaran
">
<div class="
header
"><i class="
info
circle
icon
"></i> Formula Anggaran Tuntutan</div>
<div class="
content
">
<table class="
ui
definition
table
">
<tr>
<td>
Lain-lain (RM)
</td>
<td>
RM {{ number_format(floatval($claim->others_amount ?? 0), 2) }}
</td>
<td>
KM Tuntutan
</td>
<td>
Jumlah KM − 40 km
</td>
</tr>
{{-- Butiran Lain-lain (always shown) --}}
<tr>
<td>
Butiran Lain-lain
</td>
<td>
{{ $claim->others_description ?: 'Tiada Nilai Lain-lain' }}
</td>
<td>
Kadar Motosikal
</td>
<td>
KM Tuntutan × RM 0.30 / km
</td>
</tr>
{{-- Subtotal: mileageAmount + toll + others --}}
<tr>
<td>
Jumlah Tuntutan (Perjalanan + Tol + Lain-lain)
</td>
<td>
@php
$toll = floatval($claim->toll_amount ?? 0);
$others = floatval($claim->others_amount ?? 0);
$subtotal = round($mileageAmount + $toll + $others, 2);
@endphp
RM {{ number_format($subtotal, 2) }}
</td>
<td>Kadar Kereta (≤ 500 km)</td>
<td>KM Tuntutan × RM 0.55 / km</td>
</tr>
<tr>
<td>
Penalti
</td>
<td>
@if($claim->display_penalty_amount > 0)
<span
style=
"color:#e53935;"
>
- RM {{ number_format($claim->display_penalty_amount, 2) }}
({{ $claim->display_penalty_reason }})
</span>
@else
{{ $claim->display_penalty_reason ?? 'Tiada penalti' }}
@endif
</td>
<tr>
<td>Kadar Kereta (> 500 km)</td>
<td>KM Tuntutan × RM 0.50 / km</td>
</tr>
<tr
class=
"totals-row"
>
<td>
Jumlah Akhir (RM)
</td>
<td>
<strong>
RM {{ number_format(floatval($claim->display_total_claim_amount ?? $subtotal), 2) }}
</strong>
</td>
<tr>
<td>Anggaran Tuntutan</td>
<td>(KM Tuntutan × Kadar) + Jumlah Perbelanjaan</td>
</tr>
</table>
</div>
<br>
</div>
{{-- 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>
{{-- Query History --}}
@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>Catatan HOD</th>
<th>Respons Pemohon</th>
<th>Tarikh</th>
</tr>
</thead>
<tbody>
@foreach(
$claim->auditQueries
as
$index
=>
$q
)
<tr>
<td>{{
$index
+ 1 }}</td>
<td>{{
$q->comment
?? '-' }}</td>
<td>
@if(
$q->response
)
{{
$q->response
}}
@else
<span class="
ui
orange
label
">Belum Dijawab</span>
@endif
</td>
<td>{{ \Carbon\Carbon::parse(
$q->created_at
)->format('d/m/Y H:i') }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
{{-- Action Buttons --}}
@if(in_array(
$claim->status
, [2, 3]))
<div class="
ui
segment
">
<h3 class="
ui
header
">Tindakan HOD</h3>
<form id="
formTindakan
" method="
POST
">
@csrf
<input type="
hidden
" name="
hod_comment
" id="
hiddenComment
">
<div class="
ui
form
">
<div class="
field
">
<label>Pilih Tindakan</label>
<div class="
ui
radio
checkbox
" style="
margin
-
right
:
2
rem
;
">
<input type="
radio
" name="
tindakan
" value="
sokong
" id="
radioSokong
">
<label for="
radioSokong
">Sokong</label>
</div>
<div class="
ui
radio
checkbox
">
<input type="
radio
" name="
tindakan
" value="
kuiri
" id="
radioKuiri
">
<label for="
radioKuiri
">Kuiri</label>
</div>
</div>
<div class="
field
">
<label>
Catatan
<span id="
commentRequired
" style="
color
:
red
;
display
:
none
;
">*</span>
</label>
<textarea id="
hodComment
" rows="
3
" placeholder="
Masukkan
catatan
"></textarea>
</div>
</div>
<br>
</form>
</div>
@push('script')
<script>
$(document).ready(function () {
$('.ui.radio.checkbox').checkbox();
$('input[name="
tindakan
"]').on('change', function () {
if ($(this).val() === 'kuiri') {
$('#commentRequired').show();
} else {
$('#commentRequired').hide();
}
});
});
function submitTindakan() {
var tindakan = $('input[name="
tindakan
"]:checked').val();
var comment = $('#hodComment').val().trim();
if (!tindakan) {
alert('Sila pilih tindakan (Sokong atau Kuiri).');
return;
}
if (tindakan === 'kuiri' && comment === '') {
alert('Sila masukkan catatan sebelum membuat kuiri.');
return;
}
if (!confirm(tindakan === 'sokong' ? 'Sokong permohonan ini?' : 'Kuiri permohonan ini?')) return;
$('#hiddenComment').val(comment);
var url = tindakan === 'sokong'
? '{{ route('mileage::HOD.sokong',
$claim->id
) }}'
: '{{ route('mileage::HOD.kuiri',
$claim->id
) }}';
$('#formTindakan').attr('action', url).submit();
}
</script>
@endpush
@endif
<div style="
text
-
align
:
right
;
">
<a href="
{{
route
(
'mileage::HOD.index'
)
}}
" class="
ui
button
">
<i class="
arrow
left
icon
"></i> Kembali
</a>
<button type="
button
" onclick="
submitTindakan
()
" class="
ui
violet
button
">
<i class="
send
icon
"></i> Hantar Tindakan
</button>
</div>
<br><br>
<a
href=
"{{ route('mileage::HOD.index') }}"
class=
"ui button"
>
<i
class=
"arrow left icon"
></i>
Kembali
</a>
</div>
@endsection
@push('script')
<script>
$(document).ready(function () {
$('#modalPerbelanjaan').modal({ closable: true });
$('#modalAnggaran').modal({ closable: true });
});
</script>
@endpush
packages/portal/mileage/resources/views/mileage/form.blade.php
View file @
93a00a5e
...
...
@@ -3,124 +3,147 @@
@
section
(
'content'
)
<
div
class
="
ui
segment
">
<a class="
ui
violet
left
ribbon
label
">Permohonan Tuntutan Mileage - {{
$claim->mm_apply_no
}}</a><br/><br/>
@if(session('success'))
<div class="
ui
success
message
">{{ session('success') }}</div>
@endif
@if(session('error'))
<div class="
ui
error
message
">{{ session('error') }}</div>
@endif
{{-- Segment 1: Senarai butiran yang telah ditambah
--}}
<div class="
ui
segment
">
<h3 class="
ui
header
">Senarai Butiran Tuntutan</h3>
<table class="
ui
celled
table
">
<thead>
<tr>
<th>No</th>
<th>Tarikh</th>
<th>Kenderaan</th>
<th>Projek</th>
<a class="
ui
violet
left
ribbon
label
">Permohonan Tuntutan Mileage - {{
$claim->mm_apply_no
}}</a><br/><br/>
@if(session('success'))
<div class="
ui
success
message
">{{ session('success') }}</div>
@endif
@if(session('error'))
<div class="
ui
error
message
">{{ session('error') }}</div>
@endif
{{-- Segment 1: Senarai butiran
--}}
<div class="
ui
segment
">
<h3 class="
ui
header
">Senarai 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 Jarak (KM)</th>
<th class="
right
aligned
">Jumlah Perbelanjaan (RM)</th>
<th class="
right
aligned
">Anggaran Tuntutan (RM)</th>
<th>Tindakan</th>
</tr>
</thead>
<tbody>
@php
$grandAnggaran
= 0;
@endphp
@forelse(
$claim->details
as
$index
=>
$detail
)
@php
$jumlahJarak
= (float)
$detail->md_total_mileage
;
$claimableKm
= max(0,
$jumlahJarak
- 40);
$vehicleName
= strtolower(
$detail->jenisKenderaan
?->name ?? '');
$isMotosikal
= in_array(
$vehicleName
, ['motosikal', 'motorcycle']);
$rate
=
$isMotosikal
? 0.30 : (
$claimableKm
<= 500 ? 0.55 : 0.50);
$mileageAmount
=
$claimableKm
*
$rate
;
$jumlahBelanja
= (float)
$detail->md_total_toll
+ (float)
$detail->md_total_parking_fee
;
$anggaranTuntutan
=
$mileageAmount
+
$jumlahBelanja
;
$grandAnggaran
+=
$anggaranTuntutan
;
@endphp
<tr>
<td>{{
$index
+ 1 }}</td>
<td>{{ \Carbon\Carbon::parse(
$detail->md_claim_date
)->format('d/m/Y') }}</td>
<td>{{
$detail->jenisKenderaan
?->name ?? '-' }}</td>
<td>{{
$detail->project
?
$detail->project
->p_project_code . ' - ' .
$detail->project
->p_project_description : 'Tiada Projek' }}</td> <td>{{
$detail->md_description
}} </td>
<td class="
right
aligned
">{{ number_format(
$jumlahJarak
, 1) }}</td>
<th>Tindakan</th>
</tr>
</thead>
<tbody>
@php
$grandAnggaran
= 0; @endphp
@forelse(
$claim->details
as
$index
=>
$detail
)
@php
$jumlahJarak
= (float)
$detail->md_total_mileage
;
$claimableKm
= max(0,
$jumlahJarak
- 40);
$vehicleName
= strtolower(
$detail->jenisKenderaan
?->name ?? '');
$isMotosikal
= in_array(
$vehicleName
, ['motosikal', 'motorcycle']);
$rate
=
$isMotosikal
? 0.30 : (
$claimableKm
<= 500 ? 0.55 : 0.50);
$mileageAmount
=
$claimableKm
*
$rate
;
$jumlahBelanja
= (float)
$detail->md_total_toll
+ (float)
$detail->md_total_parking_fee
;
$anggaranTuntutan
=
$mileageAmount
+
$jumlahBelanja
;
$grandAnggaran
+=
$anggaranTuntutan
;
@endphp
<tr>
<td>{{
$index
+ 1 }}</td>
<td>{{ \Carbon\Carbon::parse(
$detail->md_claim_date
)->format('d/m/Y') }}</td>
<td>{{
$detail->jenisKenderaan
?->name ?? '-' }}</td>
<td>{{
$detail->project
?
$detail->project
->p_project_code . ' - ' .
$detail->project
->p_project_description : 'Tiada Projek' }}</td>
<td>{{
$detail->md_description
}}</td>
<td class="
right
aligned
">{{ number_format(
$jumlahJarak
, 1) }}</td>
<td class="
right
aligned
">{{ number_format(
$jumlahBelanja
, 2) }}</td>
<td class="
right
aligned
">{{ number_format(
$anggaranTuntutan
, 2) }}</td>
<td>
<form action="
{{
route
(
'mileage::mileage.claim.detail.destroy'
,
[
'id'
=>
$detail
->
id
])
}}
" method="
POST
" onsubmit="
return
confirm
(
'Padam butiran ini?'
);
" style="
display
:
inline
;
">
@csrf
@method('DELETE')
<button type="
submit
" class="
ui
red
small
button
"><i class="
trash
icon
"></i></button>
</form>
</td>
</tr>
@empty
<tr>
<td colspan="
8
" class="
center
aligned
">Tiada butiran ditambah lagi.</td>
</tr>
@endforelse
</tbody>
@if(
$claim->details
->count() > 0)
<tfoot>
<td>
@if(
$claim->status
== 1)
<div class="
ui
small
icon
buttons
">
<button type="
button
" class="
ui
blue
button
btn
-
edit
-
detail
"
data-update-url="
{{
route
(
'mileage::mileage.claim.detail.update'
,
[
'id'
=>
$detail
->
id
])
}}
"
data-date="
{{
$detail
->
md_claim_date
}}
"
data-kenderaan="
{{
$detail
->
fk_lkp_jenis_kenderaan
}}
"
data-project="
{{
$detail
->
fk_lkp_project
}}
"
data-description="
{{
$detail
->
md_description
}}
"
data-from="
{{
$detail
->
md_distance_from
}}
"
data-to="
{{
$detail
->
md_distance_to
}}
"
data-mileage="
{{
$detail
->
md_total_mileage
}}
"
data-toll="
{{
$detail
->
md_total_toll
}}
"
data-parking="
{{
$detail
->
md_total_parking_fee
}}
">
<i class="
edit
icon
"></i>
</button>
<form action="
{{
route
(
'mileage::mileage.claim.detail.destroy'
,
[
'id'
=>
$detail
->
id
])
}}
" method="
POST
" onsubmit="
return
confirm
(
'Padam butiran ini?'
);
" style="
display
:
inline
;
">
@csrf
@method('DELETE')
<button type="
submit
" class="
ui
red
button
"><i class="
trash
icon
"></i></button>
</form>
</div>
@else
-
@endif
</td>
</tr>
@empty
<tr>
<td colspan="
9
" class="
center
aligned
">Tiada butiran ditambah lagi.</td>
</tr>
@endforelse
</tbody>
@if(
$claim->details
->count() > 0)
<tfoot>
<tr>
<th colspan="
7
" class="
right
aligned
">JUMLAH KESELURUHAN ANGGARAN TUNTUTAN (RM)</th>
<th class="
right
aligned
">{{ number_format(
$grandAnggaran
, 2) }}</th>
<th></th>
</tr>
</tfoot>
@endif
</table>
</div>
{{-- Segment 2: Tambah butiran --}}
<div class="
ui
segment
">
<h3 class="
ui
header
">Tambah Butiran Tuntutan</h3>
@php
$minDate
= sprintf('%04d-%02d-01',
$claim->mm_claim_year
,
$claim->mm_claim_month
);
$maxDate
= \Carbon\Carbon::createFromDate(
$claim->mm_claim_year
,
$claim->mm_claim_month
, 1)
->endOfMonth()->format('Y-m-d');
@endphp
<form class="
ui
form
" method="
POST
" action="
{{
route
(
'mileage::mileage.claim.detail.store'
,
[
'id'
=>
$claim
->
id
])
}}
">
@csrf
<div class="
two
fields
">
<div class="
field
">
<label>Tarikh</label>
<input type="
date
" name="
md_claim_date
" min="
{{
$minDate
}}
" max="
{{
$maxDate
}}
" required>
</div>
<div class="
field
">
<label>Jenis Kenderaan</label>
<select name="
fk_lkp_jenis_kenderaan
" class="
ui
dropdown
" required>
<option value="">-- Pilih --</option>
@foreach(
$jenisKenderaan
as
$jk
)
<option value="
{{
$jk
->
id
}}
">{{
$jk->name
}}</option>
@endforeach
</select>
</div>
</div>
<div class="
two
fields
">
<div class="
field
">
<label>Projek</label>
<select name="
fk_lkp_project
" class="
ui
search
selection
dropdown
">
@endif
</table>
</div>
{{-- Segment 2: Tambah / Kemaskini butiran (Draf only) --}}
@if(
$claim->status
== 1)
<div class="
ui
segment
" id="
segment2
">
<h3 class="
ui
header
" id="
segmentHeader
">Tambah Butiran Tuntutan</h3>
@php
$minDate
= sprintf('%04d-%02d-01',
$claim->mm_claim_year
,
$claim->mm_claim_month
);
$maxDate
= \Carbon\Carbon::createFromDate(
$claim->mm_claim_year
,
$claim->mm_claim_month
, 1)
->endOfMonth()->format('Y-m-d');
@endphp
<form class="
ui
form
" id="
detailForm
" method="
POST
" action="
{{
route
(
'mileage::mileage.claim.detail.store'
,
[
'id'
=>
$claim
->
id
])
}}
">
@csrf
<input type="
hidden
" name="
_method
" id="
formMethod
" value="">
<div class="
two
fields
">
<div class="
field
">
<label>Tarikh <span style="
color
:
red
;
">*</span></label>
<input type="
date
" name="
md_claim_date
" min="
{{
$minDate
}}
" max="
{{
$maxDate
}}
" required>
</div>
<div class="
field
">
<label>Jenis Kenderaan <span style="
color
:
red
;
">*</span></label>
<select name="
fk_lkp_jenis_kenderaan
" class="
ui
dropdown
" required>
<option value="">-- Pilih --</option>
@foreach(
$jenisKenderaan
as
$jk
)
<option value="
{{
$jk
->
id
}}
">{{
$jk->name
}}</option>
@endforeach
</select>
</div>
</div>
<div class="
two
fields
">
<div class="
field
">
<label>
Projek
<i class="
info
circle
icon
"
data-content="
Jika
Tiada
Projek
,
Tinggal
Kosong
"
data-position="
top
center
"
style="
cursor
:
pointer
;
color
:
#2185d0;"></i>
</
label
>
<
select
name
=
"fk_lkp_project"
class
="
ui
search
selection
dropdown
">
<option value="">Tiada Projek</option>
@foreach(
$projects
as
$project
)
<option value="
{{
$project
->
id
}}
">
...
...
@@ -128,54 +151,126 @@
</option>
@endforeach
</select>
</div>
<div class="
field
">
<label>Butiran</label>
<input type="
text
" name="
md_description
" placeholder="
Cth
:
Lawatan
ke
pejabat
klien
">
</div>
</div>
<div class="
two
fields
">
<div class="
field
">
<label>Jarak Dari</label>
<input type="
text
" name="
md_distance_from
" placeholder="
Cth
:
Pejabat
Ipoh
" required>
</div>
<div class="
field
">
<label>Jarak Ke</label>
<input type="
text
" name="
md_distance_to
" placeholder="
Cth
:
Pejabat
Pulau
Pinang
" required>
</div>
</div>
<div class="
field
">
<label>Jumlah Jarak (KM)</label>
<input type="
number
" step="
0.1
" name="
md_total_mileage
" required>
</div>
<div class="
two
fields
">
<div class="
field
">
<label>Jumlah Tol (RM)</label>
<input type="
number
" step="
0.01
" name="
md_total_toll
" value="
0
">
</div>
<div class="
field
">
<label>Jumlah Bayaran Letak Kereta (RM)</label>
<input type="
number
" step="
0.01
" name="
md_total_parking_fee
" value="
0
">
</div>
</div>
</div>
<br>
<div class="
field
">
<label>Butiran <span style="
color
:
red
;
">*</span></label>
<input type="
text
" name="
md_description
" placeholder="
Cth
:
Lawatan
ke
pejabat
klien
" required>
</div>
</div>
<div class="
two
fields
">
<div class="
field
">
<label>Jarak Dari <span style="
color
:
red
;
">*</span></label>
<input type="
text
" name="
md_distance_from
" placeholder="
Cth
:
Pejabat
Ipoh
" required>
</div>
<div class="
field
">
<label>Jarak Ke <span style="
color
:
red
;
">*</span></label>
<input type="
text
" name="
md_distance_to
" placeholder="
Cth
:
Pejabat
Pulau
Pinang
" required>
</div>
</div>
<div class="
field
">
<label>Jumlah Jarak (KM) <span style="
color
:
red
;
">*</span></label>
<input type="
number
" step="
0.1
" name="
md_total_mileage
" required>
</div>
<div class="
two
fields
">
<div class="
field
">
<label>Jumlah Tol (RM)</label>
<input type="
number
" step="
0.01
" name="
md_total_toll
" value="
0
">
</div>
<div class="
field
">
<label>Jumlah Bayaran Letak Kereta (RM)</label>
<input type="
number
" step="
0.01
" name="
md_total_parking_fee
" value="
0
">
</div>
</div>
<button type="
submit
" class="
ui
right
floated
primary
button
">Tambah Butiran</button>
<br>
<button type="
button
" id="
btnBatalEdit
" class="
ui
button
" style="
display
:
none
;
">Batal Edit</button>
<button type="
submit
" id="
btnSubmitDetail
" class="
ui
right
floated
primary
button
">Tambah Butiran</button>
<div style="
clear
:
both
"></div>
</form>
</div>
</div>
@endif
{{-- Segment 3: 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>
<th>Tindakan</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>
<td>
@if(
$claim->status
== 1)
<form action="
{{
route
(
'mileage::mileage.claim.attachment.delete'
,
$file
->
id
)
}}
" method="
POST
" onsubmit="
return
confirm
(
'Padam fail ini?'
);
" style="
display
:
inline
;
">
@csrf
@method('DELETE')
<button type="
submit
" class="
ui
red
small
button
">
<i class="
trash
icon
"></i> Padam
</button>
</form>
@else
-
@endif
</td>
</tr>
@endforeach
</tbody>
</table>
@else
<p class="
ui
grey
text
">Tiada lampiran yang dimuat naik.</p>
@endif
@if(
$claim->status
== 1)
<div class="
ui
divider
"></div>
<form class="
ui
form
" action="
{{
route
(
'mileage::mileage.claim.attachment.upload'
,
$claim
->
id
)
}}
" method="
POST
" enctype="
multipart
/
form
-
data
">
@csrf
<div class="
field
">
<label>Muat Naik Fail <span style="
color
:
red
;
">*</span></label>
<small style="
color
:
grey
;
">Format: PDF, JPG, PNG. Saiz maksimum: 5MB.</small><br><br>
<input type="
file
" name="
attachment
" accept="
.
pdf
,
.
jpg
,
.
jpeg
,
.
png
" required>
</div>
<br>
<button type="
submit
" class="
ui
primary
small
button
">
<i class="
upload
icon
"></i> Muat Naik
</button>
</form>
@endif
</div>
<br>
<a href="
{{
route
(
'mileage::mileage.listmileage'
)
}}
" class="
ui
right
floated
button
">
<i class="
arrow
left
icon
"></i> Kembali ke Senarai
</a>
<div style="
clear
:
both
"></div>
@if(
$claim->status
== 1)
<form action="
{{
route
(
'mileage::mileage.claim.submit'
,
[
'id'
=>
$claim
->
id
])
}}
" method="
POST
" style="
display
:
inline
;
" onsubmit="
return
confirm
(
'Hantar permohonan ini? Anda tidak boleh membuat perubahan selepas ini.'
);
">
@csrf
<button type="
submit
" class="
ui
right
floated
green
button
">
<i class="
send
icon
"></i> Hantar Permohonan
</button>
</form>
@endif
<a href="
{{
route
(
'mileage::mileage.listmileage'
)
}}
" class="
ui
right
floated
button
">
<i class="
arrow
left
icon
"></i> Simpan Sebagai Draf
</a>
<div style="
clear
:
both
"></div>
<br>
</div>
...
...
@@ -185,11 +280,56 @@
@push('script')
<script>
$(document).ready(function () {
$('.ui.dropdown').dropdown();
$('.ui.dropdown').dropdown();
$('select[name="
fk_lkp_project
"]').dropdown('setting', 'forceSelection', false);
$('select[name="
fk_lkp_project
"]').dropdown('setting', 'clearable', true);
$('.info.circle.icon').popup();
var storeUrl = '{{ route('mileage::mileage.claim.detail.store', ['id' =>
$claim->id
]) }}';
$('.btn-edit-detail').on('click', function () {
var btn = $(this);
$('input[name="
md_claim_date
"]').val(btn.data('date'));
$('select[name="
fk_lkp_jenis_kenderaan
"]').dropdown('set selected', btn.data('kenderaan'));
var project = btn.data('project');
if (project) {
$('select[name="
fk_lkp_project
"]').dropdown('set selected', project);
} else {
$('select[name="
fk_lkp_project
"]').dropdown('clear');
}
$('input[name="
md_description
"]').val(btn.data('description'));
$('input[name="
md_distance_from
"]').val(btn.data('from'));
$('input[name="
md_distance_to
"]').val(btn.data('to'));
$('input[name="
md_total_mileage
"]').val(btn.data('mileage'));
$('input[name="
md_total_toll
"]').val(btn.data('toll'));
$('input[name="
md_total_parking_fee
"]').val(btn.data('parking'));
$('#detailForm').attr('action', btn.data('update-url'));
$('#formMethod').val('PUT');
$('#btnSubmitDetail').text('Kemaskini Butiran');
$('#segmentHeader').text('Kemaskini Butiran Tuntutan');
$('#btnBatalEdit').show();
$('html, body').animate({ scrollTop: $('#segment2').offset().top }, 500);
});
$('#btnBatalEdit').on('click', function () {
$('#detailForm')[0].reset();
$('#detailForm').attr('action', storeUrl);
$('#formMethod').val('');
$('#btnSubmitDetail').text('Tambah Butiran');
$('#segmentHeader').text('Tambah Butiran Tuntutan');
$('#btnBatalEdit').hide();
$('select[name="
fk_lkp_jenis_kenderaan
"]').dropdown('clear');
$('select[name="
fk_lkp_project
"]').dropdown('clear');
});
});
</script>
@endpush
packages/portal/mileage/resources/views/mileage/list.blade.php
View file @
93a00a5e
...
...
@@ -28,9 +28,9 @@
<button type="
button
" class="
ui
right
floated
primary
button
" onclick="
$
(
'#modalPermohonanBaharu'
)
.
modal
(
'show'
)
">
Permohonan Baharu
</button>
<a href="
{{
route
(
'mileage::mileage.audit-trail'
)
}}
" class="
ui
right
floated
button
">
{{--
<a href="
{{
route
(
'mileage::mileage.audit-trail'
)
}}
" class="
ui
right
floated
button
">
Audit Trail
</a>
</a>
--}}
<br/>
<div class="
column
sixteen
wide
table
-
uppercase
">
...
...
@@ -81,15 +81,21 @@
}],
['header' => __('Tindakan'), 'raw' => function(
$row
){
$url
= route('mileage::mileage.claim.form', ['id' =>
$row->id
]);
return "
<
div
class
='
ui
small
basic
icon
buttons
'>
<a href='
{
$url
}
' class='
ui
button
'>
<i class='
file
icon
'></i>
</a>
</div>";
}]
$icon
= 'eye';
$color
= 'teal';
if (
$row->status
== 1) {
$icon
= 'edit';
$color
= 'blue';
} elseif (
$row->status
== 8) {
$icon
= 'exclamation circle';
$color
= 'orange';
}
$url
= route('mileage::mileage.claim.form',
$row->id
);
return '<a href="
' . $url . '
" class="
ui
' . $color . '
small
icon
button
"><i class="
' . $icon . '
icon
"></i></a>';
}]
])
->render()
...
...
packages/portal/mileage/resources/views/mileage/queryForm.blade.php
0 → 100644
View file @
93a00a5e
@
extends
(
'ui::layouts.app'
)
@
section
(
'content'
)
<
div
class
="
ui
segment
">
<a class="
ui
violet
left
ribbon
label
">Permohonan Semula - {{
$claim->mm_apply_no
}}</a><br/><br/>
@if(session('success'))
<div class="
ui
success
message
">{{ session('success') }}</div>
@endif
@if(session('error'))
<div class="
ui
error
message
">{{ session('error') }}</div>
@endif
{{-- HOD Query Info --}}
<div class="
ui
warning
message
">
<div class="
header
">Permohonan Telah Dikuiri Oleh HOD</div>
<p><strong>Catatan HOD:</strong> {{
$query->comment
?? '-' }}</p>
<p><em>Sila semak butiran dan hantar semula permohonan anda.</em></p>
</div>
{{-- Segment 1: Senarai butiran --}}
<div class="
ui
segment
">
<h3 class="
ui
header
">Senarai 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 Perbelanjaan (RM)</th>
<th class="
right
aligned
">Anggaran Tuntutan (RM)</th>
<th>Tindakan</th>
</tr>
</thead>
<tbody>
@php
$grandAnggaran
= 0; @endphp
@forelse(
$claim->details
as
$index
=>
$detail
)
@php
$jumlahJarak
= (float)
$detail->md_total_mileage
;
$claimableKm
= max(0,
$jumlahJarak
- 40);
$vehicleName
= strtolower(
$detail->jenisKenderaan
?->name ?? '');
$isMotosikal
= in_array(
$vehicleName
, ['motosikal', 'motorcycle']);
$rate
=
$isMotosikal
? 0.30 : (
$claimableKm
<= 500 ? 0.55 : 0.50);
$mileageAmount
=
$claimableKm
*
$rate
;
$jumlahBelanja
= (float)
$detail->md_total_toll
+ (float)
$detail->md_total_parking_fee
;
$anggaranTuntutan
=
$mileageAmount
+
$jumlahBelanja
;
$grandAnggaran
+=
$anggaranTuntutan
;
@endphp
<tr>
<td>{{
$index
+ 1 }}</td>
<td>{{ \Carbon\Carbon::parse(
$detail->md_claim_date
)->format('d/m/Y') }}</td>
<td>{{
$detail->jenisKenderaan
?->name ?? '-' }}</td>
<td>{{
$detail->project
?
$detail->project
->p_project_code . ' - ' .
$detail->project
->p_project_description : 'Tiada Projek' }}</td>
<td>{{
$detail->md_description
}}</td>
<td class="
right
aligned
">{{ number_format(
$jumlahJarak
, 1) }}</td>
<td class="
right
aligned
">{{ number_format(
$jumlahBelanja
, 2) }}</td>
<td class="
right
aligned
">{{ number_format(
$anggaranTuntutan
, 2) }}</td>
<td>
<div class="
ui
small
icon
buttons
">
<button type="
button
" class="
ui
blue
button
btn
-
edit
-
detail
"
data-update-url="
{{
route
(
'mileage::mileage.claim.detail.update'
,
[
'id'
=>
$detail
->
id
])
}}
"
data-date="
{{
$detail
->
md_claim_date
}}
"
data-kenderaan="
{{
$detail
->
fk_lkp_jenis_kenderaan
}}
"
data-project="
{{
$detail
->
fk_lkp_project
}}
"
data-description="
{{
$detail
->
md_description
}}
"
data-from="
{{
$detail
->
md_distance_from
}}
"
data-to="
{{
$detail
->
md_distance_to
}}
"
data-mileage="
{{
$detail
->
md_total_mileage
}}
"
data-toll="
{{
$detail
->
md_total_toll
}}
"
data-parking="
{{
$detail
->
md_total_parking_fee
}}
">
<i class="
edit
icon
"></i>
</button>
<form action="
{{
route
(
'mileage::mileage.claim.detail.destroy'
,
[
'id'
=>
$detail
->
id
])
}}
" method="
POST
" onsubmit="
return
confirm
(
'Padam butiran ini?'
);
" style="
display
:
inline
;
">
@csrf
@method('DELETE')
<button type="
submit
" class="
ui
red
button
"><i class="
trash
icon
"></i></button>
</form>
</div>
</td>
</tr>
@empty
<tr>
<td colspan="
9
" class="
center
aligned
">Tiada butiran ditambah lagi.</td>
</tr>
@endforelse
</tbody>
@if(
$claim->details
->count() > 0)
<tfoot>
<tr>
<th colspan="
7
" class="
right
aligned
">JUMLAH KESELURUHAN ANGGARAN TUNTUTAN (RM)</th>
<th class="
right
aligned
">{{ number_format(
$grandAnggaran
, 2) }}</th>
<th></th>
</tr>
</tfoot>
@endif
</table>
</div>
{{-- Segment 2: Tambah / Kemaskini butiran --}}
<div class="
ui
segment
" id="
segment2
">
<h3 class="
ui
header
" id="
segmentHeader
">Tambah Butiran Tuntutan</h3>
@php
$minDate
= sprintf('%04d-%02d-01',
$claim->mm_claim_year
,
$claim->mm_claim_month
);
$maxDate
= \Carbon\Carbon::createFromDate(
$claim->mm_claim_year
,
$claim->mm_claim_month
, 1)
->endOfMonth()->format('Y-m-d');
@endphp
<form class="
ui
form
" id="
detailForm
" method="
POST
" action="
{{
route
(
'mileage::mileage.claim.detail.store'
,
[
'id'
=>
$claim
->
id
])
}}
">
@csrf
<input type="
hidden
" name="
_method
" id="
formMethod
" value="">
<div class="
two
fields
">
<div class="
field
">
<label>Tarikh <span style="
color
:
red
;
">*</span></label>
<input type="
date
" name="
md_claim_date
" min="
{{
$minDate
}}
" max="
{{
$maxDate
}}
" required>
</div>
<div class="
field
">
<label>Jenis Kenderaan <span style="
color
:
red
;
">*</span></label>
<select name="
fk_lkp_jenis_kenderaan
" class="
ui
dropdown
" required>
<option value="">-- Pilih --</option>
@foreach(
$jenisKenderaan
as
$jk
)
<option value="
{{
$jk
->
id
}}
">{{
$jk->name
}}</option>
@endforeach
</select>
</div>
</div>
<div class="
two
fields
">
<div class="
field
">
<label>
Projek
<i class="
info
circle
icon
"
data-content="
Jika
Tiada
Projek
,
Tinggal
Kosong
"
data-position="
top
center
"
style="
cursor
:
pointer
;
color
:
#2185d0;"></i>
</
label
>
<
select
name
=
"fk_lkp_project"
class
="
ui
search
selection
dropdown
">
<option value="">Tiada Projek</option>
@foreach(
$projects
as
$project
)
<option value="
{{
$project
->
id
}}
">
{{
$project->p_project_code
}} - {{
$project->p_project_description
}}
</option>
@endforeach
</select>
</div>
<div class="
field
">
<label>Butiran <span style="
color
:
red
;
">*</span></label>
<input type="
text
" name="
md_description
" placeholder="
Cth
:
Lawatan
ke
pejabat
klien
" required>
</div>
</div>
<div class="
two
fields
">
<div class="
field
">
<label>Jarak Dari <span style="
color
:
red
;
">*</span></label>
<input type="
text
" name="
md_distance_from
" placeholder="
Cth
:
Pejabat
Ipoh
" required>
</div>
<div class="
field
">
<label>Jarak Ke <span style="
color
:
red
;
">*</span></label>
<input type="
text
" name="
md_distance_to
" placeholder="
Cth
:
Pejabat
Pulau
Pinang
" required>
</div>
</div>
<div class="
field
">
<label>Jumlah Jarak (KM) <span style="
color
:
red
;
">*</span></label>
<input type="
number
" step="
0.1
" name="
md_total_mileage
" required>
</div>
<div class="
two
fields
">
<div class="
field
">
<label>Jumlah Tol (RM)</label>
<input type="
number
" step="
0.01
" name="
md_total_toll
" value="
0
">
</div>
<div class="
field
">
<label>Jumlah Bayaran Letak Kereta (RM)</label>
<input type="
number
" step="
0.01
" name="
md_total_parking_fee
" value="
0
">
</div>
</div>
<br>
<button type="
button
" id="
btnBatalEdit
" class="
ui
button
" style="
display
:
none
;
">Batal Edit</button>
<button type="
submit
" id="
btnSubmitDetail
" class="
ui
right
floated
primary
button
">Tambah Butiran</button>
<div style="
clear
:
both
"></div>
</form>
</div>
{{-- Segment 3: 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>
<th>Tindakan</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>
<td>
<form action="
{{
route
(
'mileage::mileage.claim.attachment.delete'
,
$file
->
id
)
}}
" method="
POST
" onsubmit="
return
confirm
(
'Padam fail ini?'
);
" style="
display
:
inline
;
">
@csrf
@method('DELETE')
<button type="
submit
" class="
ui
red
small
button
">
<i class="
trash
icon
"></i> Padam
</button>
</form>
</td>
</tr>
@endforeach
</tbody>
</table>
@else
<p class="
ui
grey
text
">Tiada lampiran.</p>
@endif
<div class="
ui
divider
"></div>
<form class="
ui
form
" action="
{{
route
(
'mileage::mileage.claim.attachment.upload'
,
$claim
->
id
)
}}
" method="
POST
" enctype="
multipart
/
form
-
data
">
@csrf
<div class="
field
">
<label>Muat Naik Fail <span style="
color
:
red
;
">*</span></label>
<small style="
color
:
grey
;
">Format: PDF, JPG, PNG. Saiz maksimum: 5MB.</small><br><br>
<input type="
file
" name="
attachment
" accept="
.
pdf
,
.
jpg
,
.
jpeg
,
.
png
" required>
</div>
<br>
<button type="
submit
" class="
ui
primary
small
button
">
<i class="
upload
icon
"></i> Muat Naik
</button>
</form>
</div>
{{-- Response & Resubmit --}}
<div class="
ui
segment
">
<h3 class="
ui
header
">Maklum Balas Kepada HOD</h3>
<form class="
ui
form
" action="
{{
route
(
'mileage::mileage.claim.resubmit'
,
[
'id'
=>
$claim
->
id
])
}}
" method="
POST
" onsubmit="
return
confirm
(
'Hantar semula permohonan ini?'
);
">
@csrf
<div class="
field
">
<label>Respons Anda <span style="
color
:
red
;
">*</span></label>
<textarea name="
response
" rows="
3
" placeholder="
Masukkan
respons
anda
terhadap
catatan
HOD
...
" required></textarea>
</div>
<br>
<div style="
text
-
align
:
right
;
">
<button type="
submit
" class="
ui
green
button
">
<i class="
send
icon
"></i> Hantar Semula Permohonan
</button>
</div>
</form>
</div>
<a href="
{{
route
(
'mileage::mileage.listmileage'
)
}}
" class="
ui
right
floated
button
">
<i class="
arrow
left
icon
"></i> Simpan Sebagai Draf
</a>
<div style="
clear
:
both
"></div>
<br>
</div>
@endsection
@push('script')
<script>
$(document).ready(function () {
$('.ui.dropdown').dropdown();
$('select[name="
fk_lkp_project
"]').dropdown('setting', 'forceSelection', false);
$('select[name="
fk_lkp_project
"]').dropdown('setting', 'clearable', true);
$('.info.circle.icon').popup();
var storeUrl = '{{ route('mileage::mileage.claim.detail.store', ['id' =>
$claim->id
]) }}';
$('.btn-edit-detail').on('click', function () {
var btn = $(this);
$('input[name="
md_claim_date
"]').val(btn.data('date'));
$('select[name="
fk_lkp_jenis_kenderaan
"]').dropdown('set selected', btn.data('kenderaan'));
var project = btn.data('project');
if (project) {
$('select[name="
fk_lkp_project
"]').dropdown('set selected', project);
} else {
$('select[name="
fk_lkp_project
"]').dropdown('clear');
}
$('input[name="
md_description
"]').val(btn.data('description'));
$('input[name="
md_distance_from
"]').val(btn.data('from'));
$('input[name="
md_distance_to
"]').val(btn.data('to'));
$('input[name="
md_total_mileage
"]').val(btn.data('mileage'));
$('input[name="
md_total_toll
"]').val(btn.data('toll'));
$('input[name="
md_total_parking_fee
"]').val(btn.data('parking'));
$('#detailForm').attr('action', btn.data('update-url'));
$('#formMethod').val('PUT');
$('#btnSubmitDetail').text('Kemaskini Butiran');
$('#segmentHeader').text('Kemaskini Butiran Tuntutan');
$('#btnBatalEdit').show();
$('html, body').animate({ scrollTop: $('#segment2').offset().top }, 500);
});
$('#btnBatalEdit').on('click', function () {
$('#detailForm')[0].reset();
$('#detailForm').attr('action', storeUrl);
$('#formMethod').val('');
$('#btnSubmitDetail').text('Tambah Butiran');
$('#segmentHeader').text('Tambah Butiran Tuntutan');
$('#btnBatalEdit').hide();
$('select[name="
fk_lkp_jenis_kenderaan
"]').dropdown('clear');
$('select[name="
fk_lkp_project
"]').dropdown('clear');
});
});
</script>
@endpush
packages/portal/mileage/routes/web.php
View file @
93a00a5e
...
...
@@ -72,10 +72,11 @@ function () {
Route
::
prefix
(
'HOD'
)
->
name
(
'HOD'
)
->
group
(
function
()
{
Route
::
get
(
'/dashboard'
,
[
HODController
::
class
,
'index'
])
->
name
(
'.index'
);
Route
::
get
(
'/show/{id}'
,
[
HODController
::
class
,
'show'
])
->
name
(
'.show'
);
Route
::
post
(
'/{id}/
verify'
,
[
HODController
::
class
,
'verify'
])
->
name
(
'.verify
'
);
Route
::
post
(
'/{id}/
reject'
,
[
HODController
::
class
,
'reject'
])
->
name
(
'.reject
'
);
Route
::
post
(
'/{id}/
sokong'
,
[
HODController
::
class
,
'sokong'
])
->
name
(
'.sokong
'
);
Route
::
post
(
'/{id}/
kuiri'
,
[
HODController
::
class
,
'kuiri'
])
->
name
(
'.kuiri
'
);
});
// BOD
Route
::
prefix
(
'BOD'
)
->
name
(
'BOD'
)
->
group
(
function
()
{
Route
::
get
(
'/dashboard'
,
[
BODController
::
class
,
'index'
])
->
name
(
'.index'
);
...
...
@@ -100,6 +101,11 @@ function () {
Route
::
get
(
'claim/{id}/form'
,
[
'uses'
=>
'MileageController@formClaim'
,
'as'
=>
'mileage.claim.form'
]);
Route
::
post
(
'claim/{id}/detail/store'
,
[
'uses'
=>
'MileageController@storeDetail'
,
'as'
=>
'mileage.claim.detail.store'
]);
Route
::
delete
(
'claim/detail/{id}/destroy'
,
[
'uses'
=>
'MileageController@destroyDetail'
,
'as'
=>
'mileage.claim.detail.destroy'
]);
Route
::
put
(
'claim/detail/{id}/update'
,
[
'uses'
=>
'MileageController@updateDetail'
,
'as'
=>
'mileage.claim.detail.update'
]);
Route
::
post
(
'claim/{id}/submit'
,
[
'uses'
=>
'MileageController@submitClaim'
,
'as'
=>
'mileage.claim.submit'
]);
Route
::
post
(
'claim/{id}/resubmit'
,
[
'uses'
=>
'MileageController@resubmitClaim'
,
'as'
=>
'mileage.claim.resubmit'
]);
Route
::
post
(
'claim/{id}/attachment/upload'
,
[
'uses'
=>
'MileageController@uploadAttachment'
,
'as'
=>
'mileage.claim.attachment.upload'
]);
Route
::
delete
(
'claim/attachment/{id}/delete'
,
[
'uses'
=>
'MileageController@deleteAttachment'
,
'as'
=>
'mileage.claim.attachment.delete'
]);
Route
::
get
(
'audit-trail'
,
[
'uses'
=>
'MileageController@getAuditTrail'
,
'as'
=>
'mileage.audit-trail'
]);
...
...
packages/portal/mileage/src/Data/Repo/HODRepo.php
0 → 100644
View file @
93a00a5e
<?php
namespace
Portal\Mileage\Data\Repo
;
use
Portal\Mileage\Model\MileageClaimMain
;
use
Portal\Mileage\Model\MileageClaimAuditTrail
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Auth
;
use
Portal\Mileage\Model\AuditQuery
;
class
HODRepo
{
public
function
getHodList
(
$request
)
{
$search
=
$request
->
get
(
'search'
);
return
MileageClaimMain
::
with
([
'lkpStatus'
,
'staffInfo'
])
->
whereIn
(
'status'
,
[
2
,
3
,
7
,
8
])
->
when
(
$search
,
function
(
$query
)
use
(
$search
)
{
$query
->
where
(
'mm_apply_no'
,
'like'
,
'%'
.
$search
.
'%'
);
})
->
orderBy
(
'created_at'
,
'desc'
)
->
paginate
(
10
);
}
public
function
findClaim
(
$id
)
{
return
MileageClaimMain
::
with
([
'details.jenisKenderaan'
,
'details.project'
,
'lkpStatus'
,
'staffInfo'
,
'auditQueries'
,
'attachments'
])
->
findOrFail
(
$id
);
}
public
function
sokongClaim
(
$id
,
$comment
=
null
)
{
$claim
=
MileageClaimMain
::
findOrFail
(
$id
);
$claim
->
update
([
'status'
=>
7
,
'mm_verified_by'
=>
Auth
::
id
(),
'mm_verified_date'
=>
now
(),
]);
MileageClaimAuditTrail
::
create
([
'fk_lkp_mileage_task'
=>
6
,
'fk_mileage_claim_main'
=>
$id
,
'action_by'
=>
Auth
::
id
(),
'remark'
=>
Auth
::
user
()
->
name
.
' Telah Sokong Permohonan Tuntutan Mileage (mileage_claim_main.id = '
.
$id
.
')'
,
]);
return
$claim
;
}
public
function
kuiriClaim
(
$id
,
$comment
)
{
$claim
=
MileageClaimMain
::
findOrFail
(
$id
);
$claim
->
update
([
'status'
=>
8
,
'query_status'
=>
1
,
]);
AuditQuery
::
create
([
'fk_main'
=>
$id
,
'user_id'
=>
Auth
::
id
(),
'comment'
=>
$comment
,
]);
MileageClaimAuditTrail
::
create
([
'fk_lkp_mileage_task'
=>
7
,
'fk_mileage_claim_main'
=>
$id
,
'action_by'
=>
Auth
::
id
(),
'remark'
=>
Auth
::
user
()
->
name
.
' Telah Kuiri Permohonan Tuntutan Mileage (mileage_claim_main.id = '
.
$id
.
')'
,
]);
return
$claim
;
}
}
packages/portal/mileage/src/Data/Repo/MileageRepo.php
View file @
93a00a5e
...
...
@@ -8,7 +8,8 @@
use
Portal\Mileage\Model\StaffInfo
;
use
Portal\Mileage\Model\LkpFaCategory
;
use
Portal\Mileage\Model\MileageClaimAuditTrail
;
use
Portal\Mileage\Model\AuditQuery
;
use
Portal\Mileage\Model\MileageClaimAttachment
;
use
Illuminate\Support\Facades\Auth
;
use
Illuminate\Http\Request
;
...
...
@@ -49,15 +50,18 @@ public function index($request)
// mileage crud start
public
function
mileageList
(
$request
)
{
$search
=
request
(
'search'
);
{
$search
=
request
(
'search'
);
$staff
=
StaffInfo
::
where
(
'fk_users'
,
Auth
::
id
())
->
first
();
$data
=
MileageClaimMain
::
where
(
'mm_apply_no'
,
'like'
,
'%'
.
$search
.
'%'
)
->
orderBy
(
'created_at'
,
'desc'
)
->
paginate
(
10
);
$data
=
MileageClaimMain
::
where
(
'fk_lkp_staff_info'
,
$staff
->
id
??
null
)
->
where
(
'mm_apply_no'
,
'like'
,
'%'
.
$search
.
'%'
)
->
orderBy
(
'created_at'
,
'desc'
)
->
paginate
(
10
);
return
$data
;
}
return
$data
;
}
public
function
storeClaim
(
$request
)
{
...
...
@@ -69,7 +73,6 @@ public function storeClaim($request)
'mm_claim_month'
=>
$request
->
mm_claim_month
,
'mm_claim_year'
=>
$request
->
mm_claim_year
,
'fk_lkp_fa_category'
=>
$request
->
fk_lkp_fa_category
,
'mm_submit_date'
=>
now
(),
'status'
=>
1
,
]);
...
...
@@ -83,12 +86,11 @@ public function storeClaim($request)
return
$claim
->
id
;
}
public
function
findClaim
(
$id
)
{
return
MileageClaimMain
::
with
(
'details'
)
->
findOrFail
(
$id
);
}
{
return
MileageClaimMain
::
with
([
'details.jenisKenderaan'
,
'details.project'
,
'auditQueries'
,
'attachments'
])
->
findOrFail
(
$id
);
}
public
function
getJenisKenderaan
()
{
...
...
@@ -134,6 +136,105 @@ public function storeDetail($request, $id)
return
$detail
;
}
public
function
updateDetail
(
$request
,
$detailId
)
{
$detail
=
MileageClaimDetail
::
findOrFail
(
$detailId
);
$detail
->
update
([
'fk_lkp_jenis_kenderaan'
=>
$request
->
fk_lkp_jenis_kenderaan
,
'fk_lkp_project'
=>
$request
->
fk_lkp_project
??
null
,
'md_claim_date'
=>
$request
->
md_claim_date
,
'md_description'
=>
$request
->
md_description
,
'md_distance_from'
=>
$request
->
md_distance_from
,
'md_distance_to'
=>
$request
->
md_distance_to
,
'md_total_mileage'
=>
$request
->
md_total_mileage
,
'md_total_toll'
=>
$request
->
md_total_toll
??
0
,
'md_total_parking_fee'
=>
$request
->
md_total_parking_fee
??
0
,
]);
MileageClaimAuditTrail
::
create
([
'fk_lkp_mileage_task'
=>
5
,
'fk_mileage_claim_main'
=>
$detail
->
fk_mileage_claim_main
,
'action_by'
=>
Auth
::
id
(),
'remark'
=>
Auth
::
user
()
->
name
.
' Telah Kemaskini Butiran Tuntutan (mileage_claim_detail.id = '
.
$detailId
.
')'
,
]);
return
$detail
;
}
public
function
submitClaim
(
$id
)
{
$claim
=
MileageClaimMain
::
findOrFail
(
$id
);
$claim
->
update
([
'status'
=>
2
,
'mm_submit_date'
=>
now
(),
]);
MileageClaimAuditTrail
::
create
([
'fk_lkp_mileage_task'
=>
4
,
'fk_mileage_claim_main'
=>
$id
,
'action_by'
=>
Auth
::
id
(),
'remark'
=>
Auth
::
user
()
->
name
.
' Telah Hantar Permohonan Tuntutan Mileage (mileage_claim_main.id = '
.
$id
.
')'
,
]);
return
$claim
;
}
public
function
resubmitClaim
(
$id
,
$response
)
{
$claim
=
MileageClaimMain
::
findOrFail
(
$id
);
$query
=
AuditQuery
::
where
(
'fk_main'
,
$id
)
->
whereNull
(
'response'
)
->
latest
()
->
first
();
if
(
$query
)
{
$query
->
update
([
'response'
=>
$response
]);
}
$claim
->
update
([
'status'
=>
3
,
'query_status'
=>
null
,
'mm_submit_date'
=>
now
(),
]);
MileageClaimAuditTrail
::
create
([
'fk_lkp_mileage_task'
=>
8
,
'fk_mileage_claim_main'
=>
$id
,
'action_by'
=>
Auth
::
id
(),
'remark'
=>
Auth
::
user
()
->
name
.
' Telah Hantar Semula Permohonan Tuntutan Mileage (mileage_claim_main.id = '
.
$id
.
')'
,
]);
return
$claim
;
}
public
function
uploadAttachment
(
$request
,
$id
)
{
$file
=
$request
->
file
(
'attachment'
);
$fileName
=
$file
->
getClientOriginalName
();
$filePath
=
$file
->
storeAs
(
'mileage/attachments/'
.
$id
,
$fileName
,
'public'
);
return
MileageClaimAttachment
::
create
([
'fk_main'
=>
$id
,
'file_name'
=>
$fileName
,
'file_path'
=>
$filePath
,
]);
}
public
function
deleteAttachment
(
$id
)
{
$attachment
=
MileageClaimAttachment
::
findOrFail
(
$id
);
\Illuminate\Support\Facades\Storage
::
disk
(
'public'
)
->
delete
(
$attachment
->
file_path
);
$attachment
->
delete
();
return
$attachment
;
}
public
function
destroyDetail
(
$id
)
{
$detail
=
MileageClaimDetail
::
findOrFail
(
$id
);
...
...
packages/portal/mileage/src/Http/Controllers/HODController.php
View file @
93a00a5e
...
...
@@ -2,127 +2,47 @@
namespace
Portal\Mileage\Http\Controllers
;
use
App\Http\Controllers
\Controller
;
use
Illuminate\Routing
\Controller
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Auth
;
use
Carbon\Carbon
;
use
Portal\Mileage\Model\Users
;
use
Portal\Mileage\Model\Claim
;
use
Portal\Mileage\Data\Repo\HODRepo
;
class
HODController
extends
Controller
{
public
function
index
()
{
$hod
=
Auth
::
user
();
// check if HOD has staff info
if
(
!
$hod
||
!
$hod
->
staffInfo
)
{
return
back
()
->
with
(
'error'
,
'Maklumat jabatan HOD tidak dijumpai.'
);
}
$departmentId
=
$hod
->
staffInfo
->
fk_lkp_department
;
protected
$repos
;
// get all staff IDs under the same department
$staffIds
=
Users
::
whereHas
(
'staffInfo'
,
function
(
$query
)
use
(
$departmentId
)
{
$query
->
where
(
'fk_lkp_department'
,
$departmentId
)
;
})
->
pluck
(
'id'
);
public
function
__construct
(
HODRepo
$repos
)
{
$this
->
repos
=
$repos
;
}
// fetch claims under the HOD’s department
$claims
=
Claim
::
with
([
'user'
,
'project'
])
->
whereIn
(
'user_id'
,
$staffIds
)
->
whereNull
(
'project_id'
)
->
where
(
function
(
$q
)
use
(
$hod
)
{
$q
->
whereIn
(
'status'
,
[
'Diproses'
,
'Disokong'
])
// pending for review
->
orWhere
(
function
(
$sub
)
use
(
$hod
)
{
// Only show rejected claims that were rejected by THIS HOD
$sub
->
where
(
'status'
,
'Ditolak'
)
->
where
(
'rejected_by'
,
$hod
->
id
);
});
})
->
orderBy
(
'claim_date'
,
'desc'
)
->
get
();
public
function
index
(
Request
$request
)
{
$list
=
$this
->
repos
->
getHodList
(
$request
);
return
view
(
'mileage::HOD.index'
,
compact
(
'
claims
'
));
return
view
(
'mileage::HOD.index'
,
compact
(
'
list
'
));
}
public
function
show
(
$id
)
{
$claim
=
Claim
::
with
([
'project'
,
'jenisKenderaan'
,
'user'
])
->
findOrFail
(
$id
);
// Deduct first 40 km
$totalMileage
=
$claim
->
total_mileage
??
0
;
$claim
->
claimable_mileage
=
max
(
0
,
$totalMileage
-
40
);
// Penalty logic
$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
;
}
$calculatedAmount
=
round
(
$claimableMileage
*
$rate
,
2
);
if
(
$daysDiff
<=
30
)
{
$displayPenalty
=
0
;
$displayReason
=
'Tiada penalti (≤ 1 bulan)'
;
}
elseif
(
$daysDiff
<=
90
)
{
$displayPenalty
=
$calculatedAmount
*
0.10
;
$displayReason
=
'Lewat hantar >1 ≤3 bulan (10%)'
;
}
elseif
(
$daysDiff
<=
180
)
{
$displayPenalty
=
$calculatedAmount
*
0.30
;
$displayReason
=
'Lewat hantar >3 ≤6 bulan (30%)'
;
}
else
{
$displayPenalty
=
0
;
$displayReason
=
'Tertakluk kepada BOD'
;
}
$claim
->
display_penalty_amount
=
$displayPenalty
;
$claim
->
display_penalty_reason
=
$displayReason
;
$claim
->
display_total_claim_amount
=
(
$calculatedAmount
+
(
$claim
->
toll_amount
??
0
)
+
(
$claim
->
others_amount
??
0
))
-
$displayPenalty
;
$claim
=
$this
->
repos
->
findClaim
(
$id
);
return
view
(
'mileage::HOD.show'
,
compact
(
'claim'
));
}
public
function
verify
(
$id
)
public
function
sokong
(
Request
$request
,
$id
)
{
$hod
=
Auth
::
user
();
$claim
=
Claim
::
with
(
'user.staffInfo'
)
->
findOrFail
(
$id
);
// Check if claim is from HOD’s department
$hodDept
=
$hod
->
staffInfo
->
fk_lkp_department
??
null
;
$claimDept
=
$claim
->
user
->
staffInfo
->
fk_lkp_department
??
null
;
if
(
$hodDept
!==
$claimDept
)
{
return
back
()
->
with
(
'error'
,
'Anda tidak dibenarkan menyokong tuntutan ini.'
);
}
$claim
->
status
=
'Disokong'
;
$claim
->
approved_by
=
$hod
->
id
;
$claim
->
save
();
$this
->
repos
->
sokongClaim
(
$id
,
$request
->
hod_comment
);
return
back
()
->
with
(
'success'
,
'Tuntutan berjaya disokong.'
);
return
redirect
()
->
route
(
'mileage::HOD.index'
)
->
with
(
'success'
,
'Permohonan berjaya disokong.'
);
}
public
function
reject
(
$id
)
public
function
kuiri
(
Request
$request
,
$id
)
{
$hod
=
Auth
::
user
();
$claim
=
Claim
::
with
(
'user.staffInfo'
)
->
findOrFail
(
$id
);
$this
->
repos
->
kuiriClaim
(
$id
,
$request
->
hod_comment
);
$hodDept
=
$hod
->
staffInfo
->
fk_lkp_department
??
null
;
$claimDept
=
$claim
->
user
->
staffInfo
->
fk_lkp_department
??
null
;
if
(
$hodDept
!==
$claimDept
)
{
return
back
()
->
with
(
'error'
,
'Anda tidak dibenarkan menolak tuntutan ini.'
);
}
$claim
->
status
=
'Ditolak'
;
$claim
->
rejected_by
=
$hod
->
id
;
$claim
->
save
();
return
back
()
->
with
(
'error'
,
'Tuntutan telah ditolak.'
);
return
redirect
()
->
route
(
'mileage::HOD.index'
)
->
with
(
'success'
,
'Permohonan telah dikuiri dan dipulangkan kepada pemohon.'
);
}
}
packages/portal/mileage/src/Http/Controllers/MileageController.php
View file @
93a00a5e
...
...
@@ -69,13 +69,19 @@ public function storeClaim(Request $request)
public
function
formClaim
(
Request
$request
,
$id
)
{
$claim
=
$this
->
repos
->
findClaim
(
$id
);
$jenisKenderaan
=
$this
->
repos
->
getJenisKenderaan
();
$projects
=
$this
->
repos
->
getProjects
();
{
$claim
=
$this
->
repos
->
findClaim
(
$id
);
$jenisKenderaan
=
$this
->
repos
->
getJenisKenderaan
();
$projects
=
$this
->
repos
->
getProjects
();
if
(
$claim
->
query_status
==
1
)
{
$query
=
$claim
->
auditQueries
()
->
whereNull
(
'response'
)
->
latest
()
->
first
();
return
view
(
'mileage::mileage.queryForm'
,
compact
(
'claim'
,
'jenisKenderaan'
,
'projects'
,
'query'
));
}
return
view
(
'mileage::mileage.form'
,
compact
(
'claim'
,
'jenisKenderaan'
,
'projects'
));
}
return
view
(
'mileage::mileage.form'
,
compact
(
'claim'
,
'jenisKenderaan'
,
'projects'
));
}
public
function
storeDetail
(
Request
$request
,
$id
)
{
...
...
@@ -100,5 +106,53 @@ public function getAuditTrail(Request $request)
return
view
(
'mileage::mileage.audit-trail'
,
compact
(
'auditTrail'
));
}
public
function
updateDetail
(
Request
$request
,
$id
)
{
$this
->
repos
->
updateDetail
(
$request
,
$id
);
$detail
=
\Portal\Mileage\Model\MileageClaimDetail
::
findOrFail
(
$id
);
return
redirect
()
->
route
(
'mileage::mileage.claim.form'
,
[
'id'
=>
$detail
->
fk_mileage_claim_main
])
->
with
(
'success'
,
'Butiran tuntutan berjaya dikemaskini.'
);
}
public
function
submitClaim
(
Request
$request
,
$id
)
{
$this
->
repos
->
submitClaim
(
$id
);
return
redirect
()
->
route
(
'mileage::mileage.listmileage'
)
->
with
(
'success'
,
'Permohonan berjaya dihantar.'
);
}
public
function
resubmitClaim
(
Request
$request
,
$id
)
{
$this
->
repos
->
resubmitClaim
(
$id
,
$request
->
response
);
return
redirect
()
->
route
(
'mileage::mileage.listmileage'
)
->
with
(
'success'
,
'Permohonan berjaya dihantar semula.'
);
}
public
function
uploadAttachment
(
Request
$request
,
$id
)
{
$request
->
validate
([
'attachment'
=>
'required|file|mimes:pdf,jpg,jpeg,png|max:5120'
,
]);
$this
->
repos
->
uploadAttachment
(
$request
,
$id
);
return
redirect
()
->
route
(
'mileage::mileage.claim.form'
,
[
'id'
=>
$id
])
->
with
(
'success'
,
'Fail berjaya dimuat naik.'
);
}
public
function
deleteAttachment
(
Request
$request
,
$id
)
{
$attachment
=
$this
->
repos
->
deleteAttachment
(
$id
);
return
redirect
()
->
route
(
'mileage::mileage.claim.form'
,
[
'id'
=>
$attachment
->
fk_main
])
->
with
(
'success'
,
'Fail berjaya dipadam.'
);
}
}
packages/portal/mileage/src/Model/AuditQuery.php
0 → 100644
View file @
93a00a5e
<?php
namespace
Portal\Mileage\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
App\Models\User
;
class
AuditQuery
extends
Model
{
protected
$table
=
'audit_query'
;
protected
$fillable
=
[
'fk_main'
,
'user_id'
,
'comment'
,
'response'
,
];
public
function
claim
()
{
return
$this
->
belongsTo
(
MileageClaimMain
::
class
,
'fk_main'
);
}
public
function
hod
()
{
return
$this
->
belongsTo
(
User
::
class
,
'user_id'
);
}
}
packages/portal/mileage/src/Model/MileageClaimAttachment.php
0 → 100644
View file @
93a00a5e
<?php
namespace
Portal\Mileage\Model
;
use
Illuminate\Database\Eloquent\Model
;
class
MileageClaimAttachment
extends
Model
{
protected
$table
=
'mileage_claim_attachments'
;
protected
$fillable
=
[
'fk_main'
,
'file_name'
,
'file_path'
,
];
public
function
claim
()
{
return
$this
->
belongsTo
(
MileageClaimMain
::
class
,
'fk_main'
);
}
}
packages/portal/mileage/src/Model/MileageClaimMain.php
View file @
93a00a5e
...
...
@@ -4,6 +4,7 @@
use
App\Models\User
;
use
Illuminate\Database\Eloquent\Model
;
use
Portal\Mileage\Model\AuditQuery
;
class
MileageClaimMain
extends
Model
{
...
...
@@ -25,6 +26,7 @@ class MileageClaimMain extends Model
'mm_approved_by'
,
'mm_approved_date'
,
'status'
,
'query_status'
,
];
protected
static
function
boot
()
...
...
@@ -87,4 +89,16 @@ public function details()
{
return
$this
->
hasMany
(
MileageClaimDetail
::
class
,
'fk_mileage_claim_main'
);
}
public
function
auditQueries
()
{
return
$this
->
hasMany
(
AuditQuery
::
class
,
'fk_main'
);
}
public
function
attachments
()
{
return
$this
->
hasMany
(
MileageClaimAttachment
::
class
,
'fk_main'
);
}
}
packages/portal/mileage/src/ServiceProvider.php
View file @
93a00a5e
...
...
@@ -85,56 +85,62 @@ protected function menu()
->
data
(
'icon'
,
'home'
)
->
active
(
'home/*'
);
$menu
->
add
(
__
(
'Project Manager Dashboard'
),
route
(
'mileage::projectManager.index'
))
->
data
(
'icon'
,
'briefcase'
)
->
active
(
'projectManager/*'
)
->
data
(
'permission'
,
Permission
::
PROJECT_MANAGER
);
$menu
=
$menus
->
add
(
__
(
'Senarai Permohonan'
))
->
data
(
'icon'
,
'align justify'
);
$menu
->
add
(
__
(
'Senarai Permohonan Mileage Claim'
),
route
(
'mileage::mileage.listmileage'
))
->
data
(
'icon'
,
'bars'
)
->
active
(
'mileage/*'
);
// $menu->add(__('Project Manager Dashboard'), route('mileage::projectManager.index'))
// ->data('icon', 'briefcase')
// ->active('projectManager/*')
// ->data('permission', Permission::PROJECT_MANAGER);
$menu
->
add
(
__
(
'Project Director Dashboard'
),
route
(
'mileage::projectDirector.index'
))
->
data
(
'icon'
,
'compass'
)
->
active
(
'projectDirector/*'
)
->
data
(
'permission'
,
Permission
::
PROJECT_DIRECTOR
);
//
$menu->add(__('Project Director Dashboard'), route('mileage::projectDirector.index'))
//
->data('icon', 'compass')
//
->active('projectDirector/*')
//
->data('permission', Permission::PROJECT_DIRECTOR);
$menu
->
add
(
__
(
'HOD Dashboard'
),
route
(
'mileage::HOD.index'
))
->
data
(
'icon'
,
'black tie'
)
->
active
(
'HOD/*'
)
->
data
(
'permission'
,
Permission
::
HOD
);
$menu
->
add
(
__
(
'BOD Dashboard'
),
route
(
'mileage::BOD.index'
))
->
data
(
'icon'
,
'users cog'
)
->
active
(
'BOD/*'
)
->
data
(
'permission'
,
Permission
::
BOD
);
$menu
->
add
(
__
(
'HR Dashboard'
),
route
(
'mileage::HR
.index'
))
->
data
(
'icon'
,
'id badge
'
)
->
active
(
'HR
/*'
)
->
data
(
'permission'
,
Permission
::
HR
);
// $menu->add(__('BOD Dashboard'), route('mileage::BOD
.index'))
// ->data('icon', 'users cog
')
// ->active('BOD
/*')
// ->data('permission', Permission::BOD
);
$menu
->
add
(
__
(
'Finance Dashboard'
),
route
(
'mileage::finance
.index'
))
->
data
(
'icon'
,
'calculator
'
)
->
active
(
'finance
/*'
)
->
data
(
'permission'
,
Permission
::
FINANCE
);
// $menu->add(__('HR Dashboard'), route('mileage::HR
.index'))
// ->data('icon', 'id badge
')
// ->active('HR
/*')
// ->data('permission', Permission::HR
);
$menu
=
$menus
->
add
(
__
(
'Borang Permohonan Mileage Claim'
))
->
data
(
'icon'
,
'align justify'
);
// $menu->add(__('Finance Dashboard'), route('mileage::finance.index'))
// ->data('icon', 'calculator')
// ->active('finance/*')
// ->data('permission', Permission::FINANCE);
$now
=
Carbon
::
today
()
->
format
(
'Y-m-d
'
);
// $menu = $menus->add(__('Borang Permohonan Mileage Claim'))->data('icon', 'align justify
');
$menu
->
add
(
__
(
'Bawah Projek'
),
route
(
'mileage::applyform.index'
))
->
data
(
'icon'
,
'check'
)
->
active
(
'applyform/*'
);
// $now = Carbon::today()->format('Y-m-d');
$menu
->
add
(
__
(
'Tiada Projek'
),
route
(
'mileage::applyform.noproject
'
))
->
data
(
'icon'
,
'close
'
)
->
active
(
'noproject
/*'
);
// $menu->add(__('Bawah Projek'), route('mileage::applyform.index
'))
// ->data('icon', 'check
')
// ->active('applyform
/*');
$menu
=
$menus
->
add
(
__
(
'Senarai Permohonan'
))
->
data
(
'icon'
,
'align justify'
);
$menu
->
add
(
__
(
'Senarai Permohonan Mileage Claim'
),
route
(
'mileage::applications.index'
))
->
data
(
'icon'
,
'bars'
)
->
active
(
'applications/*'
);
// $menu->add(__('Tiada Projek'), route('mileage::applyform.noproject'))
// ->data('icon', 'close')
// ->active('noproject/*');
// $menu = $menus->add(__('Senarai Permohonan'))->data('icon', 'align justify');
// $menu->add(__('Senarai Permohonan Mileage Claim'), route('mileage::applications.index'))
// ->data('icon', 'bars')
// ->active('applications/*');
$menu
->
add
(
__
(
'Senarai Tuntutan Saya'
),
route
(
'mileage::applications.senarai'
))
->
data
(
'icon'
,
'list alternate'
)
->
active
(
'applications/senarai'
);
//
$menu->add(__('Senarai Tuntutan Saya'), route('mileage::applications.senarai'))
//
->data('icon', 'list alternate')
//
->active('applications/senarai');
});
...
...
packages/portal/overtime/src/ServiceProvider.php
View file @
93a00a5e
...
...
@@ -32,7 +32,7 @@ class ServiceProvider extends BaseServiceProvider
* @var array
*/
protected
$listen
=
[
\Portal\Overtime\Events\NotifyEmail
::
class
=>
[
\Portal\Overtime\Handlers\Events\SentEmail
::
class
],
...
...
@@ -79,15 +79,15 @@ public function boot()
protected
function
menu
()
{
app
(
'laravolt.menu.sidebar'
)
->
register
(
function
(
\Lavary\Menu\Builder
$menus
)
app
(
'laravolt.menu.sidebar'
)
->
register
(
function
(
\Lavary\Menu\Builder
$menus
)
{
$menu
=
$menus
->
add
(
__
(
'Tuntutan Lebih Masa'
))
->
data
(
'icon'
,
'align justify'
);
$menu
->
add
(
__
(
'Senarai Permohonan '
),
url
(
'/overtime/list'
))
->
data
(
'icon'
,
'home'
)
->
active
(
'overtime/*'
);
//
$menu = $menus->add(__('Tuntutan Lebih Masa'))->data('icon', 'align justify');
//
$menu->add(__('Senarai Permohonan '), url('/overtime/list'))
//
->data('icon', 'home')
//
->active('overtime/*');
// ->data('permission', Permission::PROJECT_MANAGER);
});
}
}
\ No newline at end of file
}
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