diff --git a/app/Filament/Resources/OcrValidationResource.php b/app/Filament/Resources/OcrValidationResource.php index eeff931..3c4bdaa 100644 --- a/app/Filament/Resources/OcrValidationResource.php +++ b/app/Filament/Resources/OcrValidationResource.php @@ -146,21 +146,22 @@ class OcrValidationResource extends Resource // $fullPath = storage_path('app/' . $storedPath); $fullPath = storage_path('app/private/'.$storedPath); $parser = new Parser; - // $pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath())); + $pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath())); $pdf = $parser->parseFile($fullPath); $text = $pdf->getText(); - // dd($text); - - // dd($text); $item1 = null; $item2 = null; - if (preg_match('/Item code\s*:\s*(\S+)/i', $text, $matches)) { - $item1 = $matches[1]; - } elseif (preg_match('/E CODE\s*:\s*(\S+)/i', $text, $matches)) { - $item2 = $matches[1]; - } + // if (preg_match('/Item code\s*:\s*(\S+)/i', $text, $matches)) { + // $item1 = $matches[1]; + // } + // // elseif (preg_match('/E CODE\s*:\s*(\S+)/i', $text, $matches)) { + // else if (preg_match('/(?:Item\s*code|E[-\s]*CODE)\s*:\s*(\S+)/i', $text, $matches)) { + // $item2 = $matches[1]; + // } + + // dd($item2); $processOrder = $get('gr_number'); @@ -194,36 +195,45 @@ class OcrValidationResource extends Resource 'local' ); - if ($itemCode == $item1) { - Notification::make() + Notification::make() ->title('Success') ->body("Gr Number '$processOrder' PDF uploaded successfully.") ->success() ->send(); return; - } - if ($itemCode == $item2) { - Notification::make() - ->title('Success') - ->body("Gr Number '$processOrder' PDF uploaded successfully.") - ->success() - ->send(); - return; - } else { - Notification::make() - ->title('Item Code not matched') - ->body("Item Code: {$item->code} not matched with the uploaded pdf code $item1.") - ->danger() - ->send(); + // if ($itemCode == $item1) { + // Notification::make() + // ->title('Success') + // ->body("Gr Number '$processOrder' PDF uploaded successfully.") + // ->success() + // ->send(); - if (Storage::disk('local')->exists($storedPath)) { - Storage::disk('local')->delete($storedPath); - } + // return; + // } + // if ($itemCode == $item2) { + // Notification::make() + // ->title('Success') + // ->body("Gr Number '$processOrder' PDF uploaded successfully.") + // ->success() + // ->send(); - return; - } + // return; + // } + // else { + // Notification::make() + // ->title('Item Code not matched') + // ->body("Item Code: {$item->code} not matched with the uploaded pdf code $item2.") + // ->danger() + // ->send(); + + // if (Storage::disk('local')->exists($storedPath)) { + // Storage::disk('local')->delete($storedPath); + // } + + // return; + // } } } else { Notification::make()