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
a048c923
Commit
a048c923
authored
Jun 16, 2026
by
Muhammad Iz'aan bin suhaimi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first commit - system mileage
parent
0779f4cb
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
965 additions
and
13 deletions
+965
-13
database/migrations/2026_06_11_063607_create_lkp_fa_category_table.php
+33
-0
database/migrations/2026_06_11_063633_create_mileage_claim_main_table.php
+44
-0
database/migrations/2026_06_11_063656_create_mileage_claim_detail_table.php
+41
-0
database/migrations/2026_06_12_075619_add_claim_month_year_to_mileage_claim_main_table.php
+33
-0
database/migrations/2026_06_12_084525_change_distance_columns_to_text_in_mileage_claim_detail_table.php
+32
-0
database/migrations/2026_06_13_021338_add_module_and_ref_id_to_lkp_status_table.php
+33
-0
database/seeders/LkpFaCategorySeeder.php
+24
-0
packages/portal/mileage/resources/views/mileage/form.blade.php
+173
-0
packages/portal/mileage/resources/views/mileage/list.blade.php
+155
-0
packages/portal/mileage/routes/web.php
+13
-2
packages/portal/mileage/src/Data/Repo/MileageRepo.php
+122
-0
packages/portal/mileage/src/Http/Controllers/ApplicationsController.php
+18
-1
packages/portal/mileage/src/Http/Controllers/MileageController.php
+89
-0
packages/portal/mileage/src/Model/LkpFaCategory.php
+15
-0
packages/portal/mileage/src/Model/MileageClaimDetail.php
+38
-0
packages/portal/mileage/src/Model/MileageClaimMain.php
+88
-0
packages/portal/mileage/src/ServiceProvider.php
+14
-10
No files found.
database/migrations/2026_06_11_063607_create_lkp_fa_category_table.php
0 → 100644
View file @
a048c923
<?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_fa_category'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'fa_category'
,
150
);
$table
->
integer
(
'status'
)
->
nullable
();
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'lkp_fa_category'
);
}
};
database/migrations/2026_06_11_063633_create_mileage_claim_main_table.php
0 → 100644
View file @
a048c923
<?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_main'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'mm_apply_no'
)
->
unique
();
$table
->
unsignedInteger
(
'fk_lkp_staff_info'
)
->
nullable
()
->
index
();
$table
->
string
(
'mm_staff_name'
)
->
nullable
();
$table
->
integer
(
'mm_staff_position'
)
->
nullable
();
$table
->
integer
(
'mm_staff_id'
)
->
nullable
();
$table
->
integer
(
'mm_staff_company'
)
->
nullable
();
$table
->
timestamp
(
'mm_submit_date'
)
->
nullable
();
$table
->
unsignedInteger
(
'fk_lkp_fa_category'
)
->
nullable
()
->
index
();
$table
->
unsignedInteger
(
'mm_verified_by'
)
->
nullable
()
->
index
();
$table
->
timestamp
(
'mm_verified_date'
)
->
nullable
();
$table
->
unsignedInteger
(
'mm_approved_by'
)
->
nullable
()
->
index
();
$table
->
timestamp
(
'mm_approved_date'
)
->
nullable
();
$table
->
unsignedInteger
(
'status'
)
->
nullable
()
->
index
();
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'mileage_claim_main'
);
}
};
database/migrations/2026_06_11_063656_create_mileage_claim_detail_table.php
0 → 100644
View file @
a048c923
<?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_detail'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
unsignedBigInteger
(
'fk_mileage_claim_main'
)
->
index
();
$table
->
unsignedBigInteger
(
'fk_lkp_jenis_kenderaan'
)
->
index
();
$table
->
unsignedInteger
(
'fk_lkp_project'
)
->
nullable
()
->
index
();
$table
->
timestamp
(
'md_claim_date'
);
$table
->
string
(
'md_description'
)
->
nullable
();
$table
->
float
(
'md_distance_from'
);
$table
->
float
(
'md_distance_to'
);
$table
->
float
(
'md_total_mileage'
);
$table
->
float
(
'md_total_toll'
)
->
default
(
0
);
$table
->
float
(
'md_total_parking_fee'
)
->
default
(
0
);
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'mileage_claim_detail'
);
}
};
database/migrations/2026_06_12_075619_add_claim_month_year_to_mileage_claim_main_table.php
0 → 100644
View file @
a048c923
<?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
(
'mm_claim_month'
)
->
nullable
()
->
after
(
'mm_submit_date'
);
$table
->
integer
(
'mm_claim_year'
)
->
nullable
()
->
after
(
'mm_claim_month'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
table
(
'mileage_claim_main'
,
function
(
Blueprint
$table
)
{
$table
->
dropColumn
([
'mm_claim_month'
,
'mm_claim_year'
]);
});
}
};
database/migrations/2026_06_12_084525_change_distance_columns_to_text_in_mileage_claim_detail_table.php
0 → 100644
View file @
a048c923
<?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_detail'
,
function
(
Blueprint
$table
)
{
$table
->
dropColumn
([
'md_distance_from'
,
'md_distance_to'
]);
});
Schema
::
table
(
'mileage_claim_detail'
,
function
(
Blueprint
$table
)
{
$table
->
string
(
'md_distance_from'
)
->
nullable
()
->
after
(
'md_description'
);
$table
->
string
(
'md_distance_to'
)
->
nullable
()
->
after
(
'md_distance_from'
);
});
}
public
function
down
()
{
Schema
::
table
(
'mileage_claim_detail'
,
function
(
Blueprint
$table
)
{
$table
->
dropColumn
([
'md_distance_from'
,
'md_distance_to'
]);
});
Schema
::
table
(
'mileage_claim_detail'
,
function
(
Blueprint
$table
)
{
$table
->
float
(
'md_distance_from'
)
->
after
(
'md_description'
);
$table
->
float
(
'md_distance_to'
)
->
after
(
'md_distance_from'
);
});
}
};
database/migrations/2026_06_13_021338_add_module_and_ref_id_to_lkp_status_table.php
0 → 100644
View file @
a048c923
<?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
(
'lkp_status'
,
function
(
Blueprint
$table
)
{
$table
->
string
(
'module'
)
->
nullable
()
->
after
(
'id'
);
$table
->
integer
(
'ref_id'
)
->
nullable
()
->
after
(
'module'
);
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
table
(
'lkp_status'
,
function
(
Blueprint
$table
)
{
$table
->
dropColumn
([
'module'
,
'ref_id'
]);
});
}
};
database/seeders/LkpFaCategorySeeder.php
0 → 100644
View file @
a048c923
<?php
namespace
Database\Seeders
;
use
Illuminate\Database\Seeder
;
use
Portal\Mileage\Model\LkpFaCategory
;
class
LkpFaCategorySeeder
extends
Seeder
{
public
function
run
()
{
$categories
=
[
'Employee with FA only'
,
'Employee with FA & other allowance (PM / Sales Allowance)'
,
];
foreach
(
$categories
as
$category
)
{
LkpFaCategory
::
create
([
'fa_category'
=>
$category
,
'status'
=>
1
,
]);
}
}
}
packages/portal/mileage/resources/views/mileage/form.blade.php
0 → 100644
View file @
a048c923
@
extends
(
'ui::layouts.app'
)
@
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>
<th>Jumlah Jarak (KM)</th>
<th>Jumlah Perbelanjaan (RM)</th>
<th>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
?->p_project_description ?? '-' }}</td>
<td>{{ number_format(
$jumlahJarak
, 1) }}</td>
<td>{{ number_format(
$jumlahBelanja
, 2) }}</td>
<td>{{ 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>
<tr>
<th colspan="
6
" class="
right
aligned
">JUMLAH KESELURUHAN ANGGARAN TUNTUTAN (RM)</th>
<th>{{ 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>
<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
" 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
">
<option value="">-- Tiada Projek --</option>
@foreach(
$projects
as
$project
)
<option value="
{{
$project
->
id
}}
">{{
$project->p_project_description
}}</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>
<button type="
submit
" class="
ui
primary
button
">Tambah Butiran</button>
</form>
</div>
<a href="
{{
route
(
'mileage::mileage.listmileage'
)
}}
" class="
ui
button
">
<i class="
arrow
left
icon
"></i> Kembali ke Senarai
</a>
</div>
@endsection
@push('script')
<script>
$(document).ready(function () {
$('.ui.dropdown').dropdown();
});
</script>
@endpush
packages/portal/mileage/resources/views/mileage/list.blade.php
0 → 100644
View file @
a048c923
@
extends
(
'ui::layouts.app'
)
@
section
(
'content'
)
<
style
>
.
table
-
uppercase
td
{
text
-
transform
:
uppercase
;
}
</
style
>
<
div
class
="
ui
segment
">
<a class="
ui
violet
left
ribbon
label
">Senarai Permohonan 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
<button type="
button
" class="
ui
right
floated
primary
button
" onclick="
$
(
'#modalPermohonanBaharu'
)
.
modal
(
'show'
)
">
Permohonan Baharu
</button>
<br/>
<div class="
column
sixteen
wide
table
-
uppercase
">
<h1 class="
ui
header
">Senarai Permohonan Tuntutan Mileage</h1>
{!!
Suitable::source(
$list
)
->title(__('Senarai Permohonan Tuntutan Mileage'))
->columns([
\Laravolt\Suitable\Columns\Numbering::make('No'),
['header' => __('Claim No'), 'field' => 'mm_apply_no', 'sortable' => true],
['header' => __('Bulan'), 'raw' => function(
$row
){
$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',
];
if (!
$row->mm_claim_month
|| !
$row->mm_claim_year
) {
return '-';
}
return (
$bulan[$row->mm_claim_month]
??
$row->mm_claim_month
) . ' ' .
$row->mm_claim_year
;
}],
['header' => __('Tarikh Hantar'), 'raw' => function(
$row
){
return
$row->mm_submit_date
? \Carbon\Carbon::parse(
$row->mm_submit_date
)->format('d/m/Y')
: '-';
}],
['header' => __('Status'), 'raw' => function(
$row
){
$status
=
$row->lkpStatus
?->description ?? 'Draf';
$color
= match(
$status
) {
'Draf' => 'grey',
'Diproses' => 'blue',
'Disokong' => 'green',
'Disahkan' => 'olive',
'Disemak' => 'purple',
'Dibayar' => 'teal',
'Ditolak' => 'red',
default => 'grey',
};
return '<span class="
ui
' . $color . '
label
">' .
$status
. '</span>';
}],
['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>";
}]
])
->render()
!!}
</div>
<br/><br/>
</div>
</div>
{{-- Modal: Permohonan Baharu --}}
<div class="ui small modal" id="modalPermohonanBaharu">
<i class="close icon"></i>
<div class="header">
Permohonan Baharu
</div>
<div class="content">
<form class="ui form" method="POST" action="{{ route('
mileage
::
mileage
.
claim
.
store
') }}" id="formPermohonanBaharu">
@csrf
<div class="field">
<label>Bulan Tuntutan</label>
<select name="mm_claim_month" class="ui dropdown" required>
<option value="">-- Pilih Bulan --</option>
@foreach([
1 => '
Januari
', 2 => '
Februari
', 3 => '
Mac
', 4 => '
April
',
5 => '
Mei
', 6 => '
Jun
', 7 => '
Julai
', 8 => '
Ogos
',
9 => '
September
', 10 => '
Oktober
', 11 => '
November
', 12 => '
Disember
',
] as $value => $label)
<option value="{{ $value }}" {{ now()->month == $value ? '
selected
' : '' }}>{{ $label }}</option>
@endforeach
</select>
</div>
<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>
<select name="fk_lkp_fa_category" class="ui dropdown" required>
<option value="">-- Pilih Kategori --</option>
@foreach($faCategories as $category)
<option value="{{ $category->id }}">{{ $category->fa_category }}</option>
@endforeach
</select>
</div>
</form>
</div>
<div class="actions">
<div class="ui black deny button">Batal</div>
<div class="ui primary approve button" onclick="document.getElementById('
formPermohonanBaharu
').submit()">
Seterusnya
</div>
</div>
</div>
@endsection
@push('
script
')
<script>
$(document).ready(function () {
$('
.
ui
.
dropdown
').dropdown();
$('
#modalPermohonanBaharu').modal();
});
</
script
>
@
endpush
packages/portal/mileage/routes/web.php
View file @
a048c923
...
@@ -12,7 +12,8 @@
...
@@ -12,7 +12,8 @@
Route
::
group
(
Route
::
group
(
[
[
'prefix'
=>
''
,
'namespace'
=>
'\Portal\Mileage\Http\Controllers'
,
'prefix'
=>
'mileage'
,
'as'
=>
'mileage::'
,
'as'
=>
'mileage::'
,
'middleware'
=>
[
'web'
,
'auth'
],
'middleware'
=>
[
'web'
,
'auth'
],
],
],
...
@@ -26,6 +27,7 @@ function () {
...
@@ -26,6 +27,7 @@ function () {
// Route::resource('applyform', ApplyformController::class);
// Route::resource('applyform', ApplyformController::class);
// Applications
// Applications
Route
::
get
(
'applications/senarai'
,
[
ApplicationsController
::
class
,
'senarai'
])
->
name
(
'applications.senarai'
);
Route
::
resource
(
'applications'
,
ApplicationsController
::
class
);
Route
::
resource
(
'applications'
,
ApplicationsController
::
class
);
Route
::
put
(
'applications/{id}/updateStatus'
,
[
ApplicationsController
::
class
,
'updateStatus'
])
Route
::
put
(
'applications/{id}/updateStatus'
,
[
ApplicationsController
::
class
,
'updateStatus'
])
->
name
(
'applications.updateStatus'
);
->
name
(
'applications.updateStatus'
);
...
@@ -90,7 +92,16 @@ function () {
...
@@ -90,7 +92,16 @@ function () {
Route
::
post
(
'/{id}/reject'
,
[
HRController
::
class
,
'reject'
])
->
name
(
'.reject'
);
Route
::
post
(
'/{id}/reject'
,
[
HRController
::
class
,
'reject'
])
->
name
(
'.reject'
);
Route
::
get
(
'/export'
,
[
HRController
::
class
,
'export'
])
->
name
(
'.export'
);
Route
::
get
(
'/export'
,
[
HRController
::
class
,
'export'
])
->
name
(
'.export'
);
});
});
}
Route
::
get
(
'index'
,
[
'uses'
=>
'MileageController@index'
,
'as'
=>
'mileage.index'
]);
Route
::
get
(
'list'
,
[
'uses'
=>
'MileageController@getListMileage'
,
'as'
=>
'mileage.listmileage'
]);
Route
::
post
(
'claim/store'
,
[
'uses'
=>
'MileageController@storeClaim'
,
'as'
=>
'mileage.claim.store'
]);
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'
]);
}
);
);
// Guest group (currently unused)
// Guest group (currently unused)
...
...
packages/portal/mileage/src/Data/Repo/MileageRepo.php
0 → 100644
View file @
a048c923
<?php
namespace
Portal\Mileage\Data\Repo
;
use
Portal\Mileage\Model\MileageClaimDetail
;
use
Portal\Mileage\Model\JenisKenderaan
;
use
Portal\Mileage\Model\Project
;
use
Portal\Mileage\Model\StaffInfo
;
use
Portal\Mileage\Model\LkpFaCategory
;
use
Illuminate\Http\Request
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
use
Illuminate\Support\Collection
;
use
Illuminate\Support\Facades\Input
;
use
Carbon\Carbon
;
use
App\Events\AuditLog
;
use
Auth
;
use
DB
;
use
Event
;
use
File
;
use
Mail
;
use
PDF
;
use
Redirect
;
use
Curl
;
use
Portal\Mileage\Model\MileageClaimMain
;
use
Portal\Mileage\Model\Users
;
/**
* undocumented function
*
* @return testing please hide this function and continue below
* @author afif@3fresources.com
**/
class
MileageRepo
{
public
function
index
(
$request
)
{
// $users = Users::where('status', 'ACTIVE')
// ->paginate(10);
// return $users;
}
// mileage crud start
public
function
mileageList
(
$request
)
{
$search
=
request
(
'search'
);
$data
=
MileageClaimMain
::
where
(
'mm_apply_no'
,
'like'
,
'%'
.
$search
.
'%'
)
->
orderBy
(
'created_at'
,
'desc'
)
->
paginate
(
10
);
return
$data
;
}
public
function
storeClaim
(
$request
)
{
$staff
=
StaffInfo
::
where
(
'fk_users'
,
Auth
::
id
())
->
first
();
$claim
=
MileageClaimMain
::
create
([
'fk_lkp_staff_info'
=>
$staff
->
id
??
null
,
'mm_staff_name'
=>
Auth
::
user
()
->
name
??
null
,
'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
(),
]);
return
$claim
->
id
;
}
public
function
findClaim
(
$id
)
{
return
MileageClaimMain
::
with
(
'details'
)
->
findOrFail
(
$id
);
}
public
function
getJenisKenderaan
()
{
return
JenisKenderaan
::
orderBy
(
'name'
)
->
get
();
}
public
function
getProjects
()
{
return
Project
::
orderBy
(
'p_project_description'
)
->
get
();
}
public
function
getFaCategories
()
{
return
LkpFaCategory
::
orderBy
(
'id'
)
->
get
();
}
public
function
storeDetail
(
$request
,
$id
)
{
return
MileageClaimDetail
::
create
([
'fk_mileage_claim_main'
=>
$id
,
'fk_lkp_jenis_kenderaan'
=>
$request
->
fk_lkp_jenis_kenderaan
,
'fk_lkp_project'
=>
$request
->
fk_lkp_project
,
'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
,
]);
}
public
function
destroyDetail
(
$id
)
{
$detail
=
MileageClaimDetail
::
findOrFail
(
$id
);
$detail
->
delete
();
return
$detail
;
}
}
packages/portal/mileage/src/Http/Controllers/ApplicationsController.php
View file @
a048c923
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
use
Illuminate\Http\Request
;
use
Illuminate\Http\Request
;
use
Carbon\Carbon
;
use
Carbon\Carbon
;
class
ApplicationsController
extends
Controller
class
ApplicationsController
extends
Controller
{
{
public
function
__construct
()
public
function
__construct
()
{
{
...
@@ -67,6 +67,23 @@ public function index(Request $request)
...
@@ -67,6 +67,23 @@ public function index(Request $request)
]);
]);
}
}
public
function
senarai
(
Request
$request
)
{
$user
=
auth
()
->
user
();
$month
=
$request
->
get
(
'month'
,
Carbon
::
now
()
->
format
(
'Y-m'
));
$parsedMonth
=
Carbon
::
createFromFormat
(
'Y-m'
,
$month
);
$claims
=
Claim
::
with
([
'project'
,
'jenisKenderaan'
])
->
where
(
'user_id'
,
$user
->
id
)
->
whereMonth
(
'claim_date'
,
$parsedMonth
->
month
)
->
whereYear
(
'claim_date'
,
$parsedMonth
->
year
)
->
latest
()
->
get
();
return
view
(
'mileage::application.senarai'
,
compact
(
'claims'
,
'month'
));
}
public
function
store
(
Request
$request
)
public
function
store
(
Request
$request
)
{
{
// your existing store logic
// your existing store logic
...
...
packages/portal/mileage/src/Http/Controllers/MileageController.php
0 → 100644
View file @
a048c923
<?php
namespace
Portal\Mileage\Http\Controllers
;
use
Illuminate\Routing\Controller
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Input
;
use
Carbon\Carbon
;
use
Auth
;
use
DB
;
use
Event
;
use
File
;
use
Mail
;
use
PDF
;
use
Redirect
;
use
Curl
;
use
Portal\Mileage\Data\Repo\MileageRepo
;
class
MileageController
extends
Controller
{
/**
* @var MileageRepo
*/
protected
$repos
;
public
function
__construct
(
MileageRepo
$repos
)
{
$this
->
repos
=
$repos
;
}
/**
* undocumented function
*
* @return testing please hide this function and continue below
* @author afif@3fresources.com
**/
public
function
index
(
Request
$request
)
{
dd
(
'Welcome to index E-Mileage 3FRSB'
);
exit
;
// $list = $this->repos->index($request);
// return view('mileage::list', compact('list'));
}
// mileage crud start
public
function
getListMileage
(
Request
$request
)
{
$list
=
$this
->
repos
->
mileageList
(
$request
);
$faCategories
=
$this
->
repos
->
getFaCategories
();
return
view
(
'mileage::mileage.list'
,
compact
(
'list'
,
'faCategories'
));
}
public
function
storeClaim
(
Request
$request
)
{
$id
=
$this
->
repos
->
storeClaim
(
$request
);
return
redirect
()
->
route
(
'mileage::mileage.claim.form'
,
[
'id'
=>
$id
]);
}
public
function
formClaim
(
Request
$request
,
$id
)
{
$claim
=
$this
->
repos
->
findClaim
(
$id
);
$jenisKenderaan
=
$this
->
repos
->
getJenisKenderaan
();
$projects
=
$this
->
repos
->
getProjects
();
return
view
(
'mileage::mileage.form'
,
compact
(
'claim'
,
'jenisKenderaan'
,
'projects'
));
}
public
function
storeDetail
(
Request
$request
,
$id
)
{
$this
->
repos
->
storeDetail
(
$request
,
$id
);
return
redirect
()
->
route
(
'mileage::mileage.claim.form'
,
[
'id'
=>
$id
])
->
with
(
'success'
,
'Butiran tuntutan berjaya ditambah.'
);
}
public
function
destroyDetail
(
Request
$request
,
$id
)
{
$detail
=
$this
->
repos
->
destroyDetail
(
$id
);
return
redirect
()
->
route
(
'mileage::mileage.claim.form'
,
[
'id'
=>
$detail
->
fk_mileage_claim_main
])
->
with
(
'success'
,
'Butiran tuntutan berjaya dipadam.'
);
}
}
packages/portal/mileage/src/Model/LkpFaCategory.php
0 → 100644
View file @
a048c923
<?php
namespace
Portal\Mileage\Model
;
use
Illuminate\Database\Eloquent\Model
;
class
LkpFaCategory
extends
Model
{
protected
$table
=
'lkp_fa_category'
;
protected
$fillable
=
[
'fa_category'
,
'status'
,
];
}
packages/portal/mileage/src/Model/MileageClaimDetail.php
0 → 100644
View file @
a048c923
<?php
namespace
Portal\Mileage\Model
;
use
Illuminate\Database\Eloquent\Model
;
class
MileageClaimDetail
extends
Model
{
protected
$table
=
'mileage_claim_detail'
;
protected
$fillable
=
[
'fk_mileage_claim_main'
,
'fk_lkp_jenis_kenderaan'
,
'fk_lkp_project'
,
'md_claim_date'
,
'md_description'
,
'md_distance_from'
,
'md_distance_to'
,
'md_total_mileage'
,
'md_total_toll'
,
'md_total_parking_fee'
,
];
public
function
claimMain
()
{
return
$this
->
belongsTo
(
MileageClaimMain
::
class
,
'fk_mileage_claim_main'
);
}
public
function
jenisKenderaan
()
{
return
$this
->
belongsTo
(
JenisKenderaan
::
class
,
'fk_lkp_jenis_kenderaan'
);
}
public
function
project
()
{
return
$this
->
belongsTo
(
Project
::
class
,
'fk_lkp_project'
);
}
}
packages/portal/mileage/src/Model/MileageClaimMain.php
0 → 100644
View file @
a048c923
<?php
namespace
Portal\Mileage\Model
;
use
App\Models\User
;
use
Illuminate\Database\Eloquent\Model
;
class
MileageClaimMain
extends
Model
{
protected
$table
=
'mileage_claim_main'
;
protected
$fillable
=
[
'mm_apply_no'
,
'fk_lkp_staff_info'
,
'mm_staff_name'
,
'mm_staff_position'
,
'mm_staff_id'
,
'mm_staff_company'
,
'mm_submit_date'
,
'mm_claim_month'
,
'mm_claim_year'
,
'fk_lkp_fa_category'
,
'mm_verified_by'
,
'mm_verified_date'
,
'mm_approved_by'
,
'mm_approved_date'
,
'status'
,
];
protected
static
function
boot
()
{
parent
::
boot
();
static
::
creating
(
function
(
self
$model
)
{
if
(
empty
(
$model
->
mm_apply_no
))
{
$model
->
mm_apply_no
=
static
::
generateApplyNo
();
}
});
}
/**
* Generate the next running application number in the format MC-YYYY-NNNN,
* resetting the sequence every year.
*/
public
static
function
generateApplyNo
()
:
string
{
$year
=
now
()
->
format
(
'Y'
);
$prefix
=
"MC-
{
$year
}
-"
;
$last
=
static
::
where
(
'mm_apply_no'
,
'like'
,
"
{
$prefix
}
%"
)
->
orderByDesc
(
'mm_apply_no'
)
->
value
(
'mm_apply_no'
);
$nextNumber
=
$last
?
((
int
)
substr
(
$last
,
-
4
))
+
1
:
1
;
return
$prefix
.
str_pad
((
string
)
$nextNumber
,
4
,
'0'
,
STR_PAD_LEFT
);
}
public
function
staffInfo
()
{
return
$this
->
belongsTo
(
StaffInfo
::
class
,
'fk_lkp_staff_info'
,
'id'
);
}
public
function
faCategory
()
{
return
$this
->
belongsTo
(
LkpFaCategory
::
class
,
'fk_lkp_fa_category'
);
}
public
function
lkpStatus
()
{
return
$this
->
belongsTo
(
LkpStatus
::
class
,
'status'
);
}
public
function
verifiedBy
()
{
return
$this
->
belongsTo
(
User
::
class
,
'mm_verified_by'
);
}
public
function
approvedBy
()
{
return
$this
->
belongsTo
(
User
::
class
,
'mm_approved_by'
);
}
public
function
details
()
{
return
$this
->
hasMany
(
MileageClaimDetail
::
class
,
'fk_mileage_claim_main'
);
}
}
packages/portal/mileage/src/ServiceProvider.php
View file @
a048c923
...
@@ -32,7 +32,7 @@ class ServiceProvider extends BaseServiceProvider
...
@@ -32,7 +32,7 @@ class ServiceProvider extends BaseServiceProvider
* @var array
* @var array
*/
*/
protected
$listen
=
[
protected
$listen
=
[
\Portal\Mileage\Events\NotifyEmail
::
class
=>
[
\Portal\Mileage\Events\NotifyEmail
::
class
=>
[
\Portal\Mileage\Handlers\Events\SentEmail
::
class
\Portal\Mileage\Handlers\Events\SentEmail
::
class
],
],
...
@@ -78,7 +78,7 @@ public function boot()
...
@@ -78,7 +78,7 @@ public function boot()
protected
function
menu
()
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
(
__
(
'Dashboard'
))
->
data
(
'icon'
,
'align justify'
);
$menu
=
$menus
->
add
(
__
(
'Dashboard'
))
->
data
(
'icon'
,
'align justify'
);
$menu
->
add
(
__
(
'Laman Utama'
),
url
(
'/home/'
))
$menu
->
add
(
__
(
'Laman Utama'
),
url
(
'/home/'
))
...
@@ -93,7 +93,7 @@ protected function menu()
...
@@ -93,7 +93,7 @@ protected function menu()
$menu
->
add
(
__
(
'Project Director Dashboard'
),
route
(
'mileage::projectDirector.index'
))
$menu
->
add
(
__
(
'Project Director Dashboard'
),
route
(
'mileage::projectDirector.index'
))
->
data
(
'icon'
,
'compass'
)
->
data
(
'icon'
,
'compass'
)
->
active
(
'projectDirector/*'
)
->
active
(
'projectDirector/*'
)
->
data
(
'permission'
,
Permission
::
PROJECT_DIRECTOR
);
->
data
(
'permission'
,
Permission
::
PROJECT_DIRECTOR
);
$menu
->
add
(
__
(
'HOD Dashboard'
),
route
(
'mileage::HOD.index'
))
$menu
->
add
(
__
(
'HOD Dashboard'
),
route
(
'mileage::HOD.index'
))
->
data
(
'icon'
,
'black tie'
)
->
data
(
'icon'
,
'black tie'
)
...
@@ -114,25 +114,30 @@ protected function menu()
...
@@ -114,25 +114,30 @@ protected function menu()
->
data
(
'icon'
,
'calculator'
)
->
data
(
'icon'
,
'calculator'
)
->
active
(
'finance/*'
)
->
active
(
'finance/*'
)
->
data
(
'permission'
,
Permission
::
FINANCE
);
->
data
(
'permission'
,
Permission
::
FINANCE
);
$menu
=
$menus
->
add
(
__
(
'Borang Permohonan Mileage Claim'
))
->
data
(
'icon'
,
'align justify'
);
$menu
=
$menus
->
add
(
__
(
'Borang Permohonan Mileage Claim'
))
->
data
(
'icon'
,
'align justify'
);
$now
=
Carbon
::
today
()
->
format
(
'Y-m-d'
);
$now
=
Carbon
::
today
()
->
format
(
'Y-m-d'
);
$menu
->
add
(
__
(
'Bawah Projek'
),
route
(
'mileage::applyform.index'
))
$menu
->
add
(
__
(
'Bawah Projek'
),
route
(
'mileage::applyform.index'
))
->
data
(
'icon'
,
'check'
)
->
data
(
'icon'
,
'check'
)
->
active
(
'applyform/*'
);
->
active
(
'applyform/*'
);
$menu
->
add
(
__
(
'Tiada Projek'
),
route
(
'mileage::applyform.noproject'
))
$menu
->
add
(
__
(
'Tiada Projek'
),
route
(
'mileage::applyform.noproject'
))
->
data
(
'icon'
,
'close'
)
->
data
(
'icon'
,
'close'
)
->
active
(
'noproject/*'
);
->
active
(
'noproject/*'
);
$menu
=
$menus
->
add
(
__
(
'Senarai Permohonan'
))
->
data
(
'icon'
,
'align justify'
);
$menu
=
$menus
->
add
(
__
(
'Senarai Permohonan'
))
->
data
(
'icon'
,
'align justify'
);
$menu
->
add
(
__
(
'Senarai Permohonan Mileage Claim'
),
route
(
'mileage::applications.index'
))
$menu
->
add
(
__
(
'Senarai Permohonan Mileage Claim'
),
route
(
'mileage::applications.index'
))
->
data
(
'icon'
,
'bars'
)
->
data
(
'icon'
,
'bars'
)
->
active
(
'applications/*'
);
->
active
(
'applications/*'
);
$menu
->
add
(
__
(
'Senarai Tuntutan Saya'
),
route
(
'mileage::applications.senarai'
))
->
data
(
'icon'
,
'list alternate'
)
->
active
(
'applications/senarai'
);
});
});
}
}
}
}
\ 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