redirectToLogin('Session expired. Please log in again.'); } // Calculate user age $userAge = null; if ($user['date_of_birth']) { $birthDate = new DateTime($user['date_of_birth']); $today = new DateTime(); $userAge = $today->diff($birthDate)->y; } // Format join date $joinDateFormatted = date('F j, Y', strtotime($user['created_at'])); // 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.'); } // Check and award onboarding points (only once) if ($user['email_verified'] && !$user['onboarding_completed'] && !$user['onboarding_points_awarded']) { try { // Double-check to prevent race conditions $stmt = $pdo->prepare("SELECT onboarding_points_awarded FROM users WHERE id = ? AND onboarding_points_awarded = 0"); $stmt->execute([$user['id']]); $canAward = $stmt->fetch(); if ($canAward) { $pdo->beginTransaction(); // Award 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 email verification and first login')"); $stmt->execute([$user['id']]); // Mark onboarding as completed and points as awarded $stmt = $pdo->prepare("UPDATE users SET onboarding_completed = 1, 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 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 recent point transactions $recentTransactions = []; try { $stmt = $pdo->prepare(" SELECT transaction_type, points, source, description, created_at, status FROM point_transactions WHERE user_id = ? ORDER BY created_at DESC LIMIT 20 "); $stmt->execute([$user['id']]); $recentTransactions = $stmt->fetchAll(); } catch (Exception $e) { logError('Error fetching transactions', ['user_id' => $user['id'], 'error' => $e->getMessage()]); } // Get redemption requests $redemptionRequests = []; try { $stmt = $pdo->prepare(" SELECT request_id, points_redeemed, amount_inr, upi_id, status, created_at, processed_at FROM redemption_requests WHERE user_id = ? ORDER BY created_at DESC "); $stmt->execute([$user['id']]); $redemptionRequests = $stmt->fetchAll(); } catch (Exception $e) { logError('Error fetching redemption requests', ['user_id' => $user['id'], 'error' => $e->getMessage()]); } ?>
Complete your profile, earn points, and participate in paid surveys from trusted research companies.
Available Points
₹ ValueAvailable Surveys
Complete your profile to unlockProfile Complete
/ sectionsTotal Earned
SinceEarn up to 70 points by completing all profile sections
Convert your points to cash rewards via UPI
Get support for any questions or issues
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
Help us understand you better to send more relevant survey opportunities. Each completed section earns you 5 points!
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.Available Points
Total Earned
Total Redeemed
You can redeem your points for cash via UPI transfer. Minimum redemption: 200 points (₹100)
You need at least 200 points (₹100) to redeem. You currently have points.
Need more points to redeem.
No transactions yet. Complete your profile sections to start earning points!
No redemptions yet.
₹ ( points)
UPI:
Email:
Gender:
Date of Birth:
Age: years
Postcode:
Member Since:
Survey Panel Member
VerifiedYou haven't created any support tickets yet. If you need help, click "Create New Ticket" above.