Update: 2026-05-08 01:52:24
This commit is contained in:
@@ -18,18 +18,25 @@ try {
|
||||
$stmt = $db->query("
|
||||
SELECT t.id, t.name, t.email, t.phone, t.status, t.created_at,
|
||||
(SELECT COUNT(*) FROM companies WHERE tenant_id = t.id) as companies_count,
|
||||
(SELECT COUNT(*) FROM users WHERE tenant_id = t.id) as users_count,
|
||||
(SELECT COUNT(*) FROM invoices WHERE tenant_id = t.id) as invoices_count
|
||||
FROM tenants t
|
||||
ORDER BY t.created_at DESC
|
||||
");
|
||||
$tenants = $stmt->fetchAll();
|
||||
|
||||
foreach ($tenants as &$t) {
|
||||
$decName = \App\Core\Encryption::decrypt($t['name']);
|
||||
$t['name'] = $decName !== false ? $decName : $t['name'];
|
||||
$dec = function($val) {
|
||||
if (empty($val)) return '';
|
||||
$result = \App\Core\Encryption::decrypt((string)$val);
|
||||
return ($result !== false && $result !== null) ? $result : (string)$val;
|
||||
};
|
||||
|
||||
$decEmail = \App\Core\Encryption::decrypt($t['email']);
|
||||
$t['email'] = $decEmail !== false ? $decEmail : $t['email'];
|
||||
foreach ($tenants as &$t) {
|
||||
$t['name'] = $dec($t['name']);
|
||||
$t['email'] = $dec($t['email']);
|
||||
if (!empty($t['phone'])) {
|
||||
$t['phone'] = $dec($t['phone']);
|
||||
}
|
||||
}
|
||||
|
||||
json_success($tenants);
|
||||
|
||||
Reference in New Issue
Block a user