You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!-- Bắt đầu phần Modal hiện ra block lịch, có thể thay đổi html và CSS, lưu ý các trường id của select trong mybookingappForm cần giữ nguyên -->
{% if product.available %}
{% for protag in product.tags %}
{% if protag contains 'duration_time_' %}
<form id="mybookingappForm">
<div id="myBookingAppModal" class="booking_app_modal">
<!-- Modal content -->
<div class="booking_app_modal-body">
<div class="booking_app_modal-header">
<span class="booking_app_modal_close">×</span>
<h4>Đặt lịch tại {{ shop.name }}</h4>
</div>
<div class="row">
<div class="col">
<div class="p-3 mb-2">
<select id="variant_id" name="variant_id" class="next-input"
required>
</select>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="p-3 mb-2">
<label
class="label-input-group">Chi nhánh*</label>
<div class="">
<select id="location_id" name="location_id" class="next-input"
required>
<option value="000">Chưa chọn</option>
</select>
</div>
</div>
</div>
<div class="col">
<div class="p-3 mb-2">
<label
class="label-input-group">Giờ bắt đầu*</label>
<div class=""><select id="free_time" name="free_time"
class="next-input" required>
</select>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="p-3 mb-2">
<label
class="label-input-group">Họ và tên*</label>
<input id="booking_app_customer_name" type="text" name="booking_app_customer_name"
class="next-input"
placeholder="Họ và Tên" required>
</div>
</div>
</div>
<div class="row">
<div class="col">
<div class="p-3 mb-2">
<label
class="label-input-group">Số
điện
thoại*</label>
<input id="phone" type="tel" name="phone"
class="next-input"
placeholder="097xxxxxxxx" pattern="[0-9]{10}" required>
</div>
</div>
</div>
<br>
<div id="shop_delivery_or_not" name="shop_delivery_or_not">
</div>
<br>
<div class="row">
<div class="col">
<div class="p-3 mb-2">
<button type="submit" name="book_event" id="book_event"
class="btn btn-primary btn-lg btn-block"
value="{{ variant_id }}">
BookNow
</button>
</div>
</div>
</div>
<div class="booking_app_modal-footer">
<h5> {{ shop.name }} Sẽ liên hệ lại với quý khách</h5>
</div>
</div>
</div>
</form>
{% endif %}
{% endfor %}
{% endif %}
<!-- Kết thúc phần Modal đặt lịch -->
Script để post lên server booking app
<script>
window.addEventListener("load", function () {
function sendData() {
const XHR = new XMLHttpRequest();
// Bind the FormData object and the form element
const FD = new FormData(form);
// Define what happens on successful data submission
XHR.addEventListener("load", function (event) {
alert(event.target.responseText);
$('#myBookingAppModal').modal('hide');
});
// Define what happens in case of error
XHR.addEventListener("error", function (event) {
alert('Có lỗi xảy ra, liên hệ shop để đặt lịch trực tiếp');
});
// Set up our request
XHR.open("POST", 'https://booking-app.vn/api/book');
// The data sent is what the user provided in the form
XHR.send(FD);
}
// Access the form element...
const form = document.getElementById("mybookingappForm");
// ...and take over its submit event.
form.addEventListener("submit", function (event) {
alert("Server đang lên lịch! Quý khách hãy bấm OK/Đóng và chờ trong giây lát, hệ thống sẽ thông báo nếu đặt lịch thành công!");
event.preventDefault();
sendData();
});
});
</script>
```
About
Danh sách các API cho theme haravan sau khi cài đặt booking app