0, 'base_incentive' => 0, 'incr_sample' => 0, 'incr_incentive' => 0, 'usd_factor' => 0, 'eur_factor' => 0, ]; try { $pdo = getClientDBConnection(); $stmt = $pdo->prepare("SELECT currency FROM clients WHERE id = ?"); $stmt->execute([$client_id]); $currency_row = $stmt->fetch(); if ($currency_row && !empty($currency_row['currency'])) { $client_currency = $currency_row['currency']; } $currency_map = [ 'INR' => ['symbol' => '₹', 'label' => 'Indian Rupee'], 'USD' => ['symbol' => '$', 'label' => 'US Dollar'], 'EUR' => ['symbol' => '€', 'label' => 'Euro'], ]; if (isset($currency_map[$client_currency])) { $currency_symbol = $currency_map[$client_currency]['symbol']; $currency_label = $currency_map[$client_currency]['label']; } $stmt = $pdo->query("SELECT setting_key, setting_value FROM company_settings WHERE setting_key LIKE 'pricing_%'"); while ($row = $stmt->fetch()) { switch ($row['setting_key']) { case 'pricing_base_sample_cost': $pricing['base_sample'] = (float)$row['setting_value']; break; case 'pricing_base_incentive': $pricing['base_incentive'] = (float)$row['setting_value']; break; case 'pricing_loi_increment_sample': $pricing['incr_sample'] = (float)$row['setting_value']; break; case 'pricing_loi_increment_incentive': $pricing['incr_incentive'] = (float)$row['setting_value']; break; case 'pricing_usd_factor': $pricing['usd_factor'] = (float)$row['setting_value']; break; case 'pricing_eur_factor': $pricing['eur_factor'] = (float)$row['setting_value']; break; } } $saved_estimates = []; try { $stmt = $pdo->prepare("SELECT * FROM client_estimates WHERE client_id = ? ORDER BY created_at DESC LIMIT 20"); $stmt->execute([$client_id]); $saved_estimates = $stmt->fetchAll(); } catch (Exception $e) { $saved_estimates = []; } } catch (Exception $e) { error_log("Estimator page error: " . $e->getMessage()); } $save_success = ''; $save_error = ''; if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['action']) && $_POST['action'] === 'save_estimate') { try { $pdo = getClientDBConnection(); $pdo->exec(" CREATE TABLE IF NOT EXISTS client_estimates ( id INT AUTO_INCREMENT PRIMARY KEY, client_id INT NOT NULL, project_name VARCHAR(255) DEFAULT 'Untitled', target_country VARCHAR(100) DEFAULT 'India', loi INT NOT NULL, sample_size INT NOT NULL, incidence_rate INT DEFAULT NULL, notes TEXT DEFAULT NULL, sample_cost_per DECIMAL(10,2) NOT NULL, incentive_per DECIMAL(10,2) NOT NULL, total_per_sample DECIMAL(10,2) NOT NULL, total_cost DECIMAL(12,2) NOT NULL, currency VARCHAR(3) NOT NULL DEFAULT 'INR', exchange_rate DECIMAL(10,4) DEFAULT NULL, status ENUM('draft','saved','submitted') DEFAULT 'saved', created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, KEY idx_client (client_id) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci "); $stmt = $pdo->prepare(" INSERT INTO client_estimates (client_id, project_name, target_country, loi, sample_size, incidence_rate, notes, sample_cost_per, incentive_per, total_per_sample, total_cost, currency, exchange_rate, status) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, 'saved') "); $stmt->execute([ $client_id, trim($_POST['project_name'] ?? 'Untitled'), 'India', (int)$_POST['loi'], (int)$_POST['sample_size'], !empty($_POST['incidence_rate']) ? (int)$_POST['incidence_rate'] : null, trim($_POST['notes'] ?? ''), (float)$_POST['sample_cost_per'], (float)$_POST['incentive_per'], (float)$_POST['total_per_sample'], (float)$_POST['total_cost'], $_POST['est_currency'] ?? $client_currency, !empty($_POST['exchange_rate']) ? (float)$_POST['exchange_rate'] : null, ]); $save_success = 'Estimate saved successfully!'; $stmt = $pdo->prepare("SELECT * FROM client_estimates WHERE client_id = ? ORDER BY created_at DESC LIMIT 20"); $stmt->execute([$client_id]); $saved_estimates = $stmt->fetchAll(); } catch (Exception $e) { error_log("Save estimate error: " . $e->getMessage()); $save_error = 'Error saving estimate. Please try again.'; } } include 'client-portal-header.php'; ?>
Get instant cost estimates for your research projects.
Enter your project requirements to get an instant estimate.
Your estimate summary will appear here.
Fill in the project details and click
Calculate Estimate to see a summary.
⚠ This is an approximate estimate based on standard rates. Final pricing may vary based on project complexity.
No saved estimates yet. Create and save your first estimate above.
| # | Project Name | LOI | Sample | IR | Per Sample | Total Cost | Currency | Date | Status | Action |
|---|---|---|---|---|---|---|---|---|---|---|
| min |