The booking page will render based on the selected displayed/required fields.

This commit is contained in:
Alex Tselegidis 2021-12-20 09:38:37 +01:00
parent 80e77ad8a0
commit afad7920eb
3 changed files with 111 additions and 49 deletions

View file

@ -80,12 +80,22 @@ class Booking extends EA_Controller {
$date_format = setting('date_format'); $date_format = setting('date_format');
$time_format = setting('time_format'); $time_format = setting('time_format');
$first_weekday = setting('first_weekday'); $first_weekday = setting('first_weekday');
$display_first_name = setting('display_first_name');
$require_first_name = setting('require_first_name');
$display_last_name = setting('display_last_name');
$require_last_name = setting('require_last_name');
$display_email = setting('display_email');
$require_email = setting('require_email');
$display_phone_number = setting('display_phone_number');
$require_phone_number = setting('require_phone_number'); $require_phone_number = setting('require_phone_number');
$show_phone_number = setting('show_phone_number'); $display_address = setting('display_address');
$show_address = setting('show_address'); $require_address = setting('require_address');
$show_city = setting('show_city'); $display_city = setting('display_city');
$show_zip_code = setting('show_zip_code'); $require_city = setting('require_city');
$show_notes = setting('show_notes'); $display_zip_code = setting('display_zip_code');
$require_zip_code = setting('require_zip_code');
$display_notes = setting('display_notes');
$require_notes = setting('require_notes');
$display_cookie_notice = setting('display_cookie_notice'); $display_cookie_notice = setting('display_cookie_notice');
$cookie_notice_content = setting('cookie_notice_content'); $cookie_notice_content = setting('cookie_notice_content');
$display_terms_and_conditions = setting('display_terms_and_conditions'); $display_terms_and_conditions = setting('display_terms_and_conditions');
@ -182,18 +192,28 @@ class Booking extends EA_Controller {
'date_format' => $date_format, 'date_format' => $date_format,
'time_format' => $time_format, 'time_format' => $time_format,
'first_weekday' => $first_weekday, 'first_weekday' => $first_weekday,
'display_first_name' => $display_first_name,
'require_first_name' => $require_first_name,
'display_last_name' => $display_last_name,
'require_last_name' => $require_last_name,
'display_email' => $display_email,
'require_email' => $require_email,
'display_phone_number' => $display_phone_number,
'require_phone_number' => $require_phone_number,
'display_address' => $display_address,
'require_address' => $require_address,
'display_city' => $display_city,
'require_city' => $require_city,
'display_zip_code' => $display_zip_code,
'require_zip_code' => $require_zip_code,
'display_notes' => $display_notes,
'require_notes' => $require_notes,
'display_cookie_notice' => $display_cookie_notice, 'display_cookie_notice' => $display_cookie_notice,
'cookie_notice_content' => $cookie_notice_content, 'cookie_notice_content' => $cookie_notice_content,
'display_terms_and_conditions' => $display_terms_and_conditions, 'display_terms_and_conditions' => $display_terms_and_conditions,
'terms_and_conditions_content' => $terms_and_conditions_content, 'terms_and_conditions_content' => $terms_and_conditions_content,
'display_privacy_policy' => $display_privacy_policy, 'display_privacy_policy' => $display_privacy_policy,
'privacy_policy_content' => $privacy_policy_content, 'privacy_policy_content' => $privacy_policy_content,
'require_phone_number' => $require_phone_number,
'show_phone_number' => $show_phone_number,
'show_address' => $show_address,
'show_city' => $show_city,
'show_zip_code' => $show_zip_code,
'show_notes' => $show_notes,
'display_any_provider' => $display_any_provider, 'display_any_provider' => $display_any_provider,
'timezones' => $timezones, 'timezones' => $timezones,
'grouped_timezones' => $grouped_timezones, 'grouped_timezones' => $grouped_timezones,

View file

@ -1,11 +1,21 @@
<?php <?php
/** /**
* @var string $display_first_name
* @var string $require_first_name
* @var string $display_last_name
* @var string $require_last_name
* @var string $display_email
* @var string $require_email
* @var string $display_phone_number
* @var string $require_phone_number * @var string $require_phone_number
* @var string $show_phone_number * @var string $display_address
* @var string $show_address * @var string $require_address
* @var string $show_city * @var string $display_city
* @var string $show_zip_code * @var string $require_city
* @var string $show_notes * @var string $display_zip_code
* @var string $require_zip_code
* @var string $display_notes
* @var string $require_notes
* @var string $display_terms_and_conditions * @var string $display_terms_and_conditions
* @var string $display_privacy_policy * @var string $display_privacy_policy
*/ */
@ -18,70 +28,102 @@
<div class="row frame-content"> <div class="row frame-content">
<div class="col-12 col-md-6"> <div class="col-12 col-md-6">
<div class="mb-3"> <?php if ($display_first_name): ?>
<label for="first-name" class="form-label"> <div class="mb-3">
<?= lang('first_name') ?> <label for="first-name" class="form-label">
<span class="text-danger">*</span> <?= lang('first_name') ?>
</label> <?php if ($require_first_name): ?>
<input type="text" id="first-name" class="required form-control" maxlength="100"/> <span class="text-danger">*</span>
</div> <?php endif ?>
<div class="mb-3"> </label>
<label for="last-name" class="form-label"> <input type="text" id="first-name"
<?= lang('last_name') ?> class="<?= $require_first_name ? 'required' : '' ?> form-control" maxlength="100"/>
<span class="text-danger">*</span> </div>
</label> <?php endif ?>
<input type="text" id="last-name" class="required form-control" maxlength="120"/>
</div> <?php if ($display_last_name): ?>
<div class="mb-3"> <div class="mb-3">
<label for="email" class="form-label"> <label for="last-name" class="form-label">
<?= lang('email') ?> <?= lang('last_name') ?>
<span class="text-danger">*</span> <?php if ($require_last_name): ?>
</label> <span class="text-danger">*</span>
<input type="text" id="email" class="required form-control" maxlength="120"/> <?php endif ?>
</div> </label>
<?php if ($show_phone_number): ?> <input type="text" id="last-name"
class="<?= $require_last_name ? 'required' : '' ?> form-control" maxlength="120"/>
</div>
<?php endif ?>
<?php if ($display_email): ?>
<div class="mb-3">
<label for="email" class="form-label">
<?= lang('email') ?>
<?php if ($require_email): ?>
<span class="text-danger">*</span>
<?php endif ?>
</label>
<input type="text" id="email"
class="<?= $require_email ? 'required' : '' ?> form-control" maxlength="120"/>
</div>
<?php endif ?>
<?php if ($display_phone_number): ?>
<div class="mb-3"> <div class="mb-3">
<label for="phone-number" class="form-label"> <label for="phone-number" class="form-label">
<?= lang('phone_number') ?> <?= lang('phone_number') ?>
<?= $require_phone_number ? '<span class="text-danger">*</span>' : '' ?> <?php if ($require_phone_number): ?>
<span class="text-danger">*</span>
<?php endif ?>
</label> </label>
<input type="text" id="phone-number" maxlength="60" <input type="text" id="phone-number" maxlength="60"
class="<?= $require_phone_number ? 'required' : '' ?> form-control"/> class="<?= $require_phone_number ? 'required' : '' ?> form-control"/>
</div> </div>
<?php endif; ?> <?php endif ?>
</div> </div>
<div class="col-12 col-md-6"> <div class="col-12 col-md-6">
<?php if ($show_address) : ?> <?php if ($display_address) : ?>
<div class="mb-3"> <div class="mb-3">
<label for="address" class="form-label"> <label for="address" class="form-label">
<?= lang('address') ?> <?= lang('address') ?>
<?php if ($require_address): ?>
<span class="text-danger">*</span>
<?php endif ?>
</label> </label>
<input type="text" id="address" class="form-control" maxlength="120"/> <input type="text" id="address" class="<?= $require_address ? 'required' : '' ?> form-control" maxlength="120"/>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php if ($show_city): ?> <?php if ($display_city): ?>
<div class="mb-3"> <div class="mb-3">
<label for="city" class="form-label"> <label for="city" class="form-label">
<?= lang('city') ?> <?= lang('city') ?>
<?php if ($require_city): ?>
<span class="text-danger">*</span>
<?php endif ?>
</label> </label>
<input type="text" id="city" class="form-control" maxlength="120"/> <input type="text" id="city" class="<?= $require_city ? 'required' : '' ?> form-control" maxlength="120"/>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php if ($show_zip_code): ?> <?php if ($display_zip_code): ?>
<div class="mb-3"> <div class="mb-3">
<label for="zip-code" class="form-label"> <label for="zip-code" class="form-label">
<?= lang('zip_code') ?> <?= lang('zip_code') ?>
<?php if ($require_zip_code): ?>
<span class="text-danger">*</span>
<?php endif ?>
</label> </label>
<input type="text" id="zip-code" class="form-control" maxlength="120"/> <input type="text" id="zip-code" class="<?= $require_zip_code ? 'required' : '' ?> form-control" maxlength="120"/>
</div> </div>
<?php endif; ?> <?php endif; ?>
<?php if ($show_notes): ?> <?php if ($display_notes): ?>
<div class="mb-3"> <div class="mb-3">
<label for="notes" class="form-label"> <label for="notes" class="form-label">
<?= lang('notes') ?> <?= lang('notes') ?>
<?php if ($require_notes): ?>
<span class="text-danger">*</span>
<?php endif ?>
</label> </label>
<textarea id="notes" maxlength="500" class="form-control" rows="1"></textarea> <textarea id="notes" maxlength="500" class="<?= $require_notes ? 'required' : '' ?> form-control" rows="1"></textarea>
</div> </div>
<?php endif; ?> <?php endif; ?>
</div> </div>

View file

@ -531,7 +531,7 @@ window.FrontendBook = window.FrontendBook || {};
} }
// Validate email address. // Validate email address.
if (!GeneralFunctions.validateEmail($('#email').val())) { if ($('#email').val() && !GeneralFunctions.validateEmail($('#email').val())) {
$('#email').parents('.form-group').addClass('is-invalid'); $('#email').parents('.form-group').addClass('is-invalid');
throw new Error(App.Lang.invalid_email); throw new Error(App.Lang.invalid_email);
} }