Added setting to require phone number for customers, closes #655

This commit is contained in:
Jane Sandberg 2019-10-17 19:37:52 -07:00
parent 14bbd793bf
commit 271269d059
34 changed files with 125 additions and 8 deletions

View file

@ -37,7 +37,7 @@ $config['migration_table'] = 'ea_migrations';
| be upgraded / downgraded to.
|
*/
$config['migration_version'] = 13; // current
$config['migration_version'] = 14; // current
/*

View file

@ -76,6 +76,7 @@ class Appointments extends CI_Controller {
$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');
@ -147,6 +148,7 @@ class Appointments extends CI_Controller {
'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,

View file

@ -133,6 +133,7 @@ class Backend extends CI_Controller {
$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();

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Effacer toutes vos données personn
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Alle persönlichen Informationen au
$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';

View file

@ -298,3 +298,6 @@ $lang['delete_personal_information_hint'] = 'Διαγραφή όλων των π
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -298,3 +298,5 @@ $lang['delete_personal_information_hint'] = 'Delete all personal information fro
$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';

View file

@ -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');
}
}

View file

@ -211,10 +211,14 @@ class Customers_Model extends CI_Model {
. '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));

View file

@ -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>

View file

@ -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">

View file

@ -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>

View file

@ -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');
}

View file

@ -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',

View file

@ -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');