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
c56ca088
Commit
c56ca088
authored
Jun 16, 2026
by
Muhammad Danial Bin Mohd Zaidi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first commit ot
parent
0779f4cb
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1348 additions
and
26 deletions
+1348
-26
database/migrations/seperate/2026_06_11_060303_create_overtime_request_main_table.php
+46
-0
database/migrations/seperate/2026_06_11_060326_create_overtime_request_detail_table.php
+54
-0
database/migrations/seperate/2026_06_11_060346_create_overtime_claim_main_table.php
+40
-0
database/migrations/seperate/2026_06_11_060401_create_overtime_claim_detail_table.php
+47
-0
database/migrations/seperate/2026_06_16_065354_add_month_and_year_to_overtime_claim_main_table.php
+28
-0
packages/portal/overtime/resources/views/overtime/list.blade.php
+117
-22
packages/portal/overtime/resources/views/overtime/modal/create_modal.blade.php
+179
-0
packages/portal/overtime/resources/views/overtime/modal/view_modal.blade.php
+185
-0
packages/portal/overtime/resources/views/overtime/overtimeclaim/edit.blade.php
+0
-0
packages/portal/overtime/resources/views/overtime/overtimerequest/edit.blade.php
+0
-0
packages/portal/overtime/routes/web.php
+24
-4
packages/portal/overtime/src/Data/Repo/OvertimeClaimRepo.php
+162
-0
packages/portal/overtime/src/Data/Repo/OvertimeRequestRepo.php
+56
-0
packages/portal/overtime/src/Http/Controllers/OvertimeClaimController.php
+259
-0
packages/portal/overtime/src/Http/Controllers/OvertimeRequestController.php
+52
-0
packages/portal/overtime/src/Model/OvertimeClaimDetail.php
+24
-0
packages/portal/overtime/src/Model/OvertimeClaimMain.php
+25
-0
packages/portal/overtime/src/Model/OvertimeRequestDetail.php
+26
-0
packages/portal/overtime/src/Model/OvertimeRequestMain.php
+23
-0
packages/portal/overtime/src/ServiceProvider.php
+1
-0
No files found.
database/migrations/seperate/2026_06_11_060303_create_overtime_request_main_table.php
0 → 100644
View file @
c56ca088
<?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
(
'overtime_request_main'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'orm_apply_no'
,
20
)
->
nullable
();
$table
->
dateTime
(
'orm_date'
)
->
nullable
();
$table
->
integer
(
'orm_name'
)
->
nullable
();
// FK → users.id
$table
->
integer
(
'orm_position'
)
->
nullable
();
// FK → project_role.id
$table
->
integer
(
'orm_project'
)
->
nullable
();
// FK → lkp_project.id
$table
->
integer
(
'orm_department'
)
->
nullable
();
// FK → lkp_department.id
$table
->
integer
(
'orm_status'
)
->
nullable
();
// FK → lkp_status.id
$table
->
integer
(
'orm_requested_by_id'
)
->
nullable
();
// FK → project_team.id
$table
->
dateTime
(
'orm_requested_date'
)
->
nullable
();
$table
->
integer
(
'orm_approved_by_id'
)
->
nullable
();
// FK → project_team.id
$table
->
dateTime
(
'orm_approved_date'
)
->
nullable
();
$table
->
timestamps
();
$table
->
integer
(
'updated_by'
)
->
nullable
();
$table
->
softDeletes
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'overtime_request_main'
);
}
};
database/migrations/seperate/2026_06_11_060326_create_overtime_request_detail_table.php
0 → 100644
View file @
c56ca088
<?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
::
table
(
'overtime_request_detail'
,
function
(
Blueprint
$table
)
{
if
(
!
Schema
::
hasColumn
(
'overtime_request_detail'
,
'ord_day_type'
))
{
$table
->
string
(
'ord_day_type'
)
->
nullable
()
->
after
(
'ord_month_of_overtime'
);
}
if
(
!
Schema
::
hasColumn
(
'overtime_request_detail'
,
'ord_office_start'
))
{
$table
->
string
(
'ord_office_start'
)
->
nullable
()
->
after
(
'ord_day_type'
);
}
if
(
!
Schema
::
hasColumn
(
'overtime_request_detail'
,
'ord_office_end'
))
{
$table
->
string
(
'ord_office_end'
)
->
nullable
()
->
after
(
'ord_office_start'
);
}
if
(
!
Schema
::
hasColumn
(
'overtime_request_detail'
,
'ord_time_from'
))
{
$table
->
string
(
'ord_time_from'
)
->
nullable
()
->
after
(
'ord_office_end'
);
}
if
(
!
Schema
::
hasColumn
(
'overtime_request_detail'
,
'ord_time_to'
))
{
$table
->
string
(
'ord_time_to'
)
->
nullable
()
->
after
(
'ord_time_from'
);
}
if
(
!
Schema
::
hasColumn
(
'overtime_request_detail'
,
'ord_tasks'
))
{
$table
->
text
(
'ord_tasks'
)
->
nullable
()
->
after
(
'ord_time_to'
);
}
});
}
public
function
down
()
:
void
{
Schema
::
table
(
'overtime_request_detail'
,
function
(
Blueprint
$table
)
{
$table
->
dropColumn
([
'ord_day_type'
,
'ord_office_start'
,
'ord_office_end'
,
'ord_time_from'
,
'ord_time_to'
,
'ord_tasks'
,
]);
});
}
};
\ No newline at end of file
database/migrations/seperate/2026_06_11_060346_create_overtime_claim_main_table.php
0 → 100644
View file @
c56ca088
<?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_claim_main'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
string
(
'ocm_apply_no'
)
->
nullable
();
// e.g. OTC-202606-0001
$table
->
integer
(
'ocm_name'
);
// FK → users.id (staff)
$table
->
date
(
'ocm_date'
);
$table
->
tinyInteger
(
'ocm_status'
)
->
default
(
1
);
$table
->
string
(
'ocm_project'
)
->
nullable
();
$table
->
string
(
'ocm_department'
)
->
nullable
();
$table
->
string
(
'ocm_position'
)
->
nullable
();
$table
->
integer
(
'ocm_requested_by_id'
)
->
nullable
();
// FK → users.id
$table
->
dateTime
(
'ocm_requested_date'
)
->
nullable
();
$table
->
integer
(
'ocm_approved_by_id'
)
->
nullable
();
// FK → users.id
$table
->
dateTime
(
'ocm_approved_date'
)
->
nullable
();
$table
->
timestamps
();
$table
->
integer
(
'updated_by'
)
->
nullable
();
$table
->
softDeletes
();
});
}
public
function
down
()
:
void
{
Schema
::
dropIfExists
(
'overtime_claim_main'
);
}
};
\ No newline at end of file
database/migrations/seperate/2026_06_11_060401_create_overtime_claim_detail_table.php
0 → 100644
View file @
c56ca088
<?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
(
'overtime_claim_detail'
,
function
(
Blueprint
$table
)
{
$table
->
id
();
$table
->
integer
(
'fk_overtime_claim_main'
);
// FK → overtime_claim_main.id
$table
->
integer
(
'fk_lkp_project'
)
->
nullable
();
// FK → lkp_project.id
$table
->
dateTime
(
'ocd_date'
)
->
nullable
();
$table
->
string
(
'ocd_day_type'
,
20
)
->
nullable
();
$table
->
string
(
'ocd_office_hour'
,
30
)
->
nullable
();
$table
->
time
(
'ocd_overtime_from'
)
->
nullable
();
$table
->
time
(
'ocd_overtime_to'
)
->
nullable
();
$table
->
text
(
'ocd_tasks'
)
->
nullable
();
$table
->
decimal
(
'ocd_effective_hours'
,
10
,
2
)
->
default
(
0
);
$table
->
decimal
(
'ocd_total_hours'
,
10
,
2
)
->
default
(
0
);
$table
->
timestamps
();
$table
->
integer
(
'updated_by'
)
->
nullable
();
$table
->
softDeletes
();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public
function
down
()
{
Schema
::
dropIfExists
(
'overtime_claim_detail'
);
}
};
database/migrations/seperate/2026_06_16_065354_add_month_and_year_to_overtime_claim_main_table.php
0 → 100644
View file @
c56ca088
<?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
::
table
(
'overtime_claim_main'
,
function
(
Blueprint
$table
)
{
if
(
!
Schema
::
hasColumn
(
'overtime_claim_main'
,
'ocm_month'
))
{
$table
->
integer
(
'ocm_month'
)
->
nullable
()
->
after
(
'ocm_division'
);
}
if
(
!
Schema
::
hasColumn
(
'overtime_claim_main'
,
'ocm_year'
))
{
$table
->
integer
(
'ocm_year'
)
->
nullable
()
->
after
(
'ocm_month'
);
}
});
}
public
function
down
()
:
void
{
Schema
::
table
(
'overtime_claim_main'
,
function
(
Blueprint
$table
)
{
$table
->
dropColumn
([
'ocm_month'
,
'ocm_year'
]);
});
}
};
\ No newline at end of file
packages/portal/overtime/resources/views/overtime/list.blade.php
View file @
c56ca088
...
@@ -2,43 +2,137 @@
...
@@ -2,43 +2,137 @@
@
section
(
'content'
)
@
section
(
'content'
)
@
include
(
'overtime::overtime.modal.create_modal'
)
@
include
(
'overtime::overtime.modal.view_modal'
)
<
style
>
<
style
>
.
table
-
uppercase
td
.
table
-
uppercase
td
{
text
-
transform
:
uppercase
;
}
{
text
-
transform
:
uppercase
;
}
</
style
>
</
style
>
@
if
(
session
(
'success'
))
<
div
class
="
ui
positive
message
">{{ session('success') }}</div>
@endif
@if(session('error'))
<div class="
ui
negative
message
">{{ session('error') }}</div>
@endif
<div class="
ui
segment
">
<a class="
ui
teal
left
ribbon
label
">Senarai Tuntutan Lebih Masa</a>
<div class="
ui
segment
">
<div class="
ui
segment
">
<a class="
ui
violet
left
ribbon
label
">Senarai Permohonan Tuntutan Lebih Masa</a><br/>
<div class="
ui
segment
">
<a href="
/
overtime
/
add
" class="
ui
right
floated
primary
button
">Permohonan Baharu</a><br/>
<div class="
column
sixteen
wide
table
-
uppercase
">
<h1 class="
ui
header
">Senarai Permohonan Tuntutan Lebih Masa</h1>
<div class="
ui
stackable
two
column
grid
" style="
margin
-
bottom
:
1
rem
;
">
<div class="
column
">
<h1 class="
ui
header
">
<div class="
content
">Senarai Tuntutan Lebih Masa</div>
</h1>
</div>
<div class="
column
" style="
text
-
align
:
right
;
padding
-
top
:
1.2
rem
;
">
<button class="
ui
teal
button
" id="
btn
-
tuntutan
-
baharu
">
<i class="
plus
icon
"></i> Tuntutan Baharu
</button>
</div>
</div>
<div class="
ui
divider
"></div>
<div class="
column
sixteen
wide
table
-
uppercase
">
{!!
{!!
Suitable::source(
$list
)
Suitable::source(
$list
)
->title(__('Senarai Permohonan
Tuntutan Lebih Masa'))
->title(__('Senarai
Tuntutan Lebih Masa'))
->columns([
->columns([
\Laravolt\Suitable\Columns\Numbering::make('No'),
\Laravolt\Suitable\Columns\Numbering::make('No'),
['header' => __('No Permohonan'), 'field' => 'om_apply_no', 'sortable' => true],
['header' => __('Terperinci'), 'raw' => function(
$list
){
return "
<
div
class
='
ui
small
basic
icon
buttons
'>
<a href='
/
overtime
/
edit
/
".
$list->id
."
' class='
ui
button
'>
<i class='
file
icon
'
></
i
>
</
a
>
</
div
>
";
}]
['header' => __('No. Tuntutan'), 'field' => 'ocm_apply_no', 'sortable' => true],
['header' => __('Nama'), 'raw' => function (
$row
) {
return
$row->ocm_staff_name
?: '-';
}],
['header' => __('Bulan / Tahun'), 'raw' => function (
$row
) {
if (
$row->ocm_year
&&
$row->ocm_month
) {
$months
= [
1=>'Jan',2=>'Feb',3=>'Mac',4=>'Apr',
5=>'Mei',6=>'Jun',7=>'Jul',8=>'Ogos',
9=>'Sep',10=>'Okt',11=>'Nov',12=>'Dis',
];
return (
$months[$row->ocm_month]
?? '-') . ' ' .
$row->ocm_year
;
}
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'],
];
$status
=
$map[$row->ocm_status]
?? ['colour' => 'grey', 'label' => '-'];
return "
<
span
class
='
ui
{
$status
[
'colour'
]}
label
'>{$status['
label
']}</span>";
}],
['
header
' => __('
Tindakan
'), '
raw
' => function ($row) {
$view = "<button
class='
ui
blue
button
tiny
'
onclick='
viewTuntutan
({
$row
->
id
})
'>
<i class='
eye
icon
'></i> Lihat
</button>";
$edit = "<a href='
" . route('overtime::overtime.editovertimeclaim',
$row->id
) . "
'
class='
ui
yellow
button
tiny
'>
<i class='
edit
icon
'></i> Kemaskini
</a>";
$delete = "<button
class='
ui
red
button
tiny
btn
-
delete
'
data-id='
{
$row
->
id
}
'
data-url='
" . route('overtime::overtime.deleteovertimeclaim',
$row->id
) . "
'>
<i class='
trash
icon
'></i> Padam
</button>";
return "{$view} {$edit} {$delete}";
}],
])
])
->render()
->render()
!!}
!!}
</div>
<br/><br/>
</div>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
<script>
$(document).ready(function () {
$('
#btn-tuntutan-baharu').on('click', function () {
$
(
'#modalTuntutanBaharu'
)
.
modal
({
blurring
:
true
,
closable
:
true
})
.
modal
(
'show'
);
});
$
(
document
)
.
on
(
'click'
,
'.btn-delete'
,
function
()
{
if
(
!
confirm
(
'Padam tuntutan ini? Semua butiran dan nombor tuntutan akan dipadamkan.'
))
return
;
var
url
=
$
(
this
)
.
data
(
'url'
);
var
row
=
$
(
this
)
.
closest
(
'tr'
);
$
.
ajax
({
url
:
url
,
method
:
'POST'
,
data
:
{
_token
:
$
(
'meta[name="csrf-token"]'
)
.
attr
(
'content'
)
},
success
:
function
(
res
)
{
if
(
res
.
success
)
{
row
.
fadeOut
(
300
,
function
()
{
$
(
this
)
.
remove
();
});
}
else
{
alert
(
res
.
message
||
'Ralat semasa memadam.'
);
}
},
error
:
function
()
{
alert
(
'Ralat rangkaian. Sila cuba lagi.'
);
},
});
});
});
</
script
>
@
endsection
@
endsection
\ No newline at end of file
packages/portal/overtime/resources/views/overtime/modal/create_modal.blade.php
0 → 100644
View file @
c56ca088
<script
src=
"https://code.jquery.com/jquery-3.7.1.min.js"
></script>
<div
class=
"ui small modal"
id=
"modalTuntutanBaharu"
>
<div
class=
"header"
>
<i
class=
"file alternate outline icon"
></i>
Tuntutan Baharu
</div>
<div
class=
"content"
>
<div
id=
"modal-success-msg"
class=
"ui positive message"
style=
"display:none;"
>
<p
id=
"modal-success-text"
></p>
</div>
<div
id=
"modal-error-msg"
class=
"ui negative message"
style=
"display:none;"
>
<p
id=
"modal-error-text"
></p>
</div>
<form
class=
"ui form"
id=
"form-tuntutan-baharu"
>
@csrf
<p
style=
"color:#888; margin-bottom:1.2rem;"
>
<i
class=
"info circle icon"
></i>
Pilih bulan dan tahun untuk tuntutan baharu.
Butiran lanjut boleh dilengkapkan selepas ini.
</p>
@php
$monthNames = [
1 => 'Januari', 2 => 'Februari', 3 => 'Mac', 4 => 'April',
5 => 'Mei', 6 => 'Jun', 7 => 'Julai', 8 => 'Ogos',
9 => 'September', 10 => 'Oktober', 11 => 'November', 12 => 'Disember',
];
$currentYear = now()->year;
@endphp
<div
class=
"two fields"
>
<div
class=
"required field"
id=
"field-ocm_month"
>
<label>
Bulan
</label>
<select
name=
"ocm_month"
id=
"ocm_month"
style=
"width:100%; padding:8px; border:1px solid rgba(34,36,38,.15); border-radius:4px;"
>
<option
value=
""
>
-- Pilih Bulan --
</option>
@foreach($monthNames as $monthNum => $monthName)
<option
value=
"{{ $monthNum }}"
>
{{ $monthName }}
</option>
@endforeach
</select>
</div>
<div
class=
"required field"
id=
"field-ocm_year"
>
<label>
Tahun
</label>
<select
name=
"ocm_year"
id=
"ocm_year"
style=
"width:100%; padding:8px; border:1px solid rgba(34,36,38,.15); border-radius:4px;"
>
<option
value=
""
>
-- Pilih Tahun --
</option>
@for($y = now()->year; $y >= now()->year - 3; $y--)
<option
value=
"{{ $y }}"
{{
$
y =
==
now
()
-
>
year ? 'selected' : '' }}>
{{ $y }}
</option>
@endfor
</select>
</div>
</div>
</form>
</div>
<div
class=
"actions"
>
<button
type=
"button"
class=
"ui teal button"
id=
"btn-modal-claim-submit"
>
Cipta Tuntutan
</button>
<button
type=
"button"
class=
"ui deny button"
>
<i
class=
"times icon"
></i>
Batal
</button>
</div>
</div>
<script>
$
(
document
).
ready
(
function
()
{
var
EXISTING_MONTHS_URL
=
"{{ route('overtime::overtime.existingmonths') }}"
;
var
MONTH_NAMES
=
{
1
:
'Januari'
,
2
:
'Februari'
,
3
:
'Mac'
,
4
:
'April'
,
5
:
'Mei'
,
6
:
'Jun'
,
7
:
'Julai'
,
8
:
'Ogos'
,
9
:
'September'
,
10
:
'Oktober'
,
11
:
'November'
,
12
:
'Disember'
,
};
function
refreshMonthOptions
()
{
var
year
=
$
(
'#ocm_year'
).
val
();
if
(
!
year
)
return
;
$
.
ajax
({
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
);
},
});
}
$
(
'#ocm_year'
).
on
(
'change'
,
refreshMonthOptions
);
$
(
'#modalTuntutanBaharu'
).
on
(
'show'
,
function
()
{
$
(
'#modal-success-msg, #modal-error-msg'
).
hide
();
$
(
'#field-ocm_month, #field-ocm_year'
).
removeClass
(
'error'
);
refreshMonthOptions
();
});
$
(
'#btn-modal-claim-submit'
).
on
(
'click'
,
function
()
{
var
btn
=
$
(
this
);
var
month
=
$
(
'#ocm_month'
).
val
();
var
year
=
$
(
'#ocm_year'
).
val
();
var
token
=
$
(
'input[name="_token"]'
).
first
().
val
()
||
$
(
'meta[name="csrf-token"]'
).
attr
(
'content'
);
$
(
'#modal-success-msg, #modal-error-msg'
).
hide
();
$
(
'#field-ocm_month, #field-ocm_year'
).
removeClass
(
'error'
);
var
hasError
=
false
;
if
(
!
month
)
{
$
(
'#field-ocm_month'
).
addClass
(
'error'
);
hasError
=
true
;
}
if
(
!
year
)
{
$
(
'#field-ocm_year'
).
addClass
(
'error'
);
hasError
=
true
;
}
if
(
hasError
)
{
$
(
'#modal-error-text'
).
text
(
'Sila pilih bulan dan tahun.'
);
$
(
'#modal-error-msg'
).
show
();
return
;
}
btn
.
addClass
(
'loading disabled'
);
$
.
ajax
({
url
:
"{{ route('overtime::overtime.storeovertimeclaim') }}"
,
method
:
'POST'
,
dataType
:
'json'
,
headers
:
{
'X-CSRF-TOKEN'
:
token
},
data
:
{
_token
:
token
,
ocm_month
:
month
,
ocm_year
:
year
},
success
:
function
(
res
)
{
btn
.
removeClass
(
'loading disabled'
);
if
(
res
.
success
)
{
$
(
'#modal-success-text'
).
text
(
res
.
message
);
$
(
'#modal-success-msg'
).
show
();
setTimeout
(
function
()
{
window
.
location
.
href
=
res
.
redirect
;
},
800
);
}
else
{
$
(
'#modal-error-text'
).
text
(
res
.
message
||
'Ralat tidak diketahui.'
);
$
(
'#modal-error-msg'
).
show
();
}
},
error
:
function
(
xhr
)
{
btn
.
removeClass
(
'loading disabled'
);
var
msg
=
'Ralat rangkaian. Sila cuba lagi.'
;
if
(
xhr
.
status
===
422
&&
xhr
.
responseJSON
&&
xhr
.
responseJSON
.
errors
)
{
var
errors
=
xhr
.
responseJSON
.
errors
;
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
.
responseJSON
&&
xhr
.
responseJSON
.
message
)
{
msg
=
xhr
.
responseJSON
.
message
;
}
$
(
'#modal-error-text'
).
text
(
msg
);
$
(
'#modal-error-msg'
).
show
();
},
});
});
});
</script>
\ No newline at end of file
packages/portal/overtime/resources/views/overtime/modal/view_modal.blade.php
0 → 100644
View file @
c56ca088
<script
src=
"https://code.jquery.com/jquery-3.7.1.min.js"
></script>
<style>
#modalViewTuntutan
.scrolling.content
{
max-height
:
70vh
;
overflow-y
:
auto
;
}
#modalViewTuntutan
.vm-summary
{
background
:
#ddeeff
;
border-radius
:
6px
;
padding
:
.8rem
1.1rem
;
margin-bottom
:
1rem
;
line-height
:
1.75
;
}
#modalViewTuntutan
.vm-summary
.apply-no
{
font-size
:
1.05rem
;
font-weight
:
700
;
color
:
#1a56a0
;
}
#modalViewTuntutan
.vm-summary
.meta-line
{
font-size
:
.88rem
;
color
:
#333
;
}
#modalViewTuntutan
.vm-tbl
{
width
:
100%
;
border-collapse
:
collapse
;
font-size
:
.83rem
;
}
#modalViewTuntutan
.vm-tbl
th
,
#modalViewTuntutan
.vm-tbl
td
{
border
:
1px
solid
#cfd8e3
;
padding
:
6px
9px
;
vertical-align
:
middle
;
text-align
:
center
;
}
#modalViewTuntutan
.vm-tbl
thead
tr
.grp
th
{
background
:
#2185d0
;
color
:
#fff
;
font-weight
:
600
;
font-size
:
.82rem
;
}
#modalViewTuntutan
.vm-tbl
thead
tr
.grp
th
.vm-light
{
background
:
#5aace8
;
}
#modalViewTuntutan
.vm-tbl
thead
tr
.grp
th
.vm-plain
{
background
:
#e8f0fa
;
color
:
#444
;
}
#modalViewTuntutan
.vm-tbl
tbody
td
.vm-shade
{
background
:
#f0f7ff
;
}
#modalViewTuntutan
.vm-tbl
tbody
td
.vm-left
{
text-align
:
left
;
}
#modalViewTuntutan
.vm-tbl
tfoot
td
{
background
:
#ddeeff
;
font-weight
:
700
;
color
:
#1a56a0
;
border-top
:
2px
solid
#2185d0
;
}
#modalViewTuntutan
.vm-tbl
tfoot
.lbl
{
text-align
:
right
;
font-size
:
.8rem
;
letter-spacing
:
.04em
;
}
#modalViewTuntutan
.vm-empty
{
text-align
:
center
;
color
:
#bbb
;
font-style
:
italic
;
padding
:
1.6rem
;
}
#modalViewTuntutan
.vm-loading
{
text-align
:
center
;
padding
:
2.5rem
;
color
:
#888
;
}
</style>
<div
class=
"ui large modal"
id=
"modalViewTuntutan"
>
<div
class=
"header"
>
<i
class=
"eye icon"
></i>
Lihat Tuntutan Lebih Masa
</div>
<div
class=
"scrolling content"
id=
"vm-claim-content"
>
<div
class=
"vm-loading"
>
<i
class=
"spinner loading icon"
></i>
Memuatkan data…
</div>
</div>
<div
class=
"actions"
>
<button
class=
"ui grey button"
onclick=
"$('#modalViewTuntutan').modal('hide');"
>
<i
class=
"times icon"
></i>
Tutup
</button>
</div>
</div>
<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'
];
function
vcmPad
(
n
)
{
return
String
(
n
).
padStart
(
2
,
'0'
);
}
function
vcmEsc
(
s
)
{
if
(
s
===
null
||
s
===
undefined
)
return
''
;
return
String
(
s
)
.
replace
(
/&/g
,
'&'
).
replace
(
/</g
,
'<'
)
.
replace
(
/>/g
,
'>'
).
replace
(
/"/g
,
'"'
);
}
function
vcmFmtDate
(
str
)
{
if
(
!
str
)
return
'-'
;
var
d
=
new
Date
(
str
);
return
vcmPad
(
d
.
getDate
())
+
'/'
+
vcmPad
(
d
.
getMonth
()
+
1
)
+
'/'
+
d
.
getFullYear
();
}
function
viewTuntutan
(
id
)
{
$
(
'#vm-claim-content'
).
html
(
'<div class="vm-loading"><i class="spinner loading icon"></i> Memuatkan data…</div>'
);
$
(
'#modalViewTuntutan'
).
modal
({
blurring
:
true
,
closable
:
true
}).
modal
(
'show'
);
$
.
ajax
({
url
:
"{{ route('overtime::overtime.viewovertimeclaim', ':id') }}"
.
replace
(
':id'
,
id
),
method
:
'GET'
,
success
:
function
(
res
)
{
if
(
res
.
success
)
{
$
(
'#vm-claim-content'
).
html
(
vcmBuildHtml
(
res
.
data
.
main
,
res
.
data
.
details
));
}
else
{
$
(
'#vm-claim-content'
).
html
(
'<div class="ui negative message"><p>'
+
vcmEsc
(
res
.
message
||
'Ralat semasa memuatkan data.'
)
+
'</p></div>'
);
}
},
error
:
function
()
{
$
(
'#vm-claim-content'
).
html
(
'<div class="ui negative message"><p>Ralat rangkaian. Sila cuba lagi.</p></div>'
);
},
});
}
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>'
;
// 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
:
'-'
;
var
html
=
'<div class="vm-summary">'
+
'<div class="apply-no">'
+
vcmEsc
(
main
.
ocm_apply_no
||
'-'
)
+
'</div>'
+
'<div class="meta-line">Nama: <strong>'
+
vcmEsc
(
main
.
ocm_staff_name
||
'-'
)
+
'</strong></div>'
+
'<div class="meta-line">Bulan: <strong>'
+
monthName
+
'</strong></div>'
+
'<div class="meta-line">Status: '
+
badge
+
'</div>'
;
if
(
main
.
ocm_submit_date
)
html
+=
'<div class="meta-line">Tarikh Hantar: <strong>'
+
vcmFmtDate
(
main
.
ocm_submit_date
)
+
'</strong></div>'
;
if
(
main
.
ocm_approved_date
)
html
+=
'<div class="meta-line">Tarikh Lulus: <strong>'
+
vcmFmtDate
(
main
.
ocm_approved_date
)
+
'</strong></div>'
;
html
+=
'</div>'
;
html
+=
'<div style="overflow-x:auto;">'
+
'<table class="vm-tbl"><thead>'
+
'<tr class="grp">'
+
'<th rowspan="2" class="vm-plain" style="min-width:105px;vertical-align:middle;">Tarikh</th>'
+
'<th rowspan="2" class="vm-plain" style="min-width:110px;vertical-align:middle;">Jenis Hari</th>'
+
'<th rowspan="2" class="vm-plain" style="min-width:110px;vertical-align:middle;">Office Hour</th>'
+
'<th colspan="2" style="min-width:180px;">Overtime</th>'
+
'<th rowspan="2" style="min-width:180px;vertical-align:middle;">Projek</th>'
+
'<th rowspan="2" style="min-width:280px;vertical-align:middle;">Tasks</th>'
+
'<th rowspan="2" class="vm-light" style="min-width:90px; vertical-align:middle;">Effective Hours</th>'
+
'</tr>'
+
'<tr class="grp">'
+
'<th class="vm-light" style="min-width:85px;">From</th>'
+
'<th class="vm-light" style="min-width:85px;">To</th>'
+
'</tr>'
+
'</thead><tbody>'
;
if
(
!
details
||
details
.
length
===
0
)
{
html
+=
'<tr><td colspan="8" class="vm-empty">Tiada butiran ditambah.</td></tr>'
+
'</tbody></table></div>'
;
return
html
;
}
var
grandTotal
=
0
;
details
.
forEach
(
function
(
d
)
{
var
dt
=
new
Date
(
d
.
ocd_date
);
var
day
=
dt
.
getDate
();
var
dayName
=
VCM_DAYS
[
dt
.
getDay
()];
var
dateLabel
=
vcmPad
(
day
)
+
' '
+
VCM_MONTHS
[
dt
.
getMonth
()]
+
' '
+
dt
.
getFullYear
()
+
'<br><small style="color:#999;font-weight:400;">'
+
dayName
+
'</small>'
;
var
hours
=
parseFloat
(
d
.
ocd_effective_hours
)
||
0
;
grandTotal
+=
hours
;
html
+=
'<tr>'
+
'<td>'
+
dateLabel
+
'</td>'
+
'<td class="vm-shade">'
+
vcmEsc
(
d
.
ocd_day_type
||
'-'
)
+
'</td>'
+
'<td class="vm-shade">'
+
vcmEsc
(
d
.
ocd_office_hour
||
'-'
)
+
'</td>'
+
'<td>'
+
vcmEsc
(
d
.
ocd_overtime_from
||
'-'
)
+
'</td>'
+
'<td>'
+
vcmEsc
(
d
.
ocd_overtime_to
||
'-'
)
+
'</td>'
+
'<td>'
+
vcmEsc
(
d
.
project_name
||
'-'
)
+
'</td>'
+
'<td class="vm-left">'
+
vcmEsc
(
d
.
ocd_tasks
||
'-'
)
+
'</td>'
+
'<td><strong>'
+
hours
.
toFixed
(
1
)
+
'</strong></td>'
+
'</tr>'
;
});
html
+=
'</tbody>'
+
'<tfoot><tr>'
+
'<td colspan="7" class="lbl">GRAND TOTAL HOURS</td>'
+
'<td style="text-align:center;">'
+
grandTotal
.
toFixed
(
1
)
+
'</td>'
+
'</tr></tfoot>'
+
'</table></div>'
;
return
html
;
}
</script>
\ No newline at end of file
packages/portal/overtime/resources/views/overtime/overtimeclaim/edit.blade.php
0 → 100644
View file @
c56ca088
This diff is collapsed.
Click to expand it.
packages/portal/overtime/resources/views/overtime/overtimerequest/edit.blade.php
0 → 100644
View file @
c56ca088
packages/portal/overtime/routes/web.php
View file @
c56ca088
<?php
<?php
use
Illuminate\Support\Facades\Route
;
use
Illuminate\Support\Facades\Route
;
use
Portal\overtime\Http\Controllers\OvertimeController
;
use
Portal\Overtime\Http\Controllers\OvertimeController
;
use
Portal\Overtime\Http\Controllers\OvertimeRequestController
;
use
Portal\Overtime\Http\Controllers\OvertimeClaimController
;
// Group claim Ot
Route
::
group
(
Route
::
group
(
[
[
'namespace'
=>
'\Portal\Overtime\Http\Controllers'
,
'namespace'
=>
'\Portal\Overtime\Http\Controllers'
,
...
@@ -15,7 +15,26 @@
...
@@ -15,7 +15,26 @@
function
()
{
function
()
{
Route
::
get
(
'index'
,
[
'uses'
=>
'OvertimeController@index'
,
'as'
=>
'overtime.index'
]);
Route
::
get
(
'index'
,
[
'uses'
=>
'OvertimeController@index'
,
'as'
=>
'overtime.index'
]);
Route
::
get
(
'list'
,
[
'uses'
=>
'OvertimeClaimController@getListOvertimeClaim'
,
'as'
=>
'overtime.listovertime'
]);
// OVERTIME CLAIM
Route
::
get
(
'claim/create'
,
[
'uses'
=>
'OvertimeClaimController@createOvertimeClaim'
,
'as'
=>
'overtime.createovertimeclaim'
]);
Route
::
post
(
'claim/store'
,
[
'uses'
=>
'OvertimeClaimController@storeOvertimeClaim'
,
'as'
=>
'overtime.storeovertimeclaim'
]);
Route
::
get
(
'claim/existing-months'
,
[
'uses'
=>
'OvertimeClaimController@getExistingMonths'
,
'as'
=>
'overtime.existingmonths'
]);
Route
::
get
(
'claim/{id}/view'
,
[
'uses'
=>
'OvertimeClaimController@viewOvertimeClaim'
,
'as'
=>
'overtime.viewovertimeclaim'
]);
Route
::
get
(
'claim/{id}/edit'
,
[
'uses'
=>
'OvertimeClaimController@editOvertimeClaim'
,
'as'
=>
'overtime.editovertimeclaim'
]);
Route
::
post
(
'claim/{id}/detail/add'
,
[
'uses'
=>
'OvertimeClaimController@addOvertimeClaimDetail'
,
'as'
=>
'overtime.addovertimeclaim'
]);
Route
::
post
(
'claim/detail/{id}/remove'
,
[
'uses'
=>
'OvertimeClaimController@removeOvertimeClaimDetail'
,
'as'
=>
'overtime.removeovertimeclaim'
]);
Route
::
post
(
'claim/{id}/save-details'
,
[
'uses'
=>
'OvertimeClaimController@saveOvertimeClaimDetails'
,
'as'
=>
'overtime.saveovertimeclaim'
]);
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
(
'list'
,
[
'uses'
=>
'OvertimeController@getListOvertime'
,
'as'
=>
'overtime.listovertime'
]);
// OVERTIME REQUEST
Route
::
get
(
'request/create'
,
[
'uses'
=>
'OvertimeRequestController@createOvertimeRequest'
,
'as'
=>
'overtime.createovertimerequest'
]);
Route
::
post
(
'request/store'
,
[
'uses'
=>
'OvertimeRequestController@storeOvertimeRequest'
,
'as'
=>
'overtime.storeovertimerequest'
]);
Route
::
get
(
'request/{id}/edit'
,
[
'uses'
=>
'OvertimeRequestController@editOvertimeRequest'
,
'as'
=>
'overtime.editovertimerequest'
]);
Route
::
post
(
'request/{id}/update'
,
[
'uses'
=>
'OvertimeRequestController@updateOvertimeRequest'
,
'as'
=>
'overtime.updateovertimerequest'
]);
Route
::
post
(
'request/{id}/delete'
,
[
'uses'
=>
'OvertimeRequestController@deleteOvertimeRequest'
,
'as'
=>
'overtime.deleteovertimerequest'
]);
}
}
);
);
\ No newline at end of file
packages/portal/overtime/src/Data/Repo/OvertimeClaimRepo.php
0 → 100644
View file @
c56ca088
<?php
namespace
Portal\Overtime\Data\Repo
;
use
Carbon\Carbon
;
use
Illuminate\Support\Facades\Auth
;
use
Portal\Overtime\Model\OvertimeClaimDetail
;
use
Portal\Overtime\Model\OvertimeClaimMain
;
class
OvertimeClaimRepo
{
// LIST
public
function
overtimeClaimList
(
$request
)
{
$search
=
$request
->
get
(
'search'
);
return
OvertimeClaimMain
::
where
(
'fk_lkp_staff_info'
,
Auth
::
id
())
->
where
(
function
(
$q
)
use
(
$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
();
$record
=
OvertimeClaimMain
::
create
([
'fk_lkp_staff_info'
=>
$user
->
id
,
'ocm_staff_name'
=>
$user
->
name
??
''
,
'ocm_staff_employee_code'
=>
$user
->
employee_code
??
''
,
'ocm_month'
=>
$request
->
ocm_month
,
'ocm_year'
=>
$request
->
ocm_year
,
'ocm_status'
=>
1
,
// Draft
'updated_by'
=>
$user
->
id
,
]);
// Format: OTC-202606-0001
$record
->
ocm_apply_no
=
'OTC-'
.
$request
->
ocm_year
.
str_pad
(
$request
->
ocm_month
,
2
,
'0'
,
STR_PAD_LEFT
)
.
'-'
.
str_pad
(
$record
->
id
,
4
,
'0'
,
STR_PAD_LEFT
);
$record
->
save
();
return
$record
;
}
// FIND
public
function
findOvertimeClaim
(
int
$id
)
:
OvertimeClaimMain
{
return
OvertimeClaimMain
::
findOrFail
(
$id
);
}
public
function
findOvertimeClaimDetails
(
int
$id
)
{
return
OvertimeClaimDetail
::
where
(
'fk_overtime_claim_main'
,
$id
)
->
orderBy
(
'ocd_date'
,
'asc'
)
->
get
();
}
// EXISTING MONTHS
public
function
getExistingMonthsForUser
()
:
array
{
return
OvertimeClaimMain
::
where
(
'fk_lkp_staff_info'
,
Auth
::
id
())
->
whereNotNull
(
'ocm_month'
)
->
whereNotNull
(
'ocm_year'
)
->
get
()
->
map
(
fn
(
$item
)
=>
$item
->
ocm_year
.
str_pad
(
$item
->
ocm_month
,
2
,
'0'
,
STR_PAD_LEFT
))
->
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
;
$payload
=
[
'ocd_date'
=>
$request
->
ocd_date
,
'ocd_day_type'
=>
$request
->
ocd_day_type
,
'ocd_office_hour'
=>
$officeHour
,
'ocd_overtime_from'
=>
$request
->
ocd_overtime_from
,
'ocd_overtime_to'
=>
$request
->
ocd_overtime_to
,
'ocd_effective_hours'
=>
$request
->
ocd_effective_hours
,
'ocd_tasks'
=>
$request
->
ocd_tasks
,
'fk_lkp_project'
=>
$request
->
fk_lkp_project
?:
null
,
'updated_by'
=>
Auth
::
id
(),
];
$existing
=
OvertimeClaimDetail
::
where
(
'fk_overtime_claim_main'
,
$id
)
->
whereDate
(
'ocd_date'
,
$request
->
ocd_date
)
->
first
();
if
(
$existing
)
{
$existing
->
update
(
$payload
);
return
$existing
->
fresh
();
}
return
OvertimeClaimDetail
::
create
(
array_merge
(
$payload
,
[
'fk_overtime_claim_main'
=>
$id
,
]));
}
// REMOVE DETAIL
public
function
removeOvertimeClaimDetail
(
int
$id
)
:
void
{
OvertimeClaimDetail
::
findOrFail
(
$id
)
->
delete
();
}
// UPDATE MAIN
public
function
updateOvertimeClaim
(
$request
,
int
$id
)
:
OvertimeClaimMain
{
$record
=
$this
->
findOvertimeClaim
(
$id
);
$record
->
update
([
'ocm_division'
=>
$request
->
ocm_division
??
$record
->
ocm_division
,
'ocm_verified_by'
=>
$request
->
ocm_verified_by
??
$record
->
ocm_verified_by
,
'ocm_verified_date'
=>
$request
->
ocm_verified_date
??
$record
->
ocm_verified_date
,
'ocm_approved_by'
=>
$request
->
ocm_approved_by
??
$record
->
ocm_approved_by
,
'ocm_approved_date'
=>
$request
->
ocm_approved_date
??
$record
->
ocm_approved_date
,
'ocm_status'
=>
$request
->
ocm_status
??
$record
->
ocm_status
,
'updated_by'
=>
Auth
::
id
(),
]);
return
$record
;
}
// SUBMIT
public
function
submitOvertimeClaim
(
$request
,
int
$id
)
:
OvertimeClaimMain
{
$record
=
$this
->
findOvertimeClaim
(
$id
);
$detailCount
=
OvertimeClaimDetail
::
where
(
'fk_overtime_claim_main'
,
$id
)
->
count
();
if
(
$detailCount
===
0
)
{
throw
new
\Exception
(
'Sila tambah sekurang-kurangnya satu hari tuntutan lebih masa.'
);
}
$record
->
update
([
'ocm_status'
=>
2
,
'ocm_submit_date'
=>
now
(),
'updated_by'
=>
Auth
::
id
(),
]);
return
$record
;
}
// DELETE
public
function
deleteOvertimeClaim
(
int
$id
)
:
void
{
OvertimeClaimDetail
::
where
(
'fk_overtime_claim_main'
,
$id
)
->
delete
();
OvertimeClaimMain
::
findOrFail
(
$id
)
->
delete
();
}
}
\ No newline at end of file
packages/portal/overtime/src/Data/Repo/OvertimeRequestRepo.php
0 → 100644
View file @
c56ca088
<?php
namespace
Portal\Overtime\Data\Repo
;
use
Illuminate\Http\Request
;
use
Illuminate\Database\Eloquent\SoftDeletes
;
use
Illuminate\Support\Collection
;
use
Illuminate\Support\Facades\Input
;
use
Carbon\Carbon
;
use
App\Events\AuditLog
;
use
Auth
;
use
DB
;
use
Event
;
use
File
;
use
Mail
;
use
PDF
;
use
Redirect
;
use
Curl
;
use
Portal\Overtime\Model\MainOvertime
;
use
Portal\Mileage\Model\Users
;
/**
* undocumented function
*
* @return testing please hide this function and continue below
* @author afif@3fresources.com
**/
class
OvertimeRepo
{
public
function
index
(
$request
)
{
// $users = Users::where('status', 'ACTIVE')
// ->paginate(10);
// return $users;
}
// overtime crud start
public
function
overtimeList
(
$request
)
{
$search
=
request
(
'search'
);
$data
=
MainOvertime
::
where
(
'om_apply_no'
,
'like'
,
'%'
.
$search
.
'%'
)
->
orderBy
(
'created_at'
,
'desc'
)
->
paginate
(
10
);
return
$data
;
}
// overtime crud end
}
\ No newline at end of file
packages/portal/overtime/src/Http/Controllers/OvertimeClaimController.php
0 → 100644
View file @
c56ca088
<?php
namespace
Portal\Overtime\Http\Controllers
;
use
Illuminate\Http\JsonResponse
;
use
Illuminate\Http\Request
;
use
Illuminate\Routing\Controller
;
use
Illuminate\Support\Facades\Auth
;
use
Illuminate\Support\Facades\DB
;
use
Portal\Overtime\Data\Repo\OvertimeClaimRepo
;
use
Portal\Overtime\Model\OvertimeClaimMain
;
class
OvertimeClaimController
extends
Controller
{
public
function
__construct
(
protected
OvertimeClaimRepo
$repos
)
{}
// LIST
public
function
getListOvertimeClaim
(
Request
$request
)
{
$list
=
$this
->
repos
->
overtimeClaimList
(
$request
);
$existingMonths
=
$this
->
repos
->
getExistingMonthsForUser
();
return
view
(
'overtime::overtime.list'
,
compact
(
'list'
,
'existingMonths'
));
}
// CREATE
public
function
createOvertimeClaim
()
{
$existingMonths
=
$this
->
repos
->
getExistingMonthsForUser
();
return
view
(
'overtime::overtime.modal.create_modal'
,
compact
(
'existingMonths'
));
}
public
function
storeOvertimeClaim
(
Request
$request
)
:
JsonResponse
{
$request
->
validate
(
[
'ocm_month'
=>
'required|integer|between:1,12'
,
'ocm_year'
=>
'required|integer|min:2020'
,
],
[
'ocm_month.required'
=>
'Sila pilih bulan.'
,
'ocm_year.required'
=>
'Sila pilih tahun.'
,
]
);
$existing
=
$this
->
repos
->
getExistingMonthsForUser
();
$key
=
$request
->
ocm_year
.
str_pad
(
$request
->
ocm_month
,
2
,
'0'
,
STR_PAD_LEFT
);
if
(
in_array
(
$key
,
$existing
))
{
return
response
()
->
json
([
'success'
=>
false
,
'message'
=>
'Tuntutan untuk bulan ini sudah wujud.'
,
],
422
);
}
return
$this
->
withTransaction
(
function
()
use
(
$request
)
{
$record
=
$this
->
repos
->
storeOvertimeClaim
(
$request
);
return
response
()
->
json
([
'success'
=>
true
,
'message'
=>
'Tuntutan baharu berjaya dicipta.'
,
'redirect'
=>
route
(
'overtime::overtime.editovertimeclaim'
,
$record
->
id
),
]);
});
}
// EXISTING MONTHS
public
function
getExistingMonths
()
:
JsonResponse
{
return
response
()
->
json
([
'success'
=>
true
,
'existingMonths'
=>
$this
->
repos
->
getExistingMonthsForUser
(),
]);
}
// VIEW
public
function
viewOvertimeClaim
(
Request
$request
,
int
$id
)
:
JsonResponse
{
$main
=
$this
->
repos
->
findOvertimeClaim
(
$id
);
$details
=
$this
->
repos
->
findOvertimeClaimDetails
(
$id
);
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'
),
],
'details'
=>
$details
->
map
(
fn
(
$d
)
=>
[
'id'
=>
$d
->
id
,
'ocd_date'
=>
$d
->
ocd_date
->
format
(
'Y-m-d'
),
// Carbon 'date' cast
'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_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
??
''
,
]),
],
]);
}
// 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
();
return
view
(
'overtime::overtime.overtimeclaim.edit'
,
compact
(
'data'
,
'details'
,
'projects'
));
}
// ADD DETAIL
public
function
addOvertimeClaimDetail
(
Request
$request
,
int
$id
)
:
JsonResponse
{
$request
->
validate
(
[
'ocd_date'
=>
'required|date'
,
'ocd_day_type'
=>
'required|string'
,
'ocd_office_start'
=>
'required|string'
,
'ocd_overtime_from'
=>
'required|string'
,
'ocd_overtime_to'
=>
'required|string'
,
'ocd_effective_hours'
=>
'required|numeric|min:0.5'
,
'ocd_tasks'
=>
'required|string|max:2000'
,
],
[
'ocd_date.required'
=>
'Tarikh diperlukan.'
,
'ocd_day_type.required'
=>
'Jenis hari diperlukan.'
,
'ocd_office_start.required'
=>
'Masa mula pejabat diperlukan.'
,
'ocd_overtime_from.required'
=>
'Masa mula lebih masa diperlukan.'
,
'ocd_overtime_to.required'
=>
'Masa tamat lebih masa diperlukan.'
,
'ocd_effective_hours.required'
=>
'Effective hours diperlukan.'
,
'ocd_tasks.required'
=>
'Sila huraikan tugasan.'
,
]
);
return
$this
->
withTransaction
(
function
()
use
(
$request
,
$id
)
{
$detail
=
$this
->
repos
->
addOvertimeClaimDetail
(
$id
,
$request
);
return
response
()
->
json
([
'success'
=>
true
,
'message'
=>
'Entri lebih masa berjaya ditambah.'
,
'detail'
=>
[
'id'
=>
$detail
->
id
,
'ocd_date'
=>
$detail
->
ocd_date
->
format
(
'Y-m-d'
),
'ocd_day_type'
=>
$detail
->
ocd_day_type
,
'ocd_office_hour'
=>
$detail
->
ocd_office_hour
,
'ocd_overtime_from'
=>
$detail
->
ocd_overtime_from
,
'ocd_overtime_to'
=>
$detail
->
ocd_overtime_to
,
'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
??
''
,
],
]);
});
}
// REMOVE DETAIL
public
function
removeOvertimeClaimDetail
(
Request
$request
,
int
$id
)
:
JsonResponse
{
return
$this
->
withTransaction
(
function
()
use
(
$id
)
{
$this
->
repos
->
removeOvertimeClaimDetail
(
$id
);
return
response
()
->
json
([
'success'
=>
true
,
'message'
=>
'Entri lebih masa berjaya dibuang.'
,
]);
});
}
// SAVE DRAFT
public
function
saveOvertimeClaimDetails
(
Request
$request
,
int
$id
)
:
JsonResponse
{
return
$this
->
withTransaction
(
function
()
use
(
$request
,
$id
)
{
$this
->
repos
->
updateOvertimeClaim
(
$request
,
$id
);
return
response
()
->
json
([
'success'
=>
true
,
'message'
=>
'Draf tuntutan berjaya disimpan.'
,
'redirect'
=>
route
(
'overtime::overtime.listovertime'
),
]);
});
}
// SUBMIT
public
function
submitOvertimeClaim
(
Request
$request
,
int
$id
)
:
JsonResponse
{
return
$this
->
withTransaction
(
function
()
use
(
$request
,
$id
)
{
$this
->
repos
->
submitOvertimeClaim
(
$request
,
$id
);
return
response
()
->
json
([
'success'
=>
true
,
'message'
=>
'Tuntutan berjaya dihantar untuk kelulusan.'
,
'redirect'
=>
route
(
'overtime::overtime.listovertime'
),
]);
});
}
// UPDATE
public
function
updateOvertimeClaim
(
Request
$request
,
int
$id
)
:
JsonResponse
{
return
$this
->
withTransaction
(
function
()
use
(
$request
,
$id
)
{
$this
->
repos
->
updateOvertimeClaim
(
$request
,
$id
);
return
response
()
->
json
([
'success'
=>
true
,
'message'
=>
'Tuntutan berjaya dikemaskini.'
,
'redirect'
=>
route
(
'overtime::overtime.listovertime'
),
]);
});
}
// DELETE
public
function
deleteOvertimeClaim
(
Request
$request
,
int
$id
)
:
JsonResponse
{
return
$this
->
withTransaction
(
function
()
use
(
$id
)
{
$this
->
repos
->
deleteOvertimeClaim
(
$id
);
return
response
()
->
json
([
'success'
=>
true
,
'message'
=>
'Tuntutan berjaya dipadam.'
,
]);
});
}
// PRIVATE HELPERS
private
function
withTransaction
(
callable
$callback
)
:
JsonResponse
{
try
{
DB
::
beginTransaction
();
$response
=
$callback
();
DB
::
commit
();
return
$response
;
}
catch
(
\Exception
$e
)
{
DB
::
rollBack
();
return
response
()
->
json
([
'success'
=>
false
,
'message'
=>
'Ralat: '
.
$e
->
getMessage
(),
],
500
);
}
}
}
\ No newline at end of file
packages/portal/overtime/src/Http/Controllers/OvertimeRequestController.php
0 → 100644
View file @
c56ca088
<?php
namespace
Portal\Overtime\Http\Controllers
;
use
Illuminate\Routing\Controller
;
use
Illuminate\Http\Request
;
use
Illuminate\Support\Facades\Input
;
use
Carbon\Carbon
;
use
Auth
;
use
DB
;
use
Event
;
use
File
;
use
Mail
;
use
PDF
;
use
Redirect
;
use
Curl
;
use
Portal\Overtime\Data\Repo\OvertimeRepo
;
class
OvertimeController
extends
Controller
{
public
function
__construct
(
OvertimeRepo
$repos
)
{
$this
->
repos
=
$repos
;
}
/**
* undocumented function
*
* @return testing please hide this function and continue below
* @author afif@3fresources.com
**/
public
function
index
(
Request
$request
)
{
dd
(
'Welcome to index E-OT 3FRSB'
);
exit
;
// $list = $this->repos->index($request);
// return view('overtime::list', compact('list'));
}
// overtime crud start
public
function
getListOvertime
(
Request
$request
)
{
$list
=
$this
->
repos
->
overtimeList
(
$request
);
return
view
(
'overtime::overtime.list'
,
compact
(
'list'
));
}
// overtime crud end
}
\ No newline at end of file
packages/portal/overtime/src/Model/OvertimeClaimDetail.php
0 → 100644
View file @
c56ca088
<?php
namespace
Portal\Overtime\Model
;
use
Illuminate\Database\Eloquent\Model
;
// use Illuminate\Database\Eloquent\SoftDeletes;
class
OvertimeClaimDetail
extends
Model
{
// use SoftDeletes;
protected
$table
=
'overtime_claim_detail'
;
protected
$primaryKey
=
'id'
;
protected
$guarded
=
[
'id'
];
protected
$casts
=
[
'ocd_date'
=>
'date'
,
// plain date — avoids ISO timestamp in JSON
'ocd_effective_hours'
=>
'decimal:2'
,
'ocd_total_hours'
=>
'decimal:2'
,
'deleted_at'
=>
'datetime'
,
];
}
\ No newline at end of file
packages/portal/overtime/src/Model/OvertimeClaimMain.php
0 → 100644
View file @
c56ca088
<?php
namespace
Portal\Overtime\Model
;
use
Illuminate\Database\Eloquent\Model
;
// use Illuminate\Database\Eloquent\SoftDeletes;
class
OvertimeClaimMain
extends
Model
{
// use SoftDeletes;
protected
$table
=
'overtime_claim_main'
;
protected
$primaryKey
=
'id'
;
protected
$guarded
=
[
'id'
];
protected
$casts
=
[
'ocm_month'
=>
'integer'
,
'ocm_year'
=>
'integer'
,
'ocm_verified_date'
=>
'datetime'
,
'ocm_approved_date'
=>
'datetime'
,
'ocm_submit_date'
=>
'datetime'
,
'deleted_at'
=>
'datetime'
,
];
}
\ No newline at end of file
packages/portal/overtime/src/Model/OvertimeRequestDetail.php
0 → 100644
View file @
c56ca088
<?php
namespace
Portal\Overtime\Model
;
use
Illuminate\Database\Eloquent\Model
;
// use Illuminate\Database\Eloquent\SoftDeletes;
class
OvertimeRequestDetail
extends
Model
{
// use SoftDeletes;
protected
$table
=
'overtime_request_detail'
;
protected
$primaryKey
=
'id'
;
protected
$guarded
=
[
'id'
];
protected
$casts
=
[
'ord_month_of_overtime'
=>
'date'
,
// ← was 'datetime', caused ISO timestamp in JSON
'deleted_at'
=>
'datetime'
,
'ord_budgeted'
=>
'decimal:2'
,
'ord_utilised_to_date'
=>
'decimal:2'
,
'ord_planned_ot_hour'
=>
'decimal:2'
,
'ord_balance'
=>
'decimal:2'
,
'ord_total_hours'
=>
'decimal:2'
,
];
}
\ No newline at end of file
packages/portal/overtime/src/Model/OvertimeRequestMain.php
0 → 100644
View file @
c56ca088
<?php
namespace
Portal\Overtime\Model
;
use
Illuminate\Database\Eloquent\Model
;
// use Illuminate\Database\Eloquent\SoftDeletes;
class
OvertimeRequestMain
extends
Model
{
// use SoftDeletes;
protected
$table
=
'overtime_request_main'
;
protected
$primaryKey
=
'id'
;
protected
$guarded
=
[
'id'
];
protected
$casts
=
[
'orm_date'
=>
'datetime'
,
'orm_requested_date'
=>
'datetime'
,
'orm_approved_date'
=>
'datetime'
,
'deleted_at'
=>
'datetime'
,
];
}
\ No newline at end of file
packages/portal/overtime/src/ServiceProvider.php
View file @
c56ca088
...
@@ -63,6 +63,7 @@ public function boot()
...
@@ -63,6 +63,7 @@ public function boot()
$this
->
loadViewsFrom
(
__DIR__
.
'/../resources/views'
,
'overtime'
);
$this
->
loadViewsFrom
(
__DIR__
.
'/../resources/views'
,
'overtime'
);
$this
->
menu
();
$this
->
menu
();
$this
->
loadMigrationsFrom
(
__DIR__
.
'/../database/migrations'
);
$this
->
loadMigrationsFrom
(
__DIR__
.
'/../database/migrations'
);
$this
->
loadMigrationsFrom
(
database_path
(
'migrations/seperate'
));
//add old laravolt view directive
//add old laravolt view directive
$this
->
loadViewsFrom
(
realpath
(
__DIR__
.
'/../resources/views'
),
'ui'
);
$this
->
loadViewsFrom
(
realpath
(
__DIR__
.
'/../resources/views'
),
'ui'
);
...
...
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