Update: 2026-05-04 17:59:11
This commit is contained in:
@@ -60,18 +60,20 @@ try {
|
||||
$invoices = $stmt->fetchAll();
|
||||
|
||||
// 3. Decrypt sensitive fields for display (Robustly)
|
||||
$decrypt = fn($val) => Encryption::decrypt($val ?? '') ?: ($val ?? '-');
|
||||
$dec = function($val) {
|
||||
if (empty($val)) return '';
|
||||
$result = Encryption::decrypt((string)$val);
|
||||
return ($result !== false && $result !== null && $result !== '') ? $result : (string)$val;
|
||||
};
|
||||
|
||||
foreach ($invoices as &$inv) {
|
||||
$inv['supplier_name'] = $decrypt($inv['supplier_name']);
|
||||
$inv['supplier_tin'] = $decrypt($inv['supplier_tin']);
|
||||
$inv['buyer_name'] = $decrypt($inv['buyer_name']);
|
||||
$inv['supplier_name'] = $dec($inv['supplier_name']);
|
||||
$inv['supplier_tin'] = $dec($inv['supplier_tin']);
|
||||
$inv['buyer_name'] = $dec($inv['buyer_name']);
|
||||
|
||||
if (!empty($inv['company_name'])) {
|
||||
$inv['company_name'] = $decrypt($inv['company_name']);
|
||||
}
|
||||
if (!empty($inv['tenant_name'])) {
|
||||
$inv['tenant_name'] = $decrypt($inv['tenant_name']);
|
||||
}
|
||||
// Note: company_name and tenant_name from JOIN are usually plaintext
|
||||
// Only decrypt if you are absolutely sure they are encrypted in the source table.
|
||||
// For companies.name, it's plaintext.
|
||||
}
|
||||
|
||||
json_success($invoices);
|
||||
|
||||
Reference in New Issue
Block a user