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

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


  if($loginStatus == null){
    echo "<script>window.open('login.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  ====================================================-->                                            
 <?php
  $userKey = $_REQUEST['userKey'];
  $table = "userdetails";
  $condition = " WHERE userKey='$userKey'";
  $getUserdetails = $dd->single($table,$condition);
 ?>

                          <div class="row">
                              <div class="col-xl-12 col-sm-12 mb-12">
                                 <table class="table table-bordered data-table">
                                     <table class="table table-bordered">
                                        <form method="post">
                                        <tr>
                                            <td>Join Date : <input name="" value="<?= $getUserdetails['join_date']; ?>" disabled  class="form-control"/></td>
                                            <td>Mobile : <input name="mobile" value="<?= $getUserdetails['mobile']; ?>"   class="form-control"/></td>
                                            <td>Wallet : <input name="" value="<?= round($getUserdetails['wallet'],2); ?>"   class="form-control"/></td>
                                        </tr>
                                        <tr>
                                            <?php
                                              if($getUserdetails['user_status']=="open"){
                                                  $checked1 = "checked";
                                                  $checked2 = null;
                                              }else{
                                                  $checked2 = "checked";
                                                  $checked1 = null;
                                              }
                                            ?>
                                            <td>Password : <input name="pass" value="<?= $getUserdetails['password']; ?>"  class="form-control"/></td>
                                            <td><input <?= $checked1; ?> value="open" type="radio" checked name="userStatus"/>  Active    
                                                <input <?= $checked2; ?> value="close" type="radio" name="userStatus" style="margin-left:20px"/>  Deactive</td>
                                        </tr>
                                        <tr>
                                            <td>A/c Number : <input name="account" value="<?= $getUserdetails['account']; ?>"   class="form-control"/></td>
                                            <td>Ifsc : <input name="ifsc" value="<?= $getUserdetails['ifsc']; ?>"   class="form-control"/></td>
                                            <td></td>
                                        </tr>
                                        <tr>
                                            <td colspan="3"><center><button name="update" class="btn btn-info">UPDATE</button></center></td>
                                        </tr>
                                        </form>
                                     </table> 
                                 </table>
                              </div>
                          </div>
  
                           
      <!--============  FIN DE L'AJOUT  ===============-->
      
<script>
  function viewMoreData(a){
     window.open('view_user_details.php?userKey='+a,'_self');
  }
</script>
      
     
      </div>
      <!-- /.container-fluid-->
       </div>  <!-- /content-wrapper-->


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


</body>
</html>

<?php include "style.php" ?>

<?php
 if(isset($_POST['update']))
 {
     $mobile = $_REQUEST['mobile'];
     $account = $_REQUEST['account'];
     $ifsc = $_REQUEST['ifsc'];
     $pass = $_REQUEST['pass'];
     $userStatus = $_REQUEST['userStatus'];

     $table = "userdetails";
     $value = "mobile='$mobile',password='$pass',account='$account',ifsc='$ifsc',user_status='$userStatus'";
     $condition = " userKey='$userKey'";
     $result = $dd->updateData($table,$value,$condition);
     if($result){
        echo "<script>alert('Update Successfully..!!'),window.open('?userKey=$userKey','_self')</script>";
     }

 }

?>