diff --git a/admin/emails.php b/admin/emails.php index f52f842..babcb00 100644 --- a/admin/emails.php +++ b/admin/emails.php @@ -9,61 +9,61 @@ require_once __DIR__ . '/includes/header.php'; if ($_SERVER['REQUEST_METHOD'] === 'POST') { $section = $_POST['section'] ?? ''; - - if ($section === 'sendgrid') { - setSetting('email_sendgrid', [ - 'api_key' => trim($_POST['sendgrid_api_key'] ?? ''), + + if ($section === 'cybermail') { + setSetting('email_cybermail', [ + 'api_key' => trim($_POST['cybermail_api_key'] ?? ''), 'from_email' => trim($_POST['from_email'] ?? ''), - 'from_name' => trim($_POST['from_name'] ?? '') + 'from_name' => trim($_POST['from_name'] ?? '') ]); - setFlash('success', 'SendGrid settings updated'); + setFlash('success', 'CyberMail settings updated'); } - + if ($section === 'notifications') { setSetting('email_notifications', [ 'order_confirmation' => isset($_POST['notif_order_confirmation']), - 'order_shipped' => isset($_POST['notif_order_shipped']), - 'order_delivered' => isset($_POST['notif_order_delivered']), - 'abandoned_cart' => isset($_POST['notif_abandoned_cart']), - 'low_stock' => isset($_POST['notif_low_stock']), - 'admin_new_order' => isset($_POST['notif_admin_new_order']), - 'admin_email' => trim($_POST['admin_email'] ?? '') + 'order_shipped' => isset($_POST['notif_order_shipped']), + 'order_delivered' => isset($_POST['notif_order_delivered']), + 'abandoned_cart' => isset($_POST['notif_abandoned_cart']), + 'low_stock' => isset($_POST['notif_low_stock']), + 'admin_new_order' => isset($_POST['notif_admin_new_order']), + 'admin_email' => trim($_POST['admin_email'] ?? '') ]); setFlash('success', 'Notification settings updated'); } - + if ($section === 'test') { $testEmail = trim($_POST['test_email'] ?? ''); if ($testEmail && filter_var($testEmail, FILTER_VALIDATE_EMAIL)) { - $sent = sendEmail($testEmail, 'Test Email from Tom\'s Java Jive', - '

Test Email

If you received this, your email settings are working correctly!

' + $sent = sendEmail($testEmail, 'Test Email from Tom\'s Java Jive', + '

Test Email

If you received this, your CyberMail settings are working correctly!

' ); if ($sent) { setFlash('success', 'Test email sent to ' . $testEmail); } else { - setFlash('error', 'Failed to send test email. Check your SendGrid settings.'); + setFlash('error', 'Failed to send test email. Check CYBERMAIL_API_KEY in config.'); } } } - + header('Location: /admin/emails.php'); exit; } -$sendgrid = getSetting('email_sendgrid', [ - 'api_key' => '', +$cybermail = getSetting('email_cybermail', [ + 'api_key' => '', 'from_email' => '', - 'from_name' => "Tom's Java Jive" + 'from_name' => "Tom's Java Jive" ]); $notifications = getSetting('email_notifications', [ 'order_confirmation' => true, - 'order_shipped' => true, - 'order_delivered' => true, - 'abandoned_cart' => false, - 'low_stock' => true, - 'admin_new_order' => true, - 'admin_email' => '' + 'order_shipped' => true, + 'order_delivered' => true, + 'abandoned_cart' => false, + 'low_stock' => true, + 'admin_new_order' => true, + 'admin_email' => '' ]); ?> @@ -89,44 +89,44 @@ $notifications = getSetting('email_notifications', [ - +
- +
- +
-

SendGrid Configuration

+

CyberMail Configuration

- - - Get this from SendGrid Dashboard + + + Manage at CyberMail Dashboard
- +
- +
-
- - + +
- +
@@ -136,64 +136,64 @@ $notifications = getSetting('email_notifications', [

Customer Notifications

- +
- +
- +
- +
- +

Admin Notifications

- +
- +
- +
-
- +
- +
diff --git a/admin/integrations.php b/admin/integrations.php index d30f70f..edca34d 100644 --- a/admin/integrations.php +++ b/admin/integrations.php @@ -11,21 +11,20 @@ require_once __DIR__ . '/includes/header.php'; // Handle form submission if ($_SERVER['REQUEST_METHOD'] === 'POST') { $section = $_POST['section'] ?? ''; - + $settingsMap = [ - 'sendgrid' => ['sendgrid_api_key', 'sendgrid_from_email', 'sendgrid_from_name', 'email_notifications_enabled'], - 'twilio' => ['twilio_account_sid', 'twilio_auth_token', 'twilio_phone_number', 'sms_notifications_enabled'], - 'push' => ['vapid_public_key', 'vapid_private_key', 'push_notifications_enabled'], - 'loyalty' => ['loyalty_enabled'] + 'cybermail' => ['cybermail_api_key', 'cybermail_from_email', 'cybermail_from_name', 'email_notifications_enabled'], + 'twilio' => ['twilio_account_sid', 'twilio_auth_token', 'twilio_phone_number', 'sms_notifications_enabled'], + 'push' => ['vapid_public_key', 'vapid_private_key', 'push_notifications_enabled'], + 'loyalty' => ['loyalty_enabled'] ]; - + if (isset($settingsMap[$section])) { foreach ($settingsMap[$section] as $key) { $value = $_POST[$key] ?? ''; - - // Check if setting exists + $existing = db()->fetch("SELECT id FROM settings WHERE setting_key = :key", ['key' => $key]); - + if ($existing) { db()->query( "UPDATE settings SET setting_value = :value, updated_at = NOW() WHERE setting_key = :key", @@ -33,15 +32,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') { ); } else { db()->insert('settings', [ - 'setting_key' => $key, + 'setting_key' => $key, 'setting_value' => $value ]); } } - + setFlash('success', ucfirst($section) . ' settings saved successfully!'); } - + redirect('/admin/integrations.php'); } @@ -84,10 +83,10 @@ foreach ($allSettings as $s) { font-size: 1.5rem; } -.integration-icon.sendgrid { background: #1A82E2; color: white; } -.integration-icon.twilio { background: #F22F46; color: white; } -.integration-icon.push { background: #8B5CF6; color: white; } -.integration-icon.loyalty { background: #F59E0B; color: white; } +.integration-icon.cybermail { background: #0ea5e9; color: white; } +.integration-icon.twilio { background: #F22F46; color: white; } +.integration-icon.push { background: #8B5CF6; color: white; } +.integration-icon.loyalty { background: #F59E0B; color: white; } .integration-body { padding: 1.5rem; @@ -100,44 +99,15 @@ foreach ($allSettings as $s) { font-weight: 600; } -.status-badge.configured { - background: rgba(16, 185, 129, 0.1); - color: var(--admin-success); -} +.status-badge.configured { background: rgba(16, 185, 129, 0.1); color: var(--admin-success); } +.status-badge.not-configured { background: rgba(245, 158, 11, 0.1); color: var(--admin-warning); } +.status-badge.enabled { background: rgba(16, 185, 129, 0.1); color: var(--admin-success); } +.status-badge.disabled { background: rgba(239, 68, 68, 0.1); color: var(--admin-error); } -.status-badge.not-configured { - background: rgba(245, 158, 11, 0.1); - color: var(--admin-warning); -} - -.status-badge.enabled { - background: rgba(16, 185, 129, 0.1); - color: var(--admin-success); -} - -.status-badge.disabled { - background: rgba(239, 68, 68, 0.1); - color: var(--admin-error); -} - -.key-input { - font-family: monospace; - font-size: 0.875rem; -} - -.test-btn { - margin-top: 0.5rem; -} - -.help-text { - font-size: 0.75rem; - color: var(--admin-text-muted); - margin-top: 0.25rem; -} - -.help-link { - color: var(--admin-primary); -} +.key-input { font-family: monospace; font-size: 0.875rem; } +.test-btn { margin-top: 0.5rem; } +.help-text { font-size: 0.75rem; color: var(--admin-text-muted); margin-top: 0.25rem; } +.help-link { color: var(--admin-primary); } - +
-
+
-

SendGrid Email

+

CyberMail

Send transactional emails (order confirmations, shipping updates, etc.)

- - - + +
- - + +
- - + +

- Get your API key from - SendGrid Dashboard + Manage at + CyberMail Dashboard

- +
- +
- "> + ">
- +
- +
-
@@ -237,9 +207,9 @@ foreach ($allSettings as $s) {

- @@ -248,41 +218,41 @@ foreach ($allSettings as $s) {
- +
-
-
- +
-

- Get your credentials from + Get your credentials from Twilio Console

- +
- +
- @@ -320,33 +290,33 @@ foreach ($allSettings as $s) {
- +
-
- +
-

- Generate VAPID keys at + Generate VAPID keys at Web Push Codelab

- +
- + @@ -376,15 +346,15 @@ foreach ($allSettings as $s) {
- +
- +

Tier Structure

@@ -424,10 +394,10 @@ foreach ($allSettings as $s) {

- 100 points = $1 credit • Points earned on every purchase + 100 points = $1 credit • Points earned on every purchase

- + @@ -463,7 +433,7 @@ foreach ($allSettings as $s) {