Merge branch 'ConstructionConsent/fix-no-pdf' into 'master'

fixed showing pdfs to download and not allowing in future

See merge request fronk/thetool!1696
This commit is contained in:
Luca Haid
2025-09-01 12:08:08 +00:00
2 changed files with 9 additions and 5 deletions

View File

@@ -216,7 +216,7 @@
<div class="card">
<h5 class="card-header">Oder Plan hochladen</h5>
<div class="card-body">
<input type="file" class="form-control" name="consent_plan_image" id="consent_plan_image" />
<input type="file" class="form-control" name="consent_plan_image" id="consent_plan_image" accept="image/png, image/jpeg, image/jpg" />
</div>
</div>

View File

@@ -212,10 +212,14 @@ $pagination_entity_name = "Adressen";
</tr><tr>
<th>Plan/Skizze</th>
<td>
<?php if($item->file && $item->file->file && $item->file->file->fileExists()): ?>
<!--img src="<?=self::getUrl("File", "Download", ["id" => $item->file->file_id])?>" style="max-width: 480px;"/-->
<img src="<?=$item->file->file->asDataUrl()?>" style="max-width: 480px;" />
<?php endif; ?>
<?php if($item->file && $item->file->file && $item->file->file->fileExists()):
$dataUrl = $item->file->file->asDataUrl();
if (str_contains($dataUrl, 'application/pdf')) {
echo '<a href="' . $dataUrl . '" download="your-file-name.pdf" class="btn btn-primary" aria-label="Download PDF"><i class="fas fa-download"></i> Download PDF</a>';
} else {
echo '<img src="' . $dataUrl . '" style="max-width: 480px;" alt="File preview"/>';
}
endif; ?>
</td>
</tr><tr>
<th></th>