Added laser stop approval mail in characteristics approval controller
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
This commit is contained in:
@@ -424,6 +424,93 @@ class CharacteristicApprovalController extends Controller
|
|||||||
return response()->json(['status' => true, 'message' => 'Status updated successfully']);
|
return response()->json(['status' => true, 'message' => 'Status updated successfully']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//..Laser Stop
|
||||||
|
|
||||||
|
public function laserApproveForm(Request $request)
|
||||||
|
{
|
||||||
|
$id = $request->query('id');
|
||||||
|
$level = (int) $request->query('level');
|
||||||
|
|
||||||
|
$record = RequestCharacteristic::findOrFail($id);
|
||||||
|
|
||||||
|
[$statusColumn, $approvedAtColumn, $remarkColumn] = match ($level) {
|
||||||
|
1 => ['approver_status1', 'approved1_at', 'approver_remark1'],
|
||||||
|
2 => ['approver_status2', 'approved2_at', 'approver_remark2'],
|
||||||
|
3 => ['approver_status3', 'approved3_at', 'approver_remark3'],
|
||||||
|
default => abort(403, 'Invalid approver level'),
|
||||||
|
};
|
||||||
|
|
||||||
|
$levels = [
|
||||||
|
1 => 'approver_status1',
|
||||||
|
2 => 'approver_status2',
|
||||||
|
3 => 'approver_status3',
|
||||||
|
];
|
||||||
|
|
||||||
|
$currentStatusColumn = $levels[$level];
|
||||||
|
|
||||||
|
$currentStatus = $record->$statusColumn;
|
||||||
|
|
||||||
|
if (in_array($currentStatus, ['Approved', 'Rejected'])) {
|
||||||
|
return view('approval.already-processed', [
|
||||||
|
'status' => $currentStatus,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach ($levels as $lvl => $column) {
|
||||||
|
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
|
||||||
|
return view('approval.already-processed', [
|
||||||
|
'status' => $record->$column,
|
||||||
|
'message' => 'Your request has already been processed by another approver',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// foreach ($levels as $lvl => $column) {
|
||||||
|
// if ($record->$column == 'Hold') {
|
||||||
|
|
||||||
|
// if ($lvl == $level) {
|
||||||
|
// return view('approval.reject-form', compact('id', 'level'));
|
||||||
|
// }
|
||||||
|
// else
|
||||||
|
// {
|
||||||
|
// return view('approval.already-processed', [
|
||||||
|
// 'status' => 'Hold',
|
||||||
|
// 'message' => 'On Hold',
|
||||||
|
// ]);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
$allowedMailStatusByLevel = [
|
||||||
|
1 => 'Sent',
|
||||||
|
2 => 'Sent-Mail2',
|
||||||
|
3 => 'Sent-Mail3',
|
||||||
|
];
|
||||||
|
|
||||||
|
$expectedMailStatus = $allowedMailStatusByLevel[$level] ?? null;
|
||||||
|
|
||||||
|
if ($record->mail_status != $expectedMailStatus) {
|
||||||
|
return view('approval.approve-level', [
|
||||||
|
'status' => $currentStatus,
|
||||||
|
'message' => 'Your approval time limit has expired.',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return view('approval.approve-form', compact('id', 'level'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public function laserApproveSave(Request $request)
|
||||||
|
{
|
||||||
|
$request->validate([
|
||||||
|
'id' => 'required|integer',
|
||||||
|
'level' => 'required|integer',
|
||||||
|
'remark' => 'nullable|string',
|
||||||
|
]);
|
||||||
|
|
||||||
|
return $this->updateStatus($request, 'Approved', false);
|
||||||
|
}
|
||||||
|
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
//
|
//
|
||||||
|
|||||||
Reference in New Issue
Block a user