Skip to content

Commit

Permalink
Added setting to require phone number for customers, closes alextsele…
Browse files Browse the repository at this point in the history
  • Loading branch information
sandbergja committed Oct 18, 2019
1 parent 14bbd79 commit 271269d
Show file tree
Hide file tree
Showing 34 changed files with 125 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/application/config/migration.php
Expand Up @@ -37,7 +37,7 @@
| be upgraded / downgraded to.
|
*/
$config['migration_version'] = 13; // current
$config['migration_version'] = 14; // current


/*
Expand Down
2 changes: 2 additions & 0 deletions src/application/controllers/Appointments.php
Expand Up @@ -76,6 +76,7 @@ public function index($appointment_hash = '')
$company_name = $this->settings_model->get_setting('company_name');
$date_format = $this->settings_model->get_setting('date_format');
$time_format = $this->settings_model->get_setting('time_format');
$require_phone_number = $this->settings_model->get_setting('require_phone_number');
$display_cookie_notice = $this->settings_model->get_setting('display_cookie_notice');
$cookie_notice_content = $this->settings_model->get_setting('cookie_notice_content');
$display_terms_and_conditions = $this->settings_model->get_setting('display_terms_and_conditions');
Expand Down Expand Up @@ -147,6 +148,7 @@ public function index($appointment_hash = '')
'customer_token' => $customer_token,
'date_format' => $date_format,
'time_format' => $time_format,
'require_phone_number' => $require_phone_number,
'appointment_data' => $appointment,
'provider_data' => $provider,
'customer_data' => $customer,
Expand Down
1 change: 1 addition & 0 deletions src/application/controllers/Backend.php
Expand Up @@ -133,6 +133,7 @@ public function customers()
$view['company_name'] = $this->settings_model->get_setting('company_name');
$view['date_format'] = $this->settings_model->get_setting('date_format');
$view['time_format'] = $this->settings_model->get_setting('time_format');
$view['require_phone_number'] = $this->settings_model->get_setting('require_phone_number');
$view['customers'] = $this->customers_model->get_batch();
$view['available_providers'] = $this->providers_model->get_available_providers();
$view['available_services'] = $this->services_model->get_available_services();
Expand Down
2 changes: 2 additions & 0 deletions src/application/language/arabic/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/bulgarian/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/chinese/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/danish/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/dutch/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/english/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/finnish/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/french/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Effacer toutes mes données personnelles';
$lang['delete_personal_information_prompt'] = 'Etes-vous sûr(e) de vouloir effacer toutes vos données personnelles ? Cette action est irréversible.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/german/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Persönlichen Informationen löschen';
$lang['delete_personal_information_prompt'] = 'Sind Sie sicher, dass Sie Ihre persönlichen Daten löschen möchten? Diese Aktion kann nicht rückgängig gemacht werden.';
$lang['location'] = 'Ort';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
3 changes: 3 additions & 0 deletions src/application/language/greek/translations_lang.php
Expand Up @@ -298,3 +298,6 @@
$lang['delete_personal_information'] = 'Διαγραφή Προσωπικών Πληροφοριών';
$lang['delete_personal_information_prompt'] = 'Είστε σίγουρος ότι θέλετε να διαγράψετε τις προσωπικές σας πληροφορίες; Αυτή η ενέργεια δεν μπορεί να αναιρεθεί.';
$lang['location'] = 'Τοποθεσία';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';

2 changes: 2 additions & 0 deletions src/application/language/hindi/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/hungarian/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/italian/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/japanese/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/luxembourgish/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/polish/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/portuguese-br/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/portuguese/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/romanian/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/russian/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/slovak/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/spanish/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
2 changes: 2 additions & 0 deletions src/application/language/turkish/translations_lang.php
Expand Up @@ -298,3 +298,5 @@
$lang['delete_personal_information'] = 'Delete Personal Information';
$lang['delete_personal_information_prompt'] = 'Are you sure that you want to delete your personal information? This action cannot be undone.';
$lang['location'] = 'Location';
$lang['require_phone_number'] = 'Require phone number';
$lang['require_phone_number_hint'] = 'When enabled, customers and users will need to enter the customer\'s phone number when booking an appointment';
@@ -0,0 +1,35 @@
<?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 - 2018, Alex Tselegidis
* @license http://opensource.org/licenses/GPL-3.0 - GPLv3
* @link http://easyappointments.org
* @since v1.4.0
* ---------------------------------------------------------------------------- */

class Migration_Add_require_phone_number_setting extends CI_Migration {
public function up()
{
$this->load->model('settings_model');

try
{
$this->settings_model->get_setting('require_phone_number');
}
catch (Exception $exception)
{
$this->settings_model->set_setting('require_phone_number', '1');
}
}

public function down()
{
$this->load->model('settings_model');

$this->settings_model->remove_setting('require_phone_number');
}
}
6 changes: 5 additions & 1 deletion src/application/models/Customers_model.php
Expand Up @@ -211,10 +211,14 @@ public function validate($customer)
. 'exist in the database.');
}
}

$query = $this->db->get_where('ea_settings', ['name' => 'require_phone_number']);
$phone_number_required = $query->num_rows() > 0 ? $query->row() === '1' : false;

// Validate required fields
if ( ! isset($customer['last_name'])
|| ! isset($customer['email'])
|| ! isset($customer['phone_number']))
|| (!isset($customer['phone_number']) && $phone_number_required))
{
throw new Exception('Not all required fields are provided: '
. print_r($customer, TRUE));
Expand Down
6 changes: 4 additions & 2 deletions src/application/views/appointments/book.php
Expand Up @@ -223,8 +223,10 @@
<input type="text" id="email" class="required form-control" maxlength="120" />
</div>
<div class="form-group">
<label for="phone-number" class="control-label"><?= lang('phone_number') ?> *</label>
<input type="text" id="phone-number" class="required form-control" maxlength="60" />
<label for="phone-number" class="control-label"><?= lang('phone_number') ?>
<?php echo ('1' === $require_phone_number) ? '*' : ''; ?></label>
<input type="text" id="phone-number" class="<?php echo ('1' === $require_phone_number) ? 'required' : ''; ?>
form-control" maxlength="60" />
</div>
</div>

Expand Down
6 changes: 4 additions & 2 deletions src/application/views/backend/customers.php
Expand Up @@ -109,8 +109,10 @@
</div>

<div class="form-group">
<label class="control-label" for="phone-number"><?= lang('phone_number') ?> *</label>
<input id="phone-number" class="form-control required">
<label class="control-label" for="phone-number"><?= lang('phone_number') ?>
<?php echo ('1' === $require_phone_number) ? '*' : ''; ?></label>
<input id="phone-number" class="form-control
<?php echo ('1' === $require_phone_number) ? 'required' : ''; ?>">
</div>

<div class="form-group">
Expand Down
13 changes: 13 additions & 0 deletions src/application/views/backend/settings.php
Expand Up @@ -159,6 +159,19 @@
<?= lang('require_captcha_hint') ?>
</span>
</div>
<div class="form-group">
<label for="require-phone-number">
<?= lang('require_phone_number') ?>
</label>
<br>
<button type="button" id="require-phone-number" class="btn btn-default" data-toggle="button" aria-pressed="false">
<span class="glyphicon glyphicon-phone-alt"></span>
<?= lang('require_phone_number') ?>
</button>
<span class="help-block">
<?= lang('require_phone_number_hint') ?>
</span>
</div>
</div>
</div>
</fieldset>
Expand Down
4 changes: 4 additions & 0 deletions src/assets/js/backend_settings.js
Expand Up @@ -71,6 +71,10 @@ window.BackendSettings = window.BackendSettings || {};
$('#require-captcha').addClass('active');
}

if (setting.name === 'require_phone_number' && setting.value === '1') {
$('#require-phone-number').addClass('active');
}

if (setting.name === 'display_cookie_notice') {
$('#display-cookie-notice').prop('checked', setting.value === '1');
}
Expand Down
6 changes: 6 additions & 0 deletions src/assets/js/backend_settings_system.js
Expand Up @@ -82,6 +82,12 @@
value: $('#require-captcha').hasClass('active') === true ? '1' : '0'
});

settings.push({
name: 'require_phone_number',
value: $('#require-phone-number').hasClass('active') === true ? '1' : '0'
});


// Business Logic Tab
settings.push({
name: 'company_working_plan',
Expand Down
5 changes: 3 additions & 2 deletions src/assets/sql/data.sql
Expand Up @@ -22,6 +22,7 @@ VALUES
('display_terms_and_conditions', '0'),
('terms_and_conditions_content', 'Terms and conditions content.'),
('display_privacy_policy', '0'),
('privacy_policy_content', 'Privacy policy content.');
('privacy_policy_content', 'Privacy policy content.'),
('require_phone_number', '1');

INSERT INTO `ea_migrations` VALUES ('13');
INSERT INTO `ea_migrations` VALUES ('14');

0 comments on commit 271269d

Please sign in to comment.