update pm flow

parent 358ba95d
...@@ -31,13 +31,13 @@ final class Permission extends Enum ...@@ -31,13 +31,13 @@ final class Permission extends Enum
const STAFF = "STAFF"; const STAFF = "STAFF";
// start overtime menu // start overtime menu
const APPLICATION_OT = "APPLICATION_OT"; const REQUEST_OT_PM = "REQUEST_OT_PM";
const APPLICATION_OT_REVIEW = "APPLICATION_OT_REVIEW"; const REQUEST_OT_HOD = "REQUEST_OT_HOD";
const REQUEST_OT = "REQUEST_OT"; const REQUEST_OT_PD = "REQUEST_OT_PD";
const APPLICATION_OT_HOD = "APPLICATION_OT_HOD"; const CLAIM_OT = "CLAIM_OT";
const APPLICATION_OT_PD = "APPLICATION_OT_PD"; const CLAIM_OT_PM = "CLAIM_OT_PM";
const APPLICATION_OT_SUPPORT = "APPLICATION_OT_SUPPORT"; const CLAIM_OT_HOD = "CLAIM_OT_HOD";
const APPLICATION_OT_APPROVE = "APPLICATION_OT_APPROVE"; const CLAIM_OT_PD = "CLAIM_OT_PD";
// end overtime menu // end overtime menu
......
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
/**
* Run the migrations.
*/
public function up(): void
{
Schema::table('overtime_audit_trail', function (Blueprint $table) {
$table->integer('fk_overtime_request_main')->nullable()->after('id');
$table->integer('fk_overtime_request_detail')->nullable()->after('fk_overtime_request_main');
$table->index('fk_overtime_request_main');
$table->index('fk_overtime_request_detail');
});
}
/**
* Reverse the migrations.
*/
public function down(): void
{
Schema::table('overtime_audit_trail', function (Blueprint $table) {
$table->dropIndex(['fk_overtime_request_main']);
$table->dropIndex(['fk_overtime_request_detail']);
$table->dropColumn(['fk_overtime_request_main', 'fk_overtime_request_detail']);
});
}
};
\ No newline at end of file
...@@ -82,6 +82,9 @@ ...@@ -82,6 +82,9 @@
</tr> </tr>
</tfoot> </tfoot>
</table> </table>
<div style="margin-top:.5rem;font-size:.82rem;color:#555;">
<span class="ui tiny blue label" style="margin-right:.5rem;">Auto-reviewed</span>Rows with Project "No Project" are auto-reviewed by PM on submit.
</div>
</div> </div>
</div> </div>
...@@ -102,9 +105,10 @@ ...@@ -102,9 +105,10 @@
<label>Day Type <span style="color:#e53935;"></span></label> <label>Day Type <span style="color:#e53935;"></span></label>
<select id="ocd_day_type" name="ocd_day_type"> <select id="ocd_day_type" name="ocd_day_type">
<option value="">-- Select --</option> <option value="">-- Select --</option>
<option value="1">Weekdays</option> <option value="1">Hari Bekerja</option>
<option value="2">Weekends</option> <option value="2">Hari Minggu</option>
<option value="3">Public Holiday</option> <option value="3">Hari Cuti Umum</option>
<option value="4">Hari Cuti Selain Cuti Umum</option>
</select> </select>
<div class="field-hint"><i class="magic icon"></i>Auto-detect when date is selected.</div> <div class="field-hint"><i class="magic icon"></i>Auto-detect when date is selected.</div>
</div> </div>
...@@ -121,9 +125,10 @@ ...@@ -121,9 +125,10 @@
<select id="fk_lkp_project" name="fk_lkp_project"> <select id="fk_lkp_project" name="fk_lkp_project">
<option value="">-- None / Not Applicable --</option> <option value="">-- None / Not Applicable --</option>
@foreach($projects as $proj) @foreach($projects as $proj)
<option value="{{ $proj->id }}">{{ $proj->p_project_description }}</option> <option value="{{ $proj->id }}" @if($proj->id == 110) selected @endif>{{ $proj->p_project_description }}</option>
@endforeach @endforeach
</select> </select>
<div class="field-hint"><i class="info circle icon"></i>Selecting "No Project" will route approval directly to HOD and PD.</div>
</div> </div>
</div> </div>
<div class="three fields"> <div class="three fields">
...@@ -141,13 +146,13 @@ ...@@ -141,13 +146,13 @@
</div> </div>
</div> </div>
<div class="button-row" style="display:flex;justify-content:flex-end;gap:.55rem;"> <div class="button-row" style="display:flex;justify-content:flex-end;gap:.55rem;">
<button type="button" class="ui teal button" id="btn-add-day"><i class="plus icon"></i>Add to Table</button> <button type="button" class="ui teal button" id="btn-add-row"><i class="plus icon"></i>Add to Table</button>
<button type="button" class="ui grey button" id="btn-reset"><i class="redo icon"></i>Clear</button> <button type="button" class="ui grey button" id="btn-reset"><i class="redo icon"></i>Clear</button>
</div> </div>
</div> </div>
</div> </div>
@if($queryHistory->isNotEmpty() || in_array($data->ocm_status, [6])) @if($queryHistory->isNotEmpty() || in_array($data->ocm_status, [6, 8, 10]))
<div class="ot-query-card"> <div class="ot-query-card">
<div class="form-title"><i class="comment alternate outline icon"></i>Query History</div> <div class="form-title"><i class="comment alternate outline icon"></i>Query History</div>
<div style="overflow-x:auto;"> <div style="overflow-x:auto;">
...@@ -156,8 +161,9 @@ ...@@ -156,8 +161,9 @@
<tr> <tr>
<th style="width:180px;">From</th> <th style="width:180px;">From</th>
<th>Query Notes</th> <th>Query Notes</th>
<th style="width:150px;">Query Date</th>
<th>Response</th> <th>Response</th>
<th style="width:150px;">Date</th> <th style="width:150px;">Respond Date</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -165,18 +171,19 @@ ...@@ -165,18 +171,19 @@
<tr> <tr>
<td>{{ $q->queriedBy->name ?? '-' }}</td> <td>{{ $q->queriedBy->name ?? '-' }}</td>
<td>{{ $q->remarks ?: '-' }}</td> <td>{{ $q->remarks ?: '-' }}</td>
<td>{{ $q->respond ?: '-' }}</td>
<td>{{ $q->tarikh ? \Carbon\Carbon::parse($q->tarikh)->format('d/m/Y H:i') : ($q->created_at ? $q->created_at->format('d/m/Y H:i') : '-') }}</td> <td>{{ $q->tarikh ? \Carbon\Carbon::parse($q->tarikh)->format('d/m/Y H:i') : ($q->created_at ? $q->created_at->format('d/m/Y H:i') : '-') }}</td>
<td>{{ $q->respond ?: '-' }}</td>
<td>{{ $q->updated_at ? $q->updated_at->format('d/m/Y H:i') : '-' }}</td>
</tr> </tr>
@empty @empty
<tr><td colspan="4" style="color:#999;font-style:italic;text-align:center;padding:1rem;">No query history found.</td></tr> <tr><td colspan="5" style="color:#999;font-style:italic;text-align:center;padding:1rem;">No query history found.</td></tr>
@endforelse @endforelse
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
@if(in_array($data->ocm_status, [6])) @if(in_array($data->ocm_status, [6, 8, 10]))
<div class="ot-query-card"> <div class="ot-query-card">
<div class="form-title"><i class="write icon"></i>Your Response</div> <div class="form-title"><i class="write icon"></i>Your Response</div>
<div class="field"> <div class="field">
...@@ -189,11 +196,9 @@ ...@@ -189,11 +196,9 @@
<div class="ot-footer"> <div class="ot-footer">
<a href="{{ route('overtime::overtime.listovertime') }}" class="ui grey button"><i class="arrow left icon"></i>Back</a> <a href="{{ route('overtime::overtime.listovertime') }}" class="ui grey button"><i class="arrow left icon"></i>Back</a>
@if($data->ocm_status == 1) @if(in_array($data->ocm_status, [1, 6, 8, 10]))
<button type="button" class="ui grey button" onclick="saveDetails()"><i class="save icon"></i>Save Draft</button> <button type="button" class="ui grey button" id="btn-save-draft"><i class="save icon"></i>Save Draft</button>
<button type="button" class="ui teal button" onclick="submitTuntutan()"><i class="check circle icon"></i>Submit Claim</button> <button type="button" class="ui teal button" id="btn-submit"><i class="check circle icon"></i>Submit Claim</button>
@elseif($data->ocm_status == 6)
<button type="button" class="ui grey button" onclick="saveDetails()"><i class="save icon"></i>Save Draft</button>
@endif @endif
</div> </div>
</div> </div>
...@@ -206,6 +211,12 @@ ...@@ -206,6 +211,12 @@
var details = {}; var details = {};
var MS_MONTH = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec']; var MS_MONTH = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var DAY_NAMES = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat']; var DAY_NAMES = ['Sun','Mon','Tue','Wed','Thu','Fri','Sat'];
var DAY_TYPE_OPTION_LABELS = {
'1': 'Hari Bekerja',
'2': 'Hari Minggu',
'3': 'Hari Cuti Umum',
'4': 'Hari Cuti Selain Cuti Umum'
};
$(document).ready(function () { $(document).ready(function () {
if ($.fn.dropdown) $('.ui.dropdown').dropdown({ fullTextSearch: true }); if ($.fn.dropdown) $('.ui.dropdown').dropdown({ fullTextSearch: true });
...@@ -214,8 +225,10 @@ ...@@ -214,8 +225,10 @@
}); });
function bindEvents() { function bindEvents() {
$('#btn-add-day').on('click', addDay); $('#btn-add-row').on('click', addDay);
$('#btn-reset').on('click', resetForm); $('#btn-reset').on('click', resetForm);
$('#btn-save-draft').on('click', saveDetails);
$('#btn-submit').on('click', submitTuntutan);
$('#ocd_date_input').on('change', function () { $('#ocd_date_input').on('change', function () {
var v = $(this).val(); var v = $(this).val();
...@@ -245,8 +258,10 @@ function fetchAttendance(dateVal) { ...@@ -245,8 +258,10 @@ function fetchAttendance(dateVal) {
var flexiEnd = (attendance.time_out_flexi || '').substring(0, 5); var flexiEnd = (attendance.time_out_flexi || '').substring(0, 5);
var finalOut = (attendance.time_out || '').substring(0, 5); var finalOut = (attendance.time_out || '').substring(0, 5);
var mappedDayType = mapAttendanceDayTypeCode(attendance.fk_lkp_day_type, attendance.day_type); var mappedDayType = mapAttendanceDayTypeCode(attendance.fk_lkp_day_type, attendance.day_type);
var isWeekendOrPublicHoliday = mappedDayType === '2' || mappedDayType === '3';
var otFromAuto = isWeekendOrPublicHoliday ? start : flexiEnd;
$('#ocd_day_type').val(mappedDayType || ''); setDayTypeSelection(mappedDayType, attendance.day_type || '');
$('#ocd_office_start') $('#ocd_office_start')
.val(start) .val(start)
...@@ -259,14 +274,16 @@ function fetchAttendance(dateVal) { ...@@ -259,14 +274,16 @@ function fetchAttendance(dateVal) {
.prop('readonly', true) .prop('readonly', true)
.addClass('auto-field'); .addClass('auto-field');
$('#ocd_overtime_from').val(flexiEnd); $('#ocd_overtime_from').val(otFromAuto);
$('#ocd_overtime_to').val(finalOut); $('#ocd_overtime_to').val(finalOut);
updateTotalHours(); updateTotalHours();
// If time_out_flexi is missing in attendance record, fallback office end to +9 hours. // If time_out_flexi is missing in attendance record, fallback office end to +9 hours.
if (!flexiEnd && start) { if (!flexiEnd && start) {
updateOfficeEndFromStart(); updateOfficeEndFromStart();
if (!isWeekendOrPublicHoliday) {
$('#ocd_overtime_from').val($('#ocd_office_end').val()); $('#ocd_overtime_from').val($('#ocd_office_end').val());
}
updateTotalHours(); updateTotalHours();
} }
} else { } else {
...@@ -281,15 +298,34 @@ function fetchAttendance(dateVal) { ...@@ -281,15 +298,34 @@ function fetchAttendance(dateVal) {
function mapAttendanceDayTypeCode(dayTypeId, fallbackLabel) { function mapAttendanceDayTypeCode(dayTypeId, fallbackLabel) {
var id = parseInt(dayTypeId, 10); var id = parseInt(dayTypeId, 10);
if (id === 1 || id === 2 || id === 3) return String(id); if (id === 1 || id === 2 || id === 3 || id === 4) return String(id);
if (fallbackLabel === 'Hari Bekerja') return '1'; if (fallbackLabel === 'Hari Bekerja') return '1';
if (fallbackLabel === 'Hari Rehat') return '2'; if (fallbackLabel === 'Hari Minggu' || fallbackLabel.indexOf('Hari Minggu') === 0) return '2';
if (fallbackLabel === 'Cuti Umum') return '3'; if (fallbackLabel === 'Hari Cuti Umum' || fallbackLabel.indexOf('Hari Cuti Umum') === 0) return '3';
if (fallbackLabel === 'Hari Cuti Selain Cuti Umum' || fallbackLabel.indexOf('Hari Cuti Selain Cuti Umum') === 0) return '4';
return ''; return '';
} }
function resetDayTypeOptions() {
$('#ocd_day_type option').each(function () {
var value = $(this).val();
if (Object.prototype.hasOwnProperty.call(DAY_TYPE_OPTION_LABELS, value)) {
$(this).text(DAY_TYPE_OPTION_LABELS[value]);
}
});
}
function setDayTypeSelection(dayTypeCode, displayLabel) {
resetDayTypeOptions();
$('#ocd_day_type').val(dayTypeCode || '');
if (dayTypeCode && displayLabel) {
$('#ocd_day_type option[value="' + dayTypeCode + '"]').text(displayLabel);
}
}
function enableManualOfficeHours() { function enableManualOfficeHours() {
$('#ocd_office_start') $('#ocd_office_start')
.prop('readonly', false) .prop('readonly', false)
...@@ -354,10 +390,10 @@ function updateTotalHours() { ...@@ -354,10 +390,10 @@ function updateTotalHours() {
function pad(n){ return String(n).padStart(2,'0'); } function pad(n){ return String(n).padStart(2,'0'); }
function toMin(t){ var p = t.split(':'); return +p[0] * 60 + +p[1]; } function toMin(t){ var p = t.split(':'); return +p[0] * 60 + +p[1]; }
function csrfToken(){ return $('meta[name="csrf-token"]').attr('content'); } function csrfToken(){ return $('meta[name="csrf-token"]').attr('content'); }
function esc(s){ return s === null || s === undefined ? '' : String(s).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;'); } function esc(s){ return s === null || s === undefined ? '' : String(s).replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;').replace(/"/g,'&quot;'); }
function showSuccess(msg){ $('#success-text').text(msg); $('#success-msg').show(); setTimeout(function(){ $('#success-msg').hide(); }, 3500); } 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 showError(msg){ $('#error-text').text(msg); $('#error-msg').show(); setTimeout(function(){ $('#error-msg').hide(); }, 6000); }
function formatDateLabel(dateStr){ var d = new Date(dateStr); return pad(d.getDate()) + ' ' + MS_MONTH[d.getMonth()] + ' ' + d.getFullYear() + '<br><small style="color:#999;font-weight:400;">' + DAY_NAMES[d.getDay()] + '</small>'; } function formatDateLabel(dateStr){ var d = new Date(dateStr); return pad(d.getDate()) + ' ' + MS_MONTH[d.getMonth()] + ' ' + d.getFullYear() + '<br><small style="color:#999;font-weight:400;">' + DAY_NAMES[d.getDay()] + '</small>'; }
function loadDetails() { function loadDetails() {
...@@ -381,6 +417,10 @@ function loadDetails() { ...@@ -381,6 +417,10 @@ function loadDetails() {
officeHour: d.ocd_office_hour || '', officeHour: d.ocd_office_hour || '',
projectId: d.fk_lkp_project || '', projectId: d.fk_lkp_project || '',
projectName: d.project_name || '', projectName: d.project_name || '',
// PM review metadata returned by controller
ocd_pm_reviewed: !!d.ocd_pm_reviewed,
ocd_pm_reviewed_by_name: d.ocd_pm_reviewed_by_name || '',
ocd_pm_reviewed_at: d.ocd_pm_reviewed_at || null,
}; };
}); });
} }
...@@ -414,7 +454,20 @@ function renderTable() { ...@@ -414,7 +454,20 @@ function renderTable() {
html += '<td>' + esc(d.overtimeTo || '-') + '</td>'; html += '<td>' + esc(d.overtimeTo || '-') + '</td>';
html += '<td class="td-project">' + esc(d.projectName || '-') + '</td>'; html += '<td class="td-project">' + esc(d.projectName || '-') + '</td>';
html += '<td class="td-tasks">' + esc(d.tasks || '-') + '</td>'; html += '<td class="td-tasks">' + esc(d.tasks || '-') + '</td>';
html += '<td>' + (d.pmReviewed ? '<span class="ui green label">Reviewed</span>' : '<span class="ui orange label">Pending</span>') + '</td>'; var pmReviewHtml = '';
try {
if (String(d.projectId) === '110') {
// For No Project rows show only the Auto badge (never show Pending/Reviewed)
pmReviewHtml = '<span class="ui tiny blue label">Auto</span>';
} else {
if (d.ocd_pm_reviewed) {
pmReviewHtml = '<span class="ui green label">Reviewed</span>';
} else {
pmReviewHtml = '<span class="ui orange label">Pending</span>';
}
}
} catch (e) { /* ignore */ }
html += '<td>' + pmReviewHtml + '</td>';
html += '<td>' + totalValue.toFixed(1) + '</td>'; html += '<td>' + totalValue.toFixed(1) + '</td>';
html += '<td>' + effectiveValue.toFixed(1) + '</td>'; html += '<td>' + effectiveValue.toFixed(1) + '</td>';
html += '<td><button class="btn-del" onclick="removeDay(\'' + dateStr + '\')"><i class="trash icon"></i></button></td>'; html += '<td><button class="btn-del" onclick="removeDay(\'' + dateStr + '\')"><i class="trash icon"></i></button></td>';
...@@ -485,6 +538,10 @@ function addDay() { ...@@ -485,6 +538,10 @@ function addDay() {
officeHour: res.detail.ocd_office_hour, officeHour: res.detail.ocd_office_hour,
projectId: projectId, projectId: projectId,
projectName: projectName, projectName: projectName,
// newly added rows are not PM-reviewed yet
ocd_pm_reviewed: false,
ocd_pm_reviewed_by_name: '',
ocd_pm_reviewed_at: null,
}; };
renderTable(); renderTable();
resetForm(); resetForm();
...@@ -596,6 +653,7 @@ function doSubmit() { ...@@ -596,6 +653,7 @@ function doSubmit() {
function resetForm() { function resetForm() {
$('#ocd_date_input').val(''); $('#ocd_date_input').val('');
resetDayTypeOptions();
$('#ocd_day_type').val(''); $('#ocd_day_type').val('');
$('#ocd_office_start').prop('readonly', false).removeClass('auto-field'); $('#ocd_office_start').prop('readonly', false).removeClass('auto-field');
$('#ocd_office_start, #ocd_office_end').val(''); $('#ocd_office_start, #ocd_office_end').val('');
...@@ -603,7 +661,8 @@ function resetForm() { ...@@ -603,7 +661,8 @@ function resetForm() {
$('#ocd_total_hours').val(''); $('#ocd_total_hours').val('');
$('#ocd_effective_hours').val(''); $('#ocd_effective_hours').val('');
$('#ocd_tasks').val(''); $('#ocd_tasks').val('');
$('#fk_lkp_project').val(''); // Default to No Project (id=110) per configuration
try { $('#fk_lkp_project').val('110'); } catch (e) { $('#fk_lkp_project').val(''); }
} }
</script> </script>
@endsection @endsection
...@@ -67,7 +67,18 @@ ...@@ -67,7 +67,18 @@
<td>{{ $d->ocd_overtime_to ?? '-' }}</td> <td>{{ $d->ocd_overtime_to ?? '-' }}</td>
<td>{{ $d->fk_lkp_project ? (\DB::table('lkp_project')->where('id', $d->fk_lkp_project)->value('p_project_description') ?? '-') : '-' }}</td> <td>{{ $d->fk_lkp_project ? (\DB::table('lkp_project')->where('id', $d->fk_lkp_project)->value('p_project_description') ?? '-') : '-' }}</td>
<td class="td-left">{{ $d->ocd_tasks ?? '-' }}</td> <td class="td-left">{{ $d->ocd_tasks ?? '-' }}</td>
<td>@if($d->ocd_pm_reviewed)<span class="ui green label">Reviewed</span>@else<span class="ui orange label">Pending</span>@endif</td> <td>
@php $isNoProject = ($d->fk_lkp_project == 110); @endphp
@if($isNoProject)
<span class="ui tiny blue label">Auto</span>
@else
@if($d->ocd_pm_reviewed)
<span class="ui green label">Reviewed</span>
@else
<span class="ui orange label">Pending</span>
@endif
@endif
</td>
<td><strong>{{ number_format($d->ocd_total_hours ?? 0, 1) }}</strong></td> <td><strong>{{ number_format($d->ocd_total_hours ?? 0, 1) }}</strong></td>
<td><strong>{{ number_format($d->ocd_effective_hours ?? 0, 1) }}</strong></td> <td><strong>{{ number_format($d->ocd_effective_hours ?? 0, 1) }}</strong></td>
</tr> </tr>
...@@ -142,8 +153,9 @@ ...@@ -142,8 +153,9 @@
<tr> <tr>
<th style="width:180px;">From</th> <th style="width:180px;">From</th>
<th>Query Notes</th> <th>Query Notes</th>
<th style="width:150px;">Query Date</th>
<th>Response</th> <th>Response</th>
<th style="width:150px;">Date</th> <th style="width:150px;">Respond Date</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -151,11 +163,12 @@ ...@@ -151,11 +163,12 @@
<tr> <tr>
<td>{{ \DB::table('users')->where('id', $q->fk_user_kueri)->value('name') ?? '-' }}</td> <td>{{ \DB::table('users')->where('id', $q->fk_user_kueri)->value('name') ?? '-' }}</td>
<td>{{ $q->remarks ?: '-' }}</td> <td>{{ $q->remarks ?: '-' }}</td>
<td>{{ $q->respond ?: '-' }}</td>
<td>{{ $q->tarikh ? \Carbon\Carbon::parse($q->tarikh)->format('d/m/Y H:i') : ($q->created_at ? $q->created_at->format('d/m/Y H:i') : '-') }}</td> <td>{{ $q->tarikh ? \Carbon\Carbon::parse($q->tarikh)->format('d/m/Y H:i') : ($q->created_at ? $q->created_at->format('d/m/Y H:i') : '-') }}</td>
<td>{{ $q->respond ?: '-' }}</td>
<td>{{ $q->updated_at ? $q->updated_at->format('d/m/Y H:i') : '-' }}</td>
</tr> </tr>
@empty @empty
<tr><td colspan="4" style="color:#999;font-style:italic;text-align:center;padding:1rem;">No query history found.</td></tr> <tr><td colspan="5" style="color:#999;font-style:italic;text-align:center;padding:1rem;">No query history found.</td></tr>
@endforelse @endforelse
</tbody> </tbody>
</table> </table>
......
...@@ -73,8 +73,8 @@ ...@@ -73,8 +73,8 @@
<i class='eye icon'></i> View <i class='eye icon'></i> View
</button>"; </button>";
// Editable only for Draf (1) or Dikueri oleh PM (6) // Editable only for Draf (1) or queried statuses by PM/HOD/PD (6/8/10)
$canEdit = in_array($row->ocm_status, [1, 6]); $canEdit = in_array($row->ocm_status, [1, 6, 8, 10]);
$edit = $canEdit $edit = $canEdit
? "<a href='" . route('overtime::overtime.editovertimeclaim', $row->id) . "' ? "<a href='" . route('overtime::overtime.editovertimeclaim', $row->id) . "'
...@@ -83,8 +83,8 @@ ...@@ -83,8 +83,8 @@
</a>" </a>"
: ""; : "";
// Batal allowed only from Draf (1) or Dikueri oleh PM (6) // Cancel allowed only from Draf (1) or queried statuses by PM/HOD/PD (6/8/10)
$canBatal = in_array($row->ocm_status, [1, 6]); $canBatal = in_array($row->ocm_status, [1, 6, 8, 10]);
$batal = $canBatal $batal = $canBatal
? "<button ? "<button
......
...@@ -67,7 +67,18 @@ ...@@ -67,7 +67,18 @@
<td>{{ $d->ocd_overtime_to ?? '-' }}</td> <td>{{ $d->ocd_overtime_to ?? '-' }}</td>
<td>{{ $d->fk_lkp_project ? (\DB::table('lkp_project')->where('id', $d->fk_lkp_project)->value('p_project_description') ?? '-') : '-' }}</td> <td>{{ $d->fk_lkp_project ? (\DB::table('lkp_project')->where('id', $d->fk_lkp_project)->value('p_project_description') ?? '-') : '-' }}</td>
<td class="td-left">{{ $d->ocd_tasks ?? '-' }}</td> <td class="td-left">{{ $d->ocd_tasks ?? '-' }}</td>
<td>@if($d->ocd_pm_reviewed)<span class="ui green label">Reviewed</span>@else<span class="ui orange label">Pending</span>@endif</td> <td>
@php $isNoProject = ($d->fk_lkp_project == 110); @endphp
@if($isNoProject)
<span class="ui tiny blue label">Auto</span>
@else
@if($d->ocd_pm_reviewed)
<span class="ui green label">Reviewed</span>
@else
<span class="ui orange label">Pending</span>
@endif
@endif
</td>
<td><strong>{{ number_format($d->ocd_total_hours ?? 0, 1) }}</strong></td> <td><strong>{{ number_format($d->ocd_total_hours ?? 0, 1) }}</strong></td>
<td><strong>{{ number_format($d->ocd_effective_hours ?? 0, 1) }}</strong></td> <td><strong>{{ number_format($d->ocd_effective_hours ?? 0, 1) }}</strong></td>
</tr> </tr>
...@@ -133,19 +144,21 @@ ...@@ -133,19 +144,21 @@
<tr> <tr>
<th style="width:180px;">From</th> <th style="width:180px;">From</th>
<th>Query Notes</th> <th>Query Notes</th>
<th style="width:150px;">Query Date</th>
<th>Response</th> <th>Response</th>
<th style="width:150px;">Date</th> <th style="width:150px;">Respond Date</th>
</thead> </thead>
<tbody> <tbody>
@forelse($queryHistory ?? collect() as $q) @forelse($queryHistory ?? collect() as $q)
<tr> <tr>
<td>{{ \DB::table('users')->where('id', $q->fk_user_kueri)->value('name') ?? '-' }}</td> <td>{{ \DB::table('users')->where('id', $q->fk_user_kueri)->value('name') ?? '-' }}</td>
<td>{{ $q->remarks ?: '-' }}</td> <td>{{ $q->remarks ?: '-' }}</td>
<td>{{ $q->respond ?: '-' }}</td>
<td>{{ $q->tarikh ? \Carbon\Carbon::parse($q->tarikh)->format('d/m/Y H:i') : ($q->created_at ? $q->created_at->format('d/m/Y H:i') : '-') }}</td> <td>{{ $q->tarikh ? \Carbon\Carbon::parse($q->tarikh)->format('d/m/Y H:i') : ($q->created_at ? $q->created_at->format('d/m/Y H:i') : '-') }}</td>
<td>{{ $q->respond ?: '-' }}</td>
<td>{{ $q->updated_at ? $q->updated_at->format('d/m/Y H:i') : '-' }}</td>
</tr> </tr>
@empty @empty
<tr><td colspan="4" style="color:#999;font-style:italic;text-align:center;padding:1rem;">No query history found.</td></tr> <tr><td colspan="5" style="color:#999;font-style:italic;text-align:center;padding:1rem;">No query history found.</td></tr>
@endforelse @endforelse
</tbody> </tbody>
</table> </table>
......
...@@ -126,6 +126,10 @@ ...@@ -126,6 +126,10 @@
<td class="td-project {{ $d->pm_owned ? '' : 'td-disabled' }}">{{ $d->fk_lkp_project ? ($projectNames[$d->fk_lkp_project] ?? '-') : '-' }}</td> <td class="td-project {{ $d->pm_owned ? '' : 'td-disabled' }}">{{ $d->fk_lkp_project ? ($projectNames[$d->fk_lkp_project] ?? '-') : '-' }}</td>
<td class="td-tasks {{ $d->pm_owned ? '' : 'td-disabled' }}">{{ $d->ocd_tasks ?: '-' }}</td> <td class="td-tasks {{ $d->pm_owned ? '' : 'td-disabled' }}">{{ $d->ocd_tasks ?: '-' }}</td>
<td class="{{ $d->pm_owned ? '' : 'td-disabled' }}"> <td class="{{ $d->pm_owned ? '' : 'td-disabled' }}">
@php $isNoProject = ($d->fk_lkp_project == 110); @endphp
@if($isNoProject)
<span class="ui tiny blue label">Auto</span>
@else
@if($d->pm_owned) @if($d->pm_owned)
@if($d->ocd_pm_reviewed) @if($d->ocd_pm_reviewed)
<span class="ui green label">Reviewed</span> <span class="ui green label">Reviewed</span>
...@@ -133,7 +137,13 @@ ...@@ -133,7 +137,13 @@
<span class="ui orange label">Pending</span> <span class="ui orange label">Pending</span>
@endif @endif
@else @else
<span class="ui grey label">Restricted</span> {{-- Non-owned rows remain greyed out, but show Pending or Reviewed based on actual review flag --}}
@if($d->ocd_pm_reviewed)
<span class="ui green label">Reviewed</span>
@else
<span class="ui grey label">Pending</span>
@endif
@endif
@endif @endif
</td> </td>
<td><strong>{{ number_format($d->ocd_total_hours ?? 0, 1) }}</strong></td> <td><strong>{{ number_format($d->ocd_total_hours ?? 0, 1) }}</strong></td>
...@@ -227,7 +237,7 @@ ...@@ -227,7 +237,7 @@
</div> </div>
<div style="display: flex; justify-content: flex-end; margin-top: 1rem;"> <div style="display: flex; justify-content: flex-end; margin-top: 1rem;">
<button type="button" class="ui teal button" id="btn-sokong" {{ $forms->isEmpty() ? 'disabled' : '' }}> <button type="button" class="ui teal button" id="btn-sokong" {{ $forms->isEmpty() || ($pmPendingCount ?? 0) === 0 ? 'disabled' : '' }}>
<i class="check icon"></i> Mark Reviewed <i class="check icon"></i> Mark Reviewed
</button> </button>
</div> </div>
...@@ -261,8 +271,9 @@ ...@@ -261,8 +271,9 @@
<tr> <tr>
<th style="width:180px;">From</th> <th style="width:180px;">From</th>
<th>Query Notes</th> <th>Query Notes</th>
<th style="width:150px;">Query Date</th>
<th>Response</th> <th>Response</th>
<th style="width:150px;">Date</th> <th style="width:150px;">Respond Date</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -270,11 +281,12 @@ ...@@ -270,11 +281,12 @@
<tr> <tr>
<td>{{ \DB::table('users')->where('id', $q->fk_user_kueri)->value('name') ?? '-' }}</td> <td>{{ \DB::table('users')->where('id', $q->fk_user_kueri)->value('name') ?? '-' }}</td>
<td>{{ $q->remarks ?: '-' }}</td> <td>{{ $q->remarks ?: '-' }}</td>
<td>{{ $q->respond ?: '-' }}</td>
<td>{{ $q->tarikh ? \Carbon\Carbon::parse($q->tarikh)->format('d/m/Y H:i') : ($q->created_at ? $q->created_at->format('d/m/Y H:i') : '-') }}</td> <td>{{ $q->tarikh ? \Carbon\Carbon::parse($q->tarikh)->format('d/m/Y H:i') : ($q->created_at ? $q->created_at->format('d/m/Y H:i') : '-') }}</td>
<td>{{ $q->respond ?: '-' }}</td>
<td>{{ $q->updated_at ? $q->updated_at->format('d/m/Y H:i') : '-' }}</td>
</tr> </tr>
@empty @empty
<tr><td colspan="4" style="color:#999;font-style:italic;text-align:center;padding:1rem;">No query history found.</td></tr> <tr><td colspan="5" style="color:#999;font-style:italic;text-align:center;padding:1rem;">No query history found.</td></tr>
@endforelse @endforelse
</tbody> </tbody>
</table> </table>
......
...@@ -164,9 +164,12 @@ function vcmBuildHtml(main, details) { ...@@ -164,9 +164,12 @@ function vcmBuildHtml(main, details) {
+ '<td>' + vcmEsc(d.ocd_overtime_to || '-') + '</td>' + '<td>' + vcmEsc(d.ocd_overtime_to || '-') + '</td>'
+ '<td>' + vcmEsc(d.project_name || '-') + '</td>' + '<td>' + vcmEsc(d.project_name || '-') + '</td>'
+ '<td class="vm-left">' + vcmEsc(d.ocd_tasks || '-') + '</td>' + '<td class="vm-left">' + vcmEsc(d.ocd_tasks || '-') + '</td>'
+ '<td>' + (d.ocd_pm_reviewed + '<td>'
+ ((d.fk_lkp_project && String(d.fk_lkp_project) === '110') || (d.project_id && String(d.project_id) === '110')
? '<span class="ui tiny blue label">Auto</span>'
: (d.ocd_pm_reviewed
? '<span class="ui green label">Reviewed</span>' ? '<span class="ui green label">Reviewed</span>'
: '<span class="ui orange label">Pending</span>') : '<span class="ui orange label">Pending</span>'))
+ '</td>' + '</td>'
+ '<td><strong>' + totalHours.toFixed(1) + '</strong></td>' + '<td><strong>' + totalHours.toFixed(1) + '</strong></td>'
+ '<td><strong>' + effectiveHours.toFixed(1) + '</strong></td>' + '<td><strong>' + effectiveHours.toFixed(1) + '</strong></td>'
......
...@@ -93,11 +93,16 @@ ...@@ -93,11 +93,16 @@
<td>{{ $escape($detail['project_name'] ?? '-') }}</td> <td>{{ $escape($detail['project_name'] ?? '-') }}</td>
<td class="vm-left">{{ $escape($detail['ocd_tasks'] ?? '-') }}</td> <td class="vm-left">{{ $escape($detail['ocd_tasks'] ?? '-') }}</td>
<td> <td>
@php $isNoProject = (!empty($detail['project_id']) && $detail['project_id'] == 110) || (!empty($detail['fk_lkp_project']) && $detail['fk_lkp_project'] == 110); @endphp
@if($isNoProject)
<span class="ui tiny blue label">Auto</span>
@else
@if (!empty($detail['ocd_pm_reviewed'])) @if (!empty($detail['ocd_pm_reviewed']))
<span class="ui green label">Reviewed</span> <span class="ui green label">Reviewed</span>
@else @else
<span class="ui orange label">Pending</span> <span class="ui orange label">Pending</span>
@endif @endif
@endif
</td> </td>
<td><strong>{{ number_format($totalHours, 1) }}</strong></td> <td><strong>{{ number_format($totalHours, 1) }}</strong></td>
<td><strong>{{ number_format($effectiveHours, 1) }}</strong></td> <td><strong>{{ number_format($effectiveHours, 1) }}</strong></td>
......
...@@ -155,8 +155,9 @@ ...@@ -155,8 +155,9 @@
<tr> <tr>
<th style="width:180px;">From</th> <th style="width:180px;">From</th>
<th>Query Notes</th> <th>Query Notes</th>
<th style="width:150px;">Query Date</th>
<th>Response</th> <th>Response</th>
<th style="width:150px;">Date</th> <th style="width:150px;">Respond Date</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -164,11 +165,12 @@ ...@@ -164,11 +165,12 @@
<tr> <tr>
<td>{{ \DB::table('users')->where('id', $q->fk_user_kueri)->value('name') ?? '-' }}</td> <td>{{ \DB::table('users')->where('id', $q->fk_user_kueri)->value('name') ?? '-' }}</td>
<td>{{ $q->remarks ?: '-' }}</td> <td>{{ $q->remarks ?: '-' }}</td>
<td>{{ $q->respond ?: '-' }}</td>
<td>{{ $q->tarikh ? \Carbon\Carbon::parse($q->tarikh)->format('d/m/Y H:i') : ($q->created_at ? $q->created_at->format('d/m/Y H:i') : '-') }}</td> <td>{{ $q->tarikh ? \Carbon\Carbon::parse($q->tarikh)->format('d/m/Y H:i') : ($q->created_at ? $q->created_at->format('d/m/Y H:i') : '-') }}</td>
<td>{{ $q->respond ?: '-' }}</td>
<td>{{ $q->updated_at ? $q->updated_at->format('d/m/Y H:i') : '-' }}</td>
</tr> </tr>
@empty @empty
<tr><td colspan="4" style="color:#999;font-style:italic;text-align:center;padding:1rem;">No query history found.</td></tr> <tr><td colspan="5" style="color:#999;font-style:italic;text-align:center;padding:1rem;">No query history found.</td></tr>
@endforelse @endforelse
</tbody> </tbody>
</table> </table>
......
...@@ -155,8 +155,9 @@ ...@@ -155,8 +155,9 @@
<tr> <tr>
<th style="width:180px;">From</th> <th style="width:180px;">From</th>
<th>Query Notes</th> <th>Query Notes</th>
<th style="width:150px;">Query Date</th>
<th>Response</th> <th>Response</th>
<th style="width:150px;">Date</th> <th style="width:150px;">Respond Date</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -164,11 +165,12 @@ ...@@ -164,11 +165,12 @@
<tr> <tr>
<td>{{ \DB::table('users')->where('id', $q->fk_user_kueri)->value('name') ?? '-' }}</td> <td>{{ \DB::table('users')->where('id', $q->fk_user_kueri)->value('name') ?? '-' }}</td>
<td>{{ $q->remarks ?: '-' }}</td> <td>{{ $q->remarks ?: '-' }}</td>
<td>{{ $q->respond ?: '-' }}</td>
<td>{{ $q->tarikh ? \Carbon\Carbon::parse($q->tarikh)->format('d/m/Y H:i') : ($q->created_at ? $q->created_at->format('d/m/Y H:i') : '-') }}</td> <td>{{ $q->tarikh ? \Carbon\Carbon::parse($q->tarikh)->format('d/m/Y H:i') : ($q->created_at ? $q->created_at->format('d/m/Y H:i') : '-') }}</td>
<td>{{ $q->respond ?: '-' }}</td>
<td>{{ $q->updated_at ? $q->updated_at->format('d/m/Y H:i') : '-' }}</td>
</tr> </tr>
@empty @empty
<tr><td colspan="4" style="color:#999;font-style:italic;text-align:center;padding:1rem;">No query history found.</td></tr> <tr><td colspan="5" style="color:#999;font-style:italic;text-align:center;padding:1rem;">No query history found.</td></tr>
@endforelse @endforelse
</tbody> </tbody>
</table> </table>
......
...@@ -33,6 +33,8 @@ ...@@ -33,6 +33,8 @@
$statusLabel = $statuses[$data->orm_status]->description ?? '-'; $statusLabel = $statuses[$data->orm_status]->description ?? '-';
$queryType = in_array($data->orm_status, [8, 10]) ? ($data->orm_status == 8 ? 'HOD' : 'PD') : ''; $queryType = in_array($data->orm_status, [8, 10]) ? ($data->orm_status == 8 ? 'HOD' : 'PD') : '';
$totalHours = $details->sum('ord_planned_ot_hour'); $totalHours = $details->sum('ord_planned_ot_hour');
$requestMonth = $data->orm_date ? \Carbon\Carbon::parse($data->orm_date)->format('m') : '';
$requestYear = $data->orm_date ? \Carbon\Carbon::parse($data->orm_date)->format('Y') : '';
@endphp @endphp
<div class="rf-summary"> <div class="rf-summary">
...@@ -61,6 +63,7 @@ ...@@ -61,6 +63,7 @@
<th>Planned OT Hours</th> <th>Planned OT Hours</th>
<th>Balance</th> <th>Balance</th>
<th>Reason</th> <th>Reason</th>
<th>Action</th>
</tr> </tr>
</thead> </thead>
<tbody id="rf-tbody"> <tbody id="rf-tbody">
...@@ -99,7 +102,7 @@ ...@@ -99,7 +102,7 @@
<select class="ui dropdown" id="ord_month"> <select class="ui dropdown" id="ord_month">
<option value="">Month</option> <option value="">Month</option>
@foreach(['01'=>'January','02'=>'February','03'=>'March','04'=>'April','05'=>'May','06'=>'June','07'=>'July','08'=>'August','09'=>'September','10'=>'October','11'=>'November','12'=>'December'] as $monthValue => $monthLabel) @foreach(['01'=>'January','02'=>'February','03'=>'March','04'=>'April','05'=>'May','06'=>'June','07'=>'July','08'=>'August','09'=>'September','10'=>'October','11'=>'November','12'=>'December'] as $monthValue => $monthLabel)
<option value="{{ $monthValue }}">{{ $monthLabel }}</option> <option value="{{ $monthValue }}" {{ $requestMonth == $monthValue ? 'selected' : '' }}>{{ $monthLabel }}</option>
@endforeach @endforeach
</select> </select>
</div> </div>
...@@ -107,7 +110,7 @@ ...@@ -107,7 +110,7 @@
<select class="ui dropdown" id="ord_year"> <select class="ui dropdown" id="ord_year">
<option value="">Year</option> <option value="">Year</option>
@for($year = now()->year - 1; $year <= now()->year + 2; $year++) @for($year = now()->year - 1; $year <= now()->year + 2; $year++)
<option value="{{ $year }}">{{ $year }}</option> <option value="{{ $year }}" {{ $requestYear == $year ? 'selected' : '' }}>{{ $year }}</option>
@endfor @endfor
</select> </select>
</div> </div>
...@@ -140,8 +143,9 @@ ...@@ -140,8 +143,9 @@
<tr> <tr>
<th style="width:180px;">From</th> <th style="width:180px;">From</th>
<th>Query Notes</th> <th>Query Notes</th>
<th style="width:150px;">Query Date</th>
<th>Response</th> <th>Response</th>
<th style="width:150px;">Date</th> <th style="width:150px;">Respond Date</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
...@@ -149,11 +153,12 @@ ...@@ -149,11 +153,12 @@
<tr> <tr>
<td>{{ \DB::table('users')->where('id', $q->fk_user_kueri)->value('name') ?? '-' }}</td> <td>{{ \DB::table('users')->where('id', $q->fk_user_kueri)->value('name') ?? '-' }}</td>
<td>{{ $q->remarks ?: '-' }}</td> <td>{{ $q->remarks ?: '-' }}</td>
<td>{{ $q->respond ?: '-' }}</td>
<td>{{ $q->tarikh ? \Carbon\Carbon::parse($q->tarikh)->format('d/m/Y H:i') : ($q->created_at ? $q->created_at->format('d/m/Y H:i') : '-') }}</td> <td>{{ $q->tarikh ? \Carbon\Carbon::parse($q->tarikh)->format('d/m/Y H:i') : ($q->created_at ? $q->created_at->format('d/m/Y H:i') : '-') }}</td>
<td>{{ $q->respond ?: '-' }}</td>
<td>{{ $q->updated_at ? $q->updated_at->format('d/m/Y H:i') : '-' }}</td>
</tr> </tr>
@empty @empty
<tr><td colspan="4" style="color:#999;font-style:italic;text-align:center;padding:1rem;">No query history found.</td></tr> <tr><td colspan="5" style="color:#999;font-style:italic;text-align:center;padding:1rem;">No query history found.</td></tr>
@endforelse @endforelse
</tbody> </tbody>
</table> </table>
...@@ -167,9 +172,9 @@ ...@@ -167,9 +172,9 @@
<div class="rf-footer"> <div class="rf-footer">
<a href="{{ route('overtime::overtime.listovertimerequest') }}" class="ui grey button"><i class="arrow left icon"></i>Back</a> <a href="{{ route('overtime::overtime.listovertimerequest') }}" class="ui grey button"><i class="arrow left icon"></i>Back</a>
<button type="button" class="ui grey button" onclick="saveDetails()"><i class="save icon"></i>Save Draft</button> <button type="button" class="ui grey button" id="btn-save-draft"><i class="save icon"></i>Save Draft</button>
@if(in_array($data->orm_status, [0, 8, 10])) @if(in_array($data->orm_status, [1, 8, 10]))
<button type="button" class="ui teal button" onclick="submitRequestForm()"><i class="paper plane icon"></i>Submit</button> <button type="button" class="ui teal button" id="btn-submit"><i class="paper plane icon"></i>Submit</button>
@endif @endif
</div> </div>
</div> </div>
...@@ -192,7 +197,9 @@ function bindEvents() { ...@@ -192,7 +197,9 @@ function bindEvents() {
$('#ord_balance').val((b - u).toFixed(2)); $('#ord_balance').val((b - u).toFixed(2));
}); });
$('#btn-add-row').on('click', addRow); $('#btn-add-row').on('click', addRow);
$('#btn-reset').on('click', resetForm); $('#btn-reset').on('click', resetRequestForm);
$('#btn-save-draft').on('click', saveRequestDetails);
$('#btn-submit').on('click', submitRequestForm);
} }
function csrfToken() { return $('meta[name="csrf-token"]').attr('content'); } function csrfToken() { return $('meta[name="csrf-token"]').attr('content'); }
...@@ -219,7 +226,7 @@ function renderTable() { ...@@ -219,7 +226,7 @@ function renderTable() {
var keys = Object.keys(rows); var keys = Object.keys(rows);
var tbody = $('#rf-tbody'); var tbody = $('#rf-tbody');
if (keys.length === 0) { if (keys.length === 0) {
tbody.html('<tr class="empty-row"><td colspan="10">No entries yet. Use the form below to add one.</td></tr>'); tbody.html('<tr class="empty-row"><td colspan="9">No entries yet. Use the form below to add one.</td></tr>');
$('#grand-total').text('0.00'); $('#grand-total').text('0.00');
return; return;
} }
...@@ -276,7 +283,7 @@ function addRow() { ...@@ -276,7 +283,7 @@ function addRow() {
if (!res.success) { showError(res.message || 'Error while adding.'); return; } if (!res.success) { showError(res.message || 'Error while adding.'); return; }
rows[res.detail.id] = res.detail; rows[res.detail.id] = res.detail;
renderTable(); renderTable();
resetForm(); resetRequestForm();
showSuccess(res.message || 'Entry added.'); showSuccess(res.message || 'Entry added.');
}, },
error: function (xhr) { error: function (xhr) {
...@@ -304,13 +311,51 @@ function removeRow(id) { ...@@ -304,13 +311,51 @@ function removeRow(id) {
}); });
} }
function resetForm() { function resetRequestForm() {
$('#ord_name, #ord_month, #ord_year').val(''); $('#ord_name, #ord_month, #ord_year').val('');
if ($.fn.dropdown) $('#ord_name, #ord_month, #ord_year').dropdown('clear'); if ($.fn.dropdown) $('#ord_name, #ord_month, #ord_year').dropdown('clear');
$('#ord_budgeted, #ord_utilised_to_date, #ord_planned_ot_hour, #ord_balance').val(''); $('#ord_budgeted, #ord_utilised_to_date, #ord_planned_ot_hour, #ord_balance').val('');
$('#ord_reason').val(''); $('#ord_reason').val('');
} }
function saveRequestDetails() {
var respondVal = $('#kueri_respond').val();
function doSave() {
$.ajax({
url: "{{ route('overtime::overtime.updateovertimerequest', $data->id) }}",
method: 'POST',
data: { _token: csrfToken() },
success: function (res) {
if (res.success) { showSuccess(res.message); setTimeout(function () { window.location.href = res.redirect || window.location.href; }, 1200); }
else { showError(res.message); }
},
error: function (xhr) {
var msg = 'Error while saving draft.';
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);
},
});
}
if ($('#kueri_respond').length && respondVal && respondVal.trim()) {
$.ajax({
url: "{{ route('overtime::overtime.savekueriresponddetail.request', $data->id) }}",
method: 'POST',
data: { _token: csrfToken(), respond: respondVal.trim() },
success: function () { doSave(); },
error: function (xhr) {
var msg = 'Error while saving response.';
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);
},
});
} else {
doSave();
}
}
function submitRequestForm() { function submitRequestForm() {
var respondVal = $('#kueri_respond').val(); var respondVal = $('#kueri_respond').val();
function doSubmit() { function doSubmit() {
......
...@@ -58,8 +58,8 @@ ...@@ -58,8 +58,8 @@
<i class='eye icon'></i> View <i class='eye icon'></i> View
</button>"; </button>";
$canEdit = in_array($row->orm_status, [0, 8, 10]); $canEdit = in_array($row->orm_status, [1, 8, 10]);
$canBatal = in_array($row->orm_status, [0, 8, 10]); $canBatal = in_array($row->orm_status, [1, 8, 10]);
$edit = $canEdit $edit = $canEdit
? "<a href='" . route('overtime::overtime.editovertimerequest', $row->id) . "' ? "<a href='" . route('overtime::overtime.editovertimerequest', $row->id) . "'
......
...@@ -15,7 +15,7 @@ function () { ...@@ -15,7 +15,7 @@ function () {
Route::get('index', ['uses' => 'OvertimeController@index', 'as' => 'overtime.index']); Route::get('index', ['uses' => 'OvertimeController@index', 'as' => 'overtime.index']);
// OT CLAIM - Staff // OT CLAIM - Staff
Route::middleware('can:' . Permission::APPLICATION_OT)->group(function () { Route::middleware('can:' . Permission::CLAIM_OT)->group(function () {
Route::get('list', ['uses' => 'OvertimeClaimController@getListOvertimeClaim', 'as' => 'overtime.listovertime']); Route::get('list', ['uses' => 'OvertimeClaimController@getListOvertimeClaim', 'as' => 'overtime.listovertime']);
Route::get('claim/create', ['uses' => 'OvertimeClaimController@createOvertimeClaim', 'as' => 'overtime.createovertimeclaim']); Route::get('claim/create', ['uses' => 'OvertimeClaimController@createOvertimeClaim', 'as' => 'overtime.createovertimeclaim']);
Route::post('claim/store', ['uses' => 'OvertimeClaimController@storeOvertimeClaim', 'as' => 'overtime.storeovertimeclaim']); Route::post('claim/store', ['uses' => 'OvertimeClaimController@storeOvertimeClaim', 'as' => 'overtime.storeovertimeclaim']);
...@@ -35,7 +35,7 @@ function () { ...@@ -35,7 +35,7 @@ function () {
}); });
// OT CLAIM - Project Manager (PM) // OT CLAIM - Project Manager (PM)
Route::middleware('can:' . Permission::APPLICATION_OT_REVIEW)->group(function () { Route::middleware('can:' . Permission::CLAIM_OT_PM)->group(function () {
Route::get('claim/{id}/pm-view', ['uses' => 'OvertimeProjectManagerController@viewClaim', 'as' => 'overtime.pmviewclaim']); Route::get('claim/{id}/pm-view', ['uses' => 'OvertimeProjectManagerController@viewClaim', 'as' => 'overtime.pmviewclaim']);
Route::post('claim/{id}/pm-mark-reviewed', ['uses' => 'OvertimeProjectManagerController@markReviewed', 'as' => 'overtime.pmmarkreviewed']); Route::post('claim/{id}/pm-mark-reviewed', ['uses' => 'OvertimeProjectManagerController@markReviewed', 'as' => 'overtime.pmmarkreviewed']);
Route::post('claim/{id}/sokong', ['uses' => 'OvertimeProjectManagerController@sokongClaim', 'as' => 'overtime.pmsokongclaim']); Route::post('claim/{id}/sokong', ['uses' => 'OvertimeProjectManagerController@sokongClaim', 'as' => 'overtime.pmsokongclaim']);
...@@ -44,7 +44,7 @@ function () { ...@@ -44,7 +44,7 @@ function () {
}); });
// OT CLAIM - Head of Department (HOD) // OT CLAIM - Head of Department (HOD)
Route::middleware('can:' . Permission::APPLICATION_OT_SUPPORT)->group(function () { Route::middleware('can:' . Permission::CLAIM_OT_HOD)->group(function () {
Route::get('claim/hod/list', ['uses' => 'OvertimeClaimHodController@getHodReviewList', 'as' => 'overtime.hodclaimreviewlist']); Route::get('claim/hod/list', ['uses' => 'OvertimeClaimHodController@getHodReviewList', 'as' => 'overtime.hodclaimreviewlist']);
Route::get('claim/hod/{id}/view', ['uses' => 'OvertimeClaimHodController@viewClaim', 'as' => 'overtime.hodviewclaim']); Route::get('claim/hod/{id}/view', ['uses' => 'OvertimeClaimHodController@viewClaim', 'as' => 'overtime.hodviewclaim']);
Route::post('claim/hod/{id}/sokong', ['uses' => 'OvertimeClaimHodController@sokongClaim', 'as' => 'overtime.hodsokongclaim']); Route::post('claim/hod/{id}/sokong', ['uses' => 'OvertimeClaimHodController@sokongClaim', 'as' => 'overtime.hodsokongclaim']);
...@@ -52,7 +52,7 @@ function () { ...@@ -52,7 +52,7 @@ function () {
}); });
// OT CLAIM - Project Director (PD) // OT CLAIM - Project Director (PD)
Route::middleware('can:' . Permission::APPLICATION_OT_APPROVE)->group(function () { Route::middleware('can:' . Permission::CLAIM_OT_PD)->group(function () {
Route::get('claim/pd/list', ['uses' => 'OvertimeClaimPdController@getPdReviewList', 'as' => 'overtime.pdclaimreviewlist']); Route::get('claim/pd/list', ['uses' => 'OvertimeClaimPdController@getPdReviewList', 'as' => 'overtime.pdclaimreviewlist']);
Route::get('claim/pd/{id}/view', ['uses' => 'OvertimeClaimPdController@viewClaim', 'as' => 'overtime.pdviewclaim']); Route::get('claim/pd/{id}/view', ['uses' => 'OvertimeClaimPdController@viewClaim', 'as' => 'overtime.pdviewclaim']);
Route::post('claim/pd/{id}/sokong', ['uses' => 'OvertimeClaimPdController@sokongClaim', 'as' => 'overtime.pdsokongclaim']); Route::post('claim/pd/{id}/sokong', ['uses' => 'OvertimeClaimPdController@sokongClaim', 'as' => 'overtime.pdsokongclaim']);
...@@ -60,7 +60,7 @@ function () { ...@@ -60,7 +60,7 @@ function () {
}); });
// OT REQUEST - Project Manager (PM) // OT REQUEST - Project Manager (PM)
Route::middleware('can:' . Permission::REQUEST_OT)->group(function () { Route::middleware('can:' . Permission::REQUEST_OT_PM)->group(function () {
Route::get('request/list', ['uses' => 'OvertimeRequestController@getListOvertimeRequest', 'as' => 'overtime.listovertimerequest']); Route::get('request/list', ['uses' => 'OvertimeRequestController@getListOvertimeRequest', 'as' => 'overtime.listovertimerequest']);
Route::get('request/create', ['uses' => 'OvertimeRequestController@createOvertimeRequest', 'as' => 'overtime.createovertimerequest']); Route::get('request/create', ['uses' => 'OvertimeRequestController@createOvertimeRequest', 'as' => 'overtime.createovertimerequest']);
Route::get('request/existing-projects', ['uses' => 'OvertimeRequestController@getExistingProjects', 'as' => 'overtime.existingprojects']); Route::get('request/existing-projects', ['uses' => 'OvertimeRequestController@getExistingProjects', 'as' => 'overtime.existingprojects']);
...@@ -79,7 +79,7 @@ function () { ...@@ -79,7 +79,7 @@ function () {
}); });
// OT REQUEST - Head of Department (HOD) // OT REQUEST - Head of Department (HOD)
Route::middleware('can:' . Permission::APPLICATION_OT_HOD)->group(function () { Route::middleware('can:' . Permission::REQUEST_OT_HOD)->group(function () {
Route::get('request/hod/list', ['uses' => 'OvertimeHodController@getReviewList', 'as' => 'overtime.hodreviewlist']); Route::get('request/hod/list', ['uses' => 'OvertimeHodController@getReviewList', 'as' => 'overtime.hodreviewlist']);
Route::get('request/hod/{id}/view', ['uses' => 'OvertimeHodController@viewRequestForm', 'as' => 'overtime.hodviewrequest']); Route::get('request/hod/{id}/view', ['uses' => 'OvertimeHodController@viewRequestForm', 'as' => 'overtime.hodviewrequest']);
Route::post('request/hod/{id}/approve', ['uses' => 'OvertimeHodController@approveRequestForm', 'as' => 'overtime.hodapproverequest']); Route::post('request/hod/{id}/approve', ['uses' => 'OvertimeHodController@approveRequestForm', 'as' => 'overtime.hodapproverequest']);
...@@ -88,7 +88,7 @@ function () { ...@@ -88,7 +88,7 @@ function () {
}); });
// OT REQUEST - Project Director (PD) // OT REQUEST - Project Director (PD)
Route::middleware('can:' . Permission::APPLICATION_OT_PD)->group(function () { Route::middleware('can:' . Permission::REQUEST_OT_PD)->group(function () {
Route::get('request/pd/list', ['uses' => 'OvertimePdController@getReviewList', 'as' => 'overtime.pdreviewlist']); Route::get('request/pd/list', ['uses' => 'OvertimePdController@getReviewList', 'as' => 'overtime.pdreviewlist']);
Route::get('request/pd/{id}/view', ['uses' => 'OvertimePdController@viewRequestForm', 'as' => 'overtime.pdviewrequest']); Route::get('request/pd/{id}/view', ['uses' => 'OvertimePdController@viewRequestForm', 'as' => 'overtime.pdviewrequest']);
Route::post('request/pd/{id}/approve', ['uses' => 'OvertimePdController@approveRequestForm', 'as' => 'overtime.pdapproverequest']); Route::post('request/pd/{id}/approve', ['uses' => 'OvertimePdController@approveRequestForm', 'as' => 'overtime.pdapproverequest']);
......
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
class OvertimeClaimHodRepo class OvertimeClaimHodRepo
{ {
private const NO_PROJECT_ID = 110;
// ========================================================================= // =========================================================================
// STATUSES // STATUSES
// ========================================================================= // =========================================================================
...@@ -33,6 +35,11 @@ private function currentHodDepartmentId(): ?int ...@@ -33,6 +35,11 @@ private function currentHodDepartmentId(): ?int
->value('fk_lkp_department'); ->value('fk_lkp_department');
} }
private function currentHodUserId(): ?int
{
return (int) Auth::id();
}
// ========================================================================= // =========================================================================
// HOD REVIEW LIST — status 7 is set by HOD itself, so the inbox is // HOD REVIEW LIST — status 7 is set by HOD itself, so the inbox is
...@@ -41,17 +48,25 @@ private function currentHodDepartmentId(): ?int ...@@ -41,17 +48,25 @@ private function currentHodDepartmentId(): ?int
public function getHodReviewList($request) public function getHodReviewList($request)
{ {
$search = $request->get('search'); $search = $request->get('search');
$currentHod = $this->currentHodUserId();
return OvertimeClaimMain::where('ocm_status', 5) // Only show claims that are in HOD queue and belong to applicants
// whose staff_info.penyokong matches the current HOD.
$query = OvertimeClaimMain::where('ocm_status', 5)
->whereNull('deleted_at')
->where(function ($q) use ($search) { ->where(function ($q) use ($search) {
$q->where('ocm_apply_no', 'like', "%{$search}%") $q->where('ocm_apply_no', 'like', "%{$search}%")
->orWhere('ocm_staff_name', 'like', "%{$search}%"); ->orWhere('ocm_staff_name', 'like', "%{$search}%");
}) })
->orderBy('created_at', 'desc') ->whereIn('fk_lkp_staff_info', function ($sub) use ($currentHod) {
->paginate(10); $sub->select('id')
->from('staff_info')
->where('penyokong', $currentHod);
});
return $query->orderBy('created_at', 'desc')->paginate(10);
} }
// ========================================================================= // =========================================================================
...@@ -66,6 +81,15 @@ public function findClaim(int $id): OvertimeClaimMain ...@@ -66,6 +81,15 @@ public function findClaim(int $id): OvertimeClaimMain
throw new AuthorizationException('Unauthorized claim access.'); throw new AuthorizationException('Unauthorized claim access.');
} }
// Ensure this HOD is the applicant's penyokong
$penyokong = DB::table('staff_info')
->where('id', $claim->fk_lkp_staff_info)
->value('penyokong');
if ($penyokong === null || (int) $penyokong !== $this->currentHodUserId()) {
throw new AuthorizationException('Unauthorized claim access.');
}
return $claim; return $claim;
} }
...@@ -81,6 +105,10 @@ public function countPendingPmReviews(int $claimId): int ...@@ -81,6 +105,10 @@ public function countPendingPmReviews(int $claimId): int
{ {
return OvertimeClaimDetail::where('fk_overtime_claim_main', $claimId) return OvertimeClaimDetail::where('fk_overtime_claim_main', $claimId)
->where('ocd_pm_reviewed', 0) ->where('ocd_pm_reviewed', 0)
->where(function ($q) {
$q->whereNull('fk_lkp_project')
->orWhere('fk_lkp_project', '!=', self::NO_PROJECT_ID);
})
->count(); ->count();
} }
...@@ -138,7 +166,7 @@ public function kueriClaim($request, int $claimId): OvertimeClaimMain ...@@ -138,7 +166,7 @@ public function kueriClaim($request, int $claimId): OvertimeClaimMain
$claim->update([ $claim->update([
'ocm_status' => 8, // Dikueri Oleh HOD 'ocm_status' => 8, // Dikueri Oleh HOD
'kueri_status' => 1, 'ocm_query_status' => 1,
'updated_by' => Auth::id(), 'updated_by' => Auth::id(),
]); ]);
...@@ -151,7 +179,7 @@ public function kueriClaim($request, int $claimId): OvertimeClaimMain ...@@ -151,7 +179,7 @@ public function kueriClaim($request, int $claimId): OvertimeClaimMain
'tarikh' => now(), 'tarikh' => now(),
]); ]);
$this->logAudit('UPDATE', $claim->id, null, $this->logAudit('QUERY', $claim->id, null,
"queried claim {$claim->ocm_apply_no} and sent it back to the applicant."); "queried claim {$claim->ocm_apply_no} and sent it back to the applicant.");
return $claim; return $claim;
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\Access\AuthorizationException;
use Portal\Overtime\Model\OvertimeAuditQuery; use Portal\Overtime\Model\OvertimeAuditQuery;
use Portal\Overtime\Model\OvertimeAuditTrail; use Portal\Overtime\Model\OvertimeAuditTrail;
...@@ -12,6 +13,8 @@ ...@@ -12,6 +13,8 @@
class OvertimeClaimPdRepo class OvertimeClaimPdRepo
{ {
private const NO_PROJECT_ID = 110;
// ========================================================================= // =========================================================================
// STATUSES // STATUSES
// ========================================================================= // =========================================================================
...@@ -26,6 +29,67 @@ public function getOtStatuses(): \Illuminate\Support\Collection ...@@ -26,6 +29,67 @@ public function getOtStatuses(): \Illuminate\Support\Collection
->keyBy('ref_id'); ->keyBy('ref_id');
} }
// Helpers to determine current PD's projects (ids and names)
private function currentStaffId(): ?string
{
return DB::table('staff_info')
->where('fk_users', Auth::id())
->value('staff_id');
}
private function currentPdUserId(): int
{
return (int) Auth::id();
}
private function projectTeamProjectColumn(): string
{
if (Schema::hasColumn('project_team', 'pt_project_id')) {
return 'pt_project_id';
}
return 'fk_project_id';
}
private function currentPdProjectIds(): \Illuminate\Support\Collection
{
$staffId = $this->currentStaffId();
if (! $staffId) {
return collect();
}
$projectColumn = $this->projectTeamProjectColumn();
return DB::table('project_team')
->where('pt_staff_id', $staffId)
->where('role_id', 7)
->pluck($projectColumn)
->filter()
->unique()
->values();
}
private function currentPdProjectNames(): \Illuminate\Support\Collection
{
$staffId = $this->currentStaffId();
if (! $staffId || ! Schema::hasColumn('project_team', 'pt_project_description')) {
return collect();
}
return DB::table('project_team')
->where('pt_staff_id', $staffId)
->where('role_id', 7)
->pluck('pt_project_description')
->filter(function ($name) {
return trim((string) $name) !== '';
})
->map(function ($name) {
return trim((string) $name);
})
->unique()
->values();
}
// ========================================================================= // =========================================================================
// PD REVIEW LIST — claims sokong'd by HOD (status 7) waiting for PD action // PD REVIEW LIST — claims sokong'd by HOD (status 7) waiting for PD action
// ========================================================================= // =========================================================================
...@@ -33,12 +97,62 @@ public function getOtStatuses(): \Illuminate\Support\Collection ...@@ -33,12 +97,62 @@ public function getOtStatuses(): \Illuminate\Support\Collection
public function getPdReviewList($request) public function getPdReviewList($request)
{ {
$search = $request->get('search'); $search = $request->get('search');
$pdProjectIds = $this->currentPdProjectIds();
$pdProjectNames = $this->currentPdProjectNames();
$currentPdUserId = $this->currentPdUserId();
return OvertimeClaimMain::where('ocm_status', 7) return OvertimeClaimMain::where('ocm_status', 7)
->where(function ($q) use ($search) { ->where(function ($q) use ($search) {
$q->where('ocm_apply_no', 'like', "%{$search}%") $q->where('ocm_apply_no', 'like', "%{$search}%")
->orWhere('ocm_staff_name', 'like', "%{$search}%"); ->orWhere('ocm_staff_name', 'like', "%{$search}%");
}) })
->where(function ($q) use ($pdProjectIds, $pdProjectNames, $currentPdUserId) {
// Primary path: claim has at least one detail row in PD's project scope.
if (!$pdProjectIds->isEmpty() || !$pdProjectNames->isEmpty()) {
$q->whereExists(function ($sub) use ($pdProjectIds, $pdProjectNames) {
$sub->select(DB::raw('1'))
->from('overtime_claim_detail')
->whereRaw('overtime_claim_detail.fk_overtime_claim_main = overtime_claim_main.id')
->where(function ($d) use ($pdProjectIds, $pdProjectNames) {
if (!$pdProjectIds->isEmpty()) {
$d->whereIn('overtime_claim_detail.fk_lkp_project', $pdProjectIds->all());
}
if (!$pdProjectNames->isEmpty()) {
$d->orWhereIn('overtime_claim_detail.fk_lkp_project', function ($ss) use ($pdProjectNames) {
$ss->select('id')
->from('lkp_project')
->whereIn('p_project_description', $pdProjectNames->all());
});
}
});
});
}
// Fallback path: No Project-only claim routes to applicant's pelulus.
$q->orWhere(function ($fallback) use ($currentPdUserId) {
$fallback->whereIn('fk_lkp_staff_info', function ($sub) use ($currentPdUserId) {
$sub->select('id')
->from('staff_info')
->where('pelulus', $currentPdUserId);
})
->whereExists(function ($hasNoProject) {
$hasNoProject->select(DB::raw('1'))
->from('overtime_claim_detail')
->whereRaw('overtime_claim_detail.fk_overtime_claim_main = overtime_claim_main.id')
->where('overtime_claim_detail.fk_lkp_project', self::NO_PROJECT_ID);
})
->whereNotExists(function ($hasNormalProject) {
$hasNormalProject->select(DB::raw('1'))
->from('overtime_claim_detail')
->whereRaw('overtime_claim_detail.fk_overtime_claim_main = overtime_claim_main.id')
->where(function ($d) {
$d->whereNull('overtime_claim_detail.fk_lkp_project')
->orWhere('overtime_claim_detail.fk_lkp_project', '!=', self::NO_PROJECT_ID);
});
});
});
})
->orderBy('created_at', 'desc') ->orderBy('created_at', 'desc')
->paginate(10); ->paginate(10);
} }
...@@ -55,8 +169,58 @@ public function findClaim(int $id): OvertimeClaimMain ...@@ -55,8 +169,58 @@ public function findClaim(int $id): OvertimeClaimMain
throw new AuthorizationException('Unauthorized claim access.'); throw new AuthorizationException('Unauthorized claim access.');
} }
// Ensure claim's projects match current PD's ownership/membership by
// inspecting the claim detail rows (fk_lkp_project).
$pdProjectIds = $this->currentPdProjectIds();
$pdProjectNames = $this->currentPdProjectNames();
$matches = DB::table('overtime_claim_detail')
->where('fk_overtime_claim_main', $claim->id)
->where(function ($q) use ($pdProjectIds, $pdProjectNames) {
if (!$pdProjectIds->isEmpty()) {
$q->whereIn('fk_lkp_project', $pdProjectIds->all());
}
if (!$pdProjectNames->isEmpty()) {
$q->orWhereIn('fk_lkp_project', function ($sub) use ($pdProjectNames) {
$sub->select('id')->from('lkp_project')->whereIn('p_project_description', $pdProjectNames->all());
});
}
})
->exists();
if ($matches) {
return $claim;
}
// Fallback access: No Project-only claim belongs to current PD when
// applicant's staff_info.pelulus points to this PD user.
$fallbackEligible = DB::table('staff_info')
->where('id', $claim->fk_lkp_staff_info)
->where('pelulus', $this->currentPdUserId())
->exists();
if ($fallbackEligible) {
$hasNoProject = DB::table('overtime_claim_detail')
->where('fk_overtime_claim_main', $claim->id)
->where('fk_lkp_project', self::NO_PROJECT_ID)
->exists();
$hasNormalProject = DB::table('overtime_claim_detail')
->where('fk_overtime_claim_main', $claim->id)
->where(function ($q) {
$q->whereNull('fk_lkp_project')
->orWhere('fk_lkp_project', '!=', self::NO_PROJECT_ID);
})
->exists();
if ($hasNoProject && !$hasNormalProject) {
return $claim; return $claim;
} }
}
throw new AuthorizationException('Unauthorized claim access.');
}
public function findClaimDetails(int $id) public function findClaimDetails(int $id)
{ {
...@@ -116,7 +280,7 @@ public function kueriClaim($request, int $claimId): OvertimeClaimMain ...@@ -116,7 +280,7 @@ public function kueriClaim($request, int $claimId): OvertimeClaimMain
$claim->update([ $claim->update([
'ocm_status' => 10, // Dikueri Oleh BOD/PD 'ocm_status' => 10, // Dikueri Oleh BOD/PD
'kueri_status' => 1, 'ocm_query_status' => 1,
'updated_by' => Auth::id(), 'updated_by' => Auth::id(),
]); ]);
...@@ -129,7 +293,7 @@ public function kueriClaim($request, int $claimId): OvertimeClaimMain ...@@ -129,7 +293,7 @@ public function kueriClaim($request, int $claimId): OvertimeClaimMain
'tarikh' => now(), 'tarikh' => now(),
]); ]);
$this->logAudit('UPDATE', $claim->id, null, $this->logAudit('QUERY', $claim->id, null,
"queried claim {$claim->ocm_apply_no} and sent it back to the applicant."); "queried claim {$claim->ocm_apply_no} and sent it back to the applicant.");
return $claim; return $claim;
......
...@@ -36,18 +36,52 @@ private function mapAttendanceDayType(?int $attendanceDayType): ?string ...@@ -36,18 +36,52 @@ private function mapAttendanceDayType(?int $attendanceDayType): ?string
{ {
return match ($attendanceDayType) { return match ($attendanceDayType) {
1 => 'Hari Bekerja', 1 => 'Hari Bekerja',
2 => 'Hari Rehat', 2 => 'Hari Minggu',
3 => 'Cuti Umum', 3 => 'Hari Cuti Umum',
4 => 'Hari Cuti Selain Cuti Umum',
default => null, default => null,
}; };
} }
private function mapAttendanceStatus(?int $attendanceStatus): ?string
{
return match ($attendanceStatus) {
1 => 'Hadir',
2 => 'Cuti',
3 => 'Latihan',
4 => 'Public Holiday',
5 => 'Hari Minggu',
6 => 'Urusan Rasmi',
default => null,
};
}
private function buildAttendanceDayTypeLabel(?int $attendanceDayType, ?int $attendanceStatus): ?string
{
$dayTypeLabel = $this->mapAttendanceDayType($attendanceDayType);
if ($dayTypeLabel === null) {
return null;
}
$statusLabel = $this->mapAttendanceStatus($attendanceStatus);
if ($statusLabel === null) {
return $dayTypeLabel;
}
if ($statusLabel === $dayTypeLabel) {
return $dayTypeLabel;
}
return $dayTypeLabel . ' (' . $statusLabel . ')';
}
private function mapDayTypeCodeToLabel($dayTypeCode): ?string private function mapDayTypeCodeToLabel($dayTypeCode): ?string
{ {
return match ((string) $dayTypeCode) { return match ((string) $dayTypeCode) {
'1' => 'Hari Bekerja', '1' => 'Hari Bekerja',
'2' => 'Hari Rehat', '2' => 'Hari Minggu',
'3' => 'Cuti Umum', '3' => 'Hari Cuti Umum',
'4' => 'Hari Cuti Selain Cuti Umum',
default => null, default => null,
}; };
} }
...@@ -69,15 +103,20 @@ public function getAttendanceByDate(string $date): ?array ...@@ -69,15 +103,20 @@ public function getAttendanceByDate(string $date): ?array
return null; return null;
} }
$dayType = $this->mapAttendanceDayType( $attendanceDayType = isset($attendance->fk_lkp_day_type) ? (int) $attendance->fk_lkp_day_type : null;
isset($attendance->fk_lkp_day_type) ? (int) $attendance->fk_lkp_day_type : null $attendanceStatus = isset($attendance->attendance_status) ? (int) $attendance->attendance_status : null;
$dayType = $this->buildAttendanceDayTypeLabel(
$attendanceDayType,
$attendanceStatus
); );
return [ return [
'time_in' => $attendance->time_in, 'time_in' => $attendance->time_in,
'time_out_flexi' => $attendance->time_out_flexi, 'time_out_flexi' => $attendance->time_out_flexi,
'time_out' => $attendance->time_out, 'time_out' => $attendance->time_out,
'fk_lkp_day_type' => isset($attendance->fk_lkp_day_type) ? (int) $attendance->fk_lkp_day_type : null, 'fk_lkp_day_type' => $attendanceDayType,
'attendance_status' => $attendanceStatus,
'day_type' => $dayType, 'day_type' => $dayType,
]; ];
} }
...@@ -177,13 +216,21 @@ public function addOvertimeClaimDetail(int $id, $request): OvertimeClaimDetail ...@@ -177,13 +216,21 @@ public function addOvertimeClaimDetail(int $id, $request): OvertimeClaimDetail
? $request->ocd_office_start . ' – ' . ($request->ocd_office_end ?? '?') ? $request->ocd_office_start . ' – ' . ($request->ocd_office_end ?? '?')
: null; : null;
$attendanceDayType = DB::table('attendance') $attendance = DB::table('attendance')
->where('fk_staff_info', $this->currentStaffInfoId()) ->where('fk_staff_info', $this->currentStaffInfoId())
->whereDate('date', $request->ocd_date) ->whereDate('date', $request->ocd_date)
->value('fk_lkp_day_type'); ->first(['fk_lkp_day_type', 'attendance_status']);
$attendanceDayType = $attendance && isset($attendance->fk_lkp_day_type)
? (int) $attendance->fk_lkp_day_type
: null;
$attendanceStatus = $attendance && isset($attendance->attendance_status)
? (int) $attendance->attendance_status
: null;
$resolvedDayType = $this->mapAttendanceDayType( $resolvedDayType = $this->buildAttendanceDayTypeLabel(
$attendanceDayType !== null ? (int) $attendanceDayType : null $attendanceDayType,
$attendanceStatus
) ?? $this->mapDayTypeCodeToLabel($request->ocd_day_type) ?? $request->ocd_day_type; ) ?? $this->mapDayTypeCodeToLabel($request->ocd_day_type) ?? $request->ocd_day_type;
$payload = [ $payload = [
...@@ -279,15 +326,55 @@ public function submitOvertimeClaim($request, int $id): OvertimeClaimMain ...@@ -279,15 +326,55 @@ public function submitOvertimeClaim($request, int $id): OvertimeClaimMain
throw new \Exception('Please add at least one overtime claim day.'); throw new \Exception('Please add at least one overtime claim day.');
} }
$isResubmission = $record->ocm_status == 6 && $record->ocm_query_status == 1; $isResubmission = in_array((int) $record->ocm_status, [6, 8, 10], true) && (int) $record->ocm_query_status === 1;
$newStatus = $isResubmission ? 3 : 2; $newStatus = $isResubmission ? 3 : 2;
// If all detail rows belong to the dedicated "No Project" entry,
// bypass PM review and route directly to HOD. The No Project id
// has been created already (id = 110) and we use that literal
// here per the user's request (no new seeder/files).
$NO_PROJECT_ID = 110;
$detailProjects = OvertimeClaimDetail::where('fk_overtime_claim_main', $id)
->pluck('fk_lkp_project')
->map(fn ($v) => $v === null ? null : (int) $v)
->toArray();
$allNoProject = true;
foreach ($detailProjects as $p) {
if ($p !== $NO_PROJECT_ID) {
$allNoProject = false;
break;
}
}
// For first-time submissions, clear PM review flags so PMs review unless
// this is a No Project claim — in that case mark details as reviewed
// and send straight to HOD (status 5).
if (!$isResubmission) {
if ($allNoProject) {
OvertimeClaimDetail::where('fk_overtime_claim_main', $id)
->update([
'ocd_pm_reviewed' => 1,
'ocd_pm_reviewed_by' => Auth::id(),
'ocd_pm_reviewed_at' => now(),
]);
$newStatus = 5; // Disemak oleh PM (treated as already reviewed -> HOD inbox)
} else {
OvertimeClaimDetail::where('fk_overtime_claim_main', $id) OvertimeClaimDetail::where('fk_overtime_claim_main', $id)
->update([ ->update([
'ocd_pm_reviewed' => 0, 'ocd_pm_reviewed' => 0,
'ocd_pm_reviewed_by' => null, 'ocd_pm_reviewed_by' => null,
'ocd_pm_reviewed_at' => null, 'ocd_pm_reviewed_at' => null,
]); ]);
}
} else {
// Resubmission: if all details are No Project, ensure routing goes to HOD
if ($allNoProject) {
$newStatus = 5;
}
}
$record->update([ $record->update([
'ocm_status' => $newStatus, 'ocm_status' => $newStatus,
...@@ -344,54 +431,18 @@ public function getAuditTrail(string $taskCode, int $claimId, ?int $detailId = n ...@@ -344,54 +431,18 @@ public function getAuditTrail(string $taskCode, int $claimId, ?int $detailId = n
]); ]);
} }
// AUDIT TRAIL LIST (for viewing)
public function getAuditTrailList($request)
{
$search = $request->get('search');
return \Portal\Overtime\Model\OvertimeAuditTrail::with(['claim', 'task'])
->when($search, function ($q) use ($search) {
$q->whereHas('claim', function ($q2) use ($search) {
$q2->where('ocm_apply_no', 'like', "%{$search}%");
});
})
->orderBy('created_at', 'desc')
->paginate(15);
}
// =========================================================================
// BATAL (cancel - allowed only from Draft=1 or Queried by PM=6)
// =========================================================================
public function batalOvertimeClaim(int $id): OvertimeClaimMain
{
$record = $this->findOvertimeClaim($id);
if (!in_array($record->ocm_status, [1, 6])) {
throw new \Exception('The claim cannot be cancelled in its current status.');
}
$record->update([
'ocm_status' => 4, // Cancelled claim
'updated_by' => Auth::id(),
]);
$this->getAuditTrail('UPDATE', $id, null, 'Claim cancelled by the applicant.');
return $record;
}
// ========================================================================= // =========================================================================
// SAVE QUERY RESPONSE (applicant responding to PM's query remark) // SAVE QUERY RESPONSE (applicant responding to PM/HOD/PD query remark)
// ========================================================================= // =========================================================================
public function saveKueriRespond(int $claimId, string $respond): void public function saveKueriRespond(int $claimId, string $respond): void
{ {
$record = $this->findOvertimeClaim($claimId); $record = $this->findOvertimeClaim($claimId);
if (!in_array((int) $record->ocm_status, [6, 8, 10], true)) {
throw new \Exception('This claim is not in query status.');
}
$query = \Portal\Overtime\Model\OvertimeAuditQuery::where('fk_main', $record->id) $query = \Portal\Overtime\Model\OvertimeAuditQuery::where('fk_main', $record->id)
->where('no_permohonan', $record->ocm_apply_no) ->where('no_permohonan', $record->ocm_apply_no)
->orderBy('created_at', 'desc') ->orderBy('created_at', 'desc')
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Portal\Overtime\Model\OvertimeAuditQuery; use Portal\Overtime\Model\OvertimeAuditQuery;
use Portal\Overtime\Model\OvertimeAuditTrail; use Portal\Overtime\Model\OvertimeAuditTrail;
use Portal\Overtime\Model\OvertimeRequestMain; use Portal\Overtime\Model\OvertimeRequestMain;
...@@ -13,53 +12,52 @@ ...@@ -13,53 +12,52 @@
class OvertimeHodRepo class OvertimeHodRepo
{ {
private function currentStaffId(): ?string private function currentHodUserId(): int
{ {
return DB::table('staff_info') return (int) Auth::id();
->where('fk_users', Auth::id())
->value('staff_id');
} }
private function currentHodDepartmentId(): ?int private function resolveApplicantUserId(OvertimeRequestMain $record): ?int
{ {
$staffId = $this->currentStaffId(); if (!empty($record->orm_name) && is_numeric((string) $record->orm_name)) {
if (!$staffId) { return (int) $record->orm_name;
return null;
} }
return DB::table('staff_info') if (!empty($record->orm_requested_by_id)) {
$staffId = DB::table('project_team')
->where('id', $record->orm_requested_by_id)
->value('pt_staff_id');
if ($staffId) {
$applicantUserId = DB::table('staff_info')
->where('staff_id', $staffId) ->where('staff_id', $staffId)
->value('fk_lkp_department'); ->value('fk_users');
}
private function projectTeamProjectColumn(): string if ($applicantUserId && is_numeric((string) $applicantUserId)) {
{ return (int) $applicantUserId;
if (Schema::hasColumn('project_team', 'pt_project_id')) { }
return 'pt_project_id'; }
} }
return 'fk_project_id'; return null;
} }
private function currentHodProjectIds(): \Illuminate\Support\Collection private function resolveApplicantHodUserId(OvertimeRequestMain $record): ?int
{ {
$departmentId = $this->currentHodDepartmentId(); $applicantUserId = $this->resolveApplicantUserId($record);
if (!$departmentId) { if (!$applicantUserId) {
return collect(); return null;
} }
$projectColumn = $this->projectTeamProjectColumn(); $hodUserId = DB::table('staff_info')
->where('fk_users', $applicantUserId)
->value('penyokong');
return DB::table('project_team as pt') if ($hodUserId === null || $hodUserId === '' || !is_numeric((string) $hodUserId)) {
->join('staff_info as si', 'si.staff_id', '=', 'pt.pt_staff_id') return null;
->where('si.fk_lkp_department', $departmentId) }
->whereNotNull("pt.{$projectColumn}")
->select("pt.{$projectColumn} as project_id") return (int) $hodUserId;
->distinct()
->pluck('project_id')
->filter()
->unique()
->values();
} }
public function getOtStatuses(): \Illuminate\Support\Collection public function getOtStatuses(): \Illuminate\Support\Collection
...@@ -74,9 +72,8 @@ public function getOtStatuses(): \Illuminate\Support\Collection ...@@ -74,9 +72,8 @@ public function getOtStatuses(): \Illuminate\Support\Collection
private function authorizeHodRequestAccess(OvertimeRequestMain $record, ?array $allowedStatuses = null): void private function authorizeHodRequestAccess(OvertimeRequestMain $record, ?array $allowedStatuses = null): void
{ {
$projectIds = $this->currentHodProjectIds(); $hodUserId = $this->resolveApplicantHodUserId($record);
if ($hodUserId === null || $hodUserId !== $this->currentHodUserId()) {
if ($projectIds->isEmpty() || !$projectIds->contains($record->orm_project)) {
throw new AuthorizationException('Unauthorized request access.'); throw new AuthorizationException('Unauthorized request access.');
} }
...@@ -92,18 +89,29 @@ private function authorizeHodRequestAccess(OvertimeRequestMain $record, ?array $ ...@@ -92,18 +89,29 @@ private function authorizeHodRequestAccess(OvertimeRequestMain $record, ?array $
public function getReviewList($request) public function getReviewList($request)
{ {
$search = $request->get('search', ''); $search = $request->get('search', '');
$projectIds = $this->currentHodProjectIds();
$query = OvertimeRequestMain::where('orm_status', 2)
->whereNull('deleted_at')
->when($search, fn ($q) => $q->where('orm_apply_no', 'like', "%{$search}%"));
if ($projectIds->isEmpty()) { return OvertimeRequestMain::query()
return $query->whereRaw('0 = 1')->orderBy('created_at', 'desc')->paginate(10); ->from('overtime_request_main as orm')
} ->leftJoin('project_team as pt', 'pt.id', '=', 'orm.orm_requested_by_id')
->leftJoin('staff_info as si', 'si.staff_id', '=', 'pt.pt_staff_id')
return $query->whereIn('orm_project', $projectIds) ->where('orm.orm_status', 2)
->orderBy('created_at', 'desc') ->whereNull('orm.deleted_at')
->where(function ($q) {
$q->where('si.penyokong', $this->currentHodUserId())
->orWhere(function ($fallback) {
$fallback->whereNull('orm.orm_requested_by_id')
->whereIn('orm.orm_name', function ($sub) {
$sub->select('fk_users')
->from('staff_info')
->whereNotNull('fk_users')
->where('penyokong', $this->currentHodUserId());
});
});
})
->when($search, fn ($q) => $q->where('orm.orm_apply_no', 'like', "%{$search}%"))
->select('orm.*')
->distinct()
->orderBy('orm.created_at', 'desc')
->paginate(10); ->paginate(10);
} }
...@@ -193,7 +201,7 @@ public function kueriRequestForm(int $id, string $remark): OvertimeRequestMain ...@@ -193,7 +201,7 @@ public function kueriRequestForm(int $id, string $remark): OvertimeRequestMain
]); ]);
// Audit trail: HOD kueri // Audit trail: HOD kueri
$this->logAuditTrail('KUERI', $record->id, null, 'Request form queried by HOD.'); $this->logAuditTrail('QUERY', $record->id, null, 'Request form queried by HOD.');
return $record; return $record;
} }
...@@ -241,6 +249,8 @@ private function logAuditTrail(string $taskCode, int $requestId, ?int $detailId ...@@ -241,6 +249,8 @@ private function logAuditTrail(string $taskCode, int $requestId, ?int $detailId
OvertimeAuditTrail::create([ OvertimeAuditTrail::create([
'fk_overtime_claim_main' => null, 'fk_overtime_claim_main' => null,
'fk_overtime_claim_detail' => null, 'fk_overtime_claim_detail' => null,
'fk_overtime_request_main' => $requestId,
'fk_overtime_request_detail' => $detailId,
'fk_lkp_overtime_task' => $taskId, 'fk_lkp_overtime_task' => $taskId,
'user' => Auth::id(), 'user' => Auth::id(),
'description' => $description, 'description' => $description,
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
use Illuminate\Auth\Access\AuthorizationException; use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB; use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Schema;
use Portal\Overtime\Model\OvertimeAuditQuery; use Portal\Overtime\Model\OvertimeAuditQuery;
use Portal\Overtime\Model\OvertimeAuditTrail; use Portal\Overtime\Model\OvertimeAuditTrail;
use Portal\Overtime\Model\OvertimeRequestMain; use Portal\Overtime\Model\OvertimeRequestMain;
...@@ -12,6 +13,80 @@ ...@@ -12,6 +13,80 @@
class OvertimePdRepo class OvertimePdRepo
{ {
private function currentStaffId(): ?string
{
return DB::table('staff_info')
->where('fk_users', Auth::id())
->value('staff_id');
}
private function projectTeamProjectColumn(): string
{
if (Schema::hasColumn('project_team', 'pt_project_id')) {
return 'pt_project_id';
}
return 'fk_project_id';
}
private function currentPdProjectIds(): \Illuminate\Support\Collection
{
$staffId = $this->currentStaffId();
if (!$staffId) {
return collect();
}
$projectColumn = $this->projectTeamProjectColumn();
return DB::table('project_team')
->where('pt_staff_id', $staffId)
->where('role_id', 7)
->pluck($projectColumn)
->filter()
->unique()
->values();
}
private function currentPdProjectNames(): \Illuminate\Support\Collection
{
$staffId = $this->currentStaffId();
if (!$staffId || !Schema::hasColumn('project_team', 'pt_project_description')) {
return collect();
}
return DB::table('project_team')
->where('pt_staff_id', $staffId)
->where('role_id', 7)
->pluck('pt_project_description')
->filter(function ($name) {
return trim((string) $name) !== '';
})
->map(function ($name) {
return trim((string) $name);
})
->unique()
->values();
}
private function requestBelongsToCurrentPd(OvertimeRequestMain $record): bool
{
$pdProjectIds = $this->currentPdProjectIds();
if (!$pdProjectIds->isEmpty() && $pdProjectIds->contains((int) $record->orm_project)) {
return true;
}
$projectName = DB::table('lkp_project')
->where('id', $record->orm_project)
->value('p_project_description');
if (!$projectName) {
return false;
}
$pdProjectNames = $this->currentPdProjectNames();
return $pdProjectNames->contains(trim((string) $projectName));
}
public function getOtStatuses(): \Illuminate\Support\Collection public function getOtStatuses(): \Illuminate\Support\Collection
{ {
return DB::table('lkp_status') return DB::table('lkp_status')
...@@ -24,6 +99,10 @@ public function getOtStatuses(): \Illuminate\Support\Collection ...@@ -24,6 +99,10 @@ public function getOtStatuses(): \Illuminate\Support\Collection
private function authorizePdRequestAccess(OvertimeRequestMain $record, ?array $allowedStatuses = null): void private function authorizePdRequestAccess(OvertimeRequestMain $record, ?array $allowedStatuses = null): void
{ {
if (!$this->requestBelongsToCurrentPd($record)) {
throw new AuthorizationException('Unauthorized request access.');
}
if (!in_array((int) $record->orm_status, [7, 9, 10, 11], true)) { if (!in_array((int) $record->orm_status, [7, 9, 10, 11], true)) {
throw new AuthorizationException('Unauthorized request access.'); throw new AuthorizationException('Unauthorized request access.');
} }
...@@ -41,8 +120,28 @@ public function getReviewList($request) ...@@ -41,8 +120,28 @@ public function getReviewList($request)
{ {
$search = $request->get('search', ''); $search = $request->get('search', '');
$pdProjectIds = $this->currentPdProjectIds();
$pdProjectNames = $this->currentPdProjectNames();
if ($pdProjectIds->isEmpty() && $pdProjectNames->isEmpty()) {
return OvertimeRequestMain::whereRaw('0 = 1')->paginate(10);
}
return OvertimeRequestMain::whereIn('orm_status', [7, 11]) return OvertimeRequestMain::whereIn('orm_status', [7, 11])
->whereNull('deleted_at') ->whereNull('deleted_at')
->where(function ($q) use ($pdProjectIds, $pdProjectNames) {
if (!$pdProjectIds->isEmpty()) {
$q->whereIn('orm_project', $pdProjectIds->all());
}
if (!$pdProjectNames->isEmpty()) {
$q->orWhereIn('orm_project', function ($sub) use ($pdProjectNames) {
$sub->select('id')
->from('lkp_project')
->whereIn('p_project_description', $pdProjectNames->all());
});
}
})
->when($search, fn ($q) => $q->where('orm_apply_no', 'like', "%{$search}%")) ->when($search, fn ($q) => $q->where('orm_apply_no', 'like', "%{$search}%"))
->orderBy('created_at', 'desc') ->orderBy('created_at', 'desc')
->paginate(10); ->paginate(10);
...@@ -78,11 +177,6 @@ public function findQueryHistory(int $id) ...@@ -78,11 +177,6 @@ public function findQueryHistory(int $id)
->orderBy('created_at', 'desc') ->orderBy('created_at', 'desc')
->get(); ->get();
} }
// =========================================================================
// APPROVE → status 11 (Permohonan Diluluskan — stays in PD list, visible in Sokong picker)
// =========================================================================
public function approveRequestForm(int $id): OvertimeRequestMain public function approveRequestForm(int $id): OvertimeRequestMain
{ {
$record = $this->findRequestForm($id); $record = $this->findRequestForm($id);
...@@ -136,7 +230,7 @@ public function kueriRequestForm(int $id, string $remark): OvertimeRequestMain ...@@ -136,7 +230,7 @@ public function kueriRequestForm(int $id, string $remark): OvertimeRequestMain
]); ]);
// Audit trail: PD kueri // Audit trail: PD kueri
$this->logAuditTrail('KUERI', $record->id, null, 'Request form queried by PD.'); $this->logAuditTrail('QUERY', $record->id, null, 'Request form queried by PD.');
return $record; return $record;
} }
...@@ -188,6 +282,8 @@ private function logAuditTrail(string $taskCode, int $requestId, ?int $detailId ...@@ -188,6 +282,8 @@ private function logAuditTrail(string $taskCode, int $requestId, ?int $detailId
OvertimeAuditTrail::create([ OvertimeAuditTrail::create([
'fk_overtime_claim_main' => null, 'fk_overtime_claim_main' => null,
'fk_overtime_claim_detail' => null, 'fk_overtime_claim_detail' => null,
'fk_overtime_request_main' => $requestId,
'fk_overtime_request_detail' => $detailId,
'fk_lkp_overtime_task' => $taskId, 'fk_lkp_overtime_task' => $taskId,
'user' => Auth::id(), 'user' => Auth::id(),
'description' => $description, 'description' => $description,
......
...@@ -13,6 +13,8 @@ ...@@ -13,6 +13,8 @@
class OvertimeProjectManagerRepo class OvertimeProjectManagerRepo
{ {
private const NO_PROJECT_ID = 110;
// ========================================================================= // =========================================================================
// HELPERS // HELPERS
// ========================================================================= // =========================================================================
...@@ -99,11 +101,13 @@ public function getProjectManagerReviewList($request) ...@@ -99,11 +101,13 @@ public function getProjectManagerReviewList($request)
{ {
$search = $request->get('search'); $search = $request->get('search');
// Return all pending claims (status 2 or 3) that have details $projectIds = $this->currentPmProjectIds();
// requiring PM review. Do NOT filter by PM-owned projects here;
// the view will decide which actions are enabled or disabled.
$query = OvertimeClaimMain::with('details') $query = OvertimeClaimMain::with('details')
->whereIn('ocm_status', [2, 3]); ->whereIn('ocm_status', [2, 3])
->whereHas('details', function ($q) use ($projectIds) {
$q->where('ocd_pm_reviewed', 0)
->whereIn('fk_lkp_project', $projectIds->all());
});
if ($search) { if ($search) {
$query->where(function ($q) use ($search) { $query->where(function ($q) use ($search) {
...@@ -185,10 +189,11 @@ public function getApprovedRequestFormsForCurrentPm(?OvertimeClaimMain $claim = ...@@ -185,10 +189,11 @@ public function getApprovedRequestFormsForCurrentPm(?OvertimeClaimMain $claim =
$form->request_staff_names = $this->getRequestFormStaffNames((int) $form->id); $form->request_staff_names = $this->getRequestFormStaffNames((int) $form->id);
$form->request_staff_name = $form->request_staff_names->first(); $form->request_staff_name = $form->request_staff_names->first();
$form->is_pm_project = $projectIds->contains($form->orm_project); $form->is_pm_project = $projectIds->contains($form->orm_project);
$form->display_label = implode(' - ', array_filter([ $form->display_label = trim(implode(' - ', array_filter([
$form->project_name, // Desired format: "project name (request form number) - month/year"
$form->orm_apply_no, ($form->project_name ? ($form->project_name . ' (' . $form->orm_apply_no . ')') : $form->orm_apply_no),
], static fn ($value) => $value !== null && $value !== '')); $form->request_month_year,
], static fn ($value) => $value !== null && $value !== '')));
} }
return $forms; return $forms;
...@@ -348,20 +353,32 @@ public function markClaimReviewed(int $id, int $requestFormId): OvertimeClaimMai ...@@ -348,20 +353,32 @@ public function markClaimReviewed(int $id, int $requestFormId): OvertimeClaimMai
} }
} }
$updatedRows = OvertimeClaimDetail::where('fk_overtime_claim_main', $id) $projectRowsCount = OvertimeClaimDetail::where('fk_overtime_claim_main', $id)
->where('fk_lkp_project', $requestForm->orm_project)
->count();
if ($projectRowsCount === 0) {
throw new \Exception('Tiada baris tuntutan untuk projek anda dijumpai pada permohonan ini.');
}
// Only update rows that are not yet marked reviewed. Make this
// operation idempotent so calling it when all rows are already
// reviewed does not result in an error.
OvertimeClaimDetail::where('fk_overtime_claim_main', $id)
->where('fk_lkp_project', $requestForm->orm_project) ->where('fk_lkp_project', $requestForm->orm_project)
->where('ocd_pm_reviewed', 0)
->update([ ->update([
'ocd_pm_reviewed' => 1, 'ocd_pm_reviewed' => 1,
'ocd_pm_reviewed_by' => Auth::id(), 'ocd_pm_reviewed_by' => Auth::id(),
'ocd_pm_reviewed_at' => now(), 'ocd_pm_reviewed_at' => now(),
]); ]);
if ($updatedRows === 0) {
throw new \Exception('Tiada baris tuntutan untuk projek anda dijumpai pada permohonan ini.');
}
$pendingCount = OvertimeClaimDetail::where('fk_overtime_claim_main', $id) $pendingCount = OvertimeClaimDetail::where('fk_overtime_claim_main', $id)
->where('ocd_pm_reviewed', 0) ->where('ocd_pm_reviewed', 0)
->where(function ($q) {
$q->whereNull('fk_lkp_project')
->orWhere('fk_lkp_project', '!=', self::NO_PROJECT_ID);
})
->count(); ->count();
if ($pendingCount === 0) { if ($pendingCount === 0) {
...@@ -402,7 +419,7 @@ public function kueriClaim(int $id, string $remarks): OvertimeClaimMain ...@@ -402,7 +419,7 @@ public function kueriClaim(int $id, string $remarks): OvertimeClaimMain
'tarikh' => now(), 'tarikh' => now(),
]); ]);
$this->logAuditTrail('KUERI', $id, null, 'Permohonan dikueri balik kepada pemohon.'); $this->logAuditTrail('QUERY', $id, null, 'Permohonan dikueri balik kepada pemohon.');
return $record; return $record;
} }
......
...@@ -27,10 +27,10 @@ public function getOtStatuses(): \Illuminate\Support\Collection ...@@ -27,10 +27,10 @@ public function getOtStatuses(): \Illuminate\Support\Collection
->get() ->get()
->keyBy('ref_id'); ->keyBy('ref_id');
if (!$statuses->has(0)) { if (!$statuses->has(1)) {
$statuses->put(0, (object) [ $statuses->put(1, (object) [
'module' => 'ot', 'module' => 'ot',
'ref_id' => 0, 'ref_id' => 1,
'description' => 'Draf', 'description' => 'Draf',
'status' => 1, 'status' => 1,
]); ]);
...@@ -303,7 +303,7 @@ public function storeRequestForm($request): OvertimeRequestMain ...@@ -303,7 +303,7 @@ public function storeRequestForm($request): OvertimeRequestMain
'orm_position' => $team->role_id ?? null, 'orm_position' => $team->role_id ?? null,
'orm_project' => $request->orm_project, 'orm_project' => $request->orm_project,
'orm_department' => $staffInfo->fk_lkp_department ?? null, 'orm_department' => $staffInfo->fk_lkp_department ?? null,
'orm_status' => 0, // pending HR approval 'orm_status' => 1, // Draf
'orm_requested_by_id' => $teamId, 'orm_requested_by_id' => $teamId,
'orm_requested_date' => now(), 'orm_requested_date' => now(),
'updated_by' => Auth::id(), 'updated_by' => Auth::id(),
...@@ -325,7 +325,7 @@ public function storeRequestForm($request): OvertimeRequestMain ...@@ -325,7 +325,7 @@ public function storeRequestForm($request): OvertimeRequestMain
public function updateRequestForm($request, int $id): OvertimeRequestMain public function updateRequestForm($request, int $id): OvertimeRequestMain
{ {
$record = $this->findRequestForm($id); $record = $this->findRequestForm($id);
$this->authorizePmRequestAccess($record, [0, 8, 10]); $this->authorizePmRequestAccess($record, [1, 8, 10]);
$staffInfo = $this->currentStaffInfo(); $staffInfo = $this->currentStaffInfo();
$teamId = $this->currentProjectTeamId((int) $record->orm_project); $teamId = $this->currentProjectTeamId((int) $record->orm_project);
$team = $teamId ? DB::table('project_team')->where('id', $teamId)->first() : null; $team = $teamId ? DB::table('project_team')->where('id', $teamId)->first() : null;
...@@ -351,9 +351,9 @@ public function updateRequestForm($request, int $id): OvertimeRequestMain ...@@ -351,9 +351,9 @@ public function updateRequestForm($request, int $id): OvertimeRequestMain
public function batalRequestForm(int $id): OvertimeRequestMain public function batalRequestForm(int $id): OvertimeRequestMain
{ {
$record = $this->findRequestForm($id); $record = $this->findRequestForm($id);
$this->authorizePmRequestAccess($record, [0]); $this->authorizePmRequestAccess($record, [1]);
if ($record->orm_status != 0) { if ($record->orm_status != 1) {
throw new \Exception('The request form cannot be cancelled in its current status.'); throw new \Exception('The request form cannot be cancelled in its current status.');
} }
...@@ -375,7 +375,7 @@ public function batalRequestForm(int $id): OvertimeRequestMain ...@@ -375,7 +375,7 @@ public function batalRequestForm(int $id): OvertimeRequestMain
public function deleteRequestForm(int $id): void public function deleteRequestForm(int $id): void
{ {
$record = $this->findRequestForm($id); $record = $this->findRequestForm($id);
$this->authorizePmRequestAccess($record, [0]); $this->authorizePmRequestAccess($record, [1]);
OvertimeRequestDetail::where('fk_overtime_request_main', $id)->delete(); OvertimeRequestDetail::where('fk_overtime_request_main', $id)->delete();
$record->update(['deleted_at' => now()]); $record->update(['deleted_at' => now()]);
...@@ -391,7 +391,7 @@ public function deleteRequestForm(int $id): void ...@@ -391,7 +391,7 @@ public function deleteRequestForm(int $id): void
public function addRequestFormDetail(int $mainId, $request): OvertimeRequestDetail public function addRequestFormDetail(int $mainId, $request): OvertimeRequestDetail
{ {
$record = $this->findRequestForm($mainId); $record = $this->findRequestForm($mainId);
$this->authorizePmRequestAccess($record, [0, 8, 10]); $this->authorizePmRequestAccess($record, [1, 8, 10]);
$staffUserId = $this->resolveProjectStaffIdByName((int) $record->orm_project, (string) $request->ord_name); $staffUserId = $this->resolveProjectStaffIdByName((int) $record->orm_project, (string) $request->ord_name);
if (!$staffUserId) { if (!$staffUserId) {
...@@ -425,7 +425,7 @@ public function updateRequestFormDetail(int $detailId, $request): OvertimeReques ...@@ -425,7 +425,7 @@ public function updateRequestFormDetail(int $detailId, $request): OvertimeReques
{ {
$detail = OvertimeRequestDetail::findOrFail($detailId); $detail = OvertimeRequestDetail::findOrFail($detailId);
$record = $this->findRequestForm((int) $detail->fk_overtime_request_main); $record = $this->findRequestForm((int) $detail->fk_overtime_request_main);
$this->authorizePmRequestAccess($record, [0, 8, 10]); $this->authorizePmRequestAccess($record, [1, 8, 10]);
$staffUserId = $this->resolveProjectStaffIdByName((int) $record->orm_project, (string) $request->ord_name); $staffUserId = $this->resolveProjectStaffIdByName((int) $record->orm_project, (string) $request->ord_name);
if (!$staffUserId) { if (!$staffUserId) {
...@@ -458,7 +458,7 @@ public function removeRequestFormDetail(int $detailId): void ...@@ -458,7 +458,7 @@ public function removeRequestFormDetail(int $detailId): void
{ {
$detail = OvertimeRequestDetail::findOrFail($detailId); $detail = OvertimeRequestDetail::findOrFail($detailId);
$record = $this->findRequestForm((int) $detail->fk_overtime_request_main); $record = $this->findRequestForm((int) $detail->fk_overtime_request_main);
$this->authorizePmRequestAccess($record, [0, 8, 10]); $this->authorizePmRequestAccess($record, [1, 8, 10]);
$mainId = $detail->fk_overtime_request_main; $mainId = $detail->fk_overtime_request_main;
$detail->delete(); $detail->delete();
...@@ -468,7 +468,7 @@ public function removeRequestFormDetail(int $detailId): void ...@@ -468,7 +468,7 @@ public function removeRequestFormDetail(int $detailId): void
// ========================================================================= // =========================================================================
// AUDIT TRAIL (helper for request repo) // AUDIT TRAIL (helper for request repo)
// Mirrors logger used in claim repos // Mirrors logger used in claim repos
private function logAuditTrail(string $taskCode, int $claimId, ?int $detailId = null, string $extra = ''): void private function logAuditTrail(string $taskCode, int $requestId, ?int $detailId = null, string $extra = ''): void
{ {
$taskId = DB::table('lkp_overtime_task') $taskId = DB::table('lkp_overtime_task')
->where('task_code', $taskCode) ->where('task_code', $taskCode)
...@@ -480,7 +480,7 @@ private function logAuditTrail(string $taskCode, int $claimId, ?int $detailId = ...@@ -480,7 +480,7 @@ private function logAuditTrail(string $taskCode, int $claimId, ?int $detailId =
->value('task_name') ?? $taskCode; ->value('task_name') ?? $taskCode;
$userName = Auth::user()->name ?? 'Unknown'; $userName = Auth::user()->name ?? 'Unknown';
$applyNo = OvertimeRequestMain::where('id', $claimId)->value('orm_apply_no') ?? '-'; $applyNo = OvertimeRequestMain::where('id', $requestId)->value('orm_apply_no') ?? '-';
$description = "{$userName} performed {$taskName} on request {$applyNo}."; $description = "{$userName} performed {$taskName} on request {$applyNo}.";
if ($extra) { if ($extra) {
...@@ -490,6 +490,8 @@ private function logAuditTrail(string $taskCode, int $claimId, ?int $detailId = ...@@ -490,6 +490,8 @@ private function logAuditTrail(string $taskCode, int $claimId, ?int $detailId =
OvertimeAuditTrail::create([ OvertimeAuditTrail::create([
'fk_overtime_claim_main' => null, 'fk_overtime_claim_main' => null,
'fk_overtime_claim_detail' => null, 'fk_overtime_claim_detail' => null,
'fk_overtime_request_main' => $requestId,
'fk_overtime_request_detail' => $detailId,
'fk_lkp_overtime_task' => $taskId, 'fk_lkp_overtime_task' => $taskId,
'user' => Auth::id(), 'user' => Auth::id(),
'description' => $description, 'description' => $description,
...@@ -502,7 +504,7 @@ private function logAuditTrail(string $taskCode, int $claimId, ?int $detailId = ...@@ -502,7 +504,7 @@ private function logAuditTrail(string $taskCode, int $claimId, ?int $detailId =
public function submitRequestForm(int $id): OvertimeRequestMain public function submitRequestForm(int $id): OvertimeRequestMain
{ {
$record = $this->findRequestForm($id); $record = $this->findRequestForm($id);
$this->authorizePmRequestAccess($record, [0, 8, 10]); $this->authorizePmRequestAccess($record, [1, 8, 10]);
$detailCount = OvertimeRequestDetail::where('fk_overtime_request_main', $id)->count(); $detailCount = OvertimeRequestDetail::where('fk_overtime_request_main', $id)->count();
if ($detailCount === 0) { if ($detailCount === 0) {
......
...@@ -139,8 +139,21 @@ public function viewOvertimeClaim(Request $request, int $id): JsonResponse ...@@ -139,8 +139,21 @@ public function viewOvertimeClaim(Request $request, int $id): JsonResponse
?: '-') ?: '-')
: '-'; : '-';
$pmReviewed = $details->every(fn ($d) => (bool) $d->ocd_pm_reviewed); $NO_PROJECT_ID = 110;
$pendingPmReviews = $details->where('ocd_pm_reviewed', 0)->count(); $pmReviewed = $details->filter(function ($d) use ($NO_PROJECT_ID) {
// Treat No Project rows as auto-reviewed for PM summary
if (!empty($d->fk_lkp_project) && $d->fk_lkp_project == $NO_PROJECT_ID) {
return true;
}
return (bool) $d->ocd_pm_reviewed;
})->count() === $details->count();
$pendingPmReviews = $details->filter(function ($d) use ($NO_PROJECT_ID) {
if (!empty($d->fk_lkp_project) && $d->fk_lkp_project == $NO_PROJECT_ID) {
return false;
}
return $d->ocd_pm_reviewed == 0;
})->count();
return response()->json([ return response()->json([
'success' => true, 'success' => true,
...@@ -175,6 +188,13 @@ public function viewOvertimeClaim(Request $request, int $id): JsonResponse ...@@ -175,6 +188,13 @@ public function viewOvertimeClaim(Request $request, int $id): JsonResponse
? ($projectNames[$d->fk_lkp_project] ?? '') ? ($projectNames[$d->fk_lkp_project] ?? '')
: '', : '',
'ocd_pm_reviewed' => (bool) $d->ocd_pm_reviewed, 'ocd_pm_reviewed' => (bool) $d->ocd_pm_reviewed,
'ocd_pm_reviewed_by' => $d->ocd_pm_reviewed_by,
'ocd_pm_reviewed_by_name' => $d->ocd_pm_reviewed_by
? (DB::table('staff_info')->where('fk_users', $d->ocd_pm_reviewed_by)->value('fullname')
?: DB::table('users')->where('id', $d->ocd_pm_reviewed_by)->value('name')
?: '')
: '',
'ocd_pm_reviewed_at' => $d->ocd_pm_reviewed_at ? $d->ocd_pm_reviewed_at->format('Y-m-d H:i:s') : null,
]), ]),
], ],
]); ]);
...@@ -186,15 +206,15 @@ public function viewOvertimeClaim(Request $request, int $id): JsonResponse ...@@ -186,15 +206,15 @@ public function viewOvertimeClaim(Request $request, int $id): JsonResponse
public function editOvertimeClaim(Request $request, int $id) public function editOvertimeClaim(Request $request, int $id)
{ {
$data = $this->repos->findOvertimeClaim($id); $data = $this->repos->findOvertimeClaim($id);
// Editable only for Draf (1) or Permohonan Semula (3) // Editable only for Draft (1) or queried statuses by PM/HOD/PD (6/8/10)
if (!in_array($data->ocm_status, [1, 3, 6])) { if (!in_array($data->ocm_status, [1, 6, 8, 10])) {
return redirect() return redirect()
->route('overtime::overtime.listovertime') ->route('overtime::overtime.listovertime')
->with('error', 'Permohonan yang telah dihantar tidak boleh dikemaskini.'); ->with('error', 'Permohonan yang telah dihantar tidak boleh dikemaskini.');
} }
$details = $this->repos->findOvertimeClaimDetails($id); $details = $this->repos->findOvertimeClaimDetails($id);
$projects = DB::table('lkp_project')->orderBy('p_project_description')->get(); $projects = DB::table('lkp_project')->orderBy('p_project_description')->get();
...@@ -226,7 +246,7 @@ public function editOvertimeClaim(Request $request, int $id) ...@@ -226,7 +246,7 @@ public function editOvertimeClaim(Request $request, int $id)
->get(); ->get();
return view('overtime::overtime.overtimeclaim.edit', compact('data', 'details', 'projects', 'statuses', 'latestQuery', 'queryHistory')); return view('overtime::overtime.overtimeclaim.edit', compact('data', 'details', 'projects', 'statuses', 'latestQuery', 'queryHistory'));
} }
// ADD DETAIL // ADD DETAIL
...@@ -235,7 +255,7 @@ public function editOvertimeClaim(Request $request, int $id) ...@@ -235,7 +255,7 @@ public function editOvertimeClaim(Request $request, int $id)
public function addOvertimeClaimDetail(Request $request, int $id): JsonResponse public function addOvertimeClaimDetail(Request $request, int $id): JsonResponse
{ {
$main = $this->repos->findOvertimeClaim($id); $main = $this->repos->findOvertimeClaim($id);
if (!in_array($main->ocm_status, [1, 3, 6])) { if (!in_array($main->ocm_status, [1, 6, 8, 10])) {
return response()->json([ return response()->json([
'success' => false, 'success' => false,
'message' => 'Permohonan yang telah dihantar tidak boleh dikemaskini.', 'message' => 'Permohonan yang telah dihantar tidak boleh dikemaskini.',
...@@ -300,7 +320,7 @@ public function removeOvertimeClaimDetail(Request $request, int $id): JsonRespon ...@@ -300,7 +320,7 @@ public function removeOvertimeClaimDetail(Request $request, int $id): JsonRespon
$detail = \Portal\Overtime\Model\OvertimeClaimDetail::findOrFail($id); $detail = \Portal\Overtime\Model\OvertimeClaimDetail::findOrFail($id);
$main = $this->repos->findOvertimeClaim($detail->fk_overtime_claim_main); $main = $this->repos->findOvertimeClaim($detail->fk_overtime_claim_main);
if (!in_array($main->ocm_status, [1, 3, 6])) { if (!in_array($main->ocm_status, [1, 6, 8, 10])) {
return response()->json([ return response()->json([
'success' => false, 'success' => false,
'message' => 'Permohonan yang telah dihantar tidak boleh dikemaskini.', 'message' => 'Permohonan yang telah dihantar tidak boleh dikemaskini.',
...@@ -324,7 +344,7 @@ public function removeOvertimeClaimDetail(Request $request, int $id): JsonRespon ...@@ -324,7 +344,7 @@ public function removeOvertimeClaimDetail(Request $request, int $id): JsonRespon
public function saveOvertimeClaimDetails(Request $request, int $id): JsonResponse public function saveOvertimeClaimDetails(Request $request, int $id): JsonResponse
{ {
$main = $this->repos->findOvertimeClaim($id); $main = $this->repos->findOvertimeClaim($id);
if (!in_array($main->ocm_status, [1, 3, 6])) { if (!in_array($main->ocm_status, [1, 6, 8, 10])) {
return response()->json([ return response()->json([
'success' => false, 'success' => false,
'message' => 'Permohonan yang telah dihantar tidak boleh dikemaskini.', 'message' => 'Permohonan yang telah dihantar tidak boleh dikemaskini.',
...@@ -424,23 +444,23 @@ private function withTransaction(callable $callback): JsonResponse ...@@ -424,23 +444,23 @@ private function withTransaction(callable $callback): JsonResponse
} }
} }
// =========================================================================
// AUDIT TRAIL
// =========================================================================
// AUDIT TRAIL public function getAuditTrailList(Request $request)
{
public function getAuditTrailList(Request $request)
{
$list = $this->repos->getAuditTrailList($request); $list = $this->repos->getAuditTrailList($request);
return view('overtime::overtime.audit_trail', compact('list')); return view('overtime::overtime.audit_trail', compact('list'));
} }
// ========================================================================= // =========================================================================
// BATAL // BATAL (cancel claim)
// ========================================================================= // =========================================================================
public function batalOvertimeClaim(Request $request, int $id): JsonResponse public function batalOvertimeClaim(Request $request, int $id): JsonResponse
{ {
return $this->withTransaction(function () use ($id) { return $this->withTransaction(function () use ($id) {
$this->repos->batalOvertimeClaim($id); $this->repos->batalOvertimeClaim($id);
...@@ -449,14 +469,14 @@ public function batalOvertimeClaim(Request $request, int $id): JsonResponse ...@@ -449,14 +469,14 @@ public function batalOvertimeClaim(Request $request, int $id): JsonResponse
'message' => 'Permohonan berjaya dibatalkan.', 'message' => 'Permohonan berjaya dibatalkan.',
]); ]);
}); });
} }
// ========================================================================= // =========================================================================
// SAVE KUERI RESPOND // SAVE KUERI RESPOND
// ========================================================================= // =========================================================================
public function saveKueriRespond(Request $request, int $id): JsonResponse public function saveKueriRespond(Request $request, int $id): JsonResponse
{ {
$request->validate([ $request->validate([
'respond' => 'required|string|max:2000', 'respond' => 'required|string|max:2000',
], [ ], [
...@@ -471,5 +491,6 @@ public function saveKueriRespond(Request $request, int $id): JsonResponse ...@@ -471,5 +491,6 @@ public function saveKueriRespond(Request $request, int $id): JsonResponse
'message' => 'Respond berjaya disimpan.', 'message' => 'Respond berjaya disimpan.',
]); ]);
}); });
} }
} }
...@@ -36,6 +36,14 @@ public function viewClaim(Request $request, int $id) ...@@ -36,6 +36,14 @@ public function viewClaim(Request $request, int $id)
$data = $this->repos->findClaimWithDetails($id); $data = $this->repos->findClaimWithDetails($id);
$statuses = $this->repos->getOtStatuses(); $statuses = $this->repos->getOtStatuses();
$selectionData = $this->repos->getRequestFormSelectionData($data['main']); $selectionData = $this->repos->getRequestFormSelectionData($data['main']);
$NO_PROJECT_ID = 110;
$pmPendingCount = $data['details']
->where('pm_owned', true)
->where('ocd_pm_reviewed', 0)
->filter(function ($d) use ($NO_PROJECT_ID) {
return empty($d->fk_lkp_project) || $d->fk_lkp_project != $NO_PROJECT_ID;
})
->count();
return view('overtime::overtime.overtimeclaim.projectmanager.view', [ return view('overtime::overtime.overtimeclaim.projectmanager.view', [
'main' => $data['main'], 'main' => $data['main'],
...@@ -47,6 +55,7 @@ public function viewClaim(Request $request, int $id) ...@@ -47,6 +55,7 @@ public function viewClaim(Request $request, int $id)
'forms' => $selectionData['forms'], 'forms' => $selectionData['forms'],
'months' => $selectionData['months'], 'months' => $selectionData['months'],
'staffNames' => $selectionData['staffNames'], 'staffNames' => $selectionData['staffNames'],
'pmPendingCount' => $pmPendingCount,
]); ]);
} }
......
...@@ -246,7 +246,7 @@ public function viewOvertimeRequest(Request $request, int $id): JsonResponse ...@@ -246,7 +246,7 @@ public function viewOvertimeRequest(Request $request, int $id): JsonResponse
->where('ref_id', $main->orm_status) ->where('ref_id', $main->orm_status)
->first(); ->first();
$main->orm_status_label = $status->description ?? ($main->orm_status == 0 ? 'Draf' : '-'); $main->orm_status_label = $status->description ?? ($main->orm_status == 1 ? 'Draf' : '-');
$main->orm_requested_by_name = $main->orm_requested_by_id $main->orm_requested_by_name = $main->orm_requested_by_id
? (DB::table('project_team')->where('id', $main->orm_requested_by_id)->value('pt_team') ? (DB::table('project_team')->where('id', $main->orm_requested_by_id)->value('pt_team')
?: ($this->repos->resolveApplicantName($main->orm_name) ?: '-')) ?: ($this->repos->resolveApplicantName($main->orm_name) ?: '-'))
......
...@@ -92,38 +92,38 @@ protected function menu() ...@@ -92,38 +92,38 @@ protected function menu()
$menu->add(__('List of Request Forms (PM)'), url('/overtime/request/list')) $menu->add(__('List of Request Forms (PM)'), url('/overtime/request/list'))
->data('icon', 'file alternate') ->data('icon', 'file alternate')
->active('overtime/request/*') ->active('overtime/request/*')
->data('permission', Permission::REQUEST_OT); ->data('permission', Permission::REQUEST_OT_PM);
$menu->add(__('Support Request Forms (HOD)'), url('/overtime/request/hod/list')) $menu->add(__('Support Request Forms (HOD)'), url('/overtime/request/hod/list'))
->data('icon', 'check circle') ->data('icon', 'check circle')
->active('overtime/request/hod/*') ->active('overtime/request/hod/*')
->data('permission', Permission::APPLICATION_OT_HOD); ->data('permission', Permission::REQUEST_OT_HOD);
$menu->add(__('Approve Request Forms (PD)'), url('/overtime/request/pd/list')) $menu->add(__('Approve Request Forms (PD)'), url('/overtime/request/pd/list'))
->data('icon', 'check circle outline') ->data('icon', 'check circle outline')
->active('overtime/request/pd/*') ->active('overtime/request/pd/*')
->data('permission', Permission::APPLICATION_OT_PD); ->data('permission', Permission::REQUEST_OT_PD);
$menu = $menus->add(__('OT CLAIM'))->data('icon', 'align justify'); $menu = $menus->add(__('OT CLAIM'))->data('icon', 'align justify');
$menu->add(__('List of Claim Forms '), url('/overtime/list')) $menu->add(__('List of Claim Forms '), url('/overtime/list'))
->data('icon', 'file alternate') ->data('icon', 'file alternate')
->active('overtime/*') ->active('overtime/*')
->data('permission', Permission::APPLICATION_OT); ->data('permission', Permission::CLAIM_OT);
$menu->add(__('Review Claim Forms (PM)'), url('/overtime/projectmanager/list')) $menu->add(__('Review Claim Forms (PM)'), url('/overtime/projectmanager/list'))
->data('icon', 'check') ->data('icon', 'check')
->active('overtime/*') ->active('overtime/*')
->data('permission', Permission::APPLICATION_OT_REVIEW); ->data('permission', Permission::CLAIM_OT_PM);
$menu->add(__('Support Claim Forms (HOD)'), url('/overtime/claim/hod/list')) $menu->add(__('Support Claim Forms (HOD)'), url('/overtime/claim/hod/list'))
->data('icon', 'check circle') ->data('icon', 'check circle')
->active('overtime/*') ->active('overtime/*')
->data('permission', Permission::APPLICATION_OT_SUPPORT); ->data('permission', Permission::CLAIM_OT_HOD);
$menu->add(__('Approve Claim Forms (PD)'), url('/overtime/claim/pd/list')) $menu->add(__('Approve Claim Forms (PD)'), url('/overtime/claim/pd/list'))
->data('icon', 'check circle outline') ->data('icon', 'check circle outline')
->active('overtime/*') ->active('overtime/*')
->data('permission', Permission::APPLICATION_OT_APPROVE); ->data('permission', Permission::CLAIM_OT_PD);
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment