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
358ba95d
Commit
358ba95d
authored
Jul 31, 2026
by
Muhammad Iz'aan bin suhaimi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added pm flow, show project that belong to the user
parent
49fda619
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
24 changed files
with
681 additions
and
345 deletions
+681
-345
database/migrations/2026_07_29_153020_create_mileage_claim_pm_review_table.php
+37
-0
database/migrations/2026_07_29_164142_seed_pm_tasks_to_lkp_mileage_task.php
+34
-0
packages/portal/mileage/resources/views/BOD/show.blade.php
+32
-5
packages/portal/mileage/resources/views/HOD/show.blade.php
+35
-7
packages/portal/mileage/resources/views/PM/index.blade.php
+80
-0
packages/portal/mileage/resources/views/PM/show.blade.php
+0
-0
packages/portal/mileage/resources/views/finance/show.blade.php
+0
-0
packages/portal/mileage/resources/views/mileage/form.blade.php
+34
-7
packages/portal/mileage/resources/views/mileage/queryForm.blade.php
+47
-11
packages/portal/mileage/routes/web.php
+8
-9
packages/portal/mileage/src/Data/Repo/BODRepo.php
+23
-0
packages/portal/mileage/src/Data/Repo/FinanceRepo.php
+31
-1
packages/portal/mileage/src/Data/Repo/HODRepo.php
+33
-3
packages/portal/mileage/src/Data/Repo/MileageRepo.php
+56
-5
packages/portal/mileage/src/Data/Repo/PMRepo.php
+128
-0
packages/portal/mileage/src/Http/Controllers/MileageController.php
+2
-1
packages/portal/mileage/src/Http/Controllers/PMController.php
+57
-0
packages/portal/mileage/src/Http/Controllers/ProjectManagerController.php
+0
-191
packages/portal/mileage/src/Http/Notifications/PpjMailer.php
+0
-100
packages/portal/mileage/src/Model/MileageClaimDetail.php
+5
-0
packages/portal/mileage/src/Model/MileageClaimMain.php
+5
-0
packages/portal/mileage/src/Model/MileageClaimPmReview.php
+28
-0
packages/portal/mileage/src/Model/ProjectTeam.php
+2
-1
packages/portal/mileage/src/ServiceProvider.php
+4
-4
No files found.
database/migrations/2026_07_29_153020_create_mileage_claim_pm_review_table.php
0 → 100644
View file @
358ba95d
<?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_pm_review'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
integer
(
'fk_claim_id'
)
->
index
();
$table
->
integer
(
'fk_detail_id'
)
->
index
();
$table
->
string
(
'pm_employee_code'
,
50
)
->
index
();
$table
->
enum
(
'status'
,
[
'pending'
,
'reviewed'
,
'queried'
])
->
default
(
'pending'
);
$table
->
text
(
'note'
)
->
nullable
();
$table
->
timestamps
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'mileage_claim_pm_review'
);
}
};
database/migrations/2026_07_29_164142_seed_pm_tasks_to_lkp_mileage_task.php
0 → 100644
View file @
358ba95d
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
use
Illuminate\Support\Facades\DB
;
return
new
class
extends
Migration
{
/**
* Run the migrations.
*
* @return void
*/
public
function
up
()
{
DB
::
table
(
'lkp_mileage_task'
)
->
insert
([
[
'description'
=>
'PM Semak Permohonan'
,
'status'
=>
1
,
'created_at'
=>
now
(),
'updated_at'
=>
now
()],
[
'description'
=>
'PM Kuiri Permohonan'
,
'status'
=>
1
,
'created_at'
=>
now
(),
'updated_at'
=>
now
()],
]);
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
DB
::
table
(
'lkp_mileage_task'
)
->
whereIn
(
'description'
,
[
'PM Semak Permohonan'
,
'PM Kuiri Permohonan'
])
->
delete
();
}
};
packages/portal/mileage/resources/views/BOD/show.blade.php
View file @
358ba95d
...
...
@@ -84,11 +84,12 @@
<i class="
info
circle
icon
" style="
cursor
:
pointer
;
color
:
#2185d0;"
onclick
=
"$('#modalAnggaran').modal('show');"
></
i
>
</
th
>
<
th
class
="
center
aligned
">Status</th>
</tr>
</thead>
<tbody>
@php
$grandAnggaran
=
0
;
$grandTol
=
0
;
$grandParking
=
0
;
$grandAnggaran
= 0;
$grandTol
= 0;
$grandParking
= 0;
$grandJarak
= 0;
$deductionCount
= 0;
$sortedDetails
=
$claim->details
->sortBy('md_claim_date')->values();
$dateCounts
= [];
foreach (
$sortedDetails
as
$d
) {
...
...
@@ -105,7 +106,12 @@
$dateKey
=
$detail->md_claim_date
;
$isFirstOfDate
= !isset(
$dateFirstSeen[$dateKey]
);
if (
$isFirstOfDate
)
$dateFirstSeen[$dateKey]
= true;
$claimableKm
=
$isFirstOfDate
?
max
(
0
,
$jumlahJarak
-
40
)
:
$jumlahJarak
;
if (
$isFirstOfDate
&&
$deductionCount
< 10) {
$claimableKm
= max(0,
$jumlahJarak
- 40);
$deductionCount
++;
} else {
$claimableKm
=
$jumlahJarak
;
}
$startKm
=
$cumulativeKmByDate[$dateKey]
?? 0;
$endKm
=
$startKm
+
$claimableKm
;
$mileageAmount
= 0;
...
...
@@ -118,6 +124,7 @@
$jumlahParking
= (float)
$detail->md_total_parking_fee
;
$jumlahBelanja
=
$jumlahTol
+
$jumlahParking
;
$anggaranTuntutan
=
$mileageAmount
+
$jumlahBelanja
;
$grandJarak
+=
$jumlahJarak
;
$grandTol
+=
$jumlahTol
;
$grandParking
+=
$jumlahParking
;
$grandAnggaran
+=
$anggaranTuntutan
;
...
...
@@ -134,20 +141,38 @@
<td class="
right
aligned
">{{ number_format(
$jumlahTol
, 2) }}</td>
<td class="
right
aligned
">{{ number_format(
$jumlahParking
, 2) }}</td>
<td class="
right
aligned
">{{ number_format(
$anggaranTuntutan
, 2) }}</td>
@php
$totalReviews
=
$detail->pmReviews
->count();
$reviewedCount
=
$detail->pmReviews
->where('status', 'reviewed')->count();
$queriedCount
=
$detail->pmReviews
->where('status', 'queried')->count();
@endphp
<td class="
center
aligned
">
@if(
$totalReviews
=== 0)
<span class="
ui
grey
label
">-</span>
@elseif(
$queriedCount
> 0)
<span class="
ui
yellow
label
">Dikuiri</span>
@elseif(
$reviewedCount
===
$totalReviews
)
<span class="
ui
green
label
">Disemak</span>
@else
<span class="
ui
orange
label
">{{
$reviewedCount
}}/{{
$totalReviews
}} Disemak</span>
@endif
</td>
</tr>
@empty
<tr>
<td colspan="
9
" class="
center
aligned
">Tiada butiran.</td>
<td colspan="
10
" class="
center
aligned
">Tiada butiran.</td>
</tr>
@endforelse
</tbody>
@if(
$claim->details
->count() > 0)
<tfoot>
<tr>
<th colspan="
6
" class="
right
aligned
">JUMLAH KESELURUHAN (RM)</th>
<th colspan="
5
" class="
right
aligned
">JUMLAH KESELURUHAN</th>
<th class="
right
aligned
">{{ number_format(
$grandJarak
, 1) }}</th>
<th class="
right
aligned
">{{ number_format(
$grandTol
, 2) }}</th>
<th class="
right
aligned
">{{ number_format(
$grandParking
, 2) }}</th>
<th class="
right
aligned
">{{ number_format(
$grandAnggaran
, 2) }}</th>
<th></th>
</tr>
</tfoot>
@endif
...
...
@@ -220,7 +245,9 @@
<tr>
<td>{{
$index
+ 1 }}</td>
<td>
@if(
$q->kuiri_by
== 'HOD')
@if(
$q->kuiri_by
=== 'PM')
<span class="
ui
olive
label
">PM</span>
@elseif(
$q->kuiri_by
== 'HOD')
<span class="
ui
teal
label
">HOD</span>
@elseif(
$q->kuiri_by
== 'BOD')
<span class="
ui
violet
label
">BOD</span>
...
...
packages/portal/mileage/resources/views/HOD/show.blade.php
View file @
358ba95d
...
...
@@ -80,11 +80,13 @@
<i class="
info
circle
icon
" style="
cursor
:
pointer
;
color
:
#2185d0;"
onclick
=
"$('#modalAnggaran').modal('show');"
></
i
>
</
th
>
<
th
class
="
center
aligned
">Status</th>
</tr>
</thead>
<tbody>
@php
$grandAnggaran
=
0
;
$grandTol
=
0
;
$grandParking
=
0
;
$grandAnggaran
= 0;
$grandTol
= 0;
$grandParking
= 0;
$grandJarak
= 0;
$deductionCount
= 0;
$sortedDetails
=
$claim->details
->sortBy('md_claim_date')->values();
$dateCounts
= [];
foreach (
$sortedDetails
as
$d
) {
...
...
@@ -101,7 +103,12 @@
$dateKey
=
$detail->md_claim_date
;
$isFirstOfDate
= !isset(
$dateFirstSeen[$dateKey]
);
if (
$isFirstOfDate
)
$dateFirstSeen[$dateKey]
= true;
$claimableKm
=
$isFirstOfDate
?
max
(
0
,
$jumlahJarak
-
40
)
:
$jumlahJarak
;
if (
$isFirstOfDate
&&
$deductionCount
< 10) {
$claimableKm
= max(0,
$jumlahJarak
- 40);
$deductionCount
++;
} else {
$claimableKm
=
$jumlahJarak
;
}
$startKm
=
$cumulativeKmByDate[$dateKey]
?? 0;
$endKm
=
$startKm
+
$claimableKm
;
$mileageAmount
= 0;
...
...
@@ -114,6 +121,7 @@
$jumlahParking
= (float)
$detail->md_total_parking_fee
;
$jumlahBelanja
=
$jumlahTol
+
$jumlahParking
;
$anggaranTuntutan
=
$mileageAmount
+
$jumlahBelanja
;
$grandJarak
+=
$jumlahJarak
;
$grandTol
+=
$jumlahTol
;
$grandParking
+=
$jumlahParking
;
$grandAnggaran
+=
$anggaranTuntutan
;
...
...
@@ -130,20 +138,38 @@
<td class="
right
aligned
">{{ number_format(
$jumlahTol
, 2) }}</td>
<td class="
right
aligned
">{{ number_format(
$jumlahParking
, 2) }}</td>
<td class="
right
aligned
">{{ number_format(
$anggaranTuntutan
, 2) }}</td>
@php
$totalReviews
=
$detail->pmReviews
->count();
$reviewedCount
=
$detail->pmReviews
->where('status', 'reviewed')->count();
$queriedCount
=
$detail->pmReviews
->where('status', 'queried')->count();
@endphp
<td class="
center
aligned
">
@if(
$totalReviews
=== 0)
<span class="
ui
grey
label
">-</span>
@elseif(
$queriedCount
> 0)
<span class="
ui
yellow
label
"> Dikuiri</span>
@elseif(
$reviewedCount
===
$totalReviews
)
<span class="
ui
green
label
"><i class="
check
icon
"></i> Disemak</span>
@else
<span class="
ui
orange
label
">{{
$reviewedCount
}}/{{
$totalReviews
}} Disemak</span>
@endif
</td>
</tr>
@empty
<tr>
<td colspan="
9
" class="
center
aligned
">Tiada butiran.</td>
<td colspan="
10
" class="
center
aligned
">Tiada butiran.</td>
</tr>
@endforelse
</tbody>
@if(
$claim->details
->count() > 0)
<tfoot>
<tr>
<th colspan="
6
" class="
right
aligned
">JUMLAH KESELURUHAN (RM)</th>
<th colspan="
5
" class="
right
aligned
">JUMLAH KESELURUHAN</th>
<th class="
right
aligned
">{{ number_format(
$grandJarak
, 1) }}</th>
<th class="
right
aligned
">{{ number_format(
$grandTol
, 2) }}</th>
<th class="
right
aligned
">{{ number_format(
$grandParking
, 2) }}</th>
<th class="
right
aligned
">{{ number_format(
$grandAnggaran
, 2) }}</th>
<th></th>
</tr>
</tfoot>
@endif
...
...
@@ -220,7 +246,9 @@
<tr>
<td>{{
$index
+ 1 }}</td>
<td>
@if(
$q->kuiri_by
== 'HOD')
@if(
$q->kuiri_by
=== 'PM')
<span class="
ui
olive
label
">PM</span>
@elseif(
$q->kuiri_by
== 'HOD')
<span class="
ui
teal
label
">HOD</span>
@elseif(
$q->kuiri_by
== 'BOD')
<span class="
ui
violet
label
">BOD</span>
...
...
@@ -245,7 +273,7 @@
@endif
{{-- Action Buttons --}}
@if(in_array(
$claim->status
, [
2, 3
]))
@if(in_array(
$claim->status
, [
5, 8
]))
<div class="
ui
segment
">
<h3 class="
ui
header
">Tindakan HOD</h3>
<form id="
formTindakan
" method="
POST
">
...
...
@@ -322,7 +350,7 @@ function submitTindakan() {
<a href="
{{
route
(
'mileage::HOD.index'
)
}}
" class="
ui
button
">
<i class="
arrow
left
icon
"></i> Kembali
</a>
@if(in_array(
$claim->status
, [
2, 3
]))
@if(in_array(
$claim->status
, [
5, 8
]))
<button type="
button
" onclick="
submitTindakan
()
" class="
ui
violet
button
">
<i class="
send
icon
"></i> Hantar Tindakan
</button>
...
...
packages/portal/mileage/resources/views/PM/index.blade.php
0 → 100644
View file @
358ba95d
@
extends
(
'ui::layouts.app'
)
@
section
(
'content'
)
<
div
class
="
ui
segment
">
<a class="
ui
olive
left
ribbon
label
">PM 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::PM.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
olive
button
">Cari</button>
@if(request('search'))
<a href="
{{
route
(
'mileage::PM.index'
)
}}
" class="
ui
button
">Reset</a>
@endif
</div>
</form>
<table class="
ui
celled
table
">
<thead>
<tr>
<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>
</thead>
<tbody>
@forelse(
$list
as
$index
=>
$claim
)
@php
$refId
=
$claim->lkpStatus
?->ref_id ?? 0;
$color
= match(
$refId
) {
2 => 'blue',
3 => 'yellow',
6 => 'orange',
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>
<a href="
{{
route
(
'mileage::PM.show'
,
$claim
->
id
)
}}
" class="
ui
blue
small
button
">
<i class="
eye
icon
"></i>
</a>
</td>
</tr>
@empty
<tr>
<td colspan="
7
" class="
center
aligned
">Tiada permohonan untuk disemak.</td>
</tr>
@endforelse
</tbody>
</table>
{{
$list->withQueryString
()->links() }}
</div>
</div>
@endsection
packages/portal/mileage/resources/views/PM/show.blade.php
0 → 100644
View file @
358ba95d
This diff is collapsed.
Click to expand it.
packages/portal/mileage/resources/views/finance/show.blade.php
View file @
358ba95d
This diff is collapsed.
Click to expand it.
packages/portal/mileage/resources/views/mileage/form.blade.php
View file @
358ba95d
...
...
@@ -83,12 +83,18 @@
<i class="
info
circle
icon
" style="
cursor
:
pointer
;
color
:
#2185d0;"
onclick
=
"$('#modalAnggaran').modal('show');"
></
i
>
</
th
>
@
if
(
$claim
->
status
==
1
)
<
th
>
Tindakan
</
th
>
@
endif
@
if
(
$claim
->
status
!=
1
)
<
th
class
="
center
aligned
">Status</th>
@endif
</tr>
</thead>
<tbody>
@php
$grandAnggaran
=
0
;
$grandTol
=
0
;
$grandParking
=
0
;
$grandAnggaran
= 0;
$grandTol
= 0;
$grandParking
= 0;
$grandJarak
= 0;
$deductionCount
= 0;
$sortedDetails
=
$claim->details
->sortBy('md_claim_date')->values();
$dateCounts
= [];
foreach (
$sortedDetails
as
$d
) {
...
...
@@ -105,7 +111,12 @@
$dateKey
=
$detail->md_claim_date
;
$isFirstOfDate
= !isset(
$dateFirstSeen[$dateKey]
);
if (
$isFirstOfDate
)
$dateFirstSeen[$dateKey]
= true;
$claimableKm
=
$isFirstOfDate
?
max
(
0
,
$jumlahJarak
-
40
)
:
$jumlahJarak
;
if (
$isFirstOfDate
&&
$deductionCount
< 10) {
$claimableKm
= max(0,
$jumlahJarak
- 40);
$deductionCount
++;
} else {
$claimableKm
=
$jumlahJarak
;
}
$startKm
=
$cumulativeKmByDate[$dateKey]
?? 0;
$endKm
=
$startKm
+
$claimableKm
;
$mileageAmount
= 0;
...
...
@@ -118,6 +129,7 @@
$jumlahParking
= (float)
$detail->md_total_parking_fee
;
$jumlahBelanja
=
$jumlahTol
+
$jumlahParking
;
$anggaranTuntutan
=
$mileageAmount
+
$jumlahBelanja
;
$grandJarak
+=
$jumlahJarak
;
$grandTol
+=
$jumlahTol
;
$grandParking
+=
$jumlahParking
;
$grandAnggaran
+=
$anggaranTuntutan
;
...
...
@@ -134,8 +146,8 @@
<td class="
right
aligned
">{{ number_format(
$jumlahTol
, 2) }}</td>
<td class="
right
aligned
">{{ number_format(
$jumlahParking
, 2) }}</td>
<td class="
right
aligned
">{{ number_format(
$anggaranTuntutan
, 2) }}</td>
<td>
@if(
$claim->status
== 1)
<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
])
}}
"
...
...
@@ -156,12 +168,26 @@
<button type="
submit
" class="
ui
red
button
"><i class="
trash
icon
"></i></button>
</form>
</div>
</td>
@endif
@if(
$claim->status
!= 1)
@php
$totalReviews
=
$detail->pmReviews
->count();
$reviewedCount
=
$detail->pmReviews
->where('status', 'reviewed')->count();
$queriedCount
=
$detail->pmReviews
->where('status', 'queried')->count();
@endphp
<td class="
center
aligned
">
@if(
$totalReviews
=== 0)
<span class="
ui
grey
label
">-</span>
@elseif(
$queriedCount
> 0)
<span class="
ui
yellow
label
"> Dikuiri</span>
@elseif(
$reviewedCount
===
$totalReviews
)
<span class="
ui
green
label
"></i> Disemak</span>
@else
-
<span class="
ui
orange
label
">{{
$reviewedCount
}}/{{
$totalReviews
}} Disemak</span>
@endif
</td>
@endif
</tr>
@empty
...
...
@@ -173,7 +199,8 @@
@if(
$claim->details
->count() > 0)
<tfoot>
<tr>
<th colspan="
6
" class="
right
aligned
">JUMLAH KESELURUHAN (RM)</th>
<th colspan="
5
" class="
right
aligned
">JUMLAH KESELURUHAN</th>
<th class="
right
aligned
">{{ number_format(
$grandJarak
, 1) }}</th>
<th class="
right
aligned
">{{ number_format(
$grandTol
, 2) }}</th>
<th class="
right
aligned
">{{ number_format(
$grandParking
, 2) }}</th>
<th class="
right
aligned
">{{ number_format(
$grandAnggaran
, 2) }}</th>
...
...
packages/portal/mileage/resources/views/mileage/queryForm.blade.php
View file @
358ba95d
...
...
@@ -14,12 +14,17 @@
{{-- HOD Query Info --}}
<div class="
ui
warning
message
">
<div class="
header
">Permohonan Telah Dikuiri Oleh {{
$claim->status
== 10 ? 'BOD' : 'HOD' }}</div>
<p><strong>Catatan {{
$claim->status
== 10 ? 'BOD' : 'HOD' }}:</strong> {{
$query->comment
?? '-' }}</p>
<div class="
header
">Permohonan Telah Dikuiri Oleh
{{
$claim->status
== 6 ? 'PM' : (
$claim->status
== 10 ? 'BOD' : 'HOD') }}
</div>
<p><strong>Catatan
{{
$claim->status
== 6 ? 'PM' : (
$claim->status
== 10 ? 'BOD' : 'HOD') }}:
</strong> {{
$query->comment
?? '-' }}</p>
<p><em>Sila semak butiran dan hantar semula permohonan anda.</em></p>
</div>
{{-- Maklumat Permohonan --}}
<div class="
ui
segment
">
<h3 class="
ui
header
">Maklumat Permohonan</h3>
...
...
@@ -90,11 +95,12 @@
onclick
=
"$('#modalAnggaran').modal('show');"
></
i
>
</
th
>
<
th
>
Tindakan
</
th
>
<
th
class
="
center
aligned
">Status</th>
</tr>
</thead>
<tbody>
@php
$grandAnggaran
=
0
;
$grandTol
=
0
;
$grandParking
=
0
;
$grandAnggaran
= 0;
$grandTol
= 0;
$grandParking
= 0;
$grandJarak
= 0;
$deductionCount
= 0;
$sortedDetails
=
$claim->details
->sortBy('md_claim_date')->values();
$dateCounts
= [];
foreach (
$sortedDetails
as
$d
) {
...
...
@@ -111,7 +117,12 @@
$dateKey
=
$detail->md_claim_date
;
$isFirstOfDate
= !isset(
$dateFirstSeen[$dateKey]
);
if (
$isFirstOfDate
)
$dateFirstSeen[$dateKey]
= true;
$claimableKm
=
$isFirstOfDate
?
max
(
0
,
$jumlahJarak
-
40
)
:
$jumlahJarak
;
if (
$isFirstOfDate
&&
$deductionCount
< 10) {
$claimableKm
= max(0,
$jumlahJarak
- 40);
$deductionCount
++;
} else {
$claimableKm
=
$jumlahJarak
;
}
$startKm
=
$cumulativeKmByDate[$dateKey]
?? 0;
$endKm
=
$startKm
+
$claimableKm
;
$mileageAmount
= 0;
...
...
@@ -124,6 +135,7 @@
$jumlahParking
= (float)
$detail->md_total_parking_fee
;
$jumlahBelanja
=
$jumlahTol
+
$jumlahParking
;
$anggaranTuntutan
=
$mileageAmount
+
$jumlahBelanja
;
$grandJarak
+=
$jumlahJarak
;
$grandTol
+=
$jumlahTol
;
$grandParking
+=
$jumlahParking
;
$grandAnggaran
+=
$anggaranTuntutan
;
...
...
@@ -162,21 +174,39 @@
</form>
</div>
</td>
@php
$totalReviews
=
$detail->pmReviews
->count();
$reviewedCount
=
$detail->pmReviews
->where('status', 'reviewed')->count();
$queriedCount
=
$detail->pmReviews
->where('status', 'queried')->count();
@endphp
<td class="
center
aligned
">
@if(
$totalReviews
=== 0)
<span class="
ui
grey
label
">-</span>
@elseif(
$queriedCount
> 0)
<span class="
ui
yellow
label
"> Dikuiri</span>
@elseif(
$reviewedCount
===
$totalReviews
)
<span class="
ui
green
label
"></i> Disemak</span>
@else
<span class="
ui
orange
label
">{{
$reviewedCount
}}/{{
$totalReviews
}} Disemak</span>
@endif
</td>
</tr>
@empty
<tr>
<td colspan="
1
0
" class="
center
aligned
">Tiada butiran ditambah lagi.</td>
<td colspan="
1
1
" 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 (RM)</th>
<th colspan="
5
" class="
right
aligned
">JUMLAH KESELURUHAN</th>
<th class="
right
aligned
">{{ number_format(
$grandJarak
, 1) }}</th>
<th class="
right
aligned
">{{ number_format(
$grandTol
, 2) }}</th>
<th class="
right
aligned
">{{ number_format(
$grandParking
, 2) }}</th>
<th class="
right
aligned
">{{ number_format(
$grandAnggaran
, 2) }}</th>
<th></th>
<th></th>
</tr>
</tfoot>
@endif
...
...
@@ -346,7 +376,9 @@
<tr>
<td>{{
$index
+ 1 }}</td>
<td>
@if(
$q->kuiri_by
== 'HOD')
@if(
$q->kuiri_by
=== 'PM')
<span class="
ui
olive
label
">PM</span>
@elseif(
$q->kuiri_by
== 'HOD')
<span class="
ui
teal
label
">HOD</span>
@elseif(
$q->kuiri_by
== 'BOD')
<span class="
ui
violet
label
">BOD</span>
...
...
@@ -354,7 +386,7 @@
-
@endif
</td>
<td>{{
$q->comment
?? '-' }}</td>
<td
style="
white
-
space
:
pre
-
line
;
"
>{{
$q->comment
?? '-' }}</td>
<td>
@if(
$q->response
)
{{
$q->response
}}
...
...
@@ -373,18 +405,22 @@
{{-- Response & Resubmit --}}
<div class="
ui
segment
">
<h3 class="
ui
header
">Maklum Balas Kepada HOD</h3>
<h3 class="
ui
header
">Maklum Balas Kepada
{{
$claim->status
== 6 ? 'PM' : (
$claim->status
== 10 ? 'BOD' : 'HOD') }}
</h3>
<form id="
formResubmit
" class="
ui
form
" action="
{{
route
(
'mileage::mileage.claim.resubmit'
,
[
'id'
=>
$claim
->
id
])
}}
" method="
POST
">
@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>
<textarea name="
response
" rows="
3
"
placeholder="
Masukkan
respons
anda
terhadap
catatan
{{
$claim
->
status
==
6
?
'PM'
:
(
$claim
->
status
==
10
?
'BOD'
:
'HOD'
)
}}
...
"
required></textarea>
</div>
<br>
</form>
</div>
<div >
<br>
...
...
packages/portal/mileage/routes/web.php
View file @
358ba95d
...
...
@@ -3,7 +3,7 @@
use
Illuminate\Support\Facades\Route
;
use
Portal\Mileage\Http\Controllers\ApplyformController
;
use
Portal\Mileage\Http\Controllers\ApplicationsController
;
use
Portal\Mileage\Http\Controllers\P
rojectManager
Controller
;
use
Portal\Mileage\Http\Controllers\P
M
Controller
;
use
Portal\Mileage\Http\Controllers\ProjectDirectorController
;
use
Portal\Mileage\Http\Controllers\HODController
;
use
Portal\Mileage\Http\Controllers\BODController
;
...
...
@@ -35,14 +35,13 @@ function () {
Route
::
put
(
'applications/{id}'
,
[
ApplicationsController
::
class
,
'update'
])
->
name
(
'applications.update'
);
// Project Manager
Route
::
prefix
(
'projectManager'
)
->
name
(
'projectManager'
)
->
group
(
function
()
{
Route
::
get
(
'/'
,
[
ProjectManagerController
::
class
,
'index'
])
->
name
(
'.index'
);
Route
::
get
(
'/show/{projectId}/{userId}'
,
[
ProjectManagerController
::
class
,
'show'
])
->
name
(
'.show'
);
Route
::
post
(
'/approve-month'
,
[
ProjectManagerController
::
class
,
'approveMonth'
])
->
name
(
'.approveMonth'
);
Route
::
post
(
'/reject-month'
,
[
ProjectManagerController
::
class
,
'rejectMonth'
])
->
name
(
'.rejectMonth'
);
Route
::
post
(
'/claim/{id}/approve'
,
[
ProjectManagerController
::
class
,
'approveClaim'
])
->
name
(
'.approveClaim'
);
Route
::
post
(
'/claim/{id}/reject'
,
[
ProjectManagerController
::
class
,
'rejectClaim'
])
->
name
(
'.rejectClaim'
);
/// PM
Route
::
prefix
(
'PM'
)
->
name
(
'PM'
)
->
group
(
function
()
{
Route
::
get
(
'/dashboard'
,
[
PMController
::
class
,
'index'
])
->
name
(
'.index'
);
Route
::
get
(
'/show/{id}'
,
[
PMController
::
class
,
'show'
])
->
name
(
'.show'
);
Route
::
post
(
'/detail/{detailId}/review'
,
[
PMController
::
class
,
'reviewDetail'
])
->
name
(
'.reviewDetail'
);
Route
::
post
(
'/detail/{detailId}/kuiri'
,
[
PMController
::
class
,
'kuiriDetail'
])
->
name
(
'.kuiriDetail'
);
Route
::
post
(
'/{id}/submitTindakan'
,
[
PMController
::
class
,
'submitTindakan'
])
->
name
(
'.submitTindakan'
);
});
// Project Director
...
...
packages/portal/mileage/src/Data/Repo/BODRepo.php
View file @
358ba95d
...
...
@@ -7,6 +7,8 @@
use
Portal\Mileage\Model\AuditQuery
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Auth
;
// use App\Models\User;
// use Portal\Mileage\Http\Notifications\MileageMailer;
class
BODRepo
{
...
...
@@ -31,6 +33,7 @@ public function findClaim($id)
return
MileageClaimMain
::
with
([
'details.jenisKenderaan.rates'
,
'details.project'
,
'details.pmReviews'
,
'lkpStatus'
,
'staffInfo'
,
'auditQueries'
,
...
...
@@ -56,6 +59,26 @@ public function luluskanClaim($id)
'remark'
=>
Auth
::
user
()
->
name
.
' Telah Luluskan Permohonan Tuntutan Mileage (mileage_claim_main.id = '
.
$id
.
')'
,
]);
// $claim->load('staffInfo');
// $staff = User::find($claim->staffInfo?->fk_users);
// if ($staff && filter_var($staff->email, FILTER_VALIDATE_EMAIL)) {
// $message = collect([
// 'title' => 'Makluman Tuntutan Mileage Anda Telah Diluluskan',
// 'level' => 'success',
// 'content' => [
// 'Assalamualaikum w.b.t ' . $staff->name . ',',
// 'No. Permohonan: ' . $claim->mm_apply_no,
// 'Tuntutan mileage anda telah diluluskan dan dikemukakan kepada Kewangan untuk semakan.',
// 'Sila log masuk ke sistem untuk maklumat lanjut.',
// ],
// 'footer' => [
// 'Ini adalah mesej automatik dari sistem. Sila jangan balas emel ini.',
// ],
// ]);
// $staff->notify(new MileageMailer($message));
// }
return
$claim
;
}
...
...
packages/portal/mileage/src/Data/Repo/FinanceRepo.php
View file @
358ba95d
...
...
@@ -9,6 +9,8 @@
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Auth
;
use
Carbon\Carbon
;
// use App\Models\User;
// use Portal\Mileage\Http\Notifications\MileageMailer;
class
FinanceRepo
{
...
...
@@ -45,6 +47,7 @@ public function findClaim($id)
return
MileageClaimMain
::
with
([
'details.jenisKenderaan.rates'
,
'details.project'
,
'details.pmReviews'
,
'lkpStatus'
,
'staffInfo'
,
'auditQueries'
,
...
...
@@ -119,6 +122,27 @@ public function semakClaim($id, $remark = null)
'remark'
=>
Auth
::
user
()
->
name
.
' Telah Semak Permohonan Tuntutan Mileage (mileage_claim_main.id = '
.
$id
.
')'
,
]);
// $claim->load('staffInfo');
// $staff = User::find($claim->staffInfo?->fk_users);
// if ($staff && filter_var($staff->email, FILTER_VALIDATE_EMAIL)) {
// $message = collect([
// 'title' => 'Makluman Tuntutan Mileage Anda Telah Disemak Kewangan',
// 'level' => 'success',
// 'content' => [
// 'Assalamualaikum w.b.t ' . $staff->name . ',',
// 'No. Permohonan: ' . $claim->mm_apply_no,
// 'Tuntutan mileage anda telah disemak oleh Kewangan.',
// 'Jumlah Akhir Tuntutan: RM ' . number_format($finalAmount, 2),
// 'Sila log masuk ke sistem untuk melihat butiran pelarasan kewangan.',
// ],
// 'footer' => [
// 'Ini adalah mesej automatik dari sistem. Sila jangan balas emel ini.',
// ],
// ]);
// $staff->notify(new MileageMailer($message));
// }
return
$claim
;
}
...
...
@@ -143,13 +167,19 @@ private function calculateTotal($claim)
$sortedDetails
=
$claim
->
details
->
sortBy
(
'md_claim_date'
)
->
values
();
$dateFirstSeen
=
[];
$cumulativeKmByDate
=
[];
$deductionCount
=
0
;
foreach
(
$sortedDetails
as
$detail
)
{
$jumlahJarak
=
(
float
)
$detail
->
md_total_mileage
;
$dateKey
=
$detail
->
md_claim_date
;
$isFirstOfDate
=
!
isset
(
$dateFirstSeen
[
$dateKey
]);
if
(
$isFirstOfDate
)
$dateFirstSeen
[
$dateKey
]
=
true
;
$claimableKm
=
$isFirstOfDate
?
max
(
0
,
$jumlahJarak
-
40
)
:
$jumlahJarak
;
if
(
$isFirstOfDate
&&
$deductionCount
<
10
)
{
$claimableKm
=
max
(
0
,
$jumlahJarak
-
40
);
$deductionCount
++
;
}
else
{
$claimableKm
=
$jumlahJarak
;
}
$startKm
=
$cumulativeKmByDate
[
$dateKey
]
??
0
;
$endKm
=
$startKm
+
$claimableKm
;
$mileageAmount
=
0
;
...
...
packages/portal/mileage/src/Data/Repo/HODRepo.php
View file @
358ba95d
...
...
@@ -7,6 +7,8 @@
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Auth
;
use
Portal\Mileage\Model\AuditQuery
;
// use App\Models\User;
// use Portal\Mileage\Http\Notifications\MileageMailer;
class
HODRepo
{
...
...
@@ -15,7 +17,7 @@ public function getHodList($request)
$search
=
$request
->
get
(
'search'
);
return
MileageClaimMain
::
with
([
'lkpStatus'
,
'staffInfo'
])
->
whereIn
(
'status'
,
[
2
,
3
])
->
whereIn
(
'status'
,
[
5
])
->
whereHas
(
'staffInfo'
,
function
(
$q
)
{
$q
->
where
(
'penyokong'
,
Auth
::
id
());
})
...
...
@@ -61,8 +63,16 @@ public function getHodHistory($request)
public
function
findClaim
(
$id
)
{
return
MileageClaimMain
::
with
([
'details.jenisKenderaan.rates'
,
'details.project'
,
'lkpStatus'
,
'staffInfo'
,
'auditQueries'
,
'attachments'
,
'faCategory'
])
->
findOrFail
(
$id
);
return
MileageClaimMain
::
with
([
'details.jenisKenderaan.rates'
,
'details.project'
,
'details.pmReviews'
,
'lkpStatus'
,
'staffInfo'
,
'auditQueries'
,
'attachments'
,
'faCategory'
])
->
findOrFail
(
$id
);
}
...
...
@@ -83,6 +93,26 @@ public function sokongClaim($id, $comment = null)
'remark'
=>
Auth
::
user
()
->
name
.
' Telah Sokong Permohonan Tuntutan Mileage (mileage_claim_main.id = '
.
$id
.
')'
,
]);
// $claim->load('staffInfo');
// $staff = User::find($claim->staffInfo?->fk_users);
// if ($staff && filter_var($staff->email, FILTER_VALIDATE_EMAIL)) {
// $message = collect([
// 'title' => 'Makluman Tuntutan Mileage Anda Telah Disokong',
// 'level' => 'success',
// 'content' => [
// 'Assalamualaikum w.b.t ' . $staff->name . ',',
// 'No. Permohonan: ' . $claim->mm_apply_no,
// 'Tuntutan mileage anda telah disokong dan dikemukakan kepada BOD untuk kelulusan.',
// 'Sila log masuk ke sistem untuk maklumat lanjut.',
// ],
// 'footer' => [
// 'Ini adalah mesej automatik dari sistem. Sila jangan balas emel ini.',
// ],
// ]);
// $staff->notify(new MileageMailer($message));
// }
return
$claim
;
}
...
...
packages/portal/mileage/src/Data/Repo/MileageRepo.php
View file @
358ba95d
...
...
@@ -10,6 +10,7 @@
use
Portal\Mileage\Model\MileageClaimAuditTrail
;
use
Portal\Mileage\Model\AuditQuery
;
use
Portal\Mileage\Model\MileageClaimAttachment
;
use
Portal\Mileage\Model\MileageClaimPmReview
;
use
Illuminate\Support\Facades\Auth
;
use
Illuminate\Http\Request
;
...
...
@@ -19,7 +20,7 @@
use
Carbon\Carbon
;
use
App\Events\AuditLog
;
use
DB
;
use
Illuminate\Support\Facades\
DB
;
use
Event
;
use
File
;
use
Mail
;
...
...
@@ -88,7 +89,16 @@ public function storeClaim($request)
public
function
findClaim
(
$id
)
{
return
MileageClaimMain
::
with
([
'details.jenisKenderaan.rates'
,
'details.project'
,
'auditQueries'
,
'attachments'
,
'faCategory'
,
'lkpStatus'
,
'financeDetail'
])
->
findOrFail
(
$id
);
return
MileageClaimMain
::
with
([
'details.jenisKenderaan.rates'
,
'details.project'
,
'details.pmReviews'
,
'auditQueries'
,
'attachments'
,
'faCategory'
,
'lkpStatus'
,
'financeDetail'
])
->
findOrFail
(
$id
);
}
...
...
@@ -100,12 +110,20 @@ public function getJenisKenderaan()
public
function
getProjects
()
{
$employeeCode
=
Auth
::
user
()
->
employeeCode
;
return
Project
::
where
(
'p_project_sts'
,
1
)
->
whereHas
(
'projectTeam'
,
function
(
$q
)
use
(
$employeeCode
)
{
$q
->
where
(
'pt_staff_id'
,
$employeeCode
);
})
->
orderBy
(
'p_project_code'
)
->
get
();
}
public
function
getFaCategories
()
{
return
LkpFaCategory
::
orderBy
(
'id'
)
->
get
();
...
...
@@ -165,7 +183,7 @@ public function updateDetail($request, $detailId)
public
function
submitClaim
(
$id
)
{
$claim
=
MileageClaimMain
::
findOrFail
(
$id
);
$claim
=
MileageClaimMain
::
with
(
'details'
)
->
findOrFail
(
$id
);
$claim
->
update
([
'status'
=>
2
,
...
...
@@ -179,11 +197,30 @@ public function submitClaim($id)
'remark'
=>
Auth
::
user
()
->
name
.
' Telah Hantar Permohonan Tuntutan Mileage (mileage_claim_main.id = '
.
$id
.
')'
,
]);
foreach
(
$claim
->
details
as
$detail
)
{
if
(
!
$detail
->
fk_lkp_project
)
continue
;
$pms
=
DB
::
table
(
'project_team'
)
->
where
(
'fk_project_id'
,
$detail
->
fk_lkp_project
)
->
where
(
'role_id'
,
1
)
->
pluck
(
'pt_staff_id'
);
foreach
(
$pms
as
$pmCode
)
{
MileageClaimPmReview
::
create
([
'fk_claim_id'
=>
$id
,
'fk_detail_id'
=>
$detail
->
id
,
'pm_employee_code'
=>
$pmCode
,
'status'
=>
'pending'
,
]);
}
}
return
$claim
;
}
public
function
resubmitClaim
(
$id
,
$response
)
{
{
$claim
=
MileageClaimMain
::
findOrFail
(
$id
);
$query
=
AuditQuery
::
where
(
'fk_main'
,
$id
)
...
...
@@ -195,6 +232,19 @@ public function resubmitClaim($id, $response)
$query
->
update
([
'response'
=>
$response
]);
}
if
(
$claim
->
status
==
6
)
{
// PM kuiri: only reset the specific butiran that were queried
// Other PMs' reviewed records stay intact
MileageClaimPmReview
::
where
(
'fk_claim_id'
,
$id
)
->
where
(
'status'
,
'queried'
)
->
update
([
'status'
=>
'pending'
,
'note'
=>
null
]);
}
elseif
(
in_array
(
$claim
->
status
,
[
8
,
10
]))
{
// HOD or BOD kuiri: reset ALL pm_review records
// Claim must start over from PM level
MileageClaimPmReview
::
where
(
'fk_claim_id'
,
$id
)
->
update
([
'status'
=>
'pending'
,
'note'
=>
null
]);
}
$claim
->
update
([
'status'
=>
3
,
'query_status'
=>
null
,
...
...
@@ -209,7 +259,8 @@ public function resubmitClaim($id, $response)
]);
return
$claim
;
}
}
public
function
saveDraftClaim
(
$id
)
{
...
...
packages/portal/mileage/src/Data/Repo/PMRepo.php
0 → 100644
View file @
358ba95d
<?php
namespace
Portal\Mileage\Data\Repo
;
use
Portal\Mileage\Model\MileageClaimMain
;
use
Portal\Mileage\Model\MileageClaimPmReview
;
use
Portal\Mileage\Model\MileageClaimAuditTrail
;
use
Portal\Mileage\Model\AuditQuery
;
use
Illuminate\Support\Facades\Auth
;
use
Carbon\Carbon
;
class
PMRepo
{
public
function
getPmList
(
$request
)
{
$search
=
$request
->
get
(
'search'
);
$employeeCode
=
Auth
::
user
()
->
employeeCode
;
return
MileageClaimMain
::
with
([
'lkpStatus'
,
'staffInfo'
])
->
whereIn
(
'status'
,
[
2
,
3
])
->
whereHas
(
'pmReviews'
,
function
(
$q
)
use
(
$employeeCode
)
{
$q
->
where
(
'pm_employee_code'
,
$employeeCode
);
})
->
when
(
$search
,
function
(
$q
)
use
(
$search
)
{
$q
->
where
(
'mm_apply_no'
,
'like'
,
'%'
.
$search
.
'%'
);
})
->
orderBy
(
'created_at'
,
'desc'
)
->
paginate
(
10
);
}
public
function
findClaim
(
$id
)
{
return
MileageClaimMain
::
with
([
'details.jenisKenderaan.rates'
,
'details.project'
,
'details.pmReviews'
,
'lkpStatus'
,
'staffInfo'
,
'auditQueries'
,
'attachments'
,
'faCategory'
,
])
->
findOrFail
(
$id
);
}
public
function
reviewDetail
(
$detailId
)
{
$employeeCode
=
Auth
::
user
()
->
employeeCode
;
$review
=
MileageClaimPmReview
::
where
(
'fk_detail_id'
,
$detailId
)
->
where
(
'pm_employee_code'
,
$employeeCode
)
->
firstOrFail
();
$review
->
update
([
'status'
=>
'reviewed'
]);
}
public
function
kuiriDetail
(
$detailId
,
$note
)
{
$employeeCode
=
Auth
::
user
()
->
employeeCode
;
$review
=
MileageClaimPmReview
::
where
(
'fk_detail_id'
,
$detailId
)
->
where
(
'pm_employee_code'
,
$employeeCode
)
->
firstOrFail
();
$review
->
update
([
'status'
=>
'queried'
,
'note'
=>
$note
]);
}
public
function
submitTindakan
(
$claimId
)
{
$employeeCode
=
Auth
::
user
()
->
employeeCode
;
$claim
=
MileageClaimMain
::
findOrFail
(
$claimId
);
$myReviews
=
MileageClaimPmReview
::
where
(
'fk_claim_id'
,
$claimId
)
->
where
(
'pm_employee_code'
,
$employeeCode
)
->
with
(
'claimDetail.project'
)
->
get
();
$queriedReviews
=
$myReviews
->
where
(
'status'
,
'queried'
);
if
(
$queriedReviews
->
count
()
>
0
)
{
$lines
=
$queriedReviews
->
map
(
function
(
$r
)
{
$detail
=
$r
->
claimDetail
;
$projCode
=
$detail
->
project
?->
p_project_code
??
'Tiada Projek'
;
$date
=
Carbon
::
parse
(
$detail
->
md_claim_date
)
->
format
(
'd/m/Y'
);
return
"(
{
$date
}
|
{
$projCode
}
|
{
$detail
->
md_description
}
):
{
$r
->
note
}
"
;
})
->
implode
(
"
\n
"
);
AuditQuery
::
create
([
'fk_main'
=>
$claimId
,
'user_id'
=>
Auth
::
id
(),
'comment'
=>
$lines
,
'kuiri_by'
=>
'PM'
,
]);
$claim
->
update
([
'status'
=>
6
,
'query_status'
=>
1
,
]);
MileageClaimAuditTrail
::
create
([
'fk_lkp_mileage_task'
=>
15
,
'fk_mileage_claim_main'
=>
$claimId
,
'action_by'
=>
Auth
::
id
(),
'remark'
=>
Auth
::
user
()
->
name
.
' Telah Kuiri Permohonan Tuntutan Mileage (mileage_claim_main.id = '
.
$claimId
.
')'
,
]);
}
else
{
$this
->
checkAllReviewed
(
$claimId
);
}
}
private
function
checkAllReviewed
(
$claimId
)
{
$pendingCount
=
MileageClaimPmReview
::
where
(
'fk_claim_id'
,
$claimId
)
->
where
(
'status'
,
'pending'
)
->
count
();
if
(
$pendingCount
===
0
)
{
$claim
=
MileageClaimMain
::
findOrFail
(
$claimId
);
$claim
->
update
([
'status'
=>
5
]);
MileageClaimAuditTrail
::
create
([
'fk_lkp_mileage_task'
=>
14
,
'fk_mileage_claim_main'
=>
$claimId
,
'action_by'
=>
Auth
::
id
(),
'remark'
=>
'Semua PM telah menyemak. Permohonan dikemukakan kepada HOD. (mileage_claim_main.id = '
.
$claimId
.
')'
,
]);
}
}
}
packages/portal/mileage/src/Http/Controllers/MileageController.php
View file @
358ba95d
...
...
@@ -70,11 +70,12 @@ public function storeClaim(Request $request)
public
function
formClaim
(
Request
$request
,
$id
)
{
$claim
=
$this
->
repos
->
findClaim
(
$id
);
$jenisKenderaan
=
$this
->
repos
->
getJenisKenderaan
();
$projects
=
$this
->
repos
->
getProjects
();
if
(
in_array
(
$claim
->
status
,
[
8
,
10
]))
{
if
(
in_array
(
$claim
->
status
,
[
6
,
8
,
10
]))
{
$query
=
$claim
->
auditQueries
()
->
whereNull
(
'response'
)
->
latest
()
->
first
();
return
view
(
'mileage::mileage.queryForm'
,
compact
(
'claim'
,
'jenisKenderaan'
,
'projects'
,
'query'
));
}
...
...
packages/portal/mileage/src/Http/Controllers/PMController.php
0 → 100644
View file @
358ba95d
<?php
namespace
Portal\Mileage\Http\Controllers
;
use
Illuminate\Routing\Controller
;
use
Illuminate\Http\Request
;
use
Portal\Mileage\Data\Repo\PMRepo
;
class
PMController
extends
Controller
{
protected
$repos
;
public
function
__construct
(
PMRepo
$repos
)
{
$this
->
repos
=
$repos
;
}
public
function
index
(
Request
$request
)
{
$list
=
$this
->
repos
->
getPmList
(
$request
);
return
view
(
'mileage::PM.index'
,
compact
(
'list'
));
}
public
function
show
(
$id
)
{
$claim
=
$this
->
repos
->
findClaim
(
$id
);
return
view
(
'mileage::PM.show'
,
compact
(
'claim'
));
}
public
function
reviewDetail
(
Request
$request
,
$detailId
)
{
$this
->
repos
->
reviewDetail
(
$detailId
);
return
redirect
()
->
back
()
->
with
(
'success'
,
'Butiran berjaya disemak.'
);
}
public
function
kuiriDetail
(
Request
$request
,
$detailId
)
{
$request
->
validate
([
'kuiri_note'
=>
'required|string|max:500'
,
]);
$this
->
repos
->
kuiriDetail
(
$detailId
,
$request
->
kuiri_note
);
return
redirect
()
->
back
()
->
with
(
'success'
,
'Butiran telah ditandakan sebagai kuiri.'
);
}
public
function
submitTindakan
(
Request
$request
,
$id
)
{
$this
->
repos
->
submitTindakan
(
$id
);
return
redirect
()
->
route
(
'mileage::PM.index'
)
->
with
(
'success'
,
'Tindakan berjaya dihantar.'
);
}
}
packages/portal/mileage/src/Http/Controllers/ProjectManagerController.php
deleted
100644 → 0
View file @
49fda619
<?php
namespace
Portal\Mileage\Http\Controllers
;
use
Portal\Mileage\Model\Users
;
use
Portal\Mileage\Model\Claim
;
use
Portal\Mileage\Model\Project
;
use
Portal\Mileage\Model\ProjectTeam
;
use
App\Http\Controllers\Controller
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Auth
;
use
Carbon\Carbon
;
class
ProjectManagerController
extends
Controller
{
/**
* Display the project manager dashboard (monthly view only).
*/
public
function
index
(
Request
$request
)
{
$manager
=
Auth
::
user
();
$month
=
$request
->
input
(
'month'
,
Carbon
::
now
()
->
format
(
'Y-m'
));
try
{
// validate the format (YYYY-MM)
if
(
!
preg_match
(
'/^\d{4}-\d{2}$/'
,
$month
))
{
$month
=
now
()
->
format
(
'Y-m'
);
}
$parsedMonth
=
Carbon
::
createFromFormat
(
'Y-m'
,
$month
);
}
catch
(
\Exception
$e
)
{
$month
=
now
()
->
format
(
'Y-m'
);
$parsedMonth
=
Carbon
::
createFromFormat
(
'Y-m'
,
$month
);
}
// Get project IDs assigned to this Project Manager
$projectIds
=
\Portal\Mileage\Model\ProjectTeam
::
where
(
'pt_staff_id'
,
$manager
->
employeeCode
)
->
where
(
'role_id'
,
1
)
// "Project Manager" role
->
pluck
(
'fk_project_id'
);
// Get projects under the PM
$projects
=
\Portal\Mileage\Model\Project
::
whereIn
(
'id'
,
$projectIds
)
->
get
();
// Get all claims for those projects in the selected month
$claims
=
\Portal\Mileage\Model\Claim
::
with
([
'user'
,
'project'
])
->
whereIn
(
'project_id'
,
$projectIds
)
->
whereMonth
(
'claim_date'
,
$parsedMonth
->
month
)
->
whereYear
(
'claim_date'
,
$parsedMonth
->
year
)
->
get
();
return
view
(
'mileage::projectManager.index'
,
compact
(
'projects'
,
'claims'
,
'month'
));
}
/**
* Show all claims for one staff for the selected month.
*/
public
function
show
(
$projectId
,
$userId
,
Request
$request
)
{
$month
=
$request
->
input
(
'month'
,
Carbon
::
now
()
->
format
(
'Y-m'
));
try
{
if
(
!
preg_match
(
'/^\d{4}-\d{2}$/'
,
$month
))
{
$month
=
now
()
->
format
(
'Y-m'
);
}
$parsedMonth
=
Carbon
::
createFromFormat
(
'Y-m'
,
$month
);
}
catch
(
\Exception
$e
)
{
$month
=
now
()
->
format
(
'Y-m'
);
$parsedMonth
=
Carbon
::
createFromFormat
(
'Y-m'
,
$month
);
}
$project
=
\Portal\Mileage\Model\Project
::
findOrFail
(
$projectId
);
$user
=
\Portal\Mileage\Model\Users
::
findOrFail
(
$userId
);
$claims
=
\Portal\Mileage\Model\Claim
::
with
([
'project'
])
->
where
(
'project_id'
,
$projectId
)
->
where
(
'user_id'
,
$userId
)
->
whereMonth
(
'claim_date'
,
$parsedMonth
->
month
)
->
whereYear
(
'claim_date'
,
$parsedMonth
->
year
)
->
orderBy
(
'claim_date'
,
'asc'
)
->
get
();
return
view
(
'mileage::projectManager.show'
,
compact
(
'project'
,
'user'
,
'claims'
,
'month'
));
}
/**
* Approve all pending claims for a specific project in the selected month.
*/
public
function
approveMonth
(
Request
$request
)
{
$manager
=
Auth
::
user
();
$monthLabel
=
$request
->
input
(
'month'
);
$projectId
=
$request
->
input
(
'project_id'
);
// require project_id
if
(
!
$projectId
)
{
return
back
()
->
with
(
'error'
,
'Sila pilih projek untuk disokong.'
);
}
// validate month format (expects YYYY-MM)
try
{
if
(
!
preg_match
(
'/^\d{4}-\d{2}$/'
,
$monthLabel
))
{
throw
new
\Exception
(
'Invalid month format'
);
}
$parsedMonth
=
Carbon
::
createFromFormat
(
'Y-m'
,
$monthLabel
);
}
catch
(
\Exception
$e
)
{
return
back
()
->
with
(
'error'
,
'Format bulan tidak sah. Sila pilih semula bulan dalam format YYYY-MM.'
);
}
// ensure manager oversees this project
$allowedProjectIds
=
ProjectTeam
::
where
(
'pt_staff_id'
,
$manager
->
employeeCode
)
->
where
(
'role_id'
,
1
)
// project manager role
->
pluck
(
'fk_project_id'
)
->
toArray
();
if
(
!
in_array
(
$projectId
,
$allowedProjectIds
))
{
return
back
()
->
with
(
'error'
,
'Anda tidak dibenarkan melakukan tindakan ini untuk projek terpilih.'
);
}
// update only claims for this project and month with status 'Diproses'
$approvedCount
=
Claim
::
where
(
'project_id'
,
$projectId
)
->
whereMonth
(
'claim_date'
,
$parsedMonth
->
month
)
->
whereYear
(
'claim_date'
,
$parsedMonth
->
year
)
->
where
(
'status'
,
'Diproses'
)
->
update
([
'status'
=>
'Disokong'
,
'approved_by'
=>
$manager
->
id
,
'updated_at'
=>
now
(),
]);
if
(
$approvedCount
>
0
)
{
return
back
()
->
with
(
'success'
,
$approvedCount
.
' tuntutan telah disokong untuk projek ini bagi bulan '
.
$monthLabel
.
'.'
);
}
return
back
()
->
with
(
'warning'
,
'Tiada tuntutan "Diproses" untuk disokong bagi projek ini pada bulan '
.
$monthLabel
.
'.'
);
}
/**
* Reject all pending claims for a specific project in the selected month.
*/
public
function
rejectMonth
(
Request
$request
)
{
$request
->
validate
([
'project_id'
=>
'required|integer'
,
'user_id'
=>
'required|integer'
,
'month'
=>
'required|string'
,
'reject_reason'
=>
'required|string|max:500'
,
]);
$month
=
Carbon
::
createFromFormat
(
'Y-m'
,
$request
->
month
);
$claims
=
Claim
::
where
(
'project_id'
,
$request
->
project_id
)
->
where
(
'user_id'
,
$request
->
user_id
)
->
whereMonth
(
'claim_date'
,
$month
->
month
)
->
whereYear
(
'claim_date'
,
$month
->
year
)
->
get
();
foreach
(
$claims
as
$claim
)
{
$claim
->
status
=
'Ditolak'
;
$claim
->
rejected_by
=
auth
()
->
id
();
$claim
->
reject_reason
=
$request
->
reject_reason
;
$claim
->
save
();
}
return
redirect
()
->
back
()
->
with
(
'success'
,
'Semua tuntutan telah ditolak dengan sebab: '
.
$request
->
reject_reason
);
}
public
function
approveClaim
(
$id
)
{
$claim
=
Claim
::
findOrFail
(
$id
);
$claim
->
status
=
'Disokong'
;
$claim
->
verified_by
=
auth
()
->
id
();
$claim
->
save
();
return
back
()
->
with
(
'success'
,
'Tuntutan telah disahkan.'
);
}
public
function
rejectClaim
(
Request
$request
,
$id
)
{
$request
->
validate
([
'reject_reason'
=>
'required|string|max:500'
]);
$claim
=
Claim
::
findOrFail
(
$id
);
$claim
->
status
=
'Ditolak'
;
$claim
->
rejected_by
=
auth
()
->
id
();
$claim
->
reject_reason
=
$request
->
reject_reason
;
$claim
->
save
();
return
back
()
->
with
(
'success'
,
'Tuntutan telah ditolak dengan sebab: '
.
$request
->
reject_reason
);
}
}
packages/portal/mileage/src/Http/Notifications/PpjMailer.php
deleted
100644 → 0
View file @
49fda619
<?php
namespace
Portal\Mileage\Http\Notifications
;
use
Illuminate\Bus\Queueable
;
use
Illuminate\Notifications\Notification
;
use
Illuminate\Contracts\Queue\ShouldQueue
;
use
Illuminate\Notifications\Messages\MailMessage
;
class
PpjMailer
extends
Notification
implements
ShouldQueue
{
use
Queueable
;
protected
$view
=
'ecuti::emails.layouts.simple'
;
public
$message
;
/**
* Create a new notification instance.
*
* @return void
*/
public
function
__construct
(
$message
,
$view
=
FALSE
)
{
$this
->
message
=
$message
;
$this
->
view
=
(
$view
)
?
$view
:
$this
->
view
;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public
function
via
(
$notifiable
)
{
return
[
'mail'
];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public
function
toMail
(
$notifiable
)
{
$mailMessage
=
new
MailMessage
;
if
(
$this
->
view
)
$mailMessage
->
view
=
$this
->
view
;
$mailMessage
->
subject
(
$this
->
message
->
get
(
'title'
,
'Email From '
));
// $mailMessage->title($this->message->get('title', 'Email From ' ));
$mailMessage
->
level
(
$this
->
message
->
get
(
'level'
));
// $mailMessage->greeting('Hi,' . ' ' .$notifiable->name. ', ');
$content
=
$this
->
message
->
get
(
'content'
,[]);
// dd($content);
foreach
(
$content
as
$cont
){
$mailMessage
->
line
(
$cont
);
}
$action
=
$this
->
message
->
get
(
'action'
,
FALSE
);
if
(
$action
)
:
foreach
(
$action
as
$title
=>
$uri
){
$mailMessage
->
action
(
$title
,
$uri
);
}
endif
;
$footer
=
$this
->
message
->
get
(
'footer'
,[]);
foreach
(
$footer
as
$foot
){
$mailMessage
->
line
(
$foot
);
}
// dd($mailMessage);
// $mailMessage->cc('portalppjadmin@ppj.gov.my');
// $mailMessage->bcc('pss3frsb@gmail.com'); // bcc email ke pss3frsb
return
$mailMessage
;
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public
function
toArray
(
$notifiable
)
{
}
}
packages/portal/mileage/src/Model/MileageClaimDetail.php
View file @
358ba95d
...
...
@@ -35,4 +35,9 @@ public function project()
{
return
$this
->
belongsTo
(
Project
::
class
,
'fk_lkp_project'
);
}
public
function
pmReviews
()
{
return
$this
->
hasMany
(
MileageClaimPmReview
::
class
,
'fk_detail_id'
);
}
}
packages/portal/mileage/src/Model/MileageClaimMain.php
View file @
358ba95d
...
...
@@ -6,6 +6,7 @@
use
Illuminate\Database\Eloquent\Model
;
use
Portal\Mileage\Model\AuditQuery
;
use
Portal\Mileage\Model\MileageClaimFinance
;
use
Portal\Mileage\Model\MileageClaimPmReview
;
class
MileageClaimMain
extends
Model
{
...
...
@@ -106,6 +107,10 @@ public function financeDetail()
return
$this
->
hasOne
(
MileageClaimFinance
::
class
,
'fk_mileage_claim_main'
);
}
public
function
pmReviews
()
{
return
$this
->
hasMany
(
MileageClaimPmReview
::
class
,
'fk_claim_id'
);
}
}
packages/portal/mileage/src/Model/MileageClaimPmReview.php
0 → 100644
View file @
358ba95d
<?php
namespace
Portal\Mileage\Model
;
use
Illuminate\Database\Eloquent\Model
;
class
MileageClaimPmReview
extends
Model
{
protected
$table
=
'mileage_claim_pm_review'
;
protected
$fillable
=
[
'fk_claim_id'
,
'fk_detail_id'
,
'pm_employee_code'
,
'status'
,
'note'
,
];
public
function
claimMain
()
{
return
$this
->
belongsTo
(
MileageClaimMain
::
class
,
'fk_claim_id'
);
}
public
function
claimDetail
()
{
return
$this
->
belongsTo
(
MileageClaimDetail
::
class
,
'fk_detail_id'
);
}
}
packages/portal/mileage/src/Model/ProjectTeam.php
View file @
358ba95d
...
...
@@ -23,9 +23,10 @@ public function project()
// if you want, link to App user model (pt_staff_id commonly stores App user id or employee code)
public
function
user
()
{
return
$this
->
belongsTo
(
\App\Models\User
::
class
,
'pt_staff_id'
,
'
id
'
);
return
$this
->
belongsTo
(
\App\Models\User
::
class
,
'pt_staff_id'
,
'
employeeCode
'
);
}
public
function
role
()
{
return
$this
->
belongsTo
(
ProjectRole
::
class
,
'role_id'
);
...
...
packages/portal/mileage/src/ServiceProvider.php
View file @
358ba95d
...
...
@@ -91,10 +91,10 @@ protected function menu()
->
active
(
'mileage/*'
)
->
data
(
'permission'
,
Permission
::
STAFF
);
// $menu->add(__('Project Manager Dashboard'), route('mileage::projectManager
.index'))
//
->data('icon', 'briefcase')
//
->active('projectManager/*')
//
->data('permission', Permission::PROJECT_MANAGER);
$menu
->
add
(
__
(
'Project Manager Dashboard'
),
route
(
'mileage::PM
.index'
))
->
data
(
'icon'
,
'briefcase'
)
->
active
(
'projectManager/*'
)
->
data
(
'permission'
,
Permission
::
PROJECT_MANAGER
);
// $menu->add(__('Project Director Dashboard'), route('mileage::projectDirector.index'))
// ->data('icon', 'compass')
...
...
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