<!DOCTYPE html>
<html lang="en">
<!--begin::Head-->

<head>
    <?php require $_SERVER['DOCUMENT_ROOT'].'/hethong/head2.php';?>
    <title>Lịch Sử Mua Miền | <?=$lxtdev['ten_web'];?></title>
    <?php require $_SERVER['DOCUMENT_ROOT'].'/hethong/nav.php';?>

    <!-- Nhúng bộ Icon FontAwesome phục vụ sơ đồ giao diện -->
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">

    <style>
        /* Card quản lý bảng tên miền cao cấp */
        .premium-domain-card {
            border: 1px solid rgba(0, 0, 0, 0.05) !important;
            border-radius: 16px !important;
            box-shadow: 0 10px 35px rgba(0, 0, 0, 0.02) !important;
            background: #ffffff;
            overflow: hidden;
        }
        [data-bs-theme="dark"] .premium-domain-card {
            background: #1e1e2d;
            border: 1px solid rgba(255, 255, 255, 0.05) !important;
            box-shadow: 0 10px 35px rgba(0, 0, 0, 0.2) !important;
        }

        .custom-domain-table thead tr {
            background: rgba(48, 133, 214, 0.04) !important;
            border-bottom: 2px solid rgba(48, 133, 214, 0.1) !important;
        }
        [data-bs-theme="dark"] .custom-domain-table thead tr {
            background: rgba(255, 255, 255, 0.02) !important;
            border-bottom: 2px solid rgba(255, 255, 255, 0.05) !important;
        }

        .custom-domain-table th {
            padding: 16px 12px !important;
            font-size: 0.85rem !important;
            letter-spacing: 0.5px;
        }

        .custom-domain-table td {
            padding: 16px 12px !important;
            vertical-align: middle !important;
            font-size: 0.95rem;
        }

        .custom-domain-table tbody tr {
            transition: background 0.2s ease;
        }
        .custom-domain-table tbody tr:hover {
            background: rgba(48, 133, 214, 0.01) !important;
        }

        .badge-index {
            background: #f4f6f9;
            color: #5e6278;
            padding: 4px 8px;
            border-radius: 6px;
            font-weight: 700;
        }
        [data-bs-theme="dark"] .badge-index {
            background: #2b2b40;
            color: #92929f;
        }

        .ns-code {
            font-family: monospace;
            font-size: 0.85rem;
            color: #4b5563;
            background: #f8fafc;
            padding: 2px 6px;
            border-radius: 4px;
            border: 1px solid #e2e8f0;
        }
        [data-bs-theme="dark"] .ns-code {
            color: #cbd5e1;
            background: #1f1f2e;
            border: 1px solid #32324d;
        }
    </style>
</head>

<body id="kt_app_body" data-kt-app-layout="light-sidebar" data-kt-app-header-fixed="true"
    data-kt-app-sidebar-enabled="true" data-kt-app-sidebar-fixed="true" data-kt-app-sidebar-hoverable="true"
    data-kt-app-sidebar-push-header="true" data-kt-app-sidebar-push-toolbar="true"
    data-kt-app-sidebar-push-footer="true" data-kt-app-toolbar-enabled="true" class="app-default">
    
    <script>var defaultThemeMode = "light"; var themeMode; if (document.documentElement) { if (document.documentElement.hasAttribute("data-bs-theme-mode")) { themeMode = document.documentElement.getAttribute("data-bs-theme-mode"); } else { if (localStorage.getItem("data-bs-theme") !== null) { themeMode = localStorage.getItem("data-bs-theme"); } else { themeMode = defaultThemeMode; } } if (themeMode === "system") { themeMode = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light"; } document.documentElement.setAttribute("data-bs-theme", themeMode); }</script>
    
    <div class="d-flex flex-column flex-root app-root" id="kt_app_root">
        <div class="app-page flex-column flex-column-fluid" id="kt_app_page">
            
            <div class="app-wrapper flex-column flex-row-fluid" id="kt_app_wrapper">
                <?php require $_SERVER['DOCUMENT_ROOT'].'/hethong/sider.php';?>
            </div>
            
            <div class="app-main flex-column flex-row-fluid" id="kt_app_main">
                <div class="d-flex flex-column flex-column-fluid">
                    
                    <!-- TOOLBAR TIÊU ĐỀ BREADCRUMB -->
                    <div id="kt_app_toolbar" class="app-toolbar py-3 py-lg-6">
                        <div id="kt_app_toolbar_container" class="app-container container-fluid d-flex flex-stack">
                            <div class="page-title d-flex flex-column justify-content-center flex-wrap me-3">
                                <h1 class="page-heading d-flex text-dark fw-bold fs-3 flex-column justify-content-center my-0">
                                    <i class="fa-solid fa-globe text-primary fs-4 mb-1"></i> Lịch Sử Đăng Ký Tên Miền
                                </h1>
                                <ul class="breadcrumb breadcrumb-separatorless fw-semibold fs-7 my-0 pt-1">
                                    <li class="breadcrumb-item text-muted"><a href="/" class="text-muted text-hover-primary">Home</a></li>
                                    <li class="breadcrumb-item"><span class="bullet bg-gray-400 w-5px h-2px"></span></li>
                                    <li class="breadcrumb-item text-muted">Bảng Tính Dịch Vụ</li>
                                </ul>
                            </div>
                            <div class="d-flex align-items-center gap-2 gap-lg-3">
                                <a href="#" class="btn btn-sm fw-bold btn-light-success px-4 py-3" data-bs-toggle="modal" data-bs-target="#kt_modal_create_app">
                                    <i class="fa-solid fa-wallet me-1"></i> <?=tien($user['money']);?>đ
                                </a>
                            </div>
                        </div>
                    </div>

                    <!-- NỘI DUNG LỊCH SỬ KÍCH HOẠT DOMAIN -->
                    <div class="content d-flex flex-column flex-column-fluid" id="kt_content">
                        <div class="container-xxl" id="kt_content_container">
                            
                            <div class="card premium-domain-card mb-5">
                                <!-- Card Header -->
                                <div class="card-header border-0 pt-6 bg-transparent">
                                    <div class="card-title">
                                        <div class="d-flex flex-column">
                                            <span class="fw-black text-dark fs-4 mb-1">Danh sách thông tin sở hữu Tên miền</span>
                                            <span class="text-muted fw-semibold fs-7"><i class="fa-regular fa-clock me-1"></i> Đồng bộ máy chủ cấp phát: <?=$time;?></span>
                                        </div>
                                    </div>
                                </div>
                                
                                <!-- Card Body / Datatable -->
                                <div class="card-body py-4">
                                    <div class="table-responsive">
                                        <table class="table custom-domain-table table-row-dashed align-middle gs-0 gy-4">
                                            <thead>
                                                <tr class="fw-bolder text-muted text-uppercase fs-8">
                                                    <th class="w-25px ps-3">
                                                        <div class="form-check form-check-sm form-check-custom form-check-solid">
                                                            <input class="form-check-input" type="checkbox" value="1" data-kt-check="true" data-kt-check-target=".widget-9-check" />
                                                        </div>
                                                    </th>
                                                    <th class="w-60px text-center">STT</th>
                                                    <th class="min-w-180px">Tên Miền</th>
                                                    <th class="min-w-100px text-center">Chu Kỳ</th>
                                                    <th class="min-w-130px text-center">Tổng Tiền</th>
                                                    <th class="min-w-180px text-center">NameServer Cấu Hình</th>
                                                    <th class="min-w-130px text-center">Trạng Thái</th>
                                                    <th class="min-w-140px text-center">Ngày Mua</th>
                                                    <th class="min-w-140px text-center">Ngày Hết Hạn</th>
                                                </tr>
                                            </thead>
                                            
                                            <tbody>
                                                <?php
                                                $i = 1;
                                                $result = mysqli_query($ketnoi, "SELECT * FROM `history_domain` WHERE `username` = '$username' ORDER BY `id` DESC");
                                                while($row = mysqli_fetch_assoc($result)) { 
                                                    $mien = $ketnoi->query("SELECT * FROM `ds_domain` WHERE `duoi_mien` = '".$row['duoi_mien']."' ")->fetch_array();
                                                ?>
                                                <!-- Đã sửa lỗi bổ sung thẻ mở TR chính xác -->
                                                <tr>
                                                    <td class="ps-3">
                                                        <div class="form-check form-check-sm form-check-custom form-check-solid">
                                                            <input class="form-check-input widget-9-check" type="checkbox" value="1" />
                                                        </div>
                                                    </td>

                                                    <td class="text-center">
                                                        <span class="badge-index"><?=$i++;?></span>
                                                    </td>

                                                    <td>
                                                        <a href="https://<?=$row['domain'];?>/" target="_blank" class="text-dark fw-black text-hover-primary fs-6 d-inline-flex align-items-center gap-2">
                                                            <i class="fa-solid fa-link text-muted fs-7"></i> <?=$row['domain'];?>
                                                        </a>
                                                    </td>

                                                    <td class="text-center text-gray-800 fw-bold fs-7">
                                                        1 Năm / Lần
                                                    </td>

                                                    <td class="text-center">
                                                        <span class="badge badge-light-success fw-black px-3 py-1.5 fs-7">
                                                            <?=tien($mien['gia']);?>đ
                                                        </span>
                                                    </td>

                                                    <td class="text-center">
                                                        <span class="ns-code">
                                                            <i class="fa-solid fa-network-wired me-1 opacity-50"></i> <?=$row['nameserver'];?>
                                                        </span>
                                                    </td>

                                                    <td class="text-center fw-bold">
                                                        <?=status($row['status']);?>
                                                    </td>

                                                    <td class="text-center text-gray-600 fw-semibold fs-7">
                                                        <?=ngay($row['ngay_mua']);?>
                                                    </td>

                                                    <td class="text-center text-danger fw-semibold fs-7">
                                                        <?=ngay($row['ngay_het']);?>
                                                    </td>
                                                </tr>
                                                <?php } ?>
                                            </tbody>
                                        </table>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>

                </div>
                <!--end::Content wrapper-->
                
                <?php require $_SERVER['DOCUMENT_ROOT'].'/hethong/foot.php';?>
            </div>
            <!--end:::Main-->
        </div>
    </div>
</body>
</html>
