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
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
1941 additions
and
50 deletions
+1941
-50
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
+132
-37
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
+568
-0
packages/portal/overtime/resources/views/overtime/overtimerequest/edit.blade.php
+0
-0
packages/portal/overtime/routes/web.php
+25
-5
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
+10
-8
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
>
<
div
class
="
ui
segment
">
@
if
(
session
(
'success'
))
<a class="
ui
violet
left
ribbon
label
">Senarai Permohonan Tuntutan Lebih Masa</a><br/>
<
div
class
="
ui
positive
message
">{{ session('success') }}</div>
<div class="
ui
segment
">
@endif
<a href="
/
overtime
/
add
" class="
ui
right
floated
primary
button
">Permohonan Baharu</a><br/>
@if(session('error'))
<div class="
column
sixteen
wide
table
-
uppercase
">
<div class="
ui
negative
message
">{{ session('error') }}</div>
@endif
<h1 class="
ui
header
">Senarai Permohonan Tuntutan Lebih Masa</h1>
<div class="
ui
segment
">
{!!
<a class="
ui
teal
left
ribbon
label
">Senarai Tuntutan Lebih Masa</a>
Suitable::source(
$list
)
->title(__('Senarai Permohonan Tuntutan Lebih Masa'))
<div class="
ui
segment
">
->columns([
\Laravolt\Suitable\Columns\Numbering::make('No'),
<div class="
ui
stackable
two
column
grid
" style="
margin
-
bottom
:
1
rem
;
">
['header' => __('No Permohonan'), 'field' => 'om_apply_no', 'sortable' => true],
<div class="
column
">
['header' => __('Terperinci'), 'raw' => function(
$list
){
<h1 class="
ui
header
">
return "
<div class="
content
">Senarai Tuntutan Lebih Masa</div>
<
div
class
='
ui
small
basic
icon
buttons
'>
</h1>
<a href='
/
overtime
/
edit
/
".
$list->id
."
' class='
ui
button
'>
</div>
<i class='
file
icon
'
></
i
>
<div class="
column
" style="
text
-
align
:
right
;
padding
-
top
:
1.2
rem
;
">
</
a
>
<button class="
ui
teal
button
" id="
btn
-
tuntutan
-
baharu
">
</
div
>
";
<i class="
plus
icon
"></i> Tuntutan Baharu
}]
</button>
</div>
])
</div>
->render()
!!}
<div class="
ui
divider
"></div>
</div>
<div class="
column
sixteen
wide
table
-
uppercase
">
<br/><br/>
{!!
</div>
Suitable::source(
$list
)
</div>
->title(__('Senarai Tuntutan Lebih Masa'))
->columns([
@endsection
\Laravolt\Suitable\Columns\Numbering::make('No'),
['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()
!!}
</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
\ 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
@
extends
(
'ui::layouts.app'
)
@
section
(
'content'
)
@
include
(
'overtime::overtime.modal.view_modal'
)
<
style
>
/* ─── SUMMARY BOX ──────────────────────────────────────────────────────── */
.
ot
-
summary
{
background
:
#ddeeff; border-radius: 6px;
padding
:
.
9
rem
1.2
rem
;
margin
-
bottom
:
1.2
rem
;
line
-
height
:
1.7
;
}
.
ot
-
summary
.
apply
-
no
{
font
-
size
:
1.05
rem
;
font
-
weight
:
700
;
color
:
#1a56a0; }
.
ot
-
summary
.
meta
-
line
{
font
-
size
:
.
92
rem
;
color
:
#333; }
/* ─── CARD PANELS ──────────────────────────────────────────────────────── */
.
ot
-
card
{
background
:
#fff; border: 1px solid #dde3ea;
border
-
radius
:
8
px
;
padding
:
1.2
rem
1.4
rem
;
margin
-
bottom
:
1.3
rem
;
}
.
ot
-
card
.
card
-
title
{
font
-
size
:
1
rem
;
font
-
weight
:
700
;
color
:
#222;
display
:
flex
;
align
-
items
:
center
;
gap
:
.
45
rem
;
margin
-
bottom
:
.
2
rem
;
}
.
ot
-
card
.
card
-
sub
{
font
-
size
:
.
8
rem
;
color
:
#999; margin-bottom: .95rem; }
/* ─── OT TABLE ─────────────────────────────────────────────────────────── */
.
ot
-
tbl
{
width
:
100
%
;
border
-
collapse
:
collapse
;
font
-
size
:
.
85
rem
;
}
.
ot
-
tbl
th
,
.
ot
-
tbl
td
{
border
:
1
px
solid
#cfd8e3; padding: 6px 10px;
text
-
align
:
center
;
vertical
-
align
:
middle
;
}
.
ot
-
tbl
thead
.
row
-
grp
th
{
background
:
#e8f0fa; color: #444; font-size: .8rem; font-weight: 600; padding: 5px 10px; }
.
ot
-
tbl
thead
.
row
-
grp
th
.
grp
-
blue
{
background
:
#2185d0; color: #fff; }
.
ot
-
tbl
thead
.
row
-
cols
th
{
background
:
#2185d0; color: #fff; font-size: .83rem; font-weight: 600; }
.
ot
-
tbl
thead
.
row
-
cols
th
.
col
-
light
{
background
:
#5aace8; }
.
ot
-
tbl
tbody
td
.
td
-
shade
{
background
:
#f0f7ff; }
.
ot
-
tbl
tbody
td
.
td
-
tasks
{
text
-
align
:
left
;
}
.
ot
-
tbl
tbody
td
.
td
-
project
{
text
-
align
:
left
;
}
.
ot
-
tbl
tbody
tr
:
hover
td
{
filter
:
brightness
(
.
97
);
}
.
ot
-
tbl
.
empty
-
row
td
{
color
:
#bbb; font-style: italic; padding: 1.8rem; }
.
ot
-
tbl
tfoot
td
{
background
:
#ddeeff; font-weight: 700; color: #1a56a0;
border
-
top
:
2
px
solid
#2185d0;
}
.
ot
-
tbl
tfoot
.
lbl
{
text
-
align
:
right
;
letter
-
spacing
:
.
04
em
;
font
-
size
:
.
82
rem
;
}
/* ─── DELETE BUTTON ─────────────────────────────────────────────────────── */
.
btn
-
del
{
border
:
1
px
solid
#e53935; background: transparent; color: #e53935;
border
-
radius
:
4
px
;
padding
:
2
px
9
px
;
font
-
size
:
.
78
rem
;
cursor
:
pointer
;
transition
:
all
.
15
s
;
line
-
height
:
1.6
;
}
.
btn
-
del
:
hover
{
background
:
#e53935; color: #fff; }
/* ─── ENTRY FORM CARD ──────────────────────────────────────────────────── */
.
ot
-
form
-
card
{
background
:
#fff; border: 1px solid #dde3ea;
border
-
left
:
4
px
solid
#2185d0; border-radius: 8px;
padding
:
1.3
rem
1.5
rem
1.1
rem
;
margin
-
bottom
:
1.3
rem
;
}
.
ot
-
form
-
card
.
form
-
title
{
font
-
size
:
1
rem
;
font
-
weight
:
700
;
color
:
#222;
display
:
flex
;
align
-
items
:
center
;
gap
:
.
45
rem
;
margin
-
bottom
:
1.1
rem
;
}
.
auto
-
field
,
input
[
readonly
]
{
background
:
#f4f9ff !important; color: #555 !important; cursor: default !important;
}
.
badge
-
auto
{
display
:
inline
-
block
;
font
-
size
:
.
68
rem
;
font
-
weight
:
600
;
background
:
#e3f0ff; color: #1565c0; border-radius: 3px;
padding
:
1
px
5
px
;
margin
-
left
:
.
25
rem
;
vertical
-
align
:
middle
;
}
.
field
-
hint
{
font
-
size
:
.
76
rem
;
color
:
#999; margin-top: .3rem; display: flex; align-items: center; gap: .3rem; }
/* ─── FOOTER ───────────────────────────────────────────────────────────── */
.
ot
-
footer
{
display
:
flex
;
justify
-
content
:
flex
-
end
;
gap
:
.
55
rem
;
padding
-
top
:
.
9
rem
;
border
-
top
:
1
px
solid
#e5e8ee;
}
</
style
>
<
div
class
="
ui
segment
" style="
padding
-
bottom
:
2
rem
;
">
<div id="
success
-
msg
" class="
ui
positive
message
" style="
display
:
none
;
margin
-
bottom
:.
75
rem
;
">
<p id="
success
-
text
"></p>
</div>
<div id="
error
-
msg
" class="
ui
negative
message
" style="
display
:
none
;
margin
-
bottom
:.
75
rem
;
">
<p id="
error
-
text
"></p>
</div>
{{-- ══ 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>
</div>
<div class="
meta
-
line
">
Status: <span class="
ui
{{
$s
[
'colour'
]
}}
label
" style="
font
-
size
:.
78
rem
;
">{{
$s['label']
}}</span>
</div>
</div>
{{-- ══ JADUAL TABLE ════════════════════════════════════════════════════ --}}
<div class="
ot
-
card
">
<div class="
card
-
title
">
<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 style="
overflow
-
x
:
auto
;
">
<table class="
ot
-
tbl
" id="
ot
-
table
">
<thead>
<tr class="
row
-
grp
">
<th rowspan="
2
" style="
vertical
-
align
:
middle
;
min
-
width
:
100
px
;
">Date</th>
<th rowspan="
2
" style="
vertical
-
align
:
middle
;
min
-
width
:
110
px
;
">
Day Type<br><span style="
font
-
weight
:
400
;
font
-
size
:.
73
rem
;
">(Office Use Only)</span>
</th>
<th rowspan="
2
" style="
vertical
-
align
:
middle
;
min
-
width
:
110
px
;
">Office Hour</th>
<th colspan="
2
" class="
grp
-
blue
" style="
min
-
width
:
190
px
;
">Overtime</th>
<th rowspan="
2
" class="
grp
-
blue
" style="
vertical
-
align
:
middle
;
min
-
width
:
200
px
;
">Projek</th>
<th rowspan="
2
" class="
grp
-
blue
" style="
vertical
-
align
:
middle
;
min
-
width
:
300
px
;
">Tasks</th>
<th rowspan="
2
" class="
grp
-
blue
" style="
vertical
-
align
:
middle
;
min
-
width
:
90
px
;
">
Effective<br>Hours
</th>
<th rowspan="
2
" style="
vertical
-
align
:
middle
;
min
-
width
:
55
px
;
"></th>
</tr>
<tr class="
row
-
cols
">
<th class="
col
-
light
" style="
min
-
width
:
90
px
;
">From</th>
<th class="
col
-
light
" style="
min
-
width
:
90
px
;
">To</th>
</tr>
</thead>
<tbody id="
ot
-
tbody
">
<tr class="
empty
-
row
">
<td colspan="
9
">Memuatkan entri…</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="
7
" class="
lbl
">GRAND TOTAL HOURS</td>
<td id="
grand
-
total
" style="
text
-
align
:
center
;
">0.0</td>
<td></td>
</tr>
</tfoot>
</table>
</div>
</div>
{{-- ══ ENTRY FORM ══════════════════════════════════════════════════════ --}}
<div class="
ot
-
form
-
card
">
<div class="
form
-
title
">
<i class="
plus
circle
icon
" style="
color
:
#2185d0; font-size:1.1em;"></i>
Tambah
Entri
Tuntutan
</
div
>
<
div
class
="
ui
form
" id="
form
-
add
-
detail
">
@csrf
{{-- Row 1 — Tarikh | Jenis Hari --}}
<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"
>
<
div
class
="
field
-
hint
">
<i class="
info
circle
icon
"></i>
Pilih tarikh lebih masa.
</div>
</div>
<div class="
required
field
" id="
field
-
jenis
-
hari
">
<label>Jenis Hari <span style="
color
:
#e53935;">*</span></label>
<
select
id
=
"ocd_day_type"
name
=
"ocd_day_type"
>
<
option
value
=
""
>--
Pilih
--</
option
>
<
option
value
=
"Hari Bekerja"
>
Hari
Bekerja
</
option
>
<
option
value
=
"Hari Rehat"
>
Hari
Rehat
</
option
>
<
option
value
=
"Cuti Umum"
>
Cuti
Umum
</
option
>
</
select
>
<
div
class
="
field
-
hint
">
<i class="
magic
icon
"></i>
Auto-detect apabila tarikh dipilih.
</div>
</div>
</div>
{{-- Row 2 — Office Hour Mula | Office Hour Tamat (auto) | OT From | OT To --}}
<div class="
four
fields
">
<div class="
required
field
">
<label>Office Hour — Mula <span style="
color
:
#e53935;">*</span></label>
<
input
type
=
"time"
id
=
"ocd_office_start"
name
=
"ocd_office_start"
>
<
div
class
="
field
-
hint
"><i class="
info
circle
icon
"></i> Tamat auto +9 jam.</div>
</div>
<div class="
field
">
<label>Office Hour — Tamat <span class="
badge
-
auto
">auto</span></label>
<input type="
time
" id="
ocd_office_end
" name="
ocd_office_end
" readonly class="
auto
-
field
">
</div>
<div class="
required
field
">
<label>Overtime From <span style="
color
:
#e53935;">*</span></label>
<
input
type
=
"time"
id
=
"ocd_overtime_from"
name
=
"ocd_overtime_from"
>
</
div
>
<
div
class
="
required
field
">
<label>Overtime To <span style="
color
:
#e53935;">*</span></label>
<
input
type
=
"time"
id
=
"ocd_overtime_to"
name
=
"ocd_overtime_to"
>
</
div
>
</
div
>
{{
--
Row
3
—
Projek
--
}}
<
div
class
="
one
field
">
<div class="
field
">
<label>Projek</label>
<select id="
fk_lkp_project
" name="
fk_lkp_project
">
<option value="">-- Tiada / Tidak Berkaitan --</option>
@foreach(
$projects
as
$proj
)
<option value="
{{
$proj
->
id
}}
">{{
$proj->p_project_description
}}</option>
@endforeach
</select>
</div>
</div>
{{-- Row 4 — Effective Hours (auto) | Tasks --}}
<div class="
two
fields
">
<div class="
required
field
">
<label>
Effective Hours
<span class="
badge
-
auto
">auto dari OT From — To</span>
<span style="
color
:
#e53935;">*</span>
</
label
>
<
input
type
=
"number"
id
=
"ocd_effective_hours"
name
=
"ocd_effective_hours"
step
=
"0.5"
min
=
"0.5"
placeholder
=
"Auto-kira atau isi manual"
class
="
auto
-
field
" readonly>
</div>
<div class="
required
field
">
<label>Tasks <span style="
color
:
#e53935;">*</span></label>
<
textarea
id
=
"ocd_tasks"
name
=
"ocd_tasks"
rows
=
"3"
placeholder
=
"Huraikan tugasan yang dilakukan semasa lebih masa…"
></
textarea
>
</
div
>
</
div
>
<
div
style
=
"display:flex; gap:.55rem; margin-top:.6rem;"
>
<
button
type
=
"button"
class
="
ui
teal
button
" id="
btn
-
add
-
day
">
<i class="
plus
icon
"></i> Tambah ke Jadual
</button>
<button type="
button
" class="
ui
grey
button
" id="
btn
-
reset
">
<i class="
redo
icon
"></i> Kosongkan
</button>
</div>
</div>
</div>
{{-- ══ FOOTER BUTTONS ══════════════════════════════════════════════════ --}}
<div class="
ot
-
footer
">
<a href="
{{
route
(
'overtime::overtime.listovertime'
)
}}
" class="
ui
grey
button
">
<i class="
arrow
left
icon
"></i> Kembali
</a>
<button type="
button
" class="
ui
grey
button
" onclick="
saveDetails
()
">
<i class="
save
icon
"></i> Simpan Draf
</button>
<button type="
button
" class="
ui
teal
button
" onclick="
submitTuntutan
()
">
<i class="
check
circle
icon
"></i> Hantar Tuntutan
</button>
</div>
</div>
<script src="
https
://
code
.
jquery
.
com
/
jquery
-
3.7
.
1.
min
.
js
"></script>
<script>
var mainId = {{
$data->id
}};
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'];
var details = {};
$(document).ready(function () {
loadDetails();
bindEvents();
});
function bindEvents() {
$('#ocd_date_input').on('change', function () {
var v = $(this).val();
if (!v) return;
var dow = new Date(v).getDay();
$('#ocd_day_type').val((dow === 0 || dow === 6) ? 'Hari Rehat' : 'Hari Bekerja');
});
$('#ocd_office_start').on('change', function () {
var v = $(this).val();
if (!v) { $('#ocd_office_end').val(''); return; }
var p = v.split(':');
var d = new Date(2000, 0, 1, +p[0], +p[1]);
d.setHours(d.getHours() + 9);
$('#ocd_office_end').val(pad(d.getHours()) + ':' + pad(d.getMinutes()));
});
$('#ocd_overtime_from, #ocd_overtime_to').on('change', function () {
var f = $('#ocd_overtime_from').val();
var t = $('#ocd_overtime_to').val();
if (!f || !t) return;
var diff = toMin(t) - toMin(f);
if (diff <= 0) diff += 1440;
var hrs = Math.round((diff / 60) * 2) / 2;
$('#ocd_effective_hours').val(hrs > 0 ? hrs : '');
});
$('#btn-add-day').on('click', addDay);
$('#btn-reset').on('click', resetForm);
}
function pad(n) { return String(n).padStart(2, '0'); }
function toMin(t) { var p = t.split(':'); return +p[0] * 60 + +p[1]; }
function csrfToken(){ return $('meta[name="
csrf
-
token
"]').attr('content'); }
function esc(s) {
if (s === null || s === undefined) return '';
return String(s)
.replace(/&/g,'&').replace(/</g,'<')
.replace(/>/g,'>').replace(/"
/
g
,
'"'
);
}
function
showSuccess
(
msg
)
{
$
(
'#success-text'
)
.
text
(
msg
);
$
(
'#success-msg'
)
.
show
();
setTimeout
(
function
()
{
$
(
'#success-msg'
)
.
hide
();
},
3500
);
}
function
showError
(
msg
)
{
$
(
'#error-text'
)
.
text
(
msg
);
$
(
'#error-msg'
)
.
show
();
setTimeout
(
function
()
{
$
(
'#error-msg'
)
.
hide
();
},
6000
);
}
function
formatDateLabel
(
dateStr
)
{
var
d
=
new
Date
(
dateStr
);
var
day
=
d
.
getDate
();
var
mon
=
MS_MONTH
[
d
.
getMonth
()];
var
yr
=
d
.
getFullYear
();
return
pad
(
day
)
+
' '
+
mon
+
' '
+
yr
+
'<br><small style="color:#999;font-weight:400;">'
+
DAY_NAMES
[
d
.
getDay
()]
+
'</small>'
;
}
/* ─── LOAD EXISTING DETAILS ───────────────────────────────────────────── */
function
loadDetails
()
{
$
.
ajax
({
url
:
"{{ route('overtime::overtime.viewovertimeclaim',
$data->id
) }}"
,
method
:
'GET'
,
success
:
function
(
res
)
{
if
(
!
res
.
success
||
!
res
.
data
||
!
res
.
data
.
details
)
{
renderTable
();
return
;
}
res
.
data
.
details
.
forEach
(
function
(
d
)
{
var
officeParts
=
(
d
.
ocd_office_hour
||
''
)
.
split
(
' – '
);
details
[
d
.
ocd_date
]
=
{
id
:
d
.
id
,
hours
:
parseFloat
(
d
.
ocd_effective_hours
)
||
0
,
overtimeFrom
:
d
.
ocd_overtime_from
||
''
,
overtimeTo
:
d
.
ocd_overtime_to
||
''
,
tasks
:
d
.
ocd_tasks
||
''
,
dayType
:
d
.
ocd_day_type
||
''
,
officeStart
:
officeParts
[
0
]
||
''
,
officeEnd
:
officeParts
[
1
]
||
''
,
officeHour
:
d
.
ocd_office_hour
||
''
,
projectId
:
d
.
fk_lkp_project
||
''
,
projectName
:
d
.
project_name
||
''
,
};
});
renderTable
();
},
error
:
function
()
{
showError
(
'Gagal memuatkan entri sedia ada.'
);
renderTable
();
},
});
}
/* ─── RENDER TABLE ────────────────────────────────────────────────────── */
function
renderTable
()
{
var
keys
=
Object
.
keys
(
details
)
.
sort
();
var
tbody
=
$
(
'#ot-tbody'
);
if
(
keys
.
length
===
0
)
{
tbody
.
html
(
'<tr class="empty-row"><td colspan="9">Belum ada entri. Gunakan borang di bawah untuk menambah.</td></tr>'
);
$
(
'#grand-total'
)
.
text
(
'0.0'
);
return
;
}
var
total
=
0
,
html
=
''
;
keys
.
forEach
(
function
(
dateStr
)
{
var
d
=
details
[
dateStr
];
total
+=
d
.
hours
;
html
+=
'<tr data-date="'
+
dateStr
+
'">'
;
html
+=
'<td>'
+
formatDateLabel
(
dateStr
)
+
'</td>'
;
html
+=
'<td class="td-shade">'
+
esc
(
d
.
dayType
||
'-'
)
+
'</td>'
;
html
+=
'<td class="td-shade">'
+
esc
(
d
.
officeHour
||
'-'
)
+
'</td>'
;
html
+=
'<td>'
+
esc
(
d
.
overtimeFrom
||
'-'
)
+
'</td>'
;
html
+=
'<td>'
+
esc
(
d
.
overtimeTo
||
'-'
)
+
'</td>'
;
html
+=
'<td class="td-project">'
+
esc
(
d
.
projectName
||
'-'
)
+
'</td>'
;
html
+=
'<td class="td-tasks">'
+
esc
(
d
.
tasks
||
'-'
)
+
'</td>'
;
html
+=
'<td><strong>'
+
d
.
hours
.
toFixed
(
1
)
+
'</strong></td>'
;
html
+=
'<td><button class="btn-del" onclick="removeDay(\''
+
dateStr
+
'\')">'
+
'<i class="trash icon"></i></button></td>'
;
html
+=
'</tr>'
;
});
tbody
.
html
(
html
);
$
(
'#grand-total'
)
.
text
(
total
.
toFixed
(
1
));
}
/* ─── ADD A DAY ENTRY ─────────────────────────────────────────────────── */
function
addDay
()
{
var
dateVal
=
$
(
'#ocd_date_input'
)
.
val
();
var
dayType
=
$
(
'#ocd_day_type'
)
.
val
();
var
officeStart
=
$
(
'#ocd_office_start'
)
.
val
();
var
officeEnd
=
$
(
'#ocd_office_end'
)
.
val
();
var
overtimeFrom
=
$
(
'#ocd_overtime_from'
)
.
val
();
var
overtimeTo
=
$
(
'#ocd_overtime_to'
)
.
val
();
var
hours
=
$
(
'#ocd_effective_hours'
)
.
val
();
var
tasks
=
$
(
'#ocd_tasks'
)
.
val
()
.
trim
();
var
projectId
=
$
(
'#fk_lkp_project'
)
.
val
();
var
projectName
=
$
(
'#fk_lkp_project option:selected'
)
.
text
();
if
(
projectId
===
''
)
projectName
=
'-'
;
if
(
!
dateVal
)
{
showError
(
'Sila pilih tarikh.'
);
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
;
}
if
(
!
overtimeTo
)
{
showError
(
'Sila isi Overtime To.'
);
return
;
}
if
(
!
hours
)
{
showError
(
'Effective Hours tidak boleh kosong.'
);
return
;
}
if
(
!
tasks
)
{
showError
(
'Sila isi ruangan Tasks.'
);
return
;
}
$
.
ajax
({
url
:
"{{ route('overtime::overtime.addovertimeclaim',
$data->id
) }}"
,
method
:
'POST'
,
data
:
{
_token
:
csrfToken
(),
ocd_date
:
dateVal
,
ocd_day_type
:
dayType
,
ocd_office_start
:
officeStart
,
ocd_office_end
:
officeEnd
,
ocd_overtime_from
:
overtimeFrom
,
ocd_overtime_to
:
overtimeTo
,
ocd_effective_hours
:
hours
,
ocd_tasks
:
tasks
,
fk_lkp_project
:
projectId
||
null
,
},
success
:
function
(
res
)
{
if
(
!
res
.
success
)
{
showError
(
res
.
message
||
'Ralat semasa menambah.'
);
return
;
}
details
[
dateVal
]
=
{
id
:
res
.
detail
.
id
,
hours
:
parseFloat
(
hours
),
overtimeFrom
:
overtimeFrom
,
overtimeTo
:
overtimeTo
,
tasks
:
tasks
,
dayType
:
dayType
,
officeStart
:
officeStart
,
officeEnd
:
officeEnd
,
officeHour
:
res
.
detail
.
ocd_office_hour
,
projectId
:
projectId
,
projectName
:
projectName
,
};
renderTable
();
resetForm
();
showSuccess
(
res
.
message
||
'Entri berjaya ditambah.'
);
},
error
:
function
(
xhr
)
{
var
msg
=
'Ralat semasa menambah entri.'
;
if
(
xhr
.
responseJSON
&&
xhr
.
responseJSON
.
message
)
msg
=
xhr
.
responseJSON
.
message
;
if
(
xhr
.
responseJSON
&&
xhr
.
responseJSON
.
errors
)
{
msg
=
Object
.
values
(
xhr
.
responseJSON
.
errors
)
.
flat
()
.
join
(
' '
);
}
showError
(
msg
);
},
});
}
/* ─── REMOVE DAY ENTRY ────────────────────────────────────────────────────── */
function
removeDay
(
dateStr
)
{
if
(
!
confirm
(
'Buang entri '
+
dateStr
+
' daripada jadual?'
))
return
;
var
detailId
=
details
[
dateStr
]
&&
details
[
dateStr
]
.
id
;
if
(
!
detailId
)
{
showError
(
'ID entri tidak dijumpai.'
);
return
;
}
$
.
ajax
({
url
:
"{{ route('overtime::overtime.removeovertimeclaim', ':id') }}"
.
replace
(
':id'
,
detailId
),
method
:
'POST'
,
data
:
{
_token
:
csrfToken
()
},
success
:
function
(
res
)
{
if
(
!
res
.
success
)
{
showError
(
res
.
message
||
'Ralat semasa membuang.'
);
return
;
}
delete
details
[
dateStr
];
renderTable
();
showSuccess
(
res
.
message
||
'Entri berjaya dibuang.'
);
},
error
:
function
()
{
showError
(
'Ralat rangkaian. Sila cuba lagi.'
);
},
});
}
/* ─── SAVE DRAFT ──────────────────────────────────────────────────────── */
function
saveDetails
()
{
$
.
ajax
({
url
:
"{{ route('overtime::overtime.saveovertimeclaim',
$data->id
) }}"
,
method
:
'POST'
,
data
:
{
_token
:
csrfToken
()
},
success
:
function
(
res
)
{
if
(
res
.
success
)
{
showSuccess
(
res
.
message
);
setTimeout
(
function
()
{
window
.
location
.
href
=
res
.
redirect
;
},
1500
);
}
else
{
showError
(
res
.
message
);
}
},
error
:
function
()
{
showError
(
'Ralat semasa menyimpan draf.'
);
},
});
}
/* ─── SUBMISSION ─────────────────────────────────────────────── */
function
submitTuntutan
()
{
if
(
Object
.
keys
(
details
)
.
length
===
0
)
{
alert
(
'Sila tambah sekurang-kurangnya satu entri sebelum menghantar.'
);
return
;
}
if
(
!
confirm
(
'Hantar tuntutan ini untuk kelulusan? Anda tidak boleh mengubahnya selepas ini.'
))
return
;
$
.
ajax
({
url
:
"{{ route('overtime::overtime.submitovertimeclaim',
$data->id
) }}"
,
method
:
'POST'
,
data
:
{
_token
:
csrfToken
()
},
success
:
function
(
res
)
{
if
(
res
.
success
)
{
showSuccess
(
res
.
message
);
setTimeout
(
function
()
{
window
.
location
.
href
=
res
.
redirect
;
},
1500
);
}
else
{
showError
(
res
.
message
);
}
},
error
:
function
()
{
showError
(
'Ralat semasa menghantar tuntutan.'
);
},
});
}
/* ─── RESET FORM ──────────────────────────────────────────────────────── */
function
resetForm
()
{
$
(
'#ocd_date_input'
)
.
val
(
''
);
$
(
'#ocd_day_type'
)
.
val
(
''
);
$
(
'#ocd_office_start, #ocd_office_end'
)
.
val
(
''
);
$
(
'#ocd_overtime_from, #ocd_overtime_to'
)
.
val
(
''
);
$
(
'#ocd_effective_hours'
)
.
val
(
''
);
$
(
'#ocd_tasks'
)
.
val
(
''
);
$
(
'#fk_lkp_project'
)
.
val
(
''
);
$
(
'#field-tarikh, #field-jenis-hari'
)
.
removeClass
(
'error'
);
}
</
script
>
@
endsection
\ No newline at end of file
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'
);
...
@@ -71,22 +72,22 @@ public function boot()
...
@@ -71,22 +72,22 @@ public function boot()
$this
->
publishes
(
$this
->
publishes
(
[
realpath
(
__DIR__
.
'/../resources/views'
)
=>
base_path
(
'resources/views/vendor/ui'
)],
[
realpath
(
__DIR__
.
'/../resources/views'
)
=>
base_path
(
'resources/views/vendor/ui'
)],
'views'
'views'
);
);
}
}
protected
function
menu
()
protected
function
menu
()
{
{
app
(
'laravolt.menu.sidebar'
)
->
register
(
function
(
\Lavary\Menu\Builder
$menus
)
app
(
'laravolt.menu.sidebar'
)
->
register
(
function
(
\Lavary\Menu\Builder
$menus
)
{
{
$menu
=
$menus
->
add
(
__
(
'Tuntutan Lebih Masa'
))
->
data
(
'icon'
,
'align justify'
);
$menu
=
$menus
->
add
(
__
(
'Tuntutan Lebih Masa'
))
->
data
(
'icon'
,
'align justify'
);
$menu
->
add
(
__
(
'Senarai Permohonan '
),
url
(
'/overtime/list'
))
$menu
->
add
(
__
(
'Senarai Permohonan '
),
url
(
'/overtime/list'
))
->
data
(
'icon'
,
'home'
)
->
data
(
'icon'
,
'home'
)
->
active
(
'overtime/*'
);
->
active
(
'overtime/*'
);
// ->data('permission', Permission::PROJECT_MANAGER);
// ->data('permission', Permission::PROJECT_MANAGER);
});
});
}
}
}
}
\ 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