clearify customer add/edit name/company requirements

Signed-off-by: Michael Kaufmann <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann
2022-12-06 16:25:33 +01:00
parent 4501eb2723
commit d7a2ec35cc
6 changed files with 56 additions and 25 deletions

View File

@@ -95,16 +95,6 @@ return [
'title' => lng('admin.contactdata'), 'title' => lng('admin.contactdata'),
'image' => 'icons/user_add.png', 'image' => 'icons/user_add.png',
'fields' => [ 'fields' => [
'name' => [
'label' => lng('customer.name'),
'type' => 'text',
'mandatory_ex' => true
],
'firstname' => [
'label' => lng('customer.firstname'),
'type' => 'text',
'mandatory_ex' => true
],
'gender' => [ 'gender' => [
'label' => lng('gender.title'), 'label' => lng('gender.title'),
'type' => 'select', 'type' => 'select',
@@ -114,10 +104,23 @@ return [
2 => lng('gender.female') 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' => [ 'company' => [
'label' => lng('customer.company'), 'label' => lng('customer.company'),
'desc' => lng('customer.nameorcompany_desc'),
'type' => 'text', 'type' => 'text',
'mandatory_ex' => true 'mandatory_ex' => ['firstname', 'name']
], ],
'street' => [ 'street' => [
'label' => lng('customer.street'), 'label' => lng('customer.street'),

View File

@@ -93,18 +93,6 @@ return [
'title' => lng('admin.contactdata'), 'title' => lng('admin.contactdata'),
'image' => 'icons/user_edit.png', 'image' => 'icons/user_edit.png',
'fields' => [ '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' => [ 'gender' => [
'label' => lng('gender.title'), 'label' => lng('gender.title'),
'type' => 'select', 'type' => 'select',
@@ -115,10 +103,25 @@ return [
], ],
'selected' => $result['gender'] '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' => [ 'company' => [
'label' => lng('customer.company'), 'label' => lng('customer.company'),
'desc' => lng('customer.nameorcompany_desc'),
'type' => 'text', 'type' => 'text',
'mandatory_ex' => true, 'mandatory_ex' => ['firstname', 'name'],
'value' => $result['company'] 'value' => $result['company']
], ],
'street' => [ 'street' => [

View File

@@ -546,6 +546,7 @@ return [
'name' => 'Name', 'name' => 'Name',
'firstname' => 'Vorname', 'firstname' => 'Vorname',
'company' => 'Firma', 'company' => 'Firma',
'nameorcompany_desc' => 'Entweder Vorname/Name oder Firma ist erforderlich',
'street' => 'Straße', 'street' => 'Straße',
'zipcode' => 'PLZ', 'zipcode' => 'PLZ',
'city' => 'Ort', 'city' => 'Ort',

View File

@@ -589,6 +589,7 @@ return [
'name' => 'Name', 'name' => 'Name',
'firstname' => 'First name', 'firstname' => 'First name',
'company' => 'Company', 'company' => 'Company',
'nameorcompany_desc' => 'Either firstname/name or company is required',
'street' => 'Street', 'street' => 'Street',
'zipcode' => 'Zipcode', 'zipcode' => 'Zipcode',
'city' => 'City', 'city' => 'City',

View File

@@ -72,6 +72,29 @@
{% if field.note is defined and field.note is not empty %} {% if field.note is defined and field.note is not empty %}
<small class="text-info">{{ field.note|raw }}</small> <small class="text-info">{{ field.note|raw }}</small>
{% endif %} {% endif %}
{% if field.mandatory_ex is not empty and field.mandatory_ex is iterable and field.mandatory_ex|length > 0 %}
<script>
$(function () {
$('#{{ id }}').attr('required', true);
$('#{{ id }}').trigger('change');
$('#{{ id }}').on('change', function(e) {
if ($(this).val().length > 0) {
{% for mex in field.mandatory_ex %}
$('#{{ mex }}').attr('required', false);
{% endfor %}
$('#{{ id }}').attr('required', true);
} else {
{% for mex in field.mandatory_ex %}
$('#{{ mex }}').attr('required', true);
{% endfor %}
$('#{{ id }}').attr('required', false);
}
});
});
</script>
{% endif %}
{% if norow == false and (field.type != 'hidden' or (field.type == 'hidden' and field.display is defined and field.display is not empty)) %} {% if norow == false and (field.type != 'hidden' or (field.type == 'hidden' and field.display is defined and field.display is not empty)) %}
</div> </div>
</div> </div>

View File

@@ -46,7 +46,7 @@
<i class="fa-solid fa-reply me-1"></i><span class="d-none d-xl-inline">{{ userinfo.switched_user.loginname }}</span> <i class="fa-solid fa-reply me-1"></i><span class="d-none d-xl-inline">{{ userinfo.switched_user.loginname }}</span>
</a> </a>
{% endif %} {% 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 %}
<li class="nav-item" id="updatecheck"></li> <li class="nav-item" id="updatecheck"></li>
{% endif %} {% endif %}
<li class="nav-item"> <li class="nav-item">