Skip to content
Code-Schnipsel Gruppen Projekte
Commit c7261128 erstellt von Henning Leutz's avatar Henning Leutz :martial_arts_uniform:
Dateien durchsuchen

Merge branch 'dev' of dev.quiqqer.com:quiqqer/erp into dev

Übergeordnete 77e16bca 09091236
Keine zugehörigen Branchen gefunden
Keine zugehörigen Tags gefunden
Keine zugehörigen Merge Requests gefunden
......@@ -21,14 +21,55 @@
$templateProvider = Orthos::clear($Request->query->get('tplpr'));
$quiId = Orthos::clear($Request->query->get('oid'));
$streamFile = URL_OPT_DIR.'quiqqer/erp/bin/output/backend/printStream.php?';
$streamFile .= \http_build_query([
'id' => $entityId,
't' => $entityType,
'tpl' => $template,
'tplpr' => $templateProvider,
'oid' => $quiId
]);
$requestHash = \hash('sha256', \implode('', [$entityId, $entityType, $template, $templateProvider]));
$cacheName = 'quiqqer/erp/print/'.$requestHash;
try {
$HtmlPdfDocument = Output::getDocumentPdf(
$entityId,
$entityType,
null,
Output::getOutputTemplateProviderByPackage($templateProvider),
$template ?: null
);
$imageFiles = $HtmlPdfDocument->createImage(
true,
[
'-transparent-color',
'-background white',
'-alpha remove',
'-alpha off',
'-bordercolor white',
'-border 10'
]
);
if (!\is_array($imageFiles)) {
$imageFiles = [$imageFiles];
}
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
exit;
}
QUI::getSession()->set($cacheName, \json_encode($imageFiles));
$baseUrl = URL_OPT_DIR.'quiqqer/erp/bin/output/backend/printStream.php?';
$queryParams = [
'hash' => $cacheName,
'index' => 0
];
// Retrieve all print images
$printImageSources = [];
foreach ($imageFiles as $imageFile) {
$streamFile = $baseUrl.\http_build_query($queryParams);
$printImageSources[] = $streamFile;
$queryParams['index']++;
}
echo '
<html>
......@@ -42,23 +83,19 @@
@page {
margin: 0 !important;
}
.container {
padding: 2.5em;
width: calc(100% - 5em);
}
</style>
</head>
<body>
<div class="container">
<img
id="pdfDocument"
src="'.$streamFile.'"
style="max-width: 100%;"
/>
</div>
<script>
<body>';
foreach ($printImageSources as $imgContent) {
echo '<img
class="pdfDocument"
src="'.$imgContent.'"
style="width: 100%; width: 21cm; height: 29.7cm; padding: 1cm;"
/>';
}
echo '<script>
var i, len, parts;
var search = {};
......
......@@ -5,7 +5,6 @@
require_once dirname(__FILE__, 6).'/header.php';
use QUI\ERP\Output\Output;
use QUI\Utils\Security\Orthos;
$User = QUI::getUserBySession();
......@@ -14,38 +13,31 @@
exit;
}
$Request = QUI::getRequest();
$entityId = Orthos::clear($Request->query->get('id'));
$entityType = Orthos::clear($Request->query->get('t'));
$template = Orthos::clear($Request->query->get('tpl'));
$templateProvider = Orthos::clear($Request->query->get('tplpr'));
$quiId = Orthos::clear($Request->query->get('oid'));
try {
$HtmlPdfDocument = Output::getDocumentPdf(
$entityId,
$entityType,
null,
Output::getOutputTemplateProviderByPackage($templateProvider),
$template ?: null
);
$imageFile = $HtmlPdfDocument->createImage(
true,
[
'-flatten' // removes background
]
);
} catch (\Exception $Exception) {
QUI\System\Log::writeException($Exception);
$Request = QUI::getRequest();
$hash = Orthos::clear($Request->query->get('hash'));
$index = (int)$Request->query->get('index');
if (empty($hash)) {
exit;
}
$imageFiles = QUI::getSession()->get($hash);
if (empty($imageFiles)) {
exit;
}
$imageFiles = \json_decode($imageFiles, true);
if (empty($imageFiles[$index]) || !\file_exists($imageFiles[$index])) {
exit;
}
$image = $imageFiles[$index];
$Response = QUI::getGlobalResponse();
$Response->headers->set('Content-Type', 'image/jpg');
$Response->setContent(file_get_contents($imageFile));
$Response->setContent(\file_get_contents($image));
$Response->send();
if (\file_exists($imageFile)) {
\unlink($imageFile);
}
\unlink($image);
0% Lade oder .
You are about to add 0 people to the discussion. Proceed with caution.
Bearbeitung dieser Nachricht zuerst beenden!
Bitte registrieren oder zum Kommentieren