38471-vm/patch_users_edit_ui.php
2026-02-25 17:48:02 +00:00

32 lines
2.1 KiB
PHP

<?php
$c = file_get_contents('index.php');
$find_group_edit = '<select name="group_id" class="form-select">
<option value="">--- No Group ---</option>
<?php foreach (($data[\'role_groups\'] ?? []) as $g): ?>
<option value="<?= $g[\'id\'] ?>" <?= ($u[\'group_id\'] ?? null) == $g[\'id\'] ? \'selected\' : \'\' ?>><?= htmlspecialchars((string)$g[\'name\']) ?></option>
<?php endforeach; ?>
</select>
</div>';
$repl_group_edit = $find_group_edit . '
<div class="mb-3">
<label class="form-label fw-semibold" data-en="Assigned Outlet" data-ar="الفرع">Assigned Outlet</label>
<select name="outlet_id" class="form-select">
<option value="">--- Global (Admin only) ---</option>
<?php foreach (($data[\'outlets\'] ?? []) as $o): ?>
<option value="<?= $o[\'id\'] ?>" <?= ($u[\'outlet_id\'] ?? null) == $o[\'id\'] ? \'selected\' : \'\' ?>><?= htmlspecialchars($o[\'name\']) ?></option>
<?php endforeach; ?>
</select>
</div>';
$c = str_replace($find_group_edit, $repl_group_edit, $c);
// Also we need to make sure 'status' was updated in Edit User POST!
// Looking at the previous edit_user patch, I didn't add status. I will add status now since the UI has it!
// Actually, earlier the backend code didn't update `status`?
// Let me just replace the file contents.
file_put_contents('index.php', $c);
echo "UI Edit Patched\n";