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
dcd229aa
Commit
dcd229aa
authored
Jun 19, 2026
by
Muhammad Danial Bin Mohd Zaidi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
overtime claim - audit trail
parent
2b6dcc3b
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
526 additions
and
86 deletions
+526
-86
database/migrations/seperate/2026_06_19_031007_create_lkp_overtime_task_table.php
+28
-0
database/migrations/seperate/2026_06_19_031025_create_overtime_audit_trail_table.php
+31
-0
packages/portal/overtime/resources/views/overtime/audit_trail.blade.php
+85
-0
packages/portal/overtime/resources/views/overtime/list.blade.php
+18
-8
packages/portal/overtime/resources/views/overtime/modal/create_modal.blade.php
+42
-14
packages/portal/overtime/resources/views/overtime/modal/view_modal.blade.php
+2
-10
packages/portal/overtime/resources/views/overtime/overtimeclaim/edit.blade.php
+44
-16
packages/portal/overtime/routes/web.php
+1
-0
packages/portal/overtime/src/Data/Repo/OvertimeClaimRepo.php
+146
-17
packages/portal/overtime/src/Http/Controllers/OvertimeClaimController.php
+86
-18
packages/portal/overtime/src/Model/LkpOvertimeTask.php
+15
-0
packages/portal/overtime/src/Model/OvertimeAuditTrail.php
+27
-0
packages/portal/overtime/src/Model/OvertimeClaimDetail.php
+1
-3
No files found.
database/migrations/seperate/2026_06_19_031007_create_lkp_overtime_task_table.php
0 → 100644
View file @
dcd229aa
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
return
new
class
extends
Migration
{
public
function
up
()
:
void
{
Schema
::
create
(
'lkp_overtime_task'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'task_name'
);
$table
->
string
(
'task_code'
)
->
unique
();
$table
->
boolean
(
'is_active'
)
->
default
(
true
);
$table
->
integer
(
'created_by'
)
->
nullable
();
$table
->
integer
(
'updated_by'
)
->
nullable
();
$table
->
timestamps
();
$table
->
softDeletes
();
});
}
public
function
down
()
:
void
{
Schema
::
dropIfExists
(
'lkp_overtime_task'
);
}
};
\ No newline at end of file
database/migrations/seperate/2026_06_19_031025_create_overtime_audit_trail_table.php
0 → 100644
View file @
dcd229aa
<?php
use
Illuminate\Database\Migrations\Migration
;
use
Illuminate\Database\Schema\Blueprint
;
use
Illuminate\Support\Facades\Schema
;
return
new
class
extends
Migration
{
public
function
up
()
:
void
{
Schema
::
create
(
'overtime_audit_trail'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
integer
(
'fk_overtime_claim_main'
)
->
nullable
();
$table
->
integer
(
'fk_overtime_claim_detail'
)
->
nullable
();
$table
->
integer
(
'fk_lkp_overtime_task'
)
->
nullable
();
$table
->
integer
(
'user'
)
->
nullable
();
$table
->
text
(
'description'
)
->
nullable
();
$table
->
timestamps
();
$table
->
index
(
'fk_overtime_claim_main'
);
$table
->
index
(
'fk_overtime_claim_detail'
);
$table
->
index
(
'fk_lkp_overtime_task'
);
});
}
public
function
down
()
:
void
{
Schema
::
dropIfExists
(
'overtime_audit_trail'
);
}
};
\ No newline at end of file
packages/portal/overtime/resources/views/overtime/audit_trail.blade.php
0 → 100644
View file @
dcd229aa
@
extends
(
'ui::layouts.app'
)
@
section
(
'content'
)
<
style
>
.
at
-
tbl
td
{
vertical
-
align
:
middle
;
}
.
at
-
desc
{
font
-
size
:
.
85
rem
;
color
:
#333; }
.
at
-
date
{
font
-
size
:
.
8
rem
;
color
:
#888; white-space: nowrap; }
</
style
>
<
div
class
="
ui
segment
">
<a class="
ui
teal
left
ribbon
label
">Audit Trail Tuntutan Lebih Masa</a>
<div class="
ui
segment
">
<div class="
ui
stackable
two
column
grid
" style="
margin
-
bottom
:
1
rem
;
">
<div class="
column
">
<h1 class="
ui
header
">
<div class="
content
">Audit Trail</div>
</h1>
</div>
<div class="
column
" style="
text
-
align
:
right
;
padding
-
top
:
1.2
rem
;
">
<a href="
{{
route
(
'overtime::overtime.listovertime'
)
}}
" class="
ui
grey
button
">
<i class="
arrow
left
icon
"></i> Kembali
</a>
</div>
</div>
<div class="
ui
divider
"></div>
<form method="
GET
" class="
ui
form
" style="
margin
-
bottom
:
1
rem
;
">
<div class="
fields
" style="
align
-
items
:
flex
-
end
;
">
<div class="
field
" style="
flex
:
1
;
">
<input type="
text
" name="
search
" placeholder="
Cari
No
.
Tuntutan
…
" value="
{{
request
(
'search'
)
}}
">
</div>
<div class="
field
">
<button type="
submit
" class="
ui
teal
button
">
<i class="
search
icon
"></i> Cari
</button>
</div>
</div>
</form>
<table class="
ui
celled
striped
table
at
-
tbl
">
<thead>
<tr>
<th style="
width
:
50
px
;
">No</th>
<th>No. Tuntutan</th>
<th>Tindakan</th>
<th>Penerangan</th>
<th>Tarikh</th>
</tr>
</thead>
<tbody>
@forelse(
$list
as
$i
=>
$row
)
<tr>
<td>{{
$list->firstItem
() +
$i
}}</td>
<td>{{
$row->claim
->ocm_apply_no ?? '-' }}</td>
<td>
<span class="
ui
label
" style="
font
-
size
:.
75
rem
;
">
{{
$row->task
->task_name ?? '-' }}
</span>
</td>
<td class="
at
-
desc
">{{
$row->description
}}</td>
<td class="
at
-
date
">{{
$row->created_at
?->format('d/m/Y H:i') ?? '-' }}</td>
</tr>
@empty
<tr>
<td colspan="
5
" style="
text
-
align
:
center
;
color
:
#bbb; font-style:italic; padding:1.6rem;">
Tiada
rekod
audit
trail
dijumpai
.
</
td
>
</
tr
>
@
endforelse
</
tbody
>
</
table
>
<
div
style
=
"margin-top:1rem;"
>
{{
$list
->
links
()
}}
</
div
>
</
div
>
</
div
>
@
endsection
\ No newline at end of file
packages/portal/overtime/resources/views/overtime/list.blade.php
View file @
dcd229aa
...
...
@@ -61,15 +61,25 @@
return '-';
}],
['header' => __('Status'), 'raw' => function (
$row
) {
$map
= [
1 => ['colour' => 'grey', 'label' => 'Draf'],
2 => ['colour' => 'yellow', 'label' => 'Pending'],
3 => ['colour' => 'green', 'label' => 'Lulus'],
4 => ['colour' => 'red', 'label' => 'Tolak'],
['header' => __('Status'), 'raw' => function (
$row
) use (
$statuses
) {
$colours
= [
1 => 'grey',
2 => 'blue',
3 => 'blue',
4 => 'red',
5 => 'yellow',
6 => 'orange',
7 => 'yellow',
8 => 'orange',
9 => 'yellow',
10 => 'orange',
11 => 'green',
12 => 'red',
];
$status
=
$map[$row->ocm_status]
?? ['colour' => 'grey', 'label' => '-'];
return "
<
span
class
='
ui
{
$status
[
'colour'
]}
label
'>{$status['
label
']}</span>";
$statusRow
=
$statuses[$row->ocm_status]
?? null;
$label
=
$statusRow
?
$statusRow->description
: '-';
$colour
=
$colours[$row->ocm_status]
?? 'grey';
return "
<
span
class
='
ui
{
$colour
}
label
'>{$label}</span>";
}],
['
header
' => __('
Tindakan
'), '
raw
' => function ($row) {
...
...
packages/portal/overtime/resources/views/overtime/modal/create_modal.blade.php
View file @
dcd229aa
<script
src=
"https://code.jquery.com/jquery-3.7.1.min.js"
></script>
<style>
#ocm_month
option
:disabled
{
color
:
#bbb
!important
;
background
:
#f3f3f3
!important
;
font-style
:
italic
;
}
</style>
<div
class=
"ui small modal"
id=
"modalTuntutanBaharu"
>
<div
class=
"header"
>
<i
class=
"file alternate outline icon"
></i>
...
...
@@ -85,6 +93,7 @@
9
:
'September'
,
10
:
'Oktober'
,
11
:
'November'
,
12
:
'Disember'
,
};
// ONE PERMOHONAN PER MONTH
function
refreshMonthOptions
()
{
var
year
=
$
(
'#ocm_year'
).
val
();
if
(
!
year
)
return
;
...
...
@@ -93,32 +102,46 @@ function refreshMonthOptions() {
url
:
EXISTING_MONTHS_URL
,
method
:
'GET'
,
success
:
function
(
res
)
{
var
occupied
=
res
.
success
?
(
res
.
existingMonths
||
[])
:
[];
var
current
=
$
(
'#ocm_month'
).
val
();
var
html
=
'<option value="">-- Pilih Bulan --</option>'
;
for
(
var
m
=
1
;
m
<=
12
;
m
++
)
{
var
key
=
year
+
String
(
m
).
padStart
(
2
,
'0'
);
var
isTaken
=
occupied
.
indexOf
(
key
)
!==
-
1
;
var
label
=
MONTH_NAMES
[
m
]
+
(
isTaken
?
' (Sudah ada)'
:
''
);
// disabled so it can't be selected, but still visible in dropdown
var
attrs
=
isTaken
?
' disabled style="color:#bbb;"'
:
''
;
var
selected
=
(
!
isTaken
&&
current
==
m
)
?
' selected'
:
''
;
html
+=
'<option value="'
+
m
+
'"'
+
attrs
+
selected
+
'>'
+
label
+
'</option>'
;
}
$
(
'#ocm_month'
).
html
(
html
);
var
occupied
=
(
res
.
success
&&
res
.
existingMonths
)
?
res
.
existingMonths
:
[];
buildMonthOptions
(
year
,
occupied
);
},
error
:
function
(
xhr
)
{
console
.
warn
(
'Gagal memuat bulan sedia ada.'
,
xhr
.
status
,
xhr
.
statusText
);
buildMonthOptions
(
year
,
[]);
}
});
}
function
buildMonthOptions
(
year
,
occupied
)
{
var
current
=
$
(
'#ocm_month'
).
val
();
var
html
=
'<option value="">-- Pilih Bulan --</option>'
;
for
(
var
m
=
1
;
m
<=
12
;
m
++
)
{
var
key
=
String
(
year
)
+
String
(
m
).
padStart
(
2
,
'0'
);
var
isTaken
=
occupied
.
indexOf
(
key
)
!==
-
1
;
var
label
=
isTaken
?
MONTH_NAMES
[
m
]
+
' (Telah ada permohonan)'
:
MONTH_NAMES
[
m
];
var
disabled
=
isTaken
?
' disabled'
:
''
;
var
selected
=
(
!
isTaken
&&
String
(
current
)
===
String
(
m
))
?
' selected'
:
''
;
html
+=
'<option value="'
+
m
+
'"'
+
disabled
+
selected
+
'>'
+
label
+
'</option>'
;
}
$
(
'#ocm_month'
).
html
(
html
);
}
$
(
'#ocm_year'
).
on
(
'change'
,
refreshMonthOptions
);
refreshMonthOptions
();
// REFRESH LIST EVERY TIME MODAL OPENS
$
(
'#modalTuntutanBaharu'
).
on
(
'show'
,
function
()
{
$
(
'#modal-success-msg, #modal-error-msg'
).
hide
();
$
(
'#field-ocm_month, #field-ocm_year'
).
removeClass
(
'error'
);
refreshMonthOptions
();
});
// SUBMIT
$
(
'#btn-modal-claim-submit'
).
on
(
'click'
,
function
()
{
var
btn
=
$
(
this
);
var
month
=
$
(
'#ocm_month'
).
val
();
...
...
@@ -155,6 +178,7 @@ function refreshMonthOptions() {
}
else
{
$
(
'#modal-error-text'
).
text
(
res
.
message
||
'Ralat tidak diketahui.'
);
$
(
'#modal-error-msg'
).
show
();
refreshMonthOptions
();
}
},
error
:
function
(
xhr
)
{
...
...
@@ -165,6 +189,10 @@ function refreshMonthOptions() {
msg
=
Object
.
values
(
errors
).
flat
().
join
(
' '
);
if
(
errors
.
ocm_month
)
$
(
'#field-ocm_month'
).
addClass
(
'error'
);
if
(
errors
.
ocm_year
)
$
(
'#field-ocm_year'
).
addClass
(
'error'
);
}
else
if
(
xhr
.
status
===
422
&&
xhr
.
responseJSON
&&
xhr
.
responseJSON
.
message
)
{
msg
=
xhr
.
responseJSON
.
message
;
$
(
'#field-ocm_month'
).
addClass
(
'error'
);
refreshMonthOptions
();
}
else
if
(
xhr
.
responseJSON
&&
xhr
.
responseJSON
.
message
)
{
msg
=
xhr
.
responseJSON
.
message
;
}
...
...
packages/portal/overtime/resources/views/overtime/modal/view_modal.blade.php
View file @
dcd229aa
...
...
@@ -52,13 +52,6 @@
<script>
var
VCM_MONTHS
=
[
'Jan'
,
'Feb'
,
'Mac'
,
'Apr'
,
'Mei'
,
'Jun'
,
'Jul'
,
'Ogos'
,
'Sep'
,
'Okt'
,
'Nov'
,
'Dis'
];
var
VCM_DAYS
=
[
'Ahad'
,
'Isnin'
,
'Selasa'
,
'Rabu'
,
'Khamis'
,
'Jumaat'
,
'Sabtu'
];
var
VCM_STATUS
=
{
1
:
{
colour
:
'grey'
,
label
:
'Draf'
},
2
:
{
colour
:
'yellow'
,
label
:
'Pending'
},
3
:
{
colour
:
'green'
,
label
:
'Lulus'
},
4
:
{
colour
:
'red'
,
label
:
'Tolak'
},
};
var
VCM_MONTH_MS
=
[
'Januari'
,
'Februari'
,
'Mac'
,
'April'
,
'Mei'
,
'Jun'
,
'Julai'
,
'Ogos'
,
'September'
,
'Oktober'
,
'November'
,
'Disember'
...
...
@@ -106,10 +99,9 @@ function viewTuntutan(id) {
}
function
vcmBuildHtml
(
main
,
details
)
{
var
st
=
VCM_STATUS
[
main
.
ocm_status
]
||
{
colour
:
'grey'
,
label
:
'-'
};
var
badge
=
'<span class="ui
'
+
st
.
colour
+
' label" style="font-size:.78rem;">'
+
st
.
label
+
'</span>'
;
// Status label comes directly from the controller (lkp_status lookup)
var
badge
=
'<span class="ui
label" style="font-size:.78rem;">'
+
vcmEsc
(
main
.
ocm_status_label
||
'-'
)
+
'</span>'
;
// Derive month/year from ocm_year/ocm_month on main record
var
monthName
=
(
main
.
ocm_month
&&
main
.
ocm_year
)
?
VCM_MONTH_MS
[
main
.
ocm_month
-
1
]
+
' '
+
main
.
ocm_year
:
'-'
;
...
...
packages/portal/overtime/resources/views/overtime/overtimeclaim/edit.blade.php
View file @
dcd229aa
...
...
@@ -89,24 +89,35 @@
<p id="
error
-
text
"></p>
</div>
@php
$s
= isset(
$statuses[$data->ocm_status]
)
? ['label' =>
$statuses[$data->ocm_status]->description]
: ['label' => '-'];
$colours
= [
1=>'grey', 2=>'blue', 3=>'blue', 4=>'red',
5=>'yellow', 6=>'orange', 7=>'yellow', 8=>'orange',
9=>'yellow', 10=>'orange', 11=>'green', 12=>'red',
];
$sColour
=
$colours[$data->ocm_status]
?? 'grey';
$msMonths
= [
1=>'Januari',2=>'Februari',3=>'Mac',4=>'April',5=>'Mei',6=>'Jun',
7=>'Julai',8=>'Ogos',9=>'September',10=>'Oktober',11=>'November',12=>'Disember',
];
$monthLabel
= (
$data->ocm_month
&&
$data->ocm_year
)
? (
$msMonths[$data->ocm_month]
?? '-') . ' ' .
$data->ocm_year
: '-';
@endphp
{{-- ══ SUMMARY ════════════════════════════════════════════════════════ --}}
<div class="
ot
-
summary
">
@php
$statusMap
= [
1 => ['colour' => 'grey', 'label' => 'Draf'],
2 => ['colour' => 'yellow', 'label' => 'Pending'],
3 => ['colour' => 'green', 'label' => 'Lulus'],
4 => ['colour' => 'red', 'label' => 'Tolak'],
];
$s
=
$statusMap[$data->ocm_status]
?? ['colour' => 'grey', 'label' => '-'];
$firstDate
=
$details->first
()?->ocd_date;
@endphp
<div class="
apply
-
no
">{{
$data->ocm_apply_no
}}</div>
<div class="
meta
-
line
">
Bulan: <strong>{{
$
firstDate
?
$firstDate->locale
('ms_MY')->monthName . ' ' .
$firstDate->year
: '-'
}}</strong>
Bulan: <strong>{{
$
monthLabel
}}</strong>
</div>
<div class="
meta
-
line
">
Status: <span class="
ui
{{
$s
[
'colour'
]
}}
label
" style="
font
-
size
:.
78
rem
;
">{{
$s['label']
}}</span>
Status: <span class="
ui
{{
$s
Colour
}}
label
" style="
font
-
size
:.
78
rem
;
">{{
$s['label']
}}</span>
</div>
</div>
...
...
@@ -116,7 +127,7 @@
<i class="
table
icon
" style="
color
:
#2185d0;"></i>
Jadual
Tuntutan
Lebih
Masa
</
div
>
<
div
class
="
card
-
sub
">{{
$
firstDate
?
$firstDate->locale
('ms_MY')->monthName . ' ' .
$firstDate->year
: '-'
}}</div>
<
div
class
="
card
-
sub
">{{
$
monthLabel
}}</div>
<div style="
overflow
-
x
:
auto
;
">
<table class="
ot
-
tbl
" id="
ot
-
table
">
...
...
@@ -170,10 +181,14 @@
<div class="
two
fields
">
<div class="
required
field
" id="
field
-
tarikh
">
<label>Tarikh <span style="
color
:
#e53935;">*</span></label>
<
input
type
=
"date"
id
=
"ocd_date_input"
name
=
"ocd_date_input"
>
<
input
type
=
"date"
id
=
"ocd_date_input"
name
=
"ocd_date_input"
@
if
(
$data
->
ocm_month
&&
$data
->
ocm_year
)
min
=
"{{ \Carbon\Carbon::createFromDate(
$data->ocm_year
,
$data->ocm_month
, 1)->format('Y-m-d') }}"
max
=
"{{ \Carbon\Carbon::createFromDate(
$data->ocm_year
,
$data->ocm_month
, 1)->endOfMonth()->format('Y-m-d') }}"
@
endif
>
<
div
class
="
field
-
hint
">
<i class="
info
circle
icon
"></i>
Pilih tarikh lebih masa
.
Hanya tarikh dalam bulan {{
$monthLabel
}} dibenarkan
.
</div>
</div>
<div class="
required
field
" id="
field
-
jenis
-
hari
">
...
...
@@ -275,7 +290,9 @@
<script src="
https
://
code
.
jquery
.
com
/
jquery
-
3.7
.
1.
min
.
js
"></script>
<script>
var mainId = {{
$data->id
}};
var mainId = {{
$data->id
}};
var otMonth = {{
$data->ocm_month
?? 'null' }};
var otYear = {{
$data->ocm_year
?? 'null' }};
var MS_MONTH = ['Jan','Feb','Mac','Apr','Mei','Jun','Jul','Ogos','Sep','Okt','Nov','Dis'];
var DAY_NAMES = ['Ahad','Isnin','Selasa','Rabu','Khamis','Jumaat','Sabtu'];
...
...
@@ -435,6 +452,17 @@ function addDay() {
if
(
projectId
===
''
)
projectName
=
'-'
;
if
(
!
dateVal
)
{
showError
(
'Sila pilih tarikh.'
);
return
;
}
if
(
otMonth
&&
otYear
)
{
var
dParts
=
dateVal
.
split
(
'-'
);
var
dYear
=
parseInt
(
dParts
[
0
],
10
);
var
dMonth
=
parseInt
(
dParts
[
1
],
10
);
if
(
dYear
!==
otYear
||
dMonth
!==
otMonth
)
{
showError
(
'Tarikh mesti dalam bulan permohonan ini.'
);
return
;
}
}
if
(
!
dayType
)
{
showError
(
'Sila pilih jenis hari.'
);
return
;
}
if
(
!
officeStart
)
{
showError
(
'Sila isi Office Hour — Mula.'
);
return
;
}
if
(
!
overtimeFrom
)
{
showError
(
'Sila isi Overtime From.'
);
return
;
}
...
...
packages/portal/overtime/routes/web.php
View file @
dcd229aa
...
...
@@ -29,6 +29,7 @@ function () {
Route
::
post
(
'claim/{id}/submit'
,
[
'uses'
=>
'OvertimeClaimController@submitOvertimeClaim'
,
'as'
=>
'overtime.submitovertimeclaim'
]);
Route
::
post
(
'claim/{id}/update'
,
[
'uses'
=>
'OvertimeClaimController@updateOvertimeClaim'
,
'as'
=>
'overtime.updateovertimeclaim'
]);
Route
::
post
(
'claim/{id}/delete'
,
[
'uses'
=>
'OvertimeClaimController@deleteOvertimeClaim'
,
'as'
=>
'overtime.deleteovertimeclaim'
]);
Route
::
get
(
'claim/audit-trail'
,
[
'uses'
=>
'OvertimeClaimController@getAuditTrailList'
,
'as'
=>
'overtime.audittrail'
]);
// OVERTIME REQUEST
Route
::
get
(
'request/create'
,
[
'uses'
=>
'OvertimeRequestController@createOvertimeRequest'
,
'as'
=>
'overtime.createovertimerequest'
]);
...
...
packages/portal/overtime/src/Data/Repo/OvertimeClaimRepo.php
View file @
dcd229aa
...
...
@@ -4,41 +4,72 @@
use
Carbon\Carbon
;
use
Illuminate\Support\Facades\Auth
;
use
Illuminate\Support\Facades\DB
;
use
Portal\Overtime\Model\OvertimeClaimDetail
;
use
Portal\Overtime\Model\OvertimeClaimMain
;
use
Portal\Overtime\Model\OvertimeAuditTrail
;
class
OvertimeClaimRepo
{
// HELPERS
private
function
currentStaffInfoId
()
:
?
int
{
return
DB
::
table
(
'staff_info'
)
->
where
(
'fk_users'
,
Auth
::
id
())
->
value
(
'id'
);
}
public
function
getOtStatuses
()
:
\Illuminate\Support\Collection
{
return
DB
::
table
(
'lkp_status'
)
->
where
(
'module'
,
'ot'
)
->
where
(
'status'
,
1
)
->
orderBy
(
'ref_id'
)
->
get
()
->
keyBy
(
'ref_id'
);
}
// LIST
public
function
overtimeClaimList
(
$request
)
{
$search
=
$request
->
get
(
'search'
);
$search
=
$request
->
get
(
'search'
);
$staffInfoId
=
$this
->
currentStaffInfoId
();
return
OvertimeClaimMain
::
where
(
'fk_lkp_staff_info'
,
Auth
::
id
()
)
return
OvertimeClaimMain
::
where
(
'fk_lkp_staff_info'
,
$staffInfoId
)
->
where
(
function
(
$q
)
use
(
$search
)
{
$q
->
where
(
'ocm_apply_no'
,
'like'
,
"%
{
$search
}
%"
)
->
orWhere
(
'ocm_staff_name'
,
'like'
,
"%
{
$search
}
%"
);
$q
->
where
(
'ocm_apply_no'
,
'like'
,
"%
{
$search
}
%"
)
->
orWhere
(
'ocm_staff_name'
,
'like'
,
"%
{
$search
}
%"
);
})
->
orderBy
(
'created_at'
,
'desc'
)
->
paginate
(
10
);
}
// STORE
public
function
storeOvertimeClaim
(
$request
)
:
OvertimeClaimMain
{
$user
=
Auth
::
user
();
$user
=
Auth
::
user
();
$staffInfo
=
DB
::
table
(
'staff_info'
)
->
where
(
'fk_users'
,
Auth
::
id
())
->
first
();
$record
=
OvertimeClaimMain
::
create
([
'fk_lkp_staff_info'
=>
$user
->
id
,
'ocm_staff_name'
=>
$user
->
name
??
''
,
'ocm_staff_employee_code'
=>
$user
->
employee_code
??
''
,
'fk_lkp_staff_info'
=>
$staffInfo
->
id
??
null
,
'ocm_staff_name'
=>
$staffInfo
->
fullname
??
(
$user
->
name
??
''
),
'ocm_staff_employee_code'
=>
$staffInfo
->
staff_id
??
''
,
'ocm_division'
=>
$staffInfo
->
fk_lkp_department
??
null
,
'ocm_month'
=>
$request
->
ocm_month
,
'ocm_year'
=>
$request
->
ocm_year
,
'ocm_status'
=>
1
,
// Draf
t
'updated_by'
=>
$user
->
id
,
'ocm_status'
=>
1
,
// Draf
'updated_by'
=>
Auth
::
id
()
,
]);
// Format: OTC-202606-0001
$record
->
ocm_apply_no
=
'OTC-'
.
$request
->
ocm_year
.
...
...
@@ -48,10 +79,16 @@ public function storeOvertimeClaim($request): OvertimeClaimMain
$record
->
save
();
$this
->
getAuditTrail
(
'CREATE'
,
$record
->
id
,
null
,
'Tuntutan baharu dicipta untuk bulan '
.
$request
->
ocm_month
.
'/'
.
$request
->
ocm_year
.
'.'
);
return
$record
;
}
// FIND
public
function
findOvertimeClaim
(
int
$id
)
:
OvertimeClaimMain
{
return
OvertimeClaimMain
::
findOrFail
(
$id
);
...
...
@@ -64,10 +101,15 @@ public function findOvertimeClaimDetails(int $id)
->
get
();
}
// EXISTING MONTHS
public
function
getExistingMonthsForUser
()
:
array
{
return
OvertimeClaimMain
::
where
(
'fk_lkp_staff_info'
,
Auth
::
id
())
$staffInfoId
=
$this
->
currentStaffInfoId
();
return
OvertimeClaimMain
::
where
(
'fk_lkp_staff_info'
,
$staffInfoId
)
->
whereNotNull
(
'ocm_month'
)
->
whereNotNull
(
'ocm_year'
)
->
get
()
...
...
@@ -75,10 +117,12 @@ public function getExistingMonthsForUser(): array
->
toArray
();
}
// ADD DETAIL
public
function
addOvertimeClaimDetail
(
int
$id
,
$request
)
:
OvertimeClaimDetail
{
// Combine office start + end into single "HH:MM – HH:MM" string
$officeHour
=
$request
->
ocd_office_start
?
$request
->
ocd_office_start
.
' – '
.
(
$request
->
ocd_office_end
??
'?'
)
:
null
;
...
...
@@ -101,21 +145,44 @@ public function addOvertimeClaimDetail(int $id, $request): OvertimeClaimDetail
if
(
$existing
)
{
$existing
->
update
(
$payload
);
return
$existing
->
fresh
();
$detail
=
$existing
->
fresh
();
$this
->
getAuditTrail
(
'UPDATE'
,
$id
,
$detail
->
id
,
'Entri tarikh '
.
$request
->
ocd_date
.
' dikemaskini.'
);
return
$detail
;
}
return
OvertimeClaimDetail
::
create
(
array_merge
(
$payload
,
[
$detail
=
OvertimeClaimDetail
::
create
(
array_merge
(
$payload
,
[
'fk_overtime_claim_main'
=>
$id
,
]));
$this
->
getAuditTrail
(
'CREATE'
,
$id
,
$detail
->
id
,
'Entri tarikh '
.
$request
->
ocd_date
.
' ditambah.'
);
return
$detail
;
}
// REMOVE DETAIL
public
function
removeOvertimeClaimDetail
(
int
$id
)
:
void
{
OvertimeClaimDetail
::
findOrFail
(
$id
)
->
delete
();
$detail
=
OvertimeClaimDetail
::
findOrFail
(
$id
);
$mainId
=
$detail
->
fk_overtime_claim_main
;
$date
=
$detail
->
ocd_date
;
$detail
->
delete
();
$this
->
getAuditTrail
(
'DELETE'
,
$mainId
,
$id
,
'Entri tarikh '
.
$date
.
' dibuang.'
);
}
// UPDATE MAIN
public
function
updateOvertimeClaim
(
$request
,
int
$id
)
:
OvertimeClaimMain
{
$record
=
$this
->
findOvertimeClaim
(
$id
);
...
...
@@ -130,10 +197,15 @@ public function updateOvertimeClaim($request, int $id): OvertimeClaimMain
'updated_by'
=>
Auth
::
id
(),
]);
$this
->
getAuditTrail
(
'UPDATE'
,
$id
,
null
,
'Tuntutan dikemaskini.'
);
return
$record
;
}
// SUBMIT
public
function
submitOvertimeClaim
(
$request
,
int
$id
)
:
OvertimeClaimMain
{
$record
=
$this
->
findOvertimeClaim
(
$id
);
...
...
@@ -144,18 +216,74 @@ public function submitOvertimeClaim($request, int $id): OvertimeClaimMain
}
$record
->
update
([
'ocm_status'
=>
2
,
'ocm_status'
=>
2
,
// Permohonan Baharu
'ocm_submit_date'
=>
now
(),
'updated_by'
=>
Auth
::
id
(),
]);
$this
->
getAuditTrail
(
'UPDATE'
,
$id
,
null
,
'Tuntutan dihantar untuk kelulusan.'
);
return
$record
;
}
// DELETE
public
function
deleteOvertimeClaim
(
int
$id
)
:
void
{
OvertimeClaimDetail
::
where
(
'fk_overtime_claim_main'
,
$id
)
->
delete
();
OvertimeClaimMain
::
findOrFail
(
$id
)
->
delete
();
$this
->
getAuditTrail
(
'DELETE'
,
$id
,
null
,
'Tuntutan dipadam.'
);
}
// AUDIT TRAIL
public
function
getAuditTrail
(
string
$taskCode
,
int
$claimId
,
?
int
$detailId
=
null
,
string
$extra
=
''
)
:
void
{
$taskId
=
DB
::
table
(
'lkp_overtime_task'
)
->
where
(
'task_code'
,
$taskCode
)
->
where
(
'is_active'
,
1
)
->
value
(
'id'
);
$taskName
=
DB
::
table
(
'lkp_overtime_task'
)
->
where
(
'task_code'
,
$taskCode
)
->
value
(
'task_name'
)
??
$taskCode
;
$userName
=
Auth
::
user
()
->
name
??
'Unknown'
;
$applyNo
=
OvertimeClaimMain
::
where
(
'id'
,
$claimId
)
->
value
(
'ocm_apply_no'
)
??
'-'
;
$description
=
"
{
$userName
}
melakukan tindakan
{
$taskName
}
pada permohonan
{
$applyNo
}
."
;
if
(
$extra
)
{
$description
.=
' '
.
$extra
;
}
OvertimeAuditTrail
::
create
([
'fk_overtime_claim_main'
=>
$claimId
,
'fk_overtime_claim_detail'
=>
$detailId
,
'fk_lkp_overtime_task'
=>
$taskId
,
'user'
=>
Auth
::
id
(),
'description'
=>
$description
,
]);
}
// AUDIT TRAIL LIST (for viewing)
public
function
getAuditTrailList
(
$request
)
{
$search
=
$request
->
get
(
'search'
);
return
\Portal\Overtime\Model\OvertimeAuditTrail
::
with
([
'claim'
,
'task'
])
->
when
(
$search
,
function
(
$q
)
use
(
$search
)
{
$q
->
whereHas
(
'claim'
,
function
(
$q2
)
use
(
$search
)
{
$q2
->
where
(
'ocm_apply_no'
,
'like'
,
"%
{
$search
}
%"
);
});
})
->
orderBy
(
'created_at'
,
'desc'
)
->
paginate
(
15
);
}
}
\ No newline at end of file
packages/portal/overtime/src/Http/Controllers/OvertimeClaimController.php
View file @
dcd229aa
...
...
@@ -16,16 +16,23 @@ public function __construct(
protected
OvertimeClaimRepo
$repos
)
{}
// LIST
public
function
getListOvertimeClaim
(
Request
$request
)
{
$list
=
$this
->
repos
->
overtimeClaimList
(
$request
);
$existingMonths
=
$this
->
repos
->
getExistingMonthsForUser
();
$statuses
=
$this
->
repos
->
getOtStatuses
();
return
view
(
'overtime::overtime.list'
,
compact
(
'list'
,
'existingMonths'
));
return
view
(
'overtime::overtime.list'
,
compact
(
'list'
,
'existingMonths'
,
'statuses'
));
}
// CREATE
public
function
createOvertimeClaim
()
{
$existingMonths
=
$this
->
repos
->
getExistingMonthsForUser
();
...
...
@@ -67,7 +74,10 @@ public function storeOvertimeClaim(Request $request): JsonResponse
});
}
// EXISTING MONTHS
public
function
getExistingMonths
()
:
JsonResponse
{
return
response
()
->
json
([
...
...
@@ -76,53 +86,77 @@ public function getExistingMonths(): JsonResponse
]);
}
// VIEW
public
function
viewOvertimeClaim
(
Request
$request
,
int
$id
)
:
JsonResponse
{
$main
=
$this
->
repos
->
findOvertimeClaim
(
$id
);
$details
=
$this
->
repos
->
findOvertimeClaimDetails
(
$id
);
$projectIds
=
$details
->
pluck
(
'fk_lkp_project'
)
->
filter
()
->
unique
()
->
values
();
$projectNames
=
$projectIds
->
isEmpty
()
?
collect
()
:
DB
::
table
(
'lkp_project'
)
->
whereIn
(
'id'
,
$projectIds
)
->
pluck
(
'p_project_description'
,
'id'
);
$statusRow
=
DB
::
table
(
'lkp_status'
)
->
where
(
'module'
,
'ot'
)
->
where
(
'ref_id'
,
$main
->
ocm_status
)
->
first
();
return
response
()
->
json
([
'success'
=>
true
,
'data'
=>
[
'main'
=>
[
'id'
=>
$main
->
id
,
'ocm_apply_no'
=>
$main
->
ocm_apply_no
,
'ocm_staff_name'
=>
$main
->
ocm_staff_name
,
'ocm_status'
=>
$main
->
ocm_status
,
// Derive month/year from first detail row
'ocm_month'
=>
$details
->
first
()
?->
ocd_date
?->
month
,
'ocm_year'
=>
$details
->
first
()
?->
ocd_date
?->
year
,
'ocm_submit_date'
=>
$main
->
ocm_submit_date
?->
format
(
'Y-m-d'
),
'ocm_approved_date'
=>
$main
->
ocm_approved_date
?->
format
(
'Y-m-d'
),
'id'
=>
$main
->
id
,
'ocm_apply_no'
=>
$main
->
ocm_apply_no
,
'ocm_staff_name'
=>
$main
->
ocm_staff_name
,
'ocm_status'
=>
$main
->
ocm_status
,
'ocm_status_label'
=>
$statusRow
->
description
??
'-'
,
'ocm_month'
=>
$main
->
ocm_
month
,
'ocm_year'
=>
$main
->
ocm_
year
,
'ocm_submit_date'
=>
$main
->
ocm_submit_date
?->
format
(
'Y-m-d'
),
'ocm_approved_date'
=>
$main
->
ocm_approved_date
?->
format
(
'Y-m-d'
),
],
'details'
=>
$details
->
map
(
fn
(
$d
)
=>
[
'id'
=>
$d
->
id
,
'ocd_date'
=>
$d
->
ocd_date
->
format
(
'Y-m-d'
),
// Carbon 'date' cast
'ocd_date'
=>
$d
->
ocd_date
->
format
(
'Y-m-d'
),
'ocd_day_type'
=>
$d
->
ocd_day_type
,
'ocd_office_hour'
=>
$d
->
ocd_office_hour
,
// stored as "HH:MM – HH:MM"
'ocd_overtime_from'
=>
$d
->
ocd_overtime_from
,
// raw time string
'ocd_overtime_to'
=>
$d
->
ocd_overtime_to
,
// raw time string
'ocd_office_hour'
=>
$d
->
ocd_office_hour
,
'ocd_overtime_from'
=>
$d
->
ocd_overtime_from
,
'ocd_overtime_to'
=>
$d
->
ocd_overtime_to
,
'ocd_effective_hours'
=>
$d
->
ocd_effective_hours
,
'ocd_tasks'
=>
$d
->
ocd_tasks
,
'fk_lkp_project'
=>
$d
->
fk_lkp_project
,
'project_name'
=>
$d
->
project
?->
p_project_description
??
''
,
'project_name'
=>
$d
->
fk_lkp_project
?
(
$projectNames
[
$d
->
fk_lkp_project
]
??
''
)
:
''
,
]),
],
]);
}
// EDIT
public
function
editOvertimeClaim
(
Request
$request
,
int
$id
)
{
$data
=
$this
->
repos
->
findOvertimeClaim
(
$id
);
$details
=
$this
->
repos
->
findOvertimeClaimDetails
(
$id
);
$projects
=
\DB
::
table
(
'lkp_project'
)
->
orderBy
(
'p_project_description'
)
->
get
();
$projects
=
DB
::
table
(
'lkp_project'
)
->
orderBy
(
'p_project_description'
)
->
get
();
$statuses
=
$this
->
repos
->
getOtStatuses
();
return
view
(
'overtime::overtime.overtimeclaim.edit'
,
compact
(
'data'
,
'details'
,
'projects'
));
return
view
(
'overtime::overtime.overtimeclaim.edit'
,
compact
(
'data'
,
'details'
,
'projects'
,
'statuses'
));
}
// ADD DETAIL
public
function
addOvertimeClaimDetail
(
Request
$request
,
int
$id
)
:
JsonResponse
{
$request
->
validate
(
...
...
@@ -149,6 +183,10 @@ public function addOvertimeClaimDetail(Request $request, int $id): JsonResponse
return
$this
->
withTransaction
(
function
()
use
(
$request
,
$id
)
{
$detail
=
$this
->
repos
->
addOvertimeClaimDetail
(
$id
,
$request
);
$projectName
=
$detail
->
fk_lkp_project
?
DB
::
table
(
'lkp_project'
)
->
where
(
'id'
,
$detail
->
fk_lkp_project
)
->
value
(
'p_project_description'
)
??
''
:
''
;
return
response
()
->
json
([
'success'
=>
true
,
'message'
=>
'Entri lebih masa berjaya ditambah.'
,
...
...
@@ -162,13 +200,16 @@ public function addOvertimeClaimDetail(Request $request, int $id): JsonResponse
'ocd_effective_hours'
=>
$detail
->
ocd_effective_hours
,
'ocd_tasks'
=>
$detail
->
ocd_tasks
,
'fk_lkp_project'
=>
$detail
->
fk_lkp_project
,
'project_name'
=>
$
detail
->
project
?->
p_project_description
??
''
,
'project_name'
=>
$
projectName
,
],
]);
});
}
// REMOVE DETAIL
public
function
removeOvertimeClaimDetail
(
Request
$request
,
int
$id
)
:
JsonResponse
{
return
$this
->
withTransaction
(
function
()
use
(
$id
)
{
...
...
@@ -181,7 +222,10 @@ public function removeOvertimeClaimDetail(Request $request, int $id): JsonRespon
});
}
// SAVE DRAFT
public
function
saveOvertimeClaimDetails
(
Request
$request
,
int
$id
)
:
JsonResponse
{
return
$this
->
withTransaction
(
function
()
use
(
$request
,
$id
)
{
...
...
@@ -195,7 +239,10 @@ public function saveOvertimeClaimDetails(Request $request, int $id): JsonRespons
});
}
// SUBMIT
public
function
submitOvertimeClaim
(
Request
$request
,
int
$id
)
:
JsonResponse
{
return
$this
->
withTransaction
(
function
()
use
(
$request
,
$id
)
{
...
...
@@ -209,7 +256,10 @@ public function submitOvertimeClaim(Request $request, int $id): JsonResponse
});
}
// UPDATE
public
function
updateOvertimeClaim
(
Request
$request
,
int
$id
)
:
JsonResponse
{
return
$this
->
withTransaction
(
function
()
use
(
$request
,
$id
)
{
...
...
@@ -223,7 +273,10 @@ public function updateOvertimeClaim(Request $request, int $id): JsonResponse
});
}
// DELETE
public
function
deleteOvertimeClaim
(
Request
$request
,
int
$id
)
:
JsonResponse
{
return
$this
->
withTransaction
(
function
()
use
(
$id
)
{
...
...
@@ -236,7 +289,10 @@ public function deleteOvertimeClaim(Request $request, int $id): JsonResponse
});
}
// PRIVATE HELPERS
private
function
withTransaction
(
callable
$callback
)
:
JsonResponse
{
try
{
...
...
@@ -255,4 +311,15 @@ private function withTransaction(callable $callback): JsonResponse
],
500
);
}
}
// =========================================================================
// AUDIT TRAIL
// =========================================================================
public
function
getAuditTrailList
(
Request
$request
)
{
$list
=
$this
->
repos
->
getAuditTrailList
(
$request
);
return
view
(
'overtime::overtime.audit_trail'
,
compact
(
'list'
));
}
}
\ No newline at end of file
packages/portal/overtime/src/Model/LkpOvertimeTask.php
0 → 100644
View file @
dcd229aa
<?php
namespace
Portal\Overtime\Model
;
use
Illuminate\Database\Eloquent\Model
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
class
LkpOvertimeTask
extends
Model
{
use
SoftDeletes
;
protected
$table
=
'lkp_overtime_task'
;
protected
$guarded
=
[
'id'
];
}
\ No newline at end of file
packages/portal/overtime/src/Model/OvertimeAuditTrail.php
0 → 100644
View file @
dcd229aa
<?php
namespace
Portal\Overtime\Model
;
use
Illuminate\Database\Eloquent\Model
;
class
OvertimeAuditTrail
extends
Model
{
protected
$table
=
'overtime_audit_trail'
;
protected
$guarded
=
[
'id'
];
public
function
claim
()
{
return
$this
->
belongsTo
(
OvertimeClaimMain
::
class
,
'fk_overtime_claim_main'
);
}
public
function
task
()
{
return
$this
->
belongsTo
(
LkpOvertimeTask
::
class
,
'fk_lkp_overtime_task'
);
}
public
function
userInfo
()
{
return
$this
->
belongsTo
(
\App\Models\User
::
class
,
'user'
);
}
}
\ No newline at end of file
packages/portal/overtime/src/Model/OvertimeClaimDetail.php
View file @
dcd229aa
...
...
@@ -14,10 +14,9 @@ class OvertimeClaimDetail extends Model
protected
$guarded
=
[
'id'
];
protected
$casts
=
[
'ocd_date'
=>
'date'
,
// plain date — avoids ISO timestamp in JSON
'ocd_date'
=>
'date'
,
'ocd_effective_hours'
=>
'decimal:2'
,
'ocd_total_hours'
=>
'decimal:2'
,
'deleted_at'
=>
'datetime'
,
];
}
\ 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