35 lines
1.7 KiB
PHP
35 lines
1.7 KiB
PHP
<?php
|
|
$c = file_get_contents('index.php');
|
|
|
|
// Fetch outlets for users
|
|
$c = str_replace(
|
|
"\$data['role_groups'] = db()->query(\"SELECT id, name FROM role_groups ORDER BY name ASC\")->fetchAll();\n break;\n case 'backups':",
|
|
"\$data['role_groups'] = db()->query(\"SELECT id, name FROM role_groups ORDER BY name ASC\")->fetchAll();\n \$data['outlets'] = db()->query(\"SELECT id, name FROM outlets ORDER BY name ASC\")->fetchAll();\n break;\n case 'backups':",
|
|
$c
|
|
);
|
|
|
|
// Add Outlet field to Add User
|
|
$find_group_add = '<select name="group_id" class="form-select">
|
|
<option value="">--- Select Group ---</option>
|
|
<?php foreach (($data[\'role_groups\'] ?? []) as $g): ?>
|
|
<option value="<?= $g[\'id\'] ?>"><?= htmlspecialchars($g[\'name\']) ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</div>';
|
|
|
|
$repl_group_add = $find_group_add . '
|
|
<div class="mb-3">
|
|
<label class="form-label" 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\'] ?>"><?= htmlspecialchars($o[\'name\']) ?></option>
|
|
<?php endforeach; ?>
|
|
</select>
|
|
</div>';
|
|
|
|
$c = str_replace($find_group_add, $repl_group_add, $c);
|
|
|
|
file_put_contents('index.php', $c);
|
|
echo "UI Patched\n";
|