redirectToLogin('Session expired. Please log in again.'); } // Initialize database try { $db = new Database(); $pdo = $db->getConnection(); } catch (Exception $e) { logError('Database connection failed in dashboard.php: ' . $e->getMessage()); die('System error. Please try again later.'); } // Award onboarding points if not already awarded if (!$user['onboarding_points_awarded']) { try { $pdo->beginTransaction(); // Add onboarding points $stmt = $pdo->prepare("INSERT INTO user_points (user_id, points, total_earned) VALUES (?, 10.00, 10.00) ON DUPLICATE KEY UPDATE points = points + 10.00, total_earned = total_earned + 10.00"); $stmt->execute([$user['id']]); // Add transaction record $stmt = $pdo->prepare("INSERT INTO point_transactions (user_id, transaction_type, points, source, description) VALUES (?, 'earned', 10.00, 'onboarding', 'Welcome bonus for joining Relevant Reflex')"); $stmt->execute([$user['id']]); // Mark as awarded $stmt = $pdo->prepare("UPDATE users SET onboarding_points_awarded = 1 WHERE id = ?"); $stmt->execute([$user['id']]); $pdo->commit(); logError('Onboarding points awarded', ['user_id' => $user['id'], 'points' => 10]); // Refresh user data to reflect changes $user = getCurrentUser(); } catch (Exception $e) { $pdo->rollback(); logError('Error awarding onboarding points', ['user_id' => $user['id'], 'error' => $e->getMessage()]); } } // Get user points $userPoints = ['points' => 0, 'total_earned' => 0, 'total_redeemed' => 0]; try { $stmt = $pdo->prepare("SELECT points, total_earned, total_redeemed FROM user_points WHERE user_id = ?"); $stmt->execute([$user['id']]); $pointsData = $stmt->fetch(); if ($pointsData) { $userPoints = $pointsData; } } catch (Exception $e) { logError('Error fetching user points', ['user_id' => $user['id'], 'error' => $e->getMessage()]); } // Get profiler completion status $profilerSections = [ 'personal_background' => 'Personal Background', 'household_family' => 'Household & Family', 'shopping_lifestyle' => 'Shopping & Lifestyle', 'technology_digital' => 'Technology & Digital', 'travel_transportation' => 'Travel & Transportation', 'health_fitness' => 'Health & Fitness', 'entertainment_media' => 'Entertainment & Media', 'food_dining' => 'Food & Dining', 'financial_services' => 'Financial Services', 'communication_payments' => 'Communication & Payments' ]; $profilerCompletion = []; try { $stmt = $pdo->prepare("SELECT section, completion_percentage, is_completed, points_awarded FROM profiler_completion WHERE user_id = ?"); $stmt->execute([$user['id']]); while ($row = $stmt->fetch()) { $profilerCompletion[$row['section']] = $row; } } catch (Exception $e) { logError('Error fetching profiler completion', ['user_id' => $user['id'], 'error' => $e->getMessage()]); } // Get mobile verification status $mobileVerified = false; $mobileNumber = ''; try { $stmt = $pdo->prepare("SELECT mobile_number, is_verified FROM mobile_verifications WHERE user_id = ?"); $stmt->execute([$user['id']]); $mobileData = $stmt->fetch(); if ($mobileData) { $mobileVerified = $mobileData['is_verified']; $mobileNumber = $mobileData['mobile_number']; } } catch (Exception $e) { logError('Error fetching mobile verification', ['user_id' => $user['id'], 'error' => $e->getMessage()]); } // Get UPI ID from profiler $upiId = ''; try { $stmt = $pdo->prepare("SELECT response FROM user_profiler WHERE user_id = ? AND section = 'profile' AND question_id = 'upi_id'"); $stmt->execute([$user['id']]); $upiData = $stmt->fetch(); if ($upiData) { $upiId = json_decode($upiData['response'], true); } } catch (Exception $e) { logError('Error fetching UPI ID', ['user_id' => $user['id'], 'error' => $e->getMessage()]); } // Handle UPI ID update if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'update_upi') { $newUpiId = isset($_POST['upi_id']) ? sanitize($_POST['upi_id']) : ''; if (!empty($newUpiId) && preg_match('/^[\w\.-]+@[\w\.-]+$/', $newUpiId)) { try { $stmt = $pdo->prepare("INSERT INTO user_profiler (user_id, section, question_id, response) VALUES (?, 'profile', 'upi_id', ?) ON DUPLICATE KEY UPDATE response = ?, updated_at = NOW()"); $upiJson = json_encode($newUpiId); $stmt->execute([$user['id'], $upiJson, $upiJson]); $upiId = $newUpiId; $success_message = "UPI ID updated successfully!"; } catch (Exception $e) { logError('Error updating UPI ID', ['user_id' => $user['id'], 'error' => $e->getMessage()]); $error_message = "Error updating UPI ID. Please try again."; } } else { $error_message = "Please enter a valid UPI ID (e.g., yourname@paytm)."; } } // Get user's support tickets for the support section $userTickets = []; try { $stmt = $pdo->prepare(" SELECT st.*, (SELECT COUNT(*) FROM support_messages sm WHERE sm.ticket_id = st.id) as message_count, (SELECT sm.created_at FROM support_messages sm WHERE sm.ticket_id = st.id ORDER BY sm.created_at DESC LIMIT 1) as last_reply FROM support_tickets st WHERE st.user_id = ? ORDER BY st.created_at DESC LIMIT 10 "); $stmt->execute([$user['id']]); $userTickets = $stmt->fetchAll(); } catch (Exception $e) { logError('Error fetching user tickets', ['user_id' => $user['id'], 'error' => $e->getMessage()]); } // Get user's recent redemption requests $userRedemptions = []; try { $stmt = $pdo->prepare(" SELECT * FROM redemption_requests WHERE user_id = ? ORDER BY created_at DESC LIMIT 5 "); $stmt->execute([$user['id']]); $userRedemptions = $stmt->fetchAll(); } catch (Exception $e) { logError('Error fetching user redemptions', ['user_id' => $user['id'], 'error' => $e->getMessage()]); } // Calculate account age $joinDate = new DateTime($user['created_at']); $now = new DateTime(); $accountAge = $now->diff($joinDate); $joinDateFormatted = $joinDate->format('M Y'); ?> Dashboard - Relevant Reflex

Welcome to Your Survey Dashboard!

Complete your profile, earn points, and participate in paid surveys from trusted research companies.

Available Points

Value

0

Available Surveys

Complete your profile to unlock

$name) { if (isset($profilerCompletion[$key]) && $profilerCompletion[$key]['is_completed']) { $completedSections++; } } echo round(($completedSections / count($profilerSections)) * 100); ?>%

Profile Complete

/ sections

Total Earned

Since
Complete Your Profile

Earn up to 50 points by completing all profile sections

Redeem Rewards

Convert your points to cash rewards via UPI

Need Help?

Get support for any questions or issues

Available Surveys

Complete Your Profile First!

To receive targeted survey invitations, please complete all sections in the "Know Me Better" profiler. This helps us match you with relevant surveys that fit your demographics and interests.

Current Progress: / sections completed

Know Me Better Complete All Sections to Earn 50 Points!

Help us understand you better to send more relevant survey opportunities. Each completed section earns you 5 points!

Mobile Verification

Your mobile number is verified! Verify your mobile number to receive survey notifications and earn 10 points.

We'll send you an OTP to verify your number.
10 Points Earned!
$sectionName): $completion = isset($profilerCompletion[$sectionKey]) ? $profilerCompletion[$sectionKey] : null; $isCompleted = $completion && $completion['is_completed']; $percentage = $completion ? $completion['completion_percentage'] : 0; $pointsAwarded = $completion && $completion['points_awarded']; ?>
%
Completed 0): ?> In Progress Not Started
5 Points

Rewards & Points

Available Points

Current Value

Total Earned

Lifetime Earnings

Total Redeemed

Total Withdrawn
Redeem Points
= 200): ?>

You can redeem your points for cash via UPI transfer. Minimum redemption: 200 points (₹100)

Redeem Now
Minimum Redemption Required

You need at least 200 points (₹100) to redeem.

You currently have points. Need more points.

Recent Redemption Requests
Request #

points → ₹ to

Requested on

Profile Settings

Account Information
Email:
Gender:
Date of Birth:
Postcode:
Account Status: Active Verified
Mobile Verification
Mobile number +91 is verified!
Mobile number not verified yet.
Verify Mobile Number
UPI Payment Details

Add your UPI ID to receive reward payments directly to your account.

Example: yourname@paytm, yourname@phonepe, yourname@googlepay
Your UPI ID is saved and ready for payments!

Support Center

Create Ticket

Get help with account, points, or technical issues

Create New Ticket
How It Works

Learn about our survey panel and earning process

View Guide
Contact Us

Direct email support for urgent matters

Contact Form
Your Recent Support Tickets

You haven't created any support tickets yet.

Ticket # | messages

Created: | Last reply: