Add new system-wide setting that enable users to choose the first day of the week. (#471)

The setting change the display of weeks shown in backend and booking page calendars.
Work plans and break lists in the 'settings' page are still displayed starting on Sunday.
This commit is contained in:
oxteam 2018-06-29 00:41:17 +02:00
parent 502027e894
commit 734be96126
37 changed files with 188 additions and 26 deletions

View file

@ -273,7 +273,7 @@ $config['cache_path'] = __DIR__ . '/../../storage/cache/';
| new release.
|
*/
$config['cache_busting_token'] = '93GT3';
$config['cache_busting_token'] = '93GX4';
/*
|--------------------------------------------------------------------------

View file

@ -37,7 +37,7 @@ $config['migration_table'] = 'ea_migrations';
| be upgraded / downgraded to.
|
*/
$config['migration_version'] = 12; // current
$config['migration_version'] = 13; // 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');
$first_weekday = $this->settings_model->get_setting('first_weekday');
$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,
'first_weekday' => $first_weekday,
'appointment_data' => $appointment,
'provider_data' => $provider,
'customer_data' => $customer,

View file

@ -70,6 +70,7 @@ class Backend extends CI_Controller {
$view['book_advance_timeout'] = $this->settings_model->get_setting('book_advance_timeout');
$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['company_name'] = $this->settings_model->get_setting('company_name');
$view['available_providers'] = $this->providers_model->get_available_providers();
$view['available_services'] = $this->services_model->get_available_services();
@ -132,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['first_weekday'] = $this->settings_model->get_setting('first_weekday');
$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();
@ -170,6 +172,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['first_weekday'] = $this->settings_model->get_setting('first_weekday');
$view['services'] = $this->services_model->get_batch();
$view['categories'] = $this->services_model->get_all_categories();
$this->set_user_data($view);
@ -207,6 +210,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['first_weekday'] = $this->settings_model->get_setting('first_weekday');
$view['admins'] = $this->admins_model->get_batch();
$view['providers'] = $this->providers_model->get_batch();
$view['secretaries'] = $this->secretaries_model->get_batch();
@ -320,14 +324,13 @@ class Backend extends CI_Controller {
{
throw new Exception('You do not have the required privileges for this task!');
}
$this->load->library('migration');
if ( ! $this->migration->current())
{
throw new Exception($this->migration->error_string());
}
$view = ['success' => TRUE];
}
catch (Exception $exc)

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'صيغة التاريخ';
$lang['date_format_hint'] = 'تغيير صيغة وعرض التاريخ (D - Date, M - Month, Y - Year).';
$lang['time_format'] = 'Time Format';
$lang['time_format_hint'] = 'Change the time display format (H - Hours, M - Minutes).';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'ليتم تضمينه في صفحة الحجز Google Analytics ID أضف معرّف';
$lang['availabilities_type'] = 'نوع التوفر أو الإتاحة';
$lang['flexible'] = 'مرن';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Формат на Дата';
$lang['date_format_hint'] = 'Промяна на дормат за показ на дата (D - дата, M - месец, Y - година).';
$lang['time_format'] = 'Time Format';
$lang['time_format_hint'] = 'Change the time display format (H - Hours, M - Minutes).';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Добавете Google Analytics ID за да бъде включена статистика в страницата за запазване на час.';
$lang['availabilities_type'] = 'Типове на работен период.';
$lang['flexible'] = 'Гъвкав';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Date Format';
$lang['date_format_hint'] = 'Change the date display format (D - Date, M - Month, Y - Year).';
$lang['time_format'] = 'Time Format';
$lang['time_format_hint'] = 'Change the time display format (H - Hours, M - Minutes).';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Add your Google Analytics ID to be included in the booking page.';
$lang['availabilities_type'] = 'Availabilities Type';
$lang['flexible'] = 'Flexible';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Date Format';
$lang['date_format_hint'] = 'Change the date display format (D - Date, M - Month, Y - Year).';
$lang['time_format'] = 'Time Format';
$lang['time_format_hint'] = 'Change the time display format (H - Hours, M - Minutes).';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Add your Google Analytics ID to be included in the booking page.';
$lang['availabilities_type'] = 'Availabilities Type';
$lang['flexible'] = 'Flexible';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Datum formaat';
$lang['date_format_hint'] = 'Verander het datum formaat (D - dag, M - maand, Y - jaar).';
$lang['time_format'] = 'Time Format';
$lang['time_format_hint'] = 'Change the time display format (H - Hours, M - Minutes).';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Voeg je Google Analytics ID toe om deze te gebruiken op je boekings pagina.';
$lang['availabilities_type'] = 'Beschikbaarheidstype';
$lang['flexible'] = 'Flexibel';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Date Format';
$lang['date_format_hint'] = 'Change the date display format (D - Date, M - Month, Y - Year).';
$lang['time_format'] = 'Time Format';
$lang['time_format_hint'] = 'Change the time display format (H - Hours, M - Minutes).';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Add your Google Analytics ID to be included in the booking page.';
$lang['availabilities_type'] = 'Availabilities Type';
$lang['flexible'] = 'Flexible';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Päiväyksen muoto';
$lang['date_format_hint'] = 'Vaihda päiväyksen esitysmuoto (D - Päivä, M - Kuukausi, Y - Vuosi).';
$lang['time_format'] = 'Time Format';
$lang['time_format_hint'] = 'Change the time display format (H - Hours, M - Minutes).';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Lisää Google Analytics ID varaussivulle.';
$lang['availabilities_type'] = 'Availabilities Type';
$lang['flexible'] = 'Flexible';

View file

@ -274,6 +274,8 @@ $lang['date_format'] = 'Format des Dates';
$lang['date_format_hint'] = 'Change le format d\'affichage des dates (D - Jour, M - Mois, Y - Année).';
$lang['time_format'] = 'Format de l\'Heure';
$lang['time_format_hint'] = 'Change le format d\'affichage de l\'Heure (H - Heures, M - Minutes).';
$lang['first_weekday'] = 'Premier jour de la semaine';
$lang['first_weekday_hint'] = 'Définit le premier jour de la semaine calendaire.';
$lang['google_analytics_code_hint'] = 'Renseignez l\'ID Google Analytics à utiliser dans la page des réservations.';
$lang['availabilities_type'] = 'Type de disponibilités';
$lang['flexible'] = 'Flexible';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Datumsformat';
$lang['date_format_hint'] = 'Ändern Sie das Datumsanzeigeformat (D - Datum, M - Monat, Y - Jahr).';
$lang['time_format'] = 'Zeitformat';
$lang['time_format_hint'] = 'Ändern Sie das Zeitanzeigeformat (H - Stunden, M - Minuten).';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Fügen Sie Ihre Google Analytics-ID hinzu, das auf der Buchungsseite enthalten wird.';
$lang['availabilities_type'] = 'Verfügungstyp';
$lang['flexible'] = 'Flexibel';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Μορφή Ημερομηνίας';
$lang['date_format_hint'] = 'Αλλάξτε την μορφή ημερομηνίας (D - Ημέρα, M - Μήνας, Y - Χρόνος).';
$lang['time_format'] = 'Μορφή Ώρας';
$lang['time_format_hint'] = 'Αλλάξτε την μορφή ώρας (H - Ώρα, M - Λεπτά).';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Προσθέστε τον Google Analytics ID σας το οποίο θα συμπεριληφθεί στην σελίδα κράτησης.';
$lang['availabilities_type'] = 'Τύπος Διαθεσιμοτήτων';
$lang['flexible'] = 'Ευέλικτος';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Date Format';
$lang['date_format_hint'] = 'Change the date display format (D - Date, M - Month, Y - Year).';
$lang['time_format'] = 'Time Format';
$lang['time_format_hint'] = 'Change the time display format (H - Hours, M - Minutes).';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Add your Google Analytics ID to be included in the booking page.';
$lang['availabilities_type'] = 'Availabilities Type';
$lang['flexible'] = 'Flexible';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Date Format';
$lang['date_format_hint'] = 'Change the date display format (D - Date, M - Month, Y - Year).';
$lang['time_format'] = 'Time Format';
$lang['time_format_hint'] = 'Change the time display format (H - Hours, M - Minutes).';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Add your Google Analytics ID to be included in the booking page.';
$lang['availabilities_type'] = 'Availabilities Type';
$lang['flexible'] = 'Flexible';

View file

@ -282,6 +282,8 @@ $lang['date_format'] = 'Formato data';
$lang['date_format_hint'] = 'Cambia il formato di visualizzazione della data (D - Giorno, M - Mese, Y - Anno).';
$lang['time_format'] = 'Formato orario';
$lang['time_format_hint'] = 'Cambia il formato di visualizzazione dell\'orario. (H - Ore, M - Minuti)';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Aggiunti il tuo ID di Google Analytics per includerlo nella pagina di prenotazione.';
$lang['availabilities_type'] = 'Availabilities Type';
$lang['flexible'] = 'Flexible';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Date Format';
$lang['date_format_hint'] = 'Change the date display format (D - Date, M - Month, Y - Year).';
$lang['time_format'] = 'Time Format';
$lang['time_format_hint'] = 'Change the time display format (H - Hours, M - Minutes).';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Add your Google Analytics ID to be included in the booking page.';
$lang['availabilities_type'] = 'Availabilities Type';
$lang['flexible'] = 'Flexible';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Date Format';
$lang['date_format_hint'] = 'Change the date display format (D - Date, M - Month, Y - Year).';
$lang['time_format'] = 'Time Format';
$lang['time_format_hint'] = 'Change the time display format (H - Hours, M - Minutes).';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Add your Google Analytics ID to be included in the booking page.';
$lang['availabilities_type'] = 'Availabilities Type';
$lang['flexible'] = 'Flexible';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Date Format';
$lang['date_format_hint'] = 'Change the date display format (D - Date, M - Month, Y - Year).';
$lang['time_format'] = 'Time Format';
$lang['time_format_hint'] = 'Change the time display format (H - Hours, M - Minutes).';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Add your Google Analytics ID to be included in the booking page.';
$lang['availabilities_type'] = 'Availabilities Type';
$lang['flexible'] = 'Flexible';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Formato da Data';
$lang['date_format_hint'] = 'Altera o formato de visualização da Data (D - Data, M - Mes, Y - Ano).';
$lang['time_format'] = 'Time Format';
$lang['time_format_hint'] = 'Change the time display format (H - Hours, M - Minutes).';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Adicione o seu ID do Google Analytics para ser incluido na pagina de agendamentos.';
$lang['availabilities_type'] = 'Availabilities Type';
$lang['flexible'] = 'Flexible';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Date Format';
$lang['date_format_hint'] = 'Change the date display format (D - Date, M - Month, Y - Year).';
$lang['time_format'] = 'Time Format';
$lang['time_format_hint'] = 'Change the time display format (H - Hours, M - Minutes).';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Add your Google Analytics ID to be included in the booking page.';
$lang['availabilities_type'] = 'Availabilities Type';
$lang['flexible'] = 'Flexible';

View file

@ -282,6 +282,8 @@ $lang['date_format'] = 'Date Format';
$lang['date_format_hint'] = 'Change the date display format (D - Date, M - Month, Y - Year).';
$lang['time_format'] = '';
$lang['time_format_hint'] = '';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Add your Google Analytics ID to be included in the booking page.';
$lang['availabilities_type'] = 'Availabilities Type';
$lang['flexible'] = 'Flexible';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Date Format';
$lang['date_format_hint'] = 'Change the date display format (D - Date, M - Month, Y - Year).';
$lang['time_format'] = '';
$lang['time_format_hint'] = '';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Add your Google Analytics ID to be included in the booking page.';
$lang['availabilities_type'] = 'Availabilities Type';
$lang['flexible'] = 'Flexible';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Formát dátumu';
$lang['date_format_hint'] = 'Zmeňte formát zobrazenia dátumu (D - Dátum, M - Mesiac, Y - Rok).';
$lang['time_format'] = '';
$lang['time_format_hint'] = '';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Pridajte svoje ID služby Google Analytics, aby ste bola zahrnutá do stránky rezervácie.';
$lang['availabilities_type'] = 'Typ dostupnosti';
$lang['flexible'] = 'Flexibilný';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Formato de Fecha';
$lang['date_format_hint'] = 'Cambia el formato de fecha para mostrar (D - Día, M - Mes, Y - Año).';
$lang['time_format'] = '';
$lang['time_format_hint'] = '';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Agrega tu ID de Google Analytics para ser incluido en la página de reservas.';
$lang['availabilities_type'] = 'Tipos disponibles';
$lang['flexible'] = 'Flexible';

View file

@ -276,6 +276,8 @@ $lang['date_format'] = 'Date Format';
$lang['date_format_hint'] = 'Change the date display format (D - Date, M - Month, Y - Year).';
$lang['time_format'] = '';
$lang['time_format_hint'] = '';
$lang['first_weekday'] = 'First day of week';
$lang['first_weekday_hint'] = 'Set the first day of the calendar week.';
$lang['google_analytics_code_hint'] = 'Add your Google Analytics ID to be included in the booking page.';
$lang['availabilities_type'] = 'Availabilities Type';
$lang['flexible'] = 'Flexible';

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.3.2
* ---------------------------------------------------------------------------- */
class Migration_Add_weekday_start_setting extends CI_Migration {
public function up()
{
$this->load->model('settings_model');
try
{
$this->settings_model->get_setting('first_weekday');
}
catch (Exception $exception)
{
$this->settings_model->set_setting('first_weekday', 'sunday');
}
}
public function down()
{
$this->load->model('settings_model');
$this->settings_model->remove_setting('first_weekday');
}
}

View file

@ -370,6 +370,7 @@
customerToken : <?= json_encode($customer_token) ?>,
dateFormat : <?= json_encode($date_format) ?>,
timeFormat : <?= json_encode($time_format) ?>,
firstWeekday : <?= json_encode($first_weekday) ?>,
displayCookieNotice : <?= json_encode($display_cookie_notice === '1') ?>,
appointmentData : <?= json_encode($appointment_data) ?>,
providerData : <?= json_encode($provider_data) ?>,

View file

@ -20,6 +20,7 @@
'bookAdvanceTimeout' : <?= $book_advance_timeout ?>,
'dateFormat' : <?= json_encode($date_format) ?>,
'timeFormat' : <?= json_encode($time_format) ?>,
'firstWeekday' : <?= json_encode($first_weekday) ?>,
'editAppointment' : <?= json_encode($edit_appointment) ?>,
'customers' : <?= json_encode($customers) ?>,
'secretaryProviders' : <?= json_encode($secretary_providers) ?>,

View file

@ -135,6 +135,23 @@
<?= lang('time_format_hint') ?>
</span>
</div>
<div class="form-group">
<label for="first-weekday">
<?= lang('first_weekday') ?>
</label>
<select class="form-control" id="first-weekday" data-field="first_weekday">
<option value="sunday"><?= lang('sunday') ?></option>
<option value="monday"><?= lang('monday') ?></option>
<option value="tuesday"><?= lang('tuesday') ?></option>
<option value="wednesday"><?= lang('wednesday') ?></option>
<option value="thursday"><?= lang('thursday') ?></option>
<option value="friday"><?= lang('friday') ?></option>
<option value="saturday"><?= lang('saturday') ?></option>
</select>
<span class="help-block">
<?= lang('first_weekday_hint') ?>
</span>
</div>
<div class="form-group">
<label><?= lang('customer_notifications') ?></label>
<br>

View file

@ -389,6 +389,9 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
throw new Error('Invalid GlobalVariables.dateFormat value.');
}
var fDay = GlobalVariables.firstWeekday;
var fDaynum = GeneralFunctions.getWeekDayId(fDay);
$dialog.find('#start-datetime').datetimepicker({
dateFormat: dateFormat,
timeFormat: GlobalVariables.timeFormat === 'regular' ? 'h:mm TT' : 'HH:mm',
@ -415,7 +418,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
timeText: EALang.time,
hourText: EALang.hour,
minuteText: EALang.minutes,
firstDay: 0
firstDay: fDaynum
});
$dialog.find('#start-datetime').datetimepicker('setDate', startDatetime);
@ -445,7 +448,7 @@ window.BackendCalendarAppointmentsModal = window.BackendCalendarAppointmentsModa
timeText: EALang.time,
hourText: EALang.hour,
minuteText: EALang.minutes,
firstDay: 0
firstDay: fDaynum
});
$dialog.find('#end-datetime').datetimepicker('setDate', endDatetime);
};

View file

@ -785,16 +785,6 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
$calendar.fullCalendar('removeEvents');
$calendar.fullCalendar('addEventSource', calendarEvents);
var weekDays = [
'sunday',
'monday',
'tuesday',
'wednesday',
'thursday',
'friday',
'saturday'
];
// :: ADD PROVIDER'S UNAVAILABLE TIME PERIODS
var calendarView = $calendar.fullCalendar('getView').name;
@ -805,12 +795,13 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
var workingPlanBulk = jQuery.parseJSON(provider.settings.working_plan);
var unavailablePeriod;
// Sort the working plan starting with Sunday as the first weekday to correctly align breaks in the calendar display
workingPlan = GeneralFunctions.sortWeekDict(workingPlanBulk,0); // 0 is the ID for Sunday
// Sort the working plan starting with the first day as set in General settings to correctly align breaks in the calendar display
var fDaynum = GeneralFunctions.getWeekDayId(GlobalVariables.firstWeekday);
workingPlan = GeneralFunctions.sortWeekDict(workingPlanBulk,fDaynum);
switch (calendarView) {
case 'agendaDay':
var selectedDayName = weekDays[$calendar.fullCalendar('getView').start.format('d')];
var selectedDayName = GeneralFunctions.getWeekDayName(parseInt($calendar.fullCalendar('getView').start.format('d')));
// Add custom unavailable periods.
$.each(response.unavailables, function (index, unavailable) {
@ -1091,12 +1082,15 @@ window.BackendCalendarDefaultView = window.BackendCalendarDefaultView || {};
var defaultView = window.innerWidth < 468 ? 'agendaDay' : 'agendaWeek';
var fDay = GlobalVariables.firstWeekday;
var fDaynum = GeneralFunctions.getWeekDayId(fDay);
// Initialize page calendar
$('#calendar').fullCalendar({
defaultView: defaultView,
height: _getCalendarHeight(),
editable: true,
firstDay: 0,
firstDay: fDaynum,
snapDuration: '00:30:00',
timeFormat: timeFormat,
slotLabelFormat: slotTimeFormat,

View file

@ -180,6 +180,8 @@ window.BackendCalendarUnavailabilitiesModal = window.BackendCalendarUnavailabili
break;
}
var fDay = GlobalVariables.firstWeekday;
var fDaynum = GeneralFunctions.getWeekDayId(fDay);
$dialog.find('#unavailable-start').datetimepicker({
dateFormat: dateFormat,
@ -207,7 +209,7 @@ window.BackendCalendarUnavailabilitiesModal = window.BackendCalendarUnavailabili
timeText: EALang.time,
hourText: EALang.hour,
minuteText: EALang.minutes,
firstDay: 0
firstDay: fDaynum
});
$dialog.find('#unavailable-start').val(start);
@ -237,7 +239,7 @@ window.BackendCalendarUnavailabilitiesModal = window.BackendCalendarUnavailabili
timeText: EALang.time,
hourText: EALang.hour,
minuteText: EALang.minutes,
firstDay: 0
firstDay: fDaynum
});
$dialog.find('#unavailable-end').val(end);

View file

@ -104,9 +104,12 @@ window.FrontendBook = window.FrontendBook || {};
}
});
var fDay = GlobalVariables.firstWeekday;
var fDaynum = GeneralFunctions.getWeekDayId(fDay);
$('#select-date').datepicker({
dateFormat: 'dd-mm-yy',
firstDay: 0,
firstDay: fDaynum,
minDate: 0,
defaultDate: Date.today(),

View file

@ -431,6 +431,60 @@ window.GeneralFunctions = window.GeneralFunctions || {};
return result;
};
/**
* Get the Id of a Weekday using the US week format and day names (Sunday=0) as used in the JS code of the appli, case insensitive, short and long names supported.
*
* @param {String} weekDayName The weekday name amongs Sunday, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday.
* @return {Integer} Returns the ID of the weekday.
*/
exports.getWeekDayId = function (weekDayName) {
var result;
switch (weekDayName.toLowerCase()) {
case 'sunday':
case 'sun':
result = 0;
break;
case 'monday':
case 'mon':
result = 1;
break;
case 'tuesday':
case 'tue':
result = 2;
break;
case 'wednesday':
case 'wed':
result = 3;
break;
case 'thursday':
case 'thu':
result = 4;
break;
case 'friday':
case 'fri':
result = 5;
break;
case 'saturday':
case 'sat':
result = 6;
break;
default:
throw new Error('Invalid weekday name provided!', weekDayName);
}
return result;
};
/**
* Get the name in lowercase of a Weekday using its Id.
*

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.'),
('first_weekday', 'sunday');
INSERT INTO `ea_migrations` VALUES ('12');
INSERT INTO `ea_migrations` VALUES ('13');