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
1edc8a00
Commit
1edc8a00
authored
Jun 19, 2026
by
Muhammad Iz'aan bin suhaimi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
second commit for mileage claim system
parent
2b6dcc3b
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
426 additions
and
58 deletions
+426
-58
database/migrations/2026_06_19_030729_create_lkp_mileage_task_table.php
+33
-0
database/migrations/2026_06_19_030822_create_mileage_claim_audit_trail_table.php
+35
-0
database/seeders/LkpMileageTaskSeeder.php
+18
-0
database/seeders/LkpStatusMileageSeeder.php
+25
-0
packages/portal/mileage/resources/views/mileage/audit-trail.blade.php
+53
-0
packages/portal/mileage/resources/views/mileage/form.blade.php
+46
-24
packages/portal/mileage/resources/views/mileage/list.blade.php
+88
-26
packages/portal/mileage/routes/web.php
+2
-0
packages/portal/mileage/src/Data/Repo/MileageRepo.php
+72
-5
packages/portal/mileage/src/Http/Controllers/MileageController.php
+17
-2
packages/portal/mileage/src/Model/LkpMileageTask.php
+12
-0
packages/portal/mileage/src/Model/MileageClaimAuditTrail.php
+22
-0
packages/portal/mileage/src/Model/MileageClaimMain.php
+3
-1
No files found.
database/migrations/2026_06_19_030729_create_lkp_mileage_task_table.php
0 → 100644
View file @
1edc8a00
<?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
(
'lkp_mileage_task'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'description'
);
$table
->
integer
(
'status'
)
->
default
(
1
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'lkp_mileage_task'
);
}
};
database/migrations/2026_06_19_030822_create_mileage_claim_audit_trail_table.php
0 → 100644
View file @
1edc8a00
<?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_audit_trail'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
integer
(
'fk_lkp_mileage_task'
);
$table
->
integer
(
'fk_mileage_claim_main'
);
$table
->
integer
(
'action_by'
);
$table
->
text
(
'remark'
)
->
nullable
();
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'mileage_claim_audit_trail'
);
}
};
database/seeders/LkpMileageTaskSeeder.php
0 → 100644
View file @
1edc8a00
<?php
namespace
Database\Seeders
;
use
Illuminate\Database\Seeder
;
use
Illuminate\Support\Facades\DB
;
class
LkpMileageTaskSeeder
extends
Seeder
{
public
function
run
()
{
DB
::
table
(
'lkp_mileage_task'
)
->
insert
([
[
'id'
=>
1
,
'description'
=>
'Tambah Permohonan'
,
'status'
=>
1
,
'created_at'
=>
now
(),
'updated_at'
=>
now
()],
[
'id'
=>
2
,
'description'
=>
'Tambah Butiran'
,
'status'
=>
1
,
'created_at'
=>
now
(),
'updated_at'
=>
now
()],
[
'id'
=>
3
,
'description'
=>
'Padam Butiran'
,
'status'
=>
1
,
'created_at'
=>
now
(),
'updated_at'
=>
now
()],
]);
}
}
database/seeders/LkpStatusMileageSeeder.php
0 → 100644
View file @
1edc8a00
<?php
namespace
Database\Seeders
;
use
Illuminate\Database\Seeder
;
use
Illuminate\Support\Facades\DB
;
class
LkpStatusMileageSeeder
extends
Seeder
{
public
function
run
()
{
DB
::
table
(
'lkp_status'
)
->
insert
([
[
'module'
=>
'mileage'
,
'ref_id'
=>
1
,
'description'
=>
'Draf'
,
'status'
=>
1
],
[
'module'
=>
'mileage'
,
'ref_id'
=>
2
,
'description'
=>
'Permohonan Baharu'
,
'status'
=>
1
],
[
'module'
=>
'mileage'
,
'ref_id'
=>
3
,
'description'
=>
'Permohonan Semula'
,
'status'
=>
1
],
[
'module'
=>
'mileage'
,
'ref_id'
=>
4
,
'description'
=>
'Batal Permohonan'
,
'status'
=>
1
],
[
'module'
=>
'mileage'
,
'ref_id'
=>
5
,
'description'
=>
'Disemak Oleh Project Manager'
,
'status'
=>
1
],
[
'module'
=>
'mileage'
,
'ref_id'
=>
6
,
'description'
=>
'Dikuiri Oleh Project Manager'
,
'status'
=>
1
],
[
'module'
=>
'mileage'
,
'ref_id'
=>
7
,
'description'
=>
'Disokong Oleh HOD'
,
'status'
=>
1
],
[
'module'
=>
'mileage'
,
'ref_id'
=>
8
,
'description'
=>
'Dikuiri Oleh HOD'
,
'status'
=>
1
],
[
'module'
=>
'mileage'
,
'ref_id'
=>
9
,
'description'
=>
'Diluluskan Oleh BOD'
,
'status'
=>
1
],
[
'module'
=>
'mileage'
,
'ref_id'
=>
10
,
'description'
=>
'Dikuiri Oleh BOD'
,
'status'
=>
1
],
]);
}
}
packages/portal/mileage/resources/views/mileage/audit-trail.blade.php
0 → 100644
View file @
1edc8a00
@
extends
(
'ui::layouts.app'
)
@
section
(
'content'
)
<
div
class
="
ui
segment
">
<a class="
ui
violet
left
ribbon
label
">Audit Trail Tuntutan Mileage</a><br/>
<div class="
ui
segment
">
@if(session('success'))
<div class="
ui
success
message
">{{ session('success') }}</div>
@endif
<form method="
GET
" action="
{{
route
(
'mileage::mileage.audit-trail'
)
}}
" class="
ui
form
" style="
margin
-
bottom
:
1
rem
;
">
<div class="
ui
action
input
">
<input type="
text
" name="
search
" value="
{{
request
(
'search'
)
}}
" placeholder="
Cari
rekod
audit
...
">
<button type="
submit
" class="
ui
violet
button
">Cari</button>
@if(request('search'))
<a href="
{{
route
(
'mileage::mileage.audit-trail'
)
}}
" class="
ui
button
">Reset</a>
@endif
</div>
</form>
<table class="
ui
celled
striped
table
">
<thead>
<tr>
<th>No</th>
<th>Tindakan</th>
<th>Catatan</th>
<th>Tarikh</th>
</tr>
</thead>
<tbody>
@forelse(
$auditTrail
as
$index
=>
$log
)
<tr>
<td>{{
$auditTrail->firstItem
() +
$index
}}</td>
<td>{{
$log->task
?->description ?? '-' }}</td>
<td>{{
$log->remark
}}</td>
<td>{{ \Carbon\Carbon::parse(
$log->created_at
)->format('d/m/Y H:i:s') }}</td>
</tr>
@empty
<tr>
<td colspan="
4
" class="
center
aligned
">Tiada rekod audit.</td>
</tr>
@endforelse
</tbody>
</table>
{{
$auditTrail->withQueryString
()->links() }}
</div>
</div>
@endsection
packages/portal/mileage/resources/views/mileage/form.blade.php
View file @
1edc8a00
...
@@ -23,9 +23,10 @@
...
@@ -23,9 +23,10 @@
<th>Tarikh</th>
<th>Tarikh</th>
<th>Kenderaan</th>
<th>Kenderaan</th>
<th>Projek</th>
<th>Projek</th>
<th>Jumlah Jarak (KM)</th>
<th>Butiran</th>
<th>Jumlah Perbelanjaan (RM)</th>
<th class="
right
aligned
">Jumlah Jarak (KM)</th>
<th>Anggaran Tuntutan (RM)</th>
<th class="
right
aligned
">Jumlah Perbelanjaan (RM)</th>
<th class="
right
aligned
">Anggaran Tuntutan (RM)</th>
<th>Tindakan</th>
<th>Tindakan</th>
</tr>
</tr>
</thead>
</thead>
...
@@ -54,10 +55,10 @@
...
@@ -54,10 +55,10 @@
<td>{{
$index
+ 1 }}</td>
<td>{{
$index
+ 1 }}</td>
<td>{{ \Carbon\Carbon::parse(
$detail->md_claim_date
)->format('d/m/Y') }}</td>
<td>{{ \Carbon\Carbon::parse(
$detail->md_claim_date
)->format('d/m/Y') }}</td>
<td>{{
$detail->jenisKenderaan
?->name ?? '-' }}</td>
<td>{{
$detail->jenisKenderaan
?->name ?? '-' }}</td>
<td>{{
$detail->project
?->p_project_description ?? '-' }}
</td>
<td>{{
$detail->project
?
$detail->project
->p_project_code . ' - ' .
$detail->project
->p_project_description : 'Tiada Projek' }}</td> <td>{{
$detail->md_description
}}
</td>
<td>{{ number_format(
$jumlahJarak
, 1) }}</td>
<td
class="
right
aligned
"
>{{ number_format(
$jumlahJarak
, 1) }}</td>
<td
>{{ number_format(
$jumlahBelanja
, 2) }}</td>
<td class="
right
aligned
"
>{{ number_format(
$jumlahBelanja
, 2) }}</td>
<td
>{{ number_format(
$anggaranTuntutan
, 2) }}</td>
<td class="
right
aligned
"
>{{ number_format(
$anggaranTuntutan
, 2) }}</td>
<td>
<td>
<form action="
{{
route
(
'mileage::mileage.claim.detail.destroy'
,
[
'id'
=>
$detail
->
id
])
}}
" method="
POST
" onsubmit="
return
confirm
(
'Padam butiran ini?'
);
" style="
display
:
inline
;
">
<form action="
{{
route
(
'mileage::mileage.claim.detail.destroy'
,
[
'id'
=>
$detail
->
id
])
}}
" method="
POST
" onsubmit="
return
confirm
(
'Padam butiran ini?'
);
" style="
display
:
inline
;
">
@csrf
@csrf
...
@@ -74,29 +75,37 @@
...
@@ -74,29 +75,37 @@
</tbody>
</tbody>
@if(
$claim->details
->count() > 0)
@if(
$claim->details
->count() > 0)
<tfoot>
<tfoot>
<tr>
<tr>
<th colspan="
6
" class="
right
aligned
">JUMLAH KESELURUHAN ANGGARAN TUNTUTAN (RM)</th>
<th colspan="
7
" class="
right
aligned
">JUMLAH KESELURUHAN ANGGARAN TUNTUTAN (RM)</th>
<th
>{{ number_format(
$grandAnggaran
, 2) }}</th>
<th class="
right
aligned
"
>{{ number_format(
$grandAnggaran
, 2) }}</th>
<th></th>
<th></th>
</tr>
</tr>
</tfoot>
</tfoot>
@endif
@endif
</table>
</table>
</div>
</div>
{{-- Segment 2: Tambah butiran --}}
{{-- Segment 2: Tambah butiran --}}
<div class="
ui
segment
">
<div class="
ui
segment
">
<h3 class="
ui
header
">Tambah Butiran Tuntutan</h3>
<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
])
}}
">
<form class="
ui
form
" method="
POST
" action="
{{
route
(
'mileage::mileage.claim.detail.store'
,
[
'id'
=>
$claim
->
id
])
}}
">
@csrf
@csrf
<div class="
two
fields
">
<div class="
two
fields
">
<div class="
field
">
<div class="
field
">
<label>Tarikh</label>
<label>Tarikh</label>
<input type="
date
" name="
md_claim_date
" required>
<input type="
date
" name="
md_claim_date
"
min="
{{
$minDate
}}
" max="
{{
$maxDate
}}
"
required>
</div>
</div>
<div class="
field
">
<div class="
field
">
<label>Jenis Kenderaan</label>
<label>Jenis Kenderaan</label>
<select name="
fk_lkp_jenis_kenderaan
" class="
ui
dropdown
" required>
<select name="
fk_lkp_jenis_kenderaan
" class="
ui
dropdown
" required>
...
@@ -112,11 +121,13 @@
...
@@ -112,11 +121,13 @@
<div class="
field
">
<div class="
field
">
<label>Projek</label>
<label>Projek</label>
<select name="
fk_lkp_project
" class="
ui
search
selection
dropdown
">
<select name="
fk_lkp_project
" class="
ui
search
selection
dropdown
">
<option value="">-- Tiada Projek --</option>
<option value="">Tiada Projek</option>
@foreach(
$projects
as
$project
)
@foreach(
$projects
as
$project
)
<option value="
{{
$project
->
id
}}
">{{
$project->p_project_description
}}</option>
<option value="
{{
$project
->
id
}}
">
@endforeach
{{
$project->p_project_code
}} - {{
$project->p_project_description
}}
</select>
</option>
@endforeach
</select>
</div>
</div>
<div class="
field
">
<div class="
field
">
<label>Butiran</label>
<label>Butiran</label>
...
@@ -151,14 +162,22 @@
...
@@ -151,14 +162,22 @@
</div>
</div>
</div>
</div>
<br>
<button type="
submit
" class="
ui
primary
button
">Tambah Butiran</button>
<button type="
submit
" class="
ui
right
floated
primary
button
">Tambah Butiran</button>
</form>
<div style="
clear
:
both
"></div>
</form>
</div>
</div>
<a href="
{{
route
(
'mileage::mileage.listmileage'
)
}}
" class="
ui
button
">
<br>
<a href="
{{
route
(
'mileage::mileage.listmileage'
)
}}
" class="
ui
right
floated
button
">
<i class="
arrow
left
icon
"></i> Kembali ke Senarai
<i class="
arrow
left
icon
"></i> Kembali ke Senarai
</a>
</a>
<div style="
clear
:
both
"></div>
<br>
</div>
</div>
@endsection
@endsection
...
@@ -167,6 +186,9 @@
...
@@ -167,6 +186,9 @@
<script>
<script>
$(document).ready(function () {
$(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);
});
});
</script>
</script>
@endpush
@endpush
...
...
packages/portal/mileage/resources/views/mileage/list.blade.php
View file @
1edc8a00
...
@@ -7,6 +7,11 @@
...
@@ -7,6 +7,11 @@
{
{
text
-
transform
:
uppercase
;
text
-
transform
:
uppercase
;
}
}
.
ui
.
dropdown
.
menu
.
item
.
disabled
{
font
-
style
:
italic
!
important
;
opacity
:
0.7
!
important
;
}
</
style
>
</
style
>
<
div
class
="
ui
segment
">
<
div
class
="
ui
segment
">
...
@@ -23,6 +28,9 @@
...
@@ -23,6 +28,9 @@
<button type="
button
" class="
ui
right
floated
primary
button
" onclick="
$
(
'#modalPermohonanBaharu'
)
.
modal
(
'show'
)
">
<button type="
button
" class="
ui
right
floated
primary
button
" onclick="
$
(
'#modalPermohonanBaharu'
)
.
modal
(
'show'
)
">
Permohonan Baharu
Permohonan Baharu
</button>
</button>
<a href="
{{
route
(
'mileage::mileage.audit-trail'
)
}}
" class="
ui
right
floated
button
">
Audit Trail
</a>
<br/>
<br/>
<div class="
column
sixteen
wide
table
-
uppercase
">
<div class="
column
sixteen
wide
table
-
uppercase
">
...
@@ -54,21 +62,24 @@
...
@@ -54,21 +62,24 @@
: '-';
: '-';
}],
}],
['header' => __('Status'), 'raw' => function(
$row
){
['header' => __('Status'), 'raw' => function(
$row
){
$status
=
$row->lkpStatus
?->description ?? 'Draf';
$status
=
$row->lkpStatus
?->description ?? 'Draf';
$refId
=
$row->lkpStatus
?->ref_id ?? 0;
$color
= match(
$status
) {
'Draf' => 'grey',
$color
= match(
$refId
) {
'Diproses' => 'blue',
1 => 'grey',
'Disokong' => 'green',
2 => 'blue',
'Disahkan' => 'olive',
3 => 'yellow',
'Disemak' => 'purple',
4 => 'red',
'Dibayar' => 'teal',
5 => 'olive',
'Ditolak' => 'red',
6, 8, 10 => 'orange',
default => 'grey',
7 => 'teal',
};
9 => 'green',
default => 'grey',
return '<span class="
ui
' . $color . '
label
">' .
$status
. '</span>';
};
}],
return '<span class="
ui
' . $color . '
label
">' .
$status
. '</span>';
}],
['header' => __('Tindakan'), 'raw' => function(
$row
){
['header' => __('Tindakan'), 'raw' => function(
$row
){
$url
= route('mileage::mileage.claim.form', ['id' =>
$row->id
]);
$url
= route('mileage::mileage.claim.form', ['id' =>
$row->id
]);
...
@@ -100,6 +111,16 @@
...
@@ -100,6 +111,16 @@
@csrf
@csrf
<div class="field">
<div class="field">
<label>Tahun Tuntutan</label>
<select name="mm_claim_year" class="ui dropdown" required>
<option value="">-- Pilih Tahun --</option>
@for($y = now()->year; $y >= now()->year - 2; $y--)
<option value="{{ $y }}" {{ now()->year == $y ? '
selected
' : '' }}>{{ $y }}</option>
@endfor
</select>
</div>
<div class="field">
<label>Bulan Tuntutan</label>
<label>Bulan Tuntutan</label>
<select name="mm_claim_month" class="ui dropdown" required>
<select name="mm_claim_month" class="ui dropdown" required>
<option value="">-- Pilih Bulan --</option>
<option value="">-- Pilih Bulan --</option>
...
@@ -108,21 +129,12 @@
...
@@ -108,21 +129,12 @@
5 => '
Mei
', 6 => '
Jun
', 7 => '
Julai
', 8 => '
Ogos
',
5 => '
Mei
', 6 => '
Jun
', 7 => '
Julai
', 8 => '
Ogos
',
9 => '
September
', 10 => '
Oktober
', 11 => '
November
', 12 => '
Disember
',
9 => '
September
', 10 => '
Oktober
', 11 => '
November
', 12 => '
Disember
',
] as $value => $label)
] as $value => $label)
<option value="{{ $value }}"
{{ now()->month == $value ? '
selected
' : '' }}
>{{ $label }}</option>
<option value="{{ $value }}">{{ $label }}</option>
@endforeach
@endforeach
</select>
</select>
</div>
</div>
<div class="field">
<div class="field">
<label>Tahun Tuntutan</label>
<select name="mm_claim_year" class="ui dropdown" required>
@for($y = now()->year; $y >= now()->year - 2; $y--)
<option value="{{ $y }}" {{ now()->year == $y ? '
selected
' : '' }}>{{ $y }}</option>
@endfor
</select>
</div>
<div class="field">
<label>Kategori FA</label>
<label>Kategori FA</label>
<select name="fk_lkp_fa_category" class="ui dropdown" required>
<select name="fk_lkp_fa_category" class="ui dropdown" required>
<option value="">-- Pilih Kategori --</option>
<option value="">-- Pilih Kategori --</option>
...
@@ -132,7 +144,6 @@
...
@@ -132,7 +144,6 @@
</select>
</select>
</div>
</div>
</form>
</form>
</div>
</div>
<div class="actions">
<div class="actions">
...
@@ -150,6 +161,57 @@
...
@@ -150,6 +161,57 @@
$(document).ready(function () {
$(document).ready(function () {
$('
.
ui
.
dropdown
').dropdown();
$('
.
ui
.
dropdown
').dropdown();
$('
#modalPermohonanBaharu').modal();
$('
#modalPermohonanBaharu').modal();
var
usedMonths
=
@
json
(
$usedMonths
);
var
monthNames
=
{
1
:
'Januari'
,
2
:
'Februari'
,
3
:
'Mac'
,
4
:
'April'
,
5
:
'Mei'
,
6
:
'Jun'
,
7
:
'Julai'
,
8
:
'Ogos'
,
9
:
'September'
,
10
:
'Oktober'
,
11
:
'November'
,
12
:
'Disember'
};
function
updateMonthOptions
(
year
)
{
if
(
!
year
)
return
;
var
$select
=
$
(
'select[name="mm_claim_month"]'
);
var
$field
=
$select
.
closest
(
'.field'
);
// Clear current selection
$select
.
val
(
''
);
$field
.
find
(
'.text'
)
.
addClass
(
'default'
)
.
text
(
'-- Pilih Bulan --'
);
$select
.
find
(
'option'
)
.
each
(
function
()
{
var
val
=
$
(
this
)
.
val
();
if
(
!
val
)
return
;
var
key
=
val
+
'-'
+
year
;
var
label
=
monthNames
[
parseInt
(
val
)]
||
val
;
// Target Semantic UI's generated <div class="item"> directly
var
$item
=
$field
.
find
(
'.menu .item[data-value="'
+
val
+
'"]'
);
if
(
usedMonths
.
includes
(
key
))
{
$
(
this
)
.
prop
(
'disabled'
,
true
)
.
text
(
label
+
' (Permohonan sudah dibuat)'
);
$item
.
addClass
(
'disabled'
)
.
text
(
label
+
' (Permohonan sudah dibuat)'
);
}
else
{
$
(
this
)
.
prop
(
'disabled'
,
false
)
.
text
(
label
);
$item
.
removeClass
(
'disabled'
)
.
text
(
label
);
}
});
}
// Use Semantic UI's own onChange (more reliable than jQuery 'change' on hidden selects)
$
(
'select[name="mm_claim_year"]'
)
.
dropdown
(
'setting'
,
'onChange'
,
function
(
value
)
{
updateMonthOptions
(
value
);
});
// Run immediately for the pre-selected current year
updateMonthOptions
(
'{{ now()->year }}'
);
});
});
</
script
>
</
script
>
@
endpush
@
endpush
packages/portal/mileage/routes/web.php
View file @
1edc8a00
...
@@ -101,6 +101,8 @@ function () {
...
@@ -101,6 +101,8 @@ function () {
Route
::
post
(
'claim/{id}/detail/store'
,
[
'uses'
=>
'MileageController@storeDetail'
,
'as'
=>
'mileage.claim.detail.store'
]);
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
::
delete
(
'claim/detail/{id}/destroy'
,
[
'uses'
=>
'MileageController@destroyDetail'
,
'as'
=>
'mileage.claim.detail.destroy'
]);
Route
::
get
(
'audit-trail'
,
[
'uses'
=>
'MileageController@getAuditTrail'
,
'as'
=>
'mileage.audit-trail'
]);
}
}
);
);
...
...
packages/portal/mileage/src/Data/Repo/MileageRepo.php
View file @
1edc8a00
...
@@ -7,8 +7,10 @@
...
@@ -7,8 +7,10 @@
use
Portal\Mileage\Model\Project
;
use
Portal\Mileage\Model\Project
;
use
Portal\Mileage\Model\StaffInfo
;
use
Portal\Mileage\Model\StaffInfo
;
use
Portal\Mileage\Model\LkpFaCategory
;
use
Portal\Mileage\Model\LkpFaCategory
;
use
Portal\Mileage\Model\MileageClaimAuditTrail
;
use
Illuminate\Support\Facades\Auth
;
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
use
Illuminate\Support\Collection
;
use
Illuminate\Support\Collection
;
...
@@ -16,7 +18,6 @@
...
@@ -16,7 +18,6 @@
use
Carbon\Carbon
;
use
Carbon\Carbon
;
use
App\Events\AuditLog
;
use
App\Events\AuditLog
;
use
Auth
;
use
DB
;
use
DB
;
use
Event
;
use
Event
;
use
File
;
use
File
;
...
@@ -58,7 +59,7 @@ public function mileageList($request)
...
@@ -58,7 +59,7 @@ public function mileageList($request)
return
$data
;
return
$data
;
}
}
public
function
storeClaim
(
$request
)
public
function
storeClaim
(
$request
)
{
{
$staff
=
StaffInfo
::
where
(
'fk_users'
,
Auth
::
id
())
->
first
();
$staff
=
StaffInfo
::
where
(
'fk_users'
,
Auth
::
id
())
->
first
();
...
@@ -69,12 +70,21 @@ public function storeClaim($request)
...
@@ -69,12 +70,21 @@ public function storeClaim($request)
'mm_claim_year'
=>
$request
->
mm_claim_year
,
'mm_claim_year'
=>
$request
->
mm_claim_year
,
'fk_lkp_fa_category'
=>
$request
->
fk_lkp_fa_category
,
'fk_lkp_fa_category'
=>
$request
->
fk_lkp_fa_category
,
'mm_submit_date'
=>
now
(),
'mm_submit_date'
=>
now
(),
'status'
=>
1
,
]);
]);
MileageClaimAuditTrail
::
create
([
'fk_lkp_mileage_task'
=>
1
,
// Assuming 1 is the ID for "Tambah Permohonan"
'fk_mileage_claim_main'
=>
$claim
->
id
,
'action_by'
=>
Auth
::
id
(),
'remark'
=>
Auth
::
user
()
->
name
.
' Telah Tambah Permohonan Mileage (mileage_claim_main.id = '
.
$claim
->
id
.
')'
,
]);
return
$claim
->
id
;
return
$claim
->
id
;
}
}
public
function
findClaim
(
$id
)
public
function
findClaim
(
$id
)
{
{
return
MileageClaimMain
::
with
(
'details'
)
->
findOrFail
(
$id
);
return
MileageClaimMain
::
with
(
'details'
)
->
findOrFail
(
$id
);
...
@@ -87,9 +97,12 @@ public function getJenisKenderaan()
...
@@ -87,9 +97,12 @@ public function getJenisKenderaan()
public
function
getProjects
()
public
function
getProjects
()
{
{
return
Project
::
orderBy
(
'p_project_description'
)
->
get
();
return
Project
::
where
(
'p_project_sts'
,
1
)
->
orderBy
(
'p_project_code'
)
->
get
();
}
}
public
function
getFaCategories
()
public
function
getFaCategories
()
{
{
return
LkpFaCategory
::
orderBy
(
'id'
)
->
get
();
return
LkpFaCategory
::
orderBy
(
'id'
)
->
get
();
...
@@ -98,10 +111,10 @@ public function getFaCategories()
...
@@ -98,10 +111,10 @@ public function getFaCategories()
public
function
storeDetail
(
$request
,
$id
)
public
function
storeDetail
(
$request
,
$id
)
{
{
return
MileageClaimDetail
::
create
([
$detail
=
MileageClaimDetail
::
create
([
'fk_mileage_claim_main'
=>
$id
,
'fk_mileage_claim_main'
=>
$id
,
'fk_lkp_jenis_kenderaan'
=>
$request
->
fk_lkp_jenis_kenderaan
,
'fk_lkp_jenis_kenderaan'
=>
$request
->
fk_lkp_jenis_kenderaan
,
'fk_lkp_project'
=>
$request
->
fk_lkp_project
,
'fk_lkp_project'
=>
$request
->
fk_lkp_project
??
null
,
'md_claim_date'
=>
$request
->
md_claim_date
,
'md_claim_date'
=>
$request
->
md_claim_date
,
'md_description'
=>
$request
->
md_description
,
'md_description'
=>
$request
->
md_description
,
'md_distance_from'
=>
$request
->
md_distance_from
,
'md_distance_from'
=>
$request
->
md_distance_from
,
...
@@ -110,13 +123,67 @@ public function storeDetail($request, $id)
...
@@ -110,13 +123,67 @@ public function storeDetail($request, $id)
'md_total_toll'
=>
$request
->
md_total_toll
??
0
,
'md_total_toll'
=>
$request
->
md_total_toll
??
0
,
'md_total_parking_fee'
=>
$request
->
md_total_parking_fee
??
0
,
'md_total_parking_fee'
=>
$request
->
md_total_parking_fee
??
0
,
]);
]);
MileageClaimAuditTrail
::
create
([
'fk_lkp_mileage_task'
=>
2
,
'fk_mileage_claim_main'
=>
$id
,
'action_by'
=>
Auth
::
id
(),
'remark'
=>
Auth
::
user
()
->
name
.
' Telah Tambah Butiran Tuntutan (mileage_claim_detail.id = '
.
$detail
->
id
.
')'
,
]);
return
$detail
;
}
}
public
function
destroyDetail
(
$id
)
public
function
destroyDetail
(
$id
)
{
{
$detail
=
MileageClaimDetail
::
findOrFail
(
$id
);
$detail
=
MileageClaimDetail
::
findOrFail
(
$id
);
$mainId
=
$detail
->
fk_mileage_claim_main
;
$detail
->
delete
();
$detail
->
delete
();
MileageClaimAuditTrail
::
create
([
'fk_lkp_mileage_task'
=>
3
,
'fk_mileage_claim_main'
=>
$mainId
,
'action_by'
=>
Auth
::
id
(),
'remark'
=>
Auth
::
user
()
->
name
.
' Telah Padam Butiran Tuntutan (mileage_claim_detail.id = '
.
$id
.
')'
,
]);
return
$detail
;
return
$detail
;
}
}
public
function
getUsedMonths
()
{
$staff
=
StaffInfo
::
where
(
'fk_users'
,
Auth
::
id
())
->
first
();
if
(
!
$staff
)
return
[];
return
MileageClaimMain
::
where
(
'fk_lkp_staff_info'
,
$staff
->
id
)
->
whereNotNull
(
'mm_claim_month'
)
->
whereNotNull
(
'mm_claim_year'
)
->
get
([
'mm_claim_month'
,
'mm_claim_year'
])
->
map
(
fn
(
$row
)
=>
$row
->
mm_claim_month
.
'-'
.
$row
->
mm_claim_year
)
->
toArray
();
}
public
function
claimExists
(
$request
)
{
$staff
=
StaffInfo
::
where
(
'fk_users'
,
Auth
::
id
())
->
first
();
return
MileageClaimMain
::
where
(
'fk_lkp_staff_info'
,
$staff
->
id
??
null
)
->
where
(
'mm_claim_month'
,
$request
->
mm_claim_month
)
->
where
(
'mm_claim_year'
,
$request
->
mm_claim_year
)
->
exists
();
}
public
function
getAuditTrail
(
$request
)
{
$query
=
MileageClaimAuditTrail
::
with
(
'task'
)
->
latest
();
if
(
$request
->
filled
(
'search'
))
{
$query
->
where
(
'remark'
,
'like'
,
'%'
.
$request
->
search
.
'%'
);
}
return
$query
->
paginate
(
15
);
}
}
}
packages/portal/mileage/src/Http/Controllers/MileageController.php
View file @
1edc8a00
...
@@ -45,22 +45,29 @@ public function index(Request $request)
...
@@ -45,22 +45,29 @@ public function index(Request $request)
}
}
// mileage crud start
// mileage crud start
public
function
getListMileage
(
Request
$request
)
public
function
getListMileage
(
Request
$request
)
{
{
$list
=
$this
->
repos
->
mileageList
(
$request
);
$list
=
$this
->
repos
->
mileageList
(
$request
);
$faCategories
=
$this
->
repos
->
getFaCategories
();
$faCategories
=
$this
->
repos
->
getFaCategories
();
$usedMonths
=
$this
->
repos
->
getUsedMonths
();
return
view
(
'mileage::mileage.list'
,
compact
(
'list'
,
'faCategories'
));
return
view
(
'mileage::mileage.list'
,
compact
(
'list'
,
'faCategories'
,
'usedMonths'
));
}
}
public
function
storeClaim
(
Request
$request
)
public
function
storeClaim
(
Request
$request
)
{
{
if
(
$this
->
repos
->
claimExists
(
$request
))
{
return
redirect
()
->
back
()
->
with
(
'error'
,
'Permohonan untuk bulan ini telah wujud.'
);
}
$id
=
$this
->
repos
->
storeClaim
(
$request
);
$id
=
$this
->
repos
->
storeClaim
(
$request
);
return
redirect
()
->
route
(
'mileage::mileage.claim.form'
,
[
'id'
=>
$id
]);
return
redirect
()
->
route
(
'mileage::mileage.claim.form'
,
[
'id'
=>
$id
]);
}
}
public
function
formClaim
(
Request
$request
,
$id
)
public
function
formClaim
(
Request
$request
,
$id
)
{
{
$claim
=
$this
->
repos
->
findClaim
(
$id
);
$claim
=
$this
->
repos
->
findClaim
(
$id
);
...
@@ -86,4 +93,12 @@ public function destroyDetail(Request $request, $id)
...
@@ -86,4 +93,12 @@ public function destroyDetail(Request $request, $id)
->
with
(
'success'
,
'Butiran tuntutan berjaya dipadam.'
);
->
with
(
'success'
,
'Butiran tuntutan berjaya dipadam.'
);
}
}
public
function
getAuditTrail
(
Request
$request
)
{
$auditTrail
=
$this
->
repos
->
getAuditTrail
(
$request
);
return
view
(
'mileage::mileage.audit-trail'
,
compact
(
'auditTrail'
));
}
}
}
packages/portal/mileage/src/Model/LkpMileageTask.php
0 → 100644
View file @
1edc8a00
<?php
namespace
Portal\Mileage\Model
;
use
Illuminate\Database\Eloquent\Model
;
class
LkpMileageTask
extends
Model
{
protected
$table
=
'lkp_mileage_task'
;
protected
$fillable
=
[
'description'
,
'status'
];
}
packages/portal/mileage/src/Model/MileageClaimAuditTrail.php
0 → 100644
View file @
1edc8a00
<?php
namespace
Portal\Mileage\Model
;
use
Illuminate\Database\Eloquent\Model
;
class
MileageClaimAuditTrail
extends
Model
{
protected
$table
=
'mileage_claim_audit_trail'
;
protected
$fillable
=
[
'fk_lkp_mileage_task'
,
'fk_mileage_claim_main'
,
'action_by'
,
'remark'
,
];
public
function
task
()
{
return
$this
->
belongsTo
(
LkpMileageTask
::
class
,
'fk_lkp_mileage_task'
);
}
}
packages/portal/mileage/src/Model/MileageClaimMain.php
View file @
1edc8a00
...
@@ -68,9 +68,11 @@ public function faCategory()
...
@@ -68,9 +68,11 @@ public function faCategory()
public
function
lkpStatus
()
public
function
lkpStatus
()
{
{
return
$this
->
belongsTo
(
LkpStatus
::
class
,
'status'
);
return
$this
->
belongsTo
(
LkpStatus
::
class
,
'status'
,
'ref_id'
)
->
where
(
'module'
,
'mileage'
);
}
}
public
function
verifiedBy
()
public
function
verifiedBy
()
{
{
return
$this
->
belongsTo
(
User
::
class
,
'mm_verified_by'
);
return
$this
->
belongsTo
(
User
::
class
,
'mm_verified_by'
);
...
...
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