Removed generate pallet number functionality

This commit is contained in:
dhanabalan
2025-07-02 17:06:29 +05:30
parent 4f87a0d318
commit 4d4414ffa7

View File

@@ -24,278 +24,6 @@ class TestingPanelController extends Controller
{
//
}
public function downloadQrPdf($palletNo)
{
// Generate QR code as PNG binary (adjust size as needed)
$qrCode = new QrCode($palletNo);
$output = new Output\Png();
$qrBinary = $output->output($qrCode, 100); // 100px size
$qrBase64 = base64_encode($qrBinary);
// Prepare HTML with embedded QR code
$html = '
<html>
<head>
<style>
body { margin: 0; padding: 0; width: 60mm; height: 14mm; font-size: 10pt; font-family: DejaVu Sans, sans-serif; }
.sticker-table { width: 60mm; height: 14mm; border-collapse: collapse; }
.qr-cell { width: 14mm; text-align: left; vertical-align: middle; padding-left: 5mm; padding-top: 2mm; }
.text-cell { text-align: left; vertical-align: middle; font-size: 12pt; padding-left: 7mm; padding-top: 2mm; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: bold; }
img.qr { width: 10mm; height: 10mm; display: block; }
</style>
</head>
<body>
<table class="sticker-table">
<tr>
<td class="qr-cell">
<img class="qr" src="data:image/png;base64,' . $qrBase64 . '" alt="QR" />
</td>
<td class="text-cell">
' . htmlspecialchars($palletNo) . '
</td>
</tr>
</table>
</body>
</html>
';
$mpdf = new Mpdf([
'mode' => 'utf-8',
'format' => [60, 14],
'margin_left' => 0,
'margin_right' => 0,
'margin_top' => 0,
'margin_bottom' => 0,
'tempDir' => '/var/www/storage/mpdf-tmp',
]);
$mpdf->WriteHTML($html);
$mpdf->Output('qr-label.pdf', 'I');
exit;
}
// public function downloadQrPdf($palletNo)
// {
// $qrBinary = QrCode::format('png')->size(70)->generate($palletNo); // Adjust size as needed
// $qrBase64 = base64_encode($qrBinary);
// $html = '
// <html>
// <head>
// <style>
// body {
// margin: 0;
// padding: 0;
// width: 60mm;
// height: 14mm;
// font-size: 10pt;
// font-family: DejaVu Sans, sans-serif;
// }
// .sticker-table {
// width: 60mm;
// height: 14mm;
// border-collapse: collapse;
// }
// .qr-cell {
// width: 14mm;
// text-align: left;
// vertical-align: middle;
// padding-left: 5mm;
// padding-top: 2mm;
// }
// .text-cell {
// text-align: left;
// vertical-align: middle;
// font-size: 12pt;
// padding-left: 7mm;
// padding-top: 2mm;
// white-space: nowrap;
// overflow: hidden;
// text-overflow: ellipsis;
// font-weight: bold;
// }
// img.qr {
// width: 10mm;
// height: 10mm;
// display: block;
// }
// </style>
// </head>
// <body>
// <table class="sticker-table">
// <tr>
// <td class="qr-cell">
// <img class="qr" src="data:image/png;base64,' . $qrBase64 . '" alt="QR" />
// </td>
// <td class="text-cell">
// ' . htmlspecialchars($palletNo) . '
// </td>
// </tr>
// </table>
// </body>
// </html>
// ';
// $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;
// }
// public function downloadQrPdf($palletNo)
// {
// // 1. Generate TSPL commands
// $labelContent = <<<EOT
// SIZE 60 mm,14 mm
// GAP 2 mm,0 mm
// DIRECTION 1
// CLS
// QRCODE 20,20,L,5,A,0,"$palletNo"
// TEXT 160,30,"0",0,12,12,"$palletNo"
// PRINT 1
// EOT;
// $filePath = '/tmp/labelprint.txt';
// file_put_contents($filePath, $labelContent);
// //$printerShare = '//LASER-STANDBY/TSC TTP';
// $tempFile = '/tmp/labelprint.txt';
// $printerIp = '172.31.31.250'; // Printer server IP
// $username = 'admin'; // SMB username
// $password = 'admin'; // SMB password (can be empty, but better with password)
// $printerShare = "//$printerIp/TSC_TTP_244 Pro"; // SMB share path
// $tempFile = $filePath;
// $command = "smbclient \"$printerShare\" -U \"$username%$password\" -c \"put $tempFile labelprint.txt\"";
// exec($command, $output, $status);
// // $tempFile = '/tmp/labelprint.txt';
// // $printerName = 'TSC_TTP_244_Pro'; // Replace with your actual CUPS printer queue name
// // $command = "lp -d $printerName -o raw $tempFile";
// // exec($command, $output, $status);
// if ($status === 0) {
// return response("Print sent to printer.");
// } else {
// return response("Print failed. Output: " . implode("\n", $output));
// }
// }
// public function downloadQrPdf($palletNo)
// {
// $tspl = <<<EOT
// SIZE 40 mm,30 mm
// GAP 2 mm,0 mm
// CLS
// TEXT 50,50,"0",0,1,1,"Hello, TSC!"
// PRINT 1
// EOT;
// // Save TSPL to a temporary file
// $tmpFile = tempnam(sys_get_temp_dir(), 'tsc_') . '.tspl';
// file_put_contents($tmpFile, $tspl);
// // Print using CUPS (replace with your actual printer name)
// $printerName = "TSC TTP-244 Pro"; // Example, use the exact name from CUPS
// $command = "lp -d \"$printerName\" \"$tmpFile\" 2>&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 = <<<EOT
// SIZE 60 mm,14 mm
// GAP 3 mm,0 mm
// OFFSET 0 mm
// DIRECTION 1
// CLS
// QRCODE 35,21,L,4,A,0,"$palletNo"
// TEXT 180,50,"4",0,1,1,"$palletNo"
// PRINT 1
// EOT;
// //A : error correction level:
// $escapedContent = escapeshellarg($labelContent);
// $printerName = '4';
// $command = "echo $escapedContent | lp -d \"$printerName\" -o raw";
// exec($command, $output, $status);
// if ($status === 0) {
// return response("Test print sent to printer successfully.");
// } else {
// return response("Print failed. Output: " . implode("\n", $output));
// }
// }
// public function downloadQrPdf($palletNo)
// {
// // TSPL label content (no indentation in heredoc)
// $labelContent = <<<EOT
// SIZE 60 mm,14 mm
// GAP 2 mm,0 mm
// DIRECTION 1
// CLS
// TEXT 10,10,"1",0,6,6,"Test"
// PRINT 1
// EOT;
// $printerName = '4';
// //TEXT x, y, font, rotation, x_multiplication, y_multiplication, "text"
// // $command = "echo \"$labelContent\" | lp -d \"$printerName\" -o raw";
// // exec($command, $output, $status);
// // Save label content to a temp file
// $tempFile = sys_get_temp_dir() . '/label.txt';
// file_put_contents($tempFile, $labelContent);
// // Send the temp file to the printer
// $command = "cat " . escapeshellarg($tempFile) . " | lp -d " . escapeshellarg($printerName) . " -o raw";
// exec($command, $output, $status);
// // Delete the temp file
// unlink($tempFile);
// if ($status === 0) {
// return response("TSPL command sent to printer.");
// } else {
// return response("TSPL print failed. Output: " . implode("\n", $output));
// }
// }
/**
* Store a newly created resource in storage.