<?php 

// Mengamankan koneksi database
include "../config/connect.php"; 
include '../hspages/action_path.php';
include "../config/whatsapp_api.php"; 
include "../list_data/sweetalert.php"; 
include "../config/tanggal_indo.php";

$stmt = $pdo->prepare("SELECT * FROM v_detail_agen_voucher WHERE id = :id");
$stmt->execute([':id' => $_SESSION['agen']]);
$pcmem = $stmt->fetch(PDO::FETCH_ASSOC);

$jenisAgen = $pcmem['jenis_agen'];


?>

<!DOCTYPE html>
<html lang="en">
    <head>
      <!-- basic -->
      <meta charset="utf-8">
      <meta http-equiv="X-UA-Compatible" content="IE=edge">
      <!-- mobile metas -->
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <meta name="viewport" content="initial-scale=1, maximum-scale=1">
      <!-- site metas -->
      <title>Agen Hotspot</title>
      <meta name="keywords" content="">
      <meta name="description" content="">
      <meta name="author" content="">
      <!-- bootstrap css -->
      <link rel="stylesheet" href="css/bootstrap.min.css">
      <!-- style css -->
      <link rel="stylesheet" href="css/style.css">
      <!-- Responsive-->
      <link rel="stylesheet" href="css/responsive.css">
      <!-- fevicon -->
      <link rel="icon" href="images/logo-sm.png" type="image/gif" />
      <!-- Scrollbar Custom CSS -->
      <!-- <script src="https://use.fontawesome.com/releases/v6.3.0/js/all.js" crossorigin="anonymous"></script> -->
       <link rel="stylesheet" href="css/owl.carousel.min.css"> 
      <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.css" media="screen">
      <link rel="stylesheet" href="https://rawgit.com/LeshikJanz/libraries/master/Bootstrap/baguetteBox.min.css">
      <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
    <link rel="stylesheet" href="css/fontawesome-free/css/all.min.css">
    <script src='https://cdn.jsdelivr.net/npm/sweetalert2@11'></script>
    <link rel="stylesheet" type="text/css" href="css/custom.css">

   </head>
   <!-- body onload="autorefresh('data/updatevoucher.php')" -->
<body class="main-layout" style=" zoom: 80%; background-color:  #fca503;">
    
<!--<p id="nomor"></p>-->
      <!-- loader  -->
<!-- <div class="loader_bg" style="background: rgba(0, 0, 0, 0.2);">
  <div class="loader"><img src="images/loading4.gif" style="width: 90px;" /></div>
</div> -->
  <?php
    if ($_SERVER['QUERY_STRING'] != '') 
    {
    $pag = base64_decode($_SERVER['QUERY_STRING']);
    $page = explode("|",$pag);

      $pages = $page[0];
    }
    else
    {
      $pages = 'Home';
    }
    //DATA Page
    $Page = new Pages();
    $Page->set_page($pages);
    include '../hspages/'.$Page->get_page().'.php';

 ?>
  <br><br><br>

<div class="modal fade" id="myModal" tabindex="-1" aria-labelledby="exampleModalLabel" aria-hidden="true">
    <div class="modal-dialog modal-dialog-centered">
        <div class="modal-content">
            <div class="modal-body text-center">
                <h4>INFORMASI</h4>
                <p class="text-danger">Saat ini anda masih menggunakan apk versi lama.</p>
                <h6>Untuk Update Aplikasi Terbaru, silahkan Download di Google Play Store</h6>
                <img src="images/play.png" width="90%" class="m-4">
                <a href="market://details?id=com.bilspro.appbilspro" target="_blank" class="btn btn-success">
                <!--<a href="https://play.google.com/store/apps/details?id=com.bilspro.appbilspro" target="_blank" class="btn btn-success">-->
                    <i class="fab fa-google-play"></i> Download di Play Store
                </a>
            </div>
        </div>
    </div>
</div>

<!-- Nav bawah -->
<nav class="navbar navbar-expand fixed-bottom" style="background: #ffffff; zoom: 90%; border-top: 1px solid; border-color: #fca503;">
  <ul class="navbar-nav nav-justified w-100">
    <li class="nav-item">
      <a href="?<?php echo base64_encode('changeprofile'); ?>" class="nav-link animated-link">
        <i class="fa fa-user fa-2x " style="color: #fca503;"></i><br><small style="color: #fca503;">Akun</small>
      </a>
    </li>
    <li class="nav-item" style="margin-top: -40px; margin-bottom: -20px;">
      <a href="?<?php echo base64_encode('Home'); ?>" class="nav-link animated-link">
        <span class="fa-stack fa-3x">
          <i class="fa fa-circle fa-2x" style="color: #fca503;"></i>
          <i class="fa fa-home fa-stack-1x fa-sm fa-inverse"></i>
        </span>
      </a>
    </li>
    <li class="nav-item">
      <a href="?<?php echo base64_encode('logout'); ?>" class="nav-link animated-link" id="logoutButton">
        <i class="fa fa-sign-out-alt fa-2x " style="color: #fca503;"></i><br><small style="color: #fca503;">Logout</small>
      </a>
    </li>
  </ul>
</nav>

      <!-- Javascript files-->
      <script src="js/jquery.min.js"></script>
      <script src="js/bootstrap.bundle.min.js"></script>
      <script src="js/owl.carousel.min.js"></script>
      <!-- <script src="js/custom.js"></script> -->

<script type="text/javascript">
    // // Fungsi untuk mengambil informasi perangkat
    // function FDeviceInfo() {
    //     try {
    //         // Memeriksa apakah objek Android tersedia
    //         if (window.Android && typeof Android.getDeviceInfo === "function") {
    //             // Memanggil Android.getDeviceInfo() untuk mendapatkan informasi perangkat
    //             var deviceInfo = Android.getDeviceInfo(); 
    //             console.log(deviceInfo); // Menampilkan info di konsol
    //         } else {
                
    //             // Menampilkan modal jika Android interface tidak tersedia
    //             const myModal = new bootstrap.Modal(document.getElementById('myModal'));
    //             myModal.show();
    //         }
    //     } catch (error) {
    //         // Tangani error jika ada masalah saat memanggil Android interface
    //         console.error("Error mendapatkan informasi perangkat:", error);
            
    //         // Menampilkan modal jika terjadi error
    //         const myModal = new bootstrap.Modal(document.getElementById('myModal'));
    //         myModal.show();
    //     }
    // }

    // // Memanggil fungsi FDeviceInfo() setelah halaman selesai dimuat
    // window.onload = function() {
    //     FDeviceInfo();
    // };
</script>
    
<script>
window.onscroll = function() {
    const card = document.querySelector('#specificCard'); // Ganti dengan ID atau kelas yang sesuai
    if (card) { // Periksa apakah elemen card ada
        if (document.body.scrollTop > 50 || document.documentElement.scrollTop > 50) {
            card.classList.add('scrolled-card');
        } else {
            card.classList.remove('scrolled-card');
        }
    }
};

let lastScrollTop = 0;
const navbar = document.getElementById('navbar');

if (navbar) { // Periksa apakah elemen navbar ada
    window.addEventListener('scroll', function() {
        const currentScroll = window.pageYOffset || document.documentElement.scrollTop;

        if (currentScroll > lastScrollTop) {
            // Scroll Down
            navbar.classList.add('hidden');
        } else {
            // Scroll Up
            navbar.classList.remove('hidden');
        }
        lastScrollTop = currentScroll <= 0 ? 0 : currentScroll; // Untuk Mobile or negative scrolling
    });
}
</script>
<script>
    document.addEventListener("DOMContentLoaded", function() {
        var rupiahInputs = document.querySelectorAll(".rupiah");

        // Tambahkan format Rupiah saat halaman dimuat
        rupiahInputs.forEach(function(input) {
            input.value = formatRupiah(input.value, "Rp. ");
        });

        // Event delegation untuk input dengan class rupiah
        document.body.addEventListener("input", function(e) {
            if (e.target.classList.contains("rupiah")) {
                e.target.value = formatRupiah(e.target.value, "Rp. ");
            }
        });
    });

    /* Fungsi formatRupiah */
    function formatRupiah(angka, prefix) {
        var number_string = angka.replace(/[^,\d]/g, "").toString(),
            split = number_string.split(","),
            sisa = split[0].length % 3,
            rupiah = split[0].substr(0, sisa),
            ribuan = split[0].substr(sisa).match(/\d{3}/gi);

        // Tambahkan titik jika angka sudah menjadi ribuan
        if (ribuan) {
            separator = sisa ? "." : "";
            rupiah += separator + ribuan.join(".");
        }

        rupiah = split[1] != undefined ? rupiah + "," + split[1] : rupiah;
        return prefix == undefined ? rupiah : rupiah ? prefix + rupiah : "";
    }
</script>
<script>
    document.getElementById('logoutButton').addEventListener('click', function() {
        // Hapus item dari localStorage
        localStorage.removeItem('token');
        localStorage.removeItem('handphone');
        
        //Simpan data user
        const data = {
          token: '',
          handphone: ''
        };
        AndroidInterface.saveData(JSON.stringify(data));

    });
</script>
<script>
    // const handphone = localStorage.getItem('handphone');
    // if (handphone) {
    //     document.getElementById('nomor').textContent = `Nomor Handphone: ${handphone}`;
    // } else {
    //     document.getElementById('nomor').textContent = 'Nomor handphone tidak ditemukan.';
    // }
    
    // console.log(handphone);
</script>

  </body>
</html>