Skip to content

Commit

Permalink
Add a new "is_private" flag to services and providers so that they do…
Browse files Browse the repository at this point in the history
… not appear in the booking page (#378).
  • Loading branch information
alextselegidis committed Jan 24, 2022
1 parent 86d3ce8 commit 2f41c28
Show file tree
Hide file tree
Showing 38 changed files with 220 additions and 20 deletions.
10 changes: 5 additions & 5 deletions application/controllers/Booking.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ public function index()
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)
{
Expand Down Expand Up @@ -224,7 +224,7 @@ public function index()
'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,
Expand Down Expand Up @@ -364,7 +364,7 @@ public function get_available_hours()
*/
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);

Expand Down Expand Up @@ -652,7 +652,7 @@ public function get_unavailability_dates()
*/
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)
Expand Down
4 changes: 2 additions & 2 deletions application/controllers/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,8 +99,8 @@ public function index(string $appointment_hash = '')
$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,
Expand Down
2 changes: 2 additions & 0 deletions application/language/arabic/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/bulgarian/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/catalan/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/chinese/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/czech/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/danish/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/dutch/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/english/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/finnish/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/french/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/greek/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/hebrew/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/hindi/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/hungarian/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/italian/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/japanese/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/luxembourgish/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/marathi/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/polish/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/portuguese-br/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -356,4 +356,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/portuguese/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/romanian/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/russian/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/slovak/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/spanish/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/swedish/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
2 changes: 2 additions & 0 deletions application/language/turkish/translations_lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -357,4 +357,6 @@
$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
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');

/* ----------------------------------------------------------------------------
* Easy!Appointments - Open Source Web Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @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');
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php defined('BASEPATH') or exit('No direct script access allowed');

/* ----------------------------------------------------------------------------
* Easy!Appointments - Open Source Web Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @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');
}
}
}
11 changes: 10 additions & 1 deletion application/models/Providers_model.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class Providers_model extends EA_Model {
*/
protected $casts = [
'id' => 'integer',
'is_private' => 'boolean',
'id_roles' => 'integer',
];

Expand All @@ -44,6 +45,7 @@ class Providers_model extends EA_Model {
'timezone' => 'timezone',
'language' => 'language',
'notes' => 'notes',
'isPrivate' => 'is_private',
'roleId' => 'id_roles',
];

Expand Down Expand Up @@ -609,10 +611,17 @@ public function delete_working_plan_exception(int $provider_id, string $date)
/**
* 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.*')
Expand Down
Loading

0 comments on commit 2f41c28

Please sign in to comment.