added Files JSON import
This commit is contained in:
@@ -41,6 +41,23 @@ $stmtParts = $conn->prepare($queryPartsAndResults);
|
||||
$stmtParts->bind_param("i", $idreports);
|
||||
$stmtParts->execute();
|
||||
$partsAndResults = $stmtParts->get_result();
|
||||
|
||||
// Query per ottenere i file associati al report
|
||||
$queryFiles = "
|
||||
SELECT original_filename, stored_filename, file_comment, filepath
|
||||
FROM report_files
|
||||
WHERE uuid = ?
|
||||
AND (file_comment = 'report' OR file_comment = 'main_product_image')";
|
||||
$stmtFiles = $conn->prepare($queryFiles);
|
||||
$stmtFiles->bind_param("s", $reportDetails['importcode']);
|
||||
$stmtFiles->execute();
|
||||
$filesResult = $stmtFiles->get_result();
|
||||
|
||||
$files = [];
|
||||
while ($fileRow = $filesResult->fetch_assoc()) {
|
||||
$files[$fileRow['file_comment']] = $fileRow;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
@@ -176,12 +193,128 @@ $partsAndResults = $stmtParts->get_result();
|
||||
<td><strong>Color:</strong></td>
|
||||
<td><?php echo $reportDetails['products_color']; ?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>PDF Report:</strong></td>
|
||||
<td>
|
||||
<?php if (isset($files['report'])): ?>
|
||||
<a href="<?php echo htmlspecialchars('../report_files/' . $files['report']['stored_filename']); ?>" target="_blank">
|
||||
<i class="bx bxs-file-pdf" style="font-size: 24px; color: #d9534f;"></i> View Report
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<span>No PDF available</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><strong>Product Image:</strong></td>
|
||||
<td>
|
||||
<?php if (isset($files['main_product_image'])): ?>
|
||||
<a href="<?php echo htmlspecialchars('../report_files/' . $files['main_product_image']['stored_filename']); ?>"
|
||||
target="_blank" onclick="openModal(event, this); return false;">
|
||||
<img src="<?php echo htmlspecialchars('../report_files/' . $files['main_product_image']['stored_filename']); ?>"
|
||||
alt="Product Image" style="max-width: 150px; max-height: 150px;">
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<span>No image available</span>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<!-- Modal container for enlarged image -->
|
||||
|
||||
<div id="imageModal" style="display:none; position:fixed; z-index:1000; left:0; top:0; width:100%; height:100%; background-color:rgba(0, 0, 0, 0.8); justify-content:center; align-items:center;" onclick="closeModal(event)">
|
||||
<img id="modalImage" style="max-width:90%; max-height:90%;">
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function openModal(event, link) {
|
||||
event.preventDefault();
|
||||
var modal = document.getElementById('imageModal');
|
||||
var modalImage = document.getElementById('modalImage');
|
||||
modalImage.src = link.href;
|
||||
modal.style.display = 'flex';
|
||||
}
|
||||
|
||||
function closeModal(event) {
|
||||
var modal = document.getElementById('imageModal');
|
||||
// Chiudi il modal solo se il clic è al di fuori dell'immagine
|
||||
if (event.target.id === 'imageModal') {
|
||||
modal.style.display = 'none';
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<?php
|
||||
// Query per ottenere i file aggiuntivi non etichettati come 'report' o 'main_product_image'
|
||||
$queryAdditionalFiles = "SELECT * FROM report_files WHERE uuid = ? AND file_comment NOT IN ('report', 'main_product_image')";
|
||||
$stmtAdditionalFiles = $conn->prepare($queryAdditionalFiles);
|
||||
$stmtAdditionalFiles->bind_param("s", $reportDetails['importcode']);
|
||||
$stmtAdditionalFiles->execute();
|
||||
$additionalFiles = $stmtAdditionalFiles->get_result();
|
||||
?>
|
||||
|
||||
<?php if ($additionalFiles->num_rows > 0): ?>
|
||||
<div class="card mt-4">
|
||||
<div class="card-body">
|
||||
<h5 class="header-title pb-3 mt-0">Additional Files</h5>
|
||||
<!-- Button to toggle collapsible area -->
|
||||
<button class="btn btn-primary mb-3" type="button" data-toggle="collapse" data-target="#additionalFilesSection">
|
||||
Show/Hide Additional Files
|
||||
</button>
|
||||
<!-- Collapsible area for additional files -->
|
||||
<div id="additionalFilesSection" class="collapse">
|
||||
<table class="table table-bordered">
|
||||
<thead class="thead-light">
|
||||
<tr>
|
||||
<th>File Preview</th>
|
||||
<th>Comment</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php while ($file = $additionalFiles->fetch_assoc()): ?>
|
||||
<?php
|
||||
$filePath = "../report_files/" . $file['stored_filename'];
|
||||
$isImage = preg_match('/\.(jpg|jpeg|png|gif)$/i', $file['stored_filename']);
|
||||
$isPDF = preg_match('/\.pdf$/i', $file['stored_filename']);
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<?php if ($isImage): ?>
|
||||
<!-- Thumbnail with click to enlarge -->
|
||||
<a href="<?php echo htmlspecialchars($filePath); ?>" onclick="openModal(event, this)">
|
||||
<img src="<?php echo htmlspecialchars($filePath); ?>" alt="Additional File" style="width:50px; height:auto;">
|
||||
</a>
|
||||
<?php elseif ($isPDF): ?>
|
||||
<!-- PDF icon with link -->
|
||||
<a href="<?php echo htmlspecialchars($filePath); ?>" target="_blank">
|
||||
<i class="fas fa-file-pdf" style="font-size: 24px; color: #d9534f;"></i>
|
||||
</a>
|
||||
<?php else: ?>
|
||||
<!-- Generic file icon with link -->
|
||||
<a href="<?php echo htmlspecialchars($filePath); ?>" target="_blank">
|
||||
<i class="fas fa-file-alt" style="font-size: 24px; color: #5a5a5a;"></i>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</td>
|
||||
<td><?php echo htmlspecialchars($file['file_comment'], ENT_QUOTES, 'UTF-8'); ?></td>
|
||||
</tr>
|
||||
<?php endwhile; ?>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
|
||||
<!-- Filtri -->
|
||||
<!-- Aggiungi questo filtro sopra la tabella -->
|
||||
|
||||
Reference in New Issue
Block a user