diff --git a/CHANGELOG.md b/CHANGELOG.md index 06be6cc4..20c90b76 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,7 @@ developers to maintain and readjust their custom modifications on the main proje - Create new layout structure for the markup, so that common HTML markup is being reused (#1152) - Have an option to hide customer data fields during booking (#1081) - Add a SECURITY.md file to the repository (#1122) +- Add support for custom fields on customers (#1133) ### Changed diff --git a/application/controllers/Customers.php b/application/controllers/Customers.php index a57c123c..a8aabef0 100644 --- a/application/controllers/Customers.php +++ b/application/controllers/Customers.php @@ -18,7 +18,8 @@ * * @package Controllers */ -class Customers extends EA_Controller { +class Customers extends EA_Controller +{ /** * Customers constructor. */ @@ -49,10 +50,8 @@ class Customers extends EA_Controller { $user_id = session('user_id'); - if (cannot('view', PRIV_CUSTOMERS)) - { - if ($user_id) - { + if (cannot('view', PRIV_CUSTOMERS)) { + if ($user_id) { abort(403, 'Forbidden'); } @@ -75,8 +74,7 @@ class Customers extends EA_Controller { $secretary_providers = []; - if ($role_slug === DB_SLUG_SECRETARY) - { + if ($role_slug === DB_SLUG_SECRETARY) { $secretary = $this->secretaries_model->find($user_id); $secretary_providers = $secretary['providers']; @@ -88,7 +86,7 @@ class Customers extends EA_Controller { 'date_format' => $date_format, 'time_format' => $time_format, 'timezones' => $this->timezones->to_array(), - 'secretary_providers' => $secretary_providers, + 'secretary_providers' => $secretary_providers ]); html_vars([ @@ -105,21 +103,45 @@ class Customers extends EA_Controller { 'require_address' => $require_address, 'require_city' => $require_city, 'require_zip_code' => $require_zip_code, - 'available_languages' => config('available_languages'), + 'available_languages' => config('available_languages') ]); $this->load->view('pages/customers'); } + /** + * Find a customer. + */ + public function find() + { + try { + if (cannot('view', PRIV_CUSTOMERS)) { + abort(403, 'Forbidden'); + } + + $user_id = session('user_id'); + + $customer_id = request('customer_id'); + + if (!$this->permissions->has_customer_access($user_id, $customer_id)) { + abort(403, 'Forbidden'); + } + + $customer = $this->customers_model->find($customer_id); + + json_response($customer); + } catch (Throwable $e) { + json_exception($e); + } + } + /** * Filter customers by the provided keyword. */ public function search() { - try - { - if (cannot('view', PRIV_CUSTOMERS)) - { + try { + if (cannot('view', PRIV_CUSTOMERS)) { abort(403, 'Forbidden'); } @@ -135,10 +157,8 @@ class Customers extends EA_Controller { $user_id = session('user_id'); - foreach ($customers as $index => &$customer) - { - if ( ! $this->permissions->has_customer_access($user_id, $customer['id'])) - { + foreach ($customers as $index => &$customer) { + if (!$this->permissions->has_customer_access($user_id, $customer['id'])) { unset($customers[$index]); continue; @@ -146,21 +166,15 @@ class Customers extends EA_Controller { $appointments = $this->appointments_model->get(['id_users_customer' => $customer['id']]); - foreach ($appointments as &$appointment) - { - $this->appointments_model->load($appointment, [ - 'service', - 'provider', - ]); + foreach ($appointments as &$appointment) { + $this->appointments_model->load($appointment, ['service', 'provider']); } $customer['appointments'] = $appointments; } json_response(array_values($customers)); - } - catch (Throwable $e) - { + } catch (Throwable $e) { json_exception($e); } } @@ -170,15 +184,12 @@ class Customers extends EA_Controller { */ public function store() { - try - { - if (cannot('add', PRIV_CUSTOMERS)) - { + try { + if (cannot('add', PRIV_CUSTOMERS)) { abort(403, 'Forbidden'); } - if (session('role_slug') !== DB_SLUG_ADMIN && setting('limit_customer_visibility')) - { + if (session('role_slug') !== DB_SLUG_ADMIN && setting('limit_customer_visibility')) { abort(403); } @@ -196,6 +207,11 @@ class Customers extends EA_Controller { 'notes', 'timezone', 'language', + 'custom_field_1', + 'custom_field_2', + 'custom_field_3', + 'custom_field_4', + 'custom_field_5' ]); $customer_id = $this->customers_model->save($customer); @@ -205,12 +221,10 @@ class Customers extends EA_Controller { $this->webhooks_client->trigger(WEBHOOK_CUSTOMER_SAVE, $customer); json_response([ - 'success' => TRUE, + 'success' => true, 'id' => $customer_id ]); - } - catch (Throwable $e) - { + } catch (Throwable $e) { json_exception($e); } } @@ -220,10 +234,8 @@ class Customers extends EA_Controller { */ public function update() { - try - { - if (cannot('edit', PRIV_CUSTOMERS)) - { + try { + if (cannot('edit', PRIV_CUSTOMERS)) { abort(403, 'Forbidden'); } @@ -231,8 +243,7 @@ class Customers extends EA_Controller { $customer = request('customer'); - if ( ! $this->permissions->has_customer_access($user_id, $customer['id'])) - { + if (!$this->permissions->has_customer_access($user_id, $customer['id'])) { abort(403, 'Forbidden'); } @@ -249,6 +260,11 @@ class Customers extends EA_Controller { 'notes', 'timezone', 'language', + 'custom_field_1', + 'custom_field_2', + 'custom_field_3', + 'custom_field_4', + 'custom_field_5' ]); $customer_id = $this->customers_model->save($customer); @@ -258,12 +274,10 @@ class Customers extends EA_Controller { $this->webhooks_client->trigger(WEBHOOK_CUSTOMER_SAVE, $customer); json_response([ - 'success' => TRUE, + 'success' => true, 'id' => $customer_id ]); - } - catch (Throwable $e) - { + } catch (Throwable $e) { json_exception($e); } } @@ -273,10 +287,8 @@ class Customers extends EA_Controller { */ public function destroy() { - try - { - if (cannot('delete', PRIV_CUSTOMERS)) - { + try { + if (cannot('delete', PRIV_CUSTOMERS)) { abort(403, 'Forbidden'); } @@ -284,8 +296,7 @@ class Customers extends EA_Controller { $customer_id = request('customer_id'); - if ( ! $this->permissions->has_customer_access($user_id, $customer_id)) - { + if (!$this->permissions->has_customer_access($user_id, $customer_id)) { abort(403, 'Forbidden'); } @@ -296,42 +307,9 @@ class Customers extends EA_Controller { $this->webhooks_client->trigger(WEBHOOK_CUSTOMER_DELETE, $customer); json_response([ - 'success' => TRUE, + 'success' => true ]); - } - catch (Throwable $e) - { - json_exception($e); - } - } - - /** - * Find a customer. - */ - public function find() - { - try - { - if (cannot('view', PRIV_CUSTOMERS)) - { - abort(403, 'Forbidden'); - } - - $user_id = session('user_id'); - - $customer_id = request('customer_id'); - - if ( ! $this->permissions->has_customer_access($user_id, $customer_id)) - { - abort(403, 'Forbidden'); - } - - $customer = $this->customers_model->find($customer_id); - - json_response($customer); - } - catch (Throwable $e) - { + } catch (Throwable $e) { json_exception($e); } } diff --git a/application/language/arabic/translations_lang.php b/application/language/arabic/translations_lang.php index 1aa6b9fd..2d473dc8 100755 --- a/application/language/arabic/translations_lang.php +++ b/application/language/arabic/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/bulgarian/translations_lang.php b/application/language/bulgarian/translations_lang.php index c919270b..c76cfeaf 100755 --- a/application/language/bulgarian/translations_lang.php +++ b/application/language/bulgarian/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/catalan/translations_lang.php b/application/language/catalan/translations_lang.php index fa3e2147..6b68fe9e 100644 --- a/application/language/catalan/translations_lang.php +++ b/application/language/catalan/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/chinese/translations_lang.php b/application/language/chinese/translations_lang.php index 5a972e7c..0c2d8efe 100755 --- a/application/language/chinese/translations_lang.php +++ b/application/language/chinese/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/croatian/translations_lang.php b/application/language/croatian/translations_lang.php index 62d4f583..21244e59 100644 --- a/application/language/croatian/translations_lang.php +++ b/application/language/croatian/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/czech/translations_lang.php b/application/language/czech/translations_lang.php index 2f68d2eb..30c868d4 100644 --- a/application/language/czech/translations_lang.php +++ b/application/language/czech/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/danish/translations_lang.php b/application/language/danish/translations_lang.php index 868521da..efc43a86 100755 --- a/application/language/danish/translations_lang.php +++ b/application/language/danish/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/dutch/translations_lang.php b/application/language/dutch/translations_lang.php index 63015f94..ad03ef53 100755 --- a/application/language/dutch/translations_lang.php +++ b/application/language/dutch/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/english/translations_lang.php b/application/language/english/translations_lang.php index 2d931dba..d721dffd 100755 --- a/application/language/english/translations_lang.php +++ b/application/language/english/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/estonian/translations_lang.php b/application/language/estonian/translations_lang.php index 09c14b66..63a8d36f 100644 --- a/application/language/estonian/translations_lang.php +++ b/application/language/estonian/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/finnish/translations_lang.php b/application/language/finnish/translations_lang.php index 669ac321..6ee251e8 100755 --- a/application/language/finnish/translations_lang.php +++ b/application/language/finnish/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/french/translations_lang.php b/application/language/french/translations_lang.php index b6c320a0..f7448097 100755 --- a/application/language/french/translations_lang.php +++ b/application/language/french/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/german/translations_lang.php b/application/language/german/translations_lang.php index 8450646c..745fa458 100755 --- a/application/language/german/translations_lang.php +++ b/application/language/german/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/greek/translations_lang.php b/application/language/greek/translations_lang.php index a9322c72..99588172 100755 --- a/application/language/greek/translations_lang.php +++ b/application/language/greek/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/hebrew/translations_lang.php b/application/language/hebrew/translations_lang.php index 78e8c287..fd575159 100644 --- a/application/language/hebrew/translations_lang.php +++ b/application/language/hebrew/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/hindi/translations_lang.php b/application/language/hindi/translations_lang.php index 21b9387b..97df25f2 100755 --- a/application/language/hindi/translations_lang.php +++ b/application/language/hindi/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/hungarian/translations_lang.php b/application/language/hungarian/translations_lang.php index c2c75f34..2e79f03d 100755 --- a/application/language/hungarian/translations_lang.php +++ b/application/language/hungarian/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/italian/translations_lang.php b/application/language/italian/translations_lang.php index 9a1f0172..93d6b75a 100755 --- a/application/language/italian/translations_lang.php +++ b/application/language/italian/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/japanese/translations_lang.php b/application/language/japanese/translations_lang.php index e3339b19..7467722d 100755 --- a/application/language/japanese/translations_lang.php +++ b/application/language/japanese/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/luxembourgish/translations_lang.php b/application/language/luxembourgish/translations_lang.php index c1b6f34a..3a2ef359 100755 --- a/application/language/luxembourgish/translations_lang.php +++ b/application/language/luxembourgish/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/marathi/translations_lang.php b/application/language/marathi/translations_lang.php index d836296c..3a733535 100644 --- a/application/language/marathi/translations_lang.php +++ b/application/language/marathi/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/persian/translations_lang.php b/application/language/persian/translations_lang.php index 7d6a6609..e3e8d9df 100644 --- a/application/language/persian/translations_lang.php +++ b/application/language/persian/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/polish/translations_lang.php b/application/language/polish/translations_lang.php index 152c54b2..6579b25d 100755 --- a/application/language/polish/translations_lang.php +++ b/application/language/polish/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/portuguese-br/translations_lang.php b/application/language/portuguese-br/translations_lang.php index e8afc35a..2a7c8c95 100755 --- a/application/language/portuguese-br/translations_lang.php +++ b/application/language/portuguese-br/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/portuguese/translations_lang.php b/application/language/portuguese/translations_lang.php index aa57636a..26af230b 100755 --- a/application/language/portuguese/translations_lang.php +++ b/application/language/portuguese/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/romanian/translations_lang.php b/application/language/romanian/translations_lang.php index 0ff129ee..76499148 100755 --- a/application/language/romanian/translations_lang.php +++ b/application/language/romanian/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/russian/translations_lang.php b/application/language/russian/translations_lang.php index fe627163..51e9c291 100644 --- a/application/language/russian/translations_lang.php +++ b/application/language/russian/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/serbian/translations_lang.php b/application/language/serbian/translations_lang.php index 193bdc74..e0569d02 100644 --- a/application/language/serbian/translations_lang.php +++ b/application/language/serbian/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/slovak/translations_lang.php b/application/language/slovak/translations_lang.php index 6694049b..7cd6b86b 100755 --- a/application/language/slovak/translations_lang.php +++ b/application/language/slovak/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/spanish/translations_lang.php b/application/language/spanish/translations_lang.php index d41409fc..30a70e75 100755 --- a/application/language/spanish/translations_lang.php +++ b/application/language/spanish/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/swedish/translations_lang.php b/application/language/swedish/translations_lang.php index d714a206..f99f6a6b 100644 --- a/application/language/swedish/translations_lang.php +++ b/application/language/swedish/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/language/turkish/translations_lang.php b/application/language/turkish/translations_lang.php index 6546d518..7bd07f72 100755 --- a/application/language/turkish/translations_lang.php +++ b/application/language/turkish/translations_lang.php @@ -446,5 +446,7 @@ $lang['blocked_periods'] = 'Blocked Periods'; $lang['blocked_period_save'] = 'Blocked Period Save'; $lang['blocked_period_delete'] = 'Blocked Period Delete'; $lang['blocked_periods_hint'] = 'Define periods of time where public bookings will be disabled for all providers (e.g. closed dates, holidays etc.).'; -$lang['auxiliary_field'] = 'Auxiliary Field'; +$lang['custom_field'] = 'Custom Field'; +$lang['custom_fields'] = 'Custom Fields'; +$lang['label'] = 'Label'; // End diff --git a/application/migrations/050_add_custom_fields_columns_to_users_table.php b/application/migrations/050_add_custom_fields_columns_to_users_table.php new file mode 100644 index 00000000..ee162015 --- /dev/null +++ b/application/migrations/050_add_custom_fields_columns_to_users_table.php @@ -0,0 +1,56 @@ + + * @copyright Copyright (c) Alex Tselegidis + * @license https://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link https://easyappointments.org + * @since v1.4.0 + * ---------------------------------------------------------------------------- */ + +class Migration_Add_custom_fields_columns_to_users_table extends EA_Migration +{ + /** + * @var int + */ + private const FIELD_NUMBER = 5; + + /** + * Upgrade method. + */ + public function up() + { + for ($i = self::FIELD_NUMBER; $i > 0; $i--) { + $field_name = 'custom_field_' . $i; + + if (!$this->db->field_exists($field_name, 'users')) { + $fields = [ + $field_name => [ + 'type' => 'TEXT', + 'null' => true, + 'after' => 'language' + ] + ]; + + $this->dbforge->add_column('users', $fields); + } + } + } + + /** + * Downgrade method. + */ + public function down() + { + for ($i = self::FIELD_NUMBER; $i > 0; $i--) { + $field_name = 'custom_fields_' . $i; + + if ($this->db->field_exists($field_name, 'users')) { + $this->dbforge->drop_column('users', $field_name); + } + } + } +} diff --git a/application/migrations/051_insert_custom_field_rows_to_settings_table.php b/application/migrations/051_insert_custom_field_rows_to_settings_table.php new file mode 100644 index 00000000..0e4fe4d7 --- /dev/null +++ b/application/migrations/051_insert_custom_field_rows_to_settings_table.php @@ -0,0 +1,65 @@ + + * @copyright Copyright (c) Alex Tselegidis + * @license https://opensource.org/licenses/GPL-3.0 - GPLv3 + * @link https://easyappointments.org + * @since v1.4.0 + * ---------------------------------------------------------------------------- */ + +class Migration_Insert_custom_field_rows_to_settings_table extends EA_Migration +{ + /** + * @var int + */ + private const FIELD_NUMBER = 5; + + private const SETTINGS = [ + 'display' => '0', + 'require' => '0', + 'label' => '' + ]; + + /** + * Upgrade method. + */ + public function up() + { + for ($i = 1; $i <= self::FIELD_NUMBER; $i++) { + $field_name = 'custom_field_' . $i; + + foreach (self::SETTINGS as $name => $default_value) { + $setting_name = $name . '_' . $field_name; + + if (!$this->db->get_where('settings', ['name' => $setting_name])->num_rows()) { + $this->db->insert('settings', [ + 'name' => $setting_name, + 'value' => $default_value + ]); + } + } + } + } + + /** + * Downgrade method. + */ + public function down() + { + for ($i = 1; $i >= self::FIELD_NUMBER; $i++) { + $field_name = 'custom_field_' . $i; + + foreach (self::SETTINGS as $name => $default_value) { + $setting_name = $name . '_' . $field_name; + + if ($this->db->get_where('settings', ['name' => $setting_name])->num_rows()) { + $this->db->delete('settings', ['name' => $setting_name]); + } + } + } + } +} diff --git a/application/models/Customers_model.php b/application/models/Customers_model.php index 1eaa9ab0..869a234c 100644 --- a/application/models/Customers_model.php +++ b/application/models/Customers_model.php @@ -18,13 +18,14 @@ * * @package Models */ -class Customers_model extends EA_Model { +class Customers_model extends EA_Model +{ /** * @var array */ protected array $casts = [ 'id' => 'integer', - 'id_roles' => 'integer', + 'id_roles' => 'integer' ]; /** @@ -42,7 +43,12 @@ class Customers_model extends EA_Model { 'zip' => 'zip_code', 'timezone' => 'timezone', 'language' => 'language', - 'notes' => 'notes', + 'customField1' => 'custom_field_1', + 'customField2' => 'custom_field_2', + 'customField3' => 'custom_field_3', + 'customField4' => 'custom_field_4', + 'customField5' => 'custom_field_5', + 'notes' => 'notes' ]; /** @@ -58,17 +64,13 @@ class Customers_model extends EA_Model { { $this->validate($customer); - if ($this->exists($customer) && empty($customer['id'])) - { + if ($this->exists($customer) && empty($customer['id'])) { $customer['id'] = $this->find_record_id($customer); } - if (empty($customer['id'])) - { + if (empty($customer['id'])) { return $this->insert($customer); - } - else - { + } else { return $this->update($customer); } } @@ -83,13 +85,13 @@ class Customers_model extends EA_Model { public function validate(array $customer) { // If a customer ID is provided then check whether the record really exists in the database. - if ( ! empty($customer['id'])) - { + if (!empty($customer['id'])) { $count = $this->db->get_where('users', ['id' => $customer['id']])->num_rows(); - if ( ! $count) - { - throw new InvalidArgumentException('The provided customer ID does not exist in the database: ' . $customer['id']); + if (!$count) { + throw new InvalidArgumentException( + 'The provided customer ID does not exist in the database: ' . $customer['id'] + ); } } @@ -103,31 +105,27 @@ class Customers_model extends EA_Model { $require_zip_code = filter_var(setting('require_zip_code'), FILTER_VALIDATE_BOOLEAN); if ( - (empty($customer['first_name']) && $require_first_name) - || (empty($customer['last_name']) && $require_last_name) - || (empty($customer['email']) && $require_email) - || (empty($customer['phone_number']) && $require_phone_number) - || (empty($customer['address']) && $require_address) - || (empty($customer['city']) && $require_city) - || (empty($customer['zip_code']) && $require_zip_code) - ) - { - throw new InvalidArgumentException('Not all required fields are provided: ' . print_r($customer, TRUE)); + (empty($customer['first_name']) && $require_first_name) || + (empty($customer['last_name']) && $require_last_name) || + (empty($customer['email']) && $require_email) || + (empty($customer['phone_number']) && $require_phone_number) || + (empty($customer['address']) && $require_address) || + (empty($customer['city']) && $require_city) || + (empty($customer['zip_code']) && $require_zip_code) + ) { + throw new InvalidArgumentException('Not all required fields are provided: ' . print_r($customer, true)); } - if ( ! empty($customer['email'])) - { + if (!empty($customer['email'])) { // Validate the email address. - if ( ! filter_var($customer['email'], FILTER_VALIDATE_EMAIL)) - { + if (!filter_var($customer['email'], FILTER_VALIDATE_EMAIL)) { throw new InvalidArgumentException('Invalid email address provided: ' . $customer['email']); } // Make sure the email address is unique. - $customer_id = $customer['id'] ?? NULL; + $customer_id = $customer['id'] ?? null; - $count = $this - ->db + $count = $this->db ->select() ->from('users') ->join('roles', 'roles.id = users.id_roles', 'inner') @@ -137,13 +135,123 @@ class Customers_model extends EA_Model { ->get() ->num_rows(); - if ($count > 0) - { - throw new InvalidArgumentException('The provided email address is already in use, please use a different one.'); + if ($count > 0) { + throw new InvalidArgumentException( + 'The provided email address is already in use, please use a different one.' + ); } } } + /** + * Get all customers that match the provided criteria. + * + * @param array|string|null $where Where conditions. + * @param int|null $limit Record limit. + * @param int|null $offset Record offset. + * @param string|null $order_by Order by. + * + * @return array Returns an array of customers. + */ + public function get( + array|string $where = null, + int $limit = null, + int $offset = null, + string $order_by = null + ): array { + $role_id = $this->get_customer_role_id(); + + if ($where !== null) { + $this->db->where($where); + } + + if ($order_by !== null) { + $this->db->order_by($order_by); + } + + $customers = $this->db->get_where('users', ['id_roles' => $role_id], $limit, $offset)->result_array(); + + foreach ($customers as &$customer) { + $this->cast($customer); + } + + return $customers; + } + + /** + * Get the customer role ID. + * + * @return int Returns the role ID. + */ + public function get_customer_role_id(): int + { + $role = $this->db->get_where('roles', ['slug' => DB_SLUG_CUSTOMER])->row_array(); + + if (empty($role)) { + throw new RuntimeException('The customer role was not found in the database.'); + } + + return $role['id']; + } + + /** + * Check if a particular customer record already exists in the database. + * + * @param array $customer Associative array with the customer data. + * + * @return bool Returns whether there is a record matching the provided one or not. + * + * @throws InvalidArgumentException + */ + public function exists(array $customer): bool + { + if (empty($customer['email'])) { + return false; + } + + $count = $this->db + ->select() + ->from('users') + ->join('roles', 'roles.id = users.id_roles', 'inner') + ->where('users.email', $customer['email']) + ->where('roles.slug', DB_SLUG_CUSTOMER) + ->get() + ->num_rows(); + + return $count > 0; + } + + /** + * Find the record ID of a customer. + * + * @param array $customer Associative array with the customer data. + * + * @return int Returns the ID of the record that matches the provided argument. + * + * @throws InvalidArgumentException + */ + public function find_record_id(array $customer): int + { + if (empty($customer['email'])) { + throw new InvalidArgumentException('The customer email was not provided: ' . print_r($customer, true)); + } + + $customer = $this->db + ->select('users.id') + ->from('users') + ->join('roles', 'roles.id = users.id_roles', 'inner') + ->where('users.email', $customer['email']) + ->where('roles.slug', DB_SLUG_CUSTOMER) + ->get() + ->row_array(); + + if (empty($customer)) { + throw new InvalidArgumentException('Could not find customer record id.'); + } + + return (int) $customer['id']; + } + /** * Insert a new customer into the database. * @@ -159,8 +267,7 @@ class Customers_model extends EA_Model { $customer['update_datetime'] = date('Y-m-d H:i:s'); $customer['id_roles'] = $this->get_customer_role_id(); - if ( ! $this->db->insert('users', $customer)) - { + if (!$this->db->insert('users', $customer)) { throw new RuntimeException('Could not insert customer.'); } @@ -180,8 +287,7 @@ class Customers_model extends EA_Model { { $customer['update_datetime'] = date('Y-m-d H:i:s'); - if ( ! $this->db->update('users', $customer, ['id' => $customer['id']])) - { + if (!$this->db->update('users', $customer, ['id' => $customer['id']])) { throw new RuntimeException('Could not update customer.'); } @@ -211,9 +317,10 @@ class Customers_model extends EA_Model { { $customer = $this->db->get_where('users', ['id' => $customer_id])->row_array(); - if ( ! $customer) - { - throw new InvalidArgumentException('The provided customer ID was not found in the database: ' . $customer_id); + if (!$customer) { + throw new InvalidArgumentException( + 'The provided customer ID was not found in the database: ' . $customer_id + ); } $this->cast($customer); @@ -233,22 +340,21 @@ class Customers_model extends EA_Model { */ public function value(int $customer_id, string $field): mixed { - if (empty($field)) - { + if (empty($field)) { throw new InvalidArgumentException('The field argument is cannot be empty.'); } - if (empty($customer_id)) - { + if (empty($customer_id)) { throw new InvalidArgumentException('The customer ID argument cannot be empty.'); } // Check whether the customer exists. $query = $this->db->get_where('users', ['id' => $customer_id]); - if ( ! $query->num_rows()) - { - throw new InvalidArgumentException('The provided customer ID was not found in the database: ' . $customer_id); + if (!$query->num_rows()) { + throw new InvalidArgumentException( + 'The provided customer ID was not found in the database: ' . $customer_id + ); } // Check if the required field is part of the customer data. @@ -256,128 +362,13 @@ class Customers_model extends EA_Model { $this->cast($customer); - if ( ! array_key_exists($field, $customer)) - { + if (!array_key_exists($field, $customer)) { throw new InvalidArgumentException('The requested field was not found in the customer data: ' . $field); } return $customer[$field]; } - /** - * Get all customers that match the provided criteria. - * - * @param array|string|null $where Where conditions. - * @param int|null $limit Record limit. - * @param int|null $offset Record offset. - * @param string|null $order_by Order by. - * - * @return array Returns an array of customers. - */ - public function get(array|string $where = NULL, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array - { - $role_id = $this->get_customer_role_id(); - - if ($where !== NULL) - { - $this->db->where($where); - } - - if ($order_by !== NULL) - { - $this->db->order_by($order_by); - } - - $customers = $this->db->get_where('users', ['id_roles' => $role_id], $limit, $offset)->result_array(); - - foreach ($customers as &$customer) - { - $this->cast($customer); - } - - return $customers; - } - - /** - * Get the customer role ID. - * - * @return int Returns the role ID. - */ - public function get_customer_role_id(): int - { - $role = $this->db->get_where('roles', ['slug' => DB_SLUG_CUSTOMER])->row_array(); - - if (empty($role)) - { - throw new RuntimeException('The customer role was not found in the database.'); - } - - return $role['id']; - } - - /** - * Check if a particular customer record already exists in the database. - * - * @param array $customer Associative array with the customer data. - * - * @return bool Returns whether there is a record matching the provided one or not. - * - * @throws InvalidArgumentException - */ - public function exists(array $customer): bool - { - if (empty($customer['email'])) - { - return FALSE; - } - - $count = $this - ->db - ->select() - ->from('users') - ->join('roles', 'roles.id = users.id_roles', 'inner') - ->where('users.email', $customer['email']) - ->where('roles.slug', DB_SLUG_CUSTOMER) - ->get() - ->num_rows(); - - return $count > 0; - } - - /** - * Find the record ID of a customer. - * - * @param array $customer Associative array with the customer data. - * - * @return int Returns the ID of the record that matches the provided argument. - * - * @throws InvalidArgumentException - */ - public function find_record_id(array $customer): int - { - if (empty($customer['email'])) - { - throw new InvalidArgumentException('The customer email was not provided: ' . print_r($customer, TRUE)); - } - - $customer = $this - ->db - ->select('users.id') - ->from('users') - ->join('roles', 'roles.id = users.id_roles', 'inner') - ->where('users.email', $customer['email']) - ->where('roles.slug', DB_SLUG_CUSTOMER) - ->get() - ->row_array(); - - if (empty($customer)) - { - throw new InvalidArgumentException('Could not find customer record id.'); - } - - return (int)$customer['id']; - } - /** * Get the query builder interface, configured for use with the users (customer-filtered) table. * @@ -400,12 +391,11 @@ class Customers_model extends EA_Model { * * @return array Returns an array of customers. */ - public function search(string $keyword, int $limit = NULL, int $offset = NULL, string $order_by = NULL): array + public function search(string $keyword, int $limit = null, int $offset = null, string $order_by = null): array { $role_id = $this->get_customer_role_id(); - $customers = $this - ->db + $customers = $this->db ->select() ->from('users') ->where('id_roles', $role_id) @@ -428,8 +418,7 @@ class Customers_model extends EA_Model { ->get() ->result_array(); - foreach ($customers as &$customer) - { + foreach ($customers as &$customer) { $this->cast($customer); } @@ -457,7 +446,7 @@ class Customers_model extends EA_Model { public function api_encode(array &$customer) { $encoded_resource = [ - 'id' => array_key_exists('id', $customer) ? (int)$customer['id'] : NULL, + 'id' => array_key_exists('id', $customer) ? (int) $customer['id'] : null, 'firstName' => $customer['first_name'], 'lastName' => $customer['last_name'], 'email' => $customer['email'], @@ -467,6 +456,11 @@ class Customers_model extends EA_Model { 'zip' => $customer['zip_code'], 'notes' => $customer['notes'], 'timezone' => $customer['timezone'], + 'customField1' => $customer['custom_field_1'], + 'customField2' => $customer['custom_field_2'], + 'customField3' => $customer['custom_field_3'], + 'customField4' => $customer['custom_field_4'], + 'customField5' => $customer['custom_field_5'] ]; $customer = $encoded_resource; @@ -478,52 +472,67 @@ class Customers_model extends EA_Model { * @param array $customer API resource. * @param array|null $base Base customer data to be overwritten with the provided values (useful for updates). */ - public function api_decode(array &$customer, array $base = NULL) + public function api_decode(array &$customer, array $base = null) { $decoded_resource = $base ?: []; - if (array_key_exists('id', $customer)) - { + if (array_key_exists('id', $customer)) { $decoded_resource['id'] = $customer['id']; } - if (array_key_exists('firstName', $customer)) - { + if (array_key_exists('firstName', $customer)) { $decoded_resource['first_name'] = $customer['firstName']; } - if (array_key_exists('lastName', $customer)) - { + if (array_key_exists('lastName', $customer)) { $decoded_resource['last_name'] = $customer['lastName']; } - if (array_key_exists('email', $customer)) - { + if (array_key_exists('email', $customer)) { $decoded_resource['email'] = $customer['email']; } - if (array_key_exists('phone', $customer)) - { + if (array_key_exists('phone', $customer)) { $decoded_resource['phone_number'] = $customer['phone']; } - if (array_key_exists('address', $customer)) - { + if (array_key_exists('address', $customer)) { $decoded_resource['address'] = $customer['address']; } - if (array_key_exists('city', $customer)) - { + if (array_key_exists('city', $customer)) { $decoded_resource['city'] = $customer['city']; } - if (array_key_exists('zip', $customer)) - { + if (array_key_exists('zip', $customer)) { $decoded_resource['zip_code'] = $customer['zip']; } - if (array_key_exists('notes', $customer)) - { + if (array_key_exists('language', $customer)) { + $decoded_resource['language'] = $customer['language']; + } + + if (array_key_exists('customField1', $customer)) { + $decoded_resource['custom_field_1'] = $customer['customField1']; + } + + if (array_key_exists('customField2', $customer)) { + $decoded_resource['custom_field_2'] = $customer['customField2']; + } + + if (array_key_exists('customField3', $customer)) { + $decoded_resource['custom_field_3'] = $customer['customField3']; + } + + if (array_key_exists('customField4', $customer)) { + $decoded_resource['custom_field_4'] = $customer['customField4']; + } + + if (array_key_exists('customField5', $customer)) { + $decoded_resource['custom_field_5'] = $customer['customField5']; + } + + if (array_key_exists('notes', $customer)) { $decoded_resource['notes'] = $customer['notes']; } diff --git a/application/views/components/appointments_modal.php b/application/views/components/appointments_modal.php index c6df1f7e..3c333e2e 100644 --- a/application/views/components/appointments_modal.php +++ b/application/views/components/appointments_modal.php @@ -43,27 +43,21 @@ $group) - { - $group_label = $key !== 'uncategorized' - ? e($group[0]['category_name']) - : 'Uncategorized'; + foreach ($grouped_services as $key => $group) { + $group_label = + $key !== 'uncategorized' + ? e($group[0]['category_name']) + : 'Uncategorized'; - if (count($group) > 0) - { + if (count($group) > 0) { echo ''; - foreach ($group as $service) - { - echo ''; + foreach ($group as $service) { + echo ''; } echo ''; } } - } - else - { - foreach ($available_services as $service) - { - echo ''; + } else { + foreach ($available_services as $service) { + echo ''; } } ?> @@ -124,7 +117,7 @@
- 'id="appointment-color"']) ?> + 'id="appointment-color"']); ?>
@@ -143,7 +136,7 @@ - +
@@ -228,7 +221,7 @@ * - + * - + * - + * - + @@ -280,7 +273,7 @@ - + @@ -290,7 +283,7 @@ * - + * - + * - + 'id="timezone" class="form-control required"', 'grouped_timezones' => vars('grouped_timezones') - ]) ?> + ]); ?>
@@ -337,12 +330,16 @@ * - +
+ +
+ +
@@ -361,8 +358,8 @@ - + - + diff --git a/application/views/components/booking_info_step.php b/application/views/components/booking_info_step.php index 89c337c3..03a966d4 100644 --- a/application/views/components/booking_info_step.php +++ b/application/views/components/booking_info_step.php @@ -131,6 +131,10 @@ + +
+ +
diff --git a/application/views/components/custom_fields.php b/application/views/components/custom_fields.php new file mode 100644 index 00000000..809f4e7e --- /dev/null +++ b/application/views/components/custom_fields.php @@ -0,0 +1,24 @@ + + + + +
+ + /> +
+ + diff --git a/application/views/pages/booking_settings.php b/application/views/pages/booking_settings.php index c2315a24..06f0a30e 100755 --- a/application/views/pages/booking_settings.php +++ b/application/views/pages/booking_settings.php @@ -246,6 +246,50 @@ +
+ +
+ +
+ +
+
+ + + + +
+
+ + +
+ +
+ + +
+
+
+
+ +
+ +
diff --git a/application/views/pages/customers.php b/application/views/pages/customers.php index dbe7366d..69c59f2d 100755 --- a/application/views/pages/customers.php +++ b/application/views/pages/customers.php @@ -181,7 +181,9 @@ ]); ?> - + true + ]); ?>