File "template-booking.php"
Full Path: /var/www/bvnghean.vn/wp-content/themes/bvnghean/templates/template-booking.php
File size: 13.69 KB
MIME-type: text/x-php
Charset: utf-8
<?php
/*
Template name: Booking
*/
?>
<?php get_header(); ?>
<div class="wrapper booking-page">
<div class="row container">
<div class="col-4">
<div class="px-15">
<h4 class="color-main"><strong>LƯU Ý</strong></h4>
<br>
<div class="font-h5">
<div class="mb-20 info">
<i class="las la-lightbulb"></i>
Chức năng đặt lịch khám áp dụng đối với <span style="color: red">tất cả các đối tượng bệnh nhân</span>
</div>
<div class="mb-20 info">
<i class="las la-lightbulb"></i>
Đối với đối tượng bệnh nhân khám <span style="color: red">Bảo hiểm y tế</span> vui lòng tích vào <span style="color: red">Tôi có thẻ Bảo hiểm y tế</span> sau đó điền <span style="color: red">Mã thẻ Bảo hiểm y tế</span>
</div>
<div class="mb-20 info">
<i class="las la-lightbulb"></i>
<p>Người bệnh đặt lịch khám trước 1 ngày, tối đa trước 10 ngày khám.</p>
<p>Nếu đặt lịch <span style="color: red">trước 16 giờ</span> từ thứ 2 đến thứ 6 ngày khám gần nhất là ngày hôm sau.</p>
<p>Nếu đặt lịch <span style="color: red">SAU 16 giờ</span> và thứ 7, CN ngày khám gần nhất sẽ là 3 ngày sau.</p>
<p><span style="color: red">Sau khi đặt lịch khám thành công.</span> Đến ngày khám bệnh mời quý khách vào <span style="color: red">Ô SỐ 8 - QUẦY 1 CỬA</span> khoa khám bệnh nhận phiếu khám bệnh.</p>
</div>
<div class="mb-20 info">
<i class="las la-lightbulb"></i>
Vui lòng cung cấp thông tin chính xác để được phục vụ tốt nhất.
</div>
<div class="mb-20 info">
<i class="las la-lightbulb"></i>
Trong những trường hợp khẩn cấp hoặc nghi ngờ có các triệu chứng nguy hiểm, quý khách nên ĐẾN TRỰC TIẾP hoặc trung tâm y tế gần nhất để kịp thời xử lý.
</div>
<div class="mb-20 info">
<i class="las la-lightbulb"></i>
Số điện thoại đặt khám: <a href="tel:19008082" style="color: red; font-size: 30px; display: inline-block; vertical-align: middle; font-weight: bold">1900 8082</a>
<p>+ Buổi sáng từ 7h - 12h các ngày từ thứ 2 đến thứ 6</p>
<p>+ Buổi chiều từ 13h – 16h các ngày từ thứ 2 đến thứ 6</p>
</div>
</div>
</div>
</div>
<div class="col-8 px-15">
<div class="booking-form style-form p-20">
<h4 class="color-main"><strong>ĐẶT LỊCH KHÁM BỆNH</strong></h4>
<!-- Bảo hiểm y tế -->
<h5 class="color-second"><strong>Đăng ký khám Bảo hiểm y tế</strong></h5>
<h6 style="display: flex; align-items: center;">
<input type="checkbox" id="co-the-bhyt" style="width: 20px; height: 20px;" />
<label for="co-the-bhyt" style="margin-left: 5px;">Tôi có thẻ Bảo hiểm y tế</label>
</h6>
<div class="input hide" id="bhyt-field">
<span>Mã thẻ Bảo hiểm y tế</span>
<input class="data" data="ma_the_bhyt" type="text">
</div>
<!-- upload giấy hẹn khám -->
<!-- <h6 style="display: flex; align-items: center;">
<input type="checkbox" id="co-henkham" style="width: 20px; height: 20px;" />
<label for="co-henkham" style="margin-left: 5px;">Tôi có giấy hẹn khám</label>
</h6> -->
<!-- <div class="input required" id="henkham-field">
<div>Tải ảnh giấy hẹn khám</div>
<input type="file" name="henkham_image" id="file" multiple="false" value="" accept=".png, .jpg, .jpeg, .gif"/>
</div> -->
<!-- <form id="booking-form" method="post" enctype="multipart/form-data">
<label for="henkham_image">Giấy hẹn khám</label>
<input type="file" name="henkham_image" accept=".jpg,.jpeg,.png,.pdf">
</form> -->
<!-- Thông tin bệnh nhân -->
<h5 class="color-second"><strong>Thông tin bệnh nhân</strong></h5>
<div class="input required">
<span>Họ và tên <label style="color: red">*</label></span>
<input class="data" data="ho_ten" type="text">
</div>
<div class="input required">
<span>Số Căn cước <label style="color: red">*</label></span>
<input class="data" data="so_cc" type="text" placeholder="12 số">
</div>
<div class="input required">
<span>Ngày/tháng/năm sinh <label style="color: red">*</label></span>
<input class="data" data="ngay_sinh" type="text" placeholder="Vd: 01/01/1991">
</div>
<div class="input required">
<span>Giới tính <label style="color: red">*</label></span>
<select class="data" data="gioi_tinh">
<option value="">Chọn giới tính</option>
<option value="nam">Nam</option>
<option value="nu">Nữ</option>
</select>
</div>
<div class="input required">
<span>Địa chỉ <label style="color: red">*</label></span>
<input class="data" data="dia_chi" type="text" placeholder="Vui lòng nhập địa chỉ mới 2 cấp (Xã - Tỉnh)">
</div>
<div class="input required">
<span>Số điện thoại <label style="color: red">*</label></span>
<input class="data" data="dien_thoai" type="text">
</div>
<h5 class="color-second"><strong>Thông tin đặt lịch hẹn</strong></h5>
<div class="input required">
<span>Ngày khám <label style="color: red">*</label></span>
<input type="text" class="data ngay-kham" data="ngay_kham" readonly="readonly">
</div>
<div class="input required">
<span>Mô tả triệu chứng <label style="color: red">*</label></span>
<textarea class="data" type="text" data="mo_ta"></textarea>
</div>
<div class="row">
<div class="col-8">
<div class="input required captcha-wrapper">
<span>Mã xác nhận <label style="color: red">*</label></span>
<input class="data captcha" data="captcha" type="text">
</div>
<img src="<?=get_template_directory_uri()?>/include/captcha.php" alt="CAPTCHA" class="captcha-image">
<i class="la la-redo-alt f5-captcha"></i>
</div>
<div class="col-4 align-right">
<button class="btn dat-lich inline-block">ĐẶT LỊCH <span class="booking-loading hide">...</span></button>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
// jQuery(document).ready(function($){
// function isWeekend(date) {
// var day = date.getDay();
// return day === 6 || day === 0; // 6 = Thứ 7, 0 = Chủ nhật
// }
// if (isWeekend(new Date())) {
// $(".ngay-kham").datepicker({
// minDate: 3,
// maxDate: 10,
// dateFormat: 'dd/mm/yy',
// beforeShowDay: $.datepicker.noWeekends, firstDay: 1 });
// } else {
// <?php if(date('H') < 16){ ?>
// $(".ngay-kham").datepicker({
// minDate: 1,
// maxDate: 10,
// dateFormat: 'dd/mm/yy',
// beforeShowDay: $.datepicker.noWeekends,
// firstDay: 1
// });
// <?php }else{ ?>
// $(".ngay-kham").datepicker({
// minDate: 2,
// maxDate: 11,
// dateFormat: 'dd/mm/yy',
// beforeShowDay: $.datepicker.noWeekends,
// firstDay: 1
// });
// <?php } ?>
// }
jQuery(document).ready(function($){
// THÊM MỚI: Hàm kiểm tra ngày bị chặn (30/4 - 5/5/2025)
function isDisabledDate(date) {
var disabledDates = [
'30/04/2025',
'01/05/2025',
'02/05/2025',
'03/05/2025',
'04/05/2025',
'05/05/2025'
];
var day = ("0" + date.getDate()).slice(-2);
var month = ("0" + (date.getMonth() + 1)).slice(-2);
var year = date.getFullYear();
var formattedDate = day + '/' + month + '/' + year;
return disabledDates.indexOf(formattedDate) !== -1;
}
function getNextTuesday(date) {
var day = date.getDay();
var daysToTuesday = (9 - day) % 7;
return daysToTuesday;
}
var today = new Date();
var currentHour = today.getHours();
if (today.getDay() === 6 || today.getDay() === 0 || (today.getDay() === 5 && currentHour >= 16)) { // Nếu là thứ 7, CN hoặc sau 16h thứ 6
var minDays = getNextTuesday(today);
$(".ngay-kham").datepicker({
minDate: minDays,
maxDate: minDays + 7,
dateFormat: 'dd/mm/yy',
beforeShowDay: function(date) {
var noWeekend = $.datepicker.noWeekends(date);
if (!noWeekend[0]) {
return [false];
}
if (isDisabledDate(date)) {
return [false];
}
return [true];
},
firstDay: 1
});
} else {
<?php if(date('H') < 16){ ?>
$(".ngay-kham").datepicker({
minDate: 1,
maxDate: 10,
dateFormat: 'dd/mm/yy',
beforeShowDay: function(date) {
var noWeekend = $.datepicker.noWeekends(date);
if (!noWeekend[0]) {
return [false];
}
if (isDisabledDate(date)) {
return [false];
}
return [true];
},
firstDay: 1 });
<?php
} else { ?>
$(".ngay-kham").datepicker({
minDate: 2,
maxDate: 11,
dateFormat: 'dd/mm/yy',
beforeShowDay: function(date) {
var noWeekend = $.datepicker.noWeekends(date);
if (!noWeekend[0]) {
return [false];
}
if (isDisabledDate(date)) {
return [false];
}
return [true];
},
firstDay: 1 });
<?php } ?>
}
function reset(){
$('.data').each(function(){
$(this).val('');
document.querySelector(".captcha-image").src = '<?=get_template_directory_uri()?>/include/captcha.php?' + Date.now();
});
}
$("#co-the-bhyt").on("change", function() {
if($(this).is(":checked")){
$('#bhyt-field').removeClass("hide");
}else{
$('#bhyt-field').addClass("hide");
$('input[data="ma_the_bhyt"]').val("");
}
})
//ảnh giấy hẹn khám
// $("#co-henkham").on("change", function() {
// if($(this).is(":checked")){
// $('#henkham-field').removeClass("hide");
// }else{
// $('#henkham-field').addClass("hide");
// $('#henkham_image').val("");
// }
// })
$('.dat-lich').on('click',function(){
if($('.booking-loading').hasClass('hide')){
var error = false;
$('.required').each(function(){
if($(this).children('.data').val() == ''){
error = true;
$(this).addClass('error');
}else{
$(this).removeClass('error');
}
});
if(error){
Swal.fire({
icon: 'warning',
title: 'Thiếu thông tin',
text: 'Vui lòng nhập đầy đủ thông tin!'
});
// alert('Vui lòng điền đầy đủ thông tin!');
return false;
}
else{
var value = {};
$('.data').each(function(){
var attr = $(this).attr('data');
value[attr] = $(this).val();
});
//NEW Tạo FormData để gửi file cùng với các trường dữ liệu
var formData = new FormData();
formData.append('action', 'booking');
formData.append('value', JSON.stringify(value));
//NEW Kiểm tra nếu có file được chọn
var fileInput = $('#file').prop('files');
if (fileInput && fileInput.length > 0) {
formData.append('henkham_image', fileInput[0]);
}
$('.booking-loading').removeClass('hide');
$.ajax({
type: "POST",
dataType: 'JSON',
url: admin_url,
data: {
action: 'booking',
value: value
},
success : function(data){
if(data.status == 'soon'){
Swal.fire({
icon: 'warning',
title: 'Ngày khám không hợp lệ!',
text: 'Vui lòng chọn lại ngày khám phù hợp.'
});
// alert('Ngày khám không hợp lệ!');
}else if(data.status == 'wrong_captcha'){
Swal.fire({
icon: 'error',
title: 'Sai mã xác nhận',
text: 'Vui lòng nhập lại mã xác nhận.'
});
// alert('Sai mã xác nhận');
}else if(data.status == 'upload_error'){
alert('up file thất bại');
}else if(data.status == 'success'){
Swal.fire({
icon: 'success',
title: 'Bạn đã đặt khám lịch thành công!',
html: `
<p><strong>THÔNG TIN ĐẶT LỊCH</strong></p>
<b>Họ tên:</b> ${value['ho_ten']}<br>
<b>CCCD:</b> ${value['so_cc']}<br>
<b>Ngày sinh:</b> ${value['ngay_sinh']}<br>
<b>Giới tính:</b> ${value['gioi_tinh']}<br>
<b>Ngày khám:</b> ${value['ngay_kham']}<br>
<b>Triệu chứng:</b> ${value['mo_ta']}
`,
confirmButtonText: 'Đóng'
});
// var patientInfo = 'Họ tên: ' + value['ho_ten'] + '\n' +
// 'Số CCCD: ' + value['so_cc'] + '\n' +
// 'Ngày khám: ' + value['ngay_kham'];
// alert('Bạn đã đặt lịch khám thành công!\n' + patientInfo);
//alert('Bạn đã đặt lịch khám thành công!');
reset();
}
},
error: function(){
alert('Xảy ra lỗi!');
},
complete: function(){
$('.booking-loading').addClass('hide');
}
});
}
}
});
$('.f5-captcha').on('click', function(){
document.querySelector(".captcha-image").src = '<?=get_template_directory_uri()?>/include/captcha.php?' + Date.now();
});
});
</script>
<?php get_footer(); ?>