prepare(" SELECT u.*, up.points as current_points, up.total_earned, up.total_redeemed, mv.mobile_number, mv.is_verified as mobile_verified, mv.verified_at as mobile_verified_at FROM users u LEFT JOIN user_points up ON u.id = up.user_id LEFT JOIN mobile_verifications mv ON u.id = mv.user_id WHERE u.id = ? "); $stmt->execute([$member_id]); $member = $stmt->fetch(); if (!$member) { header('Location: panel.php'); exit; } // Fetch profiler completion $completionStmt = $panelPdo->prepare(" SELECT * FROM profiler_completion WHERE user_id = ? "); $completionStmt->execute([$member_id]); $completionData = $completionStmt->fetchAll(); // Fetch actual profiler responses for this member $profilerResponses = []; try { $respStmt = $panelPdo->prepare("SELECT section, question_id, response FROM user_profiler WHERE user_id = ? ORDER BY section, question_id"); $respStmt->execute([$member_id]); while ($row = $respStmt->fetch()) { if (!isset($profilerResponses[$row['section']])) $profilerResponses[$row['section']] = []; $profilerResponses[$row['section']][$row['question_id']] = json_decode($row['response'], true); } } catch (Exception $e) { $profilerResponses = []; } // Extract PAN & UPI details from profile section $memberPanNumber = $profilerResponses['profile']['pan_number'] ?? ''; $memberPanName = $profilerResponses['profile']['pan_name'] ?? ''; $memberPanStatus = $profilerResponses['profile']['pan_status'] ?? ''; if (!empty($memberPanNumber) && empty($memberPanStatus)) $memberPanStatus = 'pending'; $memberUpiId = $profilerResponses['profile']['upi_id'] ?? ''; // Profiler question definitions for human-readable labels $profilerDefs = [ 'personal_background' => [ 'name' => 'Personal Background', 'questions' => [ 'education_level' => ['q'=>'Highest level of education','opts'=>['below_10th'=>'Below 10th Standard','10th_pass'=>'10th Standard','12th_pass'=>'12th Standard/Intermediate','diploma'=>'Diploma/ITI','graduation'=>'Graduation','post_graduation'=>'Post Graduation','professional'=>'Professional Degree','doctorate'=>'Doctorate/PhD']], 'employment_status' => ['q'=>'Current employment status','opts'=>['student'=>'Student','employed_private'=>'Employed - Private Sector','employed_government'=>'Employed - Government/Public Sector','self_employed'=>'Self Employed/Business Owner','freelancer'=>'Freelancer/Consultant','homemaker'=>'Homemaker','retired'=>'Retired','unemployed'=>'Currently Unemployed']], 'occupation_sector' => ['q'=>'Work sector','opts'=>['it_software'=>'IT/Software','banking_finance'=>'Banking & Finance','healthcare'=>'Healthcare','education'=>'Education','manufacturing'=>'Manufacturing','retail'=>'Retail','media'=>'Media & Entertainment','government'=>'Government','telecom'=>'Telecommunications','fmcg'=>'FMCG','auto'=>'Automotive','real_estate'=>'Real Estate','agriculture'=>'Agriculture','legal'=>'Legal','other'=>'Other']], 'monthly_income' => ['q'=>'Monthly household income range','opts'=>['below_15000'=>'Below ₹15,000','15000_25000'=>'₹15,000 - ₹25,000','25000_50000'=>'₹25,000 - ₹50,000','50000_75000'=>'₹50,000 - ₹75,000','75000_100000'=>'₹75,000 - ₹1,00,000','100000_200000'=>'₹1,00,000 - ₹2,00,000','200000_500000'=>'₹2,00,000 - ₹5,00,000','above_500000'=>'Above ₹5,00,000','prefer_not_to_say'=>'Prefer not to say']], 'marital_status' => ['q'=>'Marital status','opts'=>['single'=>'Single','married'=>'Married','divorced'=>'Divorced','widowed'=>'Widowed','separated'=>'Separated','live_in'=>'Live-in Relationship']], 'language_primary' => ['q'=>'Primary language spoken at home','opts'=>['hindi'=>'Hindi','english'=>'English','tamil'=>'Tamil','telugu'=>'Telugu','marathi'=>'Marathi','bengali'=>'Bengali','gujarati'=>'Gujarati','kannada'=>'Kannada','malayalam'=>'Malayalam','punjabi'=>'Punjabi','odia'=>'Odia','urdu'=>'Urdu','assamese'=>'Assamese','other'=>'Other']], 'languages_known' => ['q'=>'Languages you can read/write fluently','opts'=>['hindi'=>'Hindi','english'=>'English','tamil'=>'Tamil','telugu'=>'Telugu','marathi'=>'Marathi','bengali'=>'Bengali','gujarati'=>'Gujarati','kannada'=>'Kannada','malayalam'=>'Malayalam','punjabi'=>'Punjabi','odia'=>'Odia','urdu'=>'Urdu','assamese'=>'Assamese','other'=>'Other']], 'area_type' => ['q'=>'Area type','opts'=>['metro'=>'Metro City','tier1'=>'Tier 1 City','tier2'=>'Tier 2 City','tier3'=>'Tier 3/Small Town','semi_urban'=>'Semi-Urban','rural'=>'Rural/Village']], ] ], 'household_family' => [ 'name' => 'Household & Family', 'questions' => [ 'household_size' => ['q'=>'People living in household','opts'=>['1'=>'Just me','2'=>'2 people','3'=>'3 people','4'=>'4 people','5'=>'5 people','6_plus'=>'6 or more']], 'children_count' => ['q'=>'Number of children','opts'=>['none'=>'No children','1'=>'1 child','2'=>'2 children','3'=>'3 children','4_plus'=>'4 or more']], 'children_age_group' => ['q'=>'Age groups of children','opts'=>['infant'=>'0-2 years (Infant)','toddler'=>'3-5 years (Toddler)','child'=>'6-12 years (Child)','teen'=>'13-17 years (Teen)','adult'=>'18+ years (Adult)','not_applicable'=>'Not Applicable']], 'home_ownership' => ['q'=>'Home ownership status','opts'=>['own_house'=>'Own House','rented'=>'Rented','family_owned'=>'Family Owned','company_provided'=>'Company Provided','paying_guest'=>'Paying Guest/Hostel']], 'vehicle_ownership' => ['q'=>'Vehicles owned','opts'=>['two_wheeler'=>'Two Wheeler (Bike/Scooter)','car_hatchback'=>'Car - Hatchback','car_sedan'=>'Car - Sedan','car_suv'=>'Car - SUV/MUV','ev_two_wheeler'=>'EV Two Wheeler','ev_car'=>'Electric Car','bicycle'=>'Bicycle','none'=>'No Vehicle','commercial'=>'Commercial Vehicle']], 'domestic_help' => ['q'=>'Domestic help employed','opts'=>['full_time'=>'Full-time','part_time'=>'Part-time','cook'=>'Cook only','driver'=>'Driver','none'=>'No domestic help']], 'decision_maker' => ['q'=>'Primary decision maker for purchases','opts'=>['self'=>'Self','spouse'=>'Spouse/Partner','parents'=>'Parents','joint'=>'Joint Decision','other'=>'Other Family Member']], 'pet_ownership' => ['q'=>'Pets owned','opts'=>['dog'=>'Dog','cat'=>'Cat','bird'=>'Bird','fish'=>'Fish','other_pet'=>'Other','no_pets'=>'No Pets']], ] ], 'shopping_lifestyle' => [ 'name' => 'Shopping & Lifestyle', 'questions' => [ 'online_shopping_frequency' => ['q'=>'Online shopping frequency','opts'=>['daily'=>'Almost daily','weekly'=>'Weekly','biweekly'=>'Every 2 weeks','monthly'=>'Monthly','quarterly'=>'Every few months','rarely'=>'Rarely','never'=>'Never']], 'preferred_ecommerce' => ['q'=>'Preferred e-commerce platforms','opts'=>['amazon'=>'Amazon','flipkart'=>'Flipkart','myntra'=>'Myntra','meesho'=>'Meesho','ajio'=>'AJIO','nykaa'=>'Nykaa','tatacliq'=>'Tata CLiQ','jiomart'=>'JioMart','snapdeal'=>'Snapdeal','bigbasket'=>'BigBasket','other'=>'Other']], 'monthly_online_spend' => ['q'=>'Monthly online shopping spend','opts'=>['below_500'=>'Below ₹500','500_2000'=>'₹500 - ₹2,000','2000_5000'=>'₹2,000 - ₹5,000','5000_10000'=>'₹5,000 - ₹10,000','10000_25000'=>'₹10,000 - ₹25,000','above_25000'=>'Above ₹25,000']], 'shopping_categories' => ['q'=>'Frequently purchased categories','opts'=>['electronics'=>'Electronics & Gadgets','fashion'=>'Fashion & Clothing','beauty'=>'Beauty & Personal Care','home_kitchen'=>'Home & Kitchen','grocery'=>'Groceries & Essentials','books'=>'Books & Stationery','sports'=>'Sports & Fitness','baby'=>'Baby & Kids','health'=>'Health & Wellness','jewelry'=>'Jewelry & Accessories','automotive'=>'Automotive Accessories']], 'brand_preference' => ['q'=>'Brand preference','opts'=>['premium'=>'Prefer premium brands','mid_range'=>'Prefer mid-range brands','value'=>'Prefer value/budget brands','no_preference'=>'No brand preference','mix'=>'Mix of all']], 'deal_influence' => ['q'=>'Influence of deals on purchases','opts'=>['always'=>'Always wait for deals','often'=>'Often look for deals','sometimes'=>'Sometimes check','rarely'=>'Rarely care about deals','never'=>'Never influenced by deals']], ] ], 'technology_digital' => [ 'name' => 'Technology & Digital', 'questions' => [ 'smartphone_brand' => ['q'=>'Current smartphone brand','opts'=>['samsung'=>'Samsung','apple'=>'Apple','xiaomi'=>'Xiaomi/Redmi','realme'=>'Realme','oppo'=>'OPPO','vivo'=>'Vivo','oneplus'=>'OnePlus','nothing'=>'Nothing','google'=>'Google Pixel','motorola'=>'Motorola','other'=>'Other']], 'smartphone_price' => ['q'=>'Smartphone price range','opts'=>['below_10000'=>'Below ₹10,000','10000_15000'=>'₹10,000 - ₹15,000','15000_25000'=>'₹15,000 - ₹25,000','25000_40000'=>'₹25,000 - ₹40,000','40000_60000'=>'₹40,000 - ₹60,000','above_60000'=>'Above ₹60,000']], 'internet_provider' => ['q'=>'Primary internet provider','opts'=>['jio'=>'Jio','airtel'=>'Airtel','vi'=>'Vi (Vodafone Idea)','bsnl'=>'BSNL','act'=>'ACT Fibernet','tataplay'=>'Tata Play Fiber','local_isp'=>'Local ISP','other'=>'Other']], 'daily_internet_hours' => ['q'=>'Daily internet usage hours','opts'=>['less_1'=>'Less than 1 hour','1_3'=>'1-3 hours','3_5'=>'3-5 hours','5_8'=>'5-8 hours','above_8'=>'More than 8 hours']], 'social_media_usage' => ['q'=>'Social media platforms used regularly','opts'=>['whatsapp'=>'WhatsApp','instagram'=>'Instagram','facebook'=>'Facebook','youtube'=>'YouTube','twitter'=>'Twitter/X','linkedin'=>'LinkedIn','snapchat'=>'Snapchat','telegram'=>'Telegram','koo'=>'Koo','pinterest'=>'Pinterest','reddit'=>'Reddit','threads'=>'Threads']], 'smart_devices' => ['q'=>'Smart devices owned','opts'=>['smart_tv'=>'Smart TV','smart_watch'=>'Smartwatch/Band','smart_speaker'=>'Smart Speaker','tablet'=>'Tablet/iPad','laptop'=>'Laptop','desktop'=>'Desktop PC','gaming_console'=>'Gaming Console','smart_home'=>'Smart Home Devices','none'=>'None of these']], 'streaming_services' => ['q'=>'Streaming services subscribed to','opts'=>['netflix'=>'Netflix','prime_video'=>'Amazon Prime Video','hotstar'=>'Disney+ Hotstar','sonyliv'=>'SonyLIV','zee5'=>'ZEE5','jiocinema'=>'JioCinema','youtube_premium'=>'YouTube Premium','spotify'=>'Spotify','apple_music'=>'Apple Music','none'=>'None']], ] ], 'travel_transportation' => [ 'name' => 'Travel & Transportation', 'questions' => [ 'daily_commute' => ['q'=>'Primary daily commute mode','opts'=>['own_car'=>'Own Car','own_bike'=>'Own Bike/Scooter','public_bus'=>'Public Bus','metro_train'=>'Metro/Local Train','auto_rickshaw'=>'Auto Rickshaw','cab_ola_uber'=>'Cab (Ola/Uber)','bicycle'=>'Bicycle','walk'=>'Walk','work_from_home'=>'Work from Home']], 'travel_frequency' => ['q'=>'Domestic travel frequency (per year)','opts'=>['never'=>'Rarely/Never','1_2'=>'1-2 times','3_5'=>'3-5 times','6_10'=>'6-10 times','above_10'=>'More than 10 times']], 'international_travel' => ['q'=>'International travel experience','opts'=>['never'=>'Never traveled abroad','once'=>'Once','2_5'=>'2-5 times','6_plus'=>'More than 5 times','frequent'=>'Frequent international traveler']], 'travel_booking' => ['q'=>'Travel booking platforms used','opts'=>['makemytrip'=>'MakeMyTrip','goibibo'=>'Goibibo','irctc'=>'IRCTC','booking_com'=>'Booking.com','cleartrip'=>'Cleartrip','yatra'=>'Yatra','airbnb'=>'Airbnb','oyo'=>'OYO','travel_agent'=>'Travel Agent','direct'=>'Direct with airline/hotel']], 'travel_preference' => ['q'=>'Travel accommodation preference','opts'=>['budget'=>'Budget Hotels','mid_range'=>'Mid-range Hotels','luxury'=>'Luxury Hotels','homestay'=>'Homestays','hostel'=>'Hostels/Backpacker','resort'=>'Resorts','relative'=>"Relative's/Friend's place"]], 'cab_usage' => ['q'=>'Ride-hailing usage frequency','opts'=>['daily'=>'Daily','weekly'=>'Few times a week','monthly'=>'Few times a month','rarely'=>'Rarely','never'=>'Never use']], ] ], 'health_fitness' => [ 'name' => 'Health & Fitness', 'questions' => [ 'exercise_frequency' => ['q'=>'Exercise frequency','opts'=>['daily'=>'Daily','4_6'=>'4-6 times a week','2_3'=>'2-3 times a week','once_week'=>'Once a week','rarely'=>'Rarely','never'=>'Never']], 'fitness_activities' => ['q'=>'Fitness activities','opts'=>['gym'=>'Gym/Weight Training','yoga'=>'Yoga','running'=>'Running/Jogging','walking'=>'Walking','swimming'=>'Swimming','cycling'=>'Cycling','sports'=>'Sports','dance'=>'Dance/Zumba','home_workout'=>'Home Workout','martial_arts'=>'Martial Arts','none'=>'None']], 'health_insurance' => ['q'=>'Health insurance coverage','opts'=>['employer'=>'Employer-provided','individual'=>'Individual Policy','family_floater'=>'Family Floater','government'=>'Government Scheme','no_insurance'=>'No Health Insurance']], 'diet_type' => ['q'=>'Dietary preference','opts'=>['vegetarian'=>'Vegetarian','non_vegetarian'=>'Non-Vegetarian','eggetarian'=>'Eggetarian','vegan'=>'Vegan','jain'=>'Jain','flexitarian'=>'Flexitarian']], 'health_conditions' => ['q'=>'Health conditions managed','opts'=>['diabetes'=>'Diabetes','hypertension'=>'Hypertension/BP','thyroid'=>'Thyroid','heart'=>'Heart Condition','asthma'=>'Asthma/Respiratory','allergies'=>'Allergies','obesity'=>'Obesity','none'=>'None','prefer_not'=>'Prefer not to say']], 'wellness_spend' => ['q'=>'Monthly health/wellness spend','opts'=>['below_500'=>'Below ₹500','500_2000'=>'₹500 - ₹2,000','2000_5000'=>'₹2,000 - ₹5,000','5000_10000'=>'₹5,000 - ₹10,000','above_10000'=>'Above ₹10,000']], 'health_tracking' => ['q'=>'Health/fitness tracking tools used','opts'=>['fitness_band'=>'Fitness Band/Smartwatch','phone_app'=>'Phone App','manual'=>'Manual Tracking','health_checkup'=>'Regular Health Checkups','none'=>'None']], ] ], 'entertainment_media' => [ 'name' => 'Entertainment & Media', 'questions' => [ 'content_language' => ['q'=>'Content consumption languages','opts'=>['hindi'=>'Hindi','english'=>'English','tamil'=>'Tamil','telugu'=>'Telugu','malayalam'=>'Malayalam','kannada'=>'Kannada','bengali'=>'Bengali','marathi'=>'Marathi','punjabi'=>'Punjabi','other'=>'Other']], 'entertainment_preference' => ['q'=>'Entertainment preferences','opts'=>['movies'=>'Movies','web_series'=>'Web Series','tv_shows'=>'TV Shows','music'=>'Music','podcasts'=>'Podcasts','gaming'=>'Gaming','reading'=>'Reading/Books','live_events'=>'Live Events/Concerts','sports_viewing'=>'Watching Sports']], 'news_source' => ['q'=>'Primary news sources','opts'=>['tv_news'=>'TV News Channels','newspaper'=>'Newspaper','news_apps'=>'News Apps','social_media'=>'Social Media','youtube'=>'YouTube','radio'=>'Radio','word_of_mouth'=>'Word of Mouth']], 'gaming_platform' => ['q'=>'Gaming platforms used','opts'=>['mobile'=>'Mobile Gaming','pc'=>'PC Gaming','playstation'=>'PlayStation','xbox'=>'Xbox','nintendo'=>'Nintendo','no_gaming'=>'Do not play games']], 'music_preference' => ['q'=>'Music listening platforms','opts'=>['spotify'=>'Spotify','youtube_music'=>'YouTube Music','jiosaavn'=>'JioSaavn','gaana'=>'Gaana','apple_music'=>'Apple Music','wynk'=>'Wynk','amazon_music'=>'Amazon Music','radio'=>'FM Radio','none'=>'None']], 'cinema_frequency' => ['q'=>'Movie theatre visits per month','opts'=>['never'=>'Never','once'=>'Once a month','2_3'=>'2-3 times a month','weekly'=>'Weekly','more'=>'More than weekly']], ] ], 'food_dining' => [ 'name' => 'Food & Dining', 'questions' => [ 'dining_out_frequency' => ['q'=>'Dining out/ordering frequency','opts'=>['daily'=>'Almost Daily','3_5_week'=>'3-5 times a week','1_2_week'=>'1-2 times a week','few_month'=>'Few times a month','rarely'=>'Rarely','never'=>'Never']], 'food_delivery_apps' => ['q'=>'Food delivery apps used','opts'=>['zomato'=>'Zomato','swiggy'=>'Swiggy','eatsure'=>'EatSure','dominos'=>'Domino\'s App','mcdonalds'=>'McDonald\'s App','other'=>'Other App','none'=>'Don\'t use delivery apps']], 'cuisine_preference' => ['q'=>'Favourite cuisines','opts'=>['north_indian'=>'North Indian','south_indian'=>'South Indian','chinese'=>'Chinese/Indo-Chinese','italian'=>'Italian/Pizza/Pasta','mughlai'=>'Mughlai/Biryani','street_food'=>'Street Food','continental'=>'Continental','japanese'=>'Japanese/Sushi','thai'=>'Thai','fast_food'=>'Fast Food/Burgers','healthy'=>'Healthy/Salads']], 'cooking_frequency' => ['q'=>'Home cooking frequency','opts'=>['all_meals'=>'All meals at home','mostly'=>'Most meals at home','half'=>'About half','rarely'=>'Rarely cook','never'=>'Never cook']], 'monthly_food_spend' => ['q'=>'Monthly food/dining spend','opts'=>['below_2000'=>'Below ₹2,000','2000_5000'=>'₹2,000 - ₹5,000','5000_10000'=>'₹5,000 - ₹10,000','10000_20000'=>'₹10,000 - ₹20,000','above_20000'=>'Above ₹20,000']], 'beverage_preference' => ['q'=>'Daily beverages','opts'=>['tea'=>'Tea (Chai)','coffee'=>'Coffee','green_tea'=>'Green Tea','juice'=>'Fresh Juice','soft_drinks'=>'Soft Drinks/Cola','energy_drinks'=>'Energy Drinks','water_only'=>'Plain Water Only','milk'=>'Milk/Flavored Milk','alcohol'=>'Alcoholic Beverages']], ] ], 'financial_services' => [ 'name' => 'Financial Services', 'questions' => [ 'bank_account' => ['q'=>'Primary bank','opts'=>['sbi'=>'SBI','hdfc'=>'HDFC Bank','icici'=>'ICICI Bank','axis'=>'Axis Bank','kotak'=>'Kotak Mahindra','pnb'=>'PNB','bob'=>'Bank of Baroda','idfc'=>'IDFC First','yes'=>'Yes Bank','indusind'=>'IndusInd','other_private'=>'Other Private Bank','other_psu'=>'Other PSU Bank','payment_bank'=>'Payment Bank (Paytm/Airtel)']], 'credit_card' => ['q'=>'Credit card ownership','opts'=>['yes_multiple'=>'Yes, multiple cards','yes_one'=>'Yes, one card','no_debit'=>'No, use debit card only','no_card'=>'No cards']], 'credit_products' => ['q'=>'Credit products used','opts'=>['credit_card'=>'Credit card','personal_loan'=>'Personal loan','home_loan'=>'Home loan','car_loan'=>'Car loan','education_loan'=>'Education loan','bnpl'=>'Buy Now Pay Later','gold_loan'=>'Gold loan','none'=>'None']], 'investment_types' => ['q'=>'Investment instruments used','opts'=>['fd'=>'Fixed Deposits','mutual_funds'=>'Mutual Funds','stocks'=>'Direct Stocks','ppf'=>'PPF/EPF','gold'=>'Gold/Gold Bonds','real_estate'=>'Real Estate','nps'=>'NPS','crypto'=>'Cryptocurrency','insurance'=>'Insurance Plans','none'=>'None']], 'upi_usage' => ['q'=>'UPI/Digital payment usage','opts'=>['primary'=>'Primary payment method','frequent'=>'Frequently use','sometimes'=>'Sometimes use','rarely'=>'Rarely use','never'=>'Never use']], 'upi_apps' => ['q'=>'UPI apps used','opts'=>['gpay'=>'Google Pay','phonepe'=>'PhonePe','paytm'=>'Paytm','amazon_pay'=>'Amazon Pay','bhim'=>'BHIM','cred'=>'CRED','whatsapp_pay'=>'WhatsApp Pay','bank_app'=>'Bank\'s own app','other'=>'Other']], ] ], 'communication_payments' => [ 'name' => 'Communication & Payments', 'questions' => [ 'mobile_operator' => ['q'=>'Primary mobile operator','opts'=>['jio'=>'Jio','airtel'=>'Airtel','vi'=>'Vi (Vodafone Idea)','bsnl'=>'BSNL','mtnl'=>'MTNL','other'=>'Other']], 'mobile_plan_spend' => ['q'=>'Monthly mobile plan spend','opts'=>['below_200'=>'Below ₹200','200_500'=>'₹200 - ₹500','500_1000'=>'₹500 - ₹1,000','1000_2000'=>'₹1,000 - ₹2,000','above_2000'=>'Above ₹2,000']], 'sim_type' => ['q'=>'SIM type','opts'=>['prepaid'=>'Prepaid','postpaid'=>'Postpaid','both'=>'Both']], 'communication_apps' => ['q'=>'Communication apps used daily','opts'=>['whatsapp'=>'WhatsApp','telegram'=>'Telegram','signal'=>'Signal','messenger'=>'Facebook Messenger','teams'=>'Microsoft Teams','zoom'=>'Zoom','google_meet'=>'Google Meet','discord'=>'Discord','slack'=>'Slack']], 'digital_wallet_balance' => ['q'=>'Average digital wallet balance maintained','opts'=>['below_500'=>'Below ₹500','500_2000'=>'₹500 - ₹2,000','2000_5000'=>'₹2,000 - ₹5,000','above_5000'=>'Above ₹5,000','dont_maintain'=>'Don\'t maintain balance']], 'online_purchase_category' => ['q'=>'Categories of online purchases in last 3 months','opts'=>['electronics'=>'Electronics','fashion'=>'Fashion & Clothing','grocery'=>'Groceries','food_delivery'=>'Food Delivery','travel'=>'Travel/Booking','entertainment'=>'Entertainment/Subscriptions','education'=>'Education/Courses','health'=>'Health/Pharmacy','financial'=>'Financial/Insurance','products'=>'Product reviews and feedback','none'=>'None of these']], ] ] ]; // Fetch point transactions $transactionsStmt = $panelPdo->prepare(" SELECT * FROM point_transactions WHERE user_id = ? ORDER BY created_at DESC LIMIT 50 "); $transactionsStmt->execute([$member_id]); $transactions = $transactionsStmt->fetchAll(); // Fetch redemption requests $redemptionsStmt = $panelPdo->prepare(" SELECT * FROM redemption_requests WHERE user_id = ? ORDER BY created_at DESC "); $redemptionsStmt->execute([$member_id]); $redemptions = $redemptionsStmt->fetchAll(); // Fetch support tickets $ticketsStmt = $panelPdo->prepare(" SELECT * FROM support_tickets WHERE user_id = ? ORDER BY created_at DESC LIMIT 10 "); $ticketsStmt->execute([$member_id]); $tickets = $ticketsStmt->fetchAll(); // Fetch survey data for this member from admin DB $adminPdo = getDBConnection(); // 1. Selected: in selection_members but NO survey URL assigned for that project $selectedStmt = $adminPdo->prepare(" SELECT sm.selection_id, sm.sample_status, sm.assigned_at, ps.selection_name, ps.status as selection_status, ps.incentive_amount, ps.reward_per_complete, p.project_id, p.project_name, p.status as project_status, p.eloi, c.company_name as client_name FROM selection_members sm JOIN project_selections ps ON sm.selection_id = ps.id JOIN projects p ON ps.project_id = p.id JOIN clients c ON ps.client_id = c.id LEFT JOIN survey_urls su ON su.sent_to_user_id = sm.user_id AND su.project_id = p.project_id WHERE sm.user_id = ? AND su.id IS NULL ORDER BY sm.assigned_at DESC "); $selectedStmt->execute([$member_id]); $selectedSurveys = $selectedStmt->fetchAll(); // 2. Assigned: URL assigned but NOT yet sent (is_sent=0 and status='assigned') $assignedStmt = $adminPdo->prepare(" SELECT su.id as url_id, su.unique_identifier, su.status as url_status, su.created_at as url_created, ps.selection_name, ps.status as selection_status, p.project_id, p.project_name, p.status as project_status, p.eloi, c.company_name as client_name FROM survey_urls su JOIN projects p ON su.project_id = p.project_id JOIN clients c ON p.client_id = c.id LEFT JOIN project_selections ps ON su.assigned_to_selection_id = ps.id WHERE su.sent_to_user_id = ? AND su.is_sent = 0 AND su.status = 'assigned' ORDER BY su.created_at DESC "); $assignedStmt->execute([$member_id]); $assignedSurveys = $assignedStmt->fetchAll(); // 3. Sent: URL was sent (is_sent=1) but member has NOT interacted (no click/terminal status) $sentStmt = $adminPdo->prepare(" SELECT su.id as url_id, su.unique_identifier, su.status as url_status, su.sent_at, ps.selection_name, ps.status as selection_status, p.project_id, p.project_name, p.status as project_status, p.eloi, c.company_name as client_name FROM survey_urls su JOIN projects p ON su.project_id = p.project_id JOIN clients c ON p.client_id = c.id LEFT JOIN project_selections ps ON su.assigned_to_selection_id = ps.id WHERE su.sent_to_user_id = ? AND su.is_sent = 1 AND su.status NOT IN ('clicked','complete','partial','earlyscreenout','latescreenout','quotafull','timeout') ORDER BY su.sent_at DESC "); $sentStmt->execute([$member_id]); $sentSurveys = $sentStmt->fetchAll(); // 4. Taken: member actually interacted (clicked or has a terminal survey status) // Differentiate: "From Mail" (is_sent=1) vs "From Portal" (is_sent=0, took via Take Survey button) $takenStmt = $adminPdo->prepare(" SELECT su.id as url_id, su.unique_identifier, su.status as url_status, su.is_sent, su.clicked_at, su.completed_at, su.actual_loi_seconds, su.quality_flag, su.quality_notes, CASE WHEN su.is_sent = 1 THEN 'mail' ELSE 'portal' END as taken_source, ps.selection_name, ps.status as selection_status, ps.reward_per_complete, p.project_id, p.project_name, p.status as project_status, p.eloi, c.company_name as client_name FROM survey_urls su JOIN projects p ON su.project_id = p.project_id JOIN clients c ON p.client_id = c.id LEFT JOIN project_selections ps ON su.assigned_to_selection_id = ps.id WHERE su.sent_to_user_id = ? AND su.status IN ('clicked','complete','partial','earlyscreenout','latescreenout','quotafull','timeout') ORDER BY su.clicked_at DESC "); $takenStmt->execute([$member_id]); $takenSurveys = $takenStmt->fetchAll(); // Build taken status breakdown $takenByStatus = []; $takenBySource = ['mail' => 0, 'portal' => 0]; foreach ($takenSurveys as $t) { $s = $t['url_status']; if (!isset($takenByStatus[$s])) $takenByStatus[$s] = []; $takenByStatus[$s][] = $t; $takenBySource[$t['taken_source']]++; } } catch (Exception $e) { error_log("Member view error: " . $e->getMessage()); header('Location: panel.php'); exit; } include 'includes/header.php'; ?>
💰
Current Points
Available Balance
📈
Total Earned
Lifetime Earnings
💳
Total Redeemed
Lifetime Redemptions
Account Status

Basic Information

📧 Email Address
✓ Verified ✗ Not Verified
👤 Gender
🎂 Date of Birth
diff($dob)->y; echo $dob->format('F j, Y'); ?>
years old
📍 Postcode
📱 Mobile Number
✓ Verified
🔒 Account Status
✅ Email Verified
✓ Yes' : '✗ No'; ?>
🎯 Onboarding Status
✓ Completed ⏳ Pending
📅 Member Since
💐 Last Login

Payment & Tax Details

💳 UPI ID
Not provided'; ?>
📄 PAN Number
Not provided'; ?>
✓ Approved ✗ Rejected ⏳ Pending
👤 Name on PAN
Not provided'; ?>
⚙ PAN Verification

Survey Participation

Selected
In selection, no URL yet
Assigned
URL assigned, not mailed
Sent
Mailed, not yet taken
Taken
Clicked / has result
Taken — Source
📨 From Mail: 💻 From Portal:
Taken — Status Breakdown
'#059669','clicked'=>'#3b82f6','partial'=>'#f59e0b', 'earlyscreenout'=>'#ef4444','latescreenout'=>'#dc2626', 'quotafull'=>'#8b5cf6','timeout'=>'#6b7280' ]; $statusLabels = [ 'complete'=>'Complete','clicked'=>'Clicked','partial'=>'Partial', 'earlyscreenout'=>'Early Screen Out','latescreenout'=>'Late Screen Out', 'quotafull'=>'Quota Full','timeout'=>'Timeout' ]; foreach ($takenByStatus as $st => $items): $clr = $statusColors[$st] ?? '#6b7280'; $lbl = $statusLabels[$st] ?? ucfirst($st); ?> :
$items): $lbl = $statusLabels[$st] ?? ucfirst($st); ?>
📊
This member has no survey participation history yet.

Profiler Completion & Responses

$data) { if (!isset($allSections[$sec])) $allSections[$sec] = ['section'=>$sec,'completion_percentage'=>0,'answered_questions'=>0,'total_questions'=>count($data),'is_completed'=>0,'completed_at'=>null]; } ?> $completion): ?>
%
of questions answered • Completed on
📋
No profiler data available

Points Transaction History

💎
No transaction history available

Redemption Requests

Request ID Points Amount (₹) UPI ID Status Requested Processed
Pending'; ?>
🎁
No redemption requests found

Support Tickets

#
Created:
🎫
No support tickets found