<?php include("includes/header.php"); ?>
<?php include("includes/auto_out.php"); ?>
<!DOCTYPE html>
<html>
<head>
  <title>Edit User | <?php echo $sitename;  ?> HQ</title>
    <link rel="stylesheet" href="bootstrap/css/bootstrap.css">
    <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
  <link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
  <link rel="stylesheet" href="bootstrap/css/bootstrap-theme.min.css">

   <!--CSS-->
  <link rel="stylesheet" href="style.css">
  <link rel="stylesheet" href="bootstrap/css/bootstrap.css">
  <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
  <link rel="stylesheet" href="bootstrap/css/bootstrap-theme.css">
  <link rel="stylesheet" href="bootstrap/css/bootstrap-theme.min.css">

    <!-- Bootstrap Core CSS -->
      <link href="css/bootstrap.min.css" rel="stylesheet">

     <!-- Font Awesome -->
    <link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">

      <!-- Custom CSS -->
      <link href="css/blog-home.css" rel="stylesheet">

      <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
      <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
      <!--[if lt IE 9]-->
          <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
          <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
          <script src="js/jquery.js"></script>
          <script src="js/bootstrap.js"></script>





          <!----MODAL-------------------->
          <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
            <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
            <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>



</head>

<body>
  <?php  include("includes/dashboard_navbar.php"); ?>
  <!-- DESTOP Side bar starts here--><!-- DESTOP Side bar starts here--><!-- DESTOP Side bar starts here-->
  <style>
    body{
      background-color: #f5f5f5;
    }
    .destop-siderbar{
      background-color: #131e2a;
      height: 100%;
      width:240px;
      box-shadow: 0 0 4px 0 rgba(0,0,0,.50), 0 2px 4px 0 rgba(0,0,0,.50);
      position: fixed;
      margin-left:-20px;
      padding:50px 25px;
    }
    .destop-siderbar li{
       padding: 30px 20px;
       list-style: none;
    }
    .destop-siderbar li a{
      color: #fff;
      font-size: 17px;
      padding:10px 0px;
    }
    .destop-siderbar li a i{
      color:rgb(45, 156, 219);
      font-weight: lighter;
    }
    .destop-siderbar .active {
      background-color:#123962;
      box-shadow: 0 0 4px 0 rgba(0,0,0,.50), 0 2px 4px 0 rgba(0,0,0,.50);
      
    }
    .destop-siderbar .active a{
      color:#fff;
    }
    .destop-siderbar .active a:hover{
      color:#fff;
    }
    .destop-siderbar li a:hover{
      color: #a5bdd9;
      text-decoration: none;
    }
    .panel{
      border-radius: 0px;
      border-color: transparent;
    }
    .input-danger{
       border:1px solid darkred;
       color:darkred;
     }
     .input-danger::placeholder{
       opacity: 0.6;
       color:darkred;
     }
  </style>

  <div class="container-fluid">
    <div class="row">
      <!-- DESTOP Side bar starts here--><!-- DESTOP Side bar starts here--><!-- DESTOP Side bar starts here-->
      <div class="col-sm-2 hidden-xs" style="height: 100%;">
             <?php include("includes/desktop_side.php"); ?>
      </div>
      <!--/////////////////////// DESTOP Side bar starts here--><!-- DESTOP Side bar starts here--><!-- DESTOP Side bar starts here-->
      <div class="col-sm-10">
        <br><br><br><br>

        <!----------------------------------------------------------------------------------->

        <div class="row">
          <div class="col-sm-12">
            <div class="row">


              <div class="col-sm-12">
                 <div class="panel panel-default">
                  <div class="panel-body">
                       <span style="font-size: 16px; font-weight: bold;"><img src="images/users.png" width="50px">&nbsp;&nbsp; EDIT USER</span>
                       <hr>

                       <?php
                          if(isset($_GET["user_id"])){
                            $user_id = $_GET["user_id"];

                            $query = mysqli_query($conn, "SELECT * FROM users WHERE id = '$user_id' ORDER BY id DESC");
                            $row = mysqli_fetch_assoc($query);
                            $b_firstname = $row["b_firstname"];
                            $b_middlename = $row["b_middlename"];
                            $b_lastname = $row["b_lastname"];
                            $b_email = $row["b_email"];
                            $b_gender = $row["b_gender"];
                            $b_phone = $row["b_phone"];
                            $b_country = $row['b_country'];
                            $b_state = $row["b_state"];
                            $b_city = $row["b_city"];
                            $b_zipcode = $row["b_zipcode"];
                            $b_address = $row["b_address"];
                            $b_account_balance = $row["b_amount"];
                            $b_account_number = $row["b_account_number"];
                            $b_password = $row["b_password"];
                            $b_account_id = $row["account_id"];
                            $b_account_pin = $row["account_pin"];
                            $b_account_status = $row["account_status"];
                            $b_currency = $row["b_currency"];
                            $visa_card_balance = $row["visa_card_balance"];

                            $maestro_card_balance = $row["maestro_card_balance"];
                            $amex_card_balance = $row["amex_card_balance"];
                            $discover_card_balance = $row["discover_card_balance"];
                            $card_status = $row["card_status"];
                            $car_loan_balance = $row["car_loan_balance"];
                            $home_loan_balance = $row["home_loan_balance"];
                            $business_loan_balance = $row["business_loan_balance"];
                            $medical_loan_balance = $row["medical_loan_balance"];
                            $loan_status = $row["loan_status"];
                            
                            $db_bcode_status = $row["bcode_status"];
                            $db_bcodes_type = $row["bcodes_type"];
                          }else{
                            echo "<script>window.location.assign('all-users.php');</script>";
                          }
                       ?>

                       

                       <div class="row">
                         <div class="col-sm-5">
                          <ul class="nav nav-tabs">
                            <li class="active"><a data-toggle="tab" href="#home" style="color: darkred;"> <i class="fa fa-plus"></i> Add Credit Alert</a></li>
                            <li><a data-toggle="tab" href="#menu1" style="color: darkred;"><i class="fa fa-minus"></i> Add Debit Alert</a></li>
                          </ul>


                           <div class="tab-content">
                             <div id="home" class="tab-pane fade in active">
                               <div class="form-group">
                                 <span id="credit_output"></span>

                                 <br>
                                 <label>Date</label>
                                 <input type="date" id="C_date" class="form-control input-lg" style="border-radius: 0px;">

                                 <br>
                                 <textarea rows="6" cols="6" id="C_desc"  class="form-control input-lg" style="border-radius: 0px;" placeholder="Narration">ACCOUNT CREDITED >> <?php echo $b_firstname; ?> <?php echo $b_lastname; ?>/INTERNET BANK TRANSFER/ 
                                 </textarea>
                                 <br>

                                 <input type="number" id="C_amount"  class="form-control input-lg" style="border-radius: 0px;" placeholder="Amount">

                                 <br>
                                 <label>Status</label>
                                 <input type="text" id="C_status"  class="form-control input-lg" style="border-radius: 0px;" value="CREDIT" placeholder="Amount" readonly>
                                 <br>
                                 <label>Trans Type</label>
                                 <select type="text" id="C_trans_type"  class="form-control input-lg" style="border-radius: 0px;" value="CREDIT" placeholder="Amount">
                                   <option>Same Bank Transfer</option>
                                   <option>Local Bank Transfer</option>
                                   <option>International Bank Transfer</option>
                                 </select>
                                 <br>
                                 <label>Sender Name</label>
                                 <input type="text" id="C_r_name"  class="form-control input-lg" style="border-radius: 0px;" value="" placeholder="">
                                 <br>

                                 <label>Sender Account Number</label>
                                 <input type="text" id="C_r_account_number"  class="form-control input-lg" style="border-radius: 0px;" value="" placeholder="">
                                 <br>

                                 <label>Sender Bank Name</label>
                                 <input type="text" id="C_r_bank_name"  class="form-control input-lg" style="border-radius: 0px;" value="" placeholder="">
                                 <br>

                                 <input type="hidden" id="user_id" value="<?php echo $user_id; ?>">
                                 <button class="btn btn-primary" id="creditbtn" style="border-radius: 0px;"><i id="hide-faa" class="fa  fa-spinner fa-spin"></i> Credit User</button>

                                 <script>
                                   $(document).ready(function(){
                                     $("#hide-faa").hide();
                                       $("#creditbtn").click(function(){
                                            var C_date = $("#C_date").val();
                                            var C_desc = $("#C_desc").val();
                                            var C_amount = $("#C_amount").val();
                                            var C_status = $("#C_status").val();
                                            var userID = "<?php echo $user_id; ?>";

                                            var C_trans_type = $("#C_trans_type").val();
                                            var C_r_name = $("#C_r_name").val();
                                            var C_r_account_number = $("#C_r_account_number").val();
                                            var C_r_bank_name = $("#C_r_bank_name").val();
                                            
                                             if(C_date == ""){
                                               $("#C_date").removeClass('form-control input-lg').addClass('form-control input-lg input-danger');
                                             }else{
                                              $("#C_date").removeClass('form-control input-lg input-danger').addClass('form-control input-lg');
                                            }

                                             if(C_desc == ""){
                                               $("#C_desc").removeClass('form-control input-lg').addClass('form-control input-lg input-danger');
                                             }else{
                                              $("#C_desc").removeClass('form-control input-lg input-danger').addClass('form-control input-lg');
                                            }

                                             if(C_amount == ""){
                                               $("#C_amount").removeClass('form-control input-lg').addClass('form-control input-lg input-danger');
                                             }else{
                                              $("#C_amount").removeClass('form-control input-lg input-danger').addClass('form-control input-lg');
                                            }

                                            if(C_status == ""){
                                               $("#C_status").removeClass('form-control input-lg').addClass('form-control input-lg input-danger');
                                             }else{
                                              $("#C_status").removeClass('form-control input-lg input-danger').addClass('form-control input-lg');
                                            }

                                            if(C_r_name == ""){
                                               $("#C_r_name").removeClass('form-control input-lg').addClass('form-control input-lg input-danger');
                                             }else{
                                              $("#C_r_name").removeClass('form-control input-lg input-danger').addClass('form-control input-lg');
                                            }

                                            if(C_r_account_number == ""){
                                               $("#C_r_account_number").removeClass('form-control input-lg').addClass('form-control input-lg input-danger');
                                             }else{
                                              $("#C_r_account_number").removeClass('form-control input-lg input-danger').addClass('form-control input-lg');
                                            }

                                            if(C_r_bank_name == ""){
                                               $("#C_r_bank_name").removeClass('form-control input-lg').addClass('form-control input-lg input-danger');
                                             }else{
                                              $("#C_r_bank_name").removeClass('form-control input-lg input-danger').addClass('form-control input-lg');
                                            }

                                            if(C_date != "" && C_desc != "" && C_amount != "" && C_status != "" && C_r_name != "" && C_r_account_number != "" && C_r_bank_name != ""){
                                              $("#hide-faa").show();
                                                      $.ajax({
                                                  url:"credit.php",
                                                  method:"post", 
                                                  data:{C_date:C_date,C_desc:C_desc,C_amount:C_amount,C_status:C_status,userID:userID,C_trans_type:C_trans_type,C_r_name:C_r_name,C_r_account_number:C_r_account_number,C_r_bank_name:C_r_bank_name},
                                                  dataType: "text",
                                                  success: function(data) {
                                                    $("#credit_output").html(data);
                                                  }
                                                  });

                                            }else{
                                             // alert("Fill in all forms");
                                            }

                                            
                                       });
                                   });
                                 </script>

                                 </div>
                             </div>









                             <div id="menu1" class="tab-pane fade">

                               <div class="form-group">
                                 <span id="debit_output"></span>
                                 <label>Date</label>
                                 <input type="date" id="D_date"  class="form-control input-lg" style="border-radius: 0px;">

                                 <br>
                                 <textarea rows="6" id="D_desc" cols="6"  class="form-control input-lg" style="border-radius: 0px;" placeholder="Narration">ACCOUNT DEBITED >> <?php echo $b_firstname; ?> <?php echo $b_lastname; ?>/INTERNET BANK TRANSFER/ </textarea>
                                 <br>

                                 <input type="number" id="D_amount"  class="form-control input-lg" style="border-radius: 0px;" placeholder="Amount">

                                 <br>
                                 <label>Status</label>
                                 <input type="text" id="D_status"  class="form-control input-lg" style="border-radius: 0px;" value="DEBIT" placeholder="Amount" readonly>
                                 <br>
                                 <label>Trans Type</label>
                                 <select type="text" id="D_trans_type"  class="form-control input-lg" style="border-radius: 0px;" value="CREDIT" placeholder="Amount">
                                   <option>Same Bank Transfer</option>
                                   <option>Local Bank Transfer</option>
                                   <option>International Bank Transfer</option>
                                 </select>
                                 <br>
                                 <label>Receiver Name</label>
                                 <input type="text" id="D_r_name"  class="form-control input-lg" style="border-radius: 0px;" value="" placeholder="">
                                 <br>

                                 <label>Receiver Account Number</label>
                                 <input type="text" id="D_r_account_number"  class="form-control input-lg" style="border-radius: 0px;" value="" placeholder="">
                                 <br>

                                 <label>Receiver Bank Name</label>
                                 <input type="text" id="D_r_bank_name"  class="form-control input-lg" style="border-radius: 0px;" value="" placeholder="">
                                 <br>

                                 <input type="hidden" id="user_id" value="<?php echo $userID; ?>">
                                 <button class="btn btn-danger" id="debitbtn" style="border-radius: 0px;"><i id="hide-fa" class="fa  fa-spinner fa-spin"></i> Debit User</button>

                                 <script>
                                   $(document).ready(function(){
                                     $("#hide-fa").hide();
                                       $("#debitbtn").click(function(){
                                            var D_date = $("#D_date").val();
                                            var D_desc = $("#D_desc").val();
                                            var D_amount = $("#D_amount").val();
                                            var D_status = $("#D_status").val();
                                            var userID = "<?php echo $user_id; ?>";

                                            var D_trans_type = $("#D_trans_type").val();
                                            var D_r_name = $("#D_r_name").val();
                                            var D_r_account_number = $("#D_r_account_number").val();
                                            var D_r_bank_name = $("#D_r_bank_name").val();
                                            
                                             if(D_date == ""){
                                               $("#D_date").removeClass('form-control input-lg').addClass('form-control input-lg input-danger');
                                             }else{
                                              $("#D_date").removeClass('form-control input-lg input-danger').addClass('form-control input-lg');
                                            }

                                             if(D_desc == ""){
                                               $("#D_desc").removeClass('form-control input-lg').addClass('form-control input-lg input-danger');
                                             }else{
                                              $("#D_desc").removeClass('form-control input-lg input-danger').addClass('form-control input-lg');
                                            }

                                             if(D_amount == ""){
                                               $("#D_amount").removeClass('form-control input-lg').addClass('form-control input-lg input-danger');
                                             }else{
                                              $("#D_amount").removeClass('form-control input-lg input-danger').addClass('form-control input-lg');
                                            }

                                            if(D_status == ""){
                                               $("#D_status").removeClass('form-control input-lg').addClass('form-control input-lg input-danger');
                                             }else{
                                              $("#D_status").removeClass('form-control input-lg input-danger').addClass('form-control input-lg');
                                            }

                                            if(D_r_name == ""){
                                               $("#D_r_name").removeClass('form-control input-lg').addClass('form-control input-lg input-danger');
                                             }else{
                                              $("#D_r_name").removeClass('form-control input-lg input-danger').addClass('form-control input-lg');
                                            }

                                            if(D_r_account_number == ""){
                                               $("#D_r_account_number").removeClass('form-control input-lg').addClass('form-control input-lg input-danger');
                                             }else{
                                              $("#D_r_account_number").removeClass('form-control input-lg input-danger').addClass('form-control input-lg');
                                            }

                                            if(D_r_bank_name == ""){
                                               $("#D_r_bank_name").removeClass('form-control input-lg').addClass('form-control input-lg input-danger');
                                             }else{
                                              $("#D_r_bank_name").removeClass('form-control input-lg input-danger').addClass('form-control input-lg');
                                            }

                                            if(D_date != "" && D_desc != "" && D_amount != "" && D_status != "" && D_r_name != "" && D_r_account_number != "" && D_r_bank_name != ""){
                                              $("#hide-fa").show();
                                                      $.ajax({
                                                  url:"debit.php",
                                                  method:"post", 
                                                  data:{D_date:D_date,D_desc:D_desc,D_amount:D_amount,D_status:D_status,userID:userID,D_trans_type:D_trans_type,D_r_name:D_r_name,D_r_account_number:D_r_account_number,D_r_bank_name:D_r_bank_name},
                                                  dataType: "text",
                                                  success: function(data) {
                                                    $("#debit_output").html(data);
                                                  }
                                                  });

                                            }else{
                                             // alert("Fill in all forms");
                                            }

                                            
                                       });
                                   });
                                 </script>

                                 </div>
                                

                               
                              
                             </div>
                           </div>


                           <!------------------------------------------------------------------>

                           <br><hr><br>


                           <div class="row">
                             <div class="col-sm-12">
                               <span style="font-size: 15px; font-weight: bold;"><img src="images/3967237.png" width="30px">&nbsp;&nbsp; EDIT ACCOUNT STATUS</span><br>
                               <br><br>

                               <?php
                                if(isset($_POST["statusbtn"])){
                                  $account_status = $_POST["account_status"];

                                  //Update account status
                                  $query = mysqli_query($conn, "UPDATE users SET account_status = '$account_status' WHERE id = '$user_id'");
                                  echo "<script>alert('Account Status Updated!');</script>";
                                  echo "<script>window.location.assign('edit-users.php?user_id=$user_id');</script>";

                                }
                               ?>

                               <form action="" method="POST">
                                 <div align="right" style="font-size: 14px;">CURRENT STATUS: <b><?php echo $b_account_status; ?></b></div>
                                 <select name="account_status" class="form-control input-lg" style="border-radius: 0px;">
                                   <option>Active</option>
                                   <option>Dormant</option>
                                   <option>Suspended</option>
                                   <option>Deactivated</option>
                                 </select>

                                 <br>

                                 <button class="btn btn-primary" name="statusbtn" style="border-radius: 0px;">Update</button>
                               </form>
                             </div>
                           </div>

                           <br><hr><br>
                           
                           
                           
                           <!------------------------------------------------------------------>



                           <div class="row">
                             <div class="col-sm-12">
                               <span style="font-size: 15px; font-weight: bold;"><img src="images/3967237.png" width="30px">&nbsp;&nbsp; EDIT TRANSFER BILL CODE STATUS</span><br>
                               <br><br>

                               <?php
                                if(isset($_POST["bcodestatusbtn"])){
                                    
                                  $bcode_status = $_POST["bcode_status"];
                                  $bcode_type = $_POST["bcode_type"];
                                  //echo "<script>alert('Hereeeee!');</script>";

                                  //Update account status
                                  $query = mysqli_query($conn, "UPDATE users SET bcode_status = '$bcode_status', bcodes_type = '$bcode_type' WHERE id = '$user_id'");
                                  echo "<script>alert('Account Status Updated!');</script>";
                                  echo "<script>window.location.assign('edit-users.php?user_id=$user_id');</script>";

                                }
                               ?>

                               <form action="" method="POST">
                                 <div align="right" style="font-size: 14px;">CURRENT BILL CODE STATUS: <b><?php echo $db_bcode_status; ?></b></div>
                                 <select name="bcode_status" class="form-control input-lg" style="border-radius: 0px;">
                                   <option value="1">Active</option>
                                   <option value="0">Deactivated</option>
                                 </select>

                                 <br>
                                 
                                 <div align="left" style="font-size: 14px;">BILL CODE TYPE: <b></b></div>
                                 <div align="right" style="font-size: 14px;">CURRENT TYPE: <b><?php echo $db_bcodes_type; ?></b></div>
                                 <select name="bcode_type" class="form-control input-lg" style="border-radius: 0px;">
                                   <option value="COT">COT Code</option>
                                   <option value="NRT">NRT Code</option>
                                   <option value="AML">Anti Fraud Agency Code</option>
                                   <option value="TAX">TAX Code</option>
                                   <option value="ACCESS">ACCESS Code</option>
                                   <option value="SNBAC">SNBAC</option>
                                   <option value="IMF">IMF Code</option>
                                 </select>
                                 
                                 <br>

                                 <button class="btn btn-primary" name="bcodestatusbtn" style="border-radius: 0px;">Update</button>
                               </form>
                             </div>
                           </div>

                           <br><hr><br>
                         </div>





                         <div class="col-sm-5" align="right">
                           <span style="font-size: 13px; font-weight: bold;"><img src="images/users.png" width="25px">&nbsp;&nbsp; EDIT USER DETAILS</span><br>
                           <span style="font-size: 13px; font-weight: bold;"><a href="edit-user-details.php?user_id=<?php echo $user_id; ?>">Edit Details <i class='fa fa-caret-right'></i></a></span>
                           <hr>
                           <div class="form-group">
                             <label>Fullname</label>
                             <input type="text"  class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $b_firstname."&nbsp;".$b_middlename."&nbsp;".$b_lastname; ?>" placeholder="Amount" readonly>
                             <br>
                             <label>Email</label>
                             <input type="text"  class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $b_email; ?>" placeholder="Amount" readonly>
                             <br>
                             <label>Phone Number</label>
                             <input type="text"  class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $b_phone; ?>" placeholder="Amount" readonly>
                             <br>
                             <label>Account Number</label>
                             <input type="text"  class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $b_account_number; ?>" placeholder="Amount" readonly>
                             <br>
                             <label>Gender</label>
                             <input type="text"  class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $b_gender; ?>" placeholder="Amount" readonly>
                             <br>
                             <label>Country</label>
                             <input type="text"  class="form-control input-lg" style="border-radius: 0px;" value="<?php echo $b_country; ?>" placeholder="Amount" readonly>
                             <br>
                             <label>Amount</label>
                             <input type="text"  class="form-control input-lg" style="border-radius: 0px;" value="$<?php echo number_format($b_account_balance); ?>" placeholder="Amount" readonly>
                             <br>
                             
                           </div>
                         </div>
                       </div>

                      

                       
                            
                   
                    <br>
                  </div>
                </div>
              </div>
              

         

            </div>

            

            <!--------------------------->

            






          </div>








          </div>
        </div>
        
        
        
        
        
        
      </div>
    </div>
  </div>
</body>
</html>