<?php
session_start();
include("connection.php");
$user_profile = $_SESSION['user_name'];
// if ($user_profile == true) {
// } else {
//     header('location:index.php');
// }
?>
<?php
include("includes/header.php");
include("includes/sidebar.php");
?>
<div class="app-main__outer">
    <div class="app-main__inner">
        <div class="app-page-title">
            <div class="page-title-wrapper">
                <div class="page-title-heading">
                    <div class="page-title-icon">
                        <i class="fas fa-tachometer-alt"></i>

                    </div>
                    <div>Admin Dashboard

                    </div>
                </div>
                <div class="page-title-actions">
                    <button type="button" data-toggle="tooltip" title="Example Tooltip" data-placement="bottom" class="btn-shadow mr-3 btn btn-dark">
                        <i class="fa fa-star"></i>
                    </button>

                </div>
            </div>
        </div>

        <div class="row">
            <div class="col-md-12">
                <div class="main-card mb-3 card">
                    <div class="card-header">Header/Footer
                        <div class="btn-actions-pane-right">
                            <div role="group" class="btn-group-sm btn-group">
                                <a href="create_header_footer.php">
                                    <button class="active btn btn-focus">Add</button>
                                </a>
                            </div>
                        </div>
                    </div>
                    <div class="table-responsive">
                        <table id="main-category-table"
                            class="align-middle mb-0 table table-borderless table-striped table-hover">
                            <thead>
    <tr>
        <th class="text-center">ID</th>
        <th class="text-center">Site Name</th>
        <th class="text-center">Logo</th>
        <th class="text-center">Logo Text</th>
        <th class="text-center">Email</th>
        <th class="text-center">Phone</th>
        <th class="text-center">Address</th>
        <th class="text-center">Footer Text</th>
        <th class="text-center">Actions</th>
    </tr>
</thead>
<tbody>
    <?php
    $i = 1;
    include("connection.php");
    $sql = "SELECT * FROM settings";
    $result = mysqli_query($conn, $sql);
    if ($result) {
        while ($row = mysqli_fetch_assoc($result)) {
            $id = $row['id'];
            $site_name = $row['site_name'];
            $logo = $row['logo'];
            $logo_text = $row['logo_text'];
            $email = $row['email'];
            $phone = $row['phone'];
            $address = $row['address'];
            $footer_text = $row['footer_text'];
            echo '
            <tr>
                <td class="text-center text-muted">' . $i . '</td>
                <td class="text-center">' . $site_name . '</td>
                <td class="text-center"><img src="' . $logo . '" alt="Logo" style="width: 50px; height: 50px;"></td>
                <td class="text-center">' . $logo_text . '</td>
                <td class="text-center">' . $email . '</td>
                <td class="text-center">' . $phone . '</td>
                <td class="text-center">' . $address . '</td>
                <td class="text-center">' . $footer_text . '</td>
                <td class="text-center">
                    <button type="button" class="btn btn-primary btn-sm">
                        <a href="update_header_Footer.php?update_id=' . $id . '" style="color: white;">Update</a>
                    </button>
                    <button type="button" class="btn btn-danger btn-sm">
                        <a href="delete_header_footer.php?delete_id=' . $id . '" style="color: white;">Delete</a>
                    </button>
                </td>
            </tr>';
            $i++;
        }
    }
    ?>
</tbody>

                        </table>
                    </div>
                </div>
            </div>
        </div>
        <script>
            $(document).ready(function() {
                $('#main-category-table').DataTable();
            });
        </script>
    </div>

    <?php
    include("includes/footer.php");
    ?>