优化预约查询以及后台预约信息中文名显示
This commit is contained in:
parent
f5f09c89da
commit
6c3378f446
|
@ -637,11 +637,16 @@ class Appointments_model extends EA_Model
|
||||||
->result();
|
->result();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function get_appointments_by_phone(string $phone_number, int $limit = null, int $offset = null, string $order_by = null): array
|
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
|
$appointments = $this->db
|
||||||
->select('appointments.*')
|
->select('appointments.*')
|
||||||
->from('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 providers', 'providers.id = appointments.id_users_provider', 'inner')
|
||||||
->join('users AS customers', 'customers.id = appointments.id_users_customer', 'left')
|
->join('users AS customers', 'customers.id = appointments.id_users_customer', 'left')
|
||||||
->where('is_unavailability', false)
|
->where('is_unavailability', false)
|
||||||
|
@ -649,10 +654,10 @@ class Appointments_model extends EA_Model
|
||||||
->like('providers.phone_number', $phone_number)
|
->like('providers.phone_number', $phone_number)
|
||||||
->or_like('customers.phone_number', $phone_number)
|
->or_like('customers.phone_number', $phone_number)
|
||||||
->group_end()
|
->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)
|
->limit($limit)
|
||||||
->offset($offset)
|
->offset($offset)
|
||||||
->order_by($order_by)
|
->order_by('appointments.end_datetime')
|
||||||
->get()
|
->get()
|
||||||
->result_array();
|
->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/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/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 component('company_color_style', ['company_color' => vars('company_color')]); ?>
|
||||||
|
|
||||||
<?php slot('styles'); ?>
|
<?php slot('styles'); ?>
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
min-height: 44.2vh;
|
min-height: 589px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-container-title {
|
.search-container-title {
|
||||||
|
@ -97,23 +97,20 @@
|
||||||
'company_logo' => vars('company_logo'),
|
'company_logo' => vars('company_logo'),
|
||||||
]); ?>
|
]); ?>
|
||||||
<div class="search-container-wrapper">
|
<div class="search-container-wrapper">
|
||||||
<h2 class="search-container-title">查询预约信息</h2>
|
<h2 class="frame-title mt-md-5">查詢預約信息</h2>
|
||||||
<div class="search-container">
|
<div class="search-container">
|
||||||
<input type="text" id="phoneNumber" placeholder="请输入手机号">
|
<input type="text" id="phoneNumber" placeholder="請輸入預約時的電話號">
|
||||||
<button id="searchButton">查询</button>
|
<button id="searchButton">查 詢</button>
|
||||||
</div>
|
</div>
|
||||||
<div class="appointments-container" id="appointmentsContainer">
|
<div class="appointments-container" id="appointmentsContainer">
|
||||||
<h3>预约结果</h3>
|
<h3>已預約資訊</h3>
|
||||||
<ul id="appointmentsList"></ul>
|
<ul id="appointmentsList"></ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="no-appointments" id="noAppointmentsMessage">
|
<div class="no-appointments" id="noAppointmentsMessage">
|
||||||
未找到预约信息。
|
暫未檢索到預約資訊。
|
||||||
</div>
|
</div>
|
||||||
</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>
|
||||||
</div>
|
</div>
|
||||||
|
@ -164,9 +161,6 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 发送请求前获取CSRF token
|
|
||||||
//var csrfToken = document.querySelector('meta[name="csrf_token"]').getAttribute('content');
|
|
||||||
|
|
||||||
const url = App.Utils.Url.siteUrl('customers/search_by_phone');
|
const url = App.Utils.Url.siteUrl('customers/search_by_phone');
|
||||||
|
|
||||||
const data = {
|
const data = {
|
||||||
|
@ -189,26 +183,6 @@
|
||||||
document.getElementById('searchButton').addEventListener('click', function() {
|
document.getElementById('searchButton').addEventListener('click', function() {
|
||||||
|
|
||||||
doSearch();
|
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) {
|
function displayAppointments(appointments) {
|
||||||
|
@ -223,6 +197,10 @@
|
||||||
var serviceDiv = document.createElement('div');
|
var serviceDiv = document.createElement('div');
|
||||||
serviceDiv.textContent = `${appointment.service.name} - ${appointment.provider.last_name}${appointment.provider.first_name}`;
|
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
|
// 创建预约时间的 div
|
||||||
var timeDiv = document.createElement('div');
|
var timeDiv = document.createElement('div');
|
||||||
timeDiv.textContent = `開始時間:${appointment.start}`;
|
timeDiv.textContent = `開始時間:${appointment.start}`;
|
||||||
|
@ -237,6 +215,7 @@
|
||||||
|
|
||||||
// 将每个 div 添加到 li 中
|
// 将每个 div 添加到 li 中
|
||||||
listItem.appendChild(serviceDiv);
|
listItem.appendChild(serviceDiv);
|
||||||
|
// listItem.appendChild(nameDiv);
|
||||||
listItem.appendChild(timeDiv);
|
listItem.appendChild(timeDiv);
|
||||||
listItem.appendChild(endDiv);
|
listItem.appendChild(endDiv);
|
||||||
listItem.appendChild(statusDiv);
|
listItem.appendChild(statusDiv);
|
||||||
|
@ -277,6 +256,9 @@
|
||||||
listItem.appendChild(cancelButton);
|
listItem.appendChild(cancelButton);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var br = document.createElement('hr');
|
||||||
|
listItem.appendChild(br);
|
||||||
|
|
||||||
// 将 li 添加到 ul 或 ol 列表中
|
// 将 li 添加到 ul 或 ol 列表中
|
||||||
appointmentsList.appendChild(listItem);
|
appointmentsList.appendChild(listItem);
|
||||||
});
|
});
|
||||||
|
|
|
@ -651,16 +651,9 @@ App.Utils.CalendarDefaultView = (function () {
|
||||||
}),
|
}),
|
||||||
App.Utils.CalendarEventPopover.renderMapIcon(info.event.extendedProps.data.provider),
|
App.Utils.CalendarEventPopover.renderMapIcon(info.event.extendedProps.data.provider),
|
||||||
provider = 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/>', {
|
$('<span/>', {
|
||||||
'text': (function() {
|
'text': provider.last_name + provider.first_name,
|
||||||
if (isChineseName) {
|
|
||||||
return provider.last_name + provider.first_name;
|
|
||||||
} else {
|
|
||||||
return provider.first_name + ' ' + provider.last_name;
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
|
|
||||||
}),
|
}),
|
||||||
$('<br/>'),
|
$('<br/>'),
|
||||||
|
@ -670,9 +663,11 @@ App.Utils.CalendarDefaultView = (function () {
|
||||||
'text': lang('customer'),
|
'text': lang('customer'),
|
||||||
}),
|
}),
|
||||||
App.Utils.CalendarEventPopover.renderMapIcon(info.event.extendedProps.data.customer),
|
App.Utils.CalendarEventPopover.renderMapIcon(info.event.extendedProps.data.customer),
|
||||||
|
customer = info.event.extendedProps.data.customer,
|
||||||
|
|
||||||
$('<span/>', {
|
$('<span/>', {
|
||||||
'class': 'd-inline-block',
|
'class': 'd-inline-block',
|
||||||
'text': customerInfo.length ? customerInfo.join(' ') : '-',
|
'text': customerInfo.length ? customerInfo.reverse().join('') : '-',
|
||||||
}),
|
}),
|
||||||
$('<br/>'),
|
$('<br/>'),
|
||||||
|
|
||||||
|
@ -1210,7 +1205,7 @@ App.Utils.CalendarDefaultView = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (customerInfo.length) {
|
if (customerInfo.length) {
|
||||||
title.push(customerInfo.join(' '));
|
title.push(customerInfo.reverse().join(''));
|
||||||
}
|
}
|
||||||
|
|
||||||
const appointmentEvent = {
|
const appointmentEvent = {
|
||||||
|
|
|
@ -897,7 +897,7 @@ App.Utils.CalendarTableView = (function () {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (customerInfo.length) {
|
if (customerInfo.length) {
|
||||||
title.push(customerInfo.join(' '));
|
title.push(customerInfo.reverse().join(''));
|
||||||
}
|
}
|
||||||
|
|
||||||
calendarEvents.push({
|
calendarEvents.push({
|
||||||
|
@ -1396,7 +1396,7 @@ App.Utils.CalendarTableView = (function () {
|
||||||
}),
|
}),
|
||||||
App.Utils.CalendarEventPopover.renderMapIcon(info.event.extendedProps.data.customer),
|
App.Utils.CalendarEventPopover.renderMapIcon(info.event.extendedProps.data.customer),
|
||||||
$('<span/>', {
|
$('<span/>', {
|
||||||
'text': customerInfo.length ? customerInfo.join(' ') : '-',
|
'text': customerInfo.length ? customerInfo.reverse().join('') : '-',
|
||||||
}),
|
}),
|
||||||
$('<br/>'),
|
$('<br/>'),
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue