<?php 
session_start();
if (isset($_SESSION['id'])) {
$id = $_SESSION['id'];
}else{
header("location:login");
} 
include_once '../includes/autoloader.php';
include_once '../includes/function.php';
$newfx = new bank;
$users = $newfx->fetch_All_tra();
$total_user = $newfx->count_total_user();
$total_deposit = $newfx->count_total_deposit();
$total_trade = $newfx->count_all_transactions();
$total_withdrawal = $newfx->count_total_withdrawal();
?>
<!DOCTYPE html> 
<html lang="en"> 
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<head> 
<meta http-equiv="X-UA-Compatible" content="IE=edge"> 
<meta charset="utf-8"> 
<meta name="viewport" content="width=device-width, initial-scale=1" /> 
<meta name="description" content="Neon Admin Panel" /> 
<meta name="author" content="Laborator.co" /> 
<link rel="icon" href="assets/images/favicon.ico">  <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'../www.googletagmanager.com/gtm5445.html?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-K3LP6R3');</script>  <title>T Transfer | Alerts</title> 
<link rel="stylesheet" href="assets/js/jquery-ui/css/no-theme/jquery-ui-1.10.3.custom.min.css" id="style-resource-1"> 
<link rel="stylesheet" href="assets/css/font-icons/entypo/css/entypo.css" id="style-resource-2"> 
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Noto+Sans:400,700,400italic" id="style-resource-3"> 
<link rel="stylesheet" href="assets/css/bootstrap.css" id="style-resource-4"> 
<link rel="stylesheet" href="assets/css/neon-core.css" id="style-resource-5"> 
<link rel="stylesheet" href="assets/css/neon-theme.css" id="style-resource-6"> 
<link rel="stylesheet" href="assets/css/neon-forms.css" id="style-resource-7"> 
<link rel="stylesheet" href="assets/css/custom.css" id="style-resource-8"> 
<link rel="stylesheet" href="../fontawesomev6/css/all.css">
<script src="assets/js/jquery-1.11.3.min.js">
</script> 
<!--[if lt IE 9]>
<script src="https://demo.neontheme.com/assets/js/ie8-responsive-file-warning.js">
</script>
<![endif]-->  <!--[if lt IE 9]> 
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js">
</script> 
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js">
</script> 
<![endif]-->  </head> 
<body class="page-body" data-url="https://demo.neontheme.com">  <noscript>
<iframe src="https://www.googletagmanager.com/ns.html?id=GTM-K3LP6R3" height="0" width="0" style="display:none;visibility:hidden">
</iframe>
</noscript>   <div class="page-container">  
<?php 
include 'header.php';
?>
<div class="main-content">  
<?php 
// include 'nav.php';
?>
<hr/>  
<br/> 
<div class="row"> 
<div class="col-sm-3 col-xs-6"> 
<div class="tile-stats tile-red"> 
<div class="icon"><i class="entypo-users"></i></div> 
<div class="num" data-start="0" data-end="<?php echo $total_user ?>" data-postfix="" data-duration="1500" data-delay="0"><?php echo $total_user ?></div> 
<h3>Registered users</h3> 
</div> 
</div> 
<div class="col-sm-3 col-xs-6"> 
<div class="tile-stats tile-green"> 
<div class="icon"><i class="entypo-chart-bar"></i></div> 
<div class="num" data-start="0" data-end="<?php echo $total_trade ?>" data-postfix="" data-duration="1500" data-delay="600"><?php echo $total_trade ?></div> 
<h3>Total Transaction</h3> 

</div> 
</div> 
<div class="clear visible-xs"></div> 
<div class="col-sm-3 col-xs-6"> 
<div class="tile-stats tile-aqua"> 
<div class="icon"><i class="entypo-mail"></i></div> 
<div class="num" data-start="0" data-end="<?php echo $total_withdrawal ?>" data-postfix="" data-duration="1500" data-delay="1200"><?php echo $total_withdrawal ?></div> 
<h3>Total debit</h3> 
  
</div> 
</div> 
<div class="col-sm-3 col-xs-6"> 
<div class="tile-stats tile-blue"> 
<div class="icon"><i class="entypo-rss"></i></div> 
<div class="num" data-start="0" data-end="<?php echo $total_withdrawal ?>" data-postfix="" data-duration="1500" data-delay="1800"><?php echo $total_withdrawal ?></div> 
<h3>Total credit</h3> 
 
</div> 
</div> 
</div>
<hr/>
<h2>Everything About Transaction</h2> 

<script type="text/javascript">
// jQuery( document ).ready( function( $ ) {
// var $table3 = jQuery("#table-3");
// var table3 = $table3.DataTable( {
// "aLengthMenu": [[10, 25, 50, -1], [10, 25, 50, "All"]]
// } );
// // Initalize Select Dropdown after DataTables is created
// $table3.closest( '.dataTables_wrapper' ).find( 'select' ).select2( {
// minimumResultsForSearch: -1
// });
// // Setup - add a text input to each footer cell
// $( '#table-3 tfoot th' ).each( function () {
// var title = $('#table-3 thead th').eq( $(this).index() ).text();
// $(this).html( '<input type="text" class="form-control" placeholder="Search ' + title + '" />' );
// } );
// // Apply the search
// table3.columns().every( function () {
// var that = this;
// $( 'input', this.footer() ).on( 'keyup change', function () {
// if ( that.search() !== this.value ) {
// that
// .search( this.value )
// .draw();
// }
// } );
// } );
// } );
</script> 	
<div class="table-responsive">
<table class="table table-bordered datatable" id="table-3"> 
<thead> 
    
 

<tr class="replace-inputs"> 
<th>#</th> 
<th>amount</th>
<th>recipient account</th>
<th>destination country</th>
<th>sender acc</th>
<th>sender id</th>
<th>date of trans</th>
<th>recipient name</th>
<th>bank recieveing transfer</th>
<th>bank account balance</th>
<th>type of transaction</th>
<th>trans description</th>
<th>Senders name </th>
<th>status</th>
<th>transaction id</th>
<th>iban number</th>
<th>routing/swift number</th>
<th>debit type</th>
<th>Time</th>
<th>Actions</th>  
</tr> 
</thead> 
<tbody> <?php
$counter = 0;
foreach ($users as $fetch) {
$counter++;
?>
<tr> 
<td><?php echo $counter ?></td>
<td><?php echo $fetch["amount"]; ?></td>
<td><?php echo $fetch["recipient_acc"]; ?></td>
<td><?php echo $fetch["destination_country"]; ?></td>
<td><?php echo $fetch["sender_acc"]; ?></td>
<td><?php echo $fetch["sender_id"]; ?></td>
<td><?php echo $fetch["date_of_trans"]; ?></td>
<td><?php echo $fetch["recipient_name"]; ?></td>
<td><?php echo $fetch["bank"]; ?></td>
<td><?php echo $fetch["bank_accbal"]; ?></td>
<td><?php echo $fetch["type_of"]; ?></td>
<td><?php echo $fetch["trans_des"]; ?></td> 
<td><?php echo $fetch["from_"]; ?></td>
<td><?php echo $fetch["status"]; ?></td>
<td><?php echo $fetch["trans_id"]; ?></td>
<td><?php echo $fetch["iban"]; ?></td>
<td><?php echo $fetch["rout"]; ?></td> 
<td><?php echo $fetch["debit_type"]; ?></td>
<td><?php echo facebook_time_ago($fetch["date_of_trans"]);?></td>
<td> 
<a href="#" class="btn btn-default btn-sm btn-icon icon-left" data-userid="<?php echo $fetch['id']; ?>" onclick="showModal(this, 'modal-7')"> 
<i class="entypo-pencil">
</i>
Edit
</a> 

<script type="text/javascript">
//   function showModal(element, modalId) {
//     var userId = element.getAttribute('data-userid');
    
//     // jQuery('#' + modalId + ' .modal-title').text('Fund User Account');
    
//     jQuery('#' + modalId).modal('show', { backdrop: 'static' });
//     document.addEventListener("DOMContentLoaded", function() {
 
//  var p = document.getElementById('one').value = userId;
// });
 
//   console.log(p);
//   }

  function showModal(element, modalId) {
    var userId = element.getAttribute('data-userid');
    jQuery('#' + modalId).modal('show', { backdrop: 'static' });
    document.getElementById('one').value = userId;
  }

 
</script>
</script>
<a href="#" class="btn btn-danger btn-sm btn-icon icon-left deleteButton" data-userid="<?php echo $fetch['id']; ?>" > 
<i class="entypo-cancel">
</i>
<div id="error"></div>
Delete
</a> 
<!-- <a href="#" class="btn btn-info btn-sm btn-icon icon-left" > 
<i class="entypo-info">
</i>
Profile
</a>  -->
</td> 
<td>
<!-- <a href="javascript:;" onclick="jQuery('#modal-6').modal('show', {backdrop: 'static'});" class="btn btn-default"> 
<i class="entypo-info">
</i>
Fund user
</a>  -->


<div class="modal fade" id="modal-7"> 
<div class="modal-dialog"> 
<div class="modal-content"> 
<div class="modal-header"> 
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> 
<h4 class="modal-title">Edit Transaction</h4> 

</div> 
<div class="modal-body"> 
<form method="post" action="" id="Register">
<div id="call"></div>
<div class="row"> 
<div class="col-md-12"> 

<input type="hidden" name="id" class="form-control" id="one" value=""> 

<div class="form-group"> 
<label for="field-1" class="control-label">recipient account</label> 
<input type="number" name="recipient_acc" class="form-control" id="field-1" placeholder=""> 
</div>
</div> 
</div> 
<div class="row"> 
<div class="col-md-12"> 
<div class="form-group"> 
<label for="field-3" class="control-label">sender account</label> 
<input type="number" class="form-control" name="sender_acc" id="field-3" placeholder=""> 
</div> 
</div> 
</div>    
<div class="row"> 
<div class="col-md-12"> 
<div class="form-group"> 
<label for="field-3" class="control-label">date of transaction</label> 
<p>Note mustdate of transaction<br> be in this format 10-07-2023 06:59:24 pm <br>if possible copy and edit</p>
<input type="text" class="form-control" name="date_of_trans" id="field-3" placeholder=""> 
</div> 
</div> 
</div> 
<div class="row"> 
<div class="col-md-12"> 
<div class="form-group"> 
<label for="field-3" class="control-label">recipient name</label> 
<input type="text" class="form-control" name="recipient_name" id="field-3" placeholder=""> 
</div> 
</div> 
</div> 
<div class="row"> 
<div class="col-md-12"> 
<div class="form-group"> 
<label for="field-3" class="control-label">recipient bank</label> 
<input type="text" class="form-control" name="bank" id="field-3" placeholder=""> 
</div> 
</div> 
</div> 
<div class="row"> 
<div class="col-md-12"> 
<div class="form-group"> 
<label for="field-3" class="control-label">transaction description</label> 
<input type="text" class="form-control" maxlength="" name="trans_des" id="field-3" placeholder=""> 
</div> 
</div> 
</div> 
<div class="row"> 
<div class="col-md-12"> 
<div class="form-group"> 
<label for="field-3" class="control-label">sender's name</label> 
<input type="text" class="form-control" maxlength="" name="from_" id="field-3" placeholder=""> 
</div> 
</div> 
</div> 
<div class="row"> 
<div class="col-md-12"> 
<div class="form-group"> 
<label for="field-3" class="control-label">status</label>
<p>status must be either Approved/Declined</p>
<input type="text" class="form-control" maxlength="" name="status" id="field-3" placeholder=""> 
</div> 
</div> 
</div> 
</div> 
<div class="modal-footer"> 
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button> 
<button type="submit" class="btn btn-info" >Edit Transaction</button> 
</div> 
</form>
</div> 
</div> 
</div>
</td>

</tr>  
<?php
}
?>
 
</tfoot> 
</table> 
<br/> 

<br/>  
</div>
 
</div>      
</div> 
<script src="../js/jquery-3.5.1.js"></script>
<script src="../js/Admin_fund.js"></script>
<script src="../js/Admin_edit_transaction.js"></script>

<link rel="stylesheet" href="assets/js/datatables/datatables.css" id="style-resource-1"> 
<link rel="stylesheet" href="assets/js/select2/select2-bootstrap.css" id="style-resource-2"> 
<link rel="stylesheet" href="assets/js/select2/select2.css" id="style-resource-3"> 
<script src="assets/js/gsap/TweenMax.min.js" id="script-resource-1"></script> 
<script src="assets/js/jquery-ui/js/jquery-ui-1.10.3.minimal.min.js" id="script-resource-2"></script> 
<script src="assets/js/bootstrap.js" id="script-resource-3"></script> 
<script src="assets/js/joinable.js" id="script-resource-4"></script> 
<script src="assets/js/resizeable.js" id="script-resource-5"></script> 
<script src="assets/js/neon-api.js" id="script-resource-6"></script> 
<script src="assets/js/cookies.min.js" id="script-resource-7"></script> 
<script src="assets/js/datatables/datatables.js" id="script-resource-8"></script> 
<script src="assets/js/select2/select2.min.js" id="script-resource-9"></script> 
<script src="assets/js/neon-chat.js" id="script-resource-10"></script>  
<script src="assets/js/neon-custom.js" id="script-resource-11"></script>  
<script src="assets/js/neon-demo.js" id="script-resource-12"></script> 
<script src="assets/js/gsap/TweenMax.min.js" id="script-resource-1">
</script> 
<script src="assets/js/jquery-ui/js/jquery-ui-1.10.3.minimal.min.js" id="script-resource-2">
</script> 
<script src="assets/js/bootstrap.js" id="script-resource-3">
</script> 
  
 
<script src="assets/js/neon-skins.js" id="script-resource-11">
</script> 
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-28991003-7']);
_gaq.push(['_setDomainName', 'demo.neontheme.com']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();

function GetURLParameter(sParam)
{
    var sPageURL = window.location.search.substring(1);
    var sURLVariables = sPageURL.split('&');
    for (var i = 0; i < sURLVariables.length; i++)
    {
        var sParameterName = sURLVariables[i].split('=');
        if (sParameterName[0] == sParam)
        {
            return decodeURIComponent(sParameterName[1]);
        }
    }
}
var id = GetURLParameter('id');
if (id) {
var id = GetURLParameter('id');
}
</script> 
 
<script>
  $(document).ready(function() {
    $('.deleteButton').click(function() {
      var userId = $(this).data('userid');
 console.log(userId);
      $.ajax({
        url: '../includes/delete_Transact',
        type: 'POST',
        data: { userId: userId },
        success: function(response) {
          // Handle the response from the server after successful deletion
          console.log(response);          
          alert(response);

// Reload the page
location.reload();
        },
        error: function(xhr, status, error) {
          // Handle any error that occurred during the AJAX request
          console.log(error);

        }
      });
    });
  });
</script>

<script>
 
 function toggleUserEnabled(userId) {
  console.log(userId);
  $.ajax({
    url: '../includes/update_database',
    type: 'POST',
    data: { userId: userId },
    success: function(response) {
      // Handle the response from the server after successful update
      if (response === 'Login Enabled successfully') {
        alert(response);
        $('#toggle-' + userId).addClass('disabled');
        $('#toggle-' + userId).text('Enable');
        $('#toggleButton-' + userId).removeClass('disabled');
        


      }

      // Reload the page if needed
      // location.reload();
    },
    error: function(xhr, status, error) {
      // Handle any error that occurred during the AJAX request
      console.log(error);
    }
  });
}

function toggleUserLogin(userId) {
  console.log(userId);
  $.ajax({
    url: '../includes/update_database_new',
    type: 'POST',
    data: { userId: userId },
    success: function(response) {
      // Handle the response from the server after successful update
      if (response === 'Login disabled successfully') {
        alert(response);
        $('#toggleButton-' + userId).addClass('disabled');
        $('#toggleButton-' + userId).text('Disable');
        $('#toggle-' + userId).removeClass('disabled');
        
      }

      // Reload the page if needed
      // location.reload();
    },
    error: function(xhr, status, error) {
      // Handle any error that occurred during the AJAX request
      console.log(error);
    }
  });
}
</script>
</body> 
</html>