81 lines
2.7 KiB
PHP
Executable File
81 lines
2.7 KiB
PHP
Executable File
<?php defined('BASEPATH') or exit('No direct script access allowed');
|
|
|
|
/**
|
|
* Home Page controller.
|
|
*
|
|
* @package Controllers
|
|
*/
|
|
class Home_search extends EA_Controller
|
|
{
|
|
/**
|
|
* Render the booking page.
|
|
*
|
|
* This method creates the appointment book wizard.
|
|
*/
|
|
public function index(): void
|
|
{
|
|
if (!is_app_installed()) {
|
|
redirect('installation');
|
|
|
|
return;
|
|
}
|
|
|
|
$company_name = setting('company_name');
|
|
$company_logo = setting('company_logo');
|
|
$company_color = setting('company_color');
|
|
$google_analytics_code = setting('google_analytics_code');
|
|
$matomo_analytics_url = setting('matomo_analytics_url');
|
|
$matomo_analytics_site_id = setting('matomo_analytics_site_id');
|
|
$display_login_button = setting('display_login_button');
|
|
$theme = request('theme', setting('theme', 'default'));
|
|
|
|
if (empty($theme) || !file_exists(__DIR__ . '/../../assets/css/themes/' . $theme . '.min.css')) {
|
|
$theme = 'default';
|
|
}
|
|
|
|
script_vars([
|
|
'future_booking_limit' => setting('future_booking_limit'),
|
|
'default_language' => setting('default_language'),
|
|
]);
|
|
|
|
html_vars([
|
|
'theme' => $theme,
|
|
'company_name' => $company_name,
|
|
'company_logo' => $company_logo,
|
|
'company_color' => $company_color === '#ffffff' ? '' : $company_color,
|
|
'display_login_button' => $display_login_button,
|
|
'google_analytics_code' => $google_analytics_code,
|
|
'matomo_analytics_url' => $matomo_analytics_url,
|
|
'matomo_analytics_site_id' => $matomo_analytics_site_id,
|
|
]);
|
|
|
|
$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']);
|
|
}
|
|
}
|
|
|
|
}
|