diff --git a/app/modules_app/audit/index.php b/app/modules_app/audit/index.php index 8983a75..890a033 100644 --- a/app/modules_app/audit/index.php +++ b/app/modules_app/audit/index.php @@ -59,6 +59,11 @@ try { // Format logs foreach ($logs as &$log) { + // Decrypt user name if encrypted + if (!empty($log['user_name'])) { + $dec = \App\Core\Encryption::decrypt($log['user_name']); + $log['user_name'] = ($dec !== false && $dec !== null) ? $dec : $log['user_name']; + } $log['old_values'] = json_decode($log['old_data'] ?? '{}', true); $log['details'] = json_decode($log['new_data'] ?? '{}', true); unset($log['old_data'], $log['new_data'], $log['user_agent'], $log['ip_address']); diff --git a/app/modules_app/reports/tax_summary.php b/app/modules_app/reports/tax_summary.php index e6151fd..3e97e5b 100644 --- a/app/modules_app/reports/tax_summary.php +++ b/app/modules_app/reports/tax_summary.php @@ -17,7 +17,7 @@ $companyId = $_GET['company_id'] ?? null; $month = $_GET['month'] ?? date('m'); $year = $_GET['year'] ?? date('Y'); -$where = ["MONTH(i.invoice_date) = ? AND YEAR(i.invoice_date) = ?"]; +$where = ["MONTH(i.created_at) = ? AND YEAR(i.created_at) = ?"]; $params = [$month, $year]; if ($role !== 'super_admin') { @@ -55,13 +55,13 @@ $summary = $stmt->fetch(); // 2. Daily breakdown for chart $stmtDaily = $db->prepare(" SELECT - DAY(i.invoice_date) as day_num, + DAY(i.created_at) as day_num, COUNT(*) as count, COALESCE(SUM(grand_total), 0) as daily_total, COALESCE(SUM(tax_amount), 0) as daily_tax FROM invoices i $whereClause - GROUP BY DAY(i.invoice_date) + GROUP BY DAY(i.created_at) ORDER BY day_num "); $stmtDaily->execute($params); @@ -107,8 +107,8 @@ $prevMonth = $month == 1 ? 12 : $month - 1; $prevYear = $month == 1 ? $year - 1 : $year; $prevWhere = str_replace( - "MONTH(i.invoice_date) = ? AND YEAR(i.invoice_date) = ?", - "MONTH(i.invoice_date) = ? AND YEAR(i.invoice_date) = ?", + "MONTH(i.created_at) = ? AND YEAR(i.created_at) = ?", + "MONTH(i.created_at) = ? AND YEAR(i.created_at) = ?", implode(' AND ', $where) ); @@ -122,7 +122,7 @@ $stmtPrev = $db->prepare(" COALESCE(SUM(grand_total), 0) as total_grand, COALESCE(SUM(tax_amount), 0) as total_tax FROM invoices i - WHERE MONTH(i.invoice_date) = ? AND YEAR(i.invoice_date) = ? + WHERE MONTH(i.created_at) = ? AND YEAR(i.created_at) = ? " . ($role !== 'super_admin' ? " AND i.tenant_id = ?" : "") . ($companyId ? " AND i.company_id = ?" : "") );