<?php
session_start();
$basePath = dirname(__DIR__);
if (file_exists($basePath . '/config.php') || file_exists($basePath . '/install/install.lock')) { die('Installer is locked. To reinstall safely, back up the database, remove config.php and install/install.lock manually, then reload this page.'); }
if (empty($_SESSION['db_host'])) { header('Location: step4.php'); exit; }

$step = 7;
$stepNames = ['Welcome', 'Requirements', 'Permissions', 'Database', 'Import', 'Academy', 'Banking', 'Admin'];

if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    $_SESSION['banking_saved'] = true;
    header('Location: step8.php');
    exit;
}

$banks = [
    ['bank' => 'Standard Bank', 'account_name' => 'CIX CONNECT', 'account_number' => '10200349927', 'branch_code' => '051001'],
    ['bank' => 'Capitec Business', 'account_name' => 'CIX CONNECT', 'account_number' => '1051396964', 'branch_code' => '450105'],
    ['bank' => 'ABSA', 'account_name' => 'CIX CONNECT', 'account_number' => '4123963036', 'branch_code' => '632005'],
];
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>CIX Orbit Academy - Banking Details</title>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
    <link rel="stylesheet" href="assets/css/install.css">
</head>
<body>
<div class="installer-wrapper">
    <div class="installer-card">
        <div class="installer-header">
            <h1><i class="fas fa-orbit"></i> CIX <span>Orbit</span> Academy</h1>
            <p>Complete LMS &amp; Student Management System</p>
        </div>
        <div class="step-indicator">
            <?php for ($i = 1; $i <= 8; $i++): ?>
            <div class="step-dot <?= $i === $step ? 'active' : ($i < $step ? 'completed' : '') ?>">
                <?= $i < $step ? '<i class="fas fa-check"></i>' : $i ?>
                <span class="step-label"><?= $stepNames[$i-1] ?></span>
            </div>
            <?php endfor; ?>
        </div>
        <div class="installer-content">
            <h2><i class="fas fa-university" style="color:var(--cix-orange)"></i> Banking Details</h2>
            <p class="subtitle">These are the default banking details for student payments. You can edit them later in Settings.</p>
            
            <?php foreach ($banks as $b): ?>
            <div class="bank-card">
                <h4><i class="fas fa-landmark"></i> <?= $b['bank'] ?></h4>
                <p><strong>Account Name:</strong> <?= $b['account_name'] ?></p>
                <p><strong>Account Number:</strong> <?= $b['account_number'] ?></p>
                <p><strong>Branch Code:</strong> <?= $b['branch_code'] ?></p>
            </div>
            <?php endforeach; ?>
            
            <div class="alert alert-info">
                <i class="fas fa-info-circle"></i>
                <div>
                    <strong>Payment Instructions:</strong><br>
                    Use your student number as payment reference.<br>
                    Email proof of payment to: <strong>academic@cixconnect.co.za</strong><br>
                    WhatsApp proof of payment to: <strong>083 759 8075</strong>
                </div>
            </div>
            
            <form method="POST" action="step7.php">
                <div class="btn-group">
                    <a href="step6.php" class="btn btn-secondary"><i class="fas fa-arrow-left"></i> Back</a>
                    <button type="submit" class="btn btn-primary">Confirm &amp; Continue <i class="fas fa-arrow-right"></i></button>
                </div>
            </form>
        </div>
    </div>
</div>
<script src="assets/js/install.js"></script>
</body>
</html>
