Replace all SendGrid references with CyberMail in admin UI

This commit is contained in:
2026-05-29 15:06:43 +00:00
parent 25e96a3d5f
commit 53f9f3e4da
2 changed files with 139 additions and 169 deletions
+57 -57
View File
@@ -9,61 +9,61 @@ require_once __DIR__ . '/includes/header.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$section = $_POST['section'] ?? ''; $section = $_POST['section'] ?? '';
if ($section === 'sendgrid') { if ($section === 'cybermail') {
setSetting('email_sendgrid', [ setSetting('email_cybermail', [
'api_key' => trim($_POST['sendgrid_api_key'] ?? ''), 'api_key' => trim($_POST['cybermail_api_key'] ?? ''),
'from_email' => trim($_POST['from_email'] ?? ''), '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') { if ($section === 'notifications') {
setSetting('email_notifications', [ setSetting('email_notifications', [
'order_confirmation' => isset($_POST['notif_order_confirmation']), 'order_confirmation' => isset($_POST['notif_order_confirmation']),
'order_shipped' => isset($_POST['notif_order_shipped']), 'order_shipped' => isset($_POST['notif_order_shipped']),
'order_delivered' => isset($_POST['notif_order_delivered']), 'order_delivered' => isset($_POST['notif_order_delivered']),
'abandoned_cart' => isset($_POST['notif_abandoned_cart']), 'abandoned_cart' => isset($_POST['notif_abandoned_cart']),
'low_stock' => isset($_POST['notif_low_stock']), 'low_stock' => isset($_POST['notif_low_stock']),
'admin_new_order' => isset($_POST['notif_admin_new_order']), 'admin_new_order' => isset($_POST['notif_admin_new_order']),
'admin_email' => trim($_POST['admin_email'] ?? '') 'admin_email' => trim($_POST['admin_email'] ?? '')
]); ]);
setFlash('success', 'Notification settings updated'); setFlash('success', 'Notification settings updated');
} }
if ($section === 'test') { if ($section === 'test') {
$testEmail = trim($_POST['test_email'] ?? ''); $testEmail = trim($_POST['test_email'] ?? '');
if ($testEmail && filter_var($testEmail, FILTER_VALIDATE_EMAIL)) { if ($testEmail && filter_var($testEmail, FILTER_VALIDATE_EMAIL)) {
$sent = sendEmail($testEmail, 'Test Email from Tom\'s Java Jive', $sent = sendEmail($testEmail, 'Test Email from Tom\'s Java Jive',
'<div style="font-family: Arial; padding: 20px;"><h2>Test Email</h2><p>If you received this, your email settings are working correctly!</p></div>' '<div style="font-family: Arial; padding: 20px;"><h2>Test Email</h2><p>If you received this, your CyberMail settings are working correctly!</p></div>'
); );
if ($sent) { if ($sent) {
setFlash('success', 'Test email sent to ' . $testEmail); setFlash('success', 'Test email sent to ' . $testEmail);
} else { } 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'); header('Location: /admin/emails.php');
exit; exit;
} }
$sendgrid = getSetting('email_sendgrid', [ $cybermail = getSetting('email_cybermail', [
'api_key' => '', 'api_key' => '',
'from_email' => '', 'from_email' => '',
'from_name' => "Tom's Java Jive" 'from_name' => "Tom's Java Jive"
]); ]);
$notifications = getSetting('email_notifications', [ $notifications = getSetting('email_notifications', [
'order_confirmation' => true, 'order_confirmation' => true,
'order_shipped' => true, 'order_shipped' => true,
'order_delivered' => true, 'order_delivered' => true,
'abandoned_cart' => false, 'abandoned_cart' => false,
'low_stock' => true, 'low_stock' => true,
'admin_new_order' => true, 'admin_new_order' => true,
'admin_email' => '' 'admin_email' => ''
]); ]);
?> ?>
@@ -89,44 +89,44 @@ $notifications = getSetting('email_notifications', [
</div> </div>
</div> </div>
</div> </div>
<div> <div>
<!-- SendGrid Settings --> <!-- CyberMail Settings -->
<form method="POST"> <form method="POST">
<input type="hidden" name="section" value="sendgrid"> <input type="hidden" name="section" value="cybermail">
<div class="admin-card"> <div class="admin-card">
<div class="admin-card-header"> <div class="admin-card-header">
<h3 class="admin-card-title"><i class="fas fa-paper-plane"></i> SendGrid Configuration</h3> <h3 class="admin-card-title"><i class="fas fa-paper-plane"></i> CyberMail Configuration</h3>
</div> </div>
<div class="admin-card-body"> <div class="admin-card-body">
<div class="form-group"> <div class="form-group">
<label class="form-label">SendGrid API Key</label> <label class="form-label">CyberMail API Key</label>
<input type="password" name="sendgrid_api_key" class="form-input" <input type="password" name="cybermail_api_key" class="form-input"
value="<?= htmlspecialchars($sendgrid['api_key']) ?>" value="<?= htmlspecialchars($cybermail['api_key']) ?>"
placeholder="SG.xxxx..."> placeholder="sk_live_...">
<small class="text-muted">Get this from <a href="https://app.sendgrid.com/settings/api_keys" target="_blank">SendGrid Dashboard</a></small> <small class="text-muted">Manage at <a href="https://platform.cyberpersons.com/email/api-keys/" target="_blank">CyberMail Dashboard</a></small>
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group"> <div class="form-group">
<label class="form-label">From Email</label> <label class="form-label">From Email</label>
<input type="email" name="from_email" class="form-input" <input type="email" name="from_email" class="form-input"
value="<?= htmlspecialchars($sendgrid['from_email']) ?>" value="<?= htmlspecialchars($cybermail['from_email']) ?>"
placeholder="noreply@yourdomain.com"> placeholder="noreply@orbishosting.com">
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label">From Name</label> <label class="form-label">From Name</label>
<input type="text" name="from_name" class="form-input" <input type="text" name="from_name" class="form-input"
value="<?= htmlspecialchars($sendgrid['from_name']) ?>" value="<?= htmlspecialchars($cybermail['from_name']) ?>"
placeholder="Tom's Java Jive"> placeholder="Tom's Java Jive">
</div> </div>
</div> </div>
<button type="submit" class="btn btn-primary">Save SendGrid Settings</button> <button type="submit" class="btn btn-primary">Save CyberMail Settings</button>
</div> </div>
</div> </div>
</form> </form>
<!-- Notification Settings --> <!-- Notification Settings -->
<form method="POST"> <form method="POST">
<input type="hidden" name="section" value="notifications"> <input type="hidden" name="section" value="notifications">
@@ -136,64 +136,64 @@ $notifications = getSetting('email_notifications', [
</div> </div>
<div class="admin-card-body"> <div class="admin-card-body">
<h4 style="margin-bottom: 1rem; font-size: 0.9rem; color: var(--admin-text-muted);">Customer Notifications</h4> <h4 style="margin-bottom: 1rem; font-size: 0.9rem; color: var(--admin-text-muted);">Customer Notifications</h4>
<div class="form-group"> <div class="form-group">
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;"> <label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
<input type="checkbox" name="notif_order_confirmation" <?= $notifications['order_confirmation'] ? 'checked' : '' ?>> <input type="checkbox" name="notif_order_confirmation" <?= $notifications['order_confirmation'] ? 'checked' : '' ?>>
Order confirmation email Order confirmation email
</label> </label>
</div> </div>
<div class="form-group"> <div class="form-group">
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;"> <label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
<input type="checkbox" name="notif_order_shipped" <?= $notifications['order_shipped'] ? 'checked' : '' ?>> <input type="checkbox" name="notif_order_shipped" <?= $notifications['order_shipped'] ? 'checked' : '' ?>>
Order shipped notification Order shipped notification
</label> </label>
</div> </div>
<div class="form-group"> <div class="form-group">
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;"> <label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
<input type="checkbox" name="notif_order_delivered" <?= $notifications['order_delivered'] ? 'checked' : '' ?>> <input type="checkbox" name="notif_order_delivered" <?= $notifications['order_delivered'] ? 'checked' : '' ?>>
Order delivered notification Order delivered notification
</label> </label>
</div> </div>
<div class="form-group"> <div class="form-group">
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;"> <label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
<input type="checkbox" name="notif_abandoned_cart" <?= $notifications['abandoned_cart'] ? 'checked' : '' ?>> <input type="checkbox" name="notif_abandoned_cart" <?= $notifications['abandoned_cart'] ? 'checked' : '' ?>>
Abandoned cart reminders Abandoned cart reminders
</label> </label>
</div> </div>
<hr style="margin: 1.5rem 0;"> <hr style="margin: 1.5rem 0;">
<h4 style="margin-bottom: 1rem; font-size: 0.9rem; color: var(--admin-text-muted);">Admin Notifications</h4> <h4 style="margin-bottom: 1rem; font-size: 0.9rem; color: var(--admin-text-muted);">Admin Notifications</h4>
<div class="form-group"> <div class="form-group">
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;"> <label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
<input type="checkbox" name="notif_admin_new_order" <?= $notifications['admin_new_order'] ? 'checked' : '' ?>> <input type="checkbox" name="notif_admin_new_order" <?= $notifications['admin_new_order'] ? 'checked' : '' ?>>
New order notification New order notification
</label> </label>
</div> </div>
<div class="form-group"> <div class="form-group">
<label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;"> <label style="display: flex; align-items: center; gap: 0.5rem; cursor: pointer;">
<input type="checkbox" name="notif_low_stock" <?= $notifications['low_stock'] ? 'checked' : '' ?>> <input type="checkbox" name="notif_low_stock" <?= $notifications['low_stock'] ? 'checked' : '' ?>>
Low stock alerts Low stock alerts
</label> </label>
</div> </div>
<div class="form-group mb-0"> <div class="form-group mb-0">
<label class="form-label">Admin Email Address</label> <label class="form-label">Admin Email Address</label>
<input type="email" name="admin_email" class="form-input" <input type="email" name="admin_email" class="form-input"
value="<?= htmlspecialchars($notifications['admin_email']) ?>" value="<?= htmlspecialchars($notifications['admin_email']) ?>"
placeholder="admin@yourdomain.com"> placeholder="admin@yourdomain.com">
</div> </div>
<button type="submit" class="btn btn-primary mt-2">Save Notification Settings</button> <button type="submit" class="btn btn-primary mt-2">Save Notification Settings</button>
</div> </div>
</div> </div>
</form> </form>
<!-- Test Email --> <!-- Test Email -->
<form method="POST"> <form method="POST">
<input type="hidden" name="section" value="test"> <input type="hidden" name="section" value="test">
+82 -112
View File
@@ -11,21 +11,20 @@ require_once __DIR__ . '/includes/header.php';
// Handle form submission // Handle form submission
if ($_SERVER['REQUEST_METHOD'] === 'POST') { if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$section = $_POST['section'] ?? ''; $section = $_POST['section'] ?? '';
$settingsMap = [ $settingsMap = [
'sendgrid' => ['sendgrid_api_key', 'sendgrid_from_email', 'sendgrid_from_name', 'email_notifications_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'], 'twilio' => ['twilio_account_sid', 'twilio_auth_token', 'twilio_phone_number', 'sms_notifications_enabled'],
'push' => ['vapid_public_key', 'vapid_private_key', 'push_notifications_enabled'], 'push' => ['vapid_public_key', 'vapid_private_key', 'push_notifications_enabled'],
'loyalty' => ['loyalty_enabled'] 'loyalty' => ['loyalty_enabled']
]; ];
if (isset($settingsMap[$section])) { if (isset($settingsMap[$section])) {
foreach ($settingsMap[$section] as $key) { foreach ($settingsMap[$section] as $key) {
$value = $_POST[$key] ?? ''; $value = $_POST[$key] ?? '';
// Check if setting exists
$existing = db()->fetch("SELECT id FROM settings WHERE setting_key = :key", ['key' => $key]); $existing = db()->fetch("SELECT id FROM settings WHERE setting_key = :key", ['key' => $key]);
if ($existing) { if ($existing) {
db()->query( db()->query(
"UPDATE settings SET setting_value = :value, updated_at = NOW() WHERE setting_key = :key", "UPDATE settings SET setting_value = :value, updated_at = NOW() WHERE setting_key = :key",
@@ -33,15 +32,15 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST') {
); );
} else { } else {
db()->insert('settings', [ db()->insert('settings', [
'setting_key' => $key, 'setting_key' => $key,
'setting_value' => $value 'setting_value' => $value
]); ]);
} }
} }
setFlash('success', ucfirst($section) . ' settings saved successfully!'); setFlash('success', ucfirst($section) . ' settings saved successfully!');
} }
redirect('/admin/integrations.php'); redirect('/admin/integrations.php');
} }
@@ -84,10 +83,10 @@ foreach ($allSettings as $s) {
font-size: 1.5rem; font-size: 1.5rem;
} }
.integration-icon.sendgrid { background: #1A82E2; color: white; } .integration-icon.cybermail { background: #0ea5e9; color: white; }
.integration-icon.twilio { background: #F22F46; color: white; } .integration-icon.twilio { background: #F22F46; color: white; }
.integration-icon.push { background: #8B5CF6; color: white; } .integration-icon.push { background: #8B5CF6; color: white; }
.integration-icon.loyalty { background: #F59E0B; color: white; } .integration-icon.loyalty { background: #F59E0B; color: white; }
.integration-body { .integration-body {
padding: 1.5rem; padding: 1.5rem;
@@ -100,44 +99,15 @@ foreach ($allSettings as $s) {
font-weight: 600; font-weight: 600;
} }
.status-badge.configured { .status-badge.configured { background: rgba(16, 185, 129, 0.1); color: var(--admin-success); }
background: rgba(16, 185, 129, 0.1); .status-badge.not-configured { background: rgba(245, 158, 11, 0.1); color: var(--admin-warning); }
color: var(--admin-success); .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 { .key-input { font-family: monospace; font-size: 0.875rem; }
background: rgba(245, 158, 11, 0.1); .test-btn { margin-top: 0.5rem; }
color: var(--admin-warning); .help-text { font-size: 0.75rem; color: var(--admin-text-muted); margin-top: 0.25rem; }
} .help-link { color: var(--admin-primary); }
.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);
}
</style> </style>
<div class="page-header"> <div class="page-header">
@@ -151,71 +121,71 @@ foreach ($allSettings as $s) {
</div> </div>
<?php endif; ?> <?php endif; ?>
<!-- SendGrid Email --> <!-- CyberMail Email -->
<div class="integration-card"> <div class="integration-card">
<div class="integration-header"> <div class="integration-header">
<div class="integration-title"> <div class="integration-title">
<div class="integration-icon sendgrid"> <div class="integration-icon cybermail">
<i class="fas fa-envelope"></i> <i class="fas fa-envelope"></i>
</div> </div>
<div> <div>
<h3 style="margin: 0;">SendGrid Email</h3> <h3 style="margin: 0;">CyberMail</h3>
<p style="margin: 0.25rem 0 0; color: var(--admin-text-muted); font-size: 0.875rem;"> <p style="margin: 0.25rem 0 0; color: var(--admin-text-muted); font-size: 0.875rem;">
Send transactional emails (order confirmations, shipping updates, etc.) Send transactional emails (order confirmations, shipping updates, etc.)
</p> </p>
</div> </div>
</div> </div>
<?php <?php
$sgConfigured = !empty($settings['sendgrid_api_key']) && $settings['sendgrid_api_key'] !== 'YOUR_SENDGRID_API_KEY_HERE'; $cmConfigured = !empty($settings['cybermail_api_key']);
$sgEnabled = ($settings['email_notifications_enabled'] ?? '0') === '1'; $cmEnabled = ($settings['email_notifications_enabled'] ?? '0') === '1';
?> ?>
<span class="status-badge <?= $sgConfigured && $sgEnabled ? 'enabled' : ($sgConfigured ? 'configured' : 'not-configured') ?>"> <span class="status-badge <?= $cmConfigured && $cmEnabled ? 'enabled' : ($cmConfigured ? 'configured' : 'not-configured') ?>">
<?= $sgConfigured && $sgEnabled ? 'Enabled' : ($sgConfigured ? 'Configured' : 'Not Configured') ?> <?= $cmConfigured && $cmEnabled ? 'Enabled' : ($cmConfigured ? 'Configured' : 'Not Configured') ?>
</span> </span>
</div> </div>
<div class="integration-body"> <div class="integration-body">
<form method="POST"> <form method="POST">
<input type="hidden" name="section" value="sendgrid"> <input type="hidden" name="section" value="cybermail">
<div class="form-row"> <div class="form-row">
<div class="form-group" style="flex: 2;"> <div class="form-group" style="flex: 2;">
<label class="form-label">SendGrid API Key</label> <label class="form-label">CyberMail API Key</label>
<input type="password" name="sendgrid_api_key" class="form-input key-input" <input type="password" name="cybermail_api_key" class="form-input key-input"
value="<?= htmlspecialchars($settings['sendgrid_api_key'] ?? '') ?>" value="<?= htmlspecialchars($settings['cybermail_api_key'] ?? '') ?>"
placeholder="SG.xxxxxxxxxxxxxxxxxxxxxxxx"> placeholder="sk_live_...">
<p class="help-text"> <p class="help-text">
Get your API key from Manage at
<a href="https://app.sendgrid.com/settings/api_keys" target="_blank" class="help-link">SendGrid Dashboard</a> <a href="https://platform.cyberpersons.com/email/api-keys/" target="_blank" class="help-link">CyberMail Dashboard</a>
</p> </p>
</div> </div>
</div> </div>
<div class="form-row"> <div class="form-row">
<div class="form-group"> <div class="form-group">
<label class="form-label">From Email</label> <label class="form-label">From Email</label>
<input type="email" name="sendgrid_from_email" class="form-input" <input type="email" name="cybermail_from_email" class="form-input"
value="<?= htmlspecialchars($settings['sendgrid_from_email'] ?? 'noreply@tomsjavajive.com') ?>"> value="<?= htmlspecialchars($settings['cybermail_from_email'] ?? 'noreply@tomsjavajive.com') ?>">
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label">From Name</label> <label class="form-label">From Name</label>
<input type="text" name="sendgrid_from_name" class="form-input" <input type="text" name="cybermail_from_name" class="form-input"
value="<?= htmlspecialchars($settings['sendgrid_from_name'] ?? "Tom's Java Jive") ?>"> value="<?= htmlspecialchars($settings['cybermail_from_name'] ?? "Tom's Java Jive") ?>">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-checkbox"> <label class="form-checkbox">
<input type="checkbox" name="email_notifications_enabled" value="1" <input type="checkbox" name="email_notifications_enabled" value="1"
<?= ($settings['email_notifications_enabled'] ?? '0') === '1' ? 'checked' : '' ?>> <?= ($settings['email_notifications_enabled'] ?? '0') === '1' ? 'checked' : '' ?>>
Enable email notifications Enable email notifications
</label> </label>
</div> </div>
<div style="display: flex; gap: 0.5rem;"> <div style="display: flex; gap: 0.5rem;">
<button type="submit" class="btn btn-primary"> <button type="submit" class="btn btn-primary">
<i class="fas fa-save"></i> Save Settings <i class="fas fa-save"></i> Save Settings
</button> </button>
<button type="button" class="btn btn-secondary" onclick="testSendGrid()"> <button type="button" class="btn btn-secondary" onclick="testCyberMail()">
<i class="fas fa-paper-plane"></i> Send Test Email <i class="fas fa-paper-plane"></i> Send Test Email
</button> </button>
</div> </div>
@@ -237,9 +207,9 @@ foreach ($allSettings as $s) {
</p> </p>
</div> </div>
</div> </div>
<?php <?php
$twConfigured = !empty($settings['twilio_account_sid']) && !empty($settings['twilio_auth_token']); $twConfigured = !empty($settings['twilio_account_sid']) && !empty($settings['twilio_auth_token']);
$twEnabled = ($settings['sms_notifications_enabled'] ?? '0') === '1'; $twEnabled = ($settings['sms_notifications_enabled'] ?? '0') === '1';
?> ?>
<span class="status-badge <?= $twConfigured && $twEnabled ? 'enabled' : ($twConfigured ? 'configured' : 'not-configured') ?>"> <span class="status-badge <?= $twConfigured && $twEnabled ? 'enabled' : ($twConfigured ? 'configured' : 'not-configured') ?>">
<?= $twConfigured && $twEnabled ? 'Enabled' : ($twConfigured ? 'Configured' : 'Not Configured') ?> <?= $twConfigured && $twEnabled ? 'Enabled' : ($twConfigured ? 'Configured' : 'Not Configured') ?>
@@ -248,41 +218,41 @@ foreach ($allSettings as $s) {
<div class="integration-body"> <div class="integration-body">
<form method="POST"> <form method="POST">
<input type="hidden" name="section" value="twilio"> <input type="hidden" name="section" value="twilio">
<div class="form-row"> <div class="form-row">
<div class="form-group"> <div class="form-group">
<label class="form-label">Account SID</label> <label class="form-label">Account SID</label>
<input type="text" name="twilio_account_sid" class="form-input key-input" <input type="text" name="twilio_account_sid" class="form-input key-input"
value="<?= htmlspecialchars($settings['twilio_account_sid'] ?? '') ?>" value="<?= htmlspecialchars($settings['twilio_account_sid'] ?? '') ?>"
placeholder="ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"> placeholder="ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label">Auth Token</label> <label class="form-label">Auth Token</label>
<input type="password" name="twilio_auth_token" class="form-input key-input" <input type="password" name="twilio_auth_token" class="form-input key-input"
value="<?= htmlspecialchars($settings['twilio_auth_token'] ?? '') ?>" value="<?= htmlspecialchars($settings['twilio_auth_token'] ?? '') ?>"
placeholder="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"> placeholder="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label">Twilio Phone Number</label> <label class="form-label">Twilio Phone Number</label>
<input type="text" name="twilio_phone_number" class="form-input" <input type="text" name="twilio_phone_number" class="form-input"
value="<?= htmlspecialchars($settings['twilio_phone_number'] ?? '') ?>" value="<?= htmlspecialchars($settings['twilio_phone_number'] ?? '') ?>"
placeholder="+1234567890"> placeholder="+1234567890">
<p class="help-text"> <p class="help-text">
Get your credentials from Get your credentials from
<a href="https://console.twilio.com/" target="_blank" class="help-link">Twilio Console</a> <a href="https://console.twilio.com/" target="_blank" class="help-link">Twilio Console</a>
</p> </p>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-checkbox"> <label class="form-checkbox">
<input type="checkbox" name="sms_notifications_enabled" value="1" <input type="checkbox" name="sms_notifications_enabled" value="1"
<?= ($settings['sms_notifications_enabled'] ?? '0') === '1' ? 'checked' : '' ?>> <?= ($settings['sms_notifications_enabled'] ?? '0') === '1' ? 'checked' : '' ?>>
Enable SMS notifications Enable SMS notifications
</label> </label>
</div> </div>
<div style="display: flex; gap: 0.5rem;"> <div style="display: flex; gap: 0.5rem;">
<button type="submit" class="btn btn-primary"> <button type="submit" class="btn btn-primary">
<i class="fas fa-save"></i> Save Settings <i class="fas fa-save"></i> Save Settings
@@ -309,9 +279,9 @@ foreach ($allSettings as $s) {
</p> </p>
</div> </div>
</div> </div>
<?php <?php
$pushConfigured = !empty($settings['vapid_public_key']) && !empty($settings['vapid_private_key']); $pushConfigured = !empty($settings['vapid_public_key']) && !empty($settings['vapid_private_key']);
$pushEnabled = ($settings['push_notifications_enabled'] ?? '0') === '1'; $pushEnabled = ($settings['push_notifications_enabled'] ?? '0') === '1';
?> ?>
<span class="status-badge <?= $pushConfigured && $pushEnabled ? 'enabled' : ($pushConfigured ? 'configured' : 'not-configured') ?>"> <span class="status-badge <?= $pushConfigured && $pushEnabled ? 'enabled' : ($pushConfigured ? 'configured' : 'not-configured') ?>">
<?= $pushConfigured && $pushEnabled ? 'Enabled' : ($pushConfigured ? 'Configured' : 'Not Configured') ?> <?= $pushConfigured && $pushEnabled ? 'Enabled' : ($pushConfigured ? 'Configured' : 'Not Configured') ?>
@@ -320,33 +290,33 @@ foreach ($allSettings as $s) {
<div class="integration-body"> <div class="integration-body">
<form method="POST"> <form method="POST">
<input type="hidden" name="section" value="push"> <input type="hidden" name="section" value="push">
<div class="form-group"> <div class="form-group">
<label class="form-label">VAPID Public Key</label> <label class="form-label">VAPID Public Key</label>
<input type="text" name="vapid_public_key" class="form-input key-input" <input type="text" name="vapid_public_key" class="form-input key-input"
value="<?= htmlspecialchars($settings['vapid_public_key'] ?? '') ?>" value="<?= htmlspecialchars($settings['vapid_public_key'] ?? '') ?>"
placeholder="BNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"> placeholder="BNxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-label">VAPID Private Key</label> <label class="form-label">VAPID Private Key</label>
<input type="password" name="vapid_private_key" class="form-input key-input" <input type="password" name="vapid_private_key" class="form-input key-input"
value="<?= htmlspecialchars($settings['vapid_private_key'] ?? '') ?>" value="<?= htmlspecialchars($settings['vapid_private_key'] ?? '') ?>"
placeholder="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"> placeholder="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx">
<p class="help-text"> <p class="help-text">
Generate VAPID keys at Generate VAPID keys at
<a href="https://web-push-codelab.glitch.me/" target="_blank" class="help-link">Web Push Codelab</a> <a href="https://web-push-codelab.glitch.me/" target="_blank" class="help-link">Web Push Codelab</a>
</p> </p>
</div> </div>
<div class="form-group"> <div class="form-group">
<label class="form-checkbox"> <label class="form-checkbox">
<input type="checkbox" name="push_notifications_enabled" value="1" <input type="checkbox" name="push_notifications_enabled" value="1"
<?= ($settings['push_notifications_enabled'] ?? '0') === '1' ? 'checked' : '' ?>> <?= ($settings['push_notifications_enabled'] ?? '0') === '1' ? 'checked' : '' ?>>
Enable push notifications Enable push notifications
</label> </label>
</div> </div>
<button type="submit" class="btn btn-primary"> <button type="submit" class="btn btn-primary">
<i class="fas fa-save"></i> Save Settings <i class="fas fa-save"></i> Save Settings
</button> </button>
@@ -376,15 +346,15 @@ foreach ($allSettings as $s) {
<div class="integration-body"> <div class="integration-body">
<form method="POST"> <form method="POST">
<input type="hidden" name="section" value="loyalty"> <input type="hidden" name="section" value="loyalty">
<div class="form-group"> <div class="form-group">
<label class="form-checkbox"> <label class="form-checkbox">
<input type="checkbox" name="loyalty_enabled" value="1" <input type="checkbox" name="loyalty_enabled" value="1"
<?= $loyaltyEnabled ? 'checked' : '' ?>> <?= $loyaltyEnabled ? 'checked' : '' ?>>
Enable loyalty program Enable loyalty program
</label> </label>
</div> </div>
<div style="background: var(--admin-bg); padding: 1.5rem; border-radius: var(--admin-radius); margin: 1rem 0;"> <div style="background: var(--admin-bg); padding: 1.5rem; border-radius: var(--admin-radius); margin: 1rem 0;">
<h4 style="margin: 0 0 1rem;">Tier Structure</h4> <h4 style="margin: 0 0 1rem;">Tier Structure</h4>
<table class="table" style="margin: 0;"> <table class="table" style="margin: 0;">
@@ -424,10 +394,10 @@ foreach ($allSettings as $s) {
</tbody> </tbody>
</table> </table>
<p class="text-muted" style="margin: 1rem 0 0; font-size: 0.875rem;"> <p class="text-muted" style="margin: 1rem 0 0; font-size: 0.875rem;">
100 points = $1 credit Points earned on every purchase 100 points = $1 credit &bull; Points earned on every purchase
</p> </p>
</div> </div>
<button type="submit" class="btn btn-primary"> <button type="submit" class="btn btn-primary">
<i class="fas fa-save"></i> Save Settings <i class="fas fa-save"></i> Save Settings
</button> </button>
@@ -463,7 +433,7 @@ foreach ($allSettings as $s) {
<script> <script>
let testType = ''; let testType = '';
function testSendGrid() { function testCyberMail() {
testType = 'email'; testType = 'email';
document.getElementById('testModalTitle').textContent = 'Send Test Email'; document.getElementById('testModalTitle').textContent = 'Send Test Email';
document.getElementById('testInputLabel').textContent = 'Recipient Email'; document.getElementById('testInputLabel').textContent = 'Recipient Email';
@@ -485,14 +455,14 @@ function testTwilio() {
document.getElementById('testForm').addEventListener('submit', async function(e) { document.getElementById('testForm').addEventListener('submit', async function(e) {
e.preventDefault(); e.preventDefault();
const recipient = document.getElementById('testRecipient').value; const recipient = document.getElementById('testRecipient').value;
const resultDiv = document.getElementById('testResult'); const resultDiv = document.getElementById('testResult');
const submitBtn = document.getElementById('testSubmitBtn'); const submitBtn = document.getElementById('testSubmitBtn');
submitBtn.disabled = true; submitBtn.disabled = true;
submitBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Sending...'; submitBtn.innerHTML = '<i class="fas fa-spinner fa-spin"></i> Sending...';
try { try {
const response = await fetch('/api/test-notification.php', { const response = await fetch('/api/test-notification.php', {
method: 'POST', method: 'POST',
@@ -500,7 +470,7 @@ document.getElementById('testForm').addEventListener('submit', async function(e)
body: JSON.stringify({ type: testType, recipient }) body: JSON.stringify({ type: testType, recipient })
}); });
const data = await response.json(); const data = await response.json();
resultDiv.style.display = 'block'; resultDiv.style.display = 'block';
if (data.success) { if (data.success) {
resultDiv.style.background = 'rgba(16, 185, 129, 0.1)'; resultDiv.style.background = 'rgba(16, 185, 129, 0.1)';