From 6c3378f446304976cddf9ec1d5577442d44eb4d3 Mon Sep 17 00:00:00 2001 From: Jay Huang Date: Mon, 2 Sep 2024 23:13:54 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A2=84=E7=BA=A6=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E4=BB=A5=E5=8F=8A=E5=90=8E=E5=8F=B0=E9=A2=84=E7=BA=A6?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=B8=AD=E6=96=87=E5=90=8D=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/models/Appointments_model.php | 9 +++- .../views/layouts/home_directions_layout.php | 1 - .../views/layouts/home_search_layout.php | 54 +++++++------------ assets/js/utils/calendar_default_view.js | 15 ++---- assets/js/utils/calendar_table_view.js | 4 +- 5 files changed, 32 insertions(+), 51 deletions(-) diff --git a/application/models/Appointments_model.php b/application/models/Appointments_model.php index 5c4d9052..dc77ff61 100755 --- a/application/models/Appointments_model.php +++ b/application/models/Appointments_model.php @@ -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(); diff --git a/application/views/layouts/home_directions_layout.php b/application/views/layouts/home_directions_layout.php index 06e132a2..aeba9c47 100755 --- a/application/views/layouts/home_directions_layout.php +++ b/application/views/layouts/home_directions_layout.php @@ -26,7 +26,6 @@ - vars('company_color')]); ?> diff --git a/application/views/layouts/home_search_layout.php b/application/views/layouts/home_search_layout.php index 1e75b471..0289d138 100755 --- a/application/views/layouts/home_search_layout.php +++ b/application/views/layouts/home_search_layout.php @@ -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'), ]); ?>
-

查询预约信息

+

查詢預約信息

- - + +
-

预约结果

+

已預約資訊

    - 未找到预约信息。 + 暫未檢索到預約資訊。
    - - - vars('display_login_button')]); ?> - + vars('display_login_button')]); ?> + - 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); }); diff --git a/assets/js/utils/calendar_default_view.js b/assets/js/utils/calendar_default_view.js index 09a5c6d3..d8ed2811 100755 --- a/assets/js/utils/calendar_default_view.js +++ b/assets/js/utils/calendar_default_view.js @@ -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), $('', { - '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, }), $('
    '), @@ -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, + $('', { 'class': 'd-inline-block', - 'text': customerInfo.length ? customerInfo.join(' ') : '-', + 'text': customerInfo.length ? customerInfo.reverse().join('') : '-', }), $('
    '), @@ -1210,7 +1205,7 @@ App.Utils.CalendarDefaultView = (function () { } if (customerInfo.length) { - title.push(customerInfo.join(' ')); + title.push(customerInfo.reverse().join('')); } const appointmentEvent = { diff --git a/assets/js/utils/calendar_table_view.js b/assets/js/utils/calendar_table_view.js index 25d6582b..9d631ddf 100755 --- a/assets/js/utils/calendar_table_view.js +++ b/assets/js/utils/calendar_table_view.js @@ -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), $('', { - 'text': customerInfo.length ? customerInfo.join(' ') : '-', + 'text': customerInfo.length ? customerInfo.reverse().join('') : '-', }), $('
    '),