addres qoshish da api o'zgartirildi

This commit is contained in:
2026-04-23 16:09:50 +05:00
parent 5deccec8ba
commit ca5b6402ea
25 changed files with 30 additions and 14 deletions

View File

@@ -86,6 +86,14 @@ class ConclusionController extends Controller
$qrContent = route('qr.verify', ['type' => $cleanType, 'id' => $orderId]);
$qrImage = QrCode::format('png')->size(150)->generate($qrContent);
file_put_contents($qrPath, $qrImage);
chmod($qrPath, 0644);
}
// Convert PDF to 1.4 compatible format so FPDI can parse any PDF version
$gsTmp = tempnam(sys_get_temp_dir(), 'gs_') . '.pdf';
exec('gs -dBATCH -dNOPAUSE -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -sOutputFile=' . escapeshellarg($gsTmp) . ' ' . escapeshellarg($tmpPath) . ' 2>/dev/null', $gsOut, $gsCode);
if ($gsCode === 0 && file_exists($gsTmp) && filesize($gsTmp) > 0) {
$tmpPath = $gsTmp;
}
$pdf = new Fpdi();
@@ -98,17 +106,12 @@ class ConclusionController extends Controller
$pdf->AddPage($size2['orientation'], [$size2['width'], $size2['height']]);
$pdf->useTemplate($tpl);
if ($i === 1) {
// First page: top-right, 30mm
$sz = 30;
$qrX = $size2['width'] - $sz - 18;
$qrY = 18;
} else {
// Other pages: bottom-right, 22mm, very bottom
$sz = 22;
$qrX = $size2['width'] - $sz - 8;
$qrY = $size2['height'] - $sz - 2;
}
// All pages: bottom-right corner, white background
$sz = 22;
$qrX = $size2['width'] - $sz - 8;
$qrY = $size2['height'] - $sz - 2;
$pdf->SetFillColor(255, 255, 255);
$pdf->Rect($qrX - 1, $qrY - 1, $sz + 2, $sz + 2, 'F');
$pdf->Image($qrPath, $qrX, $qrY, $sz, $sz);
}
@@ -125,19 +128,27 @@ class ConclusionController extends Controller
$sizeCert = $pdf->getTemplateSize($tplCert);
$pdf->AddPage($sizeCert['orientation'], [$sizeCert['width'], $sizeCert['height']]);
$pdf->useTemplate($tplCert);
$pdf->Image($qrPath, $sizeCert['width'] - 22 - 8, $sizeCert['height'] - 22 - 2, 22, 22); // bottom-right
$cqX = $sizeCert['width'] - 22 - 8;
$cqY = $sizeCert['height'] - 22 - 2;
$pdf->SetFillColor(255, 255, 255);
$pdf->Rect($cqX - 1, $cqY - 1, 24, 24, 'F');
$pdf->Image($qrPath, $cqX, $cqY, 22, 22);
}
} elseif (in_array($extCert, ['jpg', 'jpeg', 'png'])) {
$pdf->AddPage('P', 'A4');
$pdf->Image($certPath, 0, 0, 210, 297);
$pdf->Image($qrPath, 210 - 22 - 8, 297 - 22 - 2, 22, 22); // bottom-right, inside frame
$pdf->SetFillColor(255, 255, 255);
$pdf->Rect(210 - 22 - 8 - 1, 297 - 22 - 2 - 1, 24, 24, 'F');
$pdf->Image($qrPath, 210 - 22 - 8, 297 - 22 - 2, 22, 22);
}
}
}
$pdf->Output('F', $outputPath);
} catch (\Exception $e) {
// If PDF manipulation fails, just copy the original
\Illuminate\Support\Facades\Log::error('ConclusionController PDF/QR failed: ' . $e->getMessage(), [
'order_id' => $orderId, 'type' => $orderType, 'file' => $e->getFile(), 'line' => $e->getLine(),
]);
copy($tmpPath, $outputPath);
}
} else {