make 'other' field optional and add inactivate/activate button
This commit is contained in:
@@ -44,7 +44,7 @@ class page
|
||||
OR ua_authority_a_id = 1)
|
||||
WHERE
|
||||
spage_page_id = 1
|
||||
AND ua_user_kid_uk_id = '.$user->get_ua_id().' ORDER BY spage_id ASC;
|
||||
AND ua_user_kid_uk_id = ' . $user->get_ua_id() . ' ORDER BY spage_id ASC;
|
||||
';
|
||||
} else {
|
||||
$menus_query = 'SELECT * FROM subpage WHERE spage_page_id = 1;';
|
||||
@@ -238,7 +238,7 @@ class page
|
||||
case 'money_update':
|
||||
// FRISSÍTÉS
|
||||
include 'include_money_update.php';
|
||||
// no break
|
||||
// no break
|
||||
case 'settings':
|
||||
// BEÁLLÍTÁSOK
|
||||
include 'include_settings.php';
|
||||
@@ -404,6 +404,10 @@ class page
|
||||
// TÁBORVEZETŐ TÖRLÉS
|
||||
include 'include_delete_camp_leader.php';
|
||||
break;
|
||||
case 'set_active_status':
|
||||
// TÁBORVEZETŐ TÖRLÉS
|
||||
include 'include_set_active_status.php';
|
||||
break;
|
||||
case 'emails':
|
||||
# email log
|
||||
include('include_emails.php');
|
||||
@@ -419,7 +423,7 @@ class page
|
||||
break;
|
||||
case 'ajax':
|
||||
if ($this->is_subpage()) {
|
||||
include 'ajax/'.$this->get_subpage();
|
||||
include 'ajax/' . $this->get_subpage();
|
||||
}
|
||||
break;
|
||||
case 'view':
|
||||
|
||||
17
_include/include_set_active_status.php
Normal file
17
_include/include_set_active_status.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
|
||||
if ($this->is_id()) {
|
||||
$user_kid = new user_kid();
|
||||
$user_kid->set_user_data_by_id($this->get_id());
|
||||
|
||||
$activityToSet = $user_kid->get_uk_is_active() == 1 ? 0 : 1;
|
||||
|
||||
$sql->update_table('user_kid', [
|
||||
'uk_is_active' => $activityToSet
|
||||
], [
|
||||
'uk_id' => $this->get_id()
|
||||
]);
|
||||
|
||||
header("Location: /admin/members/" . $this->get_id());
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
<div class="form_wrapper">
|
||||
<form method="post">
|
||||
<input type="hidden" name="action" id="action" value="user_data_create">
|
||||
<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>
|
||||
@@ -162,84 +162,84 @@
|
||||
</div>
|
||||
|
||||
|
||||
</form>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$('#uk_parent_1').change(function() {
|
||||
$(".add_parent_1_block").toggle(this.value == 'null');
|
||||
});
|
||||
|
||||
$('#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_parent_2').change(function() {
|
||||
$(".add_parent_2_block").toggle(this.value == 'null');
|
||||
});
|
||||
$('#uk_school_sc_id').change(function() {
|
||||
$(".add_school").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"]');
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const form = document.querySelector(".form_wrapper form");
|
||||
const submitButton = form.querySelector('input.button.black[type="submit"]');
|
||||
// Collect text inputs but exclude #uk_other
|
||||
const textInputs = Array.from(form.querySelectorAll(
|
||||
'input[type="text"], input[type="email"], textarea'
|
||||
)).filter(input => input.id !== "uk_other");
|
||||
|
||||
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');
|
||||
|
||||
// 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));
|
||||
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);
|
||||
});
|
||||
|
||||
// Check if any required field is empty
|
||||
const anyEmpty = fieldsToCheck.some(input => input.value.trim() === "");
|
||||
// Listen to select changes
|
||||
[parentSelect, schoolSelect, addressSelect].forEach(select => {
|
||||
select.addEventListener("change", toggleSubmitButton);
|
||||
});
|
||||
|
||||
// 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);
|
||||
// Initial validation
|
||||
toggleSubmitButton();
|
||||
});
|
||||
|
||||
// Listen to select changes
|
||||
[parentSelect, schoolSelect, addressSelect].forEach(select => {
|
||||
select.addEventListener("change", toggleSubmitButton);
|
||||
});
|
||||
|
||||
// Initial validation
|
||||
toggleSubmitButton();
|
||||
});
|
||||
|
||||
</script>
|
||||
@@ -1,6 +1,13 @@
|
||||
<div class="form_wrapper">
|
||||
<div class="buttons">
|
||||
<a href="/admin/delete_member/{$user_data.uk_id}" class="addbutton delete-big">Törlés</a>
|
||||
<a href="/admin/set_active_status/{$user_data.uk_id}" class="addbutton big">
|
||||
{if $user_data.uk_is_active}
|
||||
Inaktiválás
|
||||
{else}
|
||||
Aktiválás
|
||||
{/if}
|
||||
</a>
|
||||
</div>
|
||||
<form method="post">
|
||||
<input type="hidden" name="action" id="action" value="user_data_edit">
|
||||
@@ -13,12 +20,6 @@
|
||||
value="{$user_data.uk_name}" 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"
|
||||
{if 1==$user_data.uk_is_active}checked{/if}></div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="uk_lease">Bérletes:</label>
|
||||
<div><input type="checkbox" name="uk_lease" id="uk_lease" value="1" {if 1==$user_data.uk_lease}checked{/if}>
|
||||
@@ -258,8 +259,10 @@
|
||||
const form = document.querySelector(".form_wrapper form");
|
||||
const submitButton = form.querySelector('input.button.black[type="submit"]');
|
||||
|
||||
// Collect text inputs but exclude #uk_other
|
||||
const textInputs = Array.from(form.querySelectorAll(
|
||||
'input[type="text"], input[type="email"], textarea'));
|
||||
'input[type="text"], input[type="email"], textarea'
|
||||
)).filter(input => input.id !== "uk_other");
|
||||
|
||||
// Select fields that control conditional validation
|
||||
const parentSelect = form.querySelector('#uk_parent_1');
|
||||
|
||||
Reference in New Issue
Block a user