From 0a4d281e6983f28b6cfbd19a2d8f807f3ef5c8d9 Mon Sep 17 00:00:00 2001 From: Jay Huang Date: Mon, 12 Aug 2024 15:16:14 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=98=BE=E7=A4=BAlogo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- application/controllers/AppointmentSearch.php | 54 ++++++++++++++++++ application/models/Appointments_model.php | 8 +++ application/models/Users_model.php | 8 +++ .../views/components/booking_footer.php | 3 + .../views/components/home_contact_header.php | 2 +- application/views/components/home_header.php | 2 +- .../views/components/home_price_header.php | 2 +- .../views/components/home_search_header.php | 2 +- .../views/layouts/home_search_layout.php | 11 ++-- assets/img/logo.png | Bin 11052 -> 131717 bytes assets/img/logo_bak.png | Bin 0 -> 11052 bytes 11 files changed, 83 insertions(+), 9 deletions(-) create mode 100644 application/controllers/AppointmentSearch.php mode change 100755 => 100644 assets/img/logo.png create mode 100755 assets/img/logo_bak.png diff --git a/application/controllers/AppointmentSearch.php b/application/controllers/AppointmentSearch.php new file mode 100644 index 00000000..3fda4d63 --- /dev/null +++ b/application/controllers/AppointmentSearch.php @@ -0,0 +1,54 @@ +load->model('users_model'); + $this->load->model('appointments_model'); + } + + /** + * Search appointments by phone number. + */ + public function search_by_phone(): void + { + try { + $phone_number = request('phone_number', ''); + + if (empty($phone_number)) { + json_response([ + 'success' => false, + 'message' => 'Phone number is required.' + ]); + return; + } + + // 查询ea_users表中id_roles为3的用户ID + $user = $this->users_model->get_user_by_phone($phone_number, 3); + + if (!$user) { + json_response([ + 'success' => false, + 'message' => 'No user found with this phone number.' + ]); + return; + } + + // 用用户ID查询ea_appointments表中的记录 + $appointments = $this->appointments_model->get_appointments_by_user_id($user->id); + + json_response([ + 'success' => true, + 'appointments' => $appointments + ]); + } catch (Throwable $e) { + json_exception($e); + } + } +} \ No newline at end of file diff --git a/application/models/Appointments_model.php b/application/models/Appointments_model.php index 6c4644c1..7d84f5f0 100755 --- a/application/models/Appointments_model.php +++ b/application/models/Appointments_model.php @@ -628,4 +628,12 @@ class Appointments_model extends EA_Model $appointment = $decoded_request; } + + + public function get_appointments_by_user_id($user_id) + { + return $this->db->where('id_users_customer', $user_id) + ->get('ea_appointments') + ->result(); + } } diff --git a/application/models/Users_model.php b/application/models/Users_model.php index 3606b662..9d4b7c2a 100755 --- a/application/models/Users_model.php +++ b/application/models/Users_model.php @@ -430,4 +430,12 @@ class Users_model extends EA_Model return $this->db->get_where('user_settings', ['username' => $username])->num_rows() === 0; } + + public function get_user_by_phone($phone_number, $role_id) + { + return $this->db->where('phone', $phone_number) + ->where('id_roles', $role_id) + ->get('ea_users') + ->row(); + } } diff --git a/application/views/components/booking_footer.php b/application/views/components/booking_footer.php index 19f5ce6a..c4bc49cd 100755 --- a/application/views/components/booking_footer.php +++ b/application/views/components/booking_footer.php @@ -8,7 +8,10 @@