Refactored the booking settings page functionality and structure

This commit is contained in:
Alex Tselegidis 2021-12-20 09:16:44 +01:00
parent 7799f08da6
commit 4eec5fbe46
34 changed files with 624 additions and 232 deletions

View file

@ -20,7 +20,7 @@
*/
class Booking_settings extends EA_Controller {
/**
* Calendar constructor.
* Booking_settings constructor.
*/
public function __construct()
{
@ -54,22 +54,21 @@ class Booking_settings extends EA_Controller {
$user_id = session('user_id');
$role_slug = session('role_slug');
script_vars([
'booking_settings' => $this->settings_model->get_batch()
]);
html_vars([
'page_title' => lang('settings'),
'active_menu' => PRIV_SYSTEM_SETTINGS,
'user_display_name' => $this->accounts->get_user_display_name($user_id),
'timezones' => $this->timezones->to_array(),
'privileges' => $this->roles_model->get_permissions_by_slug($role_slug),
'system_settings' => $this->settings_model->get(),
]);
$this->load->view('pages/booking_settings', html_vars());
}
/**
* Save general settings.
* Save booking settings.
*/
public function save()
{
@ -80,26 +79,7 @@ class Booking_settings extends EA_Controller {
throw new Exception('You do not have the required permissions for this task.');
}
$settings = json_decode(request('settings', FALSE), TRUE);
// Check if phone number settings are valid.
$phone_number_required = setting('phone_number_required');
$phone_number_shown = FALSE;
foreach ($settings as $setting)
{
if ($setting['name'] === 'show_phone_number')
{
$phone_number_shown = $setting['value'];
}
}
if ($phone_number_required && ! $phone_number_shown)
{
throw new RuntimeException('You cannot hide the phone number in the booking form while it\'s also required!');
}
$settings = request('booking_settings', []);
foreach ($settings as $setting)
{

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'الموقع الالكتروني للشركة ي
$lang['go_to_booking_page'] = 'الذهاب الى صفحة الحجوزات';
$lang['settings_saved'] = 'تم حفظ الاعدادات بنجاح';
$lang['general'] = 'عام';
$lang['client_form'] = 'نموذج العميل';
$lang['booking'] = 'Booking';
$lang['visible'] = 'مرئي';
$lang['hidden'] = 'مختفي';
$lang['business_logic'] = 'منطق الأعمال';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Table';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'Препратката на организация
$lang['go_to_booking_page'] = 'Към страница за запазване.';
$lang['settings_saved'] = 'Настройките записани успешно.';
$lang['general'] = 'Общи';
$lang['client_form'] = 'Клиентска форма';
$lang['booking'] = 'Booking';
$lang['visible'] = 'видим';
$lang['hidden'] = 'Скрит';
$lang['business_logic'] = 'Бизнес логика';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Table';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'L\'enllaç a l\'organització hauria d\'enllaçar
$lang['go_to_booking_page'] = 'Ves a la pàgina de reserves';
$lang['settings_saved'] = 'Les configuracions s\'han desat correctament.';
$lang['general'] = 'General';
$lang['client_form'] = 'Formulari del client';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Visible';
$lang['hidden'] = 'Amagat';
$lang['business_logic'] = 'Lògica de negoci';
@ -333,4 +333,7 @@ $lang['default'] = 'Per defecte';
$lang['table'] = 'Taula';
$lang['date'] = 'Data';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = '公司的网址应当指向公司的官方网页 (
$lang['go_to_booking_page'] = '进入预约页面';
$lang['settings_saved'] = '设置成功保存.';
$lang['general'] = '一般设置';
$lang['client_form'] = '客户形态';
$lang['booking'] = 'Booking';
$lang['visible'] = '可见的';
$lang['hidden'] = '隐';
$lang['business_logic'] = '工作时间';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Table';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'Odkaz na web společnosti by měl vést na oficál
$lang['go_to_booking_page'] = 'Přejít na stránku rezervací';
$lang['settings_saved'] = 'Nastavení úspěšně uložena.';
$lang['general'] = 'Obecné';
$lang['client_form'] = 'Formulář klienta';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Viditelný';
$lang['hidden'] = 'Skrytý';
$lang['business_logic'] = 'Business logika';
@ -333,4 +333,7 @@ $lang['default'] = 'Výchozí';
$lang['table'] = 'Tabulka';
$lang['date'] = 'Datum';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'Firma linket skal gå ind på den officielle websi
$lang['go_to_booking_page'] = 'Gå til booking siden';
$lang['settings_saved'] = 'Indstillingerne er gemt';
$lang['general'] = 'Generelt';
$lang['client_form'] = 'Klientform';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Synlig';
$lang['hidden'] = 'Skjult';
$lang['business_logic'] = 'Forretningslogik';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Table';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'De link naar het bedrijf moet verwijzen naar de of
$lang['go_to_booking_page'] = 'Ga naar de boekingspagina';
$lang['settings_saved'] = 'Instellingen succesvol opgeslagen.';
$lang['general'] = 'Algemeen';
$lang['client_form'] = 'Klantformulier';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Zichtbaar';
$lang['hidden'] = 'Verborgen';
$lang['business_logic'] = 'Bedrijfsinstellingen';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Table';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'Company link should point to the official website
$lang['go_to_booking_page'] = 'Go To Booking Page';
$lang['settings_saved'] = 'Settings saved successfully.';
$lang['general'] = 'General';
$lang['client_form'] = 'Client Form';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Visible';
$lang['hidden'] = 'Hidden';
$lang['business_logic'] = 'Business Logic';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Table';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'Kotisivulinkin tulisi ohjata yrityksen kotisivuill
$lang['go_to_booking_page'] = 'Palaa ajanvaraussivulle';
$lang['settings_saved'] = 'Asetukset tallennettiin onnistuneesti.';
$lang['general'] = 'Yleinen';
$lang['client_form'] = 'Asiakaslomake';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Näkyvä';
$lang['hidden'] = 'Piilotettu';
$lang['business_logic'] = 'Työajat';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Table';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'Le lien de la société doit pointer vers le site
$lang['go_to_booking_page'] = 'Aller à la page de rendez-vous';
$lang['settings_saved'] = 'Paramètres sauvegardés avec succès.';
$lang['general'] = 'Général';
$lang['client_form'] = 'Formulaire de clientèle';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Visible';
$lang['hidden'] = 'Caché';
$lang['business_logic'] = 'Logique commerciale';
@ -333,4 +333,7 @@ $lang['default'] = 'Défaut';
$lang['table'] = 'Tableau';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -166,7 +166,7 @@ $lang['company_link_hint'] = 'Der Firmen-Link sollte auf die offizielle Webseite
$lang['go_to_booking_page'] = 'Weiter zur Buchungsseite';
$lang['settings_saved'] = 'Einstellungen erfolgreich gesichert.';
$lang['general'] = 'Allgemeines';
$lang['client_form'] = 'Kundenformular';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Sichtbar';
$lang['hidden'] = 'Versteckt';
$lang['business_logic'] = 'Unternehmerische Logik';

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'Ο σύνδεσμος εταιρείας θα πρ
$lang['go_to_booking_page'] = 'Πλοήγηση Στην Σελίδα Κράτησης';
$lang['settings_saved'] = 'Οι ρυθμίσεις αποθηκεύτηκαν επιτυχώς.';
$lang['general'] = 'Γενικά';
$lang['client_form'] = 'Μορφή πελάτη';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Ορατός';
$lang['hidden'] = 'Κρυμμένος';
$lang['business_logic'] = 'Επιχειρηματική Λογική';
@ -333,4 +333,7 @@ $lang['default'] = 'Προεπιλεγμένο';
$lang['table'] = 'Πίνακας';
$lang['date'] = 'Ημερομηνία';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'קישור החברה צריך לקשר לאתר
$lang['go_to_booking_page'] = 'עבור לדף ההזמנות';
$lang['settings_saved'] = 'ההגדרות נשמרו בהצלחה!';
$lang['general'] = 'כללי';
$lang['client_form'] = 'טופס הלקוח';
$lang['booking'] = 'Booking';
$lang['visible'] = 'גלוי';
$lang['hidden'] = 'מוּסתָר';
$lang['business_logic'] = 'לוגיקה עסקית';
@ -333,4 +333,7 @@ $lang['default'] = 'בְּרִירַת מֶחדָל';
$lang['table'] = 'טבלה';
$lang['date'] = 'תאריך';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'कंपनी की लिंक कंपन
$lang['go_to_booking_page'] = 'आरक्षण का पेज पर जाएं';
$lang['settings_saved'] = 'सेटिंग सफलतापूर्वक सेव.';
$lang['general'] = 'सामान्य';
$lang['client_form'] = 'क्लाइंट फॉर्म';
$lang['booking'] = 'Booking';
$lang['visible'] = 'दर्शनीय';
$lang['hidden'] = 'छिपा हुआ';
$lang['business_logic'] = 'व्यापार का तर्क';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Table';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'A vállalkozás linkje a cég hivatalos weblapjár
$lang['go_to_booking_page'] = 'Ugrás a foglalási oldalra';
$lang['settings_saved'] = 'Beállítások sikeresen mentve.';
$lang['general'] = 'Általános';
$lang['client_form'] = 'Ügyfélforma';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Látható';
$lang['hidden'] = 'Rejtett';
$lang['business_logic'] = 'Business Logic';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Table';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'Il link aziendale dovrebbe puntare al sito ufficia
$lang['go_to_booking_page'] = 'Vai alla pagina delle prenotazioni';
$lang['settings_saved'] = 'Impostazioni salvate con successo.';
$lang['general'] = 'Generale';
$lang['client_form'] = 'Forma del cliente';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Visible';
$lang['hidden'] = 'Nascosto';
$lang['business_logic'] = 'Business Logic';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Tabella';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = '会社のウェブサイトへのリンクを設
$lang['go_to_booking_page'] = '予約ページへ';
$lang['settings_saved'] = '設定は保存されました。';
$lang['general'] = '一般';
$lang['client_form'] = 'お客様のフォーム';
$lang['booking'] = 'Booking';
$lang['visible'] = '目に見える';
$lang['hidden'] = '目に見えません';
$lang['business_logic'] = '勤務時間設定';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Table';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'De Firmelink sollt op déi offiziell Websäit vun
$lang['go_to_booking_page'] = 'Gitt op d\'Buchungssäit';
$lang['settings_saved'] = 'Astellungen erfollegräich gespäichert.';
$lang['general'] = 'Allgemenges';
$lang['client_form'] = 'Client Form';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Fir siichtbar';
$lang['hidden'] = 'Verstoppen';
$lang['business_logic'] = 'Business Logik';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Table';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'कंपनी दुव्याने कंप
$lang['go_to_booking_page'] = 'आरक्षण पृष्ठावर जा';
$lang['settings_saved'] = 'सेव्ह यशस्वीरित्या सेट करीत आहे.';
$lang['general'] = 'सामान्य';
$lang['client_form'] = 'क्लायंट फॉर्म';
$lang['booking'] = 'Booking';
$lang['visible'] = 'दृश्यमान';
$lang['hidden'] = 'लपलेले';
$lang['business_logic'] = 'व्यवसाय तर्कशास्त्र';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Table';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -169,7 +169,7 @@ $lang['company_link_hint'] = 'لینک شرکت باید حاوی آدرس وب
$lang['go_to_booking_page'] = 'برو به صفحه ثبت ملاقات';
$lang['settings_saved'] = 'تنظیمات با موفقیت ذخیره شد';
$lang['general'] = 'عمومی';
$lang['client_form'] = 'فرم مشتری';
$lang['booking'] = 'Booking';
$lang['visible'] = 'قابل رویت';
$lang['hidden'] = 'پنهان';
$lang['business_logic'] = 'منطق تجارت';

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'Link firmowy powinien wskazywać na firmowe www. (
$lang['go_to_booking_page'] = 'Idź do strony bookowania';
$lang['settings_saved'] = 'Ustawienia zapisano.';
$lang['general'] = 'Ogólne';
$lang['client_form'] = 'Formularz klienta';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Widoczny';
$lang['hidden'] = 'Ukryty';
$lang['business_logic'] = 'Podział Firmy';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Table';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -169,7 +169,7 @@ $lang['company_link_hint'] = 'Endereço da empresa deve apontar para o site ofic
$lang['go_to_booking_page'] = 'Ir para a página de reserva';
$lang['settings_saved'] = 'Definições salvas com sucesso.';
$lang['general'] = 'Geral';
$lang['client_form'] = 'Forma de cliente';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Visível';
$lang['hidden'] = 'Escondido';
$lang['business_logic'] = 'Lógica de negócio';
@ -332,4 +332,7 @@ $lang['default'] = 'Padrão';
$lang['table'] = 'Tabela';
$lang['date'] = 'Data';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'Endereço da empresa deve apontar para o site ofic
$lang['go_to_booking_page'] = 'Ir para a página de reserva';
$lang['settings_saved'] = 'Definições guardadas com sucesso.';
$lang['general'] = 'Geral';
$lang['client_form'] = 'Forma de cliente';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Visível';
$lang['hidden'] = 'Escondido';
$lang['business_logic'] = 'Lógica de negócio';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Table';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'Linkul trebuie sa indice website-ul oficial al com
$lang['go_to_booking_page'] = 'La pagina de înregistrari';
$lang['settings_saved'] = 'Setari salvate.';
$lang['general'] = 'General';
$lang['client_form'] = 'Client Formular';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Vizibil';
$lang['hidden'] = 'Ascuns';
$lang['business_logic'] = 'Logica afacerii';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Table';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'Сайт компании должен указы
$lang['go_to_booking_page'] = 'Перейти на страницу заказов';
$lang['settings_saved'] = 'Настройки сохранены.';
$lang['general'] = 'Основные';
$lang['client_form'] = 'Форма клиента';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Видимый';
$lang['hidden'] = 'Скрытый';
$lang['business_logic'] = 'Бизнес-логика';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Table';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'Link firmy by mal odkazovať na oficiálnu stránk
$lang['go_to_booking_page'] = 'Prejsť na stránku rezervácií';
$lang['settings_saved'] = 'Nastavenie úspešne uložené.';
$lang['general'] = 'Všeobecný';
$lang['client_form'] = 'Tvar klienta';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Viditeľný';
$lang['hidden'] = 'Skrytý';
$lang['business_logic'] = 'Firemné údaje';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Table';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'El enlace de la empresa debe dirigir al sitio web
$lang['go_to_booking_page'] = 'Ir a la página para agendar';
$lang['settings_saved'] = 'Configuración guardada exitosamente';
$lang['general'] = 'General';
$lang['client_form'] = 'Formulario del cliente';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Visible';
$lang['hidden'] = 'Oculto';
$lang['business_logic'] = 'Lógica del negocio';
@ -333,4 +333,7 @@ $lang['default'] = 'Predeterminado';
$lang['table'] = 'Tabla';
$lang['date'] = 'Fecha';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'Länk till företagets hemsida. (obligatorisk)';
$lang['go_to_booking_page'] = 'Gå till bokningssidan.';
$lang['settings_saved'] = 'Inställningarna är sparade.';
$lang['general'] = 'Generellt';
$lang['client_form'] = 'Klientform';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Synlig';
$lang['hidden'] = 'Dold';
$lang['business_logic'] = 'Affärsregler';
@ -333,4 +333,7 @@ $lang['default'] = 'Standard';
$lang['table'] = 'Tabell';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -170,7 +170,7 @@ $lang['company_link_hint'] = 'Şirket web sitesi, şirketin resmi web sitesine y
$lang['go_to_booking_page'] = 'Rezervasyon Sayfasına Git';
$lang['settings_saved'] = 'Ayarlar başarıyla kaydedildi.';
$lang['general'] = 'Genel';
$lang['client_form'] = 'Müşteri formu';
$lang['booking'] = 'Booking';
$lang['visible'] = 'Gözle görülür';
$lang['hidden'] = 'Gizli';
$lang['business_logic'] = 'İş Mantığı';
@ -333,4 +333,7 @@ $lang['default'] = 'Default';
$lang['table'] = 'Table';
$lang['date'] = 'Date';
$lang['about'] = 'About';
$lang['booking_settings'] = 'Booking Settings';
$lang['display'] = 'Display';
$lang['require'] = 'Require';
// End

View file

@ -95,7 +95,7 @@
<?= lang('business_logic') ?>
</a>
<a class="dropdown-item" href="<?= site_url('booking_settings') ?>">
<?= lang('client_form') ?>
<?= lang('booking') ?>
</a>
<a class="dropdown-item" href="<?= site_url('legal_settings') ?>">
<?= lang('legal_contents') ?>

View file

@ -1,197 +1,292 @@
<?php
/**
* @var array $system_settings
* @var array $user_settings
* @var string $timezones
* @var array $privileges
*/
?>
<?php extend('layouts/backend_layout') ?>
<?php section('content') ?>
<div id="client-form-page" class="container-fluid backend-page">
<div id="client-form">
<form>
<fieldset>
<legend class="border-bottom mb-4">
<?= lang('Bookingsettings') ?>
<?php if ($privileges[PRIV_SYSTEM_SETTINGS]['edit'] == TRUE): ?>
<button type="button" class="save-settings btn btn-primary btn-sm mb-2"
data-tippy-content="<?= lang('save') ?>">
<i class="fas fa-check-square me-2"></i>
<?= lang('save') ?>
</button>
<?php endif ?>
</legend>
<div id="booking-settings-page" class="container backend-page">
<div id="booking-settings">
<div class="row">
<div class="col-lg-8 offset-lg-2">
<form>
<fieldset>
<legend class="d-flex justify-content-between align-items-center border-bottom mb-4 py-2">
<?= lang('booking_settings') ?>
<div class="wrapper row">
<div class="col-12 col-sm-3">
<div class="mb-3">
<label class="form-label" for="show-phone-number">
<?= lang('phone_number') ?>
</label>
<button id="show-phone-number" data-field="show_phone_number" type="button"
class="hide-toggle form-control form-sub-button">
<span class="hide-toggle-visible" hidden>
<img src="<?= base_url('assets/img/eye.svg') ?>" alt="eye"/>
<?= lang('visible') ?>
</span>
<span class="hide-toggle-hidden">
<img src="<?= base_url('assets/img/eye-hidden.svg') ?>" alt="eye-hidden"/>
<?= lang('hidden') ?>
</span>
</button>
</div>
<div class="mb-3">
<label class="form-label" for="show-address">
<?= lang('address') ?>
</label>
<button id="show-address" data-field="show_address" type="button"
class="hide-toggle form-control form-sub-button">
<span class="hide-toggle-visible" hidden>
<img src="<?= base_url('assets/img/eye.svg') ?>" alt="eye"/>
<?= lang('visible') ?>
</span>
<span class="hide-toggle-hidden">
<img src="<?= base_url('assets/img/eye-hidden.svg') ?>" alt="eye-hidden"/>
<?= lang('hidden') ?>
</span>
</button>
</div>
<div class="mb-3">
<label class="form-label" for="show-city">
<?= lang('city') ?>
</label>
<button id="show-city" data-field="show_city" type="button"
class="hide-toggle form-control form-sub-button">
<span class="hide-toggle-visible" hidden>
<img src="<?= base_url('assets/img/eye.svg') ?>" alt="eye"/>
<?= lang('visible') ?>
</span>
<span class="hide-toggle-hidden">
<img src="<?= base_url('assets/img/eye-hidden.svg') ?>" alt="eye-hidden"/>
<?= lang('hidden') ?>
</span>
</button>
</div>
<div class="mb-3">
<label class="form-label" for="show-zip-code">
<?= lang('zip_code') ?>
</label>
<button id="show-zip-code" data-field="show_zip_code" type="button"
class="hide-toggle form-control form-sub-button">
<span class="hide-toggle-visible" hidden>
<img src="<?= base_url('assets/img/eye.svg') ?>" alt="eye"/>
<?= lang('visible') ?>
</span>
<span class="hide-toggle-hidden">
<img src="<?= base_url('assets/img/eye-hidden.svg') ?>" alt="eye-hidden"/>
<?= lang('hidden') ?>
</span>
</button>
</div>
<div class="mb-3">
<label class="form-label" for="show-notes">
<?= lang('notes') ?>
</label>
<button id="show-notes" data-field="show_notes" type="button"
class="hide-toggle form-control form-sub-button">
<span class="hide-toggle-visible" hidden>
<img src="<?= base_url('assets/img/eye.svg') ?>" alt="eye"/>
<?= lang('visible') ?>
</span>
<span class="hide-toggle-hidden">
<img src="<?= base_url('assets/img/eye-hidden.svg') ?>" alt="eye-hidden"/>
<?= lang('hidden') ?>
</span>
</button>
</div>
</div>
<?php if (can('edit', PRIV_SYSTEM_SETTINGS)): ?>
<button type="button" id="save-settings" class="btn btn-primary btn-sm">
<i class="fas fa-check-square me-2"></i>
<?= lang('save') ?>
</button>
<?php endif ?>
</legend>
<div class="col-12 col-sm-9">
<div class="mb-3">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="customer-notifications">
<label class="form-label" class="custom-form-label" for="customer-notifications">
<?= lang('customer_notifications') ?>
</label>
<div class="row mb-5">
<div class="col-lg-6">
<div class="form-group mb-3">
<label for="first-name" class="form-label">
<?= lang('first_name') ?>
<span class="text-danger">*</span>
</label>
<input type="text" id="first-name" class="form-control mb-2" readonly/>
<div class="d-flex">
<div class="form-check form-switch me-4">
<input class="form-check-input display-switch" type="checkbox" id="display-first-name"
data-field="display_first_name">
<label class="form-check-label" for="display-first-name">
<?= lang('display') ?>
</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input require-switch" type="checkbox" id="require-first-name"
data-field="require_first_name">
<label class="form-check-label" for="require-first-name">
<?= lang('require') ?>
</label>
</div>
</div>
</div>
<div class="form-group mb-3">
<label for="last-name" class="form-label">
<?= lang('last_name') ?>
<span class="text-danger">*</span>
</label>
<input type="text" id="last-name" class="form-control mb-2" readonly/>
<div class="d-flex">
<div class="form-check form-switch me-4">
<input class="form-check-input display-switch" type="checkbox" id="display-last-name"
data-field="display_last_name">
<label class="form-check-label" for="display-last-name">
<?= lang('display') ?>
</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input require-switch" type="checkbox" id="require-last-name"
data-field="require_last_name">
<label class="form-check-label" for="require-last-name">
<?= lang('require') ?>
</label>
</div>
</div>
</div>
<div class="form-group mb-3">
<label for="email" class="form-label">
<?= lang('email') ?>
<span class="text-danger">*</span>
</label>
<input type="text" id="email" class="form-control mb-2" readonly/>
<div class="d-flex">
<div class="form-check form-switch me-4">
<input class="form-check-input display-switch" type="checkbox" id="display-email"
data-field="display_email">
<label class="form-check-label" for="display-email">
<?= lang('display') ?>
</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input require-switch" type="checkbox" id="require-email"
data-field="require_email">
<label class="form-check-label" for="require-email">
<?= lang('require') ?>
</label>
</div>
</div>
</div>
<div class="form-group mb-3">
<label for="phone-number" class="form-label">
<?= lang('phone_number') ?>
<span class="text-danger">*</span>
</label>
<input type="text" id="phone-number" class="form-control mb-2" readonly/>
<div class="d-flex">
<div class="form-check form-switch me-4">
<input class="form-check-input display-switch" type="checkbox" id="display-phone-number"
data-field="display_phone_number">
<label class="form-check-label" for="display-phone-number">
<?= lang('display') ?>
</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input require-switch" type="checkbox" id="require-phone-number"
data-field="require_phone_number">
<label class="form-check-label" for="require-phone-number">
<?= lang('require') ?>
</label>
</div>
</div>
</div>
</div>
<span class="form-text text-muted">
<?= lang('customer_notifications_hint') ?>
</span>
</div>
<div class="mb-3">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="require-captcha">
<label class="form-label" class="custom-form-label" for="require-captcha">
CAPTCHA
</label>
<div class="col-lg-6">
<div class="form-group mb-3">
<label for="address" class="form-label">
<?= lang('address') ?>
<span class="text-danger">*</span>
</label>
<input type="text" id="address" class="form-control mb-2" readonly/>
<div class="d-flex">
<div class="form-check form-switch me-4">
<input class="form-check-input display-switch" type="checkbox" id="display-address"
data-field="display_address">
<label class="form-check-label" for="display-address">
<?= lang('display') ?>
</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input require-switch" type="checkbox" id="require-address"
data-field="require_address">
<label class="form-check-label" for="require-address">
<?= lang('require') ?>
</label>
</div>
</div>
</div>
<div class="form-group mb-3">
<label for="city" class="form-label">
<?= lang('city') ?>
<span class="text-danger">*</span>
</label>
<input type="text" id="city" class="form-control mb-2" readonly/>
<div class="d-flex">
<div class="form-check form-switch me-4">
<input class="form-check-input display-switch" type="checkbox" id="display-city"
data-field="display_city">
<label class="form-check-label" for="display-city">
<?= lang('display') ?>
</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input require-switch" type="checkbox" id="require-city"
data-field="require_city">
<label class="form-check-label" for="require-city">
<?= lang('require') ?>
</label>
</div>
</div>
</div>
<div class="form-group mb-3">
<label for="zip-code" class="form-label">
<?= lang('zip_code') ?>
<span class="text-danger">*</span>
</label>
<input type="text" id="zip-code" class="form-control mb-2" readonly/>
<div class="d-flex">
<div class="form-check form-switch me-4">
<input class="form-check-input display-switch" type="checkbox" id="display-zip-code"
data-field="display_zip_code">
<label class="form-check-label" for="display-zip-code">
<?= lang('display') ?>
</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input require-switch" type="checkbox" id="require-zip-code"
data-field="require_zip_code">
<label class="form-check-label" for="require-zip-code">
<?= lang('require') ?>
</label>
</div>
</div>
</div>
<div class="form-group mb-3">
<label for="notes" class="form-label">
<?= lang('notes') ?>
<span class="text-danger">*</span>
</label>
<textarea id="notes" class="form-control mb-2" rows="1" readonly></textarea>
<div class="d-flex">
<div class="form-check form-switch me-4">
<input class="form-check-input display-switch" type="checkbox" id="display-notes"
data-field="display_notes">
<label class="form-check-label" for="display-notes">
<?= lang('display') ?>
</label>
</div>
<div class="form-check form-switch">
<input class="form-check-input require-switch" type="checkbox" id="require-notes"
data-field="require_notes">
<label class="form-check-label" for="require-notes">
<?= lang('require') ?>
</label>
</div>
</div>
</div>
</div>
<span class="form-text text-muted">
<?= lang('require_captcha_hint') ?>
</span>
</div>
<div class="mb-3">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="require-phone-number">
<label class="form-label" class="custom-form-label" for="require-phone-number">
<?= lang('phone_number') ?>
</label>
<div class="row">
<div class="col-12">
<div class="mb-3">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="customer-notifications"
data-field="customer_notifications">
<label class="form-check-label" for="customer-notifications">
<?= lang('customer_notifications') ?>
</label>
</div>
<div class="form-text text-muted">
<small>
<?= lang('customer_notifications_hint') ?>
</small>
</div>
</div>
<div class="mb-3">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="require-captcha"
data-field="require_captcha">
<label class="form-check-label" for="require-captcha">
CAPTCHA
</label>
</div>
<div class="form-text text-muted">
<small>
<?= lang('require_captcha_hint') ?>
</small>
</div>
</div>
<div class="mb-3">
<div class="form-check form-switch">
<input class="form-check-input" type="checkbox" id="display-any-provider"
data-field="display_any_provider">
<label class="form-check-label" for="display-any-provider">
<?= lang('any_provider') ?>
</label>
</div>
<div class="form-text text-muted">
<small>
<?= lang('display_any_provider_hint') ?>
</small>
</div>
</div>
</div>
<span class="form-text text-muted">
<?= lang('require_phone_number_hint') ?>
</span>
</div>
<div class="mb-3">
<div class="custom-control custom-switch">
<input type="checkbox" class="custom-control-input" id="display-any-provider">
<label class="form-label" class="custom-form-label" for="display-any-provider">
<?= lang('any_provider') ?>
</label>
</div>
<span class="form-text text-muted">
<?= lang('display_any_provider_hint') ?>
</span>
</div>
</div>
</div>
</fieldset>
</form>
</fieldset>
</form>
</div>
</div>
</div>
</div>
<?php section('content') ?>
<?php section('scripts') ?>
<script src="<?= asset_url('assets/js/pages/backend_settings_client_form_helper.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/backend_settings_client_form.js') ?>"></script>
<script>
var GlobalVariables = {
csrfToken: <?= json_encode($this->security->get_csrf_hash()) ?>,
baseUrl: <?= json_encode(config('base_url')) ?>,
dateFormat: <?= json_encode(setting('date_format')) ?>,
timeFormat: <?= json_encode(setting('time_format')) ?>,
firstWeekday: <?= json_encode(setting('first_weekday')) ?>,
timezones: <?= json_encode($timezones) ?>,
settings: {
system: <?= json_encode($system_settings) ?>,
},
user: {
id: <?= session('user_id') ?>,
email: <?= json_encode(session('user_email')) ?>,
timezone: <?= json_encode(session('timezone')) ?>,
role_slug: <?= json_encode(session('role_slug')) ?>,
privileges: <?= json_encode($privileges) ?>
}
};
$(function () {
BackendSettingsClientForm.initialize(true);
});
</script>
<script src="<?= asset_url('assets/js/utils/url.js') ?>"></script>
<script src="<?= asset_url('assets/js/http/booking_settings_http_client.js') ?>"></script>
<script src="<?= asset_url('assets/js/pages/booking_settings.js') ?>"></script>
<?php section('scripts') ?>

View file

@ -0,0 +1,34 @@
/* ----------------------------------------------------------------------------
* Easy!Appointments - Open Source Web Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.5.0
* ---------------------------------------------------------------------------- */
App.Http.BookingSettings = (function () {
/**
* Save booking settings.
*
* @param {Object} bookingSettings
*
* @return {Object}
*/
function save(bookingSettings) {
const url = App.Utils.Url.siteUrl('booking_settings/save');
const data = {
csrf_token: App.Vars.csrf_token,
booking_settings: bookingSettings
};
return $.post(url, data);
}
return {
save
};
})();

View file

@ -0,0 +1,202 @@
/* ----------------------------------------------------------------------------
* Easy!Appointments - Open Source Web Scheduler
*
* @package EasyAppointments
* @author A.Tselegidis <alextselegidis@gmail.com>
* @copyright Copyright (c) Alex Tselegidis
* @license https://opensource.org/licenses/GPL-3.0 - GPLv3
* @link https://easyappointments.org
* @since v1.5.0
* ---------------------------------------------------------------------------- */
/**
* Booking Settings
*
* Contains the functionality of the booking settings page.
*/
App.Pages.BookingSettings = (function () {
const $bookingSettings = $('#booking-settings');
const $saveSettings = $('#save-settings');
/**
* Check if the form has invalid values.
*
* @return {Boolean}
*/
function isInvalid() {
try {
$('#booking-settings .is-invalid').removeClass('is-invalid');
// Validate required fields.
let missingRequiredFields = false;
$('#booking-settings .required').each((index, requiredField) => {
const $requiredField = $(requiredField);
if (!$requiredField.val()) {
$requiredField.addClass('is-invalid');
missingRequiredFields = true;
}
});
if (missingRequiredFields) {
throw new Error(App.Lang.fields_are_required);
}
return false;
} catch (error) {
Backend.displayNotification(error.message);
return true;
}
}
/**
* Apply the booking settings into the page.
*
* @param {Object} bookingSettings
*/
function deserialize(bookingSettings) {
bookingSettings.forEach((bookingSetting) => {
const $field = $('[data-field="' + bookingSetting.name + '"]');
if ($field.is(':checkbox')) {
$field.prop('checked', Boolean(Number(bookingSetting.value)));
} else {
$field.val(bookingSetting.value);
}
});
}
/**
* Serialize the page values into an array.
*
* @returns {Array}
*/
function serialize() {
const bookingSettings = [];
$('[data-field]').each((index, field) => {
const $field = $(field);
bookingSettings.push({
name: $field.data('field'),
value: $field.is(':checkbox') ? Number($field.prop('checked')) : $field.val()
});
});
return bookingSettings;
}
/**
* Update the UI based on the display switch state.
*
* @param {jQuery} $displaySwitch
*/
function updateDisplaySwitch($displaySwitch) {
const isChecked = $displaySwitch.prop('checked');
const $formGroup = $displaySwitch.closest('.form-group');
$formGroup.find('.require-switch').prop('disabled', !isChecked);
$formGroup.find('.form-label, .form-control').toggleClass('opacity-25', !isChecked);
if (!isChecked) {
$formGroup.find('.require-switch').prop('checked', false);
$formGroup.find('.text-danger').hide();
}
}
/**
* Update the UI based on the require switch state.
*
* @param {jQuery} $requireSwitch
*/
function updateRequireSwitch($requireSwitch) {
const isChecked = $requireSwitch.prop('checked');
const $formGroup = $requireSwitch.closest('.form-group');
$formGroup.find('.text-danger').toggle(isChecked);
}
/**
* Update the UI based on the initial values.
*/
function applyInitialState() {
$bookingSettings.find('.display-switch').each(function (index, displaySwitch) {
const $displaySwitch = $(displaySwitch);
updateDisplaySwitch($displaySwitch);
});
$bookingSettings.find('.require-switch').each(function (index, requireSwitch) {
const $requireSwitch = $(requireSwitch);
updateRequireSwitch($requireSwitch);
});
}
/**
* Save the account information.
*/
function onSaveSettingsClick() {
if (isInvalid()) {
Backend.displayNotification(App.Lang.settings_are_invalid);
return;
}
const bookingSettings = serialize();
App.Http.BookingSettings.save(bookingSettings).done(() => {
Backend.displayNotification(App.Lang.settings_saved);
});
}
/**
* Update the UI.
*
* @param {jQuery} event
*/
function onDisplaySwitchClick(event) {
const $displaySwitch = $(event.target);
updateDisplaySwitch($displaySwitch);
}
/**
* Update the UI.
*
* @param {Event} event
*/
function onRequireSwitchClick(event) {
const $requireSwitch = $(event.target);
updateRequireSwitch($requireSwitch);
}
/**
* Initialize on document ready.
*/
function init() {
const bookingSettings = App.Vars.booking_settings;
deserialize(bookingSettings);
$saveSettings.on('click', onSaveSettingsClick);
$bookingSettings
.on('click', '.display-switch', onDisplaySwitchClick)
.on('click', '.require-switch', onRequireSwitchClick);
applyInitialState();
Backend.placeFooterToBottom();
}
document.addEventListener('DOMContentLoaded', init);
return {};
})();