<?php
	session_start();
	if($_SESSION['unohs'] == null){
		header("location:index.php?msg=unauthorized");
	}	
	date_default_timezone_set("Asia/Kolkata");
?>
<?php 
	include ("conn.php");
	
	$curdate = date('Y-m-d h:i:s');
?>
<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
  <title>Dashboard</title>
  <link rel="stylesheet" href="vendors/mdi/css/materialdesignicons.min.css">
  <link rel="stylesheet" href="vendors/feather/feather.css">
  <link rel="stylesheet" href="vendors/base/vendor.bundle.base.css">
  <link rel="stylesheet" href="vendors/flag-icon-css/css/flag-icon.min.css"/>
  <link rel="stylesheet" href="vendors/font-awesome/css/font-awesome.min.css">
  <link rel="stylesheet" href="vendors/jquery-bar-rating/fontawesome-stars-o.css">
  <link rel="stylesheet" href="vendors/jquery-bar-rating/fontawesome-stars.css">
  
  <link rel="stylesheet" href="css/style.css">
  <link rel="shortcut icon" href="images/favicon.png" />
</head>
<body>
  <div class="container-scroller">
    <nav class="navbar col-lg-12 col-12 p-0 fixed-top d-flex flex-row">
      <div class="text-center navbar-brand-wrapper d-flex align-items-center justify-content-center">
        <a class="navbar-brand brand-logo" href="dashboard.php"><img src="https://win-xo.fun/logo.png" alt="logo"/></a>
        <a class="navbar-brand brand-logo-mini" href="dashboard.php"><img src="images/logo-mini.png" alt="logo"/></a>
      </div>
      <div class="navbar-menu-wrapper d-flex align-items-center justify-content-end">
        <button class="navbar-toggler navbar-toggler align-self-center" type="button" data-toggle="minimize">
          <span class="icon-menu"></span>
          
          
          
          
          
        </button> 
        
        <ul class="navbar-nav navbar-nav-right">
    <li class="nav-item dropdown d-flex mr-4">
        <a class="nav-link count-indicator dropdown-toggle d-flex align-items-center justify-content-center" 
           id="notificationDropdown" href="#" data-toggle="dropdown">

<!-- Notification Bell -->
<nav class="navbar">
    <div class="ml-auto">
        <li class="nav-item dropdown">
            <a class="nav-link dropdown-toggle" href="#" id="notificationDropdown" role="button" data-toggle="dropdown">
                <i class="fa fa-bell" id="bell-icon"></i>
                <span class="badge badge-danger" id="notification-count" style="display: none;">0</span>
            </a>
            <div class="dropdown-menu dropdown-menu-right" aria-labelledby="notificationDropdown">
                <h6 class="dropdown-header">Update Notifications</h6>
                <div id="update-list">
                    <p class="dropdown-item">No new updates</p>
                </div>
            </div>
        </li>
    </div>
</nav>

        <ul class="navbar-nav navbar-nav-right">           
          <li class="nav-item dropdown d-flex mr-4 ">
            <a class="nav-link count-indicator dropdown-toggle d-flex align-items-center justify-content-center" id="notificationDropdown" href="#" data-toggle="dropdown">
              <i class="icon-cog"></i>
            </a>

            
            <div class="dropdown-menu dropdown-menu-right navbar-dropdown preview-list" aria-labelledby="notificationDropdown">
              <p class="mb-0 font-weight-normal float-left dropdown-header">Settings</p>              
              <a class="dropdown-item preview-item" href="logout.php">
                  <i class="icon-inbox"></i> Logout
              </a>
            </div>
          </li>
        </ul>
        <button class="navbar-toggler navbar-toggler-right d-lg-none align-self-center" type="button" data-toggle="offcanvas">
          <span class="icon-menu"></span>
        </button>
      </div>
    </nav>
    <div class="container-fluid page-body-wrapper">
      <nav class="sidebar sidebar-offcanvas" id="sidebar">
        <div class="user-profile">
          <div class="user-image">
            <img src="https://win-xo.fun/logo.png">
          </div>
          <div class="user-name">
              Game
          </div>
          <div class="user-designation">
              Admin
          </div>
        </div>
        <?php include 'compass.php';?>
      </nav>
 <div class="main-panel">
  <div class="content-wrapper">
    <div class="row">
      <div class="col-sm-12 mb-4 mb-xl-0">
        <div class="card shadow-sm border-0 rounded p-4 d-flex flex-md-row flex-column justify-content-between align-items-center" style="background: linear-gradient(to right, #3362ff, #5a83ff); color: #fff;">
          <div>
            <h4 class="font-weight-bold mb-1">👋 Hi, welcome back!</h4>
            <p class="mb-0">
              <i class="material-icons align-middle" style="font-size: 18px; vertical-align: middle;">event</i>
              <?php echo date("F d, Y"); ?>
            </p>
          </div>
          <div>
            <img src="https://scripthubdemo.online/admin_noob_panel_sanju/images/logo.png" width="60" height="60" alt="User Avatar">
          </div>
        </div>
      </div>
    </div>

    <?php 
      $chkserial = mysqli_query($conn,"SELECT * FROM `nirvahaka_shonu` WHERE `unohs`='".$_SESSION['unohs']."'");
      $salu = mysqli_fetch_array($chkserial);
      $dashboard = $salu['dashboard'];
      if($dashboard == 1){
    ?>

		  <div class="row">
			<div style="background-color: #3362ff; color: white; padding: 20px; margin: 10px;"
              class="dashboard_box blue_bg col-md-3 border-radius">
                <div class="title">
                  <p class="text-title" style="text-align:left">Today User Join</p>
					<h4 class="text-amount" style="text-align:left">
					<?php
						  $result = mysqli_query($conn,"SELECT count(*) as 'total_user' FROM shonu_subjects where status = 1 AND id NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(createdate) = DATE('".$curdate."')");
					?> 
					<?php
						  if (mysqli_num_rows($result) > 0) {
							$row = mysqli_fetch_array($result);							                            							
							$total_user = $row["total_user"];
							echo $total_user;                  																  
						  }
						  else 
						  {
							echo "0";
						  }
					?>
					</h4>
                </div>
            </div>
			<div style="background-color: #3362ff; color: white; padding: 20px; margin: 10px;"
              class="dashboard_box blue_bg col-md-3 border-radius">
                <div class="title">
                  <p class="text-title" style="text-align:left">Today's Recharge</p>
					<h4 class="text-amount" style="text-align:left">
					<?php
						  $result = mysqli_query($conn,"SELECT sum(motta) as 'pending' FROM thevani WHERE sthiti = '1' AND balakedara NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(dinankavannuracisi) = DATE('".$curdate."')");
					?> 
					<?php
						  if (mysqli_num_rows($result) > 0) {
							$row = mysqli_fetch_array($result);							                            							
							$pending = $row["pending"];
							echo number_format($pending,0);                  																  
						  }
						  else 
						  {
							echo "0";
						  }
					?>
					</h4>
                </div>
            </div>
			<div style="background-color: #3362ff; color: white; padding: 20px; margin: 10px;"
              class="dashboard_box blue_bg col-md-3 border-radius">
                <div class="title">
                  <p class="text-title" style="text-align:left">Today's Withdrawal</p>
					<h4 class="text-amount" style="text-align:left">
					<?php
						  $result = mysqli_query($conn,"SELECT sum(motta) as 'succ_w' FROM hintegedukolli where sthiti = 1 AND balakedara NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(dinankavannuracisi) = DATE('".$curdate."')");
					?> 
					<?php
						  if (mysqli_num_rows($result) > 0) {
							$row = mysqli_fetch_array($result);							                            							
							$succ_w = $row["succ_w"];
							echo number_format($succ_w,0);                  																  
						  }
						  else 
						  {
							echo "0";
						  }
					?>
					</h4>
                </div>
            </div>
			<div style="background-color: #3362ff; color: white; padding: 20px; margin: 10px;"
              class="dashboard_box blue_bg col-md-3 border-radius">
                <div class="title">
                  <p class="text-title" style="text-align:left">User Balance</p>
					<h4 class="text-amount" style="text-align:left">
					<?php
						  $result = mysqli_query($conn,"SELECT sum(motta) as 'wallt' FROM shonu_kaichila where balakedara NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND motta > 0");
					?> 
					<?php
						  if (mysqli_num_rows($result) > 0) {
							$row = mysqli_fetch_array($result);							                            							
							$zero_bl = $row["wallt"];
							echo number_format($zero_bl,2);                  																  
						  }
						  else 
						  {
							echo "0";
						  }
					?>
					</h4>
                </div>
				<a href="manage_user.php">
                  <div class="panel-footer">
                    <span class="pull-left" style="color: white;">See in Detail</span>
                    <div class="clearfix"></div>
                  </div>
                </a>
            </div>
			<div style="background-color: #3362ff; color: white; padding: 20px; margin: 10px;"
              class="dashboard_box blue_bg col-md-3 border-radius">
                <div class="title">
                  <p class="text-title" style="text-align:left">Total Users</p>
					<h4 class="text-amount" style="text-align:left">
					<?php
						  $result = mysqli_query($conn,"SELECT count(*) as 'total_user' FROM shonu_subjects where id NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND status = 1");
					?> 
					<?php
						  if (mysqli_num_rows($result) > 0) {
							$row = mysqli_fetch_array($result);							                            							
							$total_user = $row["total_user"];
							echo $total_user;                  																  
						  }
						  else 
						  {
							echo "0";
						  }
					?>
					</h4>
                </div>
				<a href="manage_user.php">
                  <div class="panel-footer">
                    <span class="pull-left" style="color: white;">See in Detail</span>
                    <div class="clearfix"></div>
                  </div>
                </a>
            </div>
			<div style="background-color: #3362ff; color: white; padding: 20px; margin: 10px;"
              class="dashboard_box blue_bg col-md-3 border-radius">
                <div class="title">
                  <p class="text-title" style="text-align:left">Pending Recharge</p>
					<h4 class="text-amount" style="text-align:left">
					<?php
						  $result = mysqli_query($conn,"SELECT sum(motta) as '2' FROM thevani where balakedara NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND sthiti = '0'");
					?> 
					<?php
						  if (mysqli_num_rows($result) > 0) {
							$row = mysqli_fetch_array($result);							                            							
							$pending = $row["2"];
							echo number_format($pending);                 																  
						  }
						  else 
						  {
							echo "0";
						  }
					?>
					</h4>
                </div>
				<a href="deposit_update.php">
                  <div class="panel-footer">
                    <span class="pull-left" style="color: white;">See in Detail</span>
                    <div class="clearfix"></div>
                  </div>
                </a>
            </div>
			<div style="background-color: #3362ff; color: white; padding: 20px; margin: 10px;"
              class="dashboard_box blue_bg col-md-3 border-radius">
                <div class="title">
                  <p class="text-title" style="text-align:left">Success Recharge</p>
					<h4 class="text-amount" style="text-align:left">
					<?php
						  $result = mysqli_query($conn,"SELECT sum(motta) as 'pending' FROM thevani where balakedara NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND sthiti = '1'");
					?> 
					<?php
						  if (mysqli_num_rows($result) > 0) {
							$row = mysqli_fetch_array($result);							                            							
							$pending = $row["pending"];
							echo number_format($pending,0);                																  
						  }
						  else 
						  {
							echo "0";
						  }
					?>
					</h4>
                </div>
				<a href="deposit_update.php">
                  <div class="panel-footer">
                    <span class="pull-left" style="color: white;">See in Detail</span>
                    <div class="clearfix"></div>
                  </div>
                </a>
            </div>
			<div style="background-color: #3362ff; color: white; padding: 20px; margin: 10px;"
              class="dashboard_box blue_bg col-md-3 border-radius">
                <div class="title">
                  <p class="text-title" style="text-align:left">Total Withdrawal</p>
					<h4 class="text-amount" style="text-align:left">
					<?php
						  $result = mysqli_query($conn,"SELECT sum(motta) as 'pending_w' FROM hintegedukolli where balakedara NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND sthiti = '1'");
					?> 
					<?php
						  if (mysqli_num_rows($result) > 0) {
							$row = mysqli_fetch_array($result);							                            							
							$pending_w = $row["pending_w"];
							echo number_format($pending_w);                 																  
						  }
						  else 
						  {
							echo "0";
						  }
					?>
					</h4>
                </div>
				<a href="withdraw_accept_list.php">
                  <div class="panel-footer">
                    <span class="pull-left" style="color: white;">See in Detail</span>
                    <div class="clearfix"></div>
                  </div>
                </a>
            </div>
			<div style="background-color: #3362ff; color: white; padding: 20px; margin: 10px;"
              class="dashboard_box blue_bg col-md-3 border-radius">
                <div class="title">
                  <p class="text-title" style="text-align:left">Withdrawal Requests</p>
					<h4 class="text-amount" style="text-align:left">
					<?php
						  $result = mysqli_query($conn,"SELECT sum(motta) as 'approve_withdrawal' FROM hintegedukolli where balakedara NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND sthiti = '0'");
					?> 
					<?php
						  if (mysqli_num_rows($result) > 0) {
							$row = mysqli_fetch_array($result);							                            							
							$approve_withdrawal = $row["approve_withdrawal"];
							echo number_format($approve_withdrawal);                 																  
						  }
						  else 
						  {
							echo "0";
						  }
					?>
					</h4>
                </div>
				<a href="manage_withdraw.php">
                  <div class="panel-footer">
                    <span class="pull-left" style="color: white;">See in Detail</span>
                    <div class="clearfix"></div>
                  </div>
                </a>
            </div>
			<div style="background-color: #3362ff; color: white; padding: 20px; margin: 10px;"
              class="dashboard_box blue_bg col-md-3 border-radius">
                <div class="title">
                  <p class="text-title" style="text-align:left">Today's total bet</p>
					<h4 class="text-amount" style="text-align:left">
					<?php
						    $bet_wingo_1 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(ketebida) as total FROM `bajikattuttate` where byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_wingo_3 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(ketebida) as total FROM `bajikattuttate_drei` where byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_wingo_5 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(ketebida) as total FROM `bajikattuttate_funf` where byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_wingo_10 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(ketebida) as total FROM `bajikattuttate_zehn` where byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_k3_1 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(ketebida) as total FROM `bajikattuttate_kemuru` where byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_k3_3 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(ketebida) as total FROM `bajikattuttate_kemuru_drei` where byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_k3_5 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(ketebida) as total FROM `bajikattuttate_kemuru_funf` where byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_k3_10 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(ketebida) as total FROM `bajikattuttate_kemuru_zehn` where byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_5d_1 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(ketebida) as total FROM `bajikattuttate_aidudi` where byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_5d_3 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(ketebida) as total FROM `bajikattuttate_aidudi_drei` where byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_5d_5 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(ketebida) as total FROM `bajikattuttate_aidudi_funf` where byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_5d_10 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(ketebida) as total FROM `bajikattuttate_aidudi_zehn` where byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$total_bet = $bet_wingo_1['total'] + $bet_wingo_3['total'] + $bet_wingo_5['total'] + $bet_wingo_10['total'] + $bet_k3_1['total'] + $bet_k3_3['total'] + $bet_k3_5['total'] + $bet_k3_10['total'] + $bet_5d_1['total'] + $bet_5d_3['total'] + $bet_5d_5['total'] + $bet_5d_10['total'];
					?> 
					<?php
							$asila = $total_bet;
						  echo number_format($total_bet, 2);
					?>
					</h4>
                </div>				
            </div>
			<div style="background-color: #3362ff; color: white; padding: 20px; margin: 10px;"
              class="dashboard_box blue_bg col-md-3 border-radius">
                <div class="title">
                  <p class="text-title" style="text-align:left">Today's total win</p>
					<h4 class="text-amount" style="text-align:left">
					<?php
						    $bet_wingo_1 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(sesabida) as total FROM `bajikattuttate` where `phalaphala` = 'gagner' AND byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_wingo_3 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(sesabida) as total FROM `bajikattuttate_drei` where `phalaphala` = 'gagner' AND byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_wingo_5 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(sesabida) as total FROM `bajikattuttate_funf` where `phalaphala` = 'gagner' AND byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_wingo_10 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(sesabida) as total FROM `bajikattuttate_zehn` where `phalaphala` = 'gagner' AND byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_k3_1 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(sesabida) as total FROM `bajikattuttate_kemuru` where `phalaphala` = 'gagner' AND byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_k3_3 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(sesabida) as total FROM `bajikattuttate_kemuru_drei` where `phalaphala` = 'gagner' AND byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_k3_5 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(sesabida) as total FROM `bajikattuttate_kemuru_funf` where `phalaphala` = 'gagner' AND byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_k3_10 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(sesabida) as total FROM `bajikattuttate_kemuru_zehn` where `phalaphala` = 'gagner' AND byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_5d_1 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(sesabida) as total FROM `bajikattuttate_aidudi` where `phalaphala` = 'gagner' AND byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_5d_3 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(sesabida) as total FROM `bajikattuttate_aidudi_drei` where `phalaphala` = 'gagner' AND byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_5d_5 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(sesabida) as total FROM `bajikattuttate_aidudi_funf` where `phalaphala` = 'gagner' AND byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$bet_5d_10 = mysqli_fetch_assoc(mysqli_query($conn,"SELECT sum(sesabida) as total FROM `bajikattuttate_aidudi_zehn` where `phalaphala` = 'gagner' AND byabaharkarta NOT IN (SELECT balakedara FROM `demo` WHERE `sthiti`='1') AND DATE(tiarikala) = DATE('".$curdate."')"));
							$total_bet = $bet_wingo_1['total'] + $bet_wingo_3['total'] + $bet_wingo_5['total'] + $bet_wingo_10['total'] + $bet_k3_1['total'] + $bet_k3_3['total'] + $bet_k3_5['total'] + $bet_k3_10['total'] + $bet_5d_1['total'] + $bet_5d_3['total'] + $bet_5d_5['total'] + $bet_5d_10['total'];
					?> 
					<?php
							$gala = $total_bet;
						  echo number_format($total_bet, 2);
					?>
					</h4>
                </div>				
            </div>
			<div style="background-color: #3362ff; color: white; padding: 20px; margin: 10px;"
              class="dashboard_box blue_bg col-md-3 border-radius">
                <div class="title">
                  <p class="text-title" style="text-align:left">Today's profit</p>
					<h4 class="text-amount" style="text-align:left">					
					<?php
							$amount = $asila - $gala;
							echo round($amount,2);
					?>
					</h4>
                </div>				
            </div>
		  </div>
		  <?php } ?>
		</div>
		
		<!-- Floating Transaction Button -->
<div id="floating-transaction-icon" onclick="toggleTransactionPanel()">
    <i class="fa fa-exchange"></i> <!-- Transaction Icon -->
</div>

<style>
    


/* Floating Transaction Icon */
#floating-transaction-icon {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #3362ff;
    color: white;
    padding: 15px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 9999;
    transition: all 0.3s ease-in-out;
}
#floating-transaction-icon:hover {
    background: #e64a19;
}

/* Transaction Panel */
#transaction-panel {
    position: fixed;
    bottom: 70px;
    right: 20px;
    width: 300px;
    height: 400px;
    background: white;
    border-radius: 10px;
    box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    z-index: 10000;
}

/* Header */
.transaction-header {
    background: #3362ff;
    color: white;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-top-left-radius: 10px;
    border-top-right-radius: 10px;
}
.transaction-header button {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
}

/* Content */
#transaction-content {
    padding: 10px;
    overflow-y: auto;
    height: 350px;
}
.transaction-item {
    padding: 10px;
    border-bottom: 1px solid #ddd;
}
.transaction-item.success { color: green; }
.transaction-item.failed { color: red; }

</style>


<!-- Transaction Chat Panel -->
<div id="transaction-panel">
    <div class="transaction-header">
        <h4>Live Transactions</h4>
        <button onclick="toggleTransactionPanel()">—</button>
    </div>
    <div id="transaction-content">
        <p>Loading transactions...</p>
    </div>
</div>

		
		
		
		
		
        <footer class="footer">
          <div class="d-sm-flex justify-content-center justify-content-sm-between">
            <span class="text-muted d-block text-center text-sm-left d-sm-inline-block">Powered by  Game Admin Admin</span>
          </div>
        </footer>
      </div>
    </div>
  </div>
  <script src="vendors/base/vendor.bundle.base.js"></script>
  <script src="js/off-canvas.js"></script>
  <script src="js/hoverable-collapse.js"></script>
  <script src="js/template.js"></script>
  <script src="vendors/chart.js/Chart.min.js"></script>
  <script src="vendors/jquery-bar-rating/jquery.barrating.min.js"></script>
  <script src="js/dashboard.js"></script>
  <script src="js/transactions.js"></script>
  
  <script>
    function checkForUpdates() {
        $.ajax({
            url: 'check_update.php',
            type: 'GET',
            dataType: 'json',
            success: function(response) {
                if (response.update_available) {
                    $("#bell-icon").addClass("text-warning");
                    $("#notification-count").text("1").show();
                    $("#update-list").html('<a href="#" class="dropdown-item" onclick="applyUpdate(\'' + response.file_url + '\')">Update to v' + response.version + '</a>');
                } else {
                    $("#bell-icon").removeClass("text-warning");
                    $("#notification-count").hide();
                    $("#update-list").html('<p class="dropdown-item">No new updates</p>');
                }
            }
        });
    }

    function applyUpdate(fileUrl) {
        $.ajax({
            url: 'apply_update.php',
            type: 'POST',
            data: { file_url: fileUrl },
            dataType: 'json',
            success: function(response) {
                alert(response.message);
                checkForUpdates(); // âœ… Update apply hone ke baad dobara check karo
            }
        });
    }

    setInterval(checkForUpdates, 5000); // âœ… Har 5 sec me update check karega
    
    
</script>

<script>
function toggleTransactionPanel() {
    $("#transaction-panel").fadeToggle(); // ðŸ”¥ Panel ko slide in/out karega
}
</script>




<!-- ✅ Notification Popup HTML -->
<div id="notificationPopup">
  <span class="close-btn" onclick="hideNotification()">&times;</span>
  <img id="notifImage" src="" alt="Image" />
  <div class="content">
    <h6 id="notifTitle"></h6>
    <p id="notifMessage" style="font-size: 14px;"></p>
    <p id="notifCost" style="font-weight: 500;"></p>
    <a id="notifLink" href="#" target="_blank" class="btn btn-sm btn-primary mt-2" style="display:none;">Contact Developer</a>
  </div>
</div>

<!-- ✅ Notification Popup CSS -->
<style>
#notificationPopup {
  position: fixed;
  bottom: 40px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  width: 480px;
  max-height: 560px;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 15px 50px rgba(0,0,0,0.25);
  overflow: hidden;
  display: none;
  border-top: 5px solid #007bff;
  animation: slideUp 0.4s ease-in-out;
}

#notificationPopup img {
  width: 100%;
  max-height: 240px;
  object-fit: contain;
  border-bottom: 1px solid #eee;
}

#notificationPopup .content {
  padding: 20px;
  max-height: 280px;
  overflow-y: auto;
  font-family: 'Segoe UI', sans-serif;
}

#notificationPopup .content h6 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 10px;
  color: #222;
}

#notificationPopup .content p {
  font-size: 15px;
  color: #444;
  line-height: 1.5;
  margin-bottom: 12px;
}

#notificationPopup .close-btn {
  position: absolute;
  top: 10px;
  right: 15px;
  font-size: 22px;
  font-weight: bold;
  cursor: pointer;
  color: #555;
}

#notifLink {
  display: inline-block;
  background-color: #007bff;
  color: white !important;
  padding: 10px 20px;
  font-size: 15px;
  border-radius: 8px;
  text-decoration: none;
  margin-top: 5px;
  transition: 0.3s;
}
#notifLink:hover {
  background-color: #0056b3;
}

@keyframes slideUp {
  from {
    transform: translate(-50%, 30px);
    opacity: 0;
  }
  to {
    transform: translate(-50%, 0px);
    opacity: 1;
  }
}
</style>

<!-- ✅ Notification Popup JS -->
<script>
const popupKey = "notification_popup_hidden_until";

function hideNotification() {
  const now = new Date();
  const hideUntil = new Date(now.getTime() + 60 * 60 * 1000); // Hide for 1 hour
  localStorage.setItem(popupKey, hideUntil.toISOString());
  document.getElementById("notificationPopup").style.display = "none";
}

async function checkNotification() {
  const now = new Date();
  const hiddenUntil = localStorage.getItem(popupKey);
  if (hiddenUntil && new Date(hiddenUntil) > now) {
    console.log("Notification hidden until:", hiddenUntil);
    return;
  }

  try {
    const response = await fetch("https://updatepanel.win-xo.fun/api/get_notifications.php");
    const data = await response.json();
    console.log("Notification response:", data);

    if (data.status && data.notifications.length > 0) {
      const n = data.notifications[0];

      // Title + Message
      document.getElementById("notifTitle").innerText = n.title;
      document.getElementById("notifMessage").innerText = n.message;

      // Image
      if (n.images.length > 0) {
        document.getElementById("notifImage").src = "https://updatepanel.win-xo.fun/" + n.images[0];
        document.getElementById("notifImage").style.display = "block";
      } else {
        document.getElementById("notifImage").style.display = "none";
      }

      // Update Cost
      if (n.update_cost && n.update_cost !== "") {
        document.getElementById("notifCost").innerText = "🪙 Update Cost: ₹" + n.update_cost;
        document.getElementById("notifCost").style.display = "block";
      } else {
        document.getElementById("notifCost").style.display = "none";
      }

      // Contact Button
      if (n.contact_link) {
        const btn = document.getElementById("notifLink");
        btn.href = n.contact_link;
        btn.innerText = "💬 Contact Developer";
        btn.style.display = "inline-block";
      } else {
        document.getElementById("notifLink").style.display = "none";
      }

      // Show Notification
      document.getElementById("notificationPopup").style.display = "block";
    }

  } catch (e) {
    console.error("Notification fetch error:", e.message);
  }
}

document.addEventListener("DOMContentLoaded", checkNotification);
</script>





</body>

</html>