优化预约查询以及后台预约信息中文名显示
This commit is contained in:
parent
f5f09c89da
commit
6c3378f446
|
@ -637,11 +637,16 @@ class Appointments_model extends EA_Model
|
|||
->result();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function get_appointments_by_phone(string $phone_number, int $limit = null, int $offset = null, string $order_by = null): array
|
||||
{
|
||||
$today = new DateTime('today');
|
||||
|
||||
$appointments = $this->db
|
||||
->select('appointments.*')
|
||||
->from('appointments')
|
||||
->join('services', 'services.id = appointments.id_services', 'left')
|
||||
->join('users AS providers', 'providers.id = appointments.id_users_provider', 'inner')
|
||||
->join('users AS customers', 'customers.id = appointments.id_users_customer', 'left')
|
||||
->where('is_unavailability', false)
|
||||
|
@ -649,10 +654,10 @@ class Appointments_model extends EA_Model
|
|||
->like('providers.phone_number', $phone_number)
|
||||
->or_like('customers.phone_number', $phone_number)
|
||||
->group_end()
|
||||
// ->where('appointments.start_datetime >=', date('Y-m-d H:i:s')) // 过滤掉当天00点之前的预约
|
||||
->where('appointments.start_datetime >=', $today->format('Y-m-d H:i:s')) // 过滤掉当天00点之前的预约
|
||||
->limit($limit)
|
||||
->offset($offset)
|
||||
->order_by($order_by)
|
||||
->order_by('appointments.end_datetime')
|
||||
->get()
|
||||
->result_array();
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@
|
|||
<link rel="stylesheet" type="text/css" href="<?= asset_url('assets/css/general.css') ?>">
|
||||
<link rel="stylesheet" type="text/css" href="<?= asset_url('assets/css/layouts/booking_layout.css') ?>">
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="<?= asset_url('assets/vendor/bootstrap/bootstrap.min.css') ?>">
|
||||
<?php component('company_color_style', ['company_color' => vars('company_color')]); ?>
|
||||
|
||||
<?php slot('styles'); ?>
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
justify-content: center;
|
||||
align-items: center;
|
||||
flex-direction: column;
|
||||
min-height: 44.2vh;
|
||||
min-height: 589px;
|
||||
}
|
||||
|
||||
.search-container-title {
|
||||
|
@ -97,26 +97,23 @@
|
|||
'company_logo' => vars('company_logo'),
|
||||
]); ?>
|
||||
<div class="search-container-wrapper">
|
||||
<h2 class="search-container-title">查询预约信息</h2>
|
||||
<h2 class="frame-title mt-md-5">查詢預約信息</h2>
|
||||
<div class="search-container">
|
||||
<input type="text" id="phoneNumber" placeholder="请输入手机号">
|
||||
<button id="searchButton">查询</button>
|
||||
<input type="text" id="phoneNumber" placeholder="請輸入預約時的電話號">
|
||||
<button id="searchButton">查 詢</button>
|
||||
</div>
|
||||
<div class="appointments-container" id="appointmentsContainer">
|
||||
<h3>预约结果</h3>
|
||||
<h3>已預約資訊</h3>
|
||||
<ul id="appointmentsList"></ul>
|
||||
</div>
|
||||
<div class="no-appointments" id="noAppointmentsMessage">
|
||||
未找到预约信息。
|
||||
暫未檢索到預約資訊。
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<?php component('booking_footer', ['display_login_button' => vars('display_login_button')]); ?>
|
||||
|
||||
<?php component('booking_footer', ['display_login_button' => vars('display_login_button')]); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if (vars('display_cookie_notice') === '1'): ?>
|
||||
<?php component('cookie_notice_modal', ['cookie_notice_content' => vars('cookie_notice_content')]); ?>
|
||||
|
@ -164,9 +161,6 @@
|
|||
return;
|
||||
}
|
||||
|
||||
// 发送请求前获取CSRF token
|
||||
//var csrfToken = document.querySelector('meta[name="csrf_token"]').getAttribute('content');
|
||||
|
||||
const url = App.Utils.Url.siteUrl('customers/search_by_phone');
|
||||
|
||||
const data = {
|
||||
|
@ -189,26 +183,6 @@
|
|||
document.getElementById('searchButton').addEventListener('click', function() {
|
||||
|
||||
doSearch();
|
||||
// fetch('/index.php/customers/search_by_phone', {
|
||||
// method: 'POST',
|
||||
// headers: {
|
||||
// 'Content-Type': 'application/json',
|
||||
// //'X-CSRF-TOKEN': csrfToken // 添加CSRF Token到请求头
|
||||
// },
|
||||
// body: formData
|
||||
// })
|
||||
// .then(response => response.json())
|
||||
// .then(data => {
|
||||
// if (data.success && data.appointments.length > 0) {
|
||||
// displayAppointments(data.appointments);
|
||||
// } else {
|
||||
// showNoAppointmentsMessage();
|
||||
// }
|
||||
// })
|
||||
// .catch(error => {
|
||||
// console.error('Error fetching appointments:', error);
|
||||
// showNoAppointmentsMessage();
|
||||
// });
|
||||
});
|
||||
|
||||
function displayAppointments(appointments) {
|
||||
|
@ -218,11 +192,15 @@
|
|||
appointmentsList.innerHTML = '';
|
||||
appointments.forEach(function(appointment) {
|
||||
var listItem = document.createElement('li');
|
||||
|
||||
|
||||
// 创建服务名称和提供者姓名的 div
|
||||
var serviceDiv = document.createElement('div');
|
||||
serviceDiv.textContent = `${appointment.service.name} - ${appointment.provider.last_name}${appointment.provider.first_name}`;
|
||||
|
||||
// 创建预约客户 div
|
||||
// var nameDiv = document.createElement('div');
|
||||
// nameDiv.textContent = `預約人:${appointment.customer.last_name}${appointment.customer.first_name}`;
|
||||
|
||||
// 创建预约时间的 div
|
||||
var timeDiv = document.createElement('div');
|
||||
timeDiv.textContent = `開始時間:${appointment.start}`;
|
||||
|
@ -237,10 +215,11 @@
|
|||
|
||||
// 将每个 div 添加到 li 中
|
||||
listItem.appendChild(serviceDiv);
|
||||
// listItem.appendChild(nameDiv);
|
||||
listItem.appendChild(timeDiv);
|
||||
listItem.appendChild(endDiv);
|
||||
listItem.appendChild(statusDiv);
|
||||
|
||||
|
||||
// 如果状态是“已预约”,添加取消预约按钮
|
||||
if (appointment.status === '已預約') {
|
||||
var cancelButton = document.createElement('button');
|
||||
|
@ -277,6 +256,9 @@
|
|||
listItem.appendChild(cancelButton);
|
||||
}
|
||||
|
||||
var br = document.createElement('hr');
|
||||
listItem.appendChild(br);
|
||||
|
||||
// 将 li 添加到 ul 或 ol 列表中
|
||||
appointmentsList.appendChild(listItem);
|
||||
});
|
||||
|
|
|
@ -651,16 +651,9 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
}),
|
||||
App.Utils.CalendarEventPopover.renderMapIcon(info.event.extendedProps.data.provider),
|
||||
provider = info.event.extendedProps.data.provider,
|
||||
isChineseName = /[\u4e00-\u9fa5]/.test(provider.last_name) || /[\u4e00-\u9fa5]/.test(provider.first_name),
|
||||
|
||||
$('<span/>', {
|
||||
'text': (function() {
|
||||
if (isChineseName) {
|
||||
return provider.last_name + provider.first_name;
|
||||
} else {
|
||||
return provider.first_name + ' ' + provider.last_name;
|
||||
}
|
||||
}),
|
||||
'text': provider.last_name + provider.first_name,
|
||||
|
||||
}),
|
||||
$('<br/>'),
|
||||
|
@ -670,9 +663,11 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
'text': lang('customer'),
|
||||
}),
|
||||
App.Utils.CalendarEventPopover.renderMapIcon(info.event.extendedProps.data.customer),
|
||||
customer = info.event.extendedProps.data.customer,
|
||||
|
||||
$('<span/>', {
|
||||
'class': 'd-inline-block',
|
||||
'text': customerInfo.length ? customerInfo.join(' ') : '-',
|
||||
'text': customerInfo.length ? customerInfo.reverse().join('') : '-',
|
||||
}),
|
||||
$('<br/>'),
|
||||
|
||||
|
@ -1210,7 +1205,7 @@ App.Utils.CalendarDefaultView = (function () {
|
|||
}
|
||||
|
||||
if (customerInfo.length) {
|
||||
title.push(customerInfo.join(' '));
|
||||
title.push(customerInfo.reverse().join(''));
|
||||
}
|
||||
|
||||
const appointmentEvent = {
|
||||
|
|
|
@ -897,7 +897,7 @@ App.Utils.CalendarTableView = (function () {
|
|||
}
|
||||
|
||||
if (customerInfo.length) {
|
||||
title.push(customerInfo.join(' '));
|
||||
title.push(customerInfo.reverse().join(''));
|
||||
}
|
||||
|
||||
calendarEvents.push({
|
||||
|
@ -1396,7 +1396,7 @@ App.Utils.CalendarTableView = (function () {
|
|||
}),
|
||||
App.Utils.CalendarEventPopover.renderMapIcon(info.event.extendedProps.data.customer),
|
||||
$('<span/>', {
|
||||
'text': customerInfo.length ? customerInfo.join(' ') : '-',
|
||||
'text': customerInfo.length ? customerInfo.reverse().join('') : '-',
|
||||
}),
|
||||
$('<br/>'),
|
||||
|
||||
|
|
Loading…
Reference in New Issue