Skip to content
Merged

up #19

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified app/__pycache__/views.cpython-312.pyc
Binary file not shown.
223 changes: 87 additions & 136 deletions app/static/css/booking.css
Original file line number Diff line number Diff line change
@@ -1,182 +1,133 @@
/* Main container */
.booking-container {
max-width: 1200px;
margin: 40px auto;
padding: 0 20px;
.booking {
max-width: 800px;
margin: auto;
padding: 20px;
background: #eee;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
margin-bottom: 20px;
}

/* Progress bar */
.progress-bar {
display: flex;
justify-content: space-between;
margin-bottom: 40px;
h2 {
margin-bottom: 20px;
color: #333;
}

.step {
display: flex;
align-items: center;
flex: 1;
position: relative;
.section {
background: white;
padding: 15px;
border-radius: 8px;
margin-bottom: 20px;
}

.step:not(:last-child)::after {
content: '';
position: absolute;
width: 100%;
height: 2px;
background: #e0e0e0;
top: 50%;
left: 50%;
transform: translateY(-50%);
z-index: 1;
.section label {
display: block;
margin-bottom: 5px;
}

.step.active::after {
background: #007bff;
.pix-text input,
.section select,
.section textarea {
width: 70%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ccc;
border-radius: 4px;
}
.email {
float: left;
width: 49%;
}
.phone {
float: right;
width: 49%;
}

.step-number {
width: 30px;
height: 30px;
border-radius: 50%;
background: #fff;
border: 2px solid #e0e0e0;
.check-box {
display: flex;
align-items: center;
justify-content: center;
font-weight: bold;
z-index: 2;
width: 80%;
}

.step.active .step-number {
border-color: #007bff;
background: #007bff;
color: #fff;
.self-use {
float: left;
width: 50%;
display: flex;
font-size: 15px;
}

/* Form sections */
.section {
background: #fff;
border-radius: 8px;
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
padding: 24px;
margin-bottom: 24px;
.gift {
float: right;
width: 50%;
display: flex;
font-size: 15px;
}

.section h2 {
margin-bottom: 20px;
font-size: 1.5rem;
color: #333;
.gift label,
.self-use label {
width: 222px;
margin-left: 15px;
margin-top: 3px;
}

/* Form inputs */
.form-group {
.service {
background: white;
padding: 15px;
border-radius: 8px;
margin-bottom: 20px;
}

.form-group label {
display: block;
margin-bottom: 8px;
font-weight: 500;
.checkbox-group {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 10px;
}

.form-group input {
width: 100%;
padding: 10px;
border: 1px solid #ddd;
border-radius: 4px;
.checkbox-item {
display: flex;
align-items: center;
gap: 10px;
}

/* Services grid */
.services-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
gap: 20px;
.checkbox-item input {
width: 16px;
height: 16px;
}

.service-item {
border: 1px solid #ddd;
border-radius: 8px;
padding: 15px;
transition: all 0.3s ease;
.checkbox-item label {
font-size: 14px;
color: #343a40;
cursor: pointer;
}

.service-item:hover {
box-shadow: 0 4px 8px rgba(0,0,0,0.1);
.utility {
background: white;
padding: 15px;
border-radius: 8px;
margin-bottom: 20px;
}

/* Price summary */
.price-details {
border-top: 1px solid #eee;
padding-top: 20px;
.summary {
background: white;
padding: 15px;
border-radius: 8px;
}

.price-row {
display: flex;
justify-content: space-between;
margin-bottom: 12px;
.summary div {
margin-bottom: 10px;
font-weight: bold;
}

.total {
font-size: 1.2em;
font-weight: bold;
margin-top: 20px;
padding-top: 20px;
border-top: 2px solid #eee;
color: #e74c3c;
}

/* Submit button */
.submit-btn {
display: block;
width: 100%;
padding: 16px;
padding: 10px;
background: #007bff;
color: #fff;
border: none;
border-radius: 4px;
font-size: 1.1em;
cursor: pointer;
transition: background 0.3s ease;
font-size: 1em;
}

.submit-btn:hover {
background: #0056b3;
}

/* Payment modal */
.payment-methods {
margin-top: 24px;
}

.payment-option {
display: block;
padding: 15px;
border: 1px solid #ddd;
border-radius: 4px;
margin-bottom: 12px;
cursor: pointer;
}

.payment-option:hover {
background: #f8f9fa;
}

.option-content {
display: flex;
align-items: center;
gap: 12px;
}

/* Responsive design */
@media (max-width: 768px) {
.form-row {
flex-direction: column;
}

.services-grid {
grid-template-columns: 1fr;
}

.step-text {
display: none;
}
}
50 changes: 50 additions & 0 deletions app/static/js/booking.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,54 @@
$(document).ready(function() {
// Apply voucher handler
$('#apply-voucher').click(function() {
$.ajax({
url: '/promotion/', // URL đến trang promotion.html
type: 'GET',
success: function(data) {
// Lấy danh sách các voucher từ dữ liệu trả về
var voucherList = $(data).find('.promotion-item');

// Xóa danh sách voucher cũ
$('#voucher-list-container').empty();

// Thêm từng voucher vào modal
voucherList.each(function() {
var voucher = $(this);
var voucherId = voucher.attr('id'); // Lấy ID của voucher
var voucherCode = voucher.find('h6').text(); // Lấy mã voucher
var voucherDiscount = voucher.find('h5').text(); // Lấy phần trăm giảm giá

// Tạo nút voucher với mã voucher và phần trăm giảm giá
var voucherButton = $('<button type="button" class="btn btn-outline-primary">' + voucherCode + ' - ' + voucherDiscount + '</button>');

// Thêm sự kiện click cho nút voucher
voucherButton.click(function() {
// Áp dụng mã voucher vào input
$('#voucher-code').val(voucherCode);

// Tính toán giá trị giảm giá
var totalPrice = parseFloat($('#total-price').text().replace(/\./g, '').replace(' VNĐ', '')); // Lấy tổng giá tiền và chuyển đổi sang số
var discountPercentage = parseFloat(voucherDiscount.replace('Giảm ', '').replace('%', '')); // Lấy phần trăm giảm giá và chuyển đổi sang số
var discountAmount = totalPrice * (discountPercentage / 100); // Tính giá trị giảm giá

// Hiển thị số tiền giảm
$('#discount-amount').text('Voucher: ' + -(discountAmount.toLocaleString('vi-VN')) + ' VNĐ');

// Tính và hiển thị "Thành tiền"
var finalPrice = totalPrice - discountAmount; // Tính tổng giá tiền sau khi giảm giá
$('#final-price').text('Thành tiền: ' + finalPrice.toLocaleString('vi-VN') + ' VNĐ');

// Ẩn modal
$('#voucherModal').modal('hide');
});

// Thêm nút voucher vào danh sách
$('#voucher-list-container').append(voucherButton);
});
}
});
});

// Form submission handler
$(".submit-btn").click(function() {
// Validate required fields
Expand Down
52 changes: 38 additions & 14 deletions app/templates/booking.html
Original file line number Diff line number Diff line change
Expand Up @@ -206,20 +206,44 @@ <h3>{{ room.name }}</h3>
</div>
</section>

<div class="section summary">
<h2>Chi tiết giá</h2>
<div>
Giá phòng: <span id="room-price">{{ room.formatted_price }}</span>
</div>
<div>
Thuế và phí: <span id="tax-fee">31.664 VNĐ</span>
</div>
<div class="total">
Tổng giá: <span id="total-price">267.960 VNĐ</span>
</div>
<div class="voucher-section">
<input type="text" id="voucher-code" placeholder="Nhập mã voucher">
<button id="apply-voucher" class="btn btn-primary">Áp dụng voucher</button>
<div class="section summary">
<h2>Chi tiết giá</h2>
<div>
Giá phòng: <span id="room-price">{{ room.formatted_price }}</span>
</div>
<div>
Thuế và phí: <span id="tax-fee">31.664 VNĐ</span>
</div>
<div>
Tổng giá: <span id="total-price">267.960 VNĐ</span>
</div>
<div id="discount-amount">Voucher: 0 VNĐ</div>
<div class="total">
<span id="final-price">Thành tiền: 0 VNĐ</span>
</div>
<div class="voucher-section">
<input type="text" id="voucher-code" placeholder="Nhập mã voucher">
<button id="apply-voucher" type="button" class="btn btn-primary" data-toggle="modal"
data-target="#voucherModal">Áp dụng voucher</button>
</div>

<div id="voucherModal" class="modal fade" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">Chọn voucher</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div id="voucher-list-container"></div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Đóng</button>
</div>
</div>
</div>
</div>
<button class="submit-btn">Tiếp tục thanh toán</button>

Expand Down
Loading