41 lines
1.2 KiB
PHP
Executable File
41 lines
1.2 KiB
PHP
Executable File
<?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']);
|
|
}
|
|
}
|
|
|
|
}
|