Updated role from Design to Laser and hasWorkFlowId updated against work flow status
Some checks failed
Gemini PR Review / Gemini PR Review (pull_request) Waiting to run
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Waiting to run
Laravel Larastan / larastan (pull_request) Waiting to run
Laravel Pint / pint (pull_request) Waiting to run
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled

This commit is contained in:
dhanabalan
2026-04-04 21:40:41 +05:30
parent 9b8f178bed
commit ff6713e1d6

View File

@@ -14,7 +14,6 @@ use App\Models\RequestCharacteristic;
use App\Models\StickerMaster; use App\Models\StickerMaster;
use App\Models\User; use App\Models\User;
use App\Models\WorkGroupMaster; use App\Models\WorkGroupMaster;
use Filament\Facades\Filament;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log; use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Response; use Illuminate\Support\Facades\Response;
@@ -326,7 +325,7 @@ class CharacteristicsController extends Controller
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => "User name '{$userName}' not found for the plant code '{$plantCode}'!", 'status_description' => "User name '{$userName}' not found for the plant code '{$plantCode}'!",
], 403); ], 403);
} elseif (! $user->hasRole(['Super Admin', 'Design Manager', 'Design Supervisor', 'Design Employee'])) { } elseif (! $user->hasRole(['Super Admin', 'Laser Manager', 'Laser Supervisor', 'Laser Employee'])) {
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => 'User does not have rights!', 'status_description' => 'User does not have rights!',
@@ -638,7 +637,7 @@ class CharacteristicsController extends Controller
if (! $userPlant && ! $user->hasRole('Super Admin')) { if (! $userPlant && ! $user->hasRole('Super Admin')) {
$missingUsersPlant[$field] = $markUser; $missingUsersPlant[$field] = $markUser;
} elseif (! $user->hasRole(['Super Admin', 'Design Manager', 'Design Supervisor', 'Design Employee'])) { } elseif (! $user->hasRole(['Super Admin', 'Laser Manager', 'Laser Supervisor', 'Laser Employee'])) {
$missingUsersRight[$field] = $markUser; $missingUsersRight[$field] = $markUser;
} }
} }
@@ -1171,7 +1170,7 @@ class CharacteristicsController extends Controller
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => "User '{$userName}' not found for Plant '{$plantCode}'!", 'status_description' => "User '{$userName}' not found for Plant '{$plantCode}'!",
], 403); ], 403);
} elseif (! $user->hasRole(['Super Admin', 'Design Manager', 'Design Supervisor', 'Design Employee'])) { } elseif (! $user->hasRole(['Super Admin', 'Laser Manager', 'Laser Supervisor', 'Laser Employee'])) {
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => 'User does not have rights!', 'status_description' => 'User does not have rights!',
@@ -1345,7 +1344,7 @@ class CharacteristicsController extends Controller
if (! $userPlant && ! $user->hasRole('Super Admin')) { if (! $userPlant && ! $user->hasRole('Super Admin')) {
$missingUsersPlant[$field] = $markUser; $missingUsersPlant[$field] = $markUser;
} elseif (! $user->hasRole(['Super Admin', 'Design Manager', 'Design Supervisor', 'Design Employee'])) { } elseif (! $user->hasRole(['Super Admin', 'Laser Manager', 'Laser Supervisor', 'Laser Employee'])) {
$missingUsersRight[$field] = $markUser; $missingUsersRight[$field] = $markUser;
} }
} }
@@ -1640,7 +1639,7 @@ class CharacteristicsController extends Controller
if (! $userPlant && ! $user->hasRole('Super Admin')) { if (! $userPlant && ! $user->hasRole('Super Admin')) {
$missingUsersPlant[$field] = $markUser; $missingUsersPlant[$field] = $markUser;
} elseif (! $user->hasRole(['Super Admin', 'Design Manager', 'Design Supervisor', 'Design Employee'])) { } elseif (! $user->hasRole(['Super Admin', 'Laser Manager', 'Laser Supervisor', 'Laser Employee'])) {
$missingUsersRight[$field] = $markUser; $missingUsersRight[$field] = $markUser;
} }
} }
@@ -1929,7 +1928,7 @@ class CharacteristicsController extends Controller
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => 'User name not found for the plant!', 'status_description' => 'User name not found for the plant!',
], 403); ], 403);
} elseif (! $user->hasRole(['Super Admin', 'Design Manager', 'Design Supervisor', 'Design Employee'])) { } elseif (! $user->hasRole(['Super Admin', 'Laser Manager', 'Laser Supervisor', 'Laser Employee'])) {
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => 'User does not have rights!', 'status_description' => 'User does not have rights!',
@@ -2435,7 +2434,7 @@ class CharacteristicsController extends Controller
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => 'User Name not found for the plant!', 'status_description' => 'User Name not found for the plant!',
], 403); ], 403);
} elseif (! $user->hasRole(['Super Admin', 'Design Manager', 'Design Supervisor', 'Design Employee'])) { } elseif (! $user->hasRole(['Super Admin', 'Laser Manager', 'Laser Supervisor', 'Laser Employee'])) {
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => 'User does not have rights!', 'status_description' => 'User does not have rights!',
@@ -3446,7 +3445,7 @@ class CharacteristicsController extends Controller
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => "User name '{$userName}' not found for the plant code '{$plantCode}'!", 'status_description' => "User name '{$userName}' not found for the plant code '{$plantCode}'!",
], 403); ], 403);
} elseif (! $user->hasRole(['Super Admin', 'Design Manager', 'Design Supervisor', 'Design Employee'])) { } elseif (! $user->hasRole(['Super Admin', 'Laser Manager', 'Laser Supervisor', 'Laser Employee'])) {
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => 'User does not have rights!', 'status_description' => 'User does not have rights!',
@@ -3593,7 +3592,137 @@ class CharacteristicsController extends Controller
], 404); ], 404);
} }
// ..Both Has Pending and Completed Logic // ..completed Logic and pending logic for characteristics and quality
$classRow = ClassCharacteristic::where('plant_id', $plantId)
->where('machine_id', $MachineId)
->where('aufnr', $jobNo)
->first();
if ($classRow) {
if (! empty($characteristics)) {
$requestChars = RequestCharacteristic::where('plant_id', $plantId)
->where('machine_id', $MachineId)
->where('aufnr', $jobNo)
->get();
if (! $requestChars->isEmpty()) {
$hasPending = false;
$allApproved = true;
foreach ($requestChars as $row) {
$isApproved = (
$row->approver_status1 == 'Approved' || $row->approver_status1 == 'Rejected' ||
$row->approver_status2 == 'Approved' || $row->approver_status2 == 'Rejected' ||
$row->approver_status3 == 'Approved' || $row->approver_status2 == 'Rejected'
);
$isPending = ! empty($row->mail_status) &&
(
empty($row->approver_status1) || $row->approver_status1 == 'Hold' ||
empty($row->approver_status2) || $row->approver_status2 == 'Hold' ||
empty($row->approver_status3) || $row->approver_status3 == 'Hold'
);
if ($isPending) {
$hasPending = true;
$allApproved = false;
break;
}
if (! $isApproved) {
$allApproved = false;
}
}
$current = $classRow->has_work_flow_id ?? '0';
if ($hasPending) {
if ($current == '0') {
$newValue = '1';
} elseif ($current == '1') {
$newValue = '1';
} elseif ($current == '2') {
$newValue = '3';
} elseif ($current == '3') {
$newValue = '3';
}
} elseif ($allApproved) {
if ($current == '0') {
$newValue = '0';
} elseif ($current == '1') {
$newValue = '0';
} elseif ($current == '2') {
$newValue = '2';
} elseif ($current == '3') {
$newValue = '2';
}
}
ClassCharacteristic::where('plant_id', $plantId)
->where('machine_id', $MachineId)
->where('aufnr', $jobNo)
->update([
'has_work_flow_id' => $newValue,
'updated_at' => now(),
'updated_by' => $userName,
]);
}
} elseif (empty($characteristics)) {
$requestChar = RequestCharacteristic::where('plant_id', $plantId)
->where('machine_id', $MachineId)
->where('aufnr', $jobNo)
->latest()
->first();
if ($requestChar) {
$current = $requestChar->has_work_flow_id ?? '0';
$isApproved =
$requestChar->approver_status1 == 'Approved' ||
$requestChar->approver_status2 == 'Approved' ||
$requestChar->approver_status3 == 'Approved';
if ($isApproved) {
if ($current == '0') {
$newValue = '0';
} elseif ($current == '1') {
$newValue = '1';
} elseif ($current == '2') {
$newValue = '0';
} elseif ($current == '3') {
$newValue = '1';
}
} elseif (
$requestChar->approver_status1 == 'Hold' || $requestChar->approver_status1 == 'Rejected' || $requestChar->approver_status1 == null || $requestChar->approver_status1 == '' ||
$requestChar->approver_status2 == 'Hold' || $requestChar->approver_status2 == 'Rejected' || $requestChar->approver_status2 == null || $requestChar->approver_status2 == '' ||
$requestChar->approver_status3 == 'Hold' || $requestChar->approver_status3 == 'Rejected' || $requestChar->approver_status3 == null || $requestChar->approver_status3 == ''
) {
if ($current == '0') {
$newValue = '2';
} elseif ($current == '1') {
$newValue = '3';
} elseif ($current == '2') {
$newValue = '2';
} elseif ($current == '3') {
$newValue = '3';
}
}
}
ClassCharacteristic::where('plant_id', $plantId)
->where('machine_id', $MachineId)
->where('aufnr', $jobNo)
->update([
'has_work_flow_id' => $newValue,
'updated_at' => now(),
'updated_by' => $userName,
]);
}
}
foreach ($characteristics as $char) { foreach ($characteristics as $char) {
$charNameUpp = strtoupper($char['characteristic_name']) ?? null; $charNameUpp = strtoupper($char['characteristic_name']) ?? null;
@@ -3780,11 +3909,15 @@ class CharacteristicsController extends Controller
$classChar = ClassCharacteristic::where('plant_id', $plantId)->where('machine_id', $MachineId)->where('aufnr', $jobNo)->first(); $classChar = ClassCharacteristic::where('plant_id', $plantId)->where('machine_id', $MachineId)->where('aufnr', $jobNo)->first();
$hasWorkFlowId = $classChar->has_work_flow_id ?? null; $hasWorkFlowId = $classChar?->has_work_flow_id;
$updatedWorkId = null; $updatedWorkId = null;
if ($hasWorkFlowId != '' || $hasWorkFlowId != null) { if ($classChar) {
if ($hasWorkFlowId == '' || $hasWorkFlowId == null) {
$hasWorkFlowId = '0';
}
if ($hasWorkFlowId == '0') { if ($hasWorkFlowId == '0') {
if ($requestType == 'Characteristic') { if ($requestType == 'Characteristic') {
@@ -3811,16 +3944,16 @@ class CharacteristicsController extends Controller
$updatedWorkId = '3'; $updatedWorkId = '3';
} }
} }
}
ClassCharacteristic::where('plant_id', $plantId) ClassCharacteristic::where('plant_id', $plantId)
->where('machine_id', $MachineId) ->where('machine_id', $MachineId)
->where('aufnr', $jobNo) ->where('aufnr', $jobNo)
->update([ ->update([
'has_work_flow_id' => $updatedWorkId, 'has_work_flow_id' => $updatedWorkId,
'updated_at' => now(), 'updated_at' => now(),
'updated_by' => Filament::auth()->user->name(), 'updated_by' => $userName,
]); ]);
}
return response()->json([ return response()->json([
'work_flow_ids' => [$workFlowIds], 'work_flow_ids' => [$workFlowIds],
@@ -3947,6 +4080,54 @@ class CharacteristicsController extends Controller
], 404); ], 404);
} }
$classChar = ClassCharacteristic::where('plant_id', $plantId)->where('machine_id', $MachineId)->where('aufnr', $jobNo)->latest()->first();
$hasWorkFlowId = $classChar?->has_work_flow_id ?? null;
$updatedWorkId = null;
if ($classChar) {
if ($hasWorkFlowId == '' || $hasWorkFlowId == null) {
$hasWorkFlowId = '0';
}
if ($hasWorkFlowId == '0') {
if ($requestType == 'Characteristic') {
$updatedWorkId = '1';
} elseif ($requestType == 'Quality') {
$updatedWorkId = '2';
}
} elseif ($hasWorkFlowId == '1') {
if ($requestType == 'Characteristic') {
$updatedWorkId = '1';
} elseif ($requestType == 'Quality') {
$updatedWorkId = '3';
}
} elseif ($hasWorkFlowId == '2') {
if ($requestType == 'Characteristic') {
$updatedWorkId = '3';
} elseif ($requestType == 'Quality') {
$updatedWorkId = '2';
}
} elseif ($hasWorkFlowId == '3') {
if ($requestType == 'Characteristic') {
$updatedWorkId = '3';
} elseif ($requestType == 'Quality') {
$updatedWorkId = '3';
}
}
ClassCharacteristic::where('plant_id', $plantId)
->where('machine_id', $MachineId)
->where('aufnr', $jobNo)
->update([
'has_work_flow_id' => $updatedWorkId,
'updated_at' => now(),
'updated_by' => $userName,
]);
}
return response()->json([ return response()->json([
'work_flow_ids' => [$approvalId], 'work_flow_ids' => [$approvalId],
], 200); ], 200);
@@ -4100,7 +4281,7 @@ class CharacteristicsController extends Controller
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => "User name '{$userName}' not found for the plant code '{$plantCode}'!", 'status_description' => "User name '{$userName}' not found for the plant code '{$plantCode}'!",
], 404); ], 404);
} elseif (! $user->hasRole(['Super Admin', 'Design Manager', 'Design Supervisor', 'Design Employee'])) { } elseif (! $user->hasRole(['Super Admin', 'Laser Manager', 'Laser Supervisor', 'Laser Employee'])) {
return response()->json([ return response()->json([
'status_code' => 'ERROR', 'status_code' => 'ERROR',
'status_description' => 'User does not have rights!', 'status_description' => 'User does not have rights!',