<?php
require_once '../../includes/config.php';
require_once '../../includes/db.php';
require_once '../../includes/functions.php';
require_once '../includes/admin-functions.php';

// Provera da li je korisnik prijavljen kao admin
if (!is_admin()) {
    header('Location: /admin/login.php');
    exit;
}

// Naslov stranice
$page_title = 'Podešavanja';

// Uključivanje header-a
require_once '../includes/header.php';
?>

<div class="content-header">
    <div class="container-fluid">
        <div class="row mb-2">
            <div class="col-sm-6">
                <h1 class="m-0">Podešavanja</h1>
            </div>
            <div class="col-sm-6">
                <ol class="breadcrumb float-sm-right">
                    <li class="breadcrumb-item"><a href="/admin/">Kontrolna tabla</a></li>
                    <li class="breadcrumb-item active">Podešavanja</li>
                </ol>
            </div>
        </div>
    </div>
</div>

<section class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-3">
                <div class="card">
                    <div class="card-header">
                        <h3 class="card-title">Kategorije podešavanja</h3>
                    </div>
                    <div class="card-body p-0">
                        <ul class="nav nav-pills flex-column">
                            <li class="nav-item">
                                <a href="/admin/settings/general.php" class="nav-link">
                                    <i class="fas fa-cog mr-2"></i> Opšta podešavanja
                                </a>
                            </li>
                            <li class="nav-item">
                                <a href="/admin/settings/payment.php" class="nav-link">
                                    <i class="fas fa-credit-card mr-2"></i> Načini plaćanja
                                </a>
                            </li>
                            <li class="nav-item">
                                <a href="/admin/settings/shipping.php" class="nav-link">
                                    <i class="fas fa-truck mr-2"></i> Dostava
                                </a>
                            </li>
                            <li class="nav-item">
                                <a href="/admin/settings/email.php" class="nav-link">
                                    <i class="fas fa-envelope mr-2"></i> Email podešavanja
                                </a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="col-md-9">
                <div class="card">
                    <div class="card-header">
                        <h3 class="card-title">Brzi pregled</h3>
                    </div>
                    <div class="card-body">
                        <div class="row">
                            <div class="col-md-6">
                                <h5>Opšta podešavanja</h5>
                                <p>Naziv sajta: <?php echo get_setting('site_name', 'Hugong Aparati'); ?></p>
                                <p>Email kontakt: <?php echo get_setting('contact_email', 'N/A'); ?></p>
                            </div>
                            <div class="col-md-6">
                                <h5>Plaćanje</h5>
                                <p>Aktivni načini plaćanja: 
                                    <?php 
                                    $payment_methods = get_setting('active_payment_methods', '');
                                    echo !empty($payment_methods) ? implode(', ', explode(',', $payment_methods)) : 'Nijeden';
                                    ?>
                                </p>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</section>

<?php require_once '../includes/footer.php'; ?>