处理预约查询
This commit is contained in:
parent
f3b15a4948
commit
927b38842f
|
@ -52,4 +52,29 @@ class Home_search extends EA_Controller
|
||||||
$this->load->view('pages/home_search');
|
$this->load->view('pages/home_search');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function search_by_phone()
|
||||||
|
{
|
||||||
|
// 从POST请求中获取电话号码
|
||||||
|
$input = json_decode(file_get_contents('php://input'), true);
|
||||||
|
$phoneNumber = isset($input['phone_number']) ? $input['phone_number'] : '';
|
||||||
|
|
||||||
|
if (empty($phoneNumber)) {
|
||||||
|
// 返回错误信息
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Invalid phone number']);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询数据库中的预约信息
|
||||||
|
$this->load->model('appointments_model');
|
||||||
|
$appointments = $this->Appointment_model->get_appointments_by_phone($phoneNumber);
|
||||||
|
|
||||||
|
if (!empty($appointments)) {
|
||||||
|
// 返回预约信息
|
||||||
|
echo json_encode(['success' => true, 'appointments' => $appointments]);
|
||||||
|
} else {
|
||||||
|
// 如果没有找到预约信息
|
||||||
|
echo json_encode(['success' => false, 'message' => 'No appointments found']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,40 @@
|
||||||
|
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Home Page controller.
|
||||||
|
*
|
||||||
|
* @package Controllers
|
||||||
|
*/
|
||||||
|
class Home_search_phone extends EA_Controller
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Render the booking page.
|
||||||
|
*
|
||||||
|
* This method creates the appointment book wizard.
|
||||||
|
*/
|
||||||
|
public function search_by_phone()
|
||||||
|
{
|
||||||
|
// 从POST请求中获取电话号码
|
||||||
|
$input = json_decode(file_get_contents('php://input'), true);
|
||||||
|
$phoneNumber = isset($input['phone_number']) ? $input['phone_number'] : '';
|
||||||
|
|
||||||
|
if (empty($phoneNumber)) {
|
||||||
|
// 返回错误信息
|
||||||
|
echo json_encode(['success' => false, 'message' => 'Invalid phone number']);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 查询数据库中的预约信息
|
||||||
|
$this->load->model('Appointment_model');
|
||||||
|
$appointments = $this->Appointment_model->get_appointments_by_phone($phoneNumber);
|
||||||
|
|
||||||
|
if (!empty($appointments)) {
|
||||||
|
// 返回预约信息
|
||||||
|
echo json_encode(['success' => true, 'appointments' => $appointments]);
|
||||||
|
} else {
|
||||||
|
// 如果没有找到预约信息
|
||||||
|
echo json_encode(['success' => false, 'message' => 'No appointments found']);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -497,4 +497,5 @@ $lang['search_appointments_title'] = '预约查询';
|
||||||
$lang['enter_phone_number'] = '输入预约时提交的电话号码';
|
$lang['enter_phone_number'] = '输入预约时提交的电话号码';
|
||||||
$lang['search_button'] = '查询';
|
$lang['search_button'] = '查询';
|
||||||
$lang['no_appointments_message'] = '暂无预约信息';
|
$lang['no_appointments_message'] = '暂无预约信息';
|
||||||
|
$lang['enter_valid_phone_number'] = '请输入有效电话号';
|
||||||
// End
|
// End
|
||||||
|
|
|
@ -497,4 +497,5 @@ $lang['search_appointments_title'] = '預約查詢';
|
||||||
$lang['enter_phone_number'] = '輸入預約時提交的電話號碼';
|
$lang['enter_phone_number'] = '輸入預約時提交的電話號碼';
|
||||||
$lang['search_button'] = '查詢';
|
$lang['search_button'] = '查詢';
|
||||||
$lang['no_appointments_message'] = '暫無預約記錄';
|
$lang['no_appointments_message'] = '暫無預約記錄';
|
||||||
|
$lang['enter_valid_phone_number'] = '請輸入有效電話號碼';
|
||||||
// End
|
// End
|
||||||
|
|
|
@ -497,4 +497,5 @@ $lang['search_appointments_title'] = 'Enquiry';
|
||||||
$lang['enter_phone_number'] = 'Enter Phone Number';
|
$lang['enter_phone_number'] = 'Enter Phone Number';
|
||||||
$lang['search_button'] = 'Search';
|
$lang['search_button'] = 'Search';
|
||||||
$lang['no_appointments_message'] = 'No Appointments Found';
|
$lang['no_appointments_message'] = 'No Appointments Found';
|
||||||
|
$lang['enter_valid_phone_number'] = 'Please enter a valid phone number';
|
||||||
// End
|
// End
|
||||||
|
|
|
@ -636,4 +636,30 @@ class Appointments_model extends EA_Model
|
||||||
->get('ea_appointments')
|
->get('ea_appointments')
|
||||||
->result();
|
->result();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function get_appointments_by_phone(string $phone_number, int $limit = null, int $offset = null, string $order_by = null): array
|
||||||
|
{
|
||||||
|
$appointments = $this->db
|
||||||
|
->select('appointments.*')
|
||||||
|
->from('appointments')
|
||||||
|
->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)
|
||||||
|
->group_start()
|
||||||
|
->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点之前的预约
|
||||||
|
->limit($limit)
|
||||||
|
->offset($offset)
|
||||||
|
->order_by($order_by)
|
||||||
|
->get()
|
||||||
|
->result_array();
|
||||||
|
|
||||||
|
foreach ($appointments as &$appointment) {
|
||||||
|
$this->api_encode($appointment);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $appointments;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,8 @@
|
||||||
var map = new AMap.Map('map-container', {
|
var map = new AMap.Map('map-container', {
|
||||||
resizeEnable: true,
|
resizeEnable: true,
|
||||||
center: [114.124435,22.369331], // 设置中心点坐标为荃湾地区
|
center: [114.124435,22.369331], // 设置中心点坐标为荃湾地区
|
||||||
zoom: 18 // 地图缩放级别
|
zoom: 18, // 地图缩放级别
|
||||||
|
lang: 'zh_tw'
|
||||||
});
|
});
|
||||||
|
|
||||||
var marker = new AMap.Marker({
|
var marker = new AMap.Marker({
|
||||||
|
|
|
@ -154,10 +154,11 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
fetch('/index.php/appointmentsearch/search_by_phone', {
|
fetch('/index.php/home_search/search_by_phone', {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json',
|
||||||
|
'X-CSRF-TOKEN': '<?= csrf_hash() ?>' // 添加 CSRF 令牌
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ phone_number: phoneNumber })
|
body: JSON.stringify({ phone_number: phoneNumber })
|
||||||
})
|
})
|
||||||
|
|
|
@ -0,0 +1,236 @@
|
||||||
|
<?php extend('layouts/backend_layout'); ?>
|
||||||
|
|
||||||
|
<?php section('content'); ?>
|
||||||
|
|
||||||
|
<div class="container-fluid backend-page" id="customers-page">
|
||||||
|
<div class="row" id="customers">
|
||||||
|
<div id="filter-customers" class="filter-records col col-12 col-md-5">
|
||||||
|
<form class="mb-4">
|
||||||
|
<div class="input-group mb-3">
|
||||||
|
<input type="text" class="key form-control" aria-label="keyword">
|
||||||
|
|
||||||
|
<button class="filter btn btn-outline-secondary" type="submit"
|
||||||
|
data-tippy-content="<?= lang('filter') ?>">
|
||||||
|
<i class="fas fa-search"></i>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<h4 class="text-black-50 mb-3 fw-light">
|
||||||
|
<?= lang('customers') ?>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
<?php slot('after_page_title'); ?>
|
||||||
|
|
||||||
|
<div class="results">
|
||||||
|
<!-- JS -->
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="record-details col-12 col-md-7">
|
||||||
|
<div class="btn-toolbar mb-4">
|
||||||
|
<div id="add-edit-delete-group" class="btn-group">
|
||||||
|
<?php if (
|
||||||
|
can('add', PRIV_CUSTOMERS) &&
|
||||||
|
(!setting('limit_customer_access') || vars('role_slug') === DB_SLUG_ADMIN)
|
||||||
|
): ?>
|
||||||
|
<button id="add-customer" class="btn btn-primary">
|
||||||
|
<i class="fas fa-plus-square me-2"></i>
|
||||||
|
<?= lang('add') ?>
|
||||||
|
</button>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if (can('edit', PRIV_CUSTOMERS)): ?>
|
||||||
|
<button id="edit-customer" class="btn btn-outline-secondary" disabled="disabled">
|
||||||
|
<i class="fas fa-edit me-2"></i>
|
||||||
|
<?= lang('edit') ?>
|
||||||
|
</button>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php if (can('delete', PRIV_CUSTOMERS)): ?>
|
||||||
|
<button id="delete-customer" class="btn btn-outline-secondary" disabled="disabled">
|
||||||
|
<i class="fas fa-trash-alt me-2"></i>
|
||||||
|
<?= lang('delete') ?>
|
||||||
|
</button>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="save-cancel-group" style="display:none;">
|
||||||
|
<button id="save-customer" class="btn btn-primary">
|
||||||
|
<i class="fas fa-check-square me-2"></i>
|
||||||
|
<?= lang('save') ?>
|
||||||
|
</button>
|
||||||
|
<button id="cancel-customer" class="btn btn-secondary">
|
||||||
|
<?= lang('cancel') ?>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php slot('after_page_actions'); ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<input id="customer-id" type="hidden">
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-12 col-md-6" style="margin-left: 0;">
|
||||||
|
<h4 class="text-black-50 mb-3 fw-light">
|
||||||
|
<?= lang('details') ?>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
<div id="form-message" class="alert" style="display:none;"></div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="first-name" class="form-label">
|
||||||
|
<?= lang('first_name') ?>
|
||||||
|
<?php if (vars('require_first_name')): ?>
|
||||||
|
<span class="text-danger" hidden>*</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</label>
|
||||||
|
<input type="text" id="first-name"
|
||||||
|
class="<?= vars('require_first_name') ? 'required' : '' ?> form-control" maxlength="100"
|
||||||
|
disabled/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="last-name" class="form-label">
|
||||||
|
<?= lang('last_name') ?>
|
||||||
|
<?php if (vars('require_last_name')): ?>
|
||||||
|
<span class="text-danger" hidden>*</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</label>
|
||||||
|
<input type="text" id="last-name"
|
||||||
|
class="<?= vars('require_last_name') ? 'required' : '' ?> form-control" maxlength="120"
|
||||||
|
disabled/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="email" class="form-label">
|
||||||
|
<?= lang('email') ?>
|
||||||
|
<?php if (vars('require_email')): ?>
|
||||||
|
<span class="text-danger" hidden>*</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</label>
|
||||||
|
<input type="text" id="email"
|
||||||
|
class="<?= vars('require_email') ? 'required' : '' ?> form-control" maxlength="120"
|
||||||
|
disabled/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="phone-number" class="form-label">
|
||||||
|
<?= lang('phone_number') ?>
|
||||||
|
<?php if (vars('require_phone_number')): ?>
|
||||||
|
<span class="text-danger" hidden>*</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</label>
|
||||||
|
<input type="text" id="phone-number" maxlength="60"
|
||||||
|
class="<?= vars('require_phone_number') ? 'required' : '' ?> form-control" disabled/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="address" class="form-label">
|
||||||
|
<?= lang('address') ?>
|
||||||
|
<?php if (vars('require_address')): ?>
|
||||||
|
<span class="text-danger" hidden>*</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</label>
|
||||||
|
<input type="text" id="address"
|
||||||
|
class="<?= vars('require_address') ? 'required' : '' ?> form-control"
|
||||||
|
maxlength="120" disabled/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="city" class="form-label">
|
||||||
|
<?= lang('city') ?>
|
||||||
|
<?php if (vars('require_city')): ?>
|
||||||
|
<span class="text-danger" hidden>*</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</label>
|
||||||
|
<input type="text" id="city" class="<?= vars('require_city') ? 'required' : '' ?> form-control"
|
||||||
|
maxlength="120" disabled/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="zip-code" class="form-label">
|
||||||
|
<?= lang('zip_code') ?>
|
||||||
|
<?php if (vars('require_zip_code')): ?>
|
||||||
|
<span class="text-danger" hidden>*</span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</label>
|
||||||
|
<input type="text" id="zip-code"
|
||||||
|
class="<?= vars('require_zip_code') ? 'required' : '' ?> form-control"
|
||||||
|
maxlength="120" disabled/>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label" for="language">
|
||||||
|
<?= lang('language') ?>
|
||||||
|
<span class="text-danger" hidden>*</span>
|
||||||
|
</label>
|
||||||
|
<select id="language" class="form-select required" disabled>
|
||||||
|
<?php foreach (vars('available_languages') as $available_language): ?>
|
||||||
|
<option value="<?= $available_language ?>">
|
||||||
|
<?= ucfirst($available_language) ?>
|
||||||
|
</option>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label" for="timezone">
|
||||||
|
<?= lang('timezone') ?>
|
||||||
|
<span class="text-danger" hidden>*</span>
|
||||||
|
</label>
|
||||||
|
<?php component('timezone_dropdown', [
|
||||||
|
'attributes' => 'id="timezone" class="form-control required" disabled',
|
||||||
|
'grouped_timezones' => vars('grouped_timezones'),
|
||||||
|
]); ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if (setting('ldap_is_active')): ?>
|
||||||
|
<div class="mb-3">
|
||||||
|
<label for="ldap-dn" class="form-label">
|
||||||
|
<?= lang('ldap_dn') ?>
|
||||||
|
</label>
|
||||||
|
<input type="text" id="ldap-dn" class="form-control" maxlength="100" disabled/>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
|
<?php component('custom_fields', [
|
||||||
|
'disabled' => true,
|
||||||
|
]); ?>
|
||||||
|
|
||||||
|
<div class="mb-3">
|
||||||
|
<label class="form-label" for="notes">
|
||||||
|
<?= lang('notes') ?>
|
||||||
|
</label>
|
||||||
|
<textarea id="notes" rows="4" class="form-control" disabled></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php slot('after_primary_fields'); ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="col-12 col-md-6">
|
||||||
|
<h4 class="text-black-50 mb-3 fw-light">
|
||||||
|
<?= lang('appointments') ?>
|
||||||
|
</h4>
|
||||||
|
|
||||||
|
<div id="customer-appointments" class="card bg-white border"></div>
|
||||||
|
|
||||||
|
<?php slot('after_secondary_fields'); ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php end_section('content'); ?>
|
||||||
|
|
||||||
|
<?php section('scripts'); ?>
|
||||||
|
|
||||||
|
<script src="<?= asset_url('assets/js/utils/date.js') ?>"></script>
|
||||||
|
<script src="<?= asset_url('assets/js/utils/message.js') ?>"></script>
|
||||||
|
<script src="<?= asset_url('assets/js/utils/validation.js') ?>"></script>
|
||||||
|
<script src="<?= asset_url('assets/js/utils/url.js') ?>"></script>
|
||||||
|
<script src="<?= asset_url('assets/js/http/customers_http_client.js') ?>"></script>
|
||||||
|
<script src="<?= asset_url('assets/js/pages/customers.js') ?>"></script>
|
||||||
|
|
||||||
|
<?php end_section('scripts'); ?>
|
Loading…
Reference in New Issue