Updated validation logic against created_by and updated_by columns on importer
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Gemini PR Review / Gemini PR Review (pull_request) Has been cancelled
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Has been cancelled
Laravel Larastan / larastan (pull_request) Has been cancelled
Laravel Pint / pint (pull_request) Has been cancelled

This commit is contained in:
dhanabalan
2026-02-20 21:04:41 +05:30
parent 95217ce722
commit cddc8a1b70

View File

@@ -146,6 +146,11 @@ class ProcessOrderImporter extends Importer
$reworkStatus = 0; $reworkStatus = 0;
} }
if ($createdBy == null || $createdBy == '') {
$createdBy = Filament::auth()->user()?->name;
$updatedBy = $createdBy;
}
if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) { if (Str::length($plantCod) < 4 || ! is_numeric($plantCod) || ! preg_match('/^[1-9]\d{3,}$/', $plantCod)) {
$warnMsg[] = 'Invalid plant code found'; $warnMsg[] = 'Invalid plant code found';
} else { } else {
@@ -204,10 +209,22 @@ class ProcessOrderImporter extends Importer
$lineId = null; $lineId = null;
} }
// $user = User::where('name', $this->data['created_by'])->first(); if ($createdBy != null && $createdBy != '') {
// if (! $user) { if ($plantId) {
// $warnMsg[] = 'User not found'; $user = User::where('name', $createdBy)->first();
// }
$userPlant = User::where('name', $createdBy)->where('plant_id', $plantId)->first();
if (! $user) {
$warnMsg[] = 'Created By user name not found!';
} elseif (! $userPlant && ! $user->hasRole('Super Admin')) {
$warnMsg[] = "Created By user '{$createdBy}' not found for Plant '{$plantCod}'!";
} elseif (! $user->hasRole(['Super Admin', 'Process Quality Manager', 'Process Manager', 'Process Supervisor', 'Process Employee'])) {
$warnMsg[] = 'Created By user does not have rights!';
}
}
$updatedBy = Filament::auth()->user()?->name;
}
if (! empty($warnMsg)) { if (! empty($warnMsg)) {
throw new RowImportFailedException(implode(', ', $warnMsg)); throw new RowImportFailedException(implode(', ', $warnMsg));