1. Added import and export actions with labels and warning colors for the following resources:
- LineResource - LineStopResource - LocatorResource - MachineResource - MfmMeterResource - MfmParameterResource - MotorTestingMasterResource - PlantResource - ProductionLineStopResource - ProductionPlanResource - ProductionQuantityResource - QualityValidationResource - SerialValidationResource - ShiftResource - StickerMasterResource - UserResource - WorkGroupMasterResource 2. Updated camera capture functionality to ensure overlay canvas size syncs with video size.
This commit is contained in:
@@ -25,6 +25,13 @@ use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Illuminate\Validation\Rule;
|
||||
use thiagoalessio\TesseractOCR\TesseractOCR;
|
||||
use setasign\Fpdi\Fpdi;
|
||||
use setasign\Fpdi\PdfReader;
|
||||
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
||||
|
||||
|
||||
|
||||
|
||||
class GrMasterResource extends Resource
|
||||
{
|
||||
@@ -210,6 +217,176 @@ class GrMasterResource extends Resource
|
||||
return;
|
||||
}
|
||||
}),
|
||||
// Action::make('uploadNow1')
|
||||
// ->label('Upload OCR')
|
||||
// ->action(function ($get, callable $set) {
|
||||
// $uploadedFiles = $get('photo');
|
||||
|
||||
// if (is_array($uploadedFiles) && count($uploadedFiles) > 0)
|
||||
// {
|
||||
// $uploaded = reset($uploadedFiles);
|
||||
|
||||
// if ($uploaded instanceof TemporaryUploadedFile) {
|
||||
// $grNumber = $get('gr_number');
|
||||
// $safeName = preg_replace('/[^A-Za-z0-9_\-]/', '_', $grNumber);
|
||||
// // $originalName = $uploaded->getClientOriginalName();
|
||||
// // $path = 'uploads/GRNumber/' . $originalName;
|
||||
// $finalFileName = $safeName . '.jpg';
|
||||
// $finalPath = 'uploads/OCR/' . $finalFileName;
|
||||
|
||||
// // if (Storage::disk('local')->exists($finalPath)) {
|
||||
// // Notification::make()
|
||||
// // ->title('Duplicate File')
|
||||
// // ->body("The file '{$finalFileName}' already exists in uploads/GRNumber.")
|
||||
// // ->warning()
|
||||
// // ->send();
|
||||
// // return; // Stop here
|
||||
// // }
|
||||
|
||||
// $storedPath = $uploaded->storeAs(
|
||||
// 'uploads/OCR',
|
||||
// $finalFileName,
|
||||
// 'local'
|
||||
// );
|
||||
|
||||
// // $storedPath = $uploaded->storeAs('uploads/OCR', $finalFileName, 'local');
|
||||
// // $fullPath = storage_path('app/' . $storedPath);
|
||||
// $storedPath = $uploaded->storeAs('uploads/OCR', $finalFileName, 'local');
|
||||
|
||||
// $fullPath = storage_path('app/private/' . $storedPath);
|
||||
|
||||
// $text = (new TesseractOCR($fullPath))->lang('eng')->run();
|
||||
|
||||
// $rawText = $text;
|
||||
|
||||
// preg_match_all('/\d+/', $rawText, $matches);
|
||||
|
||||
// $serialNumbers = $matches[0];
|
||||
|
||||
// $serialNumbers = array_slice($serialNumbers, 0, 4);
|
||||
|
||||
// //dd($serialNumbers);
|
||||
|
||||
// $processOrder = $get('gr_number');
|
||||
|
||||
// $itemId = $get('item_id');
|
||||
|
||||
// $plant = $get('plant_id');
|
||||
|
||||
// $item = Item::find($itemId);
|
||||
|
||||
// $plant = Plant::find($plant);
|
||||
|
||||
// $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/multi.pdf');
|
||||
|
||||
// $outputPath = storage_path('app/private/uploads/StickerTemplateOcr/multi_filled.pdf');
|
||||
|
||||
// $storedPath = $uploaded->storeAs(
|
||||
// 'uploads/GRNumber',
|
||||
// $finalFileName,
|
||||
// 'local'
|
||||
// );
|
||||
|
||||
// $pdf = new Fpdi('P', 'mm', [90, 90]);
|
||||
|
||||
// $templateId = $pdf->setSourceFile($templatePath);
|
||||
// $templatePage = $pdf->importPage(1);
|
||||
|
||||
// $pdf->AddPage();
|
||||
// $pdf->useTemplate($templatePage, 0, 0, 90, 90);
|
||||
|
||||
// $pdf->SetFont('Helvetica', '', 10);
|
||||
// $pdf->SetTextColor(0, 0, 0);
|
||||
|
||||
// $slots = [
|
||||
// ['x' => 5.7, 'y' => 41.9, 'w' => 46.5, 'h' => 3.5], // 1st serial
|
||||
// ['x' => 50, 'y' => 41.5, 'w' => 46.6, 'h' => 3.9], // 2nd serial
|
||||
// ['x' => 5.7, 'y' => 60, 'w' => 46.5, 'h' => 3.5], // 3rd serial
|
||||
// ['x' => 50, 'y' => 60, 'w' => 46.6, 'h' => 3.5], // 4rd serial
|
||||
// ];
|
||||
|
||||
// $qrSlots = [
|
||||
// ['x' => 17.3, 'y' => 29.2, 'size' => 11.4],
|
||||
// ['x' => 61.5, 'y' => 29, 'size' => 11.5],
|
||||
// ['x' => 17.7, 'y' => 46.7, 'size' => 11.4],
|
||||
// ['x' => 61.7, 'y' => 46.7, 'size' => 11.4],
|
||||
// ];
|
||||
|
||||
// // foreach ($serialNumbers as $i => $serial) {
|
||||
// // if (isset($slots[$i])) {
|
||||
// // $pdf->SetFillColor(255, 255, 255); // erase old serial
|
||||
// // $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F');
|
||||
// // $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']);
|
||||
// // // $pdf->Write(0, $serial);
|
||||
// // $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L');
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // $pdf->Output('F', $outputPath);
|
||||
// // return response()->download($outputPath);
|
||||
|
||||
// //
|
||||
|
||||
// // foreach ($serialNumbers as $i => $serial) {
|
||||
// // if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue;
|
||||
|
||||
// // //Generate QR code PNG temporarily
|
||||
// // $qrPath = storage_path("app/private/uploads/QR/qr_$serial.png");
|
||||
// // QrCode::format('png')->size(100)->generate($serial, $qrPath);
|
||||
|
||||
// // //Place QR code above serial
|
||||
// // $pdf->Image($qrPath, $qrSlots[$i]['x'], $qrSlots[$i]['y'], $qrSlots[$i]['size'], $qrSlots[$i]['size']);
|
||||
|
||||
// // //Erase old serial
|
||||
// // $pdf->SetFillColor(255, 255, 255);
|
||||
// // $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F');
|
||||
|
||||
// // //Write new serial number
|
||||
// // $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']);
|
||||
// // $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L');
|
||||
// // }
|
||||
|
||||
// foreach ($serialNumbers as $i => $serial) {
|
||||
// if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue;
|
||||
|
||||
// // Erase old QR completely (slightly larger)
|
||||
// $pdf->SetFillColor(255, 255, 255);
|
||||
// $pdf->Rect($qrSlots[$i]['x']-1, $qrSlots[$i]['y']-1, $qrSlots[$i]['size']+2, $qrSlots[$i]['size']+2, 'F');
|
||||
|
||||
// // Generate new QR code
|
||||
// $qrPath = storage_path("app/private/uploads/QR/qr_$serial.png");
|
||||
// $qrDir = storage_path('app/private/uploads/QR');
|
||||
// if (!file_exists($qrDir)) mkdir($qrDir, 0777, true);
|
||||
// QrCode::format('png')->size(100)->generate($serial, $qrPath);
|
||||
|
||||
// // Place QR code
|
||||
// $pdf->Image($qrPath, $qrSlots[$i]['x'], $qrSlots[$i]['y'], $qrSlots[$i]['size'], $qrSlots[$i]['size']);
|
||||
|
||||
// // Erase old serial
|
||||
// $pdf->SetFillColor(255, 255, 255);
|
||||
// $pdf->Rect($slots[$i]['x'], $slots[$i]['y'], $slots[$i]['w'], $slots[$i]['h'], 'F');
|
||||
|
||||
// // Write new serial
|
||||
// $pdf->SetXY($slots[$i]['x'], $slots[$i]['y']);
|
||||
// $pdf->Cell($slots[$i]['w'], $slots[$i]['h'], $serial, 0, 0, 'L');
|
||||
// }
|
||||
|
||||
// // Save the final PDF
|
||||
// $pdf->Output('F', $outputPath);
|
||||
|
||||
// // Download
|
||||
// return response()->download($outputPath);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Notification::make()
|
||||
// ->title('No file selected to upload')
|
||||
// ->warning()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
// }),
|
||||
|
||||
Action::make('downloadAttachment')
|
||||
->label('Download PDF')
|
||||
@@ -326,11 +503,15 @@ class GrMasterResource extends Resource
|
||||
])
|
||||
->headerActions([
|
||||
ImportAction::make()
|
||||
->label('Import GR Masters')
|
||||
->color('warning')
|
||||
->importer(GrMasterImporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view import gr master');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export GR Masters')
|
||||
->color('warning')
|
||||
->exporter(GrMasterExporter::class)
|
||||
->visible(function() {
|
||||
return Filament::auth()->user()->can('view export gr master');
|
||||
|
||||
Reference in New Issue
Block a user