Deploy from Lumerel
This commit is contained in:
54
.docker/99-migrate.sh
Normal file
54
.docker/99-migrate.sh
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# IMPORTANT: This script is sourced (not executed) by the webdevops entrypoint.
|
||||||
|
# Never use "exit" — it would kill the parent entrypoint and prevent supervisord from starting.
|
||||||
|
# Use "return" instead to leave this script without affecting the parent.
|
||||||
|
|
||||||
|
echo ">>> Waiting for database connection..."
|
||||||
|
echo ">>> DB_HOST=${DB_HOST:-NOT SET}"
|
||||||
|
echo ">>> DB_PORT=${DB_PORT:-NOT SET}"
|
||||||
|
echo ">>> DB_DATABASE=${DB_DATABASE:-NOT SET}"
|
||||||
|
echo ">>> DB_USERNAME=${DB_USERNAME:-NOT SET}"
|
||||||
|
echo ">>> DB_PASSWORD is $([ -n "$DB_PASSWORD" ] && echo 'set' || echo 'NOT SET')"
|
||||||
|
|
||||||
|
if [ -z "$DB_HOST" ] || [ -z "$DB_USERNAME" ]; then
|
||||||
|
echo ">>> ERROR: DB_HOST or DB_USERNAME not set. Skipping migrations."
|
||||||
|
return 0 2>/dev/null || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
_migrate_max_retries=30
|
||||||
|
_migrate_count=0
|
||||||
|
_migrate_done=false
|
||||||
|
|
||||||
|
while [ $_migrate_count -lt $_migrate_max_retries ]; do
|
||||||
|
if php -r '
|
||||||
|
try {
|
||||||
|
$host = getenv("DB_HOST");
|
||||||
|
$port = getenv("DB_PORT") ?: "3306";
|
||||||
|
$user = getenv("DB_USERNAME");
|
||||||
|
$pass = getenv("DB_PASSWORD");
|
||||||
|
new PDO("mysql:host=$host;port=$port", $user, $pass, [PDO::ATTR_TIMEOUT => 3]);
|
||||||
|
exit(0);
|
||||||
|
} catch (Throwable $e) {
|
||||||
|
fwrite(STDERR, "PDO error: " . $e->getMessage() . "\n");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
' 2>&1; then
|
||||||
|
echo ">>> Database is reachable. Running migrations..."
|
||||||
|
if php /app/migrate.php; then
|
||||||
|
echo ">>> Migrations completed successfully."
|
||||||
|
else
|
||||||
|
echo ">>> WARNING: migrate.php exited with code $?"
|
||||||
|
fi
|
||||||
|
_migrate_done=true
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
|
||||||
|
_migrate_count=$((_migrate_count + 1))
|
||||||
|
echo ">>> Waiting for database... attempt $_migrate_count/$_migrate_max_retries"
|
||||||
|
sleep 2
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ "$_migrate_done" = false ]; then
|
||||||
|
echo ">>> WARNING: Could not connect to database after $_migrate_max_retries attempts. Skipping migrations."
|
||||||
|
fi
|
||||||
3
.dockerignore
Normal file
3
.dockerignore
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
.git
|
||||||
|
Dockerfile
|
||||||
|
.dockerignore
|
||||||
23
Dockerfile
Normal file
23
Dockerfile
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
FROM webdevops/php-nginx:8.3-alpine
|
||||||
|
ENV WEB_DOCUMENT_ROOT=/app/public
|
||||||
|
ARG CACHE_BUST=1771297448
|
||||||
|
COPY . /app
|
||||||
|
RUN echo "index index.php index.html index.htm;" > /opt/docker/etc/nginx/vhost.common.d/01-index.conf \
|
||||||
|
&& echo "add_header Cache-Control 'no-cache, no-store, must-revalidate';" > /opt/docker/etc/nginx/vhost.common.d/02-no-cache.conf
|
||||||
|
RUN set -e; if [ -f /app/composer.json ]; then \
|
||||||
|
echo ">>> composer.json found, installing dependencies..."; \
|
||||||
|
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer; \
|
||||||
|
cd /app && composer install --no-dev --no-interaction --optimize-autoloader; \
|
||||||
|
ls -la /app/vendor/autoload.php; \
|
||||||
|
else \
|
||||||
|
echo ">>> No composer.json found, skipping composer install"; \
|
||||||
|
fi
|
||||||
|
RUN set -e; if [ -f /app/package.json ]; then \
|
||||||
|
echo ">>> package.json found, installing node dependencies..."; \
|
||||||
|
apk add --no-cache nodejs npm; \
|
||||||
|
cd /app && npm install --production; \
|
||||||
|
else \
|
||||||
|
echo ">>> No package.json found, skipping npm install"; \
|
||||||
|
fi
|
||||||
|
COPY --chmod=755 .docker/99-migrate.sh /opt/docker/provision/entrypoint.d/99-migrate.sh
|
||||||
|
RUN chown -R application:application /app
|
||||||
13
composer.json
Normal file
13
composer.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"name": "todd-low-media/onboarding",
|
||||||
|
"description": "Interactive onboarding portal for new customers",
|
||||||
|
"type": "project",
|
||||||
|
"require": {
|
||||||
|
"php": ">=7.4"
|
||||||
|
},
|
||||||
|
"autoload": {
|
||||||
|
"psr-4": {
|
||||||
|
"App\\": "src/"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
34
migrate.php
Normal file
34
migrate.php
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
<?php
|
||||||
|
// Migration runner
|
||||||
|
require_once __DIR__ . '/src/db.php';
|
||||||
|
|
||||||
|
// Create migrations tracking table
|
||||||
|
$pdo->exec("
|
||||||
|
CREATE TABLE IF NOT EXISTS migrations (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
migration VARCHAR(255) NOT NULL UNIQUE,
|
||||||
|
ran_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
)
|
||||||
|
");
|
||||||
|
|
||||||
|
// Get already-run migrations
|
||||||
|
$stmt = $pdo->query("SELECT migration FROM migrations");
|
||||||
|
$ranMigrations = $stmt->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
|
// Scan and run new migrations
|
||||||
|
$migrationFiles = glob(__DIR__ . '/migrations/*.php');
|
||||||
|
sort($migrationFiles);
|
||||||
|
|
||||||
|
foreach ($migrationFiles as $file) {
|
||||||
|
$migrationName = basename($file);
|
||||||
|
|
||||||
|
if (!in_array($migrationName, $ranMigrations)) {
|
||||||
|
echo "Running migration: $migrationName\n";
|
||||||
|
require $file;
|
||||||
|
|
||||||
|
$pdo->prepare("INSERT INTO migrations (migration) VALUES (?)")->execute([$migrationName]);
|
||||||
|
echo "Completed: $migrationName\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "All migrations completed.\n";
|
||||||
30
migrations/001_create_onboarding_sessions_table.php
Normal file
30
migrations/001_create_onboarding_sessions_table.php
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
<?php
|
||||||
|
// Create onboarding sessions table
|
||||||
|
$pdo->exec("
|
||||||
|
CREATE TABLE IF NOT EXISTS onboarding_sessions (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
session_token VARCHAR(64) UNIQUE NOT NULL,
|
||||||
|
company_name VARCHAR(255),
|
||||||
|
company_logo VARCHAR(255),
|
||||||
|
primary_color VARCHAR(7),
|
||||||
|
secondary_color VARCHAR(7),
|
||||||
|
industry VARCHAR(100),
|
||||||
|
company_tagline TEXT,
|
||||||
|
quote_format VARCHAR(50),
|
||||||
|
payment_terms VARCHAR(100),
|
||||||
|
quote_validity_days INT,
|
||||||
|
show_itemized_pricing BOOLEAN DEFAULT 1,
|
||||||
|
include_terms_conditions BOOLEAN DEFAULT 1,
|
||||||
|
contact_name VARCHAR(255),
|
||||||
|
contact_email VARCHAR(255),
|
||||||
|
contact_phone VARCHAR(50),
|
||||||
|
contact_address TEXT,
|
||||||
|
website VARCHAR(255),
|
||||||
|
current_step INT DEFAULT 1,
|
||||||
|
completed BOOLEAN DEFAULT 0,
|
||||||
|
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||||
|
updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
|
||||||
|
INDEX idx_session_token (session_token),
|
||||||
|
INDEX idx_completed (completed)
|
||||||
|
)
|
||||||
|
");
|
||||||
339
public/dashboard.php
Normal file
339
public/dashboard.php
Normal file
@@ -0,0 +1,339 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once __DIR__ . '/../src/db.php';
|
||||||
|
|
||||||
|
if (!isset($_SESSION['onboarding_token'])) {
|
||||||
|
header('Location: index.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$token = $_SESSION['onboarding_token'];
|
||||||
|
|
||||||
|
// Fetch session data
|
||||||
|
$stmt = $pdo->prepare("SELECT * FROM onboarding_sessions WHERE session_token = ?");
|
||||||
|
$stmt->execute([$token]);
|
||||||
|
$session = $stmt->fetch();
|
||||||
|
|
||||||
|
if (!$session || !$session['completed']) {
|
||||||
|
header('Location: index.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Dashboard - <?= htmlspecialchars($session['company_name']) ?></title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
||||||
|
background: #f3f4f6;
|
||||||
|
min-height: 100vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
background: linear-gradient(135deg, <?= $session['primary_color'] ?> 0%, <?= $session['secondary_color'] ?> 100%);
|
||||||
|
color: white;
|
||||||
|
padding: 24px 40px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.header-content {
|
||||||
|
max-width: 1200px;
|
||||||
|
margin: 0 auto;
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header h1 {
|
||||||
|
font-size: 24px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header p {
|
||||||
|
font-size: 14px;
|
||||||
|
opacity: 0.9;
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
max-width: 1200px;
|
||||||
|
margin: 40px auto;
|
||||||
|
padding: 0 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.welcome-card {
|
||||||
|
background: white;
|
||||||
|
border-radius: 16px;
|
||||||
|
padding: 40px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
margin-bottom: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.welcome-card h2 {
|
||||||
|
font-size: 28px;
|
||||||
|
color: #1f2937;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.welcome-card p {
|
||||||
|
font-size: 16px;
|
||||||
|
color: #6b7280;
|
||||||
|
line-height: 1.6;
|
||||||
|
}
|
||||||
|
|
||||||
|
.cards-grid {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
|
||||||
|
gap: 24px;
|
||||||
|
margin-top: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card {
|
||||||
|
background: white;
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 32px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
transition: transform 0.2s ease, box-shadow 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card:hover {
|
||||||
|
transform: translateY(-4px);
|
||||||
|
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-icon {
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
border-radius: 12px;
|
||||||
|
background: linear-gradient(135deg, <?= $session['primary_color'] ?> 0%, <?= $session['secondary_color'] ?> 100%);
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-size: 24px;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card h3 {
|
||||||
|
font-size: 20px;
|
||||||
|
color: #1f2937;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card p {
|
||||||
|
font-size: 14px;
|
||||||
|
color: #6b7280;
|
||||||
|
line-height: 1.6;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-button {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 10px 20px;
|
||||||
|
background: linear-gradient(135deg, <?= $session['primary_color'] ?> 0%, <?= $session['secondary_color'] ?> 100%);
|
||||||
|
color: white;
|
||||||
|
text-decoration: none;
|
||||||
|
border-radius: 8px;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 14px;
|
||||||
|
transition: transform 0.2s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-button:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-section {
|
||||||
|
background: white;
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 32px;
|
||||||
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
||||||
|
margin-top: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.settings-section h3 {
|
||||||
|
font-size: 20px;
|
||||||
|
color: #1f2937;
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setting-item {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 16px 0;
|
||||||
|
border-bottom: 1px solid #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setting-item:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setting-label {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #4b5563;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.setting-value {
|
||||||
|
color: #1f2937;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-preview {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
border-radius: 6px;
|
||||||
|
display: inline-block;
|
||||||
|
border: 2px solid #e5e7eb;
|
||||||
|
vertical-align: middle;
|
||||||
|
margin-right: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge {
|
||||||
|
display: inline-block;
|
||||||
|
padding: 4px 12px;
|
||||||
|
background: #10b981;
|
||||||
|
color: white;
|
||||||
|
border-radius: 12px;
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="header">
|
||||||
|
<div class="header-content">
|
||||||
|
<div>
|
||||||
|
<h1><?= htmlspecialchars($session['company_name']) ?></h1>
|
||||||
|
<p><?= htmlspecialchars($session['company_tagline'] ?: 'Your Dashboard') ?></p>
|
||||||
|
</div>
|
||||||
|
<span class="badge">✓ Setup Complete</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="container">
|
||||||
|
<div class="welcome-card">
|
||||||
|
<h2>Welcome, <?= htmlspecialchars($session['contact_name']) ?>! 👋</h2>
|
||||||
|
<p>Your onboarding is complete and your account is ready to go. Below you'll find quick access to key features and your current settings.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="cards-grid">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-icon">📄</div>
|
||||||
|
<h3>Create Quote</h3>
|
||||||
|
<p>Start building your first professional quote with your custom branding and preferences.</p>
|
||||||
|
<a href="#" class="card-button">New Quote →</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-icon">🎨</div>
|
||||||
|
<h3>Customize Templates</h3>
|
||||||
|
<p>Personalize your quote templates with your brand colors, logo, and messaging.</p>
|
||||||
|
<a href="#" class="card-button">Edit Templates →</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-icon">👥</div>
|
||||||
|
<h3>Manage Clients</h3>
|
||||||
|
<p>Add and organize your client contacts for faster quote generation.</p>
|
||||||
|
<a href="#" class="card-button">View Clients →</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-icon">📊</div>
|
||||||
|
<h3>View Reports</h3>
|
||||||
|
<p>Track your quotes, conversions, and revenue with detailed analytics.</p>
|
||||||
|
<a href="#" class="card-button">See Reports →</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-icon">⚙️</div>
|
||||||
|
<h3>Account Settings</h3>
|
||||||
|
<p>Update your company information, preferences, and integrations.</p>
|
||||||
|
<a href="#" class="card-button">Manage Settings →</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-icon">💬</div>
|
||||||
|
<h3>Get Support</h3>
|
||||||
|
<p>Need help? Our support team is here to assist you with any questions.</p>
|
||||||
|
<a href="#" class="card-button">Contact Support →</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="settings-section">
|
||||||
|
<h3>Your Current Settings</h3>
|
||||||
|
|
||||||
|
<div class="setting-item">
|
||||||
|
<span class="setting-label">Company Name</span>
|
||||||
|
<span class="setting-value"><?= htmlspecialchars($session['company_name']) ?></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-item">
|
||||||
|
<span class="setting-label">Industry</span>
|
||||||
|
<span class="setting-value"><?= ucfirst($session['industry']) ?></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-item">
|
||||||
|
<span class="setting-label">Primary Brand Color</span>
|
||||||
|
<span class="setting-value">
|
||||||
|
<span class="color-preview" style="background: <?= $session['primary_color'] ?>"></span>
|
||||||
|
<?= $session['primary_color'] ?>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-item">
|
||||||
|
<span class="setting-label">Secondary Brand Color</span>
|
||||||
|
<span class="setting-value">
|
||||||
|
<span class="color-preview" style="background: <?= $session['secondary_color'] ?>"></span>
|
||||||
|
<?= $session['secondary_color'] ?>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-item">
|
||||||
|
<span class="setting-label">Quote Format</span>
|
||||||
|
<span class="setting-value"><?= ucfirst($session['quote_format']) ?></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-item">
|
||||||
|
<span class="setting-label">Payment Terms</span>
|
||||||
|
<span class="setting-value"><?= str_replace('_', ' ', ucfirst($session['payment_terms'])) ?></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-item">
|
||||||
|
<span class="setting-label">Quote Validity</span>
|
||||||
|
<span class="setting-value"><?= $session['quote_validity_days'] ?> days</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-item">
|
||||||
|
<span class="setting-label">Contact Email</span>
|
||||||
|
<span class="setting-value"><?= htmlspecialchars($session['contact_email']) ?></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="setting-item">
|
||||||
|
<span class="setting-label">Contact Phone</span>
|
||||||
|
<span class="setting-value"><?= htmlspecialchars($session['contact_phone']) ?></span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php if ($session['website']): ?>
|
||||||
|
<div class="setting-item">
|
||||||
|
<span class="setting-label">Website</span>
|
||||||
|
<span class="setting-value">
|
||||||
|
<a href="<?= htmlspecialchars($session['website']) ?>" target="_blank" style="color: <?= $session['primary_color'] ?>">
|
||||||
|
<?= htmlspecialchars($session['website']) ?>
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
823
public/index.php
Normal file
823
public/index.php
Normal file
@@ -0,0 +1,823 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once __DIR__ . '/../src/db.php';
|
||||||
|
|
||||||
|
// Initialize or retrieve session token
|
||||||
|
if (!isset($_SESSION['onboarding_token'])) {
|
||||||
|
$_SESSION['onboarding_token'] = bin2hex(random_bytes(32));
|
||||||
|
|
||||||
|
// Create new onboarding session
|
||||||
|
$stmt = $pdo->prepare("INSERT INTO onboarding_sessions (session_token) VALUES (?)");
|
||||||
|
$stmt->execute([$_SESSION['onboarding_token']]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$token = $_SESSION['onboarding_token'];
|
||||||
|
|
||||||
|
// Fetch current session data
|
||||||
|
$stmt = $pdo->prepare("SELECT * FROM onboarding_sessions WHERE session_token = ?");
|
||||||
|
$stmt->execute([$token]);
|
||||||
|
$session = $stmt->fetch();
|
||||||
|
|
||||||
|
$currentStep = $session['current_step'] ?? 1;
|
||||||
|
$completed = $session['completed'] ?? 0;
|
||||||
|
?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Welcome! Let's Get Started</title>
|
||||||
|
<style>
|
||||||
|
* {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
body {
|
||||||
|
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
min-height: 100vh;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.container {
|
||||||
|
background: white;
|
||||||
|
border-radius: 20px;
|
||||||
|
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
|
||||||
|
max-width: 800px;
|
||||||
|
width: 100%;
|
||||||
|
overflow: hidden;
|
||||||
|
animation: slideUp 0.5s ease-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes slideUp {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateY(30px);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateY(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
color: white;
|
||||||
|
padding: 40px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header h1 {
|
||||||
|
font-size: 32px;
|
||||||
|
margin-bottom: 10px;
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header p {
|
||||||
|
font-size: 16px;
|
||||||
|
opacity: 0.95;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-bar {
|
||||||
|
background: rgba(255, 255, 255, 0.2);
|
||||||
|
height: 6px;
|
||||||
|
margin-top: 30px;
|
||||||
|
border-radius: 3px;
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.progress-fill {
|
||||||
|
background: white;
|
||||||
|
height: 100%;
|
||||||
|
transition: width 0.4s ease;
|
||||||
|
border-radius: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.steps {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 30px 40px;
|
||||||
|
border-bottom: 1px solid #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-indicator {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
flex: 1;
|
||||||
|
position: relative;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-indicator:not(:last-child)::after {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
left: calc(100% - 10px);
|
||||||
|
top: 15px;
|
||||||
|
width: calc(100% - 40px);
|
||||||
|
height: 2px;
|
||||||
|
background: #e5e7eb;
|
||||||
|
z-index: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-indicator.active:not(:last-child)::after,
|
||||||
|
.step-indicator.completed:not(:last-child)::after {
|
||||||
|
background: #667eea;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-number {
|
||||||
|
width: 32px;
|
||||||
|
height: 32px;
|
||||||
|
border-radius: 50%;
|
||||||
|
background: #e5e7eb;
|
||||||
|
color: #6b7280;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 14px;
|
||||||
|
position: relative;
|
||||||
|
z-index: 1;
|
||||||
|
transition: all 0.3s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-indicator.active .step-number {
|
||||||
|
background: #667eea;
|
||||||
|
color: white;
|
||||||
|
transform: scale(1.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-indicator.completed .step-number {
|
||||||
|
background: #10b981;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-indicator.completed .step-number::before {
|
||||||
|
content: '✓';
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-label {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #6b7280;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-indicator.active .step-label {
|
||||||
|
color: #667eea;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
padding: 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-content {
|
||||||
|
display: none;
|
||||||
|
animation: fadeIn 0.4s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-content.active {
|
||||||
|
display: block;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes fadeIn {
|
||||||
|
from {
|
||||||
|
opacity: 0;
|
||||||
|
transform: translateX(20px);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
opacity: 1;
|
||||||
|
transform: translateX(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-group {
|
||||||
|
margin-bottom: 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
label {
|
||||||
|
display: block;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #1f2937;
|
||||||
|
margin-bottom: 8px;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
label .optional {
|
||||||
|
font-weight: 400;
|
||||||
|
color: #6b7280;
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="text"],
|
||||||
|
input[type="email"],
|
||||||
|
input[type="tel"],
|
||||||
|
input[type="url"],
|
||||||
|
input[type="number"],
|
||||||
|
input[type="color"],
|
||||||
|
textarea,
|
||||||
|
select {
|
||||||
|
width: 100%;
|
||||||
|
padding: 12px 16px;
|
||||||
|
border: 2px solid #e5e7eb;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size: 15px;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
font-family: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type="color"] {
|
||||||
|
height: 50px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
input:focus,
|
||||||
|
textarea:focus,
|
||||||
|
select:focus {
|
||||||
|
outline: none;
|
||||||
|
border-color: #667eea;
|
||||||
|
box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea {
|
||||||
|
resize: vertical;
|
||||||
|
min-height: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-row {
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: 1fr 1fr;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-group {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 10px;
|
||||||
|
padding: 12px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-group input[type="checkbox"] {
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.checkbox-group label {
|
||||||
|
margin: 0;
|
||||||
|
cursor: pointer;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.buttons {
|
||||||
|
display: flex;
|
||||||
|
gap: 12px;
|
||||||
|
margin-top: 32px;
|
||||||
|
padding-top: 32px;
|
||||||
|
border-top: 1px solid #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
button {
|
||||||
|
padding: 14px 28px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 10px;
|
||||||
|
font-size: 15px;
|
||||||
|
font-weight: 600;
|
||||||
|
cursor: pointer;
|
||||||
|
transition: all 0.2s ease;
|
||||||
|
font-family: inherit;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary {
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
color: white;
|
||||||
|
flex: 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:hover {
|
||||||
|
transform: translateY(-2px);
|
||||||
|
box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary {
|
||||||
|
background: #f3f4f6;
|
||||||
|
color: #4b5563;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-secondary:hover {
|
||||||
|
background: #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:disabled {
|
||||||
|
opacity: 0.5;
|
||||||
|
cursor: not-allowed;
|
||||||
|
transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.completion-screen {
|
||||||
|
text-align: center;
|
||||||
|
padding: 60px 40px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.completion-screen .icon {
|
||||||
|
width: 80px;
|
||||||
|
height: 80px;
|
||||||
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
||||||
|
border-radius: 50%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: center;
|
||||||
|
margin: 0 auto 30px;
|
||||||
|
font-size: 40px;
|
||||||
|
animation: scaleIn 0.5s ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes scaleIn {
|
||||||
|
from {
|
||||||
|
transform: scale(0);
|
||||||
|
}
|
||||||
|
to {
|
||||||
|
transform: scale(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.completion-screen h2 {
|
||||||
|
font-size: 28px;
|
||||||
|
color: #1f2937;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.completion-screen p {
|
||||||
|
font-size: 16px;
|
||||||
|
color: #6b7280;
|
||||||
|
line-height: 1.6;
|
||||||
|
margin-bottom: 32px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-card {
|
||||||
|
background: #f9fafb;
|
||||||
|
border-radius: 12px;
|
||||||
|
padding: 24px;
|
||||||
|
text-align: left;
|
||||||
|
margin: 24px 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-card h3 {
|
||||||
|
font-size: 18px;
|
||||||
|
color: #1f2937;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-item {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 8px 0;
|
||||||
|
border-bottom: 1px solid #e5e7eb;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-item:last-child {
|
||||||
|
border-bottom: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-label {
|
||||||
|
font-weight: 600;
|
||||||
|
color: #4b5563;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.summary-value {
|
||||||
|
color: #1f2937;
|
||||||
|
font-size: 14px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.color-preview {
|
||||||
|
width: 24px;
|
||||||
|
height: 24px;
|
||||||
|
border-radius: 6px;
|
||||||
|
display: inline-block;
|
||||||
|
border: 2px solid #e5e7eb;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
|
|
||||||
|
.help-text {
|
||||||
|
font-size: 13px;
|
||||||
|
color: #6b7280;
|
||||||
|
margin-top: 6px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 768px) {
|
||||||
|
.form-row {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.steps {
|
||||||
|
padding: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.step-label {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
padding: 30px 20px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container">
|
||||||
|
<?php if (!$completed): ?>
|
||||||
|
<div class="header">
|
||||||
|
<h1>🎉 Welcome Aboard!</h1>
|
||||||
|
<p>Let's set up your account in just a few simple steps</p>
|
||||||
|
<div class="progress-bar">
|
||||||
|
<div class="progress-fill" id="progressFill" style="width: <?= ($currentStep / 4) * 100 ?>%"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="steps">
|
||||||
|
<div class="step-indicator <?= $currentStep >= 1 ? 'active' : '' ?> <?= $currentStep > 1 ? 'completed' : '' ?>">
|
||||||
|
<div class="step-number"><?= $currentStep > 1 ? '' : '1' ?></div>
|
||||||
|
<div class="step-label">Company Branding</div>
|
||||||
|
</div>
|
||||||
|
<div class="step-indicator <?= $currentStep >= 2 ? 'active' : '' ?> <?= $currentStep > 2 ? 'completed' : '' ?>">
|
||||||
|
<div class="step-number"><?= $currentStep > 2 ? '' : '2' ?></div>
|
||||||
|
<div class="step-label">Quote Preferences</div>
|
||||||
|
</div>
|
||||||
|
<div class="step-indicator <?= $currentStep >= 3 ? 'active' : '' ?> <?= $currentStep > 3 ? 'completed' : '' ?>">
|
||||||
|
<div class="step-number"><?= $currentStep > 3 ? '' : '3' ?></div>
|
||||||
|
<div class="step-label">Contact Info</div>
|
||||||
|
</div>
|
||||||
|
<div class="step-indicator <?= $currentStep >= 4 ? 'active' : '' ?>">
|
||||||
|
<div class="step-number">4</div>
|
||||||
|
<div class="step-label">Review</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="content">
|
||||||
|
<form id="onboardingForm" method="POST" action="save.php">
|
||||||
|
<!-- Step 1: Company Branding -->
|
||||||
|
<div class="step-content <?= $currentStep == 1 ? 'active' : '' ?>" data-step="1">
|
||||||
|
<h2 style="margin-bottom: 24px; color: #1f2937;">Tell us about your company</h2>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Company Name *</label>
|
||||||
|
<input type="text" name="company_name" value="<?= htmlspecialchars($session['company_name'] ?? '') ?>" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Primary Brand Color *</label>
|
||||||
|
<input type="color" name="primary_color" value="<?= $session['primary_color'] ?? '#667eea' ?>" required>
|
||||||
|
<div class="help-text">This will be used for headers and buttons</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Secondary Brand Color *</label>
|
||||||
|
<input type="color" name="secondary_color" value="<?= $session['secondary_color'] ?? '#764ba2' ?>" required>
|
||||||
|
<div class="help-text">Used for accents and highlights</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Industry *</label>
|
||||||
|
<select name="industry" required>
|
||||||
|
<option value="">Select your industry...</option>
|
||||||
|
<option value="technology" <?= ($session['industry'] ?? '') == 'technology' ? 'selected' : '' ?>>Technology</option>
|
||||||
|
<option value="consulting" <?= ($session['industry'] ?? '') == 'consulting' ? 'selected' : '' ?>>Consulting</option>
|
||||||
|
<option value="creative" <?= ($session['industry'] ?? '') == 'creative' ? 'selected' : '' ?>>Creative Services</option>
|
||||||
|
<option value="construction" <?= ($session['industry'] ?? '') == 'construction' ? 'selected' : '' ?>>Construction</option>
|
||||||
|
<option value="retail" <?= ($session['industry'] ?? '') == 'retail' ? 'selected' : '' ?>>Retail</option>
|
||||||
|
<option value="healthcare" <?= ($session['industry'] ?? '') == 'healthcare' ? 'selected' : '' ?>>Healthcare</option>
|
||||||
|
<option value="finance" <?= ($session['industry'] ?? '') == 'finance' ? 'selected' : '' ?>>Finance</option>
|
||||||
|
<option value="other" <?= ($session['industry'] ?? '') == 'other' ? 'selected' : '' ?>>Other</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Company Tagline <span class="optional">(optional)</span></label>
|
||||||
|
<input type="text" name="company_tagline" value="<?= htmlspecialchars($session['company_tagline'] ?? '') ?>" placeholder="e.g., Building tomorrow's solutions today">
|
||||||
|
<div class="help-text">A brief description that appears on your quotes</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Step 2: Quote Preferences -->
|
||||||
|
<div class="step-content <?= $currentStep == 2 ? 'active' : '' ?>" data-step="2">
|
||||||
|
<h2 style="margin-bottom: 24px; color: #1f2937;">Customize your quotes</h2>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Quote Format *</label>
|
||||||
|
<select name="quote_format" required>
|
||||||
|
<option value="detailed" <?= ($session['quote_format'] ?? '') == 'detailed' ? 'selected' : '' ?>>Detailed (itemized with descriptions)</option>
|
||||||
|
<option value="summary" <?= ($session['quote_format'] ?? '') == 'summary' ? 'selected' : '' ?>>Summary (totals only)</option>
|
||||||
|
<option value="professional" <?= ($session['quote_format'] ?? '') == 'professional' ? 'selected' : '' ?>>Professional (balanced detail)</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Payment Terms *</label>
|
||||||
|
<select name="payment_terms" required>
|
||||||
|
<option value="net_15" <?= ($session['payment_terms'] ?? '') == 'net_15' ? 'selected' : '' ?>>Net 15</option>
|
||||||
|
<option value="net_30" <?= ($session['payment_terms'] ?? 'net_30') == 'net_30' ? 'selected' : '' ?>>Net 30</option>
|
||||||
|
<option value="net_60" <?= ($session['payment_terms'] ?? '') == 'net_60' ? 'selected' : '' ?>>Net 60</option>
|
||||||
|
<option value="due_on_receipt" <?= ($session['payment_terms'] ?? '') == 'due_on_receipt' ? 'selected' : '' ?>>Due on Receipt</option>
|
||||||
|
<option value="50_50" <?= ($session['payment_terms'] ?? '') == '50_50' ? 'selected' : '' ?>>50% Deposit, 50% on Completion</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Quote Valid For (days) *</label>
|
||||||
|
<input type="number" name="quote_validity_days" value="<?= $session['quote_validity_days'] ?? '30' ?>" min="1" max="365" required>
|
||||||
|
<div class="help-text">How long quotes remain valid</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="checkbox-group">
|
||||||
|
<input type="checkbox" name="show_itemized_pricing" id="show_itemized" value="1" <?= ($session['show_itemized_pricing'] ?? 1) ? 'checked' : '' ?>>
|
||||||
|
<label for="show_itemized">Show itemized pricing breakdown</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<div class="checkbox-group">
|
||||||
|
<input type="checkbox" name="include_terms_conditions" id="include_terms" value="1" <?= ($session['include_terms_conditions'] ?? 1) ? 'checked' : '' ?>>
|
||||||
|
<label for="include_terms">Include terms & conditions on quotes</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Step 3: Contact Information -->
|
||||||
|
<div class="step-content <?= $currentStep == 3 ? 'active' : '' ?>" data-step="3">
|
||||||
|
<h2 style="margin-bottom: 24px; color: #1f2937;">Your contact details</h2>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Contact Name *</label>
|
||||||
|
<input type="text" name="contact_name" value="<?= htmlspecialchars($session['contact_name'] ?? '') ?>" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-row">
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Email Address *</label>
|
||||||
|
<input type="email" name="contact_email" value="<?= htmlspecialchars($session['contact_email'] ?? '') ?>" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Phone Number *</label>
|
||||||
|
<input type="tel" name="contact_phone" value="<?= htmlspecialchars($session['contact_phone'] ?? '') ?>" required>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Business Address <span class="optional">(optional)</span></label>
|
||||||
|
<textarea name="contact_address" placeholder="Street address, city, state, ZIP"><?= htmlspecialchars($session['contact_address'] ?? '') ?></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="form-group">
|
||||||
|
<label>Website <span class="optional">(optional)</span></label>
|
||||||
|
<input type="url" name="website" value="<?= htmlspecialchars($session['website'] ?? '') ?>" placeholder="https://www.example.com">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Step 4: Review -->
|
||||||
|
<div class="step-content <?= $currentStep == 4 ? 'active' : '' ?>" data-step="4">
|
||||||
|
<h2 style="margin-bottom: 24px; color: #1f2937;">Review your information</h2>
|
||||||
|
|
||||||
|
<div class="summary-card">
|
||||||
|
<h3>Company Branding</h3>
|
||||||
|
<div class="summary-item">
|
||||||
|
<span class="summary-label">Company Name</span>
|
||||||
|
<span class="summary-value"><?= htmlspecialchars($session['company_name'] ?? 'Not set') ?></span>
|
||||||
|
</div>
|
||||||
|
<div class="summary-item">
|
||||||
|
<span class="summary-label">Primary Color</span>
|
||||||
|
<span class="summary-value">
|
||||||
|
<span class="color-preview" style="background: <?= $session['primary_color'] ?? '#667eea' ?>"></span>
|
||||||
|
<?= $session['primary_color'] ?? '#667eea' ?>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="summary-item">
|
||||||
|
<span class="summary-label">Secondary Color</span>
|
||||||
|
<span class="summary-value">
|
||||||
|
<span class="color-preview" style="background: <?= $session['secondary_color'] ?? '#764ba2' ?>"></span>
|
||||||
|
<?= $session['secondary_color'] ?? '#764ba2' ?>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="summary-item">
|
||||||
|
<span class="summary-label">Industry</span>
|
||||||
|
<span class="summary-value"><?= ucfirst($session['industry'] ?? 'Not set') ?></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="summary-card">
|
||||||
|
<h3>Quote Preferences</h3>
|
||||||
|
<div class="summary-item">
|
||||||
|
<span class="summary-label">Format</span>
|
||||||
|
<span class="summary-value"><?= ucfirst($session['quote_format'] ?? 'Not set') ?></span>
|
||||||
|
</div>
|
||||||
|
<div class="summary-item">
|
||||||
|
<span class="summary-label">Payment Terms</span>
|
||||||
|
<span class="summary-value"><?= str_replace('_', ' ', ucfirst($session['payment_terms'] ?? 'Not set')) ?></span>
|
||||||
|
</div>
|
||||||
|
<div class="summary-item">
|
||||||
|
<span class="summary-label">Valid For</span>
|
||||||
|
<span class="summary-value"><?= $session['quote_validity_days'] ?? '30' ?> days</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="summary-card">
|
||||||
|
<h3>Contact Information</h3>
|
||||||
|
<div class="summary-item">
|
||||||
|
<span class="summary-label">Name</span>
|
||||||
|
<span class="summary-value"><?= htmlspecialchars($session['contact_name'] ?? 'Not set') ?></span>
|
||||||
|
</div>
|
||||||
|
<div class="summary-item">
|
||||||
|
<span class="summary-label">Email</span>
|
||||||
|
<span class="summary-value"><?= htmlspecialchars($session['contact_email'] ?? 'Not set') ?></span>
|
||||||
|
</div>
|
||||||
|
<div class="summary-item">
|
||||||
|
<span class="summary-label">Phone</span>
|
||||||
|
<span class="summary-value"><?= htmlspecialchars($session['contact_phone'] ?? 'Not set') ?></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="buttons">
|
||||||
|
<button type="button" class="btn-secondary" id="prevBtn" style="display: <?= $currentStep > 1 ? 'block' : 'none' ?>">
|
||||||
|
← Previous
|
||||||
|
</button>
|
||||||
|
<button type="button" class="btn-primary" id="nextBtn" style="display: <?= $currentStep < 4 ? 'block' : 'none' ?>">
|
||||||
|
Next →
|
||||||
|
</button>
|
||||||
|
<button type="submit" class="btn-primary" id="submitBtn" style="display: <?= $currentStep == 4 ? 'block' : 'none' ?>">
|
||||||
|
Complete Setup 🚀
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
<?php else: ?>
|
||||||
|
<div class="completion-screen">
|
||||||
|
<div class="icon">🎉</div>
|
||||||
|
<h2>All Set! Welcome to the Team</h2>
|
||||||
|
<p>Your account has been successfully configured. You're ready to start creating beautiful quotes and managing your business.</p>
|
||||||
|
|
||||||
|
<div class="summary-card">
|
||||||
|
<h3>What's Next?</h3>
|
||||||
|
<p style="text-align: left; margin-top: 12px;">
|
||||||
|
• Access your dashboard to create your first quote<br>
|
||||||
|
• Customize templates with your branding<br>
|
||||||
|
• Invite team members to collaborate<br>
|
||||||
|
• Explore advanced features and integrations
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button class="btn-primary" onclick="window.location.href='dashboard.php'">
|
||||||
|
Go to Dashboard →
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
let currentStep = <?= $currentStep ?>;
|
||||||
|
const totalSteps = 4;
|
||||||
|
|
||||||
|
const prevBtn = document.getElementById('prevBtn');
|
||||||
|
const nextBtn = document.getElementById('nextBtn');
|
||||||
|
const submitBtn = document.getElementById('submitBtn');
|
||||||
|
const form = document.getElementById('onboardingForm');
|
||||||
|
|
||||||
|
function updateUI() {
|
||||||
|
// Hide all steps
|
||||||
|
document.querySelectorAll('.step-content').forEach(step => {
|
||||||
|
step.classList.remove('active');
|
||||||
|
});
|
||||||
|
|
||||||
|
// Show current step
|
||||||
|
document.querySelector(`[data-step="${currentStep}"]`).classList.add('active');
|
||||||
|
|
||||||
|
// Update step indicators
|
||||||
|
document.querySelectorAll('.step-indicator').forEach((indicator, index) => {
|
||||||
|
indicator.classList.remove('active', 'completed');
|
||||||
|
if (index + 1 === currentStep) {
|
||||||
|
indicator.classList.add('active');
|
||||||
|
} else if (index + 1 < currentStep) {
|
||||||
|
indicator.classList.add('completed');
|
||||||
|
}
|
||||||
|
|
||||||
|
const stepNumber = indicator.querySelector('.step-number');
|
||||||
|
if (index + 1 < currentStep) {
|
||||||
|
stepNumber.textContent = '';
|
||||||
|
} else {
|
||||||
|
stepNumber.textContent = index + 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Update progress bar
|
||||||
|
const progress = (currentStep / totalSteps) * 100;
|
||||||
|
document.getElementById('progressFill').style.width = progress + '%';
|
||||||
|
|
||||||
|
// Update buttons
|
||||||
|
prevBtn.style.display = currentStep > 1 ? 'block' : 'none';
|
||||||
|
nextBtn.style.display = currentStep < totalSteps ? 'block' : 'none';
|
||||||
|
submitBtn.style.display = currentStep === totalSteps ? 'block' : 'none';
|
||||||
|
}
|
||||||
|
|
||||||
|
function validateStep(step) {
|
||||||
|
const stepContent = document.querySelector(`[data-step="${step}"]`);
|
||||||
|
const requiredFields = stepContent.querySelectorAll('[required]');
|
||||||
|
|
||||||
|
for (let field of requiredFields) {
|
||||||
|
if (!field.value.trim()) {
|
||||||
|
field.focus();
|
||||||
|
field.style.borderColor = '#ef4444';
|
||||||
|
setTimeout(() => {
|
||||||
|
field.style.borderColor = '#e5e7eb';
|
||||||
|
}, 2000);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function saveProgress() {
|
||||||
|
const formData = new FormData(form);
|
||||||
|
formData.append('current_step', currentStep);
|
||||||
|
formData.append('save_progress', '1');
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('save.php', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
});
|
||||||
|
return response.ok;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Error saving progress:', error);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nextBtn.addEventListener('click', async () => {
|
||||||
|
if (validateStep(currentStep)) {
|
||||||
|
await saveProgress();
|
||||||
|
currentStep++;
|
||||||
|
updateUI();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
prevBtn.addEventListener('click', async () => {
|
||||||
|
await saveProgress();
|
||||||
|
currentStep--;
|
||||||
|
updateUI();
|
||||||
|
});
|
||||||
|
|
||||||
|
form.addEventListener('submit', async (e) => {
|
||||||
|
e.preventDefault();
|
||||||
|
|
||||||
|
if (!validateStep(currentStep)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const formData = new FormData(form);
|
||||||
|
formData.append('complete', '1');
|
||||||
|
|
||||||
|
submitBtn.disabled = true;
|
||||||
|
submitBtn.textContent = 'Completing...';
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch('save.php', {
|
||||||
|
method: 'POST',
|
||||||
|
body: formData
|
||||||
|
});
|
||||||
|
|
||||||
|
if (response.ok) {
|
||||||
|
window.location.reload();
|
||||||
|
} else {
|
||||||
|
alert('There was an error completing your setup. Please try again.');
|
||||||
|
submitBtn.disabled = false;
|
||||||
|
submitBtn.textContent = 'Complete Setup 🚀';
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
alert('There was an error completing your setup. Please try again.');
|
||||||
|
submitBtn.disabled = false;
|
||||||
|
submitBtn.textContent = 'Complete Setup 🚀';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// Auto-save on input change
|
||||||
|
let saveTimeout;
|
||||||
|
form.addEventListener('input', () => {
|
||||||
|
clearTimeout(saveTimeout);
|
||||||
|
saveTimeout = setTimeout(() => {
|
||||||
|
saveProgress();
|
||||||
|
}, 1000);
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
111
public/save.php
Normal file
111
public/save.php
Normal file
@@ -0,0 +1,111 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once __DIR__ . '/../src/db.php';
|
||||||
|
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
|
||||||
|
if (!isset($_SESSION['onboarding_token'])) {
|
||||||
|
http_response_code(400);
|
||||||
|
echo json_encode(['error' => 'No session found']);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
$token = $_SESSION['onboarding_token'];
|
||||||
|
|
||||||
|
try {
|
||||||
|
// Prepare update data
|
||||||
|
$updates = [];
|
||||||
|
$params = [];
|
||||||
|
|
||||||
|
// Company branding fields
|
||||||
|
if (isset($_POST['company_name'])) {
|
||||||
|
$updates[] = 'company_name = ?';
|
||||||
|
$params[] = $_POST['company_name'];
|
||||||
|
}
|
||||||
|
if (isset($_POST['primary_color'])) {
|
||||||
|
$updates[] = 'primary_color = ?';
|
||||||
|
$params[] = $_POST['primary_color'];
|
||||||
|
}
|
||||||
|
if (isset($_POST['secondary_color'])) {
|
||||||
|
$updates[] = 'secondary_color = ?';
|
||||||
|
$params[] = $_POST['secondary_color'];
|
||||||
|
}
|
||||||
|
if (isset($_POST['industry'])) {
|
||||||
|
$updates[] = 'industry = ?';
|
||||||
|
$params[] = $_POST['industry'];
|
||||||
|
}
|
||||||
|
if (isset($_POST['company_tagline'])) {
|
||||||
|
$updates[] = 'company_tagline = ?';
|
||||||
|
$params[] = $_POST['company_tagline'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Quote preferences fields
|
||||||
|
if (isset($_POST['quote_format'])) {
|
||||||
|
$updates[] = 'quote_format = ?';
|
||||||
|
$params[] = $_POST['quote_format'];
|
||||||
|
}
|
||||||
|
if (isset($_POST['payment_terms'])) {
|
||||||
|
$updates[] = 'payment_terms = ?';
|
||||||
|
$params[] = $_POST['payment_terms'];
|
||||||
|
}
|
||||||
|
if (isset($_POST['quote_validity_days'])) {
|
||||||
|
$updates[] = 'quote_validity_days = ?';
|
||||||
|
$params[] = intval($_POST['quote_validity_days']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checkboxes (handle unchecked state)
|
||||||
|
$updates[] = 'show_itemized_pricing = ?';
|
||||||
|
$params[] = isset($_POST['show_itemized_pricing']) ? 1 : 0;
|
||||||
|
|
||||||
|
$updates[] = 'include_terms_conditions = ?';
|
||||||
|
$params[] = isset($_POST['include_terms_conditions']) ? 1 : 0;
|
||||||
|
|
||||||
|
// Contact information fields
|
||||||
|
if (isset($_POST['contact_name'])) {
|
||||||
|
$updates[] = 'contact_name = ?';
|
||||||
|
$params[] = $_POST['contact_name'];
|
||||||
|
}
|
||||||
|
if (isset($_POST['contact_email'])) {
|
||||||
|
$updates[] = 'contact_email = ?';
|
||||||
|
$params[] = $_POST['contact_email'];
|
||||||
|
}
|
||||||
|
if (isset($_POST['contact_phone'])) {
|
||||||
|
$updates[] = 'contact_phone = ?';
|
||||||
|
$params[] = $_POST['contact_phone'];
|
||||||
|
}
|
||||||
|
if (isset($_POST['contact_address'])) {
|
||||||
|
$updates[] = 'contact_address = ?';
|
||||||
|
$params[] = $_POST['contact_address'];
|
||||||
|
}
|
||||||
|
if (isset($_POST['website'])) {
|
||||||
|
$updates[] = 'website = ?';
|
||||||
|
$params[] = $_POST['website'];
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update current step
|
||||||
|
if (isset($_POST['current_step'])) {
|
||||||
|
$updates[] = 'current_step = ?';
|
||||||
|
$params[] = intval($_POST['current_step']);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Mark as completed if requested
|
||||||
|
if (isset($_POST['complete'])) {
|
||||||
|
$updates[] = 'completed = 1';
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!empty($updates)) {
|
||||||
|
$sql = "UPDATE onboarding_sessions SET " . implode(', ', $updates) . " WHERE session_token = ?";
|
||||||
|
$params[] = $token;
|
||||||
|
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
$stmt->execute($params);
|
||||||
|
|
||||||
|
echo json_encode(['success' => true]);
|
||||||
|
} else {
|
||||||
|
echo json_encode(['success' => true, 'message' => 'No updates']);
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
http_response_code(500);
|
||||||
|
echo json_encode(['error' => 'Database error: ' . $e->getMessage()]);
|
||||||
|
}
|
||||||
16
src/db.php
Normal file
16
src/db.php
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<?php
|
||||||
|
// Shared database connection
|
||||||
|
try {
|
||||||
|
$pdo = new PDO(
|
||||||
|
'mysql:host=' . getenv('DB_HOST') . ';port=' . getenv('DB_PORT') . ';dbname=' . getenv('DB_DATABASE') . ';charset=utf8mb4',
|
||||||
|
getenv('DB_USERNAME'),
|
||||||
|
getenv('DB_PASSWORD'),
|
||||||
|
[
|
||||||
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||||
|
PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
|
||||||
|
PDO::ATTR_EMULATE_PREPARES => false
|
||||||
|
]
|
||||||
|
);
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
die('Database connection failed: ' . $e->getMessage());
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user