diff --git a/application/controllers/Booking.php b/application/controllers/Booking.php index 1822a434..66c1d9ce 100755 --- a/application/controllers/Booking.php +++ b/application/controllers/Booking.php @@ -86,8 +86,8 @@ class Booking extends EA_Controller { return; } - $available_services = $this->services_model->get_available_services(); - $available_providers = $this->providers_model->get_available_providers(); + $available_services = $this->services_model->get_available_services(TRUE); + $available_providers = $this->providers_model->get_available_providers(TRUE); foreach ($available_providers as &$available_provider) { @@ -224,7 +224,7 @@ class Booking extends EA_Controller { 'available_providers' => $available_providers, 'company_name' => $company_name, 'company_logo' => $company_logo, - 'company_color' => $company_color, + 'company_color' => $company_color === '#ffffff' ? '' : $company_color, 'date_format' => $date_format, 'time_format' => $time_format, 'first_weekday' => $first_weekday, @@ -364,7 +364,7 @@ class Booking extends EA_Controller { */ protected function search_any_provider(int $service_id, string $date, string $hour = NULL): ?int { - $available_providers = $this->providers_model->get_available_providers(); + $available_providers = $this->providers_model->get_available_providers(TRUE); $service = $this->services_model->find($service_id); @@ -652,7 +652,7 @@ class Booking extends EA_Controller { */ protected function search_providers_by_service(int $service_id): array { - $available_providers = $this->providers_model->get_available_providers(); + $available_providers = $this->providers_model->get_available_providers(TRUE); $provider_list = []; foreach ($available_providers as $provider) diff --git a/application/controllers/Calendar.php b/application/controllers/Calendar.php index 7fc4a6ba..7773796f 100644 --- a/application/controllers/Calendar.php +++ b/application/controllers/Calendar.php @@ -99,8 +99,8 @@ class Calendar extends EA_Controller { $available_providers = $this->providers_model->get_available_providers(); $available_services = $this->services_model->get_available_services(); - - $calendar_view = request('view', $user['settings']['calendar_view']); + + $calendar_view = request('view', $user['settings']['calendar_view']); script_vars([ 'user_id' => $user_id, diff --git a/application/language/arabic/translations_lang.php b/application/language/arabic/translations_lang.php index e3ab44cb..629a1687 100755 --- a/application/language/arabic/translations_lang.php +++ b/application/language/arabic/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/bulgarian/translations_lang.php b/application/language/bulgarian/translations_lang.php index 9b7360c6..05f944a5 100755 --- a/application/language/bulgarian/translations_lang.php +++ b/application/language/bulgarian/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/catalan/translations_lang.php b/application/language/catalan/translations_lang.php index 0a119841..16bbf54c 100644 --- a/application/language/catalan/translations_lang.php +++ b/application/language/catalan/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/chinese/translations_lang.php b/application/language/chinese/translations_lang.php index b0805074..77889dfb 100755 --- a/application/language/chinese/translations_lang.php +++ b/application/language/chinese/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/czech/translations_lang.php b/application/language/czech/translations_lang.php index 58717efd..122b9d9a 100644 --- a/application/language/czech/translations_lang.php +++ b/application/language/czech/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/danish/translations_lang.php b/application/language/danish/translations_lang.php index ef132482..8efe2d00 100755 --- a/application/language/danish/translations_lang.php +++ b/application/language/danish/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/dutch/translations_lang.php b/application/language/dutch/translations_lang.php index 4723a106..58d57e4b 100755 --- a/application/language/dutch/translations_lang.php +++ b/application/language/dutch/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/english/translations_lang.php b/application/language/english/translations_lang.php index ba93dc83..97d31f83 100755 --- a/application/language/english/translations_lang.php +++ b/application/language/english/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/finnish/translations_lang.php b/application/language/finnish/translations_lang.php index 13b9284d..5a3a2bbe 100755 --- a/application/language/finnish/translations_lang.php +++ b/application/language/finnish/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/french/translations_lang.php b/application/language/french/translations_lang.php index 59b75d50..fa7e7174 100755 --- a/application/language/french/translations_lang.php +++ b/application/language/french/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/greek/translations_lang.php b/application/language/greek/translations_lang.php index ebab792d..d9755299 100755 --- a/application/language/greek/translations_lang.php +++ b/application/language/greek/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/hebrew/translations_lang.php b/application/language/hebrew/translations_lang.php index 23fd83bc..f9d96d44 100644 --- a/application/language/hebrew/translations_lang.php +++ b/application/language/hebrew/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/hindi/translations_lang.php b/application/language/hindi/translations_lang.php index e6a74632..af7ce8f3 100755 --- a/application/language/hindi/translations_lang.php +++ b/application/language/hindi/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/hungarian/translations_lang.php b/application/language/hungarian/translations_lang.php index b64c95e4..5543b130 100755 --- a/application/language/hungarian/translations_lang.php +++ b/application/language/hungarian/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/italian/translations_lang.php b/application/language/italian/translations_lang.php index f33aea92..4b85c7c0 100755 --- a/application/language/italian/translations_lang.php +++ b/application/language/italian/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/japanese/translations_lang.php b/application/language/japanese/translations_lang.php index 0705974e..13ba4e73 100755 --- a/application/language/japanese/translations_lang.php +++ b/application/language/japanese/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/luxembourgish/translations_lang.php b/application/language/luxembourgish/translations_lang.php index 8fdd5b74..a5ca853c 100755 --- a/application/language/luxembourgish/translations_lang.php +++ b/application/language/luxembourgish/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/marathi/translations_lang.php b/application/language/marathi/translations_lang.php index c11b9a49..dbe559f0 100644 --- a/application/language/marathi/translations_lang.php +++ b/application/language/marathi/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/polish/translations_lang.php b/application/language/polish/translations_lang.php index ffcd1866..7c4df1a0 100755 --- a/application/language/polish/translations_lang.php +++ b/application/language/polish/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/portuguese-br/translations_lang.php b/application/language/portuguese-br/translations_lang.php index c4b618d6..07e4e824 100755 --- a/application/language/portuguese-br/translations_lang.php +++ b/application/language/portuguese-br/translations_lang.php @@ -356,4 +356,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/portuguese/translations_lang.php b/application/language/portuguese/translations_lang.php index 4193c281..9ea406b5 100755 --- a/application/language/portuguese/translations_lang.php +++ b/application/language/portuguese/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/romanian/translations_lang.php b/application/language/romanian/translations_lang.php index 3a2ef1ca..49a56f3a 100755 --- a/application/language/romanian/translations_lang.php +++ b/application/language/romanian/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/russian/translations_lang.php b/application/language/russian/translations_lang.php index f58a19c9..a8863a35 100755 --- a/application/language/russian/translations_lang.php +++ b/application/language/russian/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/slovak/translations_lang.php b/application/language/slovak/translations_lang.php index cc0f07af..03080cf6 100755 --- a/application/language/slovak/translations_lang.php +++ b/application/language/slovak/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/spanish/translations_lang.php b/application/language/spanish/translations_lang.php index 79c2e315..65c5288f 100755 --- a/application/language/spanish/translations_lang.php +++ b/application/language/spanish/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/swedish/translations_lang.php b/application/language/swedish/translations_lang.php index 613fef62..04faf037 100644 --- a/application/language/swedish/translations_lang.php +++ b/application/language/swedish/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/language/turkish/translations_lang.php b/application/language/turkish/translations_lang.php index c3b27a43..67546992 100755 --- a/application/language/turkish/translations_lang.php +++ b/application/language/turkish/translations_lang.php @@ -357,4 +357,6 @@ $lang['company'] = 'Company'; $lang['remove'] = 'Remove'; $lang['login_button'] = 'Login Button'; $lang['display_login_button_hint'] = 'Defines whether the login button is being displayed in the booking page.'; +$lang['private'] = 'Private'; +$lang['private_hint'] = 'Private records will not be displayed or processed in public pages such as the booking page.'; // End diff --git a/application/migrations/035_add_is_private_column_to_services_table.php b/application/migrations/035_add_is_private_column_to_services_table.php new file mode 100644 index 00000000..2a8663ad --- /dev/null +++ b/application/migrations/035_add_is_private_column_to_services_table.php @@ -0,0 +1,45 @@ + + * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.4.0 + * ---------------------------------------------------------------------------- */ + +class Migration_Add_is_private_column_to_services_table extends CI_Migration { + /** + * Upgrade method. + */ + public function up() + { + if ( ! $this->db->field_exists('is_private', 'services')) + { + $fields = [ + 'is_private' => [ + 'type' => 'TINYINT', + 'constraint' => '4', + 'default' => '0', + 'after' => 'attendants_number' + ] + ]; + + $this->dbforge->add_column('services', $fields); + } + } + + /** + * Downgrade method. + */ + public function down() + { + if ( ! $this->db->field_exists('is_private', 'services')) + { + $this->dbforge->drop_column('services', 'is_private'); + } + } +} diff --git a/application/migrations/036_add_is_private_column_to_users_table.php b/application/migrations/036_add_is_private_column_to_users_table.php new file mode 100644 index 00000000..6bf245ea --- /dev/null +++ b/application/migrations/036_add_is_private_column_to_users_table.php @@ -0,0 +1,45 @@ + + * @copyright Copyright (c) 2013 - 2020, Alex Tselegidis + * @license http://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link http://easyappointments.org + * @since v1.4.0 + * ---------------------------------------------------------------------------- */ + +class Migration_Add_is_private_column_to_users_table extends CI_Migration { + /** + * Upgrade method. + */ + public function up() + { + if ( ! $this->db->field_exists('is_private', 'users')) + { + $fields = [ + 'is_private' => [ + 'type' => 'TINYINT', + 'constraint' => '4', + 'default' => '0', + 'after' => 'language' + ] + ]; + + $this->dbforge->add_column('users', $fields); + } + } + + /** + * Downgrade method. + */ + public function down() + { + if ( ! $this->db->field_exists('is_private', 'users')) + { + $this->dbforge->drop_column('users', 'is_private'); + } + } +} diff --git a/application/models/Providers_model.php b/application/models/Providers_model.php index 6b1a80f0..42218ebf 100755 --- a/application/models/Providers_model.php +++ b/application/models/Providers_model.php @@ -24,6 +24,7 @@ class Providers_model extends EA_Model { */ protected $casts = [ 'id' => 'integer', + 'is_private' => 'boolean', 'id_roles' => 'integer', ]; @@ -44,6 +45,7 @@ class Providers_model extends EA_Model { 'timezone' => 'timezone', 'language' => 'language', 'notes' => 'notes', + 'isPrivate' => 'is_private', 'roleId' => 'id_roles', ]; @@ -609,10 +611,17 @@ class Providers_model extends EA_Model { /** * Get all the provider records that are assigned to at least one service. * + * @param bool $without_private Only include the public providers. + * * @return array Returns an array of providers. */ - public function get_available_providers(): array + public function get_available_providers(bool $without_private = FALSE): array { + if ($without_private) + { + $this->db->where('users.is_private', FALSE); + } + $providers = $this ->db ->select('users.*') diff --git a/application/models/Services_model.php b/application/models/Services_model.php index 0c8ec56a..549ae9bb 100644 --- a/application/models/Services_model.php +++ b/application/models/Services_model.php @@ -26,6 +26,7 @@ class Services_model extends EA_Model { 'id' => 'integer', 'price' => 'float', 'attendants_number' => 'integer', + 'is_private' => 'boolean', 'id_categories' => 'integer', ]; @@ -43,6 +44,7 @@ class Services_model extends EA_Model { 'color' => 'color', 'availabilitiesType' => 'availabilities_type', 'attendantsNumber' => 'attendants_number', + 'isPrivate' => 'is_private', 'categoryId' => 'id_categories', ]; @@ -211,9 +213,9 @@ class Services_model extends EA_Model { } $service = $this->db->get_where('services', ['id' => $service_id])->row_array(); - - $this->cast($service); - + + $this->cast($service); + return $service; } @@ -249,7 +251,7 @@ class Services_model extends EA_Model { // Check if the required field is part of the service data. $service = $query->row_array(); - + $this->cast($service); if ( ! array_key_exists($field, $service)) @@ -283,22 +285,29 @@ class Services_model extends EA_Model { } $services = $this->db->get('services', $limit, $offset)->result_array(); - - foreach ($services as $service) + + foreach ($services as &$service) { $this->cast($service); } - + return $services; } /** * Get all the service records that are assigned to at least one provider. * + * @param bool $without_private Only include the public services. + * * @return array Returns an array of services. */ - public function get_available_services(): array + public function get_available_services(bool $without_private = FALSE): array { + if ($without_private) + { + $this->db->where('services.is_private', FALSE); + } + $services = $this ->db ->distinct() @@ -310,7 +319,7 @@ class Services_model extends EA_Model { ->get() ->result_array(); - foreach ($services as $service) + foreach ($services as &$service) { $this->cast($service); } @@ -351,8 +360,8 @@ class Services_model extends EA_Model { ->order_by($order_by) ->get() ->result_array(); - - foreach ($services as $service) + + foreach ($services as &$service) { $this->cast($service); } diff --git a/application/views/layouts/booking_layout.php b/application/views/layouts/booking_layout.php index 45806b1d..e5e39a54 100644 --- a/application/views/layouts/booking_layout.php +++ b/application/views/layouts/booking_layout.php @@ -19,7 +19,9 @@ - vars('company_color')]) ?> + + vars('company_color')]) ?> +
diff --git a/application/views/pages/providers.php b/application/views/pages/providers.php index d0dfed1e..b0fea678 100755 --- a/application/views/pages/providers.php +++ b/application/views/pages/providers.php @@ -146,6 +146,21 @@ +