246 lines
8.7 KiB
Smarty
246 lines
8.7 KiB
Smarty
<div class="form_wrapper">
|
|
<form method="post">
|
|
<input type="hidden" name="action" id="action" value="user_data_create">
|
|
<div>
|
|
<label class="desc" for="uk_name">Név:</label>
|
|
<div><input type="text" name="uk_name" id="uk_name" size="8" class="field text fn" required></div>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="desc" for="uk_is_active">Aktív:</label>
|
|
<div><input type="checkbox" name="uk_is_active" id="uk_is_active" value="1" checked></div>
|
|
</div>
|
|
|
|
<div>
|
|
<label for="uk_lease">Bérletes:</label>
|
|
<div><input type="checkbox" name="uk_lease" id="uk_lease" value="1" checked></div>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="desc" for="uk_last_modified">Utolsó módosítás dátuma:</label>
|
|
<div><input type="text" name="uk_last_modified" id="uk_last_modified" value="{$today}"></div>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="desc" for="uk_password">Jelszó:</label>
|
|
<div><input type="text" name="uk_password" id="uk_password"></div>
|
|
</div>
|
|
|
|
<div>
|
|
<legend class="desc" for="uk_gender">Nem: </legend>
|
|
<div>
|
|
<input id="r_01" type="radio" name="uk_gender" value="1" checked>
|
|
<label class="choice" for="r_01">Fiú</label>
|
|
</div>
|
|
<div>
|
|
<input id="r_02" type="radio" name="uk_gender" value="2">
|
|
<label class="choice" for="r_02">Lány</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="desc" for="uk_birth_date">Születési dátum:</label>
|
|
<div><input type="text" name="uk_birth_date" id="uk_birth_date"></div>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="desc" for="uk_birth_year">Születési év:</label>
|
|
<div><input type="text" name="uk_birth_year" id="uk_birth_year"></div>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="desc" for="uk_address_scc_id">Lakhely (település):</label>
|
|
<div>
|
|
<select name="uk_address_scc_id" id="uk_address_scc_id">
|
|
<option value="null"> - </option>
|
|
{foreach $school_city_assoc_array as $school_city_array}
|
|
<option value="{$school_city_array->get_scc_id()}">
|
|
{$school_city_array->get_scc_city()}
|
|
</option>
|
|
{/foreach}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<legend class="desc" for="uk_hand">Kéz: </legend>
|
|
<div>
|
|
<input id="r_03" type="radio" name="uk_hand" value="1">
|
|
<label class="choice" for="r_03">Bal</label>
|
|
</div>
|
|
<div>
|
|
<input id="r_04" type="radio" name="uk_hand" value="2" checked>
|
|
<label class="choice" for="r_04">Jobb</label>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="desc" for="uk_email">E-mail cím:</label>
|
|
<div><input type="email" name="uk_email" id="uk_email"></div>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="desc" for="uk_phone">Telefonszám:</label>
|
|
<div><input type="text" name="uk_phone" id="uk_phone"></div>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="desc" for="uk_school_sc_id">Iskola neve:</label>
|
|
<div>
|
|
<select name="uk_school_sc_id" id="uk_school_sc_id">
|
|
<option value="null"> - (állítsd erre új iskola felvételéhez)</option>
|
|
{foreach $school_assoc_array as $school_array}
|
|
<option value="{$school_array->get_sc_id()}">
|
|
{$school_array->get_sc_name()}
|
|
{if $school_array->get_sc_school_city()}({$school_array->get_sc_school_city()->get_scc_city()}){/if}
|
|
</option>
|
|
{/foreach}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="add_school">
|
|
<label class="desc" for="add_school">Új iskola neve:</label>
|
|
<div><input type="text" name="add_school" id="add_school"></div>
|
|
</div>
|
|
|
|
<div class="add_school">
|
|
<label class="desc" for="uk_school_city_scc_id">Új iskola települése:</label>
|
|
<div>
|
|
<select name="uk_school_city_scc_id" id="uk_school_city_scc_id">
|
|
<option value="null"> - </option>
|
|
{foreach $school_city_assoc_array as $school_city_array}
|
|
<option value="{$school_city_array->get_scc_id()}">
|
|
{$school_city_array->get_scc_city()}
|
|
</option>
|
|
{/foreach}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div>
|
|
<label class="desc" for="uk_parent_1">Szülő:</label>
|
|
<div>
|
|
<select name="uk_parent_1" id="uk_parent_1">
|
|
<option value="null"> - (állítsd erre új szülő felvételéhez)</option>
|
|
{foreach $parent_assoc_array as $parent_array}
|
|
<option value="{$parent_array.up_id}">
|
|
{$parent_array.up_name}
|
|
</option>
|
|
{/foreach}
|
|
</select>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="add_parent_1_block">
|
|
<label class="desc" for="add_parent_1">Új szülő neve:</label>
|
|
<div><input type="text" name="add_parent_1" id="add_parent_1"></div>
|
|
</div>
|
|
|
|
<div class="add_parent_1_block">
|
|
<label class="desc" for="parent_1_email">E-mail cím:</label>
|
|
<div><input type="text" name="parent_1_email" id="parent_1_email"></div>
|
|
</div>
|
|
<div class="add_parent_1_block">
|
|
<label class="desc" for="parent_1_phone">Telefonszám:</label>
|
|
<div><input type="text" name="parent_1_phone" id="parent_1_phone"></div>
|
|
</div>
|
|
|
|
<br>
|
|
|
|
<div>
|
|
<label class="desc" id="title2" for="uk_other">Egyéb:</label>
|
|
<div><textarea rows="5" name="uk_other" id="uk_other"></textarea></div>
|
|
</div>
|
|
|
|
<br>
|
|
|
|
|
|
<div>
|
|
<div>
|
|
<input disabled class="button black" type="submit" value="Létrehozás">
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</form>
|
|
</div>
|
|
|
|
<script>
|
|
|
|
$('#uk_parent_1').change(function() {
|
|
$(".add_parent_1_block").toggle(this.value == 'null');
|
|
});
|
|
|
|
$('#uk_parent_2').change(function() {
|
|
$(".add_parent_2_block").toggle(this.value == 'null');
|
|
});
|
|
|
|
$('#uk_school_sc_id').change(function() {
|
|
$(".add_school").toggle(this.value == 'null');
|
|
});
|
|
|
|
document.addEventListener("DOMContentLoaded", function () {
|
|
const form = document.querySelector(".form_wrapper form");
|
|
const submitButton = form.querySelector('input.button.black[type="submit"]');
|
|
|
|
const textInputs = Array.from(form.querySelectorAll('input[type="text"], input[type="email"], textarea'));
|
|
|
|
// Select fields that control conditional validation
|
|
const parentSelect = form.querySelector('#uk_parent_1');
|
|
const schoolSelect = form.querySelector('#uk_school_sc_id');
|
|
const addressSelect = form.querySelector('#uk_address_scc_id');
|
|
|
|
const conditionalFields = [
|
|
{
|
|
select: parentSelect,
|
|
valueToIgnore: 'null',
|
|
fields: [
|
|
form.querySelector('#add_parent_1'),
|
|
form.querySelector('#parent_1_email'),
|
|
form.querySelector('#parent_1_phone')
|
|
]
|
|
},
|
|
{
|
|
select: schoolSelect,
|
|
valueToIgnore: 'null',
|
|
fields: [
|
|
form.querySelector('#add_school')
|
|
]
|
|
}
|
|
];
|
|
|
|
function toggleSubmitButton() {
|
|
let fieldsToCheck = [...textInputs];
|
|
|
|
// Exclude fields based on select value
|
|
conditionalFields.forEach(group => {
|
|
if (group.select.value !== group.valueToIgnore) {
|
|
fieldsToCheck = fieldsToCheck.filter(field => !group.fields.includes(field));
|
|
}
|
|
});
|
|
|
|
// Check if any required field is empty
|
|
const anyEmpty = fieldsToCheck.some(input => input.value.trim() === "");
|
|
|
|
// Check if uk_address_scc_id is still "null"
|
|
const addressMissing = addressSelect.value === "null";
|
|
|
|
submitButton.disabled = anyEmpty || addressMissing;
|
|
}
|
|
|
|
// Listen to input changes
|
|
textInputs.forEach(input => {
|
|
input.addEventListener("input", toggleSubmitButton);
|
|
});
|
|
|
|
// Listen to select changes
|
|
[parentSelect, schoolSelect, addressSelect].forEach(select => {
|
|
select.addEventListener("change", toggleSubmitButton);
|
|
});
|
|
|
|
// Initial validation
|
|
toggleSubmitButton();
|
|
});
|
|
|
|
</script>
|