Add Checkbox that will select all / de-select all Client Restriction permissions in add/edit user

This commit is contained in:
johnnyq
2024-06-04 16:05:49 -04:00
parent 0aea143049
commit 21019ba471
2 changed files with 22 additions and 10 deletions

View File

@@ -115,6 +115,12 @@
</div> </div>
<ul class="list-group"> <ul class="list-group">
<li class="list-group-item bg-dark">
<div class="form-check">
<input type="checkbox" class="form-check-input" onclick="this.closest('.tab-pane').querySelectorAll('.client-checkbox').forEach(checkbox => checkbox.checked = this.checked);">
<label class="form-check-label ml-3"><strong>Restrict Access to Clients</strong></label>
</div>
</li>
<?php <?php
@@ -126,8 +132,8 @@
?> ?>
<li class="list-group-item"> <li class="list-group-item">
<div class="form-check"> <div class="form-check">
<input type="checkbox" class="form-check-input" name="clients[]" value="<?php echo $client_id; ?>"> <input type="checkbox" class="form-check-input client-checkbox" name="clients[]" value="<?php echo $client_id; ?>">
<label class="form-check-label ml-2"><?php echo $client_name; ?></label> <label class="form-check-label ml-3"><?php echo $client_name; ?></label>
</div> </div>
</li> </li>

View File

@@ -135,24 +135,30 @@
</div> </div>
<ul class="list-group"> <ul class="list-group">
<li class="list-group-item bg-dark">
<div class="form-check">
<input type="checkbox" class="form-check-input" onclick="this.closest('.tab-pane').querySelectorAll('.client-checkbox').forEach(checkbox => checkbox.checked = this.checked);">
<label class="form-check-label ml-3"><strong>Restrict Access to Clients</strong></label>
</div>
</li>
<?php <?php
$sql_client_select = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_archived_at IS NULL ORDER BY client_name ASC"); $sql_client_select = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_archived_at IS NULL ORDER BY client_name ASC");
while ($row = mysqli_fetch_array($sql_client_select)) { while ($row = mysqli_fetch_array($sql_client_select)) {
$client_id_select = intval($row['client_id']); $client_id_select = intval($row['client_id']);
$client_name_select = nullable_htmlentities($row['client_name']); $client_name_select = nullable_htmlentities($row['client_name']);
?> ?>
<li class="list-group-item"> <li class="list-group-item">
<div class="form-check"> <div class="form-check">
<input type="checkbox" class="form-check-input" name="clients[]" value="<?php echo $client_id_select; ?>" <?php if (in_array($client_id_select, $client_access_array)) { echo "checked"; } ?>> <input type="checkbox" class="form-check-input client-checkbox" name="clients[]" value="<?php echo $client_id_select; ?>" <?php if (in_array($client_id_select, $client_access_array)) { echo "checked"; } ?>>
<label class="form-check-label ml-2"><?php echo $client_name_select; ?></label> <label class="form-check-label ml-2"><?php echo $client_name_select; ?></label>
</div> </div>
</li> </li>
<?php } ?> <?php } ?>
</ul> </ul>