|
|
@@ -48,6 +48,12 @@ if ($searchCode) {
|
|
|
|
|
|
$reservations = array_reverse($reservations); // Newest first
|
|
|
|
|
|
+$canNotifyMap = [];
|
|
|
+foreach ($reservations as $reservation) {
|
|
|
+ $isNotified = isset($reservation['backorder_status']) && $reservation['backorder_status'] === 'notified';
|
|
|
+ $canNotifyMap[$reservation['id']] = !$isNotified && canFulfillReservationItems($reservation['items']);
|
|
|
+}
|
|
|
+
|
|
|
include __DIR__ . '/../includes/header.php';
|
|
|
?>
|
|
|
|
|
|
@@ -131,7 +137,7 @@ include __DIR__ . '/../includes/header.php';
|
|
|
<?php if ((!isset($reservation['backorder_status']) || $reservation['backorder_status'] !== 'notified') && canFulfillReservationItems($reservation['items'])): ?>
|
|
|
<form method="POST" style="display: inline;" onsubmit="return confirm('Kunde über Verfügbarkeit informieren?');">
|
|
|
<input type="hidden" name="reservation_id" value="<?php echo htmlspecialchars($reservation['id']); ?>">
|
|
|
- <button type="submit" name="notify_available" class="btn btn-small">Verfügbarkeit melden</button>
|
|
|
+ <button type="submit" name="notify_available" class="btn btn-small">Abholung freigeben</button>
|
|
|
</form>
|
|
|
<?php endif; ?>
|
|
|
<button onclick="showDetails('<?php echo htmlspecialchars($reservation['id']); ?>')" class="btn btn-secondary btn-small">Details</button>
|
|
|
@@ -144,9 +150,13 @@ include __DIR__ . '/../includes/header.php';
|
|
|
|
|
|
<!-- Details Modal -->
|
|
|
<div id="detailsModal" style="display: none; position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0,0,0,0.5); z-index: 1000; align-items: center; justify-content: center;">
|
|
|
- <div style="background: white; padding: 2rem; border-radius: 8px; max-width: 600px; max-height: 80vh; overflow-y: auto; position: relative;">
|
|
|
+ <div style="background: white; padding: 2rem; border-radius: 8px; max-width: 900px; max-height: 90vh; overflow-y: auto; position: relative;">
|
|
|
<button onclick="closeDetails()" style="position: absolute; top: 1rem; right: 1rem; background: #dc3545; color: white; border: none; border-radius: 4px; padding: 0.5rem 1rem; cursor: pointer;">Schließen</button>
|
|
|
<div id="detailsContent"></div>
|
|
|
+ <form method="POST" id="notifyForm" style="margin-top: 1.5rem; display: none;" onsubmit="return confirm('Kunde über Verfügbarkeit informieren?');">
|
|
|
+ <input type="hidden" name="reservation_id" id="notifyReservationId" value="">
|
|
|
+ <button type="submit" name="notify_available" class="btn">Abholung freigeben</button>
|
|
|
+ </form>
|
|
|
</div>
|
|
|
</div>
|
|
|
|
|
|
@@ -154,6 +164,7 @@ include __DIR__ . '/../includes/header.php';
|
|
|
function showDetails(reservationId) {
|
|
|
const reservations = <?php echo json_encode(getReservations()); ?>;
|
|
|
const reservation = reservations.find(r => r.id === reservationId);
|
|
|
+ const canNotifyMap = <?php echo json_encode($canNotifyMap); ?>;
|
|
|
|
|
|
if (!reservation) return;
|
|
|
|
|
|
@@ -180,10 +191,18 @@ function showDetails(reservationId) {
|
|
|
<p><strong>Erstellt:</strong> ${reservation.created}</p>
|
|
|
<p><strong>Status:</strong> ${statusText}</p>
|
|
|
${itemsHtml}
|
|
|
- <p><strong>Hinweis:</strong> Lieferung erfolgt in Chargen.</p>
|
|
|
`;
|
|
|
|
|
|
document.getElementById('detailsContent').innerHTML = html;
|
|
|
+ const notifyForm = document.getElementById('notifyForm');
|
|
|
+ const notifyReservationId = document.getElementById('notifyReservationId');
|
|
|
+ if (canNotifyMap[reservation.id]) {
|
|
|
+ notifyReservationId.value = reservation.id;
|
|
|
+ notifyForm.style.display = 'block';
|
|
|
+ } else {
|
|
|
+ notifyReservationId.value = '';
|
|
|
+ notifyForm.style.display = 'none';
|
|
|
+ }
|
|
|
document.getElementById('detailsModal').style.display = 'flex';
|
|
|
}
|
|
|
|