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
00bade44
Commit
00bade44
authored
Oct 09, 2026
by
Muhammad Aniq bin Mohd Nizam
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Laporan Mileage
parent
a1423c92
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
253 additions
and
37 deletions
+253
-37
packages/portal/mileage/resources/views/laporan/index.blade.php
+0
-0
packages/portal/mileage/resources/views/laporan/table_partial.blade.php
+64
-0
packages/portal/mileage/routes/web.php
+7
-2
packages/portal/mileage/src/Data/Repo/LaporanRepo.php
+83
-0
packages/portal/mileage/src/Http/Controllers/LaporanMileageController.php
+69
-0
packages/portal/mileage/src/Model/MileageClaimDetail.php
+2
-1
packages/portal/mileage/src/Model/MileageClaimMain.php
+19
-13
packages/portal/mileage/src/ServiceProvider.php
+9
-21
No files found.
packages/portal/mileage/resources/views/laporan/index.blade.php
0 → 100644
View file @
00bade44
This diff is collapsed.
Click to expand it.
packages/portal/mileage/resources/views/laporan/table_partial.blade.php
0 → 100644
View file @
00bade44
<table
class=
"ui celled striped table"
id=
"mileageReportTable"
>
<thead>
<tr
class=
"center aligned"
>
<th>
#
</th>
<th>
NO. PERMOHONAN
</th>
<th>
NAMA STAFF
</th>
<th>
TARIKH
</th>
<th>
TUJUAN
</th>
<th>
JARAK (KM)
</th>
<th>
JUMLAH TUNTUTAN (RM)
</th>
<th>
STATUS
</th>
</tr>
</thead>
<tbody>
@forelse($laporanData as $index => $item)
@php
// Distance
&
Amount calculation
$distance = $item->jarak ?? ($item->details ? $item->details->sum('md_total_mileage') : 0);
$amount = $item->jumlah ?? ($item->details ? $item->details->sum('md_total_amount') : 0);
// Destinasi / Tujuan mapping
$destination = $item->tujuan
?? ($item->details ? $item->details->pluck('md_description')->filter()->unique()->implode(', ') : null)
?? '-';
// Truncate time off submit date (e.g. 2026-07-22 10:34:14 -> 2026-07-22)
$submitDate = $item->mm_submit_date ?? $item->tarikh ?? null;
$formattedDate = $submitDate ? \Carbon\Carbon::parse($submitDate)->format('Y-m-d') : '-';
@endphp
<tr>
<td
class=
"center aligned"
>
{{ $index + 1 }}
</td>
<td
class=
"center aligned"
>
{{ $item->mm_apply_no ?? $item->apply_no ?? '-' }}
</td>
<td>
{{ $item->staffInfo->fullname ?? $item->mm_staff_name ?? $item->staff_name ?? '-' }}
</td>
<td
class=
"center aligned"
>
{{ $formattedDate }}
</td>
<td>
{{ $destination }}
</td>
<td
class=
"center aligned"
>
{{ number_format($distance, 1) }} KM
</td>
<td
class=
"center aligned"
>
RM {{ number_format($amount, 2) }}
</td>
<td
class=
"center aligned"
>
<span
class=
"ui label"
>
{{ $item->status ?? $item->lkpStatus->ref_description ?? '-' }}
</span>
</td>
</tr>
@empty
<tr>
<td
colspan=
"8"
class=
"center aligned text-muted"
>
<i
class=
"folder open outline icon large margin-top-10"
></i><br>
Tiada rekod laporan dijumpai.
</td>
</tr>
@endforelse
</tbody>
<tfoot>
<tr>
<th
colspan=
"5"
class=
"right aligned"
><strong>
JUMLAH KESELURUHAN:
</strong></th>
<th
class=
"center aligned"
>
<strong>
{{ number_format($totalJarak ?? 0, 1) }} KM
</strong>
</th>
<th
class=
"center aligned"
>
<strong>
RM {{ number_format($totalJumlah ?? 0, 2) }}
</strong>
</th>
<th></th>
</tr>
</tfoot>
</table>
\ No newline at end of file
packages/portal/mileage/routes/web.php
View file @
00bade44
...
...
@@ -12,6 +12,7 @@
use
Portal\Mileage\Http\Controllers\LkpMileageTaskController
;
use
Portal\Mileage\Http\Controllers\LkpRateController
;
use
Portal\Mileage\Http\Controllers\LkpStatusController
;
use
Portal\Mileage\Http\Controllers\LaporanMileageController
;
Route
::
group
(
[
...
...
@@ -81,10 +82,15 @@ function () {
Route
::
get
(
'audit-trail'
,
[
'uses'
=>
'MileageController@getAuditTrail'
,
'as'
=>
'mileage.audit-trail'
]);
// Laporan
Route
::
prefix
(
'laporan'
)
->
name
(
'laporan.'
)
->
group
(
function
()
{
Route
::
get
(
'/'
,
[
LaporanMileageController
::
class
,
'index'
])
->
name
(
'index'
);
Route
::
get
(
'/data'
,
[
LaporanMileageController
::
class
,
'data'
])
->
name
(
'data'
);
});
// Tetapan
Route
::
get
(
'tetapan'
,
[
'uses'
=>
'TetapanController@index'
,
'as'
=>
'mileage.tetapan'
]);
// Jenis Kenderaan
Route
::
get
(
'jenis-kenderaan'
,
[
JenisKenderaanController
::
class
,
'index'
])
->
name
(
'jenis-kenderaan.index'
);
Route
::
get
(
'jenis-kenderaan/create'
,
[
JenisKenderaanController
::
class
,
'create'
])
->
name
(
'jenis-kenderaan.create'
);
...
...
@@ -131,7 +137,6 @@ function () {
Route
::
delete
(
'lkpstatus/{id}'
,
[
LkpStatusController
::
class
,
'destroy'
])
->
name
(
'lkpstatus.destroy'
);
Route
::
get
(
'claim/{id}/pdf'
,
[
'uses'
=>
'MileageController@downloadPdf'
,
'as'
=>
'mileage.claim.downloadPdf'
]);
}
);
...
...
packages/portal/mileage/src/Data/Repo/LaporanRepo.php
0 → 100644
View file @
00bade44
<?php
namespace
Portal\Mileage\Data\Repo
;
use
Portal\Mileage\Model\JenisKenderaan
;
use
Portal\Mileage\Model\StaffInfo
;
use
Portal\Mileage\Model\Project
;
use
Portal\Mileage\Model\MileageClaimMain
;
use
Illuminate\Support\Carbon
;
use
Illuminate\Support\Facades\DB
;
class
LaporanRepo
{
public
function
getKenderaanOptions
()
{
return
JenisKenderaan
::
get
();
}
public
function
getStaffOptions
()
{
return
StaffInfo
::
where
(
'status'
,
1
)
->
orderBy
(
'fullname'
,
'asc'
)
->
get
();
}
public
function
getProjectOptions
()
{
return
Project
::
get
();
}
public
function
getFilteredData
(
$request
)
{
$query
=
MileageClaimMain
::
with
([
'staffInfo'
,
'finance'
,
'details.jenisKenderaan'
,
'details.project'
]);
// CLAIM / TRAVEL MONTH FILTERING
if
(
$request
->
filled
(
'bulan'
))
{
$monthNum
=
(
int
)
$request
->
bulan
;
$monthPadded
=
sprintf
(
'%02d'
,
$monthNum
);
$query
->
where
(
function
(
$q
)
use
(
$monthNum
,
$monthPadded
)
{
$q
->
where
(
'mm_claim_month'
,
$monthNum
)
->
orWhere
(
'mm_claim_month'
,
$monthPadded
)
->
orWhereRaw
(
'MONTH(mm_claim_month) = ?'
,
[
$monthNum
]);
});
}
else
{
if
(
$request
->
filled
(
'tarikh_dari'
))
{
$date
=
Carbon
::
parse
(
$request
->
tarikh_dari
)
->
startOfDay
();
$query
->
whereDate
(
'mm_submit_date'
,
'>='
,
$date
);
}
if
(
$request
->
filled
(
'tarikh_hingga'
))
{
$date2
=
Carbon
::
parse
(
$request
->
tarikh_hingga
)
->
endOfDay
();
$query
->
whereDate
(
'mm_submit_date'
,
'<='
,
$date2
);
}
}
if
(
$request
->
filled
(
'staff_id'
))
{
$query
->
where
(
'fk_lkp_staff_info'
,
$request
->
staff_id
);
}
if
(
$request
->
filled
(
'kenderaan_id'
))
{
$query
->
whereHas
(
'details'
,
function
(
$q
)
use
(
$request
)
{
$q
->
where
(
'fk_lkp_jenis_kenderaan'
,
$request
->
kenderaan_id
);
});
}
if
(
$request
->
filled
(
'project_id'
))
{
$query
->
whereHas
(
'details'
,
function
(
$q
)
use
(
$request
)
{
$q
->
where
(
'fk_lkp_project'
,
$request
->
project_id
);
});
}
$query
->
orderBy
(
'mm_submit_date'
,
'desc'
);
return
$query
->
get
();
}
}
\ No newline at end of file
packages/portal/mileage/src/Http/Controllers/LaporanMileageController.php
0 → 100644
View file @
00bade44
<?php
namespace
Portal\Mileage\Http\Controllers
;
use
Illuminate\Routing\Controller
;
use
Illuminate\Http\Request
;
use
Portal\Mileage\Data\Repo\LaporanRepo
;
use
Exception
;
class
LaporanMileageController
extends
Controller
{
/**
* @var LaporanRepo
*/
protected
$repos
;
public
function
__construct
(
LaporanRepo
$repos
)
{
$this
->
repos
=
$repos
;
}
/**
* Display the index filter page for mileage reports
*
* @param Request $request
* @return \Illuminate\View\View
*/
public
function
index
(
Request
$request
)
{
$kenderaanList
=
$this
->
repos
->
getKenderaanOptions
();
$staffList
=
$this
->
repos
->
getStaffOptions
();
$projectList
=
$this
->
repos
->
getProjectOptions
();
return
view
(
'mileage::laporan.index'
,
compact
(
'kenderaanList'
,
'staffList'
,
'projectList'
));
}
/**
* Fetch filtered report data via AJAX
*
* @param Request $request
* @return \Illuminate\Http\JsonResponse
*/
public
function
data
(
Request
$request
)
{
try
{
$laporanData
=
$this
->
repos
->
getFilteredData
(
$request
);
// Optional: If you ever decide to return rendered HTML instead of raw JSON data
if
(
$request
->
get
(
'render_html'
))
{
$html
=
view
(
'mileage::laporan.partials.table_rows'
,
compact
(
'laporanData'
))
->
render
();
return
response
()
->
json
([
'success'
=>
true
,
'html'
=>
$html
,
]);
}
return
response
()
->
json
([
'success'
=>
true
,
'data'
=>
$laporanData
,
]);
}
catch
(
Exception
$e
)
{
return
response
()
->
json
([
'success'
=>
false
,
'message'
=>
'Ralat semasa memuatkan data: '
.
$e
->
getMessage
(),
],
500
);
}
}
}
\ No newline at end of file
packages/portal/mileage/src/Model/MileageClaimDetail.php
View file @
00bade44
...
...
@@ -40,4 +40,4 @@ public function pmReviews()
{
return
$this
->
hasMany
(
MileageClaimPmReview
::
class
,
'fk_detail_id'
);
}
}
}
\ No newline at end of file
packages/portal/mileage/src/Model/MileageClaimMain.php
View file @
00bade44
...
...
@@ -7,6 +7,11 @@
use
Portal\Mileage\Model\AuditQuery
;
use
Portal\Mileage\Model\MileageClaimFinance
;
use
Portal\Mileage\Model\MileageClaimPmReview
;
use
Portal\Mileage\Model\MileageClaimDetail
;
use
Portal\Mileage\Model\MileageClaimAttachment
;
use
Portal\Mileage\Model\StaffInfo
;
use
Portal\Mileage\Model\LkpFaCategory
;
use
Portal\Mileage\Model\LkpStatus
;
class
MileageClaimMain
extends
Model
{
...
...
@@ -42,10 +47,6 @@ protected static function boot()
});
}
/**
* 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'
);
...
...
@@ -65,6 +66,11 @@ public function staffInfo()
return
$this
->
belongsTo
(
StaffInfo
::
class
,
'fk_lkp_staff_info'
,
'id'
);
}
public
function
details
()
{
return
$this
->
hasMany
(
MileageClaimDetail
::
class
,
'fk_mileage_claim_main'
);
}
public
function
faCategory
()
{
return
$this
->
belongsTo
(
LkpFaCategory
::
class
,
'fk_lkp_fa_category'
);
...
...
@@ -76,7 +82,6 @@ public function lkpStatus()
->
where
(
'module'
,
'mileage'
);
}
public
function
verifiedBy
()
{
return
$this
->
belongsTo
(
User
::
class
,
'mm_verified_by'
);
...
...
@@ -87,11 +92,6 @@ public function approvedBy()
return
$this
->
belongsTo
(
User
::
class
,
'mm_approved_by'
);
}
public
function
details
()
{
return
$this
->
hasMany
(
MileageClaimDetail
::
class
,
'fk_mileage_claim_main'
);
}
public
function
auditQueries
()
{
return
$this
->
hasMany
(
AuditQuery
::
class
,
'fk_main'
);
...
...
@@ -102,6 +102,13 @@ public function attachments()
return
$this
->
hasMany
(
MileageClaimAttachment
::
class
,
'fk_main'
);
}
// Direct relationship named finance for eager-loading in LaporanRepo
public
function
finance
()
{
return
$this
->
hasOne
(
MileageClaimFinance
::
class
,
'fk_mileage_claim_main'
);
}
// Kept financeDetail as an alias so existing views/controllers won't break
public
function
financeDetail
()
{
return
$this
->
hasOne
(
MileageClaimFinance
::
class
,
'fk_mileage_claim_main'
);
...
...
@@ -111,6 +118,4 @@ public function pmReviews()
{
return
$this
->
hasMany
(
MileageClaimPmReview
::
class
,
'fk_claim_id'
);
}
}
}
\ No newline at end of file
packages/portal/mileage/src/ServiceProvider.php
View file @
00bade44
...
...
@@ -136,30 +136,17 @@ protected function menu()
->
data
(
'icon'
,
'cog'
)
->
active
(
'mileage/tetapan*'
);
$menu
=
$menus
->
add
(
__
(
'Laporan'
))
->
data
(
'icon'
,
'file alternate outline'
);
// $menu = $menus->add(__('Borang Permohonan Mileage Claim'))->data('icon', 'align justify');
// $now = Carbon::today()->format('Y-m-d');
// $menu->add(__('Bawah Projek'), route('mileage::applyform.index'))
// ->data('icon', 'check')
// ->active('applyform/*');
// $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
(
__
(
'Laporan Mileage'
),
route
(
'mileage::laporan.index'
))
->
data
(
'icon'
,
'car'
)
->
active
(
'laporan*'
);
// $menu->add(__('Laporan Overtime'), route('lkpotask::laporan.index'))
// ->data('icon', 'clock outline')
// ->active('laporan-overtime*');
});
}
}
}
\ 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