


    <?php include("inc/header.php") ?>


  <body data-spy="scroll" data-target="#navSection" data-offset="100">

    <?php include("inc/sidebar.php") ?>
    
    
    <!-- sidebar -->
<script>
   $(document).ready(function(){
$("#submit").click(function(){
var money = $("#money").val();
var timee = $("#time").val();
var operation = $("#operation").val();
var countt = $("#count").val();
var accid = $("#accid").val();
var bal= $("#bal").val();
// Returns successful data submission message when the entered information is stored in database.
var dataString = 'money1='+ money + '&time1='+ timee + '&operation1='+ operation + '&count1='+ countt +'&accidd=' + accid;
if(money==''||time==''||operation=-''||count==''||accid=='')
{
alert("Please Fill All Fields");
}
else
{
//
console.log("it is working");
}
return false; 
});
});    
</script> 
    <div class="content">
      <div class="header">
        <div class="header-left">
          <a href="#" class="burger-menu"><i data-feather="menu"></i></a>

        </div><!-- header-left -->

        <div class="header-right">
          
          <div class="dropdown dropdown-loggeduser">
            <a href="#" class="dropdown-link" data-toggle="dropdown">
              <div class="avatar avatar-sm">
                <img src="https://cdn.iconscout.com/icon/free/png-256/laptop-user-1-1179329.png" class="rounded-circle" alt="">
              </div><!-- avatar -->
            </a>
            <div class="dropdown-menu dropdown-menu-right">
              <div class="dropdown-menu-header">
                <div class="media align-items-center">
                  
                  <div class="media-body mg-l-10">
                    <h6>Louise Kate Lumaad</h6>
                    <span>Administrator</span>
                  </div>
                </div><!-- media -->
              </div>
              <div class="dropdown-menu-body">
                <a href="#" class="dropdown-item"><i data-feather="user"></i> View Profile</a>
                
                <a href="../ " class="dropdown-item"><i data-feather="log-out"></i> Sign Out</a>
              </div>
            </div><!-- dropdown-menu -->
          </div>
        </div><!-- header-right -->
      </div><!-- header -->
      <div class="content-header">
        <div>
          <div class="alert alert-success">
  <strong><h4 class="content-title">ALL ON-GOING TRANSACTIONS ON EXCRYPTOTRUST</h4></strong>  
</div>
          
        </div>
      </div><!-- content-header -->
     
     
      <div class="content-body content-body-components">
	   
	        
     
     
     
     
     <div class="row" style="padding:20px;">
         <div class="col-md-12">
             <center>
             <h4>Recent Deposit Transactions</h4>
             </center>
             <br>
              <div class="table-responsive">
              <table class="table table-striped mg-b-0">
                <thead>
                    <tr>
                    <th scope="col">Username</th>
                    <th scope="col">Amount Deposited</th>
                    <th scope="col">Date of Payment</th>
                    <th scope="col">Action</th>
                  </tr>
                  
                </thead>
                
                <?
                    $db="select * from Deposit where credit='pending'";
                    $query=mysqli_query($conn, $db);
                    while ($fetch=mysqli_fetch_array($query)){
                        $name=$fetch['name'];
                        $userid = $fetch['user_id'];
                        $amount=$fetch['amount'];
                        $exp=$fetch['user_id'];
                        $email=$fetch['email'];
                        $date=$fetch['time'];
                        $id=$fetch['dep_id'];
                        $o_amount=$fetch['o_amount'];
                        
                        
                        
                    
                ?>
                
                
               <tbody>
                            <tr>
                                <td>
                                    <center>
                                        <? echo $name; ?>
                                    </center>
                                </td>

                                <td>
                                    <center>
                                        <? echo $amount; ?>
                                    </center>
                                </td>
                                
                                
                                
                                <td>
                                    <center>
                                        <? echo $date; ?>
                                    </center>
                                </td>
                                
                                <td> <? echo '<a class="btn btn-success btn-xs" href="activate.php?id='.$id.'&exp='.$exp.'">VERIFY</a>'; ?> </td>
                            </tr>
                            
                             
                            
                </tbody>
                <? } ?>
              </table>
            </div>
            
         </div>
         <div class="col-md-12">
                 <form method="post">
                <div class="row">
                    <div class="col-md-12">
                         
                        <br>
                        
                        <label for="seconds">Select User:</label><br>
                        
                        <select name="acc_id" id="accid" class="form-control" required>
                            <?
                            $us="select * from User where status='active'";
                            $uss=mysqli_query($conn, $us);
                            while($u=mysqli_fetch_array($uss)){
                                $na=$u['name'];
                                
                                
                                $i=$u['user_id'];
                                $bal=$u['balance'];
                            
                        ?>
                          <option value="<? echo $i ?>"><? echo $na; ?></option>
                          <? } ?>
                        </select><br>

                        
                                                
                        
                        <label for="seconds">Choose level:</label><br>
                        <select name="level" class="form-control" id="time" required>
                          <option value="Basic">Basic</option>
                          <option value="Bronze">Bronze</option>
                          <option value="Silver">Silver</option>
                          <option value="Gold">Gold</option>
                          <option value="Platinum">Platinum</option>
                          <option value="Diamond">Diamond</option>
                          
                        </select><br>
                        
                        <label>Add amount to level</label><br>
                        <input type="text" class="form-control" name="amount_money" id="money" placeholder=""/><br>
                        
                        

                        
                        <button class="btn btn-lg btn-outline-info" type="submit" name="submit" id="" >Submit</button><br>
                        
                    </div>
                    
                    
                    
                    
                </div>
                </form>
                
                     
            </div>
            
            
            
            
            
            <div class="col-md-12">
                 <form method="post">
                <div class="row">
                    <div class="col-md-12">
                         
                        <br>
                        
                        <label for="seconds">Select Active User:</label><br>
                        
                        <select name="accid" id="accid" class="form-control" required>
                            <?
                            $us="select * from User where status='active'";
                            $uss=mysqli_query($conn, $us);
                            while($u=mysqli_fetch_array($uss)){
                                $na=$u['name'];
                                $exp_id = $u['exp_id'];
                                
                                $user_id=$u['user_id'];
                                $bal=$u['balance'];
                            
                        ?>
                          <option value="<? echo $user_id ?>"><? echo $na; ?></option>
                          <? } ?>
                        </select><br>

                        
                        <label>By How Much do you want to increase/decrease?</label><br>
                        <input type="text" class="form-control" name="money" id="money" placeholder=""/><br>
                        
                        
                        
                        
                        <label for="operation">Choose the operation:</label><br>
                        <select name="operation" class="form-control" id="operation" required>
                          <option value="increase">Increase</option>
                          <option value="decrease">Decrease</option>
                        </select>
                        <br>
                        
                        

                        
                        <button class="btn btn-lg btn-outline-info" type="submit" name="sub" id="" >Start Transaction</button><br>
                        
                    </div>
                    
                    
                    
                    
                </div>
                </form>
                
                     
            </div>
            
            
     </div>
     
     <?
        $accid=$_POST['accid'];
        $money=$_POST['money'];
        $op=$_POST['operation'];
        $time=$_POST['time'];
        $curr=date('d-m-y');

        if(isset($_POST['sub'])){
            
            
            
            
            
            $tr="insert into Transaction(user_id,amount,operation,timef) values('$accid','$money','$op','$curr')";
            $t=mysqli_query($conn, $tr);
            
            if($t){
                
                $select_balance = "select * from User where user_id='$accid'";
                $query_balance = mysqli_query($conn, $select_balance);
                $fetch_balance = mysqli_fetch_array($query_balance);
                $user_balance = $fetch_balance['balance'];
                
                if($op == 'increase'){
                    $new = $user_balance + $money;
                }elseif($op == 'decrease'){
                    $new = $user_balance - $money;
                }
                
                
                $update_new = "update User set balance='$new' where user_id='$accid'";
                $query_new = mysqli_query($conn, $update_new);
                
                if($query_new == true){
                
                echo '<script type="text/javascript"> alert("Profit added successfully"); document.location="customer.php"; </script>';
                }else{
                    echo '<script type="text/javascript"> alert("something went wrong"); document.location="transaction.php"; </script>';
                }
            }else{
                echo '<script type="text/javascript"> alert("Please verify deposit before adding profit"); document.location="transaction.php"; </script>';
            }
            
        }
        
        if(isset($_POST['stop'])){
            $acc=$_POST['acc'];
            
            $g="select * from User where email='$acc'";
            $ge=mysqli_query($conn, $g);
            $gee=mysqli_fetch_array($ge);
            $uid=$gee['user_id'];
            
            $del="delete from Transaction where user_id='$uid'";
            $de=mysqli_query($conn, $del);
            
            if($de){
                echo '<script type="text/javascript"> alert("Transaction stopped"); document.location="transaction.php"; </script>';
            }

        }
     ?>
     
     
    <?php
        $level = $_POST['level'];
        $acc_id = $_POST['acc_id'];
        $amount_money = $_POST['amount_money'];
        
        
        
        if(isset($_POST['submit'])){
            
            $update_user_info = "update User set acc_status='$level', account='$amount_money' where user_id='$acc_id'";
            $query_user_info = mysqli_query($conn, $update_user_info);
            
            if($query_user_info == true){
                echo '<script type="text/javascript"> alert("User level changed successfully"); document.location="transaction.php"; </script>';
            }
        }
    ?>
           
	   

      </div><!-- content-body -->
     
    </div><!-- content -->

	
	
	
	
	
	
	
	
	
    <script src="lib/jquery/jquery.min.js"></script>
    <script src="lib/bootstrap/js/bootstrap.bundle.min.js"></script>
    <script src="lib/feather-icons/feather.min.js"></script>
    <script src="lib/perfect-scrollbar/perfect-scrollbar.min.js"></script>
    <script src="lib/prismjs/prism.js"></script>
    <script src="lib/js-cookie/js.cookie.js"></script>

    <script src="assets/js/cassie.js"></script>
    <script>
      $(function(){

        'use strict'

      })
    </script>
	
	<script>
      $(function(){

        'use strict'

        $('#modal6').on('show.bs.modal', function (event) {

          var animation = $(event.relatedTarget).data('animation');
          $(this).addClass(animation);
        })

        // hide modal with effect
        $('#modal6').on('hidden.bs.modal', function (e) {
          $(this).removeClass (function (index, className) {
              return (className.match (/(^|\s)effect-\S+/g) || []).join(' ');
          });
        });

      })
      
       $(document).ready(function() {
    var number = parseInt($('#money').text(), 10) || 0; // Get the number from paragraph


    // Called the function in each second
    var interval = setInterval(function() {
        $('#money').text(number++); // Update the value in paragraph

        if (number > 1000) {
            clearInterval(interval); // If exceeded 100, clear interval
        }
    }, 1000); // Run for each second
}); 
      
      
    </script>
  </body>

</html>
