prepare("SELECT affiliate_code FROM affiliates WHERE id = ?"); $stmt->execute([$delete_id]); $affiliate_code = $stmt->fetchColumn(); // Delete affiliate (cascade will delete attachments and signups) $stmt = $pdo->prepare("DELETE FROM affiliates WHERE id = ?"); $stmt->execute([$delete_id]); logActivity($_SESSION['admin_id'], 'delete_affiliate', "Deleted affiliate: $affiliate_code", 'affiliate', $delete_id); $success = 'Affiliate deleted successfully!'; } catch (Exception $e) { $error = 'An error occurred while deleting. Please try again.'; error_log("Delete affiliate error: " . $e->getMessage()); } } } } // Fetch all affiliates try { $pdo = getDBConnection(); $stmt = $pdo->query("SELECT * FROM affiliates ORDER BY created_at DESC"); $affiliates = $stmt->fetchAll(); } catch (Exception $e) { $affiliates = []; error_log("Fetch affiliates error: " . $e->getMessage()); } // Calculate statistics $total_affiliates = count($affiliates); $active_affiliates = count(array_filter($affiliates, fn($a) => $a['status'] === 'active')); $total_hits = array_sum(array_column($affiliates, 'total_signups')); // total_signups = total clicks/hits $verified_signups = array_sum(array_column($affiliates, 'total_verified_signups')); $company_affiliates = count(array_filter($affiliates, fn($a) => $a['type'] === 'company')); $individual_affiliates = count(array_filter($affiliates, fn($a) => $a['type'] === 'individual')); // Count not verified: registered (signup_completed=1) but email NOT verified $not_verified_count = 0; try { $stmt = $pdo->query(" SELECT COUNT(*) FROM affiliate_signups WHERE signup_completed = 1 AND email_verified = 0 "); $not_verified_count = (int)$stmt->fetchColumn(); } catch (Exception $e) { error_log("Not verified count error: " . $e->getMessage()); } include 'includes/header.php'; ?>
Total Affiliates
Active Affiliates
Total Hits
Not Verified
Verified Signups
Companies
Individuals
ID Affiliate Code Company/Name Type In-charge Location Contact Hits Verified Status Actions
No affiliates found. Click "Add New Affiliate" to create one.
#
-
👁