#!/bin/bash
# ============================================
# JBR Sofa - Live Deployment Helper Script
# ============================================
# This script helps prepare the application for deployment

echo ""
echo "============================================"
echo "JBR Sofa - Deployment Checker"
echo "============================================"
echo ""

# Check if config.php exists
if [ -f config.php ]; then
    echo "[OK] config.php found"
else
    echo "[ERROR] config.php not found"
fi

# Check if .env file exists
if [ -f .env ]; then
    echo "[OK] .env file found"
else
    echo "[WARNING] .env file not found - copy from .env.example"
fi

# Check if database.sql exists
if [ -f database.sql ]; then
    echo "[OK] database.sql found"
else
    echo "[ERROR] database.sql not found"
fi

# Check if vendor exists
if [ -d vendor ]; then
    echo "[OK] vendor directory found"
else
    echo "[ERROR] vendor directory not found - run: composer install --no-dev"
fi

# Check if temp directory exists
if [ -d temp ]; then
    echo "[OK] temp directory found"
else
    echo "[WARNING] Creating temp directory..."
    mkdir -p temp
    chmod 755 temp
    echo "[OK] temp directory created"
fi

# Check includes
echo ""
echo "Checking core files..."
if [ -f includes/db.php ]; then
    echo "[OK] includes/db.php found"
else
    echo "[ERROR] includes/db.php not found"
fi

if [ -f includes/functions.php ]; then
    echo "[OK] includes/functions.php found"
else
    echo "[ERROR] includes/functions.php not found"
fi

if [ -f includes/header.php ]; then
    echo "[OK] includes/header.php found"
else
    echo "[ERROR] includes/header.php not found"
fi

echo ""
echo "============================================"
echo "Checklist:"
echo "============================================"
echo "[ ] 1. Copy .env.example to .env"
echo "[ ] 2. Update .env with live server database credentials"
echo "[ ] 3. Upload all files to live server"
echo "[ ] 4. Create database on live server using database.sql"
echo "[ ] 5. Set correct file permissions (755 for temp, 644 for error_log)"
echo "[ ] 6. Test at https://bismitrichy.com/jbrsofa"
echo "[ ] 7. Check error_log for any issues"
echo ""
echo "For detailed instructions, see DEPLOYMENT.md"
echo ""
