Update: 2026-05-08 01:48:19
This commit is contained in:
@@ -59,6 +59,11 @@ try {
|
|||||||
|
|
||||||
// Format logs
|
// Format logs
|
||||||
foreach ($logs as &$log) {
|
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['old_values'] = json_decode($log['old_data'] ?? '{}', true);
|
||||||
$log['details'] = json_decode($log['new_data'] ?? '{}', true);
|
$log['details'] = json_decode($log['new_data'] ?? '{}', true);
|
||||||
unset($log['old_data'], $log['new_data'], $log['user_agent'], $log['ip_address']);
|
unset($log['old_data'], $log['new_data'], $log['user_agent'], $log['ip_address']);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ $companyId = $_GET['company_id'] ?? null;
|
|||||||
$month = $_GET['month'] ?? date('m');
|
$month = $_GET['month'] ?? date('m');
|
||||||
$year = $_GET['year'] ?? date('Y');
|
$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];
|
$params = [$month, $year];
|
||||||
|
|
||||||
if ($role !== 'super_admin') {
|
if ($role !== 'super_admin') {
|
||||||
@@ -55,13 +55,13 @@ $summary = $stmt->fetch();
|
|||||||
// 2. Daily breakdown for chart
|
// 2. Daily breakdown for chart
|
||||||
$stmtDaily = $db->prepare("
|
$stmtDaily = $db->prepare("
|
||||||
SELECT
|
SELECT
|
||||||
DAY(i.invoice_date) as day_num,
|
DAY(i.created_at) as day_num,
|
||||||
COUNT(*) as count,
|
COUNT(*) as count,
|
||||||
COALESCE(SUM(grand_total), 0) as daily_total,
|
COALESCE(SUM(grand_total), 0) as daily_total,
|
||||||
COALESCE(SUM(tax_amount), 0) as daily_tax
|
COALESCE(SUM(tax_amount), 0) as daily_tax
|
||||||
FROM invoices i
|
FROM invoices i
|
||||||
$whereClause
|
$whereClause
|
||||||
GROUP BY DAY(i.invoice_date)
|
GROUP BY DAY(i.created_at)
|
||||||
ORDER BY day_num
|
ORDER BY day_num
|
||||||
");
|
");
|
||||||
$stmtDaily->execute($params);
|
$stmtDaily->execute($params);
|
||||||
@@ -107,8 +107,8 @@ $prevMonth = $month == 1 ? 12 : $month - 1;
|
|||||||
$prevYear = $month == 1 ? $year - 1 : $year;
|
$prevYear = $month == 1 ? $year - 1 : $year;
|
||||||
|
|
||||||
$prevWhere = str_replace(
|
$prevWhere = str_replace(
|
||||||
"MONTH(i.invoice_date) = ? AND YEAR(i.invoice_date) = ?",
|
"MONTH(i.created_at) = ? AND YEAR(i.created_at) = ?",
|
||||||
"MONTH(i.invoice_date) = ? AND YEAR(i.invoice_date) = ?",
|
"MONTH(i.created_at) = ? AND YEAR(i.created_at) = ?",
|
||||||
implode(' AND ', $where)
|
implode(' AND ', $where)
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -122,7 +122,7 @@ $stmtPrev = $db->prepare("
|
|||||||
COALESCE(SUM(grand_total), 0) as total_grand,
|
COALESCE(SUM(grand_total), 0) as total_grand,
|
||||||
COALESCE(SUM(tax_amount), 0) as total_tax
|
COALESCE(SUM(tax_amount), 0) as total_tax
|
||||||
FROM invoices i
|
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 = ?" : "")
|
" . ($role !== 'super_admin' ? " AND i.tenant_id = ?" : "")
|
||||||
. ($companyId ? " AND i.company_id = ?" : "")
|
. ($companyId ? " AND i.company_id = ?" : "")
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user