Merge pull request 'Updated role from Design to Laser and hasWorkFlowId updated against work flow status' (#503) from ranjith-dev into master
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled

Reviewed-on: #503
This commit was merged in pull request #503.
This commit is contained in:
2026-04-06 02:40:06 +00:00
3 changed files with 240 additions and 52 deletions

View File

@@ -5,16 +5,17 @@ namespace App\Filament\Resources;
use App\Filament\Exports\RequestCharacteristicExporter; use App\Filament\Exports\RequestCharacteristicExporter;
use App\Filament\Resources\RequestCharacteristicResource\Pages; use App\Filament\Resources\RequestCharacteristicResource\Pages;
use App\Models\CharacteristicApproverMaster; use App\Models\CharacteristicApproverMaster;
use App\Models\InvoiceValidation;
use App\Models\Item; use App\Models\Item;
use App\Models\Machine; use App\Models\Machine;
use App\Models\Plant; use App\Models\Plant;
use App\Models\RequestCharacteristic; use App\Models\RequestCharacteristic;
use App\Models\StickerMaster;
use Closure; use Closure;
use Filament\Facades\Filament; use Filament\Facades\Filament;
use Filament\Forms; use Filament\Forms;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Section; use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Form; use Filament\Forms\Form;
use Filament\Forms\Get; use Filament\Forms\Get;
use Filament\Forms\Set; use Filament\Forms\Set;
@@ -22,15 +23,12 @@ use Filament\Resources\Resource;
use Filament\Tables; use Filament\Tables;
use Filament\Tables\Actions\ExportAction; use Filament\Tables\Actions\ExportAction;
use Filament\Tables\Actions\ImportAction; use Filament\Tables\Actions\ImportAction;
use Filament\Tables\Filters\Filter;
use Filament\Tables\Table; use Filament\Tables\Table;
use Illuminate\Database\Eloquent\Builder; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\SoftDeletingScope; use Illuminate\Database\Eloquent\SoftDeletingScope;
use Illuminate\Support\Facades\Schema; use Illuminate\Support\Facades\Schema;
use Illuminate\Validation\Rule; use Illuminate\Validation\Rule;
use Filament\Forms\Components\DateTimePicker;
use Filament\Forms\Components\Select;
use Filament\Tables\Filters\Filter;
use Filament\Forms\Components\TextInput;
class RequestCharacteristicResource extends Resource class RequestCharacteristicResource extends Resource
{ {
@@ -176,6 +174,9 @@ class RequestCharacteristicResource extends Resource
Forms\Components\TextInput::make('aufnr') Forms\Components\TextInput::make('aufnr')
->label('Job Number') ->label('Job Number')
->reactive() ->reactive()
->numeric()
->minlength(7)
->maxlength(10)
->required(function (callable $get) { ->required(function (callable $get) {
$item = $get('item_id'); $item = $get('item_id');
if ($item) { if ($item) {
@@ -876,7 +877,8 @@ class RequestCharacteristicResource extends Resource
Tables\Columns\TextColumn::make('work_flow_id') Tables\Columns\TextColumn::make('work_flow_id')
->label('Work Flow ID') ->label('Work Flow ID')
->alignCenter() ->alignCenter()
->searchable(), // isIndividual: true ->searchable()
->sortable(), // isIndividual: true
Tables\Columns\TextColumn::make('plant.name') Tables\Columns\TextColumn::make('plant.name')
->label('Plant Name') ->label('Plant Name')
->alignCenter() ->alignCenter()
@@ -1109,10 +1111,10 @@ class RequestCharacteristicResource extends Resource
->afterStateUpdated(function ($state, callable $set, callable $get): void { ->afterStateUpdated(function ($state, callable $set, callable $get): void {
$set('machine', null); $set('machine', null);
$set('item_id', null); $set('item_id', null);
$set('aufnr', null); // $set('aufnr', null);
}), }),
Select::make('machine') Select::make('machine')
->label('Machine') ->label('Search by Work Center')
->nullable() ->nullable()
->searchable() ->searchable()
->reactive() ->reactive()
@@ -1130,8 +1132,8 @@ class RequestCharacteristicResource extends Resource
})->pluck('work_center', 'id'); })->pluck('work_center', 'id');
}) })
->afterStateUpdated(function ($state, callable $set, callable $get): void { ->afterStateUpdated(function ($state, callable $set, callable $get): void {
$set('item_id', null); // $set('item_id', null);
$set('aufnr', null); // $set('aufnr', null);
}), }),
Select::make('item_id') Select::make('item_id')
->label('Search by Item Code') ->label('Search by Item Code')
@@ -1152,25 +1154,28 @@ class RequestCharacteristicResource extends Resource
})->pluck('code', 'id'); })->pluck('code', 'id');
}) })
->afterStateUpdated(function ($state, callable $set, callable $get): void { ->afterStateUpdated(function ($state, callable $set, callable $get): void {
$set('aufnr', null); // $set('aufnr', null);
}), }),
TextInput::make('aufnr') TextInput::make('aufnr')
->label('Job Number') ->label('Job Number')
->placeholder(placeholder: 'Enter Job Number'), ->placeholder('Enter Job Number')
->numeric()
->minlength(7)
->maxlength(10),
DateTimePicker::make(name: 'created_from') DateTimePicker::make(name: 'created_from')
->label('Created From') ->label('Created From')
->placeholder(placeholder: 'Select From DateTime') ->placeholder('Select From DateTime')
->reactive() ->reactive()
->native(false), ->native(false),
DateTimePicker::make('created_to') DateTimePicker::make('created_to')
->label('Created To') ->label('Created To')
->placeholder(placeholder: 'Select To DateTime') ->placeholder('Select To DateTime')
->reactive() ->reactive()
->native(false), ->native(false),
]) ])
->query(function ($query, array $data) { ->query(function ($query, array $data) {
// Hide all records initially if no filters are applied // Hide all records initially if no filters are applied
if ((empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['created_from']) && empty($data['created_to']) && empty($data['operator_id']) && empty($data['scanned_status']) && empty($data['sticker_master_id']))) { if (empty($data['Plant']) && empty($data['machine']) && empty($data['item_id']) && empty($data['aufnr']) && empty($data['created_from']) && empty($data['created_to'])) {
return $query->whereRaw('1 = 0'); return $query->whereRaw('1 = 0');
} }
@@ -1218,7 +1223,7 @@ class RequestCharacteristicResource extends Resource
} }
if (! empty($data['machine'])) { if (! empty($data['machine'])) {
$indicators[] = 'Machine: '.Machine::where('id', $data['machine'])->value('work_center'); $indicators[] = 'Work Center: '.Machine::where('id', $data['machine'])->value('work_center');
} }
if (! empty($data['item_id'])) { if (! empty($data['item_id'])) {

View File

@@ -2,6 +2,7 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\ClassCharacteristic;
use App\Models\RequestCharacteristic; use App\Models\RequestCharacteristic;
use Carbon\Carbon; use Carbon\Carbon;
use Illuminate\Http\Request; use Illuminate\Http\Request;
@@ -52,14 +53,13 @@ class CharacteristicApprovalController extends Controller
foreach ($levels as $lvl => $column) { foreach ($levels as $lvl => $column) {
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) { if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
return view('approval.already-processed', [ return view('approval.already-processed', [
'status' => $record->$column, 'status' => $record->$column,
'message' => 'Your request has already been processed by another approver', 'message' => 'Your request has already been processed by another approver',
]); ]);
} }
} }
foreach ($levels as $lvl => $column) foreach ($levels as $lvl => $column) {
{
if ($record->$column == 'Hold') { if ($record->$column == 'Hold') {
if ($lvl == $level) { if ($lvl == $level) {
@@ -127,13 +127,12 @@ class CharacteristicApprovalController extends Controller
foreach ($levels as $lvl => $column) { foreach ($levels as $lvl => $column) {
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) { if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
return view('approval.already-processed', [ return view('approval.already-processed', [
'status' => $record->$column, 'status' => $record->$column,
'message' => 'Your request has already been processed by another approver', 'message' => 'Your request has already been processed by another approver',
]); ]);
} }
} }
// foreach ($levels as $lvl => $column) { // foreach ($levels as $lvl => $column) {
// if ($record->$column == 'Hold') { // if ($record->$column == 'Hold') {
@@ -150,7 +149,6 @@ class CharacteristicApprovalController extends Controller
// } // }
// } // }
$allowedMailStatusByLevel = [ $allowedMailStatusByLevel = [
1 => 'Sent', 1 => 'Sent',
2 => 'Sent-Mail2', 2 => 'Sent-Mail2',
@@ -161,12 +159,11 @@ class CharacteristicApprovalController extends Controller
if ($record->mail_status != $expectedMailStatus) { if ($record->mail_status != $expectedMailStatus) {
return view('approval.approve-level', [ return view('approval.approve-level', [
'status'=> $currentStatus, 'status' => $currentStatus,
'message' => 'Your approval time limit has expired.', 'message' => 'Your approval time limit has expired.',
]); ]);
} }
return view('approval.reject-form', compact('id', 'level')); return view('approval.reject-form', compact('id', 'level'));
} }
@@ -203,13 +200,12 @@ class CharacteristicApprovalController extends Controller
foreach ($levels as $lvl => $column) { foreach ($levels as $lvl => $column) {
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) { if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
return view('approval.already-processed', [ return view('approval.already-processed', [
'status' => $record->$column, 'status' => $record->$column,
'message' => 'Your request has already been processed by another approver', 'message' => 'Your request has already been processed by another approver',
]); ]);
} }
} }
// foreach ($levels as $lvl => $column) { // foreach ($levels as $lvl => $column) {
// if ($record->$column == 'Hold') { // if ($record->$column == 'Hold') {
@@ -236,7 +232,7 @@ class CharacteristicApprovalController extends Controller
if ($record->mail_status != $expectedMailStatus) { if ($record->mail_status != $expectedMailStatus) {
return view('approval.approve-level', [ return view('approval.approve-level', [
'status'=> $currentStatus, 'status' => $currentStatus,
'message' => 'Your approval time limit has expired.', 'message' => 'Your approval time limit has expired.',
]); ]);
} }
@@ -328,7 +324,7 @@ class CharacteristicApprovalController extends Controller
foreach ($levels as $lvl => $column) { foreach ($levels as $lvl => $column) {
if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) { if ($lvl != $level && in_array($record->$column, ['Approved', 'Rejected'])) {
return view('approval.already-processed', [ return view('approval.already-processed', [
'status' => $record->$column, 'status' => $record->$column,
'message' => 'your request has already been processed by another approver', 'message' => 'your request has already been processed by another approver',
]); ]);
} }
@@ -345,7 +341,7 @@ class CharacteristicApprovalController extends Controller
if ($record->mail_status != $expectedMailStatus) { if ($record->mail_status != $expectedMailStatus) {
if ($returnView) { if ($returnView) {
return view('approval.approve-level', [ return view('approval.approve-level', [
'status' => $currentStatus, 'status' => $currentStatus,
'message' => 'Your approval time limit has expired.', 'message' => 'Your approval time limit has expired.',
]); ]);
} }
@@ -384,6 +380,12 @@ class CharacteristicApprovalController extends Controller
$r->update($updateData); $r->update($updateData);
} }
// UPDATE class characteristics
// ClassCharacteristic::where('plant_id', $record->plant_id)
// ->where('machine_id', $record->machine_id)
// ->where('aufnr', $record->aufnr)
// ->update(['has_work_flow_id' => $record->work_flow_id]);
if ($returnView) { if ($returnView) {
return match ($status) { return match ($status) {
'Approved' => view('approval.success'), 'Approved' => view('approval.success'),

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!',