This commit is contained in:
Roman Pyrih
2025-06-25 14:58:13 +02:00
parent 8087ebc4ab
commit 036afcbc74
2 changed files with 42 additions and 0 deletions

View File

@@ -202,4 +202,18 @@ class Apanel
header( 'Location: /apanel/main_view/' );
exit;
}
static public function use_ticket() {
global $mdb;
$order_id = \S::get('order_id');
$date = date('Y-m-d H:i:s');
$mdb->update('orders', ['used_ticket' => 1, 'used_ticket_date' => $date], ['id' => $order_id]);
echo json_encode([
'useStatus' => true
]);
exit;
}
}

View File

@@ -194,11 +194,20 @@
<div class="order-summary__wrapper">
<h2>Suma:</h2>
<p id="order-general-price"><?= $ticketsPrice; ?> zł</p>
<hr>
<div class="flex flex-buttons-group">
<button class="btn-t1 btn-save-new-list">Zapisz</button>
<a href="#" class="btn btn-danger btn-delete-order" data-id="<?= $orderInfo[0]['id']; ?>">Usuń zamówienie</a>
</div>
<?php if($orderInfo[0]['used_ticket'] == 0) : ?>
<hr>
<div class="flex flex-buttons-group">
<a href="#" class="btn btn-dark btn-accept-order w-100" data-id="<?= $orderInfo[0]['id']; ?>">Oznacz jako wykorzystane</a>
</div>
<?php endif; ?>
</div>
</div>
</div>
@@ -342,5 +351,24 @@ $(function() {
}
});
})
$('body').on('click', '.btn-accept-order', function(e) {
var order_id = $(this).attr( 'data-id' );
$.ajax({
type: 'POST',
cache: false,
url: '/apanel/use_ticket/',
data: {
order_id: order_id,
},
success: function(data) {
response = jQuery.parseJSON(data);
if (response.useStatus == true) {
alert("Status zmieniono na 'Wykorzystany'")
}
}
});
});
});
</script>