Merge branch 'make_phone_number_optional' of https://github.com/sandbergja/easyappointments into sandbergja-make_phone_number_optional

# Conflicts:
#	src/application/controllers/Appointments.php
#	src/application/controllers/Backend.php
#	src/application/language/arabic/translations_lang.php
#	src/application/language/bulgarian/translations_lang.php
#	src/application/language/chinese/translations_lang.php
#	src/application/language/danish/translations_lang.php
#	src/application/language/dutch/translations_lang.php
#	src/application/language/english/translations_lang.php
#	src/application/language/finnish/translations_lang.php
#	src/application/language/french/translations_lang.php
#	src/application/language/german/translations_lang.php
#	src/application/language/greek/translations_lang.php
#	src/application/language/hindi/translations_lang.php
#	src/application/language/hungarian/translations_lang.php
#	src/application/language/italian/translations_lang.php
#	src/application/language/japanese/translations_lang.php
#	src/application/language/luxembourgish/translations_lang.php
#	src/application/language/polish/translations_lang.php
#	src/application/language/portuguese-br/translations_lang.php
#	src/application/language/portuguese/translations_lang.php
#	src/application/language/romanian/translations_lang.php
#	src/application/language/russian/translations_lang.php
#	src/application/language/slovak/translations_lang.php
#	src/application/language/spanish/translations_lang.php
#	src/application/language/turkish/translations_lang.php
#	src/assets/sql/data.sql
This commit is contained in:
Alex Tselegidis 2020-03-10 21:11:33 +01:00
commit 058089134b
32 changed files with 122 additions and 10 deletions

View file

@ -77,6 +77,7 @@ class Appointments extends CI_Controller {
$date_format = $this->settings_model->get_setting('date_format');
$time_format = $this->settings_model->get_setting('time_format');
$first_weekday = $this->settings_model->get_setting('first_weekday');
$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');
@ -149,6 +150,7 @@ class Appointments extends CI_Controller {
'date_format' => $date_format,
'time_format' => $time_format,
'first_weekday' => $first_weekday,
'require_phone_number' => $require_phone_number,
'appointment_data' => $appointment,
'provider_data' => $provider,
'customer_data' => $customer,

View file

@ -135,6 +135,7 @@ class Backend extends CI_Controller {
$view['date_format'] = $this->settings_model->get_setting('date_format');
$view['time_format'] = $this->settings_model->get_setting('time_format');
$view['first_weekday'] = $this->settings_model->get_setting('first_weekday');
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = 'New working day';
$lang['extra_period_saved'] = 'New working day saved successfully!';
$lang['add_extra_periods_during_each_day'] = 'Add working days outside the working plan.';
$lang['add_extra_period'] = 'Add a working day';
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -308,3 +308,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -305,3 +305,6 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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,9 +298,6 @@ $lang['delete_personal_information_hint'] = 'Deletar toda informação pessoal d
$lang['delete_personal_information'] = 'Deletar Informação Pessoal';
$lang['delete_personal_information_prompt'] = 'Tem certeza que deja deletar suas informações pessoais? Essa ação não pode ser desfeita.';
$lang['location'] = 'Location';
$lang['availabilities_type'] = 'Availabilities Type';
$lang['flexible'] = 'Flexible';
$lang['fixed'] = 'Fixed';
$lang['extra_period'] = '';
$lang['extra_periods'] = '';
$lang['extra_periods_hint'] = '';
@ -310,3 +307,5 @@ $lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -305,3 +305,5 @@ $lang['new_extra_period_title'] = '';
$lang['extra_period_saved'] = '';
$lang['add_extra_periods_during_each_day'] = '';
$lang['add_extra_period'] = '';
$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

@ -177,6 +177,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

@ -85,6 +85,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

@ -23,6 +23,7 @@ VALUES
('terms_and_conditions_content', 'Terms and conditions content.'),
('display_privacy_policy', '0'),
('privacy_policy_content', 'Privacy policy content.'),
('first_weekday', 'sunday');
('first_weekday', 'sunday'),
('require_phone_number', '1');
INSERT INTO `ea_migrations` VALUES ('13');
INSERT INTO `ea_migrations` VALUES ('15');