<?php include 'header.php'; ?>

<link rel="stylesheet" href="assets/admin/css/index.css" media="screen">
<script src="https://unpkg.com/@lottiefiles/lottie-player@latest/dist/lottie-player.js"></script>


<style>
.countdown-container {
    text-align: center;
    padding: 20px;
    border: 3px solid #ff4d4d;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    max-width: 500px;
    margin: 20px auto;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    width: 100%;
}

.countdown-timer {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 15px;
    flex-wrap: wrap;
}

.countdown-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    background: linear-gradient(145deg, #e6e6e6, #ffffff);
    color: #333;
    padding: 15px 10px;
    border-radius: 10px;
    width: 80px;
    text-align: center;
    font-weight: bold;
    font-size: 1em;
    box-shadow: 4px 4px 10px #bcbcbc, -4px -4px 10px #ffffff;
    transition: transform 0.2s ease-in-out;
    perspective: 200px;
}

.flip {
    animation: flip 0.6s ease-in-out;
}

@keyframes flip {
    0% { transform: rotateX(0deg); }
    50% { transform: rotateX(-90deg); opacity: 0.6; }
    100% { transform: rotateX(0deg); opacity: 1; }
}

.countdown-value {
    font-size: 2em;
}

.progress-container {
    width: 100%;
    background: #ddd;
    height: 8px;
    border-radius: 5px;
    margin-top: 10px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    width: 0%;
    background: green;
    transition: width 0.5s ease-in-out;
}

.renew-link {
    color: red;
    font-weight: bold;
    text-decoration: none;
}

button {
    margin-top: 10px;
    padding: 10px 20px;
    border: none;
    background: #333;
    color: white;
    font-size: 1em;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

button:hover {
    background: #555;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.8);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {opacity: 0;}
    to {opacity: 1;}
}

.modal-content {
    background: #fff;
    margin: 5% auto;
    padding: 25px;
    border-radius: 12px;
    width: 80%;
    max-width: 500px;
    box-shadow: 0 5px 30px rgba(0,0,0,0.3);
    animation: slideIn 0.4s;
}

@keyframes slideIn {
    from {transform: translateY(-50px); opacity: 0;}
    to {transform: translateY(0); opacity: 1;}
}

.close {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close:hover {
    color: #333;
}

.payment-method {
    margin: 20px 0;
    padding: 20px;
    border-radius: 8px;
    background: #f9f9f9;
    border: 1px solid #eee;
    transition: transform 0.3s, box-shadow 0.3s;
}

.payment-method:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.payment-method h3 {
    margin-top: 0;
    color: #333;
    display: flex;
    align-items: center;
    gap: 10px;
}

.payment-method h3 i {
    font-size: 1.2em;
}

.qr-code {

    margin: 15px auto;
    display: block;
    border: 1px solid #ddd;
    padding: 5px;
    background: white;
    border-radius: 8px;
    transition: transform 0.3s;
}



.payment-number {
    font-weight: bold;
    color: #e74c3c;
    font-size: 1.1em;
    margin: 15px 0;
    background: #f8f8f8;
    padding: 10px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    border: 1px dashed #e74c3c;
}

.copy-btn {
    background: #3498db;
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
    transition: all 0.3s;
}

.copy-btn:hover {
    background: #2980b9;
}

.copy-btn i {
    font-size: 0.9em;
}

.whatsapp-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #25D366;
    color: white;
    padding: 12px 20px;
    border-radius: 5px;
    text-decoration: none;
    margin-top: 15px;
    font-weight: bold;
    transition: all 0.3s;
    width: 100%;
    max-width: 250px;
}

.whatsapp-btn:hover {
    background: #128C7E;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.payment-options {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 15px;
}

.payment-option {
    background: #f1f1f1;
    padding: 8px 15px;
    border-radius: 20px;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 5px;
}

.payment-option i {
    color: #e74c3c;
}

.pulse {
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.tooltip {
    position: relative;
    display: inline-block;
}

.tooltip .tooltiptext {
    visibility: hidden;
    width: 120px;
    background-color: #555;
    color: #fff;
    text-align: center;
    border-radius: 6px;
    padding: 5px;
    position: absolute;
    z-index: 1;
    bottom: 125%;
    left: 50%;
    margin-left: -60px;
    opacity: 0;
    transition: opacity 0.3s;
}

.tooltip .tooltiptext::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #555 transparent transparent transparent;
}

.tooltip:hover .tooltiptext {
    visibility: visible;
    opacity: 1;
}

/* Dark Mode */
.dark-mode .modal-content {
    background: #333;
    color: white;
}

.dark-mode .payment-method {
    background: #444;
    border-color: #555;
}

.dark-mode .payment-method h3 {
    color: white;
}

.dark-mode .close:hover {
    color: #ddd;
}

.dark-mode .payment-number {
    background: #555;
    border-color: #e74c3c;
}

.dark-mode .payment-option {
    background: #555;
    color: white;
}

/* Media Queries - More Responsive */
@media (max-width: 768px) {
    .countdown-container {
        padding: 15px;
        max-width: 90%;
    }

    .countdown-item {
        width: 70px;
        font-size: 1.1em;
    }

    .countdown-value {
        font-size: 1.8em;
    }

    button {
        padding: 10px 18px;
        font-size: 1em;
    }

    .modal-content {
        width: 90%;
        margin: 10% auto;
        padding: 20px;
    }



    .payment-method {
        padding: 15px;
    }
}

@media (max-width: 480px) {
    .countdown-container {
        padding: 12px;
        max-width: 95%;
    }

    .countdown-item {
        width: 60px;
        padding: 10px 5px;
        font-size: 0.9em;
    }

    .countdown-value {
        font-size: 1.5em;
    }

    .countdown-label {
        font-size: 0.8em;
    }

    .modal-content {
        width: 95%;
        padding: 15px;
    }



    .payment-number {
        font-size: 1em;
        padding: 8px;
        flex-direction: column;
        gap: 5px;
    }

    .whatsapp-btn {
        padding: 10px 15px;
        font-size: 0.9em;
    }

    .payment-options {
        flex-direction: column;
        align-items: center;
    }
}
</style>

<?php
// Assuming you're using PDO and already connected to the database
$query = "SELECT * FROM panel_info WHERE panel_id = 1";
$panel = $conn->prepare($query);
$panel->execute();
$panelInfo = $panel->fetch(PDO::FETCH_ASSOC);
$renewalDate = $panelInfo['renewal_date'];
$dateCreated = $panelInfo['date_created'];

$formattedDateCreated = date("d M Y", strtotime($dateCreated));
?>


<!-- Payment Modal -->
<div id="paymentModal" class="modal">
    <div class="modal-content">
        <span class="close">&times;</span>
        <h2 style="text-align: center; color: #e74c3c; margin-bottom: 25px;">
            <i class="fas fa-credit-card"></i> Payment Methods
        </h2>
        
        <!-- Mobile Banking Bangladesh -->
        <div class="payment-method">
            <h3><i class="fas fa-mobile-alt"></i> Mobile Banking (Bangladesh)</h3>
            
            <div class="payment-options">
                <div class="payment-option">
                    <i class="fas fa-money-bill-wave"></i> Bkash
                </div>
                <div class="payment-option">
                    <i class="fas fa-money-bill-wave"></i> Nagad
                </div>
            </div>
            
            <p>Send payment to this Personal number:</p>
            <div class="payment-number">
                <span id="mobilePaymentNumber">01864614704</span>
                <button class="copy-btn" onclick="copyToClipboard('mobilePaymentNumber')">
                    <i class="far fa-copy"></i> Copy
                </button>
            </div>
            
            <p style="font-size: 0.9em; color: #666; margin-top: 5px;">
                <i class="fas fa-info-circle"></i> After payment, please send the transaction ID
            </p>
            
            <a href="https://wa.me/8801864614704?text=I%20have%20sent%20the%20payment%20via%20Mobile%20Banking.%20Transaction%20ID:%20" 
               class="whatsapp-btn" target="_blank">
               <i class="fab fa-whatsapp"></i> Confirm Payment
            </a>
        </div>
        
        <!-- Binance Global Payment -->
        <div class="payment-method">
            <h3><i class="fab fa-bitcoin"></i> Binance (Global Payment)</h3>
            
            <img src="https://i.postimg.cc/L61sR35f/Whats-App-Image-2025-04-20-at-8-45-41-PM.jpg" 
                 alt="Binance QR Code" class="qr-code">
                 
            <p>Send to Binance Pay ID:</p>
            <div class="payment-number">
                <span id="binanceGlobalId">870215389</span>
                <button class="copy-btn" onclick="copyToClipboard('binanceGlobalId')">
                    <i class="far fa-copy"></i> Copy
                </button>
            </div>
            
            <a href="https://wa.me/8801864614704?text=I%20have%20sent%20the%20payment%20via%20Binance%20(Global).%20Transaction%20ID:%20" 
               class="whatsapp-btn" target="_blank" style="background: #F0B90B; color: #000;">
               <i class="fab fa-whatsapp"></i> Confirm Payment
            </a>
        </div>
        
        <div style="text-align: center; margin-top: 20px; font-size: 0.9em; color: #666;">
            <i class="fas fa-info-circle"></i> Please include your account details when confirming payment
        </div>
    </div>
</div>

<script>
var renewalDate = "<?php echo $renewalDate; ?>";

// Get the modal elements
var modal = document.getElementById("paymentModal");
var btn = document.getElementById("payNowBtn");
var span = document.getElementsByClassName("close")[0];

// When the user clicks the button, open the modal 
btn.onclick = function() {
    modal.style.display = "block";
    document.body.style.overflow = "hidden"; // Prevent scrolling when modal is open
}

// When the user clicks on <span> (x), close the modal
span.onclick = function() {
    modal.style.display = "none";
    document.body.style.overflow = "auto"; // Re-enable scrolling
}

// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) {
    if (event.target == modal) {
        modal.style.display = "none";
        document.body.style.overflow = "auto"; // Re-enable scrolling
    }
}

// Copy to clipboard function
function copyToClipboard(elementId) {
    var copyText = document.getElementById(elementId);
    var textArea = document.createElement("textarea");
    textArea.value = copyText.textContent;
    document.body.appendChild(textArea);
    textArea.select();
    document.execCommand("Copy");
    textArea.remove();
    
    // Show tooltip or alert
    alert("Copied: " + copyText.textContent);
}

function updateCountdown() {
    var countDownDate = new Date(renewalDate).getTime();
    var now = new Date().getTime();
    var distance = countDownDate - now;

    const alertBox = document.getElementById("alert-box");
    const countdownContainer = document.getElementById("countdown-container");

    // Change background color based on days remaining
    var daysRemaining = Math.floor(distance / (1000 * 60 * 60 * 24));

    if (daysRemaining <= 0) {
        countdownContainer.style.display = "none"; // Hide countdown when expired
        alertBox.style.display = "block"; // Show alert
        clearInterval(x);
        return;
    } else if (daysRemaining <= 5) {
        countdownContainer.style.borderColor = "#ff9900";
        countdownContainer.style.background = "rgba(255, 153, 0, 0.1)";
    } else if (daysRemaining <= 10) {
        countdownContainer.style.borderColor = "#ffcc00";
        countdownContainer.style.background = "rgba(255, 204, 0, 0.1)";
    } else {
        countdownContainer.style.borderColor = "#4CAF50";
        countdownContainer.style.background = "rgba(76, 175, 80, 0.1)";
    }

    var days = Math.floor(distance / (1000 * 60 * 60 * 24));
    var hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60));
    var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60));
    var seconds = Math.floor((distance % (1000 * 60)) / 1000);

    // Add flip animation when values change
    if (document.getElementById("days").textContent != (days < 10 ? "0" + days : days)) {
        document.getElementById("days").classList.add("flip");
        setTimeout(() => document.getElementById("days").classList.remove("flip"), 600);
    }
    if (document.getElementById("hours").textContent != (hours < 10 ? "0" + hours : hours)) {
        document.getElementById("hours").classList.add("flip");
        setTimeout(() => document.getElementById("hours").classList.remove("flip"), 600);
    }
    if (document.getElementById("minutes").textContent != (minutes < 10 ? "0" + minutes : minutes)) {
        document.getElementById("minutes").classList.add("flip");
        setTimeout(() => document.getElementById("minutes").classList.remove("flip"), 600);
    }
    if (document.getElementById("seconds").textContent != (seconds < 10 ? "0" + seconds : seconds)) {
        document.getElementById("seconds").classList.add("flip");
        setTimeout(() => document.getElementById("seconds").classList.remove("flip"), 600);
    }

    document.getElementById("days").textContent = (days < 10 ? "0" + days : days);
    document.getElementById("hours").textContent = (hours < 10 ? "0" + hours : hours);
    document.getElementById("minutes").textContent = (minutes < 10 ? "0" + minutes : minutes);
    document.getElementById("seconds").textContent = (seconds < 10 ? "0" + seconds : seconds);
}

// Initialize countdown immediately and set interval
updateCountdown(); // Call immediately
var x = setInterval(updateCountdown, 1000);
</script>


<br>

<div class="container-fluid">
       <ul class="nav nav-tabs p-b d-block">
	<li class="active "><a href="/<?= $secure_admin ?>/index">Summary</a></li>
          <li class=""><a href="/<?= $secure_admin ?>/analytics">Analytics <span id="newUpdates" class="label label-danger">NEW</span></a></li>

</ul> 
   <div class="row">
       
<div class="col-lg-3 col-md-6">
    <div class="panel panel-green">
        <div class="panel-heading">
            <div class="row">
                <div class="col-xs-3">
                    <div class="icon">
                        <lottie-player src="https://lottie.host/a5817291-bcbd-4bb9-a8d1-2b5dc4193976/D7Omky22uC.json" background="transparent" speed="1" style="width: 70px; height: 70px;" loop="" autoplay=""></lottie-player>
                    </div>
                </div>
                <div class="col-xs-9 text-right">
                    <!-- Today Count for Users -->
                    <div><span class="fw-bold">Today:</span>
                        <?php 
                            $clients = $conn->prepare("SELECT * FROM clients");
                            $clients->execute();
                            $clients = $clients->fetchAll(PDO::FETCH_ASSOC);
                            $today = date('Y-m-d');
                            $count_today_users = 0;

                            foreach ($clients as $client) {
                                $register_date = explode(" ", $client["register_date"])[0];
                                if ($register_date == $today) {
                                    $count_today_users++;
                                }
                            }
                        ?>
                        <span class="mb-0 mr-2"><?= $count_today_users ?></span>
                    </div>

                    <!-- Total Registered Users -->
                    <div class="huge">Total Registered Users: <?php echo countRow(["table"=>"clients"]) ?></div>
                   
                </div>
            </div>
        </div>
        <a href="<?php echo site_url("$secure_admin/") ?>clients">
            <div class="panel-footer">
                <span class="pull-left">See in Detail</span>
                <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                <div class="clearfix"></div>
            </div>
        </a>
    </div>
</div>

<div class="col-lg-3 col-md-6">
    <div class="panel panel-green">
        <div class="panel-heading">
            <div class="row">
                <div class="col-xs-3">
                    <div class="icon">
                        <lottie-player src="https://lottie.host/d8c39f43-d8b0-4f13-af6c-e968b824d568/IowHHOO2nX.json" background="transparent" speed="1" style="width: 70px; height: 70px;" loop="" autoplay=""></lottie-player>
                    </div>
                </div>
                <div class="col-xs-9 text-right">
                    <!-- Today Count for Orders -->
                    <div><span class="fw-bold">Today:</span>
                        <?php 
                            $orders = $conn->prepare("SELECT * FROM orders");
                            $orders->execute();
                            $orders = $orders->fetchAll(PDO::FETCH_ASSOC);
                            $count_today_orders = 0;

                            foreach ($orders as $order) {
                                $order_date = explode(" ", $order["order_create"])[0];
                                if ($order_date == $today) {
                                    $count_today_orders++;
                                }
                            }
                        ?>
                        <span class="mb-0 mr-2"><?= $count_today_orders ?></span>
                    </div>

                    <!-- Total Orders -->
                    <div class="huge">Total Orders: <?php echo countRow(["table"=>"orders"]) ?></div>
                    
                </div>
            </div>
        </div>
        <a href="<?php echo site_url("$secure_admin/") ?>orders">
            <div class="panel-footer">
                <span class="pull-left">See in Detail</span>
                <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                <div class="clearfix"></div>
            </div>
        </a>
    </div>
</div>

      
                  <div class="col-lg-3 col-md-6">
         <div class="panel panel-green">
            <div class="panel-heading">
               <div class="row">
                  <div class="col-xs-3">
                                                                      <div class="icon">
                                <lottie-player src="https://lottie.host/ecde3792-8837-44df-9c8e-46f7806f81fe/dtxQBfW460.json" background="transparent" speed="1" style="width: 70px; height: 70px;" loop="" autoplay=""></lottie-player>
                            </div>
                    
                  </div>
                  <div class="col-xs-9 text-right">
                     <div class="huge"><?php echo countRow(["table"=>"services"]) ?></div>
                     <div>Total Active Services</div>
                  </div>
               </div>
            </div>
            <a href="<?php echo site_url("$secure_admin/") ?>services">
               <div class="panel-footer">
                  <span class="pull-left">See in Detail</span>
                  <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                  <div class="clearfix"></div>
               </div>
            </a>
         </div>
      </div>
      
      
                        <div class="col-lg-3 col-md-6">
         <div class="panel panel-green">
            <div class="panel-heading">
               <div class="row">
                  <div class="col-xs-3">
                                                                      <div class="icon">
                                <lottie-player src="https://lottie.host/0e48af0f-2d67-417b-967b-81c349a07178/QOpovtLCht.json" background="transparent" speed="1" style="width: 70px; height: 70px;" loop="" autoplay=""></lottie-player>
                            </div>
                    
                  </div>
                  <div class="col-xs-9 text-right">
                     <div class="huge"><?php echo countRow(["table"=>"categories","where"=>["category_deleted"=>0]]) ?></div>
                     <div>Total Active categories</div>
                  </div>
               </div>
            </div>
            <a href="<?php echo site_url("$secure_admin/") ?>services">
               <div class="panel-footer">
                  <span class="pull-left">See in Detail</span>
                  <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                  <div class="clearfix"></div>
               </div>
            </a>
         </div>
      </div>
      
      <div class="col-lg-3 col-md-6">
         <div class="panel panel-green">
            <div class="panel-heading">
               <div class="row">
                  <div class="col-xs-3">
                                                                                           <div class="icon">
                                <lottie-player src="https://lottie.host/58bf5fdc-58c5-41ae-9a7a-9829cf424731/qTp2dU6c83.json" background="transparent" speed="1" style="width: 70px; height: 70px;" loop="" autoplay=""></lottie-player>
                            </div>
                  </div>
                  <div class="col-xs-9 text-right">
                     <div class="huge"><?php echo $failCount ?></div>
                     <div>Orders Failed</div>
                  </div>
               </div>
            </div>
            <a href="<?php echo site_url("$secure_admin/") ?>orders/1/fail">
               <div class="panel-footer">
                  <span class="pull-left">See in Detail</span>
                  <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                  <div class="clearfix"></div>
               </div>
            </a>
         </div>
      </div>
      <div class="col-lg-3 col-md-6">
         <div class="panel panel-yellow">
            <div class="panel-heading">
               <div class="row">
                  <div class="col-xs-3">
                                                                     <div class="icon">
                                <lottie-player src="https://lottie.host/0819cfe7-ec51-4821-bf2a-a6ff6cb938a8/drhrzEwmsY.json" background="transparent" speed="1" style="width: 70px; height: 70px;" loop="" autoplay=""></lottie-player>
                            </div>
                  </div>
                  <div class="col-xs-9 text-right">
                     <div class="huge">                    <?php 
                        echo $settings["site_currency"];
                        $today_start = date('Y-m-d 00:00:00');
                        $today_end = date('Y-m-d 23:59:59');
                        $query = $conn->prepare("SELECT SUM(payment_amount) as total FROM payments 
                                                 WHERE payment_create_date BETWEEN :start AND :end 
                                                 AND payment_status = 3");
                        $query->execute(["start" => $today_start, "end" => $today_end]);
                        $result = $query->fetch(PDO::FETCH_ASSOC);
                        echo $result['total'] ? $result['total'] : 0;
                    ?></div>
                     <div>Total Funds Added Today</div>
                  </div>
               </div>
            </div>
             <a href="<?php echo site_url("$secure_admin/") ?>fund-add-history">
               <div class="panel-footer">
                  <span class="pull-left">See in Detail</span>
                  <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                  <div class="clearfix"></div>
               </div>
           </a>
         </div>
      </div>
      <div class="col-lg-3 col-md-6">
         <div class="panel panel-red">
            <div class="panel-heading">
               <div class="row">
                  <div class="col-xs-3">
                                                                                                                <div class="icon">
                                <lottie-player src="https://lottie.host/fc016248-d942-4fcf-b061-408ab32b0b8d/gp7rrJJguh.json" background="transparent" speed="1" style="width: 70px; height: 70px;" loop="" autoplay=""></lottie-player>
                            </div>
                  </div>
                  <div class="col-xs-9 text-right">
                     <div class="huge"><?php echo countRow(["table"=>"tickets","where"=>["client_new"=>2]]); ?></div>
                     <div>Pending Support Tickets</div>
                  </div>
               </div>
            </div>
            <a href="<?php echo site_url("$secure_admin/") ?>tickets?search=unread">
               <div class="panel-footer">
                  <span class="pull-left">See in Detail</span>
                  <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                  <div class="clearfix"></div>
               </div>
            </a>
         </div>
      </div>
      
            <div class="col-lg-3 col-md-6">
         <div class="panel panel-red">
            <div class="panel-heading">
               <div class="row">
                  <div class="col-xs-3">
                                                                                                                <div class="icon">
                                <lottie-player src="https://cdn.lordicon.com/cosvjkbu.json" background="transparent" speed="1" style="width: 70px; height: 70px;" loop="" autoplay=""></lottie-player>
                            </div>
                  </div>
                  <div class="col-xs-9 text-right">
                     <div class="huge"><?php echo $settings["panel_orders"]; ?></div>
                     <div>Total Orders with fake orders</div>
                  </div>
               </div>
            </div>
            <a href="<?php echo site_url("$secure_admin/") ?>tickets?search=unread">
               <div class="panel-footer">
                  <span class="pull-left">See in Detail</span>
                  <span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
                  <div class="clearfix"></div>
               </div>
            </a>
         </div>
      </div>
      
   </div>


<div class="container-fluid">
   <div class="row">
     
         <div class="panel panel-default">         

            <!-- /.panel-heading -->
            <div class="panel-body">
                   <h4 class="log-title">Website Logs</h4>
               <div class="table-responsive">
                  <table class="table">
                     <thead>
                        <tr>
                          <th class="checkAll-th">
                             <div class="checkAll-holder">
                                <input type="checkbox" id="checkAll">
                                <input type="hidden" id="checkAllText" value="order">
                             </div>
                             <div class="action-block">
                                <ul class="action-list" style="margin:5px 0 0 0!important">
                                   <li><span class="countOrders"></span> log selected</li>
                                   <li>
                                      <div class="dropdown">
                                         <button type="button" class="btn btn-default btn-xs dropdown-toggle btn-xs-caret" data-toggle="dropdown"> batch operations <span class="caret"></span></button>
                                         <ul class="dropdown-menu">
                                            <li>
                                              <a class="bulkorder" data-type="delete">delete</a>
                                            </li>
                                         </ul>
                                      </div>
                                   </li>
                                </ul>
                             </div>
                          </th>
                           <th>Username</th>
                           <th>Detail</th>
                           <th>IP Address</th>
                           <th>Date</th>
                        </tr>
                     </thead>
                     <form id="changebulkForm" action="<?php echo site_url("$secure_admin/logs/multi-action") ?>" method="post">
    <tbody>
        <?php if( !$logs ): ?>
            <tr>
                <td colspan="4"><center>No logs found</center></td>
            </tr>
        <?php endif; ?>
        <?php foreach($logs as $log): ?>
        <tr>
            <td><input type="checkbox" class="selectOrder" name="log[<?php echo $log["id"] ?>]" value="1" style="border:1px solid #fff"></td>
            <td><?php echo $log["username"] ?></td>
            <td><?php echo $log["action"] ?></td>
            <?php


            $ip = $log["report_ip"];
            $location_data = getLocationFromIP($ip); 

            $city = $location_data['city'] ?? 'Unknown';
            $region = $location_data['region'] ?? 'Unknown';
            $country = $location_data['country'] ?? 'Unknown';

            echo "<td>{$city}, {$region}, {$country} <a href='https://www.ip-tracker.org/locator/ip-lookup.php?ip={$ip}' target='_blank'><i class='fa fa-search'></i></a></td>";
            ?>
            <td><?php echo date('F j, Y, g:i a', strtotime($log["report_date"])); ?></td>
        </tr>
        <?php endforeach; ?>
    </tbody>
    <input type="hidden" name="bulkStatus" id="bulkStatus" value="0">
</form>

                  </table>
               </div>
            </div>
         </div>
         <?php if( $paginationArr["count"] > 1 ): ?>
           <div class="row">
              <div class="col-sm-8">
                 <nav>
                    <ul class="pagination">
                      <?php if( $paginationArr["current"] != 1 ): ?>
                       <li class="prev"><a href="<?php echo site_url("$secure_admin/logs/1/".$search_link) ?>">&laquo;</a></li>
                       <li class="prev"><a href="<?php echo site_url("$secure_admin/logs/".$paginationArr["previous"]."/".$search_link) ?>">&lsaquo;</a></li>
                       <?php
                           endif;
                           for ($page=1; $page<=$pageCount; $page++):
                             if( $page >= ($paginationArr['current']-9) and $page <= ($paginationArr['current']+9) ):
                       ?>
                       <li class="<?php if( $page == $paginationArr["current"] ): echo "active"; endif; ?> "><a href="<?php echo site_url("$secure_admin/logs/".$page."/".$status.$search_link) ?>"><?=$page?></a></li>
                       <?php endif; endfor;
                             if( $paginationArr["current"] != $paginationArr["count"] ):
                       ?>
                       <li class="next"><a href="<?php echo site_url("$secure_admin/logs/".$paginationArr["next"]."/".$search_link) ?>" data-page="1">&rsaquo;</a></li>
                       <li class="next"><a href="<?php echo site_url("$secure_admin/logs/".$paginationArr["count"]."/".$search_link) ?>" data-page="1">&raquo;</a></li>
                       <?php endif; ?>
                    </ul>
                 </nav>
              </div>
           </div>
         <?php endif; ?>
      </div>
   </div>
</div>

<div class="modal modal-center fade" id="confirmChange" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" data-backdrop="static">
   <div class="modal-dialog modal-dialog-center" role="document">
      <div class="modal-content">
         <div class="modal-body text-center">
            <h4>Are you sure you want to perform the operation??</h4>
            <div align="center">
               <a class="btn btn-primary" href="" id="confirmYes">Yes</a>
               <button type="button" class="btn btn-default" data-dismiss="modal">No</button>
            </div>
         </div>
      </div>
   </div>
</div>











<?php include 'footer.php'; ?>
