From d7a2ec35cc86673573ec2c3ecdd6944cfea609d3 Mon Sep 17 00:00:00 2001 From: Michael Kaufmann Date: Tue, 6 Dec 2022 16:25:33 +0100 Subject: [PATCH] clearify customer add/edit name/company requirements Signed-off-by: Michael Kaufmann --- .../admin/customer/formfield.customer_add.php | 25 +++++++++------- .../customer/formfield.customer_edit.php | 29 ++++++++++--------- lng/de.lng.php | 1 + lng/en.lng.php | 1 + templates/Froxlor/form/formfields.html.twig | 23 +++++++++++++++ templates/Froxlor/userarea.html.twig | 2 +- 6 files changed, 56 insertions(+), 25 deletions(-) diff --git a/lib/formfields/admin/customer/formfield.customer_add.php b/lib/formfields/admin/customer/formfield.customer_add.php index 4fca6eaf..51e2aa13 100644 --- a/lib/formfields/admin/customer/formfield.customer_add.php +++ b/lib/formfields/admin/customer/formfield.customer_add.php @@ -95,16 +95,6 @@ return [ 'title' => lng('admin.contactdata'), 'image' => 'icons/user_add.png', 'fields' => [ - 'name' => [ - 'label' => lng('customer.name'), - 'type' => 'text', - 'mandatory_ex' => true - ], - 'firstname' => [ - 'label' => lng('customer.firstname'), - 'type' => 'text', - 'mandatory_ex' => true - ], 'gender' => [ 'label' => lng('gender.title'), 'type' => 'select', @@ -114,10 +104,23 @@ return [ 2 => lng('gender.female') ] ], + 'firstname' => [ + 'label' => lng('customer.firstname'), + 'desc' => lng('customer.nameorcompany_desc'), + 'type' => 'text', + 'mandatory_ex' => ['company'] + ], + 'name' => [ + 'label' => lng('customer.name'), + 'desc' => lng('customer.nameorcompany_desc'), + 'type' => 'text', + 'mandatory_ex' => ['company'] + ], 'company' => [ 'label' => lng('customer.company'), + 'desc' => lng('customer.nameorcompany_desc'), 'type' => 'text', - 'mandatory_ex' => true + 'mandatory_ex' => ['firstname', 'name'] ], 'street' => [ 'label' => lng('customer.street'), diff --git a/lib/formfields/admin/customer/formfield.customer_edit.php b/lib/formfields/admin/customer/formfield.customer_edit.php index 6c4088f3..4b8c7712 100644 --- a/lib/formfields/admin/customer/formfield.customer_edit.php +++ b/lib/formfields/admin/customer/formfield.customer_edit.php @@ -93,18 +93,6 @@ return [ 'title' => lng('admin.contactdata'), 'image' => 'icons/user_edit.png', 'fields' => [ - 'name' => [ - 'label' => lng('customer.name'), - 'type' => 'text', - 'mandatory_ex' => true, - 'value' => $result['name'] - ], - 'firstname' => [ - 'label' => lng('customer.firstname'), - 'type' => 'text', - 'mandatory_ex' => true, - 'value' => $result['firstname'] - ], 'gender' => [ 'label' => lng('gender.title'), 'type' => 'select', @@ -115,10 +103,25 @@ return [ ], 'selected' => $result['gender'] ], + 'firstname' => [ + 'label' => lng('customer.firstname'), + 'desc' => lng('customer.nameorcompany_desc'), + 'type' => 'text', + 'mandatory_ex' => ['company'], + 'value' => $result['firstname'] + ], + 'name' => [ + 'label' => lng('customer.name'), + 'desc' => lng('customer.nameorcompany_desc'), + 'type' => 'text', + 'mandatory_ex' => ['company'], + 'value' => $result['name'] + ], 'company' => [ 'label' => lng('customer.company'), + 'desc' => lng('customer.nameorcompany_desc'), 'type' => 'text', - 'mandatory_ex' => true, + 'mandatory_ex' => ['firstname', 'name'], 'value' => $result['company'] ], 'street' => [ diff --git a/lng/de.lng.php b/lng/de.lng.php index c0ede0c8..8da256a2 100644 --- a/lng/de.lng.php +++ b/lng/de.lng.php @@ -546,6 +546,7 @@ return [ 'name' => 'Name', 'firstname' => 'Vorname', 'company' => 'Firma', + 'nameorcompany_desc' => 'Entweder Vorname/Name oder Firma ist erforderlich', 'street' => 'Straße', 'zipcode' => 'PLZ', 'city' => 'Ort', diff --git a/lng/en.lng.php b/lng/en.lng.php index a7785577..5a1c2285 100644 --- a/lng/en.lng.php +++ b/lng/en.lng.php @@ -589,6 +589,7 @@ return [ 'name' => 'Name', 'firstname' => 'First name', 'company' => 'Company', + 'nameorcompany_desc' => 'Either firstname/name or company is required', 'street' => 'Street', 'zipcode' => 'Zipcode', 'city' => 'City', diff --git a/templates/Froxlor/form/formfields.html.twig b/templates/Froxlor/form/formfields.html.twig index c2ce18e5..d8e76e79 100644 --- a/templates/Froxlor/form/formfields.html.twig +++ b/templates/Froxlor/form/formfields.html.twig @@ -72,6 +72,29 @@ {% if field.note is defined and field.note is not empty %} {{ field.note|raw }} {% endif %} + + {% if field.mandatory_ex is not empty and field.mandatory_ex is iterable and field.mandatory_ex|length > 0 %} + + {% endif %} + {% if norow == false and (field.type != 'hidden' or (field.type == 'hidden' and field.display is defined and field.display is not empty)) %} diff --git a/templates/Froxlor/userarea.html.twig b/templates/Froxlor/userarea.html.twig index f9d4bc59..791f9349 100644 --- a/templates/Froxlor/userarea.html.twig +++ b/templates/Froxlor/userarea.html.twig @@ -46,7 +46,7 @@ {{ userinfo.switched_user.loginname }} {% endif %} - {% if userinfo.adminsession == 1 %} + {% if userinfo.adminsession == 1 and call_static('\\Froxlor\\CurrentUser', 'getField', ['change_serversettings']) is not empty and call_static('\\Froxlor\\CurrentUser', 'getField', ['change_serversettings']) == 1 %} {% endif %}