diff --git a/app/Http/Controllers/TestingPanelController.php b/app/Http/Controllers/TestingPanelController.php
index 882795d9a..c9ee6919f 100644
--- a/app/Http/Controllers/TestingPanelController.php
+++ b/app/Http/Controllers/TestingPanelController.php
@@ -9,6 +9,8 @@ use App\Models\TestingPanelReading;
use DB;
use Filament\Notifications\Notification;
use Illuminate\Http\Request;
+use Mpdf\Mpdf;
+use SimpleSoftwareIO\QrCode\Facades\QrCode;
class TestingPanelController extends Controller
{
@@ -20,6 +22,236 @@ class TestingPanelController extends Controller
//
}
+ public function downloadQrPdf($palletNo)
+ {
+ $qrBinary = QrCode::format('png')->size(70)->generate($palletNo); // Adjust size as needed
+ $qrBase64 = base64_encode($qrBinary);
+
+ $html = '
+
+
+
+
+
+
+
+
+
+ |
+
+ ' . htmlspecialchars($palletNo) . '
+ |
+
+
+
+
+ ';
+
+ $mpdf = new Mpdf([
+ 'mode' => 'utf-8',
+ 'format' => [60, 14],
+ 'margin_left' => 0,
+ 'margin_right' => 0,
+ 'margin_top' => 0,
+ 'margin_bottom' => 0,
+ ]);
+
+ $mpdf->WriteHTML($html);
+ $mpdf->Output(); // This directly flushes output as PDF
+ exit;
+
+ // $mpdf->WriteHTML($html);
+
+ // return response($mpdf->Output('qr-code.pdf', 'S'), 200, [
+ // 'Content-Type' => 'application/pdf',
+ // //'Content-Disposition' => 'attachment; filename="qr-code.pdf"'
+ // 'Content-Disposition' => 'inline; filename="qr-code.pdf"'
+ // ]);
+ }
+
+
+// public function downloadQrPdf($palletNo)
+// {
+// // 1. Generate TSPL commands
+// $labelContent = <<&1";
+
+// exec($command, $output, $return_var);
+// $outputStr = implode("\n", $output);
+
+// unlink($tmpFile);
+
+// if ($return_var === 0) {
+// return "Label sent to printer!";
+// }
+// else
+// {
+// return "Failed to send label to printer. Error: " . $outputStr;
+// }
+// }
+
+ // public function downloadQrPdf($palletNo)
+ // {
+ // // TSPL commands for test label
+ // $labelContent = <<where('code', $item['item_code']);
})->where('plant_id', $plantId)->first();
@@ -336,8 +568,6 @@ class TestingPanelController extends Controller
// return response("" . implode("\n", $messages), 200)
// ->header('Content-Type', 'text/plain');
-
-
}
catch (\Exception $e)
{
@@ -345,7 +575,7 @@ class TestingPanelController extends Controller
return response()->json([
'status_code' => 'ERROR',
- 'status_description' => 'Internal Sever Error : '.$e->getCode()
+ 'status_description' => 'Internal Sever Error : '.$e?->getCode()
], 500);
}
}
diff --git a/routes/web.php b/routes/web.php
index 854c0d6b9..8c113f787 100644
--- a/routes/web.php
+++ b/routes/web.php
@@ -1,6 +1,11 @@
send(
// new test()
// );
+
// });
+
+// Route::get('/qr-pdf-test', function () {
+// $qrBinary = QrCode::format('png')->size(200)->generate('Test');
+// $qrBase64 = base64_encode($qrBinary);
+
+// $html = '
';
+// $mpdf = new Mpdf(['mode' => 'utf-8']);
+// $mpdf->WriteHTML($html);
+// return response($mpdf->Output('qr-code.pdf', 'S'), 200, [
+// 'Content-Type' => 'application/pdf',
+// 'Content-Disposition' => 'attachment; filename="qr-code.pdf"'
+// ]);
+// });
+
+//Route::get('/download-qr-pdf', [TestingPanelController::class, 'downloadQrPdf'])->name('download-qr-pdf');
+
+Route::get('/download-qr-pdf/{palletNo}', [TestingPanelController::class, 'downloadQrPdf'])->name('download-qr-pdf');