<?php
@session_start();
include "control/activity.php";

 $dd = new activity();
 $loginStatus = $_SESSION['loginDetails'];


  if(isset($_SESSION['loginDetails'])){

  }else{
     header("Location:dashboard.php");
  }

  if($loginStatus == null){
    echo "<script>window.open('logout.php','_self')</script>";
  }



  $table = "admin_calculation";
  $condition = null;
  $getAdminDetails = $dd->single($table,$condition);
  
?>

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<title><?= $getAdminDetails['title']; ?></title>
</head>
<body>

    <div class="main" id="main">
		  <?php include "menu.php"; ?>
    <div class="right"> 
  <div class="tab-content">


   <?php include "headermenu.php"; ?>


        <!-- Overview -->
         <div id="overview" class="tab-pane active"  >
                <div class="content" >
                  
               <div class="content-wrapper">
                 <div class="container-fluid">

                      <!--======================================================  Content  ====================================================-->                                            
                          <ol class="breadcrumb">
                            <li class="breadcrumb-item">
                              <a href="dashboard.php">ALL-REQUEST</a>
                            </li>
                          </ol>

                          <div class="row">
                              <div class="col-xl-12 col-sm-12 mb-12">
                                 <table class="table table-bordered data-table">
                                    <tr>
                                        <td>
                                            <!-- <button onclick="kycRequest()" class="btn btn-xs btn-info"> KYC REQUEST</button> -->
                                            <button onclick="changereceivedupi()" class="btn btn-xs btn-info"> CHANGE UPI</button>
                                            
                                            <button onclick="contactLinkOnlclick()" class="btn btn-xs btn-info"> CHANGE Telegram</button>
                                            <button onclick="contactWhatsapp()" class="btn btn-xs btn-info"> CHANGE Whatsapp</button>
                                            <button onclick="contactInstagram()" class="btn btn-xs btn-info"> CHANGE Instagram</button>
                                            
                                            <button onclick="marqueenotice()" class="btn btn-xs btn-info"> MARQUEE NOTICE</button>
                                            <button onclick="changepassword()" class="btn btn-xs btn-info"> CHANGE PASSWORD</button>
                                            <button onclick="changepin()" class="btn btn-xs btn-info"> CHANGE PIN</button>
                                            <!--<button onclick="setCommission()" class="btn btn-xs btn-info"> Set Commission</button>-->
                                             <!--<button onclick="tutorial()" class="btn btn-xs btn-info"> Tutorial</button>-->
                                             <!--<button onclick="actvityAward()" class="btn btn-xs btn-info"> Activity Award</button>-->
                                             <!--<button onclick="invitationBonus()" class="btn btn-xs btn-info"> Invitation Bonus</button></td> -->
                                    </tr>

                                    <tr style="display:none;" id="upiSection">
                                        <td><form method="post">UPI ID : <input name="upiId" value="<?= $getAdminDetails['upi_id']; ?>" class="form-control"/><br> <button name="changeButton" class="btn btn-block btn-warning"> CHANGE </button></form></td>
                                    </tr>


                                    
                                    <tr style="display:none;" id="cantactLink">
                                        <td><form method="post">Contact Link : <input name="telegram" value="<?= $getAdminDetails['telegram']; ?>" class="form-control"/><br> <button name="tel" class="btn btn-block btn-warning"> CHANGE </button></form></td>
                                    </tr>
                                    
                                    <tr style="display:none;" id="cantactWhatsapp">
                                        <td><form method="post"> Whatsapp Link : <input name="whatsapp" value="<?= $getAdminDetails['whatsapp']; ?>" class="form-control"/><br> <button name="whatsappp" class="btn btn-block btn-warning"> CHANGE </button></form></td>
                                    </tr>
                                    
                                    <tr style="display:none;" id="cantactInstagram">
                                        <td><form method="post">Instagram Link : <input name="instagram" value="<?= $getAdminDetails['instagram']; ?>" class="form-control"/><br> <button name="instagramm" class="btn btn-block btn-warning"> CHANGE </button></form></td>
                                    </tr>


                                    
                                    <tr style="display:none;" id="noticeMar">
                                        <td><form method="post">Marquee Notice : <textarea style="width:200px; height:200px;" name="marqueeNotice" class="form-control"><?= $getAdminDetails['notice']; ?></textarea><br> <button name="notice" class="btn btn-block btn-warning"> CHANGE </button></form></td>
                                    </tr>
                                    
                                    
                                    <tr style="display:none;" id="changepass">
                                        <td><form method="post"><input  name="oldpass" class="form-control" placeholder="OldPassword"/><br>
                                             <input  name="newpass" class="form-control" placeholder="NewPassword"/><br> 
                                             <input  name="conpass" class="form-control" placeholder="ConfirmPassword"/><br>
                                             <button name="changepass" class="btn btn-block btn-warning"> CHANGE </button>
                                             </form></td>
                                    </tr>
                                    
                                    
                                    
                                    <tr style="display:none;" id="changepin">
                                        <td><form method="post">
                                             <input  name="oldpin" class="form-control" placeholder="Old Pin"/><br>
                                             <input  name="npin" class="form-control" placeholder="new Pin"/><br> 
                                             <input  name="cpin" class="form-control" placeholder="confirm Pin"/><br>
                                             <button name="changePin" class="btn btn-block btn-warning"> CHANGE Pin</button>
                                             </form></td>
                                    </tr>


                                 </table>
                              </div>
                          </div>
  <?php
  
if(isset($_REQUEST['changePin']))
{
    $oldpin = $_REQUEST['oldpin'];
    $npin = $_REQUEST['npin'];
    $cpin = $_REQUEST['cpin'];
    
    $table = "admin_calculation";
    $condition = " where pin='$oldpin' AND adminKey='1'";
    $result = $dd->check($table,$condition);
    if($result['status'] == "success")
    {
         if($npin ==$cpin)
         {
             $table = "admin_calculation";
             $value = "pin='$cpin'";
             $condition = " pin='$oldpin' AND adminKey='1'";
             $result = $dd->updateData($table,$value,$condition);
             if($result){
                  echo "<script>alert('Pin Re-set successfully..!!'),window.open('dashboard.php','_self')</script>";
             }
         }
         else{
             echo "<script>alert('Invalid Confirm Password')</script>";
         }
    }
    else{
        echo "<script>alert('Invalid Password')</script>";
    }
}



if(isset($_REQUEST['changeButton']))
{
    $upiId = $_REQUEST['upiId'];
    $table = "admin_calculation";
    $value = "upi_id='$upiId'";
    $condition = " adminKey='1'";
    $result = $dd->updateData($table,$value,$condition);
    if($result){
        echo "<script>alert('Update successfully..!!'),window.open('?','_self')</script>";
    }
}







if(isset($_REQUEST['tel']))
{
    $telegram = $_REQUEST['telegram'];
    $table = "admin_calculation";
    $value = "telegram='$telegram'";
    $condition = " adminKey='1'";
    $result = $dd->updateData($table,$value,$condition);
    if($result){
        echo "<script>alert('Update successfully..!!'),window.open('?','_self')</script>";
    }
}

if(isset($_REQUEST['whatsappp']))
{
    $whatsapp = $_REQUEST['whatsapp'];
    $table = "admin_calculation";
    $value = "whatsapp='$whatsapp'";
    $condition = " adminKey='1'";
    $result = $dd->updateData($table,$value,$condition);
    if($result){
        echo "<script>alert('Update successfully..!!'),window.open('?','_self')</script>";
    }
}

if(isset($_REQUEST['instagramm']))
{
    $instagram = $_REQUEST['instagram'];
    $table = "admin_calculation";
    $value = "instagram='$instagram'";
    $condition = " adminKey='1'";
    $result = $dd->updateData($table,$value,$condition);
    if($result){
        echo "<script>alert('Update successfully..!!'),window.open('?','_self')</script>";
    }
}




if(isset($_REQUEST['notice']))
{
    $marqueeNotice2 = $_REQUEST['marqueeNotice'];
    $marqueeNotice = preg_replace('/[^\p{L}\p{N}\s]/u', '', $marqueeNotice2);
    $table = "admin_calculation";
    $value = "notice='$marqueeNotice'";
    $condition = " adminKey='1'";
    $result = $dd->updateData($table,$value,$condition);
    if($result){
        echo "<script>alert('Update successfully..!!'),window.open('?','_self')</script>";
    }
}


if(isset($_REQUEST['changepass']))
{
    $oldpass = $_REQUEST['oldpass'];
    $newpass = $_REQUEST['newpass'];
    $changepass = $_REQUEST['conpass'];
    
    $table = "admin_calculation";
    $condition = " where password='$oldpass' AND adminKey='1'";
    $result = $dd->check($table,$condition);
    if($result['status'] == "success")
    {
         if($newpass ==$changepass)
         {
             $table = "admin_calculation";
             $value = "password='$newpass'";
             $condition = " password='$oldpass' AND adminKey='1'";
             $result = $dd->updateData($table,$value,$condition);
             if($result){
                  echo "<script>alert('Password Re-set successfully..!!'),window.open('logout.php','_self')</script>";
             }
         }
         else{
             echo "<script>alert('Invalid Confirm Password')</script>";
         }
    }
    else{
        echo "<script>alert('Invalid Password')</script>";
    }
}


?>
                           
      <!--============  FIN DE L'AJOUT  ===============-->
      
<script>

 function invitationBonus()
 {
     window.open('invitationbonus.php','_self');
 }
 
 function actvityAward(){
     window.open('activityaward.php','_self');
 }
 

 function tutorial(){
     window.open('tutorial.php','_self');
 }
 
 
 
 function changepin(){
    document.getElementById("cantactWhatsapp").style.display = "none";
    document.getElementById("cantactInstagram").style.display = "none";
    document.getElementById("upiSection").style.display = "none";
    document.getElementById("cantactLink").style.display = "none";
    document.getElementById("noticeMar").style.display = "none";
    document.getElementById("changepass").style.display = "none";
    document.getElementById("changepin").style.display = "block";
 }
 
 function contactWhatsapp()
 {
    document.getElementById("cantactWhatsapp").style.display = "block";
    document.getElementById("cantactInstagram").style.display = "none";
    document.getElementById("upiSection").style.display = "none";
    document.getElementById("cantactLink").style.display = "none";
    document.getElementById("noticeMar").style.display = "none";
    document.getElementById("changepass").style.display = "none";
    document.getElementById("changepin").style.display = "none";
 }
  function contactInstagram()
 {
    document.getElementById("cantactWhatsapp").style.display = "none";
    document.getElementById("cantactInstagram").style.display = "block";
    document.getElementById("upiSection").style.display = "none";
    document.getElementById("cantactLink").style.display = "none";
    document.getElementById("noticeMar").style.display = "none";
    document.getElementById("changepass").style.display = "none";
    document.getElementById("changepin").style.display = "none";
 }

 function changereceivedupi()
 {
    document.getElementById("upiSection").style.display = "block";
    document.getElementById("cantactLink").style.display = "none";
    document.getElementById("noticeMar").style.display = "none";
    document.getElementById("changepass").style.display = "none";
     document.getElementById("cantactWhatsapp").style.display = "none";
    document.getElementById("cantactInstagram").style.display = "none";
    document.getElementById("changepin").style.display = "none";
 }


 function contactLinkOnlclick()
 {
    document.getElementById("cantactLink").style.display = "block";
    document.getElementById("upiSection").style.display = "none";
    document.getElementById("noticeMar").style.display = "none";
    document.getElementById("changepass").style.display = "none";
     document.getElementById("cantactWhatsapp").style.display = "none";
    document.getElementById("cantactInstagram").style.display = "none";
    document.getElementById("changepin").style.display = "none";
 }


 function marqueenotice()
 {
    document.getElementById("noticeMar").style.display = "block";
    document.getElementById("upiSection").style.display = "none";
    document.getElementById("cantactLink").style.display = "none";
    document.getElementById("changepass").style.display = "none";
     document.getElementById("cantactWhatsapp").style.display = "none";
    document.getElementById("cantactInstagram").style.display = "none";
    document.getElementById("changepin").style.display = "none";
 }
 
 
 function changepassword()
 {
    document.getElementById("noticeMar").style.display = "none";
    document.getElementById("upiSection").style.display = "none";
    document.getElementById("cantactLink").style.display = "none";
    document.getElementById("changepass").style.display = "block";
     document.getElementById("cantactWhatsapp").style.display = "none";
    document.getElementById("cantactInstagram").style.display = "none";
    document.getElementById("changepin").style.display = "none";
     
 }
 
 
 function setCommission()
 {
     window.open('setCommission.php','_self');
 }

</script>
      
     
      </div>
      <!-- /.container-fluid-->
       </div>  <!-- /content-wrapper-->


                </div>
                </div>
             </div><!--Right panel-->
</div><!--Main-->





<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0-alpha1/dist/css/bootstrap.min.css" rel="stylesheet">
  <style>
    /* Style for the popup */
    .popup {
      display: none; /* Initially hidden */
      position: fixed;
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);
      background-color: white;
      padding: 20px;
      border: 1px solid #ccc;
      box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
      z-index: 1000;
    }
    
    /* Overlay background */
    .overlay {
      display: none; /* Initially hidden */
      position: fixed;
      top: 0;
      left: 0;
      width: 100%;
      height: 100%;
      background-color: rgba(0, 0, 0, 0.5);
      z-index: 999;
    }
  </style>




<div class="overlay" id="overlay"></div>



  <div class="popup" id="popup" style="display:block;">
    <p>4-Digit Pin</p>
    <input onKeyUp="getEnteredPin()" class="form-control" id="pin" placeholder="Enter Pin please."/>
  </div>
  
  <script>
      const popup = document.getElementById('popup');
      const overlay = document.getElementById('overlay');
      popup.style.display = 'block';
      overlay.style.display = 'block';
      
      function getEnteredPin()
      {
          var tttt = document.getElementById("pin").value;
          if(tttt.length == 4){
                const xhttp = new XMLHttpRequest();
                xhttp.onload = function() {
                    var demo_show = this.responseText;
                    const myArr = JSON.parse(demo_show);
                    if(myArr.status == "success")
                    {
                        popup.style.display = 'none';
                        overlay.style.display = 'none';
                    }
                    else{
                        alert(myArr.remark);
                    }
                }
                xhttp.open("GET", "securePin.php?pin="+tttt);
                xhttp.send();
          }
      }
      
      
  </script>
  
</body>
</html>

<?php include "style.php" ?>