From 6d57961985ecd319d202fdec805acc87ab1b9522 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Fri, 13 Feb 2026 10:15:56 +0000 Subject: [PATCH] adding favicon --- admin/audit_logs.php | 3 + admin/auth.php | 131 +++++--- admin/cases.php | 3 + admin/categories.php | 3 + admin/donations.php | 3 + admin/donors.php | 3 + admin/financial_summary.php | 5 +- admin/index.php | 5 +- admin/login.php | 3 + admin/profile.php | 49 ++- admin/settings.php | 3 + assets/images/favicon_1770977716.jpg | Bin 0 -> 6101 bytes certificate.php | 7 +- db/migrations/20260213_add_email_settings.sql | 4 +- db/migrations/20260213_add_favicon_url.sql | 2 + index.php | 3 + mail/MailService.php | 50 ++- mail/WablasService.php | 12 +- mail/config.php | 19 +- scripts/monthly_report.php | 317 +++++++++--------- success.php | 5 +- 21 files changed, 393 insertions(+), 237 deletions(-) create mode 100644 assets/images/favicon_1770977716.jpg create mode 100644 db/migrations/20260213_add_favicon_url.sql diff --git a/admin/audit_logs.php b/admin/audit_logs.php index 63660c1..94bf156 100644 --- a/admin/audit_logs.php +++ b/admin/audit_logs.php @@ -21,6 +21,9 @@ $logs = $pdo->query(" Audit Logs - <?= htmlspecialchars(get_org_name()) ?> Admin + + + - - -
-
-

Monthly Financial Summary

-

Period: {$month_name}

-
- -
-
-

Total Donations

-
$" . number_format($stats['total_amount'], 2) . "
-
-
-

Donation Count

-
{$stats['total_count']}
-
-
- -

Donations by Category

- - - - - - - - "; - -foreach ($stats['by_category'] as $cat) { - $html .= ""; -} - -$html .= " - -
CategoryAmount
" . htmlspecialchars($cat['name']) . "$" . number_format($cat['total'], 2) . "
- -

Top 5 Performing Cases

- - - - - - - - "; - -foreach ($stats['top_cases'] as $case) { - $html .= ""; -} - -$html .= " - -
Case TitleAmount
" . htmlspecialchars($case['title']) . "$" . number_format($case['total'], 2) . "
- - -
- -"; - -// Send Email -$subject = "Financial Summary Report - {$month_name}"; -$plain_text = "Monthly Financial Summary for {$month_name}\n\nTotal Amount: $" . number_format($stats['total_amount'], 2) . "\nTotal Count: {$stats['total_count']}\n\nPlease view the HTML version for detailed breakdown."; - -$res = MailService::sendMail($recipient, $subject, $html, $plain_text); - -if (!empty($res['success'])) { - echo "Report sent successfully to {$recipient} for {$month_name}.\n"; -} else { - echo "Failed to send report: " . ($res['error'] ?? 'Unknown error') . "\n"; -} - +query("SELECT * FROM settings")->fetchAll(); +$settings = []; +foreach ($settings_raw as $s) { + $settings[$s['setting_key']] = $s['setting_value']; +} + +$recipient = $settings['report_recipient_email'] ?? getenv('MAIL_TO'); + +if (empty($recipient)) { + die("Error: No recipient email configured in settings or environment.\n"); +} + +// Get org profile +$org = $pdo->query("SELECT * FROM org_profile LIMIT 1")->fetch(); +$orgName = $org['name_en'] ?? 'Organization'; + +// Calculate last month date range +$start_date = date('Y-m-01', strtotime('first day of last month')); +$end_date = date('Y-m-t', strtotime('last month')); +$month_name = date('F Y', strtotime('last month')); + +// Fetch statistics for the period +$stats = []; + +// 1. Total Donations +$stmt = $pdo->prepare("SELECT SUM(amount) as total, COUNT(*) as count FROM donations WHERE status = 'paid' AND created_at BETWEEN ? AND ?"); +$stmt->execute([$start_date . ' 00:00:00', $end_date . ' 23:59:59']); +$donation_stats = $stmt->fetch(PDO::FETCH_ASSOC); +$stats['total_amount'] = $donation_stats['total'] ?? 0; +$stats['total_count'] = $donation_stats['count'] ?? 0; + +// 2. Donations by Category +$stmt = $pdo->prepare(" + SELECT c.name, SUM(d.amount) as total + FROM donations d + JOIN cases cs ON d.case_id = cs.id + JOIN categories c ON cs.category_id = c.id + WHERE d.status = 'paid' AND d.created_at BETWEEN ? AND ? + GROUP BY c.id + ORDER BY total DESC +"); +$stmt->execute([$start_date . ' 00:00:00', $end_date . ' 23:59:59']); +$stats['by_category'] = $stmt->fetchAll(PDO::FETCH_ASSOC); + +// 3. Top Cases +$stmt = $pdo->prepare(" + SELECT cs.title, SUM(d.amount) as total + FROM donations d + JOIN cases cs ON d.case_id = cs.id + WHERE d.status = 'paid' AND d.created_at BETWEEN ? AND ? + GROUP BY cs.id + ORDER BY total DESC + LIMIT 5 +"); +$stmt->execute([$start_date . ' 00:00:00', $end_date . ' 23:59:59']); +$stats['top_cases'] = $stmt->fetchAll(PDO::FETCH_ASSOC); + +// Build HTML Email +$html = " + + + + + +
+
+

Monthly Financial Summary

+

Period: {$month_name}

+
+ +
+
+

Total Donations

+
$ " . number_format($stats['total_amount'], 2) . "
+
+
+

Donation Count

+
{$stats['total_count']}
+
+
+ +

Donations by Category

+ + + + + + + + "; + +foreach ($stats['by_category'] as $cat) { + $html .= ""; +} + +$html .= " + +
CategoryAmount
" . htmlspecialchars($cat['name']) . "$" . number_format($cat['total'], 2) . "
+ +

Top 5 Performing Cases

+ + + + + + + + "; + +foreach ($stats['top_cases'] as $case) { + $html .= ""; +} + +$html .= " + +
Case TitleAmount
" . htmlspecialchars($case['title']) . "$" . number_format($case['total'], 2) . "
+ + +
+ +"; + +// Send Email +$subject = "Financial Summary Report - {$month_name}"; +$plain_text = "Monthly Financial Summary for {$month_name}\n\nTotal Amount: $" . number_format($stats['total_amount'], 2) . "\nTotal Count: {$stats['total_count']}\n\nPlease view the HTML version for detailed breakdown."; + +$res = MailService::sendMail($recipient, $subject, $html, $plain_text); + +if (!empty($res['success'])) { + echo "Report sent successfully to {$recipient} for {$month_name}.\n"; +} else { + echo "Failed to send report: " . ($res['error'] ?? 'Unknown error') . "\n"; +} \ No newline at end of file diff --git a/success.php b/success.php index d483bc8..a702a37 100644 --- a/success.php +++ b/success.php @@ -77,13 +77,16 @@ if ($donation) { $final_donation_id = $existing['id']; } } + +$org = $pdo->query("SELECT * FROM org_profile LIMIT 1")->fetch(); +$orgName = $org['name_en'] ?? 'Organization'; ?> - Donation Successful - CharityHub + Donation Successful - <?= htmlspecialchars($orgName) ?>