Updated alignments and added orderby query while load plant
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Has been cancelled
This commit is contained in:
@@ -5,33 +5,28 @@ namespace App\Filament\Resources;
|
||||
use App\Filament\Exports\GrMasterExporter;
|
||||
use App\Filament\Imports\GrMasterImporter;
|
||||
use App\Filament\Resources\GrMasterResource\Pages;
|
||||
use App\Filament\Resources\GrMasterResource\RelationManagers;
|
||||
use App\Models\GrMaster;
|
||||
use App\Models\Item;
|
||||
use App\Models\Plant;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Forms;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Table;
|
||||
use Illuminate\Database\Eloquent\Builder;
|
||||
use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Forms\Components\Actions\Action;
|
||||
use Storage;
|
||||
use Smalot\PdfParser\Parser;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use Filament\Tables\Actions\ImportAction;
|
||||
use Filament\Tables\Actions\ExportAction;
|
||||
use Illuminate\Validation\Rule;
|
||||
use thiagoalessio\TesseractOCR\TesseractOCR;
|
||||
use Livewire\Features\SupportFileUploads\TemporaryUploadedFile;
|
||||
use setasign\Fpdi\Fpdi;
|
||||
use setasign\Fpdi\PdfReader;
|
||||
use SimpleSoftwareIO\QrCode\Facades\QrCode;
|
||||
|
||||
|
||||
|
||||
use Smalot\PdfParser\Parser;
|
||||
use Storage;
|
||||
use thiagoalessio\TesseractOCR\TesseractOCR;
|
||||
|
||||
class GrMasterResource extends Resource
|
||||
{
|
||||
@@ -39,6 +34,8 @@ class GrMasterResource extends Resource
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-rectangle-stack';
|
||||
|
||||
protected static ?string $navigationGroup = 'Process Order';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
{
|
||||
return $form
|
||||
@@ -49,12 +46,13 @@ class GrMasterResource extends Resource
|
||||
->relationship('plant', 'name')
|
||||
->options(function (callable $get) {
|
||||
$userHas = Filament::auth()->user()->plant_id;
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::pluck('name', 'id')->toArray();
|
||||
|
||||
return ($userHas && strlen($userHas) > 0) ? Plant::where('id', $userHas)->pluck('name', 'id')->toArray() : Plant::orderBy('code')->pluck('name', 'id')->toArray();
|
||||
})
|
||||
->required(),
|
||||
Forms\Components\Select::make('item_id')
|
||||
->label('Item Code')
|
||||
//->relationship('item', 'id')
|
||||
// ->relationship('item', 'id')
|
||||
->reactive()
|
||||
->searchable()
|
||||
->options(function (callable $get) {
|
||||
@@ -62,6 +60,7 @@ class GrMasterResource extends Resource
|
||||
if (empty($plantId)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return Item::where('plant_id', $plantId)->pluck('code', 'id');
|
||||
})
|
||||
->required(),
|
||||
@@ -72,9 +71,9 @@ class GrMasterResource extends Resource
|
||||
Forms\Components\TextInput::make('serial_number')
|
||||
->label('Serial Number')
|
||||
->rule(function (callable $get) {
|
||||
return Rule::unique('gr_masters', 'serial_number')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id')); // Ignore current record during updates
|
||||
return Rule::unique('gr_masters', 'serial_number')
|
||||
->where('plant_id', $get('plant_id'))
|
||||
->ignore($get('id')); // Ignore current record during updates
|
||||
}),
|
||||
|
||||
Forms\Components\FileUpload::make('attachment')
|
||||
@@ -91,8 +90,7 @@ class GrMasterResource extends Resource
|
||||
->action(function ($get, callable $set) {
|
||||
$uploadedFiles = $get('attachment');
|
||||
|
||||
if (is_array($uploadedFiles) && count($uploadedFiles) > 0)
|
||||
{
|
||||
if (is_array($uploadedFiles) && count($uploadedFiles) > 0) {
|
||||
$uploaded = reset($uploadedFiles);
|
||||
|
||||
if ($uploaded instanceof TemporaryUploadedFile) {
|
||||
@@ -100,8 +98,8 @@ class GrMasterResource extends Resource
|
||||
$safeName = preg_replace('/[^A-Za-z0-9_\-]/', '_', $grNumber);
|
||||
// $originalName = $uploaded->getClientOriginalName();
|
||||
// $path = 'uploads/GRNumber/' . $originalName;
|
||||
$finalFileName = $safeName . '.pdf';
|
||||
$finalPath = 'uploads/GRNumber/' . $finalFileName;
|
||||
$finalFileName = $safeName.'.pdf';
|
||||
$finalPath = 'uploads/GRNumber/'.$finalFileName;
|
||||
|
||||
if (Storage::disk('local')->exists($finalPath)) {
|
||||
Notification::make()
|
||||
@@ -109,6 +107,7 @@ class GrMasterResource extends Resource
|
||||
->body("The file '{$finalFileName}' already exists in uploads/GRNumber.")
|
||||
->warning()
|
||||
->send();
|
||||
|
||||
return; // Stop here
|
||||
}
|
||||
|
||||
@@ -118,15 +117,14 @@ class GrMasterResource extends Resource
|
||||
'local'
|
||||
);
|
||||
|
||||
|
||||
// $fullPath = storage_path('app/' . $storedPath);
|
||||
$fullPath = storage_path('app/private/' . $storedPath);
|
||||
$parser = new Parser();
|
||||
//$pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath()));
|
||||
// $fullPath = storage_path('app/' . $storedPath);
|
||||
$fullPath = storage_path('app/private/'.$storedPath);
|
||||
$parser = new Parser;
|
||||
// $pdf = $parser->parseContent(file_get_contents($uploaded->getRealPath()));
|
||||
$pdf = $parser->parseFile($fullPath);
|
||||
$text = $pdf->getText();
|
||||
|
||||
//dd($text);
|
||||
// dd($text);
|
||||
|
||||
if (preg_match('/Item code\s*:\s*(\S+)/i', $text, $matches)) {
|
||||
$item1 = $matches[1];
|
||||
@@ -136,8 +134,7 @@ class GrMasterResource extends Resource
|
||||
// $item2 = $matches[1];
|
||||
// dd($item2);
|
||||
// }
|
||||
else
|
||||
{
|
||||
else {
|
||||
Notification::make()
|
||||
->title('Item Code Not Found')
|
||||
->body('Could not find Item code in uploaded PDF.')
|
||||
@@ -147,6 +144,7 @@ class GrMasterResource extends Resource
|
||||
if (Storage::disk('local')->exists($storedPath)) {
|
||||
Storage::disk('local')->delete($storedPath);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -160,21 +158,19 @@ class GrMasterResource extends Resource
|
||||
|
||||
$plant = Plant::find($plant);
|
||||
|
||||
if ($item)
|
||||
{
|
||||
if ($item) {
|
||||
$itemCode = $item->code;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$itemCode = null;
|
||||
Notification::make()
|
||||
->title('Item Not Found')
|
||||
->body("Item not found in uploaded pdf.")
|
||||
->body('Item not found in uploaded pdf.')
|
||||
->warning()
|
||||
->send();
|
||||
if (Storage::disk('local')->exists($storedPath)) {
|
||||
Storage::disk('local')->delete($storedPath);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -184,220 +180,219 @@ class GrMasterResource extends Resource
|
||||
'local'
|
||||
);
|
||||
|
||||
if($itemCode == $item1)
|
||||
{
|
||||
if ($itemCode == $item1) {
|
||||
Notification::make()
|
||||
->title('Success')
|
||||
->body("Gr Number '$processOrder' PDF uploaded successfully.")
|
||||
->success()
|
||||
->send();
|
||||
->title('Success')
|
||||
->body("Gr Number '$processOrder' PDF uploaded successfully.")
|
||||
->success()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Notification::make()
|
||||
->title('Item Code not matched')
|
||||
->body("Item Code: {$item->code} not matched with the uploaded pdf code $item1.")
|
||||
->danger()
|
||||
->send();
|
||||
->title('Item Code not matched')
|
||||
->body("Item Code: {$item->code} not matched with the uploaded pdf code $item1.")
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
if (Storage::disk('local')->exists($storedPath)) {
|
||||
Storage::disk('local')->delete($storedPath);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
Notification::make()
|
||||
->title('No file selected to upload')
|
||||
->warning()
|
||||
->send();
|
||||
return;
|
||||
|
||||
return;
|
||||
}
|
||||
}),
|
||||
// Action::make('uploadNow1')
|
||||
// ->label('Upload OCR')
|
||||
// ->action(function ($get, callable $set) {
|
||||
// $uploadedFiles = $get('photo');
|
||||
// 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 (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 ($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
|
||||
// // }
|
||||
// // 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'
|
||||
// );
|
||||
|
||||
// // $storedPath = $uploaded->storeAs('uploads/OCR', $finalFileName, 'local');
|
||||
// // $fullPath = storage_path('app/' . $storedPath);
|
||||
// $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);
|
||||
// $fullPath = storage_path('app/private/' . $storedPath);
|
||||
|
||||
// $text = (new TesseractOCR($fullPath))->lang('eng')->run();
|
||||
// $text = (new TesseractOCR($fullPath))->lang('eng')->run();
|
||||
|
||||
// $rawText = $text;
|
||||
// $rawText = $text;
|
||||
|
||||
// preg_match_all('/\d+/', $rawText, $matches);
|
||||
// preg_match_all('/\d+/', $rawText, $matches);
|
||||
|
||||
// $serialNumbers = $matches[0];
|
||||
// $serialNumbers = $matches[0];
|
||||
|
||||
// $serialNumbers = array_slice($serialNumbers, 0, 4);
|
||||
// $serialNumbers = array_slice($serialNumbers, 0, 4);
|
||||
|
||||
// //dd($serialNumbers);
|
||||
// //dd($serialNumbers);
|
||||
|
||||
// $processOrder = $get('gr_number');
|
||||
// $processOrder = $get('gr_number');
|
||||
|
||||
// $itemId = $get('item_id');
|
||||
// $itemId = $get('item_id');
|
||||
|
||||
// $plant = $get('plant_id');
|
||||
// $plant = $get('plant_id');
|
||||
|
||||
// $item = Item::find($itemId);
|
||||
// $item = Item::find($itemId);
|
||||
|
||||
// $plant = Plant::find($plant);
|
||||
// $plant = Plant::find($plant);
|
||||
|
||||
// $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/multi.pdf');
|
||||
// $templatePath = storage_path('app/private/uploads/StickerTemplateOcr/multi.pdf');
|
||||
|
||||
// $outputPath = storage_path('app/private/uploads/StickerTemplateOcr/multi_filled.pdf');
|
||||
// $outputPath = storage_path('app/private/uploads/StickerTemplateOcr/multi_filled.pdf');
|
||||
|
||||
// $storedPath = $uploaded->storeAs(
|
||||
// 'uploads/GRNumber',
|
||||
// $finalFileName,
|
||||
// 'local'
|
||||
// );
|
||||
// $storedPath = $uploaded->storeAs(
|
||||
// 'uploads/GRNumber',
|
||||
// $finalFileName,
|
||||
// 'local'
|
||||
// );
|
||||
|
||||
// $pdf = new Fpdi('P', 'mm', [90, 90]);
|
||||
// $pdf = new Fpdi('P', 'mm', [90, 90]);
|
||||
|
||||
// $templateId = $pdf->setSourceFile($templatePath);
|
||||
// $templatePage = $pdf->importPage(1);
|
||||
// $templateId = $pdf->setSourceFile($templatePath);
|
||||
// $templatePage = $pdf->importPage(1);
|
||||
|
||||
// $pdf->AddPage();
|
||||
// $pdf->useTemplate($templatePage, 0, 0, 90, 90);
|
||||
// $pdf->AddPage();
|
||||
// $pdf->useTemplate($templatePage, 0, 0, 90, 90);
|
||||
|
||||
// $pdf->SetFont('Helvetica', '', 10);
|
||||
// $pdf->SetTextColor(0, 0, 0);
|
||||
// $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
|
||||
// ];
|
||||
// $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],
|
||||
// ];
|
||||
// $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');
|
||||
// // }
|
||||
// // }
|
||||
// // 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);
|
||||
// // $pdf->Output('F', $outputPath);
|
||||
// // return response()->download($outputPath);
|
||||
|
||||
// //
|
||||
// //
|
||||
|
||||
// // foreach ($serialNumbers as $i => $serial) {
|
||||
// // if (!isset($slots[$i]) || !isset($qrSlots[$i])) continue;
|
||||
// // 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);
|
||||
// // //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']);
|
||||
// // //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');
|
||||
// // //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');
|
||||
// // }
|
||||
// // //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;
|
||||
// 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');
|
||||
// // 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);
|
||||
// // 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']);
|
||||
// // 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');
|
||||
// // 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');
|
||||
// }
|
||||
// // 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);
|
||||
// // 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;
|
||||
// }
|
||||
// }),
|
||||
// // Download
|
||||
// return response()->download($outputPath);
|
||||
// }
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// Notification::make()
|
||||
// ->title('No file selected to upload')
|
||||
// ->warning()
|
||||
// ->send();
|
||||
// return;
|
||||
// }
|
||||
// }),
|
||||
|
||||
Action::make('downloadAttachment')
|
||||
->label('Download PDF')
|
||||
->action(function ($get) {
|
||||
$equipmentNumber = $get('gr_number');
|
||||
|
||||
if (!$equipmentNumber) {
|
||||
if (! $equipmentNumber) {
|
||||
Notification::make()
|
||||
->title('No GR Number entered')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -411,17 +406,18 @@ class GrMasterResource extends Resource
|
||||
}
|
||||
}
|
||||
|
||||
if (!$fileToDownload) {
|
||||
if (! $fileToDownload) {
|
||||
Notification::make()
|
||||
->title('PDF not found for this process order')
|
||||
->danger()
|
||||
->send();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
return response()->download(Storage::disk('local')->path($fileToDownload));
|
||||
}),
|
||||
]),
|
||||
]),
|
||||
Forms\Components\Hidden::make('created_by')
|
||||
->label('Created By')
|
||||
->default(Filament::auth()->user()?->name),
|
||||
@@ -440,6 +436,7 @@ class GrMasterResource extends Resource
|
||||
$paginator = $livewire->getTableRecords();
|
||||
$perPage = method_exists($paginator, 'perPage') ? $paginator->perPage() : 10;
|
||||
$currentPage = method_exists($paginator, 'currentPage') ? $paginator->currentPage() : 1;
|
||||
|
||||
return ($currentPage - 1) * $perPage + $rowLoop->iteration;
|
||||
}),
|
||||
Tables\Columns\TextColumn::make('plant.name')
|
||||
@@ -506,14 +503,14 @@ class GrMasterResource extends Resource
|
||||
->label('Import GR Masters')
|
||||
->color('warning')
|
||||
->importer(GrMasterImporter::class)
|
||||
->visible(function() {
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view import gr master');
|
||||
}),
|
||||
ExportAction::make()
|
||||
->label('Export GR Masters')
|
||||
->color('warning')
|
||||
->exporter(GrMasterExporter::class)
|
||||
->visible(function() {
|
||||
->visible(function () {
|
||||
return Filament::auth()->user()->can('view export gr master');
|
||||
}),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user