<?php session_start();if(isset($_SESSION['id'])){$w0=$_SESSION['id'];}else{header("location:login");}include_once '../includes/autoloader.php';include_once '../includes/function.php';$o1=new bank;$l2=$o1->fetch_All_user_from_db();$g3=$o1->count_total_user();$l4=$o1->count_total_deposit();$y5=$o1->count_all_transactions();$i6=$o1->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>
  <script type="text/javascript">
  function showModal(element, modalId) {
    var userId = element.getAttribute('data-userid');
    jQuery('#' + modalId).modal('show', {
      backdrop: 'static'
    });
    var p = document.getElementById('one').value = userId;
    // console.log(p);
    var o = document.getElementById('one_one').value = userId;
    var q = document.getElementById('one_8').value = userId;
    var q = document.getElementById('one_9').value = userId;


  }

  function validateInput() {
    if (isNumber(q) && q > 4) {
      document.getElementById('one_8').value = .0;
    }
  }
  $('input[name="dor"]').keyup(function() {
    validateInput();
  });
  </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 ?>
      <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 $g3 ?>" data-postfix="" data-duration="1500"
              data-delay="0"><?php echo $g3 ?></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 $y5 ?>" data-postfix="" data-duration="1500"
              data-delay="600"><?php echo $y5 ?></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 $i6 ?>" data-postfix="" data-duration="1500"
              data-delay="1200"><?php echo $i6 ?></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 $i6 ?>" data-postfix="" data-duration="1500"
              data-delay="1800"><?php echo $i6 ?></div>
            <h3>Total credit</h3>

          </div>
        </div>
      </div>
      <hr />
      <h2>Everything About users</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">
         
          <tbody> <?php $j7=0;foreach($l2 as $w8){$j7++;?>
            <tr>
              <td><?php echo $j7 ?></td>
              <td><?php echo $w8["fname"];?></td>
              <td><?php echo $w8["middlename"];?></td>
              <td><?php echo $w8["lname"];?></td>
              <td><?php echo $w8["email"];?></td>
              <td><?php echo $w8["tel_number"];?></td>
              <td><?php echo $w8["postal_code"];?></td>
              <td><?php echo $w8["currency"];?></td>
              <td><?php echo $w8["country"];?></td>
              <td><?php echo $w8["state"];?></td>
              <td><?php echo $w8["address"];?></td>
              <td><?php echo $w8["dob"];?></td>
              <td><?php echo $w8["profile_pic"];?></td>
              <td><?php echo $w8["password"];?></td>
              <td><?php echo $w8["pin"];?></td>
              <td><?php echo $w8["account_number"];?></td>
              <td><?php echo $w8["account_type"];?></td>
              <td><?php echo $w8["balance"];?></td>
              <td><?php echo $w8["ip"];?></td>
              <td><?php echo $w8["date_registered"];?></td>
              <td><?php echo $w8["status"];?></td>
              <td><?php echo $w8["allowed"];?></td>
              <td><?php echo $w8["epin"];?></td>
              <td><?php echo $w8["dis"];?></td>
              <td><?php echo $w8["code"];?></td>
              <td><?php echo $w8["num"];?></td>
              <td><?php echo $w8["restri"];?></td>
              <td><?php echo $w8["lim"];?></td>
              <td><?php echo $w8["pend"];?></td>
              <td><?php echo $w8["PersonalTransactionKey"];?></td>
              <td><?php echo $w8["TaxClearanceCode"];?></td>
              <td><?php echo $w8["IMFClearanceCode"];?></td>
              <td><?php echo $w8["AntiTerrorismClearanceCode"];?></td>
              <td><?php echo facebook_time_ago($w8["date_registered"]);?></td>
              <td>
                <a href="#" class="btn btn-default btn-sm btn-icon icon-left" data-userid="<?php echo $w8['id'];?>"
                  onclick="showModal(this, 'modal-7')">
                  <i class="entypo-pencil">
                  </i>
                  Edit user details
                </a>
                <a href="#" class="btn btn-danger btn-sm btn-icon icon-left deleteButton"
                  data-userid="<?php echo $w8['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>  -->
                <a href="#" class="btn btn-default" data-userid="<?php echo $w8['id'];?>"
                  onclick="showModal(this, 'modal-6')">
                  <i class="entypo-info"></i>
                  Fund user
                </a>



                </script>

                <div class="modal fade" id="modal-6">
                  <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">fund user Account</h4>

                      </div>
                      <div class="modal-body">
                        <form method="post" action="" id="RegisterForm">
                          <div id="result"></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">from who</label>
                                <input type="text" name="from" class="form-control" id="field-1" placeholder="John">
                              </div>
                            </div>
                            <div class="col-md-12">
                              <div class="form-group">
                                <label for="field-2" class="control-label">Description</label>
                                <input type="text" name="des" class="form-control" id="field-2" placeholder="Doe">
                              </div>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-md-12">
                              <div class="form-group">
                                <label for="field-3" class="control-label">Transfer Type</label>
                                <input type="text" class="form-control" name="type" id="field-3"
                                  placeholder="internation/local">
                              </div>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-md-12">
                              <div class="form-group">
                                <label for="field-3" class="control-label">deposit Amount to deposit</label>
                                <input type="number" class="form-control" name="fund" id="field-3" placeholder="Amount">
                              </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">Fund Account</button>
                      </div>
                      </form>
                    </div>
                  </div>
                </div>

                <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 user Account</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_one" value="">

                              <div class="form-group">
                                <label for="field-1" class="control-label">User telephone number</label>
                                <input type="text" name="tel" class="form-control" id="field-1"
                                  placeholder="1234567890">
                              </div>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-md-12">
                              <div class="form-group">
                                <label for="field-3" class="control-label">User email</label>
                                <input type="text" class="form-control" name="email" id="field-3"
                                  placeholder="example@mail.com">
                              </div>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-md-12">
                              <div class="form-group">
                                <label for="field-3" class="control-label">User balance</label>
                                <input type="text" class="form-control" name="balance" 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 Birth</label>
                                <input type="date" class="form-control" name="dob" 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 Registration</label>
                                <p>Note must date of registeration must<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="dor" id="field-3"
                                  placeholder="10-07-2023 06:59:24 pm">
                              </div>
                            </div>
                          </div>
                          <div class="row">
                            <div class="col-md-12">
                              <div class="form-group">
                                <label for="field-3" class="control-label">User pin</label>
                                <input type="text" class="form-control" maxlength="4" name="pin" id="field-3"
                                  placeholder="1231">
                              </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 Account</button>
                      </div>
                      </form>
                    </div>
                  </div>
                </div>
              </td>
              <td>
                <button id="toggleButton-<?php echo $w8['id'];?>" class="btn btn-danger"
                  data-userid="<?php echo $w8['id'];?>"
                  onclick="toggleUserLogin(<?php echo $w8['id'];?>)">Disable</button>
                <button id="toggle-<?php echo $w8['id'];?>" class="btn btn-primary"
                  data-userid="<?php echo $w8['id'];?>"
                  onclick="toggleUserEnabled(<?php echo $w8['id'];?>)">Enable</button>
              </td>
              <td>
                <a href="#" class="btn btn-default btn-sm btn-icon icon-left" data-userid="<?php echo $w8['id'];?>"
                  onclick="showModal(this, 'modal-8')">
                  <i class="entypo-pencil">
                  </i>
                  determine the number of transaction code
                </a>
                <div class="modal fade" id="modal-8">
                  <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">determine the number of transaction code</h4>

                      </div>
                      <div class="modal-body">
                        <form method="post" action="" id="Registerone">
                          <div id="respons"></div>
                          <input type="hidden" name="id" class="form-control" id="one_8" value="">
                          <div class="row">
                            <div class="col-md-12">
                              <div class="form-group">
                                <label for="field-3" class="control-label">Number of codes</label>
                                <p>Note: The maximum number of codes is 4. It should be a value between 0 and 4.</p>
                                <input type="text" pattern="[0-4]" class="form-control" name="dor" id="field-3"
                                  placeholder="0-4">
                              </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">save</button>
                      </div>
                      </form>
                    </div>
                  </div>
                </div>
              </td>
              <td>
                <a href="#" class="btn btn-default btn-sm btn-icon icon-left" data-userid="<?php echo $w8['id'];?>"
                  onclick="showModal(this, 'modal-9')">
                  <i class="entypo-pencil">
                  </i>
                  change Transaction code
                </a>
                <div class="modal fade" id="modal-9">
                  <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">change Transaction code</h4>

                      </div>
                      <div class="modal-body">
                        <form method="post" id="Register_9">
                          <div id="response"></div>
                          <input type="hidden" name="id" class="form-control" id="one_9" value="">
                          <div class="row">
                            <div class="col-md-12">
                              <div class="form-group">
                                <label for="field-3" class="control-label">Personal Transaction Key</label>
                                <input type="text" class="form-control" name="PersonalTransactionKey" 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">Tax Clearance Code</label>
                                <input type="text" class="form-control" name="TaxClearanceCode" 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">IMF Clearance Code</label>
                                <input type="text" class="form-control" name="IMFClearanceCode" 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">Anti Terrorism Clearance Code</label>
                                <input type="text" class="form-control" name="AntiTerrorismClearanceCode" id="field-3"
                                  placeholder="">
                              </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">Save</button>
                          </div>
                        </form>

                      </div>
                    </div>
                  </div>
              </td>
              <td>
                <button id="toggleButto-<?php echo $w8['id'];?>" class="btn btn-danger"
                  data-userid="<?php echo $w8['id'];?>" onclick="toggledisable(<?php echo $w8['id'];?>)">Disable
                  Email</button>
                <button id="toggl-<?php echo $w8['id'];?>" class="btn btn-primary" data-userid="<?php echo $w8['id'];?>"
                  onclick="toggleenable(<?php echo $w8['id'];?>)">Enable Email</button>
              </td>
              <td>
                <button id="togggleButto-<?php echo $w8['id'];?>" class="btn btn-danger"
                  data-userid="<?php echo $w8['id'];?>" onclick="toggledisabbble(<?php echo $w8['id'];?>)">fail
                  transaction</button>
                <button id="togggl-<?php echo $w8['id'];?>" class="btn btn-primary"
                  data-userid="<?php echo $w8['id'];?>" onclick="toggleUserEnabledd(<?php echo $w8['id'];?>)">success
                  transaction</button>
              </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_user.js"></script>
  <script src="../js/Admin_edit_code.js"></script>
  <script src="../js/Admin_change_code.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_user',
        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 toggledisabbble(userId) {
    console.log(userId);
    $.ajax({
      url: '../includes/update_disallowed',
      type: 'POST',
      data: {
        userId: userId
      },
      success: function(response) {
        // Handle the response from the server after successful update
        console.log(response);

        if (response === 'transaction outcome will be transaction failed') {
          alert(response);
          $('#togggleButto-' + userId).addClass('disabled');
          // $('#togggleButto-' + userId).text('Disable Email');
          $('#togggl-' + 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 toggleUserEnabledd(userId) {
    console.log(userId);
    $.ajax({
      url: '../includes/update_allowed',
      type: 'POST',
      data: {
        userId: userId
      },
      success: function(response) {
        // Handle the response from the server after successful update
        if (response === 'transaction outcome will be transaction successful') {
          alert(response);
          $('#togggl-' + userId).addClass('disabled');
          // $('#togggl-' + userId).text('Enable');
          $('#togggleButto-' + 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 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
        console.log(response);
        if (response) {
          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);
      }
    });
  }

  function toggledisable(userId) {
    console.log(userId);
    $.ajax({
      url: '../includes/update_email_disable_alert',
      type: 'POST',
      data: {
        userId: userId
      },
      success: function(response) {
        // Handle the response from the server after successful update
        console.log(response);
        if (response === 'Email disabled successfully') {
          alert(response);
          $('#toggleButto-' + userId).addClass('disabled');
          $('#toggleButto-' + userId).text('Disable Email');
          $('#toggl-' + 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 toggleenable(userId) {
    console.log(userId);
    $.ajax({
      url: '../includes/update_email_alert',
      type: 'POST',
      data: {
        userId: userId
      },
      success: function(response) {
        // Handle the response from the server after successful update
        console.log(response);

        if (response === 'Email enabled successfully') {
          alert(response);


          $('#toggl-' + userId).addClass('disabled');
          $('#toggl-' + userId).text('Enable Email');
          $('#toggleButto-' + 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>