From 558554cd16c359be5cf8fdd6620f2b1293c8143e Mon Sep 17 00:00:00 2001 From: Zheng Zhi Ling Date: Wed, 11 May 2022 20:58:06 +0800 Subject: [PATCH 01/29] host db and model --- application/models/Host_model.php | 83 +++++++++++++++++++++++++++++++ sql/20220511_ea_host.sql | 15 ++++++ 2 files changed, 98 insertions(+) create mode 100644 application/models/Host_model.php create mode 100644 sql/20220511_ea_host.sql diff --git a/application/models/Host_model.php b/application/models/Host_model.php new file mode 100644 index 0000000000..9946d55fd1 --- /dev/null +++ b/application/models/Host_model.php @@ -0,0 +1,83 @@ +db->get_where('host', ['chinese_name' => $chinese_name])->num_rows() == 0) + { + // Check if setting exists in db. + throw new Exception('$chinese_name host does not exist in database: ' . $chinese_name); + } + + $query = $this->db->get_where('host', ['chinese_name' => $chinese_name]); + $host = $query->num_rows() > 0 ? $query->row() : ''; + $data = [ + 'chinese_name' => $chinese_name, + 'english_name' => $english_name, + 'url' => $url, + 'logo' => $logo, + 'description' => $description, + 'main_color' => $main_color, + 'secondary_color' => $secondary_color, + 'text_color' => $text_color + ]; + return $host -> $data; + } + + public function set_host($chinese_name, $english_name, $url, $logo, $description, $main_color, $secondary_color, $text_color) + { + if ( ! is_string($chinese_name)) + { + throw new Exception('$chinese_name argument is not a string: ' . $chinese_name); + } + + $query = $this->db->get_where('host', ['chinese_name' => $chinese_name]); + + if ($query->num_rows() > 0) + { + // Update setting + if ( ! $this->db->update('host', ['text_color' => $text_color], ['secondary_color' => $secondary_color], + ['main_color' => $main_color], ['description' => $description], ['logo' => $logo], + ['url' => $url], ['english_name' => $english_name], ['chinese_name' => $chinese_name])) + { + throw new Exception('Could not update database host.'); + } + $host_id = (int)$this->db->get_where('host', ['chinese_name' => $$chinese_name])->row()->id; + } + else + { + // Insert setting + $insert_data = [ + 'chinese_name' => $chinese_name, + 'english_name' => $english_name, + 'url' => $url, + 'logo' => $logo, + 'description' => $description, + 'main_color' => $main_color, + 'secondary_color' => $secondary_color, + 'text_color' => $text_color + ]; + + if ( ! $this->db->insert('host', $insert_data)) + { + throw new Exception('Could not insert database host'); + } + + $host_id = (int)$this->db->insert_id(); + } + + return $host_id; + } + + public function get_hosts() + { + return $this->db->get('host')->result_array(); + } +} \ No newline at end of file diff --git a/sql/20220511_ea_host.sql b/sql/20220511_ea_host.sql new file mode 100644 index 0000000000..fa3900426f --- /dev/null +++ b/sql/20220511_ea_host.sql @@ -0,0 +1,15 @@ +CREATE TABLE `ea_host` ( + `id` int(11) unsigned NOT NULL AUTO_INCREMENT, + `chinese_name` varchar(256) DEFAULT NULL, + `english_name` varchar(256) DEFAULT NULL, + `url` varchar(256) DEFAULT NULL, + `logo` varchar(256) DEFAULT NULL, + `description` varchar(256) DEFAULT '', + `main_color` varchar(32) DEFAULT NULL, + `secondary_color` varchar(32) DEFAULT NULL, + `text_color` varchar(32) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + +INSERT INTO `ea_host` (`id`, `chinese_name`, `english_name`, `url`, `logo`, `description`, `main_color`, `secondary_color`, `text_color`) + VALUES ('1', '車友趣', 'car2dude', 'https://www.car2dude.com/', 'https://reserve.car2dude.com/assets/img/logo.png', '車輛保養維修最佳夥伴', '#ff7e35', NULL, NULL); \ No newline at end of file From 72f8835143ce62ea1e98d9cd5661c51cf2a97471 Mon Sep 17 00:00:00 2001 From: Zheng Zhi Ling Date: Wed, 11 May 2022 22:26:57 +0800 Subject: [PATCH 02/29] host db and model_2 --- application/models/Host_model.php | 56 +++++++++++-------------------- sql/20220511_ea_host.sql | 22 ++++++------ 2 files changed, 30 insertions(+), 48 deletions(-) diff --git a/application/models/Host_model.php b/application/models/Host_model.php index 9946d55fd1..d838de0e25 100644 --- a/application/models/Host_model.php +++ b/application/models/Host_model.php @@ -2,67 +2,49 @@ class Host_model extends EA_Model { - public function get_host($chinese_name) + public function get_host($name) { - if ( ! is_string($chinese_name)) + if ( ! is_string($name)) { // Check argument type. - throw new Exception('$chinese_name argument is not a string: ' . $chinese_name); + throw new Exception('$name argument is not a string: ' . $name); } - if ($this->db->get_where('host', ['chinese_name' => $chinese_name])->num_rows() == 0) + if ($this->db->get_where('host', ['name' => $name])->num_rows() == 0) { - // Check if setting exists in db. - throw new Exception('$chinese_name host does not exist in database: ' . $chinese_name); + // Check if host exists in db. + throw new Exception('$name host does not exist in database: ' . $name); } - $query = $this->db->get_where('host', ['chinese_name' => $chinese_name]); + $query = $this->db->get_where('host', ['name' => $name]); $host = $query->num_rows() > 0 ? $query->row() : ''; - $data = [ - 'chinese_name' => $chinese_name, - 'english_name' => $english_name, - 'url' => $url, - 'logo' => $logo, - 'description' => $description, - 'main_color' => $main_color, - 'secondary_color' => $secondary_color, - 'text_color' => $text_color - ]; - return $host -> $data; + return $host->value; } - public function set_host($chinese_name, $english_name, $url, $logo, $description, $main_color, $secondary_color, $text_color) + public function set_host($name, $value) { - if ( ! is_string($chinese_name)) + if ( ! is_string($name)) { - throw new Exception('$chinese_name argument is not a string: ' . $chinese_name); + throw new Exception('$name argument is not a string: ' . $name); } - $query = $this->db->get_where('host', ['chinese_name' => $chinese_name]); + $query = $this->db->get_where('host', ['name' => $name]); if ($query->num_rows() > 0) { - // Update setting - if ( ! $this->db->update('host', ['text_color' => $text_color], ['secondary_color' => $secondary_color], - ['main_color' => $main_color], ['description' => $description], ['logo' => $logo], - ['url' => $url], ['english_name' => $english_name], ['chinese_name' => $chinese_name])) + // Update host + if ( ! $this->db->update('host', ['value' => $value], ['name' => $name])) { throw new Exception('Could not update database host.'); } - $host_id = (int)$this->db->get_where('host', ['chinese_name' => $$chinese_name])->row()->id; + $host_id = (int)$this->db->get_where('host', ['name' => $name])->row()->id; } else { - // Insert setting + // Insert host $insert_data = [ - 'chinese_name' => $chinese_name, - 'english_name' => $english_name, - 'url' => $url, - 'logo' => $logo, - 'description' => $description, - 'main_color' => $main_color, - 'secondary_color' => $secondary_color, - 'text_color' => $text_color + 'name' => $name, + 'value' => $value ]; if ( ! $this->db->insert('host', $insert_data)) @@ -78,6 +60,6 @@ public function set_host($chinese_name, $english_name, $url, $logo, $description public function get_hosts() { - return $this->db->get('host')->result_array(); + return $this->db->get('hosts')->result_array(); } } \ No newline at end of file diff --git a/sql/20220511_ea_host.sql b/sql/20220511_ea_host.sql index fa3900426f..c84b4facec 100644 --- a/sql/20220511_ea_host.sql +++ b/sql/20220511_ea_host.sql @@ -1,15 +1,15 @@ CREATE TABLE `ea_host` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, - `chinese_name` varchar(256) DEFAULT NULL, - `english_name` varchar(256) DEFAULT NULL, - `url` varchar(256) DEFAULT NULL, - `logo` varchar(256) DEFAULT NULL, - `description` varchar(256) DEFAULT '', - `main_color` varchar(32) DEFAULT NULL, - `secondary_color` varchar(32) DEFAULT NULL, - `text_color` varchar(32) DEFAULT NULL, + `name` varchar(256) DEFAULT NULL, + `value` varchar(256) DEFAULT NULL, PRIMARY KEY (`id`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4; -INSERT INTO `ea_host` (`id`, `chinese_name`, `english_name`, `url`, `logo`, `description`, `main_color`, `secondary_color`, `text_color`) - VALUES ('1', '車友趣', 'car2dude', 'https://www.car2dude.com/', 'https://reserve.car2dude.com/assets/img/logo.png', '車輛保養維修最佳夥伴', '#ff7e35', NULL, NULL); \ No newline at end of file +INSERT INTO `ea_host` (`id`, `name`, `value`) VALUES ('1', 'chinese_name', '車友趣'); +INSERT INTO `ea_host` (`id`, `name`, `value`) VALUES ('2', 'english_name', 'car2dude'); +INSERT INTO `ea_host` (`id`, `name`, `value`) VALUES ('3', 'url', 'https://www.car2dude.com/'); +INSERT INTO `ea_host` (`id`, `name`, `value`) VALUES ('4', 'logo', 'https://reserve.car2dude.com/assets/img/logo.png'); +INSERT INTO `ea_host` (`id`, `name`, `value`) VALUES ('5', 'description', '車輛保養維修最佳夥伴'); +INSERT INTO `ea_host` (`id`, `name`, `value`) VALUES ('6', 'main_color', '#ff7e35'); +INSERT INTO `ea_host` (`id`, `name`, `value`) VALUES ('7', 'secondary_color', NULL); +INSERT INTO `ea_host` (`id`, `name`, `value`) VALUES ('8', 'logo', NULL); \ No newline at end of file From 13d82886da099bb70590f0b2b31bb2b0fd9689c0 Mon Sep 17 00:00:00 2001 From: Zheng Zhi Ling Date: Wed, 11 May 2022 22:58:07 +0800 Subject: [PATCH 03/29] appointment frame-footer replace host-data --- application/controllers/Appointments.php | 17 +++++++++++++++++ application/views/appointments/book.php | 2 +- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/application/controllers/Appointments.php b/application/controllers/Appointments.php index 5489b2c762..3624675a13 100755 --- a/application/controllers/Appointments.php +++ b/application/controllers/Appointments.php @@ -35,6 +35,7 @@ public function __construct() $this->load->model('services_model'); $this->load->model('customers_model'); $this->load->model('settings_model'); + $this->load->model('host_model'); $this->load->library('timezones'); $this->load->library('synchronization'); $this->load->library('notifications'); @@ -79,6 +80,14 @@ public function index($appointment_hash = '') $privacy_policy_content = $this->settings_model->get_setting('privacy_policy_content'); $display_any_provider = $this->settings_model->get_setting('display_any_provider'); $timezones = $this->timezones->to_array(); + $chinese_name = $this->host_model->get_host('chinese_name'); + $english_name = $this->host_model->get_host('english_name'); + $url = $this->host_model->get_host('url'); + $logo = $this->host_model->get_host('logo'); + $description = $this->host_model->get_host('description'); + $main_color = $this->host_model->get_host('main_color'); + $secondary_color = $this->host_model->get_host('secondary_color'); + $text_color = $this->host_model->get_host('text_color'); // Remove the data that are not needed inside the $available_providers array. foreach ($available_providers as $index => $provider) @@ -182,6 +191,14 @@ public function index($appointment_hash = '') 'privacy_policy_content' => $privacy_policy_content, 'timezones' => $timezones, 'display_any_provider' => $display_any_provider, + 'chinese_name' => $chinese_name, + 'english_name' => $english_name, + 'url' => $url, + 'logo' => $logo, + 'description' => $description, + 'main_color' => $main_color, + 'secondary_color' => $secondary_color, + 'text_color' => $text_color ]; } catch (Exception $exception) diff --git a/application/views/appointments/book.php b/application/views/appointments/book.php index b0918f1aa0..e401909c97 100755 --- a/application/views/appointments/book.php +++ b/application/views/appointments/book.php @@ -354,7 +354,7 @@ class="btn btn-danger btn-sm"> Copyright - © 2020 車友趣 + © 2020 車友趣 All rights reserved. From 3306ae7c0edb01afcebc9253384e2182b80d2fff Mon Sep 17 00:00:00 2001 From: Zheng Zhi Ling Date: Thu, 12 May 2022 02:01:39 +0800 Subject: [PATCH 04/29] appointment css_background replace main_color --- application/views/appointments/book.php | 10 ++++++---- assets/css/frontend.css | 6 ++---- assets/js/frontend_book.js | 3 ++- 3 files changed, 10 insertions(+), 9 deletions(-) diff --git a/application/views/appointments/book.php b/application/views/appointments/book.php index e401909c97..32cc467d0b 100755 --- a/application/views/appointments/book.php +++ b/application/views/appointments/book.php @@ -338,7 +338,8 @@ class="btn btn-danger btn-sm">
- @@ -350,11 +351,11 @@ class="btn btn-danger btn-sm"> -