prepare(" SELECT ps.*, p.project_name, p.project_id as project_code, p.eloi, p.status as project_status FROM project_selections ps JOIN projects p ON ps.project_id = p.id WHERE ps.id = ? AND ps.client_id = ? "); $stmt->execute([$selection_id, $_SESSION['client_id']]); $selection = $stmt->fetch(); if (!$selection) { header('Location: projects-list.php'); exit; } // Get selection criteria $stmt = $pdo->prepare("SELECT * FROM selection_criteria WHERE selection_id = ? ORDER BY id"); $stmt->execute([$selection_id]); $criteria = $stmt->fetchAll(); // Get member count $stmt = $pdo->prepare("SELECT COUNT(*) FROM selection_members WHERE selection_id = ?"); $stmt->execute([$selection_id]); $member_count = $stmt->fetchColumn(); // Get assigned URL counts from survey_urls table $stmt = $pdo->prepare(" SELECT COUNT(*) FROM survey_urls WHERE assigned_to_selection_id = ? "); $stmt->execute([$selection_id]); $urls_assigned = (int)$stmt->fetchColumn(); // Total available URLs for the project $stmt = $pdo->prepare(" SELECT COUNT(*) FROM survey_urls WHERE project_id = (SELECT project_id FROM projects WHERE id = ?) AND status = 'available' "); $stmt->execute([$selection['project_id']]); $urls_available = (int)$stmt->fetchColumn(); $fully_assigned = ($member_count > 0 && $urls_assigned >= $member_count); $shortfall = max(0, $member_count - $urls_assigned); // Calculate default incentive: Rs.10 base for 5 min, +Rs.1 per min beyond $eloi = (int)($selection['eloi'] ?? 10); $default_incentive = max(10, 10 + max(0, $eloi - 5)); // URL status breakdown for tracking table $status_filter = $_GET['url_status'] ?? 'all'; $page = max(1, intval($_GET['page'] ?? 1)); $per_page = 25; $offset = ($page - 1) * $per_page; // Get status counts $stmt = $pdo->prepare(" SELECT status, COUNT(*) as cnt FROM survey_urls WHERE assigned_to_selection_id = ? GROUP BY status "); $stmt->execute([$selection_id]); $status_counts = $stmt->fetchAll(PDO::FETCH_KEY_PAIR); $total_urls = array_sum($status_counts); // Get paginated URLs $url_where = "assigned_to_selection_id = ?"; $url_params = [$selection_id]; if ($status_filter !== 'all') { $url_where .= " AND status = ?"; $url_params[] = $status_filter; } $stmt = $pdo->prepare("SELECT COUNT(*) FROM survey_urls WHERE $url_where"); $stmt->execute($url_params); $filtered_total = (int)$stmt->fetchColumn(); $total_pages = max(1, ceil($filtered_total / $per_page)); $stmt = $pdo->prepare(" SELECT su.*, sm.user_id FROM survey_urls su LEFT JOIN selection_members sm ON su.sent_to_user_id = sm.user_id AND sm.selection_id = su.assigned_to_selection_id WHERE su.$url_where ORDER BY su.id ASC LIMIT $per_page OFFSET $offset "); $stmt->execute($url_params); $url_rows = $stmt->fetchAll(); // Check if invitations already sent $invitations_sent = !empty($selection['invitations_sent_at']); $page_title = 'View Selection'; include 'client-portal-header.php'; ?>
Selection ID: | Project:
| # | Proxy URL | Status | User ID | Sent At | Clicked At |
|---|---|---|---|---|---|
No URLs yet.
No specific criteria applied